@preventive/triage 1.0.0-alpha.9 → 1.0.0-alpha.90

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 (448) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/README.md +16 -0
  3. package/api/reap.ts +16 -78
  4. package/cli.js +6 -0
  5. package/client/dependency-paths.d.ts +3 -0
  6. package/client/dependency-paths.js +36 -0
  7. package/client/finding-link.js +305 -0
  8. package/client/linked-findings.d.ts +1 -0
  9. package/client/linked-findings.js +115 -0
  10. package/common/bundle-commit.d.ts +1 -0
  11. package/common/bundle-commit.js +4 -0
  12. package/common/bundle-compare-diff.d.ts +6 -0
  13. package/common/bundle-compare-diff.js +378 -0
  14. package/common/bundle-compare-inputs.d.ts +3 -0
  15. package/common/bundle-compare-inputs.js +141 -0
  16. package/common/bundle-compare-versions.js +172 -0
  17. package/common/bundle-comparison.d.ts +8 -0
  18. package/common/bundle-comparison.js +69 -0
  19. package/common/bundle-imports.js +20 -0
  20. package/common/bundle-metadata.d.ts +15 -0
  21. package/common/bundle-metadata.js +226 -0
  22. package/common/bundle-pkg-of.d.ts +1 -0
  23. package/common/bundle-pkg-of.js +90 -0
  24. package/common/bundle-reasons.d.ts +6 -0
  25. package/common/bundle-reasons.js +58 -0
  26. package/common/bundle-source-links.d.ts +6 -0
  27. package/common/bundle-source-links.js +216 -0
  28. package/common/bundle-sourcemap.d.ts +10 -0
  29. package/common/bundle-sourcemap.js +100 -0
  30. package/common/bundle-sources.d.ts +10 -0
  31. package/common/bundle-sources.js +374 -0
  32. package/common/bundle-stats.js +41 -0
  33. package/common/bundle-tabs.js +1 -0
  34. package/common/code-language.js +80 -0
  35. package/common/default-scan-models.ts +37 -0
  36. package/common/dependency-reviews.d.ts +19 -0
  37. package/common/dependency-reviews.js +67 -0
  38. package/common/finding-duplicates.js +63 -0
  39. package/common/finding-filters.js +313 -0
  40. package/common/finding-id.js +47 -0
  41. package/common/finding-repo.d.ts +5 -0
  42. package/common/finding-repo.js +67 -0
  43. package/common/github-issue-labels.d.ts +3 -0
  44. package/common/github-issue-labels.js +42 -0
  45. package/common/github-pr.ts +56 -0
  46. package/common/gzip.js +59 -0
  47. package/common/line-diff.d.ts +15 -0
  48. package/common/line-diff.js +188 -0
  49. package/common/linked-workspace-groups.js +63 -0
  50. package/common/managed/agent-tasks.ts +292 -0
  51. package/common/managed/comments.ts +43 -0
  52. package/common/managed/dependency-routes.js +25 -0
  53. package/common/managed/directory-packages.ts +28 -0
  54. package/common/managed/finding-detail.d.ts +5 -0
  55. package/common/managed/finding-detail.js +75 -0
  56. package/common/managed/finding-values.d.ts +2 -0
  57. package/common/managed/finding-values.js +138 -0
  58. package/common/managed/github-agents.ts +114 -0
  59. package/common/managed/github-logins.ts +49 -0
  60. package/common/managed/lite-name.d.ts +2 -0
  61. package/common/managed/lite-name.js +20 -0
  62. package/common/managed/npm-packages.d.ts +9 -0
  63. package/common/managed/npm-packages.js +63 -0
  64. package/common/managed/permissions.ts +31 -0
  65. package/common/managed/report-content.ts +72 -0
  66. package/common/managed/report-filter.ts +120 -0
  67. package/common/managed/repository-alias.ts +65 -0
  68. package/common/managed/review-view-routes.js +23 -0
  69. package/common/managed/risk-routes.js +30 -0
  70. package/common/managed/roles.ts +48 -0
  71. package/common/managed/routes.d.ts +2 -0
  72. package/common/managed/routes.js +386 -0
  73. package/common/managed/scan-models.ts +6 -0
  74. package/common/managed/stasis-config.ts +7 -0
  75. package/common/managed/team-app.d.ts +19 -0
  76. package/common/managed/team-app.js +129 -0
  77. package/common/managed/team-filters.js +26 -0
  78. package/common/managed/triage.ts +83 -0
  79. package/common/managed/upload-seal.ts +126 -0
  80. package/common/npm-token.d.ts +2 -0
  81. package/common/npm-token.js +14 -0
  82. package/common/pretty-json.js +123 -0
  83. package/common/pretty-kinds.js +20 -0
  84. package/common/pretty-print.d.ts +7 -0
  85. package/common/pretty-print.js +41 -0
  86. package/common/pretty-sourcemap.js +70 -0
  87. package/common/repo-commit.d.ts +4 -0
  88. package/common/repo-commit.js +30 -0
  89. package/common/revalidation-conflicts.js +48 -0
  90. package/common/revalidation-input-groups.js +56 -0
  91. package/common/scan-server.ts +13 -0
  92. package/common/security-links.d.ts +5 -0
  93. package/common/security-links.js +33 -0
  94. package/common/server-info.ts +46 -0
  95. package/common/sourcemap-listing.js +78 -0
  96. package/common/sourcemap-mappings.js +136 -0
  97. package/common/sourcemap-unlist.js +85 -0
  98. package/common/stasis-files.d.ts +5 -0
  99. package/common/stasis-files.js +20 -0
  100. package/common/stasis-tgz.d.ts +6 -0
  101. package/common/stasis-tgz.js +27 -0
  102. package/common/utf8.d.ts +3 -0
  103. package/common/utf8.js +45 -0
  104. package/common/whitespace-insensitive.js +19 -0
  105. package/common/workspace-app.js +91 -0
  106. package/common/workspace-groups.js +176 -0
  107. package/out/activity.js +2 -0
  108. package/out/brotli-fallback.js +3 -3
  109. package/out/chunk-2XUEZHIP.js +28 -0
  110. package/out/chunk-3DOSBILK.js +4 -0
  111. package/out/chunk-55YIWY3H.js +5 -0
  112. package/out/chunk-5AVGKFMR.js +1 -0
  113. package/out/chunk-5PWEAEA5.js +1 -0
  114. package/out/chunk-6VOB5WXX.js +2 -0
  115. package/out/chunk-6Y6PZ2BU.js +9 -0
  116. package/out/chunk-74JZTGTO.js +11 -0
  117. package/out/chunk-7BKKYVWR.js +7 -0
  118. package/out/chunk-7C7DWL7I.js +1 -0
  119. package/out/chunk-7HP2VYIC.js +2 -0
  120. package/out/chunk-7YFJUT2P.js +1 -0
  121. package/out/chunk-A4BBBHQU.js +1 -0
  122. package/out/chunk-B64CTMVU.js +4 -0
  123. package/out/chunk-BEKYZCPX.js +14 -0
  124. package/out/chunk-BZJU5EEV.js +1 -0
  125. package/out/chunk-C4Z6ZBXV.js +10 -0
  126. package/out/chunk-CJVMNJDZ.js +3 -0
  127. package/out/chunk-CU3FPB3P.js +1 -0
  128. package/out/chunk-DEVAORP2.js +1 -0
  129. package/out/chunk-DUASGS2O.js +8 -0
  130. package/out/chunk-EEJA7JBI.js +13 -0
  131. package/out/chunk-ESXA7KID.js +1 -0
  132. package/out/chunk-FSU2PLJL.js +1 -0
  133. package/out/chunk-GO7FT4OD.js +1 -0
  134. package/out/chunk-GX5UXWT4.js +1 -0
  135. package/out/chunk-HGWFRZNC.js +267 -0
  136. package/out/chunk-IYPY47MC.js +1 -0
  137. package/out/chunk-JZAROLQT.js +40 -0
  138. package/out/chunk-K4XJHM2T.js +1 -0
  139. package/out/chunk-KP2XM324.js +6 -0
  140. package/out/chunk-LRWB6QVO.js +1 -0
  141. package/out/chunk-LVSLM7HB.js +1 -0
  142. package/out/chunk-LVW7WWV4.js +1 -0
  143. package/out/chunk-N57OWFKY.js +15 -0
  144. package/out/chunk-NRPC74AM.js +1 -0
  145. package/out/chunk-OOJM4CTU.js +1 -0
  146. package/out/chunk-PKLVXUEI.js +11 -0
  147. package/out/chunk-PLGH63UC.js +2 -0
  148. package/out/chunk-PNHBZGDD.js +1 -0
  149. package/out/chunk-PWFUOLZK.js +17 -0
  150. package/out/chunk-PXK7EU4V.js +1 -0
  151. package/out/chunk-QD3IBSF4.js +7 -0
  152. package/out/chunk-QI66YA4F.js +1 -0
  153. package/out/chunk-QRKFPLA4.js +80 -0
  154. package/out/chunk-R3NZFXVR.js +1 -0
  155. package/out/chunk-R5O6FAW4.js +2 -0
  156. package/out/chunk-RAM3GDAD.js +1 -0
  157. package/out/chunk-RPNO56H2.js +1 -0
  158. package/out/chunk-SMNFBOLO.js +10 -0
  159. package/out/chunk-SSPDMA6D.js +1 -0
  160. package/out/chunk-SZTCJVZJ.js +55 -0
  161. package/out/chunk-SZWPYLPC.js +1 -0
  162. package/out/chunk-TKPNRQNN.js +3 -0
  163. package/out/chunk-TUII34K2.js +1 -0
  164. package/out/chunk-UJP4PQJA.js +1 -0
  165. package/out/chunk-UJSJMXEG.js +1 -0
  166. package/out/chunk-UR4WYMIP.js +1 -0
  167. package/out/chunk-UTYWTUTC.js +1 -0
  168. package/out/chunk-VHEXSGGP.js +1 -0
  169. package/out/chunk-VYYUMYVW.js +9 -0
  170. package/out/chunk-WBK5ZN4K.js +3 -0
  171. package/out/chunk-WCDYSIKG.js +1 -0
  172. package/out/chunk-XM4RLC4A.js +2 -0
  173. package/out/chunk-XRAAYXPR.js +1 -0
  174. package/out/chunk-ZQHLECTI.js +1 -0
  175. package/out/client-managed-import.js +4 -0
  176. package/out/client-managed.js +35 -0
  177. package/out/client-sync.js +11 -17
  178. package/out/compare.js +26 -0
  179. package/out/dialogs.js +40 -0
  180. package/out/github-issue-authorized.html +3 -0
  181. package/out/github-issue-authorized.js +1 -0
  182. package/out/graph.js +19 -5
  183. package/out/index.html +105 -25
  184. package/out/prism.js +14 -10
  185. package/out/scan.js +2 -0
  186. package/out/stasis.svg +20 -0
  187. package/out/terminal.js +367 -39
  188. package/out/view.css +1 -1
  189. package/out/view.js +19 -148
  190. package/package.json +416 -64
  191. package/risk/actions/findings.js +161 -0
  192. package/risk/actions/resolve.js +287 -0
  193. package/risk/actions/scripts/commands.js +182 -0
  194. package/risk/actions/scripts/grade.js +113 -0
  195. package/risk/actions/scripts/packages.js +123 -0
  196. package/risk/actions/scripts/shell.js +169 -0
  197. package/risk/actions/uses.js +94 -0
  198. package/risk/actions/workflow.js +183 -0
  199. package/risk/files/characters.js +354 -0
  200. package/risk/files/hosts.js +206 -0
  201. package/risk/files/readability.js +185 -0
  202. package/risk/files/runs-code.js +568 -0
  203. package/risk/files/script.js +420 -0
  204. package/risk/files/source-map-link.js +43 -0
  205. package/risk/files/stamps.js +47 -0
  206. package/risk/index.d.ts +309 -0
  207. package/risk/index.js +12 -0
  208. package/risk/npm/assess.js +303 -0
  209. package/risk/npm/combined.js +68 -0
  210. package/risk/npm/compare.js +236 -0
  211. package/risk/npm/dependencies.js +172 -0
  212. package/risk/npm/diff.js +79 -0
  213. package/risk/npm/downloads.js +84 -0
  214. package/risk/npm/files.js +445 -0
  215. package/risk/npm/held.js +67 -0
  216. package/risk/npm/install-scripts.js +34 -0
  217. package/risk/npm/malware.js +38 -0
  218. package/risk/npm/manifest.js +65 -0
  219. package/risk/npm/new-dependency.js +60 -0
  220. package/risk/npm/old-version.js +108 -0
  221. package/risk/npm/registry.js +401 -0
  222. package/risk/npm/release.js +85 -0
  223. package/risk/npm/score.js +59 -0
  224. package/risk/npm/specs.js +124 -0
  225. package/risk/npm/tarball.js +169 -0
  226. package/server-common/database-config.ts +16 -0
  227. package/server-common/initialize.ts +18 -0
  228. package/server-common/npm-advisories.ts +101 -0
  229. package/{server → server-common}/origin.ts +5 -5
  230. package/server-common/reap.ts +48 -0
  231. package/server-common/scan-config.ts +19 -0
  232. package/server-common/standalone.ts +29 -0
  233. package/server-common/storage-crypto.ts +182 -0
  234. package/server-common/storage-log.ts +38 -0
  235. package/server-common/vercel-blob.ts +103 -0
  236. package/server-e2e/app.ts +487 -0
  237. package/{server → server-e2e}/bus-receiver.ts +2 -1
  238. package/{server → server-e2e}/cli.js +9 -4
  239. package/{server → server-e2e}/config.ts +52 -42
  240. package/{server → server-e2e}/db-neon.ts +2 -2
  241. package/{server → server-e2e}/db-revision-sql.ts +1 -1
  242. package/{server → server-e2e}/db-stmt.ts +2 -2
  243. package/{server → server-e2e}/db.ts +7 -7
  244. package/{server → server-e2e}/http.ts +44 -13
  245. package/{server → server-e2e}/hub.ts +40 -9
  246. package/server-e2e/index.ts +17 -0
  247. package/server-e2e/lifecycle.ts +95 -0
  248. package/{server → server-e2e}/neon-driver.ts +2 -2
  249. package/{server → server-e2e}/npm-proxy.ts +12 -145
  250. package/{server → server-e2e}/objstore/blob-vercel.ts +10 -114
  251. package/{server → server-e2e}/objstore/blob.ts +1 -1
  252. package/{server → server-e2e}/objstore/fetch-mint-guard.ts +2 -2
  253. package/{server → server-e2e}/objstore/handlers.ts +9 -8
  254. package/{server → server-e2e}/objstore/init.ts +19 -27
  255. package/{server → server-e2e}/objstore/reaper.ts +1 -1
  256. package/{server → server-e2e}/objstore/rest-deny.ts +1 -1
  257. package/{server → server-e2e}/objstore/rest-mint.ts +3 -3
  258. package/{server → server-e2e}/objstore/rest.ts +3 -3
  259. package/{server → server-e2e}/objstore/store-neon.ts +6 -10
  260. package/{server → server-e2e}/objstore/store.ts +7 -7
  261. package/{server → server-e2e}/objstore/tokens.ts +2 -2
  262. package/{server → server-e2e}/pubsub.ts +12 -9
  263. package/{server → server-e2e}/sign.ts +4 -4
  264. package/{server → server-e2e}/sse-server.ts +3 -3
  265. package/{server → server-e2e}/static.ts +18 -17
  266. package/{server → server-e2e}/sync-handlers.ts +56 -30
  267. package/{server → server-e2e}/ws-server.ts +20 -9
  268. package/server-managed/activity.ts +269 -0
  269. package/server-managed/agent-merges.ts +109 -0
  270. package/server-managed/app-agents.ts +23 -0
  271. package/server-managed/avatar-store.ts +21 -0
  272. package/server-managed/blob-store.ts +26 -0
  273. package/server-managed/brotli.ts +10 -0
  274. package/server-managed/bundle-advisories.ts +176 -0
  275. package/server-managed/bundle-advisory-inventory.ts +85 -0
  276. package/server-managed/bundle-build-diagnostics.d.ts +10 -0
  277. package/server-managed/bundle-build-diagnostics.js +23 -0
  278. package/server-managed/bundle-build-leases.ts +41 -0
  279. package/server-managed/bundle-build-worker.js +387 -0
  280. package/server-managed/bundle-build.ts +328 -0
  281. package/server-managed/bundle-cache.ts +261 -0
  282. package/server-managed/bundle-catalog.ts +29 -0
  283. package/server-managed/bundle-commits.ts +133 -0
  284. package/server-managed/bundle-dependency-reviews.ts +91 -0
  285. package/server-managed/bundle-store.ts +24 -0
  286. package/server-managed/bundle-summary-cache.ts +139 -0
  287. package/server-managed/bundle-validation.ts +33 -0
  288. package/server-managed/bundle.ts +151 -0
  289. package/server-managed/cache-storage.ts +20 -0
  290. package/server-managed/cli.js +21 -0
  291. package/server-managed/combined.ts +43 -0
  292. package/server-managed/comments.ts +138 -0
  293. package/server-managed/commit-coauthors.ts +105 -0
  294. package/server-managed/commit-lockfiles.ts +78 -0
  295. package/server-managed/comparison.ts +51 -0
  296. package/server-managed/config.ts +163 -0
  297. package/server-managed/content-access.ts +15 -0
  298. package/server-managed/crypto.ts +25 -0
  299. package/server-managed/db-methods.ts +1950 -0
  300. package/server-managed/db-neon.ts +401 -0
  301. package/server-managed/db-schema.ts +271 -0
  302. package/server-managed/db-table-names.ts +22 -0
  303. package/server-managed/db.ts +150 -0
  304. package/server-managed/dependabot-access.ts +85 -0
  305. package/server-managed/dependabot-alerts.ts +197 -0
  306. package/server-managed/dependency-review-comments.ts +158 -0
  307. package/server-managed/dependency-reviews.ts +369 -0
  308. package/server-managed/github-accounts.ts +59 -0
  309. package/server-managed/github-actions.ts +71 -0
  310. package/server-managed/github-app.ts +347 -0
  311. package/server-managed/github-errors.ts +92 -0
  312. package/server-managed/github-graphql.ts +42 -0
  313. package/server-managed/github-issue-links.ts +264 -0
  314. package/server-managed/github-issue-oauth.ts +30 -0
  315. package/server-managed/github-issues.ts +169 -0
  316. package/server-managed/github-link-oauth.ts +56 -0
  317. package/server-managed/github-links.ts +204 -0
  318. package/server-managed/github-metadata.ts +218 -0
  319. package/server-managed/github-oauth.ts +264 -0
  320. package/server-managed/github-pulls.ts +290 -0
  321. package/server-managed/github-requests.ts +181 -0
  322. package/server-managed/github-users.ts +53 -0
  323. package/server-managed/github-values.ts +26 -0
  324. package/server-managed/history-windows.ts +172 -0
  325. package/server-managed/http-response.ts +76 -0
  326. package/server-managed/http.ts +6722 -0
  327. package/server-managed/import-triage.ts +51 -0
  328. package/server-managed/index.ts +204 -0
  329. package/server-managed/kept-briefly.ts +37 -0
  330. package/server-managed/kept.ts +28 -0
  331. package/server-managed/known-listings.ts +112 -0
  332. package/server-managed/link-reports.ts +149 -0
  333. package/server-managed/listed-activity.ts +39 -0
  334. package/server-managed/locked-packages.ts +234 -0
  335. package/server-managed/lockfile-scope.ts +58 -0
  336. package/server-managed/lru.ts +30 -0
  337. package/server-managed/managed-issues.ts +92 -0
  338. package/server-managed/management-catalog.ts +45 -0
  339. package/server-managed/management.ts +116 -0
  340. package/server-managed/npm-delta-worker.js +203 -0
  341. package/server-managed/npm-delta.ts +277 -0
  342. package/server-managed/npm-insights.ts +455 -0
  343. package/server-managed/npm-kept.ts +274 -0
  344. package/server-managed/npm-loads.ts +259 -0
  345. package/server-managed/npm-manifest.ts +117 -0
  346. package/server-managed/npm-packages.ts +477 -0
  347. package/server-managed/npm-patch-paths.ts +86 -0
  348. package/server-managed/npm-patch.ts +457 -0
  349. package/server-managed/npm-provenance.ts +127 -0
  350. package/server-managed/npm-risk.ts +310 -0
  351. package/server-managed/object-storage-disk.ts +147 -0
  352. package/server-managed/object-storage-vercel.ts +71 -0
  353. package/server-managed/object-storage.ts +82 -0
  354. package/server-managed/package-entry-points.ts +127 -0
  355. package/server-managed/pretty-copies.ts +22 -0
  356. package/server-managed/pretty-format.d.ts +4 -0
  357. package/server-managed/pretty-format.js +27 -0
  358. package/server-managed/pretty-print.ts +444 -0
  359. package/server-managed/public-workspace.ts +242 -0
  360. package/server-managed/pull-comment-reviews.ts +161 -0
  361. package/server-managed/pull-dependencies.ts +370 -0
  362. package/server-managed/pull-dependency-reviews.ts +458 -0
  363. package/server-managed/pull-reviews.ts +202 -0
  364. package/server-managed/pulse-walk.ts +164 -0
  365. package/server-managed/queue.ts +54 -0
  366. package/server-managed/release-commits.ts +85 -0
  367. package/server-managed/rename-diff-worker.js +30 -0
  368. package/server-managed/rename-diff.ts +237 -0
  369. package/server-managed/repo-path.ts +21 -0
  370. package/server-managed/report-migration.ts +32 -0
  371. package/server-managed/report-opening.ts +77 -0
  372. package/server-managed/report-query.ts +10 -0
  373. package/server-managed/report-response.ts +16 -0
  374. package/server-managed/report-sources.ts +185 -0
  375. package/server-managed/report-store.ts +77 -0
  376. package/server-managed/repository-actions.ts +220 -0
  377. package/server-managed/repository-agents.ts +422 -0
  378. package/server-managed/repository-aliases.ts +119 -0
  379. package/server-managed/repository-browser.ts +362 -0
  380. package/server-managed/repository-changes.ts +280 -0
  381. package/server-managed/repository-code.ts +222 -0
  382. package/server-managed/repository-dependency-reviews.ts +220 -0
  383. package/server-managed/repository-discovery.ts +83 -0
  384. package/server-managed/repository-history.ts +444 -0
  385. package/server-managed/repository-issues.ts +293 -0
  386. package/server-managed/repository-policy.ts +27 -0
  387. package/server-managed/repository-pulls.ts +207 -0
  388. package/server-managed/repository-pulse.ts +409 -0
  389. package/server-managed/repository-risk-assess.ts +179 -0
  390. package/server-managed/repository-risk-audit.ts +145 -0
  391. package/server-managed/repository-risk-caches.ts +56 -0
  392. package/server-managed/repository-risk-kept.ts +86 -0
  393. package/server-managed/repository-risk-read.ts +296 -0
  394. package/server-managed/repository-risk-stasis.ts +61 -0
  395. package/server-managed/repository-risk-turn.ts +97 -0
  396. package/server-managed/repository-risk.ts +528 -0
  397. package/server-managed/repository-squashes.ts +160 -0
  398. package/server-managed/repository-stamp.ts +41 -0
  399. package/server-managed/request-timing.ts +63 -0
  400. package/server-managed/reviewed-dependencies.ts +170 -0
  401. package/server-managed/revisions.ts +35 -0
  402. package/server-managed/scan-downloads.ts +121 -0
  403. package/server-managed/session.ts +132 -0
  404. package/server-managed/slugs.ts +38 -0
  405. package/server-managed/solidity-entry-points.ts +71 -0
  406. package/server-managed/sql-postgres.ts +34 -0
  407. package/server-managed/sql.ts +107 -0
  408. package/server-managed/stasis-config.ts +147 -0
  409. package/server-managed/stasis-dependencies.ts +280 -0
  410. package/server-managed/static.ts +28 -0
  411. package/server-managed/storage-command.ts +16 -0
  412. package/server-managed/storage-db.ts +183 -0
  413. package/server-managed/storage-encryption.ts +288 -0
  414. package/server-managed/storage-maintenance.ts +259 -0
  415. package/server-managed/storage-payload.ts +121 -0
  416. package/server-managed/storage-stores.ts +91 -0
  417. package/server-managed/storage.ts +82 -0
  418. package/server-managed/team-app-summaries.ts +57 -0
  419. package/server-managed/team-app.ts +162 -0
  420. package/server-managed/team-catalog.ts +7 -0
  421. package/server-managed/team-feed.ts +180 -0
  422. package/server-managed/team-icons.ts +50 -0
  423. package/server-managed/team-npm-scopes.ts +103 -0
  424. package/server-managed/team-progress.ts +77 -0
  425. package/server-managed/team-reports.ts +369 -0
  426. package/server-managed/triage-response.ts +16 -0
  427. package/server-managed/type-only-proof.js +181 -0
  428. package/server-managed/type-only-worker.js +31 -0
  429. package/server-managed/type-only.ts +135 -0
  430. package/server-managed/uploads.ts +106 -0
  431. package/server-managed/upstream-cache.ts +275 -0
  432. package/server-managed/view-as.ts +58 -0
  433. package/server-managed/worker-turns.ts +76 -0
  434. package/server-managed/workspace-shares.ts +170 -0
  435. package/server.ts +70 -0
  436. package/strip-types-loader.js +13 -10
  437. package/server/index.ts +0 -480
  438. package/server/lifecycle.ts +0 -208
  439. /package/{LICENSE → LICENSE-MIT} +0 -0
  440. /package/{server → server-e2e}/auth.ts +0 -0
  441. /package/{server → server-e2e}/config.example.json +0 -0
  442. /package/{server → server-e2e}/objstore/blob-fs.ts +0 -0
  443. /package/{server → server-e2e}/objstore/fs.ts +0 -0
  444. /package/{server → server-e2e}/objstore/sign.ts +0 -0
  445. /package/{server → server-e2e}/peer.ts +0 -0
  446. /package/{server → server-e2e}/sse-session.ts +0 -0
  447. /package/{server → server-e2e}/util.ts +0 -0
  448. /package/{server → server-e2e}/validation.ts +0 -0
package/out/terminal.js CHANGED
@@ -1,39 +1,367 @@
1
- var Z=globalThis[Symbol.for("@rray/frontend")];if(!Z)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:Q,html:C,nothing:q,unsafeCSS:J,render:Sn,StateElement:vn,classMap:yn,repeat:$n,styleMap:kn}=Z;function tt(t,e){if(t.length===0)return{argv:[],quoted:new Set};let r=[t[0]],n=new Set;e.has(0)&&n.add(0);for(let s=1;s<t.length;s++){let i=t[s];if(e.has(s)){n.add(r.length),r.push(i);continue}for(let o of et(i))r.push(o)}return{argv:r,quoted:n}}function et(t){for(let e=0;e<t.length;e++){if(t[e]!=="{")continue;let r=Pt(t,e);if(r===-1)continue;let n=Bt(t.slice(e+1,r));if(n.length<2)continue;let s=t.slice(0,e),i=t.slice(r+1),o=[];for(let u of n)o.push(...et(s+u+i));return o}return[t]}function Pt(t,e){let r=1;for(let n=e+1;n<t.length;n++)if(t[n]==="{")r++;else if(t[n]==="}"&&(r--,r===0))return n;return-1}function Bt(t){let e=[],r=0,n=0;for(let s=0;s<t.length;s++)t[s]==="{"?r++:t[s]==="}"?r--:t[s]===","&&r===0&&(e.push(t.slice(n,s)),n=s+1);return e.push(t.slice(n)),e}function nt(t){let e=Xt(t);for(let s of e)if(s.kind==="amp")throw new Error("background processes (`&`) are not supported");for(;e.length>0&&e.at(-1).kind==="semi";)e.pop();let{steps:r,consumed:n}=st(e,0,!1);if(n!==e.length)throw new Error("unexpected `)`");return rt(r),r}function rt(t){for(let e of t){if(e.stages.length===0)throw new Error("empty pipeline stage");for(let r of e.stages)if(r.group)rt(r.group);else if(r.argv.length===0)throw new Error("empty pipeline stage")}}function st(t,e,r){let n=[{gate:"first",stages:[]}],s={argv:[],quoted:new Set},i=e;for(;i<t.length;){let o=t[i];if(o.kind==="paren_close"){if(!r)throw new Error("unexpected `)`");return Ht(n,s,i+1)}if(o.kind==="paren_open"){if(s.group||s.argv.length>0)throw new Error("unexpected `(`");let u=st(t,i+1,!0);s.group=u.steps,i=u.consumed;continue}if(o.kind==="pipe"||o.kind==="and"||o.kind==="or"||o.kind==="semi"){n.at(-1).stages.push(s),s={argv:[],quoted:new Set},o.kind==="and"?n.push({gate:"and",stages:[]}):o.kind==="or"?n.push({gate:"or",stages:[]}):o.kind==="semi"&&n.push({gate:"seq",stages:[]}),i++;continue}if(o.kind==="redir"){i=zt(s,t,i)+1;continue}if(s.group)throw new Error("unexpected token after `)`");o.quoted&&s.quoted.add(s.argv.length),s.argv.push(o.value),i++}if(r)throw new Error("unmatched `(`");return n.at(-1).stages.push(s),{steps:n,consumed:i}}function Ht(t,e,r){let n=t.at(-1);if(!e.group&&e.argv.length===0&&!Gt(e)&&n.stages.length===0){if(t.length===1)throw new Error("empty subshell `()`");t.pop()}else n.stages.push(e);return{steps:t,consumed:r}}function Gt(t){return!!(t.stdoutToNull||t.stderrToNull||t.mergeStderrToStdout||t.mergeStdoutToStderr)}function zt(t,e,r){let n=e[r],s=n.fd==="1"?"":n.fd;if(n.toFd)return n.fd==="2"&&n.toFd==="1"?t.mergeStderrToStdout=!0:n.fd==="1"&&n.toFd==="2"&&(t.mergeStdoutToStderr=!0),r;let i=e[r+1],o=s+">"+(n.append?">":"");if(n.append)throw new Error(`filesystem is read-only \u2014 \`${o}\` append is not supported; use \`|\` to pipe or \`${s}>/dev/null\` to discard`);if(!i||i.kind!=="word")throw new Error(`redirect \`${o}\` requires a target`);if(i.value!=="/dev/null")throw new Error(`filesystem is read-only \u2014 use \`|\` to pipe between commands, or \`${o}/dev/null\` to discard`);return n.fd==="1"?t.stdoutToNull=!0:t.stderrToNull=!0,r+1}function Xt(t){let e=[],r="",n=null,s=!1,i=!1,o=()=>{s&&e.push({kind:"word",value:r,quoted:i}),r="",s=!1,i=!1};for(let u=0;u<t.length;u++){let c=t[u];if(n){c===n?n=null:r+=c;continue}if(c==="'"||c==='"'){n=c,s=!0,i=!0;continue}if(!s&&(c==="1"||c==="2")&&t[u+1]===">"){if(o(),t[u+2]==="&"){let l=t[u+3],f=t[u+4];if((l==="1"||l==="2")&&(f===void 0||/[\s|&>;()]/u.test(f))){e.push({kind:"redir",fd:c,toFd:l}),u+=3;continue}throw new Error(`redirect \`${c}>&\` requires fd 1 or 2 followed by a token boundary`)}t[u+2]===">"?(e.push({kind:"redir",fd:c,append:!0}),u+=2):(e.push({kind:"redir",fd:c,append:!1}),u+=1);continue}if(c==="|"){o(),t[u+1]==="|"?(e.push({kind:"or"}),u++):e.push({kind:"pipe"});continue}if(c==="&"){o(),t[u+1]==="&"?(e.push({kind:"and"}),u++):e.push({kind:"amp"});continue}if(c===">"){o(),t[u+1]===">"?(e.push({kind:"redir",fd:"1",append:!0}),u++):e.push({kind:"redir",fd:"1",append:!1});continue}if(c===";"){o(),e.push({kind:"semi"});continue}if(c==="("){o(),e.push({kind:"paren_open"});continue}if(c===")"){o(),e.push({kind:"paren_close"});continue}if(/\s/u.test(c)){o();continue}r+=c,s=!0}if(n)throw new Error(`unterminated ${n==="'"?"single":"double"} quote`);return o(),e}function p(t,e={}){let r=D(e.short),n=D(e.long),s=D(e.valueShort),i=D(e.valueLong),o=D(e.repeatable),u=e.stopAtFirstPositional??!1,c=new Set,l=new Map,f=[];for(let a=0;a<t.length;a++){let d=t[a];if(d==="--"){f.push(...t.slice(a+1));break}if(/^-+$/u.test(d)){f.push(d);continue}if(d.startsWith("--")&&d.length>2){let m=d.slice(2);if(i.has(m)||o.has(m))O(l,o,m,it(t,++a,`--${m}`));else if(n.has(m))c.add(m);else throw new Error(`unknown option: --${m}`);continue}if(d.startsWith("-")&&d.length>1&&!/^-\d/u.test(d)){a=Vt(t,a,r,s,o,c,l);continue}if(u){f.push(...t.slice(a));break}f.push(d)}return{flags:c,values:l,positional:f}}function D(t){return t instanceof Set?t:new Set(t??[])}function it(t,e,r){if(e>=t.length)throw new Error(`${r} requires an argument`);return t[e]}function O(t,e,r,n){if(!e.has(r)){t.set(r,n);return}let s=t.get(r);s?s.push(n):t.set(r,[n])}function Vt(t,e,r,n,s,i,o){let u=t[e].slice(1);for(let c=0;c<u.length;c++){let l=u[c];if(n.has(l)||s.has(l))return c+1<u.length?(O(o,s,l,u.slice(c+1)),e):(O(o,s,l,it(t,++e,`-${l}`)),e);if(!r.has(l))throw new Error(`unknown option: -${l}`);i.add(l)}return e}function M(t){let e=t.startsWith("/"),r=t.split("/").filter(Boolean),n=[];for(let s of r)if(s!=="."){if(s===".."){n.length>0&&n.at(-1)!==".."?n.pop():e||n.push("..");continue}n.push(s)}return e?"/"+n.join("/"):n.length===0?".":n.join("/")}function w(t,e){return e.startsWith("/")?M(e):M(t+"/"+e)}function I(t){let e=M(t);if(e==="/")return"/";let r=e.lastIndexOf("/");return r<0?".":r===0?"/":e.slice(0,r)}function F(t){let e=M(t);if(e==="/")return"/";let r=e.lastIndexOf("/");return e.slice(r+1)}function A(t,e){return t==="/"?"/"+e:t+"/"+e}function L(t,e){return t==="/"?e.slice(1):e.slice(t.length+1)}function ot(t){let e=new Map,r=t instanceof Map?t.entries():Object.entries(t??{});for(let[i,o]of r)typeof o=="string"&&e.set(M("/"+String(i)),o);let n=new Map([["/",{dirs:[],files:[]}]]);for(let i of e.keys()){let o=I(i);Kt(n,o),n.get(o).files.push(F(i))}for(let i of n.values())i.dirs.sort(),i.files.sort();let s={isFile:i=>e.has(i),isDir:i=>n.has(i),readFile:i=>e.get(i),listDir:i=>{let o=n.get(i);if(!o)throw new Error(`not a directory: ${i}`);return o},walkFiles:i=>Ut(s,i)};return s}function*P(t,e,r=Number.POSITIVE_INFINITY){if(t.isFile(e)){yield{path:e,kind:"file",depth:0};return}if(!t.isDir(e))return;yield{path:e,kind:"dir",depth:0};let n=[{path:e,depth:0}];for(let s=0;s<n.length;s++){let i=n[s];if(i.depth>=r)continue;let{dirs:o,files:u}=t.listDir(i.path),c=i.depth+1;for(let l of o){let f=A(i.path,l);yield{path:f,kind:"dir",depth:c},n.push({path:f,depth:c})}for(let l of u)yield{path:A(i.path,l),kind:"file",depth:c}}}function*Ut(t,e){for(let r of P(t,e))r.kind==="file"&&(yield r.path)}function Kt(t,e){let r=[],n=e;for(;n!=="/"&&!t.has(n);)r.push(n),n=I(n);for(let s=r.length-1;s>=0;s--){let i=r[s];t.set(i,{dirs:[],files:[]}),t.get(I(i)).dirs.push(F(i))}}var g=(t="")=>({stdout:t,stderr:"",exitCode:0}),h=(t,e=1)=>({stdout:"",stderr:t.endsWith(`
2
- `)?t:t+`
3
- `,exitCode:e}),k=t=>h(`usage: ${t}`,2);function S(t){if(t==="")return[];let e=t.split(`
4
- `);return e.at(-1)===""&&e.pop(),e}var v=t=>t.length===0?"":t.join(`
5
- `)+`
6
- `;function B(t,e,r){let n=[],s="",i=!1;for(let o of e){let u=w(r.cwd,o);if(r.fs.isDir(u)){s+=`${t}: ${o}: is a directory
7
- `,i=!0;continue}if(!r.fs.isFile(u)){s+=`${t}: ${o}: no such file or directory
8
- `,i=!0;continue}n.push({name:o,content:r.fs.readFile(u)})}return{inputs:n,stderr:s,failed:i}}function E(t,e,r,n){return e.length===0?{inputs:[{name:null,content:r}],stderr:"",failed:!1}:B(t,e,n)}function W(t,e,r,n){let s=E(t,e,r,n);return{content:s.inputs.map(i=>i.content).join(""),stderr:s.stderr,failed:s.failed}}var y=(t,e)=>({stdout:t,stderr:e.stderr,exitCode:e.failed?1:0});function T(t,e){if(typeof t!="string"||!/^\d+$/u.test(t))return{error:h(`${e}: invalid count: ${t}`)};let r=Number(t);return Number.isSafeInteger(r)?{value:r}:{error:h(`${e}: out of range: ${t}`)}}function Yt(t,e,r){let{positional:n}=p(e),s=E("tac",n,t,r),i=[];for(let{content:o}of s.inputs)i.push(...S(o).toReversed());return y(v(i),s)}var ut=1e6;function Zt(t,e){let{positional:r}=p(e);if(r.length===0||r.length>3)return k("seq LAST | seq FIRST LAST | seq FIRST INCR LAST");let n=[];for(let f of r){if(!/^-?\d+$/u.test(f))return h(`seq: invalid integer: ${f}`);n.push(Number(f))}let s,i,o;if(n.length===1?(s=1,i=1,o=n[0]):n.length===2?(s=n[0],o=n[1],i=s<=o?1:-1):[s,i,o]=n,i===0)return h("seq: increment must be non-zero");let c=(i>0?s<=o:s>=o)?Math.floor(Math.abs(o-s)/Math.abs(i))+1:0;if(c>ut)return h(`seq: range too large: ${c} elements exceeds limit of ${ut}`);let l=[];if(i>0)for(let f=s;f<=o;f+=i)l.push(String(f));else for(let f=s;f>=o;f+=i)l.push(String(f));return g(v(l))}function Qt(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["b"]}),i=n.get("b")??"t";if(i!=="a"&&i!=="t")return h(`nl: -b: only \`a\` and \`t\` are supported (got \`${i}\`)`);let o=E("nl",s,t,r),u=[],c=0;for(let{content:l}of o.inputs)for(let f of S(l))i==="a"||f!==""?(c++,u.push(`${String(c).padStart(6)} ${f}`)):u.push(f);return y(v(u),o)}function Jt(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["d","f","c"]}),i=n.has("f"),o=n.has("c");if(i===o)return k("cut -f LIST [-d DELIM] [file...] | cut -c LIST [file...]");if(o&&n.has("d"))return h("cut: -d is only valid with -f");let u=te(i?n.get("f"):n.get("c"));if(u.error)return u.error;let c=n.get("d")??" ";if(i&&c.length!==1)return h("cut: -d delimiter must be a single character");let l=E("cut",s,t,r),f=[];for(let{content:a}of l.inputs)for(let d of S(a))f.push(i?ee(d,c,u.ranges):lt([...d],u.ranges).join(""));return y(v(f),l)}function te(t){let e=[];for(let r of t.split(",")){if(r==="")return{error:h(`cut: empty list item in \`${t}\``)};if(/^\d+$/u.test(r)){let o=Number(r);if(o<1)return{error:h("cut: list items must be >= 1")};e.push([o,o]);continue}let n=r.match(/^(\d*)-(\d*)$/u);if(!n||n[1]===""&&n[2]==="")return{error:h(`cut: invalid list item: ${r}`)};let s=n[1]===""?1:Number(n[1]),i=n[2]===""?Number.POSITIVE_INFINITY:Number(n[2]);if(s<1)return{error:h("cut: list items must be >= 1")};if(i<s)return{error:h(`cut: reversed range: ${r}`)};e.push([s,i])}return{ranges:e}}function lt(t,e){let r=new Set,n=[];for(let[s,i]of e)for(let o=s;o<=Math.min(i,t.length);o++)r.has(o)||(r.add(o),n.push(o));return n.sort((s,i)=>s-i),n.map(s=>t[s-1])}function ee(t,e,r){let n=t.split(e);return n.length===1?t:lt(n,r).join(e)}function ne(t,e){let{flags:r,positional:n}=p(e,{short:["d","s"]}),s=r.has("d"),i=r.has("s");if(s&&i)return h("tr: -d combined with -s is not supported");let o=s||i?1:2;if(n.length!==o)return k("tr SET1 SET2 | tr -d SET | tr -s SET");let u=ct(n[0]);if(u.error)return u.error;if(s){let a=new Set(u.chars);return g([...t].filter(d=>!a.has(d)).join(""))}if(i)return g(re(t,new Set(u.chars)));let c=ct(n[1]);if(c.error)return c.error;if(c.chars.length===0)return h("tr: SET2 must not be empty");let l=new Map,f=c.chars.at(-1);for(let a=0;a<u.chars.length;a++)l.set(u.chars[a],c.chars[a]??f);return g([...t].map(a=>l.get(a)??a).join(""))}function ct(t){let e=[...t],r=[],n=0,s=()=>{if(e[n]!=="\\")return e[n++];if(n+1>=e.length)return null;let i=e[n+1];return n+=2,i==="n"?`
9
- `:i==="t"?" ":i==="\\"?"\\":i==="0"?"\0":i};for(;n<e.length;){let i=s();if(i===null)return{error:h("tr: trailing backslash in set")};if(e[n]==="-"&&n+1<e.length){n++;let o=s();if(o===null)return{error:h("tr: trailing backslash in set")};let u=i.codePointAt(0),c=o.codePointAt(0);if(c<u)return{error:h(`tr: reversed range: ${i}-${o}`)};for(let l=u;l<=c;l++)r.push(String.fromCodePoint(l))}else r.push(i)}return{chars:r}}function re(t,e){let r="",n=null;for(let s of t)e.has(s)&&s===n||(r+=s,n=s);return r}function se(t,e,r){let{positional:n}=p(e);if(n.length===0)return k("which COMMAND...");let s=[],i=0;for(let o of n)r.hasCommand(o)?s.push(`/usr/bin/${o}`):(s.push(`${o} not found`),i=1);return{stdout:v(s),stderr:"",exitCode:i}}var ft={cut:Jt,tac:Yt,tr:ne,seq:Zt,nl:Qt,which:se};var at=/[*?]/u;function G(t){return new RegExp("^"+t.replace(/[.+^${}()|[\]\\]/gu,"\\$&").replace(/\*/gu,".*").replace(/\?/gu,".")+"$","u")}function ht(t,e,r){if(t.length===0)return[];let n=[t[0]];for(let s=1;s<t.length;s++){let i=t[s];if(e.has(s)||!at.test(i)){n.push(i);continue}let o=ie(i,r);o.length>0?n.push(...o):n.push(i)}return n}function ie(t,e){let r=t.startsWith("/"),n=t.startsWith("./"),s=t.endsWith("/")&&t.length>1,i=t.split("/").filter(Boolean);if(i.length===0)return r?["/"]:[];let o=[r?"/":"."];for(let u=0;u<i.length;u++){let c=i[u];if(!at.test(c)){o=o.map(l=>H(l,c));continue}o=ue(o,c,u===i.length-1,e)}return s?o=o.filter(u=>e.fs.isDir(w(e.cwd,u))).map(u=>u==="/"?u:u+"/"):o=o.filter(u=>oe(u,e)),n&&(o=o.map(u=>u.startsWith("./")?u:"./"+u)),o.sort(),o}function oe(t,e){let r=w(e.cwd,t);return e.fs.isFile(r)||e.fs.isDir(r)}function ue(t,e,r,n){let s=G(e),i=e.startsWith("."),o=c=>!i&&c.startsWith(".")?!1:s.test(c),u=[];for(let c of t){let l=w(n.cwd,c);if(!n.fs.isDir(l))continue;let{dirs:f,files:a}=n.fs.listDir(l);for(let d of f)o(d)&&u.push(H(c,d));if(r)for(let d of a)o(d)&&u.push(H(c,d))}return u}function H(t,e){return t==="."?e:A(t,e)}var dt=new Set(["name","type","path","mindepth","maxdepth"]);function pt(t,e,r){let n=ce(e);if(n.error)return n.error;let{starts:s,minDepth:i,maxDepth:o,groups:u}=n,c=[];for(let l of s){let f=w(r.cwd,l);if(!r.fs.isDir(f)&&!r.fs.isFile(f))return h(`find: ${l}: no such file or directory`);for(let a of P(r.fs,f,o)){if(a.depth<i)continue;let d=ge(l,f,a.path);de(u,{kind:a.kind,path:d})&&c.push(d)}}return g(c.length===0?"":c.join(`
10
- `)+`
11
- `)}function ce(t){let e=le(t);return e.error?e:fe(e.tokens,e.minDepth,e.maxDepth)}function le(t){let e=[],r=0,n=Number.POSITIVE_INFINITY;for(let s=0;s<t.length;s++){let i=t[s],o=i==="-mindepth"||i==="--mindepth"?"mindepth":i==="-maxdepth"||i==="--maxdepth"?"maxdepth":null;if(o){if(s+1>=t.length)return{error:h(`find: -${o} requires a value`)};let u=T(t[s+1],`find: -${o}`);if(u.error)return u;o==="mindepth"?r=u.value:n=u.value,s++;continue}if(i==="--"){e.push(...t.slice(s));break}e.push(i)}return{tokens:e,minDepth:r,maxDepth:n}}function fe(t,e,r){let n=[[]],s=[],i=!1,o=!1,u=!1,c=null;for(let l=0;l<t.length;l++){let f=t[l];if(o){s.push(f);continue}if(f==="-not"||f==="!"){if(i)return{error:h("find: `-not` cannot precede another `-not`")};i=!0,u=!0;continue}if(f==="-a"||f==="-and"||f==="--and"){if(i)return{error:h("find: `-not` must be followed by a primary")};if(c)return{error:h(`find: \`${c}\` with no right-hand expression`)};if(n.at(-1).length===0)return{error:h("find: `-a` with no left-hand expression")};c="-a",u=!0;continue}if(f==="-o"||f==="-or"||f==="--or"){if(i)return{error:h("find: `-not` must be followed by a primary")};if(c)return{error:h(`find: \`${c}\` with no right-hand expression`)};if(n.at(-1).length===0)return{error:h("find: `-o` with no left-hand expression")};n.push([]),c="-o",u=!0;continue}let a=ae(f);if(a!==null){if(l+1>=t.length)return{error:h(`find: ${f} requires a value`)};let d=t[l+1],m=he(a,d);if(m.error)return m;let x={kind:a,value:d,negate:i};(a==="name"||a==="path")&&(x.re=G(d)),n.at(-1).push(x),i=!1,c=null,u=!0,l++;continue}if(f==="--"){o=!0;continue}if(i)return{error:h(`find: \`-not\` must be followed by a primary, got: ${f}`)};if(f.startsWith("-")&&f!=="-"&&!/^-\d/u.test(f))return{error:h(`find: unknown option: ${f}`)};if(u)return{error:h(`find: paths must precede expression: ${f}`)};s.push(f)}return i?{error:h("find: trailing `-not` with no primary")}:c?{error:h(`find: \`${c}\` with no right-hand expression`)}:{starts:s.length>0?s:["."],minDepth:e,maxDepth:r,groups:n}}function ae(t){return/^--?(?:min|max)depth$/u.test(t)?null:t.startsWith("--")&&dt.has(t.slice(2))?t.slice(2):t.startsWith("-")&&dt.has(t.slice(1))?t.slice(1):null}function he(t,e){return t==="type"&&e!=="f"&&e!=="d"?{error:h(`find: -type/--type expects 'f' or 'd', got: ${e}`)}:{}}function de(t,e){return t.some(r=>r.every(n=>pe(n,e)))}function pe(t,e){let r=me(t,e);return t.negate?!r:r}function me(t,e){return t.kind==="type"?t.value==="f"?e.kind==="file":e.kind==="dir":t.kind==="name"?t.re.test(F(e.path)):t.kind==="path"?t.re.test(e.path):!1}function ge(t,e,r){if(r===e)return t;let n=L(e,r);return t.endsWith("/")?t+n:t+"/"+n}function we(t,e,r){return p(e),g(r.cwd+`
12
- `)}function xe(t,e,r){let{positional:n}=p(e),s=n[0]??"/",i=w(r.cwd,s);return r.fs.isDir(i)?(r.cwd=i,g()):h(`cd: not a directory: ${s}`)}function be(t,e,r){let{flags:n,positional:s}=p(Se(e),{short:["l","a"]}),i={long:n.has("l"),all:n.has("a")},o=s.length>0?s:["."],u=[],c=[],l=0;for(let f=0;f<o.length;f++){let a=ve(o[f],o.length>1,i,r);if(a.error){l=1,c.push(a.error);continue}f>0&&o.length>1&&u.push(""),u.push(...a.lines)}return{stdout:u.length===0?"":u.join(`
13
- `)+`
14
- `,stderr:c.length===0?"":c.join(`
15
- `)+`
16
- `,exitCode:l}}function Se(t){let e=[],r=!1;for(let n of t){if(r){e.push(n);continue}if(n==="--"){e.push(n),r=!0;continue}if(n!=="-1"){if(/^-[a-zA-Z0-9]+$/u.test(n)&&n.includes("1")&&/[a-zA-Z]/u.test(n)){e.push("-"+n.slice(1).replaceAll("1",""));continue}e.push(n)}}return e}function ve(t,e,r,n){let s=w(n.cwd,t);if(n.fs.isFile(s))return{lines:[z(t,n.fs.readFile(s).length,!1,r.long)]};if(!n.fs.isDir(s))return{error:`ls: ${t}: no such file or directory`};let i=e?[`${t}:`]:[],{dirs:o,files:u}=n.fs.listDir(s);for(let c of o)!r.all&&c.startsWith(".")||i.push(z(c,0,!0,r.long));for(let c of u){if(!r.all&&c.startsWith("."))continue;let l=A(s,c);i.push(z(c,n.fs.readFile(l).length,!1,r.long))}return{lines:i}}function z(t,e,r,n){let s=t+(r?"/":"");return n?`${r?"d":"-"} ${String(e).padStart(8)} ${s}`:s}function ye(t,e,r){let{positional:n}=p(e),s=n[0]??".",i=w(r.cwd,s);if(!r.fs.isDir(i))return h(`tree: ${s}: not a directory`);let o=[s];return $e(r.fs,i,o),g(o.join(`
17
- `)+`
18
- `)}function $e(t,e,r){let n=[{dir:e,prefix:"",items:mt(t,e),i:0}];for(;n.length>0;){let s=n.at(-1);if(s.i>=s.items.length){n.pop();continue}let{n:i,isDir:o}=s.items[s.i],u=s.i===s.items.length-1;if(r.push(s.prefix+(u?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+i+(o?"/":"")),s.i++,!o)continue;let c=A(s.dir,i);n.push({dir:c,prefix:s.prefix+(u?" ":"\u2502 "),items:mt(t,c),i:0})}}function mt(t,e){let{dirs:r,files:n}=t.listDir(e);return[...r.map(s=>({n:s,isDir:!0})),...n.map(s=>({n:s,isDir:!1}))]}function ke(t,e){let{positional:r}=p(e);return r.length===0?k("basename PATH"):g(F(r[0])+`
19
- `)}function Ee(t,e){let{positional:r}=p(e);return r.length===0?k("dirname PATH"):g(I(r[0])+`
20
- `)}var gt={pwd:we,cd:xe,ls:be,find:pt,tree:ye,basename:ke,dirname:Ee};var Te=/^(\d+)(?:,(\d+))?p$/u;function wt(t,e,r){let n;try{n=p(e,{short:["n"]})}catch{return X()}let{flags:s,positional:i}=n;if(!s.has("n")||i.length===0)return X();let o=Te.exec(i[0]);if(!o)return X();let u=Number(o[1]),c=o[2]===void 0?u:Number(o[2]);if(u<1||c<1)return h("sed: line numbers must be >= 1");if(c<u)return h(`sed: reversed range: ${u},${c}`);let l=i.slice(1);if(l.length>1)return h("sed: at most one input file is supported");let f=E("sed",l,t,r),a=f.inputs[0]?.content??"",m=S(a).slice(u-1,c);return y(m.length>0?m.join(`
21
- `)+`
22
- `:"",f)}function X(){return h("sed: only `-n 'X[,Y]p'` (line range print) is supported")}function xt(t,e){let r=t[e+1];if(r===void 0)return-1;if("^$\\.*+?()[]{}|/bBdDsSwW".includes(r)||r>="1"&&r<="9")return 2;let n=i=>i!==void 0&&/[0-9A-Fa-f]/u.test(i),s=(i,o)=>{if(t[e+2]!==i)return 0;let u=t.indexOf(o,e+3);return u>e+3?u-e+1:0};if(r==="x")return n(t[e+2])&&n(t[e+3])?4:0;if(r==="u"){if(t[e+2]==="{"){let i=s("{","}"),o=i?t.slice(e+3,e+i-1):"";return o.length>=1&&o.length<=6&&[...o].every(n)&&parseInt(o,16)<=1114111?i:0}return[2,3,4,5].every(i=>n(t[e+i]))?6:0}return r==="p"||r==="P"?s("{","}"):r==="c"?/[A-Za-z]/u.test(t[e+2]??"")?3:0:r==="k"?s("<",">"):0}function St(t){let e="(){}+?|",r="",n=!1;for(let s=0;s<t.length;s++){let i=t[s];if(n){if(i==="\\"){let o=xt(t,s);if(o===-1)return{error:"trailing backslash (\\)"};if(o>0){r+=t.slice(s,s+o),s+=o-1;continue}r+=t[s+1],s++;continue}r+=i,i==="]"&&(n=!1);continue}if(i==="["){r+=i,n=!0,t[s+1]==="^"&&(r+="^",s++),t[s+1]==="]"&&(r+="\\]",s++);continue}if(i==="\\"){if(s+1>=t.length)return{error:"trailing backslash (\\)"};let o=t[s+1];if(e.includes(o)){r+=o,s++;continue}if(o==="<"||o===">"){r+="\\b",s++;continue}let u=xt(t,s);if(u>0){r+=t.slice(s,s+u),s+=u-1;continue}r+=o,s++;continue}if(i==="*"&&(s===0||t[s-1]==="^"&&bt(t,s-1))){r+="\\*";continue}if(i==="^"&&!bt(t,s)){r+="\\^";continue}if(i==="$"&&!(s===t.length-1||t[s+1]==="\\"&&(t[s+2]===")"||t[s+2]==="|"))){r+="\\$";continue}if(e.includes(i)){r+="\\"+i;continue}r+=i}return{source:r}}function bt(t,e){return e===0?!0:e>=2&&t[e-2]==="\\"&&(t[e-1]==="("||t[e-1]==="|")}var vt="[-i] [-v] [-n] [-r] [-w] [-o] [-E|-F|-G] [-l] [-L] [-c] [-h] [-H] [-A N] [-B N] [-C N]",_e=`grep ${vt} PATTERN [PATH...]
23
- or: grep ${vt} -e PATTERN ... [PATH...]`,Ce=["i","v","n","r","l","L","c","w","h","H","o","E","F","G"],Ne=["A","B","C"];function $t(t,e,r){let n;try{n=p(e,{short:Ce,valueShort:Ne,repeatable:["e"]})}catch(Ot){return h(`grep: ${Ot.message}`,2)}let{flags:s,values:i,positional:o}=n,u=i.get("e")??[],c,l;if(u.length>0)c=u,l=o;else if(o.length>0)c=[o[0]],l=o.slice(1);else return k(_e);let f=Ae(s);if(f)return f;let a=Fe(c,s);if(a.error)return a.error;let d=De(i);if(d.error)return d.error;let m=s.has("r"),x=Ie(m,t,l,r),b=Me(s,m,l.length),_=s.has("v"),$={showName:b,invert:_,showLine:s.has("n"),only:s.has("o"),after:d.after,before:d.before},N=s.has("l")?yt(x.inputs,a.res,_,!1):s.has("L")?yt(x.inputs,a.res,_,!0):s.has("c")?Oe(x.inputs,a.res,_,b):Re(x.inputs,a.res,$);return x.failed?{stdout:N.stdout,stderr:x.stderr+N.stderr,exitCode:2}:N}function Ae(t){if(t.has("h")&&t.has("H"))return h("grep: -h and -H are mutually exclusive");let e=["l","L","c"].filter(n=>t.has(n));if(e.length>1)return h(`grep: ${e.map(n=>`-${n}`).join(" / ")} are mutually exclusive`);let r=["E","F","G"].filter(n=>t.has(n));return r.length>1?h(`grep: ${r.map(n=>`-${n}`).join(" / ")} are mutually exclusive`):null}function Fe(t,e){let r=[],n=e.has("i")?"iu":"u";for(let s of t){let i;if(e.has("F"))i=RegExp.escape(s);else if(e.has("E"))i=s;else{let o=St(s);if(o.error)return{error:h(`grep: ${o.error}`,2)};i=o.source}e.has("w")&&(i=`\\b(?:${i})\\b`);try{r.push(new RegExp(i,n))}catch(o){let u=e.has("F")?`fixed-string /${n}`:e.has("E")?`ERE / ECMAScript /${n}`:`BRE /${n}`;return{error:h(`grep: invalid pattern (${u}): ${o.message}`,2)}}}return{res:r}}function R(t,e){return t.some(r=>r.test(e))}var V=()=>({stdout:"",stderr:"",exitCode:1});function De(t){let e=t.get("C"),r=e===void 0?null:T(e,"grep: -C");if(r?.error)return r;let n=T(t.get("A")??e??"0","grep: -A");if(n.error)return n;let s=T(t.get("B")??e??"0","grep: -B");return s.error?s:{after:n.value,before:s.value}}function Me(t,e,r){return t.has("h")?!1:t.has("H")?!0:e||r>1}function Ie(t,e,r,n){return t?Le("grep",r.length>0?r:["."],n):r.length>0?B("grep",r,n):{inputs:[{name:null,content:e}],stderr:"",failed:!1}}function Le(t,e,r){let n=[],s="",i=!1;for(let o of e){let u=w(r.cwd,o);if(r.fs.isFile(u)){n.push({name:o,content:r.fs.readFile(u)});continue}if(!r.fs.isDir(u)){s+=`${t}: ${o}: no such file or directory
24
- `,i=!0;continue}for(let c of r.fs.walkFiles(u))n.push({name:We(o,u,c),content:r.fs.readFile(c)})}return{inputs:n,stderr:s,failed:i}}function We(t,e,r){let n=L(e,r);return t==="."?n:t.endsWith("/")?t+n:t+"/"+n}function Re(t,e,r){let n=[],s=!1;for(let{name:o,content:u}of t){let c=S(u),l=je(c,e,o,r);l.matched&&(s=!0),l.lines.length>0&&n.push(l.lines.join(`
25
- `))}let i=n.join(`
26
- `);return s?g(i+(i?`
27
- `:"")):V()}function je(t,e,r,n){let{invert:s,after:i,before:o,only:u}=n,c=o>0||i>0,l=[],f=!1,a=-1;for(let d=0;d<t.length;d++){if(R(e,t[d])===s)continue;if(f=!0,u){l.push(...qe(t[d],r,d+1,e,n));continue}let m=Math.max(0,d-o),x=Math.min(t.length-1,d+i);c&&a>=0&&m>a+1&&l.push("--");for(let b=Math.max(m,a+1);b<=x;b++){let _=b===d||R(e,t[b])!==s;l.push(kt(t[b],r,b+1,_,n))}a=x}return{lines:l,matched:f}}function qe(t,e,r,n,s){let i=[];for(let c of n){let l=new RegExp(c.source,c.flags+"g");for(let f of t.matchAll(l))f[0].length>0&&i.push({index:f.index,text:f[0]})}i.sort((c,l)=>c.index-l.index||l.text.length-c.text.length);let o=[],u=0;for(let c of i)c.index<u||(o.push(kt(c.text,e,r,!0,s)),u=c.index+c.text.length);return o}function kt(t,e,r,n,s){let{showName:i,showLine:o}=s,u=n?":":"-",c=[];return i&&c.push(e??"(standard input)"),o&&c.push(String(r)),c.length>0?c.join(u)+u+t:t}function yt(t,e,r,n){let s=[];for(let{name:i,content:o}of t){let c=S(o).some(l=>R(e,l)!==r);(n?!c:c)&&s.push(i??"(standard input)")}return s.length>0?g(v(s)):V()}function Oe(t,e,r,n){let s=[],i=!1;for(let{name:o,content:u}of t){let c=S(u),l=0;for(let f of c)R(e,f)!==r&&l++;l>0&&(i=!0),n?s.push(`${o??"(standard input)"}:${l}`):s.push(String(l))}return s.length===0?V():{stdout:v(s),stderr:"",exitCode:i?0:1}}function Pe(t,e,r){let{flags:n,positional:s}=p(e,{short:["n"]}),i=W("cat",s,t,r);return y(n.has("n")?Be(i.content):i.content,i)}function Be(t){if(t==="")return"";let e=t.endsWith(`
28
- `)?`
29
- `:"";return(e?t.slice(0,-1).split(`
30
- `):t.split(`
31
- `)).map((n,s)=>`${String(s+1).padStart(6)} ${n}`).join(`
32
- `)+e}function He(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["n"]});Ct(n,s);let i=T(n.get("n")??"10","head: -n");return i.error?i.error:Nt("head",t,s,r,o=>o.slice(0,i.value))}function Ge(t,e,r){let{values:n,positional:s}=p(e,{valueShort:["n"]});Ct(n,s);let i=T(n.get("n")??"10","tail: -n");return i.error?i.error:Nt("tail",t,s,r,o=>i.value===0?[]:o.slice(-i.value))}function Ct(t,e){t.has("n")||e[0]&&/^-\d+$/u.test(e[0])&&t.set("n",e.shift().slice(1))}function Nt(t,e,r,n,s){let i=E(t,r,e,n),o=i.inputs.length>1,u=[];for(let c=0;c<i.inputs.length;c++){let{name:l,content:f}=i.inputs[c],a=s(S(f)).join(`
33
- `);o?u.push(`${c>0?`
34
- `:""}==> ${l} <==
35
- ${a}${a?`
36
- `:""}`):a.length>0&&u.push(a+`
37
- `)}return y(u.join(""),i)}function ze(t,e,r){let{flags:n,positional:s}=p(e,{short:["l","w","c"]}),i=Xe(n),o=E("wc",s,t,r),u=[],c={l:0,w:0,c:0};for(let{name:l,content:f}of o.inputs){let a=Ue(f);u.push(Et(a,l,i)),c.l+=a.l,c.w+=a.w,c.c+=a.c}return o.inputs.length>1&&u.push(Et(c,"total",i)),y(v(u),o)}function Xe(t){return t.has("l")||t.has("w")||t.has("c")?{l:t.has("l"),w:t.has("w"),c:t.has("c")}:{l:!0,w:!0,c:!0}}var Ve=new TextEncoder;function Ue(t){return{l:(t.match(/\n/gu)??[]).length,w:(t.match(/\S+/gu)??[]).length,c:Ve.encode(t).length}}function Et(t,e,r){let n=[];return r.l&&n.push(String(t.l).padStart(7)),r.w&&n.push(String(t.w).padStart(7)),r.c&&n.push(String(t.c).padStart(7)),n.join(" ")+(e?" "+e:"")}function Ke(t,e,r){let{flags:n,positional:s}=p(e,{short:["n","r","u"]}),i=W("sort",s,t,r),o=S(i.content),u=n.has("n"),c=n.has("u");if(u){let l=o.map(f=>({line:f,key:Tt(f)}));l.sort(c?(f,a)=>f.key-a.key:(f,a)=>f.key-a.key||(f.line<a.line?-1:f.line>a.line?1:0)),o=l.map(f=>f.line)}else o.sort();if(c){let l=new Set;o=o.filter(f=>{let a=u?Tt(f):f;return l.has(a)?!1:(l.add(a),!0)})}return n.has("r")&&o.reverse(),y(v(o),i)}function Tt(t){let e=/^[ \t]*(-?(?:\d+\.?\d*|\.\d+))/u.exec(t);return e?Number(e[1]):0}function Ye(t,e,r){let{flags:n,positional:s}=p(e,{short:["c","d","u","i"]}),i=W("uniq",s,t,r),o=n.has("c"),u=n.has("d"),c=n.has("u"),l=n.has("i"),f=$=>l?$.toLowerCase():$,a=S(i.content),d=[],m=null,x=null,b=0,_=()=>{if(m===null)return;let $=b>=2;!(u&&c)&&(u?$:!c||!$)&&d.push(o?`${String(b).padStart(7)} ${m}`:m)};for(let $ of a){let N=f($);if(N===x){b++;continue}_(),m=$,x=N,b=1}return _(),y(v(d),i)}function Ze(t,e){let{flags:r,positional:n}=p(e,{short:["n","e","E"]}),s=n.join(" "),i=!r.has("n");if(r.has("e")){let o=Qe(s);s=o.text,o.stop&&(i=!1)}return g(i?s+`
38
- `:s)}function Qe(t){let e={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,"\\":92},r="";for(let n=0;n<t.length;n++){if(t[n]!=="\\"||n+1>=t.length){r+=t[n];continue}let s=t[++n];if(s==="c")return{text:r,stop:!0};if(s in e){r+=String.fromCodePoint(e[s]);continue}if(s==="0"){let i="";for(;i.length<3&&/[0-7]/u.test(t[n+1]??"");)i+=t[++n];r+=String.fromCodePoint(i===""?0:parseInt(i,8));continue}if(s==="x"&&/[0-9a-fA-F]/u.test(t[n+1]??"")){let i="";for(;i.length<2&&/[0-9a-fA-F]/u.test(t[n+1]??"");)i+=t[++n];r+=String.fromCodePoint(parseInt(i,16));continue}r+="\\"+s}return{text:r,stop:!1}}function Je(t,e,r){let{flags:n,values:s,positional:i}=p(e,{short:["r"],valueShort:["n"],stopAtFirstPositional:!0}),[o="echo",...u]=i,c=t.split(/\s+/u).filter(Boolean);if(c.length===0)return n.has("r")?g():r.dispatch(o,u,"");let l=s.has("n")?T(s.get("n"),"xargs: -n"):{value:c.length};return l.error?l.error:s.has("n")&&l.value===0?h("xargs: -n: must be at least 1"):tn(r,o,u,c,l.value)}function tn(t,e,r,n,s){let i="",o="",u=0;for(let c=0;c<n.length;c+=s){let l=t.dispatch(e,[...r,...n.slice(c,c+s)],"");i+=l.stdout,o+=l.stderr,l.exitCode!==0&&(u=l.exitCode)}return{stdout:i,stderr:o,exitCode:u}}function _t(){return g()}function en(){return{stdout:"",stderr:"",exitCode:1}}var At={cat:Pe,grep:$t,head:He,tail:Ge,wc:ze,sort:Ke,uniq:Ye,echo:Ze,xargs:Je},Ft={true:_t,false:en,":":_t};function Dt(t,e,r){let{index:n,pipe:s}=rn(t),i=t.slice(n),o=sn(i),u=i.slice(o),c=i.slice(0,o).trim(),l=c==="",f=l?"":r.resolveCommand(c.split(/\s+/u)[0]),a=t.slice(0,n+o),d=s&&a.endsWith("|")?" ":"";return nn(u,l,s,f,e,r).map(m=>a+d+m)}function nn(t,e,r,n,s,i){if(!e)return r?[]:on(t,s,n==="cd");let o=r?i.pipeNames:i.names;for(let u of i.binPrefixes)if(t.startsWith(u)){let c=t.slice(u.length);return o.filter(l=>l.startsWith(c)).map(l=>u+l)}return t.startsWith("/")||t.startsWith("./")?[]:o.filter(u=>u.startsWith(t))}function rn(t){let e=0,r=!1,n=0;for(;n<t.length;){let s=t[n];if(s==="|"){let i=t[n+1]==="|";n+=i?2:1,e=n,r=!i}else s==="&"&&t[n+1]==="&"?(n+=2,e=n,r=!1):s===";"?(n++,e=n,r=!1):n++}return{index:e,pipe:r}}function sn(t){for(let e=t.length-1;e>=0;e--)if(/\s/u.test(t[e]))return e+1;return 0}function on(t,e,r=!1){let n=t.lastIndexOf("/"),s=t.slice(0,n+1),i=t.slice(n+1),o=w(e.cwd,s);if(!e.fs.isDir(o))return[];let{dirs:u,files:c}=e.fs.listDir(o),l=i.startsWith("."),f=[];for(let a of u)!l&&a.startsWith(".")||a.startsWith(i)&&f.push(s+a+"/");if(r)return f;for(let a of c)!l&&a.startsWith(".")||a.startsWith(i)&&f.push(s+a);return f}var j={__proto__:null,...At,...gt,...ft},U={__proto__:null,sed:wt,...Ft},un=["ls","cd","cat","grep","find","head","tail","wc","tree","sort","uniq","cut","tr","nl","tac","xargs","echo","pwd","seq","which","basename","dirname"],Mt=fn(),cn=Mt.join(", "),ln=["grep","head","tail","wc","sort","uniq","cut","xargs","tr","nl","tac","cat"];function fn(){let t=new Set(Object.keys(j)),e=[];for(let r of un)t.delete(r)&&e.push(r);return e.push(...[...t].sort()),e}function It(t,e={}){let r=ot(t),s={cwd:e.cwd===void 0?"/":w("/",e.cwd),fs:r};if(s.dispatch=(i,o,u)=>Rt(i,o,u,s),s.hasCommand=i=>!!(j[i]||U[i]),!r.isDir(s.cwd))throw new Error(`createTerminal: cwd is not a directory: ${s.cwd}`);return{run:i=>an(i,s),cwd:()=>s.cwd,complete:i=>Dt(i,s,{names:Mt,pipeNames:ln,binPrefixes:Lt,resolveCommand:Wt})}}var Lt=["/usr/local/bin/","/usr/bin/","/bin/","/sbin/"];function Wt(t){for(let e of Lt)if(t.startsWith(e)){let r=t.slice(e.length);if(j[r]||U[r])return r}return t}function Rt(t,e,r,n){let s=Wt(t),i=j[s]??U[s];if(!i)return mn(t);try{return i(r,e,n)}catch(o){return h(`${t}: ${o.message}`)}}function an(t,e){try{let r=t.trim();if(r==="")return{stdout:"",stderr:"",exitCode:0,cwd:e.cwd};let n=nt(r);return{...jt(n,e,""),cwd:e.cwd}}catch(r){return{...h(`error: ${r.message}`),cwd:e.cwd}}}function jt(t,e,r){let n="",s="",i=0,o=!1;for(let u=0;u<t.length;u++){let c=t[u];if(c.gate==="and"&&i!==0||c.gate==="or"&&i===0)continue;let l=hn(c.stages,e,u===0?r:"");n+=l.stdout,s+=l.stderr,i=l.exitCode,o=!0}return o||(i=0),{stdout:n,stderr:s,exitCode:i}}function hn(t,e,r){let n=r,s="";for(let i=0;i<t.length;i++){let o=t[i],u=o.group?pn(o.group,e,n):dn(o,e,n),c=u.stdout,l=u.stderr;if(o.mergeStderrToStdout&&(c+=l,l=""),o.mergeStdoutToStderr&&(l+=c,c=""),o.stdoutToNull&&(c=""),o.stderrToNull&&(l=""),s+=l,i===t.length-1)return{stdout:c,stderr:s,exitCode:u.exitCode};n=c}return{stdout:"",stderr:s,exitCode:0}}function dn(t,e,r){let n=tt(t.argv,t.quoted??new Set),s=ht(n.argv,n.quoted,e);return Rt(s[0],s.slice(1),r,e)}function pn(t,e,r){let n=e.cwd;try{return jt(t,e,r)}finally{e.cwd=n}}function mn(t){return h(`${t}: command not found. Available: ${cn}`,127)}var qt=`:host{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--bg, #0c0c0c);color:var(--text, #e6edf3);font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:13px;line-height:1.45}.output{flex:1 1 auto;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;padding:12px 14px 6px;cursor:text}.banner{color:var(--muted, #8b949e);margin-bottom:8px}.banner .cmd{color:var(--accent, #58a6ff)}.banner .cmd:hover{text-decoration:underline}.line{white-space:pre-wrap;overflow-wrap:break-word}.cwd{color:var(--accent, #58a6ff)}.sigil{color:var(--muted, #8b949e);margin:0 6px 0 4px}.stdout,.stderr{margin:0 0 4px;font:inherit;white-space:pre-wrap;overflow-wrap:break-word}.stderr{color:var(--critical, #d8413a)}.form{flex:0 0 auto;display:flex;align-items:center;padding:8px 14px 10px;border-top:1px solid var(--border, #2c2c2c)}.form:focus-within{border-top-color:var(--accent, #58a6ff)}.form .cwd{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none}.form .sigil{flex:0 0 auto;user-select:none}.input-wrap{flex:1 1 auto;min-width:0;position:relative;display:flex;align-items:center}.input{width:100%;background:transparent;border:none;outline:none;color:inherit;font:inherit;padding:0;position:relative}.ghost{position:absolute;inset:0;display:flex;align-items:center;font:inherit;white-space:pre;overflow:hidden;pointer-events:none;user-select:none;color:var(--muted, #8b949e);opacity:.55}.ghost-pad{color:transparent}
39
- `;function wn(t){let r=["ls","find /",`grep -r ${xn(t)} .`];if(!t||t.size===0)return r;let n=null;for(let s of t.keys()){let i=bn(s);(n===null||i.length<n.length)&&(n=i)}return n&&r.push(`cat ${n} | head -n 20`),r}var K=["TODO","FIXME","XXX","HACK","NOTE","BUG","export","import","require","//"];function xn(t){if(!t||t.size===0)return K[0];for(let e of K)for(let r of t.values())if(r.includes(e))return e;return K[0]}function bn(t){return t.startsWith("./")?t.slice(2):t.startsWith("/")?t.slice(1):t}var Y=class t extends Q{static properties={sources:{attribute:!1},_lines:{state:!0},_input:{state:!0},_cwd:{state:!0},_ghost:{state:!0}};static styles=J(qt);#n=null;#c=null;#e=[];#t=-1;#s="";#r=null;#i=null;static#a=200;constructor(){super(),this.sources=null,this._lines=[],this._input="",this._cwd="/",this._ghost=""}willUpdate(e){e.has("sources")&&this.sources!==this.#c&&(this.#n=this.sources?It(this.sources):null,this._cwd=this.#n?this.#n.cwd():"/",this._lines=[{kind:"banner",commands:wn(this.sources)}],this.#e=[],this.#t=-1,this.#s="",this.#r=null,this._input="",this.#c=this.sources),e.has("_input")&&(this.#u(),this.#f())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#l())}disconnectedCallback(){super.disconnectedCallback(),this.#u()}firstUpdated(){this.#o()}updated(e){(e.has("_lines")||e.has("sources"))&&this.#l()}#o(){let e=this.renderRoot.querySelector(".input");e&&e.focus()}#l(){let e=this.renderRoot.querySelector(".output");e&&(e.scrollTop=e.scrollHeight)}#h=e=>{if(e.preventDefault(),!this.#n)return;let r=this._input,n=r.trim();if(n==="clear"){this._lines=[],this._input="",n.length>0&&(this.#e=[...this.#e,r]),this.#t=-1;return}let s=this._cwd,i=this.#n.run(r);this._cwd=i.cwd;let o=[...this._lines,{kind:"prompt",cwd:s,text:r}];i.stdout&&o.push({kind:"stdout",text:i.stdout}),i.stderr&&o.push({kind:"stderr",text:i.stderr}),this._lines=o,n.length>0&&(this.#e=[...this.#e,r]),this.#t=-1,this._input=""};#d=e=>{if(e.key==="Tab"&&!e.shiftKey){e.preventDefault(),this.#p();return}this.#r=null,e.key==="ArrowUp"?(e.preventDefault(),this.#g()):e.key==="ArrowDown"&&(e.preventDefault(),this.#w()),this.#u(),this.#f()};#p(){if(!this.#n)return;let e=this.#r;if(e&&e.items[e.index]===this._input){e.index=(e.index+1)%e.items.length,this._input=e.items[e.index];return}let r=this.#n.complete(this._input);if(r.length===0){this.#r=null;return}this._input=r[0],this.#r=r.length>1?{items:r,index:0}:null}#u(){this._ghost="",this.#i!==null&&(clearTimeout(this.#i),this.#i=null)}#f(){this.#i=setTimeout(()=>{this.#i=null,this.#m()},t.#a)}#m(){if(!this.#n||this.#r)return;let e=this._input,r=e.slice(-1),n=e===""||r===" "||r==="|",s=/[\w./]/u.test(r);if(!n&&!s)return;let i=this.#n.complete(e);if(i.length===0)return;let o=i[0];!o.startsWith(e)||o===e||s&&i.includes(e)||(this._ghost=o.slice(e.length))}#g(){this.#e.length!==0&&(this.#t<0?(this.#s=this._input,this.#t=this.#e.length-1):this.#t=Math.max(0,this.#t-1),this._input=this.#e[this.#t])}#w(){if(this.#t<0)return;let e=this.#t+1;e>=this.#e.length?(this.#t=-1,this._input=this.#s,this.#s=""):(this.#t=e,this._input=this.#e[e])}#x=e=>{this._input=e.target.value};#b=e=>{this._input=e,this.#t=-1,this.#s="",this.#o()};#S=()=>{let e=this.renderRoot.getSelection?.()??document.getSelection();e&&!e.isCollapsed||this.#o()};render(){return C`<div class="output" @click="${this.#S}">${this._lines.map(e=>this.#v(e))}</div><form class="form" @submit="${this.#h}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?C`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:q} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#x}" @keydown="${this.#d}"></div></form>`}#v(e){return e.kind==="banner"?C`<div class="banner">Virtual shell over the bundle source tree. Try ${e.commands.map((r,n)=>C`${n>0?", ":""}\`<span class="cmd" @click="${()=>this.#b(r)}">${r}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:e.kind==="prompt"?C`<div class="line"><span class="cwd">${e.cwd}</span><span class="sigil">$</span>${e.text}</div>`:e.kind==="stdout"?C`<pre class="stdout">${e.text}</pre>`:e.kind==="stderr"?C`<pre class="stderr">${e.text}</pre>`:q}};customElements.define("bundle-terminal",Y);function vr(t,e){let r=document.createElement("bundle-terminal");return r.dataset.integrity=e??"",r.sources=t,r}export{vr as createTerminalElement};
1
+ import{a as e,b as t,c as n,d as r,e as i,f as a,g as o,h as s,i as c,j as l,k as u,l as d,m as f,n as p,o as m,p as h,q as g,r as _,s as v,t as y}from"./chunk-PLGH63UC.js";import{a as ee}from"./chunk-GO7FT4OD.js";import{a as te,b as ne}from"./chunk-SZWPYLPC.js";import{a as re}from"./chunk-DEVAORP2.js";import{d as ie,e as ae}from"./chunk-ZQHLECTI.js";import{a as oe,b as se,c as ce,d as le,e as ue,f as de}from"./chunk-N57OWFKY.js";import{a as fe,b,c as pe,d as me}from"./chunk-7YFJUT2P.js";import"./chunk-PXK7EU4V.js";import{a as he,d as ge}from"./chunk-PWFUOLZK.js";import"./chunk-C4Z6ZBXV.js";import{a as _e,c as ve,g as ye,j as be}from"./chunk-2XUEZHIP.js";import"./chunk-OOJM4CTU.js";var xe={__proto__:null,ENOENT:`No such file or directory`,ENOTDIR:`Not a directory`,EISDIR:`Is a directory`,EEXIST:`File exists`,ENOTEMPTY:`Directory not empty`,ELOOP:`Too many levels of symbolic links`,EINVAL:`Invalid argument`,EPERM:`Operation not permitted`,EBUSY:`Device or resource busy`,EILSEQ:`Invalid or incomplete multibyte or wide character`,ENAMETOOLONG:`File name too long`},Se=/[\p{Cc}\p{Zl}\p{Zp}\p{Bidi_Control}]/gu,Ce=e=>`${e}`.replaceAll(Se,e=>`\\u${e.codePointAt(0).toString(16).padStart(4,`0`)}`),we=(e,t,n=`a string`)=>TypeError(`${e} must be ${n}, not ${t===null?`null`:typeof t}`),x=class extends Error{constructor(e,t){super(`${Ce(t)}: ${xe[e]??e}`),this.name=`VfsError`,this.code=e,this.path=t}},Te=(e,t=`path`)=>{if(typeof e!=`string`)throw we(t,e);return e};function Ee(e,t){let n=Math.min(Te(e).length,Te(t).length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.codePointAt(r)-t.codePointAt(r);return e.length-t.length}var De=e=>[...e.entries.keys()].sort(Ee),Oe=(e,t)=>t===``?e:e===`/`?`/${t}`:`${e}/${t}`;function*ke(e,t=e=>e,n=()=>!0){let r=[{name:``,node:e,depth:0}];for(;r.length>0;){let e=r.pop();if(yield t(e),e.node.type!==`directory`||!n(e))continue;let i=De(e.node);for(let t=i.length-1;t>=0;t--){let n=e.name===``?i[t]:`${e.name}/${i[t]}`;r.push({name:n,leaf:i[t],parent:e.node,node:e.node.entries.get(i[t]),depth:e.depth+1})}}}var Ae=new Set([`error`,`keep`,`replace`]);function je(e,t,n=`'error', 'keep' or 'replace'`){if(typeof e!=`string`)throw we(t,e,n);if(!Ae.has(e))throw RangeError(`${t} must be ${n}, not ${JSON.stringify(e)}`);return e}function Me({clash:e=`error`,fold:t}){if(typeof e!=`function`&&je(e,`clash`,`'error', 'keep', 'replace' or a function`),t!==void 0&&typeof t!=`function`)throw we(`fold`,t,`a function`);return{fold:t,settle:typeof e==`function`?(t,n)=>je(e(t,n),`what clash returns`):()=>e}}function Ne(e,t,n,{settle:r,fold:i},a){let o=Fe(t,a.copy),s=new Map([[o,{into:e}]]),c=[];for(let{name:e,leaf:t,parent:a,node:l}of ke(o,void 0,e=>s.has(e.node))){if(a===void 0)continue;let o=s.get(a),u=o.into.entries.get(t);if(u?.type===`directory`&&l.type===`directory`){s.set(l,{into:u});continue}let d=u===void 0?Ie(o,a,t,i):[t];if(d.length>0){let i=Oe(n,e),a=r(i,d.map(e=>i.slice(0,-t.length)+e));if(a===`error`)throw new x(`EEXIST`,i);if(a===`keep`)continue}c.push({dir:o.into,name:t,node:l,taken:d})}for(let{dir:e,name:t,node:n,taken:r}of c){for(let e of ke(n))a.number(e.node);for(let t of r)e.entries.delete(t);e.entries.set(t,n)}}function*Pe(e,t,n){for(let{name:r,node:i}of ke(e))if(i.type===`directory`)for(let e of Map.groupBy(De(i),e=>n(e)).values())e.length>1&&(yield{path:Oe(t,r),names:e})}function Fe(e,t){let n=new Map;for(let{node:r,parent:i,leaf:a}of ke(e))n.has(r)||n.set(r,t(r)),i!==void 0&&n.get(i).entries.set(a,n.get(r));return n.get(e)}function Ie(e,t,n,r){return r===void 0?[]:(e.keys??=Map.groupBy(De(e.into).filter(e=>!t.entries.has(e)),e=>r(e)),e.keys.get(r(n))??[])}var Le=40,Re=255,ze=4096,Be=new Uint8Array,Ve={file:420,directory:493,symlink:511},He=new TextEncoder,Ue=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0}),We=e=>typeof e==`string`&&e.endsWith(`/`),Ge=class{#e;#t=0;constructor(){this.#e=this.#r()}#n(e,t,n=Ve[e],r=0){return{ino:++this.#t,type:e,mode:rt(n),mtime:it(r),...t}}#r(e,t){return this.#n(`directory`,{entries:new Map},e,t)}#i(e,{follow:t=!0,mkdirs:n=!1,create:r=!1}={}){if(typeof e!=`string`)throw we(`a path`,e);if(e.includes(`\0`))throw new x(`EINVAL`,e);if(e===``)throw new x(`ENOENT`,e);let i=e.endsWith(`/`),a=[Ke(e)],o=[{name:``,node:this.#e}],s=Le,c,l,u,d;for(;;){for(;a.length>1&&Je(a.at(-1));)a.pop();if(Je(a.at(-1))){({name:u,node:d}=o.pop()),c=void 0;break}if(l=a.length>1,u=Xe(a.at(-1)),u===`.`)continue;if(u===`..`){o.length>1&&o.pop();continue}c=o.at(-1).node;let f=a.every(Je);if(d=c.entries.get(u),r&&!f&&a.every(qe)){i=!0;break}if(d===void 0){if(f)break;if(!n||l)throw new x(`ENOENT`,e);et(u,e),d=this.#r(),c.entries.set(u,d)}if(d.type===`symlink`&&(!f||t)){if(s--===0)throw new x(`ELOOP`,e);d.target.startsWith(`/`)&&(o.length=1),a.push(Ke(d.target,!0))}else{if(f){if(i&&!r&&d.type!==`directory`)throw new x(`ENOTDIR`,e);break}if(d.type!==`directory`)throw new x(`ENOTDIR`,e);o.push({name:u,node:d})}}return{dir:c,name:u,node:d,trailing:i,chain:o,linked:l}}#a(e,t=!0){let n=this.#i(e,{follow:t});if(n.node===void 0)throw new x(`ENOENT`,e);return n}#o(e,t){return this.#a(e,t).node}#s(e,t,n){et(e.name,n),e.dir.entries.set(e.name,t)}#c(e,t){if(e.dir!==void 0)return e.dir;throw new x(Ye(t,0)===t.length?`EBUSY`:`EINVAL`,t)}#l(e,t,n){try{return this.#i(e,{follow:n}).node?.type===t}catch(e){if(e instanceof x)return!1;throw e}}stat(e){return Qe(this.#o(e,!0))}lstat(e){return Qe(this.#o(e,We(e)))}isFile(e){return this.#l(e,`file`,!0)}isDirectory(e){return this.#l(e,`directory`,!0)}isSymlink(e){return this.#l(e,`symlink`,!1)}realpath(e){return Ze(this.#a(e))}readFile(e){let t=this.#o(e,!0);if(t.type===`directory`)throw new x(`EISDIR`,e);return t.bytes}readText(e){let t=this.readFile(e);try{return Ue.decode(t)}catch{throw new x(`EILSEQ`,e)}}readlink(e){let t=this.#o(e,We(e));if(t.type!==`symlink`)throw new x(`EINVAL`,e);return t.target}readdir(e){let t=this.#o(e,!0);if(t.type!==`directory`)throw new x(`ENOTDIR`,e);return De(t)}#u(e,t,n,r,i,a=!1){let o=a&&t instanceof Uint8Array?at(t):ot(t,e),s=this.#i(e,{follow:!We(e),create:!0});if(s.trailing||s.node?.type===`directory`)throw new x(`EISDIR`,e);s.node===void 0?this.#s(s,this.#n(`file`,{bytes:o},r,i),e):n(s.node,o)}writeFile(e,t,{mode:n,mtime:r,adopt:i=!1}={}){if(typeof i!=`boolean`)throw we(`adopt`,i,`a boolean`);this.#u(e,t,(e,t)=>Object.assign(e,{bytes:t,grows:!1,...$e(e,n,r)}),n,r,i)}appendFile(e,t){this.#u(e,t,ct)}mkdir(e,{recursive:t=!1,mode:n,mtime:r}={}){let i=this.#i(e,{follow:t,mkdirs:t,create:!t});if(i.node===void 0){if(i.linked)throw new x(`ENOENT`,e);this.#s(i,this.#r(n,r),e)}else if(!t||i.node.type!==`directory`)throw new x(`EEXIST`,e)}symlink(e,t,{mode:n,mtime:r}={}){if(typeof e!=`string`)throw we(`a link target`,e);if(e===``||e.includes(`\0`))throw new x(`EINVAL`,t);et(e,t,ze),this.#s(this.#d(t),this.#n(`symlink`,{target:e,size:tt(e)},n,r),t)}hardlink(e,t){let n=this.#o(e,We(e)),r=this.#d(t);if(n.type===`directory`)throw new x(`EPERM`,e);this.#s(r,n,t)}#d(e){let t=this.#i(e,{follow:!1,create:!0});if(t.node!==void 0)throw new x(`EEXIST`,e);if(t.trailing)throw new x(`ENOENT`,e);return t}unlink(e){this.rm(e)}rmdir(e){let t=this.#a(e,!1);if(t.node.type!==`directory`)throw new x(`ENOTDIR`,e);let n=this.#c(t,e);if(t.node.entries.size>0)throw new x(`ENOTEMPTY`,e);n.entries.delete(t.name)}rm(e,{recursive:t=!1}={}){let n=this.#a(e,!1);if(n.node.type===`directory`&&!t)throw new x(`EISDIR`,e);this.#c(n,e).entries.delete(n.name)}rename(e,t){let n=this.#i(e,{follow:!1,create:!0}),r=this.#i(t,{follow:!1,create:!0}),i=this.#c(n,e),a=this.#c(r,t);if(n.node===void 0)throw new x(`ENOENT`,e);et(r.name,t);let o=n.node.type===`directory`;if(!o&&(n.trailing||r.trailing))throw new x(`ENOTDIR`,n.trailing?e:t);if(r.chain.some(e=>e.node===n.node))throw new x(`EINVAL`,t);if(n.chain.some(e=>e.node===r.node))throw new x(`ENOTEMPTY`,t);if(r.node!==n.node){if(r.node!==void 0&&r.node.type===`directory`!==o)throw new x(o?`ENOTDIR`:`EISDIR`,t);if(r.node?.type===`directory`&&r.node.entries.size>0)throw new x(`ENOTEMPTY`,t);i.entries.delete(n.name),a.entries.set(r.name,n.node)}}chmod(e,t){this.#o(e,!0).mode=rt(t)}utimes(e,t){this.#o(e,!0).mtime=it(t)}mount(e,t=`/`,n={}){if(typeof e!=`object`||!e||!(#e in e))throw we(`a tree`,e,`a Vfs`);let r=Me(n),i=this.#a(t);if(i.node.type!==`directory`)throw new x(`ENOTDIR`,t);Ne(i.node,e.#e,Ze(i),r,{copy:st,number:e=>{e.ino||=++this.#t}})}walk(e=`/`){let t=this.#a(e),n=Ze(t);return ke(t.node,({name:e,node:t,depth:r})=>({path:Oe(n,e),type:t.type,depth:r}))}collisions(e,t=`/`){if(typeof e!=`function`)throw we(`fold`,e,`a function`);let n=this.#a(t);return Pe(n.node,Ze(n),e)}entries(e=`/`){let t=this.#a(e),n=t.node.type===`directory`?`.`:t.name,r=new Map;return ke(t.node,({name:e,node:t})=>{let i=e===``?n:e,a={name:i,type:t.type,mode:t.mode,mtime:t.mtime,linkname:``,data:Be},o=r.get(t);return o===void 0?t.type===`symlink`?(r.set(t,i),a.linkname=t.target):t.type===`file`&&(r.set(t,i),a.data=t.bytes):(a.type=`hardlink`,a.linkname=o),a})}},Ke=(e,t=!1)=>({text:e,at:Ye(e,0),dot:t&&e.endsWith(`/`)}),qe=e=>e.at===e.text.length,Je=e=>qe(e)&&!e.dot,Ye=(e,t)=>{let n=t;for(;e[n]===`/`;)n++;return n};function Xe(e){if(qe(e))return e.dot=!1,`.`;let t=e.text.indexOf(`/`,e.at),n=t===-1?e.text.length:t,r=e.text.slice(e.at,n);return e.at=Ye(e.text,n),r}var Ze=({chain:e,name:t})=>`/${[...e.slice(1).map(e=>e.name),t].filter(Boolean).join(`/`)}`,Qe=e=>({type:e.type,ino:e.ino,mode:e.mode,mtime:e.mtime,size:e.bytes?.length??e.size??0}),$e=(e,t=e.mode,n=e.mtime)=>({mode:rt(t),mtime:it(n)});function et(e,t,n=Re){if(!e.isWellFormed())throw new x(`EILSEQ`,t);if(nt(e,n))throw new x(`ENAMETOOLONG`,t)}function tt(e){let t=0;for(let n of e){let e=n.codePointAt(0);t+=e<128?1:e<2048?2:e<65536?3:4}return t}var nt=(e,t)=>e.length>t||e.length*3>t&&tt(e)>t;function rt(e){if(!Number.isInteger(e)||e<0||e>4095)throw RangeError(`a mode must be an integer from 0 to 0o7777, not ${e}`);return e}function it(e){if(!Number.isSafeInteger(e))throw RangeError(`an mtime must be an integer of whole seconds, not ${e}`);return e}var at=e=>e.constructor===Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.length);function ot(e,t){if(typeof e==`string`){if(!e.isWellFormed())throw new x(`EILSEQ`,t);return He.encode(e)}if(e instanceof Uint8Array)return new Uint8Array(e);throw we(`file contents`,e,`a string or a Uint8Array`)}function st({type:e,mode:t,mtime:n,bytes:r,target:i,size:a}){let o={ino:0,type:e,mode:t,mtime:n};return e===`directory`?o.entries=new Map:e===`symlink`?Object.assign(o,{target:i,size:a}):o.bytes=r,o}function ct(e,t){let n=e.bytes,r=n.length+t.length,i=e.grows===!0&&n.byteOffset+r<=n.buffer.byteLength,a=i?new Uint8Array(n.buffer,n.byteOffset,r):new Uint8Array(Math.max(r,n.length*2)).subarray(0,r);i||a.set(n),a.set(t,n.length),e.bytes=a,e.grows=!0}var S=(e=``)=>({stdout:e,stderr:``,exitCode:0}),C=(e,t=1)=>({stdout:``,stderr:e.endsWith(`
2
+ `)?e:e+`
3
+ `,exitCode:t}),lt=(e,t=1)=>C(`usage: ${e}`,t),ut=Symbol(`unsupported`);function w(e){if(e==null)return null;try{return e[ut]??null}catch{return null}}function T(e,t,n,r,i=1){return E(C(r,i),e,t,n,r)}function E(e,t,n,r,i){return Object.defineProperty(e,ut,{value:{kind:t,command:n,detail:r,message:i},enumerable:!1,configurable:!0}),e}function dt(e,t,n,r){let i=w(e);return i?T(i.kind,t,i.detail,n,r):C(n,r)}var D=class extends Error{constructor(e,t,n){super(n),this.name=`UnsupportedError`,E(this,e,null,t,n)}};function ft(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let i=JSON.stringify([n.kind,r,n.detail]);e.has(i)||(e.add(i),t.push(Object.freeze(n)))}}}function O(e){try{return fe(e)}catch(e){throw e instanceof TypeError?new D(`feature`,`unpaired surrogate`,`unpaired UTF-16 surrogates cannot be encoded as UTF-8`):e}}var pt=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*mt(e){for(let t=0;t<e.length;){let n=xt[e[t]],r=n===1?e[t]:n===0?-1:gt(e,t,n);yield r,t+=r<0?1:n}}var ht=[0,0,128,2048,65536];function gt(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let i=1;i<n;i++){if((e[t+i]&192)!=128)return-1;r=r<<6|e[t+i]&63}return r<ht[n]||r>1114111||r>=55296&&r<=57343?-1:r}var _t=e=>me(e);function vt(e){let t;try{t=pe(e)}catch{}return t}function yt(e){let t=vt(e);if(t!==void 0)return t;let n=new Uint16Array(e.length),r=0;for(let t=0;t<e.length;){let i=xt[e[t]],a=i===1?e[t]:i===0?-1:gt(e,t,i);a<0?n[r++]=56320+e[t++]:(a>65535?(n[r++]=55232+(a>>10),n[r++]=56320+(a&1023)):n[r++]=a,t+=i)}let i=``;for(let e=0;e<r;e+=bt)i+=String.fromCharCode.apply(null,n.subarray(e,Math.min(r,e+bt)));return i}var bt=4096,xt=Uint8Array.from({length:256},(e,t)=>pt(t)),St=`\\uDC80-\\uDCFF`,Ct=RegExp(`[${St}]`,`u`),wt=e=>e>=56448&&e<=56575;function Tt(e){if(!Ct.test(e))return O(e);let t=new Uint8Array(e.length*3),n=0;for(let r=0;r<e.length;r++){let i=e.codePointAt(r);if(i<128)t[n++]=i;else if(wt(i))t[n++]=i-56320;else if(i<2048)n=Et(t,n,192|i>>6,i,1);else if(i<65536){if(i>=55296&&i<=57343)return O(e);n=Et(t,n,224|i>>12,i,2)}else n=Et(t,n,240|i>>18,i,3),r++}return t.slice(0,n)}function Et(e,t,n,r,i){e[t++]=n;for(let n=i-1;n>=0;n--)e[t++]=128|r>>6*n&63;return t}function Dt(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function k(e){try{return pe(e)}catch{throw new D(`feature`,`partial UTF-8 byte sequence`,`byte output that is not valid UTF-8 cannot be represented by this string-based terminal`)}}function Ot(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(Boolean),r=[];for(let e of n)if(e!==`.`){if(e===`..`){r.length>0&&r.at(-1)!==`..`?r.pop():t||r.push(`..`);continue}r.push(e)}return t?`/`+r.join(`/`):r.length===0?`.`:r.join(`/`)}function A(e,t){return t.startsWith(`/`)?Ot(t):Ot(e+`/`+t)}var kt=40,At=(e,t)=>e.isLink?.(t)===!0;function j(e,t,n,{follow:r=!0}={}){let i=jt(e,t,n,{follow:r});return i.error?{path:null,error:i.error}:t.endsWith(`/`)&&!n.isDir(i.path)?{path:null,error:`Not a directory`}:{path:i.path,error:null}}function jt(e,t,n,{follow:r=!0,lenient:i=!1}={}){if(t===``||t.includes(`\0`))return{path:`/`,error:`No such file or directory`,rest:[]};let a=(t.startsWith(`/`)?t:e+`/`+t).split(`/`).filter(Boolean),o=r||t.endsWith(`/`),s=kt,c=`/`;for(;a.length>0;){let e=a.shift();if(!n.isDir(c)){if(!i){let t=n.isFile(c)||At(n,c)?`Not a directory`:`No such file or directory`;return{path:c,error:t,rest:[e,...a]}}e===`..`?c=M(c):e!==`.`&&(c=Ft(c,e));continue}if(e===`..`){c=M(c);continue}if(e!==`.`&&(c=Ft(c,e)),!At(n,c)||a.length===0&&!o)continue;if(s--===0)return{path:c,error:`Too many levels of symbolic links`,rest:[...a]};let t=n.readLink(c);c=t.startsWith(`/`)?`/`:M(c),a.unshift(...t.split(`/`).filter(Boolean),...t.endsWith(`/`)?[`.`]:[])}let l=!n.isDir(c)&&!n.isFile(c)&&!At(n,c);return{path:c,error:l?`No such file or directory`:null,rest:[]}}var Mt=(e,t,n,r=!0)=>n===``||n.includes(`\0`)?A(t,n):jt(t,n,e,{follow:r,lenient:!0}).path;function Nt(e,t,n,r=j(e,t,n)){if(r.path!==null)return null;if(t===``||t.includes(`\0`)||t.endsWith(`/`)||r.error!==`No such file or directory`)return r.error;let i=jt(e,t,n);return i.rest.length>0?i.error:n.isDir(M(i.path))?null:`Not a directory`}function M(e){let t=Ot(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return n<0?`.`:n===0?`/`:t.slice(0,n)}function Pt(e){let t=Ot(e);if(t===`/`)return`/`;let n=t.lastIndexOf(`/`);return t.slice(n+1)}function N(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e.codePointAt(n)-t.codePointAt(n);return e.length-t.length}function Ft(e,t){return e===`/`?`/`+t:e+`/`+t}function It(e,t){return e===`/`?t.slice(1):t.slice(e.length+1)}function Lt(e,t,n=`reading them as text`){let r=vt(e);if(r===void 0)throw new D(`feature`,`binary file`,`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var Rt=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((e,n)=>e===t[n]);function*zt(e,t,n=1/0,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:`file`,depth:0};return}if(!e.isDir(t)){At(e,t)&&(yield{path:t,kind:`link`,depth:0});return}let i=[{path:t,kind:`dir`,depth:0}];for(;i.length;){let t=i.pop();if(yield t,t.kind!==`dir`||t.depth>=n||!r(t.path))continue;let{dirs:a,files:o,links:s=[]}=e.listDir(t.path),c=a.length-1,l=o.length-1,u=s.length-1;for(;c>=0||l>=0||u>=0;){let e=c>=0?`dir`:null,n=c>=0?a[c]:null;l>=0&&(n===null||N(o[l],n)>=0)&&(e=`file`,n=o[l]),u>=0&&(n===null||N(s[u],n)>=0)&&(e=`link`,n=s[u]),e===`dir`?c--:e===`file`?l--:u--,i.push({path:Ft(t.path,n),kind:e,depth:t.depth+1})}}}function*Bt(e,t){for(let n of zt(e,t))n.kind===`file`&&(yield n.path)}function Vt(e,t=`/`){let n=new Ge;try{n.mkdir(t,{recursive:!0})}catch(e){throw Wt(e,`mount ${JSON.stringify(t)}`)}let r={declared:new Map,made:new Set([`/`,t])};for(let[i,a]of Zt(e)){let e=String(i);if(e.includes(`\0`))throw TypeError(`createTerminal: source paths must not contain NUL characters`);let o=en(a,e),s=Ot(`/`+e);Ht(n,r,t===`/`?s:s===`/`?t:t+s,o,e)}return Yt(n)}function Ht(e,t,n,r,i){let a=t.declared.get(n);if(a!==void 0){if(a===r.type&&Gt(e,n,r))return;throw TypeError(`createTerminal: source ${JSON.stringify(i)} names the same path as an earlier source, which declared something else there`)}t.declared.set(n,r.type);let o=n.slice(0,n.lastIndexOf(`/`))||`/`;if(!t.made.has(o)){try{e.mkdir(o,{recursive:!0})}catch(e){throw e?.code===`ENOENT`?Ut(i):Wt(e?.code===`EEXIST`?new x(`ENOTDIR`,o):e,`source ${JSON.stringify(i)}`)}if(e.realpath(o)!==o)throw Ut(i);t.made.add(o)}try{if(r.type===`file`)e.writeFile(n,r.data);else if(r.type===`symlink`)e.symlink(r.target,n);else{try{e.mkdir(n)}catch(t){if(t?.code!==`EEXIST`||e.lstat(n).type!==`directory`)throw t}t.made.add(n)}}catch(e){throw Wt(e,`source ${JSON.stringify(i)}`)}}var Ut=e=>TypeError(`createTerminal: source ${JSON.stringify(e)} is declared through a symbolic link; declare it where the link leads`);function Wt(e,t){return e instanceof x?TypeError(`createTerminal: ${t}: ${e.message}`,{cause:e}):e}function Gt(e,t,n){return n.type===`directory`?!0:n.type===`symlink`?e.readlink(t)===n.target:Rt(e.readFile(t),typeof n.data==`string`?O(n.data):n.data)}var Kt={directory:`dirs`,file:`files`,symlink:`links`},qt=e=>e.slice(0,e.lastIndexOf(`/`))||`/`,Jt=()=>({dirs:[],files:[],links:[]});function Yt(e){let t=null,n=null,r={children:new Map,types:new Map},i=()=>n??=Xt(e,o),a=new WeakMap,o=e=>t!==null&&(e===t||e.startsWith(t+`/`)),s=t=>{let n=r.children.get(t);if(n!==void 0)return n;n={listing:Jt(),types:new Map};for(let r of e.readdir(t)){let{type:i}=e.lstat(Ft(t,r));n.types.set(r,i),n.listing[Kt[i]].push(r)}return r.children.set(t,n),n},c=e=>{if(typeof e!=`string`||!e.startsWith(`/`))return;if(e===`/`)return`directory`;let t=[],n=e;for(;o(qt(n))&&!r.types.has(n);)t.push(n),n=qt(n);let a=o(qt(n))?r.types.get(n):i().types.get(n)??``;for(let e=t.length-1;e>=0;e--){let n=t[e];a=a===`directory`?s(qt(n)).types.get(n.slice(n.lastIndexOf(`/`)+1))??``:``,r.types.set(n,a)}return a||void 0},l=t=>c(t)===void 0?void 0:e.lstat(t),u=t=>c(t)===`file`?e.readFile(t):void 0,d={vfs:e,writableAt:e=>{t=e,n=null,r={children:new Map,types:new Map}},reshaped:()=>{r={children:new Map,types:new Map}},isFile:e=>c(e)===`file`,isDir:e=>c(e)===`directory`,isLink:e=>c(e)===`symlink`,readLink:t=>c(t)===`symlink`?e.readlink(t):void 0,readFile:e=>{let t=u(e),n=t&&a.get(t);return t&&n===void 0&&a.set(t,n=Lt(t,JSON.stringify(e))),n},readBytes:e=>u(e),fileSize:e=>{let t=l(e);return t===void 0||t.type===`directory`?void 0:t.size},sameFileContents:(e,t)=>Rt(u(e),u(t)),exactBytes:u,isBytes:e=>c(e)===`file`,isEmptyFile:e=>{let t=l(e);return t?.type===`file`&&t.size===0},listDir:e=>{if(c(e)!==`directory`)throw Error(`not a directory: ${e}`);return o(e)?s(e).listing:i().children.get(e)},walkFiles:e=>Bt(d,e)};return d}function Xt(e,t){let n=new Map([[`/`,Jt()]]),r=new Map([[`/`,`directory`]]),i=[`/`];for(let{path:a,type:o,depth:s}of e.walk(`/`)){if(s===0)continue;let e=i[s-1];o===`directory`&&(i[s]=a),!t(e)&&(o===`directory`&&n.set(a,Jt()),n.get(e)[Kt[o]].push(a.slice(e.length+(e===`/`?0:1))),r.set(a,o))}return{children:n,types:r}}function Zt(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}var Qt={file:[`data`],directory:[],symlink:[`target`]},$t=new Set([`mode`,`mtime`]);function en(e,t){let n=JSON.stringify(t);if(typeof e==`string`)return{type:`file`,data:tn(e,t)};if(ArrayBuffer.isView(e))return{type:`file`,data:rn(e,t)};if(e instanceof ArrayBuffer)throw TypeError(`createTerminal: source ${n} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`createTerminal: source ${n} is ${e===null?`null`:Array.isArray(e)?`an array`:e===void 0?`undefined`:`a ${typeof e}`}; a source is text, a Uint8Array, or an object declaring its type`);if(e.format!==void 0)return{type:`file`,data:nn(e,t)};let{type:r}=e;if(r===`link`)throw TypeError(`createTerminal: source ${n} declares type "link"; a symbolic link is declared as { type: 'symlink', target }`);if(r===`hardlink`)throw TypeError(`createTerminal: source ${n} declares a hard link, which is not supported: each file here has the one name`);if(r===void 0)throw TypeError(`createTerminal: source ${n} declares no type; an object declares { type: 'file' | 'directory' | 'symlink' } or { format: 'base64', data }`);if(!Object.hasOwn(Qt,r))throw TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(r)}; the types are 'file', 'directory' and 'symlink'`);for(let t of Object.keys(e))if(!(t===`type`||Qt[r].includes(t)))throw TypeError($t.has(t)?`createTerminal: source ${n} declares \`${t}\`, which this terminal does not keep yet`:`createTerminal: source ${n} declares \`${t}\`, which a ${r} does not have`);if(r===`directory`)return{type:r};if(r===`symlink`){let{target:t}=e;if(typeof t!=`string`||t===``||t.includes(`\0`))throw TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{type:r,target:t}}let{data:i=``}=e;if(typeof i==`string`)return{type:r,data:tn(i,t)};if(ArrayBuffer.isView(i))return{type:r,data:rn(i,t)};throw TypeError(`createTerminal: source ${n} declares \`data\` that is neither text nor a Uint8Array`)}function tn(e,t){if(!e.isWellFormed())throw TypeError(`createTerminal: source ${JSON.stringify(t)} holds a lone surrogate, which no UTF-8 spells; declare the file's bytes as a Uint8Array`);return e}function nn(e,t){let n=JSON.stringify(t);if(e.format!==`base64`)throw TypeError(`createTerminal: source ${n} declares format ${JSON.stringify(e.format)}; the only format is { format: 'base64', data }`);let r=Object.keys(e).find(e=>e!==`format`&&e!==`data`);if(r!==void 0)throw TypeError(`createTerminal: source ${n} declares \`${r}\`, which base64 contents do not have`);if(typeof e.data!=`string`)throw TypeError(`createTerminal: source ${n} must declare its base64 as a string in \`data\``);try{return ae(e.data)}catch(e){throw e instanceof SyntaxError?TypeError(`createTerminal: source ${n} declares base64 that does not decode`,{cause:e}):e}}function rn(e,t){if(e.BYTES_PER_ELEMENT!==1)throw TypeError(`createTerminal: source ${JSON.stringify(t)} is a ${e[Symbol.toStringTag]??`view`}; declare a file's bytes as a Uint8Array`);return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var an={__proto__:null,alpha:`A-Za-z`,digit:`0-9`,alnum:`0-9A-Za-z`,upper:`A-Z`,lower:`a-z`,space:` \\t\\n\\v\\f\\r`,blank:` \\t`,punct:"!-\\/:-@\\[-`{-~",xdigit:`0-9A-Fa-f`,cntrl:`\\x00-\\x1F\\x7F`,print:`\\x20-\\x7E`,graph:`\\x21-\\x7E`,word:`0-9A-Za-z_`},on={__proto__:null};for(let[e,t]of Object.entries(an)){let n=RegExp(`[${t}]`,`u`),r=[];for(let e=0;e<128;e++){if(!n.test(String.fromCodePoint(e)))continue;let t=r.at(-1);t&&t[1]===e-1?t[1]=e:r.push([e,e])}on[e]=r}var sn=32767;function cn(e,t){if(e>sn||t!==void 0&&t>sn)throw Error(`Regular expression too big`)}function ln(e,t,n=!1){let r=t+1;e[r]===`^`&&r++;let i=!0,a=!1;for(;r<e.length;){let t=e[r];if(t===`]`&&!i)return r;if(i=!1,t===`[`&&`:.=`.includes(e[r+1]??``)){let t=e[r+1],i=e.indexOf(t+`]`,r+2);if(i===-1)throw Error(`Unmatched [, [^, [:, [., or [=`);if(t===`:`&&!(e.slice(r+2,i)in an))throw Error(`Invalid character class name`);if(t!==`:`&&n&&/\P{ASCII}/u.test(e.slice(r+2,i)))throw Error(`Invalid collation character`);r=i+2,a=t!==`.`;continue}if(t===`-`&&a&&r+1<e.length&&e[r+1]!==`]`)throw Error(`Invalid range end`);let o=t===`\\`&&r+1<e.length?2:1;if(e[r+o]===`-`&&e[r+o+1]!==void 0&&e[r+o+1]!==`]`){let t=r+o+1,i=e[t]===`[`?e[t+1]:void 0;if(i===`:`||i===`=`)throw Error(`Invalid range end`);let s=i===`.`?e.indexOf(`.]`,t+2):-1;if(i===`.`&&s===-1)throw Error(`Unmatched [, [^, [:, [., or [=`);let c=i===`.`?t+2:t+ +(e[t]===`\\`);if(n&&(e.codePointAt(r+o-1)>127||e.codePointAt(c)>127))throw Error(`Invalid collation character`);r=s===-1?t+(e[t]===`\\`?2:1):s+2,a=!0}else r+=o,a=!1}throw Error(`Unmatched [, [^, [:, [., or [=`)}function un(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let i=n.classes?n.classes.body(r[1]):an[r[1]];if(i===void 0){if(n?.unknown!==`empty`)throw Error(`invalid character class \`[:${r[1]}:]\``);return{body:``,end:t+r[0].length}}return{body:i,end:t+r[0].length}}var dn={alpha:`1t:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,3:3,3:7,2:1,2:1,1:0,8:0,4:1,1:4,2:b,a:0,4:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,4:4,4:1,2:1,4:0,7:3,1:0,7:f,b:2,1:8,1:2,1:l,1:6,1:1,1:4,3:8,1:2,1:1,3:0,f:3,2:9,9:3,4:2,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,9:1,4:1,1:4,2:9,1:0,g:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:2,3:0,6:0,e:9,g:c,1:2,1:m,1:f,3:7,1:2,1:2,8:1,1:2,2:0,2:3,2:9,g:3,1:7,1:2,1:m,1:9,1:4,3:7,1:2,1:2,8:1,6:1,1:3,2:9,1:2,c:c,1:2,1:14,2:7,1:2,1:2,1:0,5:3,7:4,2:9,a:5,1:2,1:h,3:n,1:8,1:0,2:6,8:5,1:0,1:7,6:9,2:1,d:1l,5:6,6:0,2:9,13:1,1:0,1:4,1:n,1:0,1:i,1:2,2:4,1:0,6:0,2:9,2:3,w:0,v:9,m:7,1:z,4:i,4:f,1:z,1v:1i,1:0,2:e,6:25,2:11,1:0,5:0,2:16,1:98,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,11:f,g:2d,2:5,3:h7,2:g,1:p,5:22,3:a,7:j,b:k,c:j,c:c,1:2,1:1,c:1f,2:i,e:0,4:0,3:9,12:9,6:2g,7:16,5:1x,a:u,1:b,4:8,d:13,2:4,b:17,4:p,6:9,12:r,4:1q,2:j,b:9,6:9,d:0,n:1,b:2,1d:1f,1:e,1:7,3:9,12:15,2:1l,1:a,e:1i,9:9,3:1c,2:8,7:16,2:2,15:3,1:5,1:1,3:0,5:5b,13:d,b:7p,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:6,1:0,3:2,1:6,3:3,2:5,4:c,5:2,1:6,38:0,d:0,g:c,2t:0,4:0,2:9,1:0,3:4,6:0,1:0,1:0,1:3,1:a,2:3,5:4,4:0,h:14,ml:1f,1ee:6c,6:3,3:1,c:11,1:0,5:0,2:1j,7:0,g:m,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:v,1b:0,d1:2,p:8,7:4,2:4,4:2d,6:2,1:2h,1:3,5:16,1:2l,h:v,1c:f,e8:533,1s:h3g,1v:19,2:7g,3:r,k:1a,5:7,3:34,13:8,2:2u,2:1r,5:1,1:0,1:4,o:j,1:w,o:1f,c:1v,1:0,a:9,o:5,3:0,1:19,5:y,d:s,3:1e,1:b,f:a,6:u,1:1i,9:d,2:9,6:m,3:1w,1:0,1:0,o:2,2:f,2:3,b:5,2:5,2:5,9:6,1:6,1:16,1:d,6:3e,5:9,6:8mb,c:m,4:1c,6is:a5,2:2x,12:6,c:4,5:b,1:c,1:4,1:0,1:1,1:1,1:2z,x:a2,i:1r,2:1h,14:b,38:4,1:3q,j:9,7:p,6:p,b:2g,3:5,2:5,2:5,2:2,z:b,1:p,1:i,1:1,1:e,2:d,y:3e,1x:1g,7f:s,3:1c,1b:v,d:t,5:16,5:t,2:z,4:7,1:4,16:4d,2:9,6:z,4:z,4:13,8:1f,c:a,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,a:m,9:u,1t:i,1:1,a:l,a:p,1y:1j,6:1,1s:3,1:1,5:7,1:2,1:s,16:s,3:s,z:7,1:r,r:1h,a:l,a:i,d:h,32:20,1j:1e,d:1e,d:13,8:9,92:15,1:1,3:1,26:s,a:0,8:l,16:h,1a:k,r:m,9:1x,w:9,1:4,a:1k,9:0,d:o,7:9,6:1e,3:9,4:3,8:y,3:0,9:1r,1:3,9:c,1:0,z:h,1:x,2:0,6:3,1q:6,1:0,1:3,1:e,1:9,7:1k,7:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,3:0,6:0,5:6,4c:1t,1:2,1:3,5:9,5:2,u:1t,2:1,1:0,8:9,4m:1h,2:6,p:5,y:1q,1:0,3:0,b:9,12:1h,2:0,7:9,1i:q,2:d,5:9,6:6,55:1k,2v:21,l:7,2:0,2:7,1:1,1:t,1:1,2:1,2:3,d:9,1y:7,2:19,2:5,1:0,1:1,r:1e,2:9,h:1z,5:0,i:20,7b:8,1:18,1:6,1:0,f:9,o:t,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:2,1:0,2:1,8:9,6:5,1:1,1:10,1:1,1:3,1:0,7:9,8m:m,9:g,1:14,3:2,f:9,2e:0,27:pl,2u:32,h:5f,218:2o,f:tr,h:5,33t:g6,6nt:fs,7:u,1:9,6:26,1:9,6:t,i:1b,g:3,c:9,9:k,5:i,j4:1r,3k:22,4:1k,7:g,1s:1,1:0,c:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,4:0,4m9:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:o,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:7,2:1d,1ds:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,a:6,2:9,4:0,8x:t,i:17,4:9,d2:r,4:9,km:6,1:3,1:1,1:e,1:5g,1n:1v,3:0,3:0,4:9,x2:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,hg:p,6:p,6:p,21y:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f`,digit:`1c:9`,alnum:`1c:9,7:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,3:3,3:7,2:1,2:1,1:0,8:0,4:1,1:4,2:b,a:0,4:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,4:4,4:1,2:1,4:0,7:3,1:0,7:f,b:2,1:8,1:2,1:l,1:6,1:1,1:4,3:8,1:2,1:1,3:0,f:3,2:9,9:3,4:2,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,9:1,4:1,1:4,2:9,1:0,g:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:2,3:0,6:0,e:9,g:c,1:2,1:m,1:f,3:7,1:2,1:2,8:1,1:2,2:0,2:3,2:9,g:3,1:7,1:2,1:m,1:9,1:4,3:7,1:2,1:2,8:1,6:1,1:3,2:9,1:2,c:c,1:2,1:14,2:7,1:2,1:2,1:0,5:3,7:4,2:9,a:5,1:2,1:h,3:n,1:8,1:0,2:6,8:5,1:0,1:7,6:9,2:1,d:1l,5:6,6:0,2:9,13:1,1:0,1:4,1:n,1:0,1:i,1:2,2:4,1:0,6:0,2:9,2:3,w:0,v:9,m:7,1:z,4:i,4:f,1:z,1v:1i,1:0,2:e,6:25,2:11,1:0,5:0,2:16,1:98,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,11:f,g:2d,2:5,3:h7,2:g,1:p,5:22,3:a,7:j,b:k,c:j,c:c,1:2,1:1,c:1f,2:i,e:0,4:0,3:9,12:9,6:2g,7:16,5:1x,a:u,1:b,4:8,d:13,2:4,b:17,4:p,6:9,12:r,4:1q,2:j,b:9,6:9,d:0,n:1,b:2,1d:1f,1:e,1:7,3:9,12:15,2:1l,1:a,e:1i,9:9,3:1c,2:8,7:16,2:2,15:3,1:5,1:1,3:0,5:5b,13:d,b:7p,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:6,1:0,3:2,1:6,3:3,2:5,4:c,5:2,1:6,38:0,d:0,g:c,2t:0,4:0,2:9,1:0,3:4,6:0,1:0,1:0,1:3,1:a,2:3,5:4,4:0,h:14,ml:1f,1ee:6c,6:3,3:1,c:11,1:0,5:0,2:1j,7:0,g:m,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:v,1b:0,d1:2,p:8,7:4,2:4,4:2d,6:2,1:2h,1:3,5:16,1:2l,h:v,1c:f,e8:533,1s:h3g,1v:19,2:7g,3:r,k:1a,5:7,3:34,13:8,2:2u,2:1r,5:1,1:0,1:4,o:j,1:w,o:1f,c:1v,1:0,a:9,o:5,3:0,1:19,5:y,d:s,3:1e,1:b,f:a,6:u,1:1i,9:d,2:9,6:m,3:1w,1:0,1:0,o:2,2:f,2:3,b:5,2:5,2:5,9:6,1:6,1:16,1:d,6:3e,5:9,6:8mb,c:m,4:1c,6is:a5,2:2x,12:6,c:4,5:b,1:c,1:4,1:0,1:1,1:1,1:2z,x:a2,i:1r,2:1h,14:b,38:4,1:3q,j:9,7:p,6:p,b:2g,3:5,2:5,2:5,2:2,z:b,1:p,1:i,1:1,1:e,2:d,y:3e,1x:1g,7f:s,3:1c,1b:v,d:t,5:16,5:t,2:z,4:7,1:4,16:4d,2:9,6:z,4:z,4:13,8:1f,c:a,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,a:m,9:u,1t:i,1:1,a:l,a:p,1y:1j,6:1,1s:3,1:1,5:7,1:2,1:s,16:s,3:s,z:7,1:r,r:1h,a:l,a:i,d:h,32:20,1j:1e,d:1e,d:13,8:9,92:15,1:1,3:1,26:s,a:0,8:l,16:h,1a:k,r:m,9:1x,w:9,1:4,a:1k,9:0,d:o,7:9,6:1e,3:9,4:3,8:y,3:0,9:1r,1:3,9:c,1:0,z:h,1:x,2:0,6:3,1q:6,1:0,1:3,1:e,1:9,7:1k,7:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,3:0,6:0,5:6,4c:1t,1:2,1:3,5:9,5:2,u:1t,2:1,1:0,8:9,4m:1h,2:6,p:5,y:1q,1:0,3:0,b:9,12:1h,2:0,7:9,1i:q,2:d,5:9,6:6,55:1k,2v:21,l:7,2:0,2:7,1:1,1:t,1:1,2:1,2:3,d:9,1y:7,2:19,2:5,1:0,1:1,r:1e,2:9,h:1z,5:0,i:20,7b:8,1:18,1:6,1:0,f:9,o:t,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:2,1:0,2:1,8:9,6:5,1:1,1:10,1:1,1:3,1:0,7:9,8m:m,9:g,1:14,3:2,f:9,2e:0,27:pl,2u:32,h:5f,218:2o,f:tr,h:5,33t:g6,6nt:fs,7:u,1:9,6:26,1:9,6:t,i:1b,g:3,c:9,9:k,5:i,j4:1r,3k:22,4:1k,7:g,1s:1,1:0,c:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,4:0,4m9:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:o,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:u,1:o,1:7,2:1d,1ds:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,a:6,2:9,4:0,8x:t,i:17,4:9,d2:r,4:9,km:6,1:3,1:1,1:e,1:5g,1n:1v,3:0,3:0,4:9,x2:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,hg:p,6:p,6:p,21y:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f`,upper:`1t:p,2t:m,1:6,x:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,3:1,1:0,1:1,1:2,2:3,1:1,1:2,3:1,1:1,1:0,1:0,1:1,1:0,2:0,1:1,1:2,1:0,1:1,3:0,7:1,1:1,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:1,1:0,1:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,7:1,1:1,2:0,1:3,1:0,1:0,1:0,1:0,81:0,1:0,3:0,8:0,6:0,1:2,1:0,1:1,1:g,1:8,z:0,2:2,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,5:0,2:0,1:1,2:1e,1c:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:11,289:11,1:0,5:0,k2:2d,1p6:16,2:2,8w:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:7,8:5,a:7,8:7,8:5,b:0,1:0,1:0,1:0,8:7,o:7,8:7,8:7,8:4,b:4,b:3,c:4,b:4,79:0,4:0,3:2,2:2,2:0,3:4,6:0,1:0,1:0,1:3,2:3,a:1,5:0,q:f,j:0,mq:p,1f4:1b,1c:0,1:2,2:0,1:0,1:0,1:3,1:0,2:0,8:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,8:0,1:0,4:0,nyl:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,j:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,3r:0,1:0,1:0,1:0,1:0,1:0,1:0,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,a:0,1:0,1:1,1:0,1:0,1:0,1:0,4:0,1:0,2:0,1:0,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:4,1:4,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:3,1:0,6:0,5:0,1:0,s:0,h7v:p,xx:13,3s:z,4c:a,1:e,1:6,1:1,1d6:1e,2ct:v,gw0:v,k2o:p,q:p,q:p,q:0,1:1,2:0,2:1,2:3,1:7,q:p,q:1,1:3,2:7,1:6,r:1,1:3,1:4,1:0,3:6,r:p,q:p,q:p,q:p,q:p,q:p,u:o,x:o,x:o,x:o,x:o,x:0,3ed:x,1la:p,6:p,6:p`,lower:`2p:p,1b:0,a:0,4:0,10:n,1:7,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:2,2:0,1:0,2:0,3:1,4:0,2:0,3:2,2:0,2:0,1:0,1:0,2:0,1:1,1:0,2:0,3:0,1:0,2:1,2:2,5:1,1:1,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,1:1,1:0,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:6,2:0,2:1,1:0,4:0,1:0,1:0,1:0,1:1w,1:z,7:1,u:4,2o:0,17:0,1:0,3:0,2:3,i:0,r:y,1:1,3:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:4,1:0,2:0,2:1,1f:1b,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,9:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,2:0,1:0,1:0,1:0,1:0,1:0,1:1,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1c:14,287:16,1:3,l4:5,1oi:8,3b:5b,1t:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:8,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:8,8:5,a:7,8:7,8:5,a:7,8:7,8:d,2:7,8:7,8:7,8:4,1:1,6:0,3:2,1:1,8:3,2:1,8:7,a:2,1:1,3d:0,d:0,g:c,31:0,3:1,3:0,r:0,4:0,4:0,2:1,8:3,4:0,x:f,4:0,nf:p,1fq:1b,1:0,3:1,1:0,1:0,1:0,4:0,1:1,1:7,3:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:1,7:0,1:0,4:0,c:11,1:0,5:0,nwz:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,j:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:2,3p:0,1:0,1:0,1:0,1:0,1:0,1:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:9,1:0,1:0,2:0,1:0,1:0,1:0,1:0,4:0,1:0,2:0,1:2,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,5:0,5:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0,4:0,1:0,6:0,1:0,1:0,1:0,1:0,o:2,1:0,1:2,mt:16,1:d,6:27,fnk:6,c:4,tl:p,y5:13,3s:z,4b:a,1:e,1:6,1:1,cj:0,2:2,1:15,1:8,zp:1e,2bx:v,gw0:v,k2i:p,q:6,1:h,q:p,q:3,1:0,1:6,1:a,q:p,q:p,q:p,q:p,q:p,q:p,q:p,q:p,q:r,s:o,1:5,q:o,1:5,q:o,1:5,q:o,1:5,q:o,1:5,1:0,1f8:9,1:j,6:5,79:1p,1pw:x`,space:`9:4,i:0,4f3:0,1vj:6,1:2,t:1,1h:0,334:0`,blank:`9:0,m:0,4f3:0,1vj:6,1:2,2c:0,334:0`,punct:`x:e,a:6,q:5,q:3,x:9,1:9,1:3,1:4,n:0,v:0,cq:3,c:d,5:6,1:0,1:2d,1:15,5:0,8:0,5:1,1:0,32:0,3v:7,5s:5,15:1,2:2,1:u,e:0,1:0,2:0,2:0,18:1,b:f,b:4,1k:0,h:3,2u:0,8:3,8:3,g:1,1:d,1:0,1c:a,4g:8,2:3,3:2,o:1,j:0,2:e,q:2,2:0,15:0,7:1,6:7,16:9,c:2,7:5,24:0,g:0,3:3,f:1,a:0,23:0,g:0,10:9,1:1,1p:0,g:0,14:0,1x:0,g:0,y:1,b:2,1o:0,g:0,7:0,q:0,1:5,2d:0,y:a,1t:0,g:0,15:8,4:0,1j:0,g:0,31:1,g:0,1:0,8:6,h:9,28:0,15:0,22:0,7:5,1:1,a:1,2m:0,d:4,1:0,1e:u,a:l,1w:3,1i:e,1:c,2k:0,1:1,f:5,26:1,2j:0,gx:v,j:9,2u:0,h8:1,18:1,26:2,12:1,u:2,3h:1,j:d,1:3,1:0,i:9,6:f,89:2,4:0,3:1,44:0,3:x,u:1,1s:0,k:7,2:0,w:6,1:5,2:e,2:a,2w:0,f:0,l:10,17:1,1m:0,b:1,8:3,1j:0,3:4,1q:1,1s:7,8:o,4:0,6:0,2:2,5i:12,e:a,cd:0,1:2,b:2,d:2,d:2,d:1,8:0,3:s,2:1g,1:4,1:a,3:a,1:e,h:w,f:w,f:1,1:3,1:1,a:0,1:2,5:5,1:0,1:0,1:0,4:0,b:1,4:4,5:3,1:g,15:2,4:ie,p:a,l:2d,1g:1ah,2:v,1:2w,6d:5,4:2,7:6,34:0,e:0,3k:1a,1:19,y:p,1:2g,c:5x,q:f,1:3,3:o,9:6,5:1,5:2,2h:3,3:0,2i:0,44:f,w:z,b:0,g:u,1:db,534:1r,h3k:1i,1j:1,7h:2,2n:4,8:2,35:7,8:m,9:1,2v:1,3f:0,x:4,3:9,1m:3,24:0,9:1,g:h,6:2,1:0,1a:4,z:0,b:0,2b:0,c:d,g:1,3g:3,n:2,1x:0,1:0,s:1,g:1,4:0,2s:0,e:1,3j:2,aaa:4xr,fd:0,3s:g,aj:h,3j:0,18:t,6:1e,1:i,1:3,43:0,1:e,a:6,q:5,q:a,3e:6,1:6,a:4,76:2,4:18,3:8,1h:p,1:c,3:0,1b:19,6a:r,10:3,3f:0,1c:0,bi:0,kn:8,n:8,13:8,23:4,m:5,3:0,v:0,3g:1,2:f,2:19,1k:2,4:9,7:8,10:2,t:2,14:0,s:1,4:b,1u:6,o:7,o:7,p:3,c:6,96:5,9s:u,1a:0,27:2,t:9,v:j,14:7,1n:6,3e:7,4:j,a:0,e:0,1l:8,b:0,2t:1,b:3,1b:2,22:0,4:8,d:0,1:2,1:j,1s:1,1:5,2z:0,1r:1,28:1,g:0,o:6,3:4,5p:0,3:0,4:4,a:1,1:1,2r:1,2:0,6w:o,2v:0,1:2,s:c,21:1,1:0,35:0,e:5,6x:2,4u:8,22:1,4:3,49:0,1:0,28:1,a:8,28:4,1:4,2l:9,8l:0,1:4,k:i,3:1,5s:0,1:1,29:0,9r:1,20:e,34:1d,d:0,vk:4,29o:1,u5:g,6:e,aoo:1,3k:5,1m:f,4:1,l:6,m6:q,93:0,1:0,f5j:1,1:4,3mk:19,2:m,9:37,1o:6t,a:12,2:5d,l:1x,3e:j,c:j,c:2e,9:o,nc:0,p:0,v:0,p:0,v:0,p:0,v:0,p:0,v:0,p:0,1o:i3,f:4,1:e,1a8:6,o:0,9q:0,1p:3,f:0,do:3,rb:f,31:2,1:2,j:1,lt:1v,24:1o,c2:1,7i:17,4:2r,c:e,2:e,1:e,1:10,a:1b,q:5,q:5,q:z,1k:s,d:17,4:8,7:1,e:5,4a:rb,4:g,3:c,3:3a,4:2m,6:b,4:0,f:b,4:1j,8:9,6:13,8:t,2:1,26:9f,c:d,2:c,3:8,7:19,1:6,8:d,4:8,7:8,7:42,1:1i,gvna:0,u:2n,3k:6n,1e6o:1ekd,2:1ekd`,xdigit:`1c:9,7:5,q:5`,cntrl:`0:v,2n:w,688:1`,print:`w:2m,x:k7,2:5,4:6,1:0,1:j,1:b0,1:11,2:1d,2:2,1:1i,8:q,4:5,b:7h,1:1n,2:2s,e:1m,2:1c,2:e,1:r,2:0,1:a,5:u,1:1,6:6j,1:7,2:1,2:l,1:6,1:0,3:3,2:8,2:1,2:3,8:0,4:1,1:4,2:o,2:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,2:0,1:4,4:1,2:2,3:0,7:3,1:0,7:g,a:2,1:8,1:2,1:l,1:6,1:1,1:4,2:9,1:2,1:2,2:0,f:3,2:b,7:6,1:2,1:7,2:1,2:l,1:6,1:1,1:4,2:8,2:1,2:2,7:2,4:1,1:4,2:h,a:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:3,2:0,6:0,e:k,5:c,1:2,1:m,1:f,2:8,1:2,1:3,7:1,1:2,2:0,2:3,2:9,7:l,1:2,1:m,1:9,1:4,2:8,1:2,1:3,7:1,6:1,1:3,2:9,1:2,c:c,1:2,1:1e,1:2,1:5,4:f,2:p,1:2,1:h,3:n,1:8,1:0,2:6,3:0,4:5,1:0,1:7,6:9,2:2,c:1l,4:s,11:1,1:0,1:4,1:n,1:0,1:m,2:4,1:0,1:6,1:9,2:3,w:1z,1:z,4:12,1:z,1:e,1:c,11:5h,1:0,5:0,2:ag,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,2:v,3:p,6:2d,2:5,2:ik,3:2g,7:l,9:n,9:j,c:c,1:2,1:1,c:2l,2:9,6:9,6:p,6:2g,7:16,5:1x,a:u,1:b,4:b,4:0,3:15,2:4,b:17,4:p,6:a,3:1p,2:1s,1:s,2:a,6:9,6:d,2:u,1d:24,3:1a,1:37,8:1n,3:e,3:1n,7:16,2:a,8:16,5:et,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:e,1:d,2:5,1:i,2:2,1:8,1:13,2:1m,1:b,2:q,1:c,3:w,f:w,f:3v,4:ie,p:a,l:1eb,2:v,1:9o,5:18,1:0,5:0,2:1j,7:1,e:n,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:3h,y:p,1:2g,c:5x,q:27,1:2d,2:2u,5:16,1:2l,1:2b,b:1b,1:mlo,3:1i,9:9n,k:53,8:5m,5:1,1:0,1:4,o:1m,3:9,6:1j,8:1x,8:b,6:37,b:t,3:25,1:a,4:w,1:1i,9:d,2:9,2:2u,o:r,a:5,2:5,2:5,9:6,1:6,1:1n,4:3h,2:9,6:8mb,c:m,4:1c,1l0:57x,2:2x,12:6,c:4,5:p,1:4,1:0,1:1,1:1,1:3g,g:cc,2:1h,7:0,w:15,6:1e,1:i,1:3,4:4,1:3q,2:0,1:59,3:5,2:5,2:5,2:2,3:6,1:6,a:4,2:b,1:p,1:i,1:1,1:e,2:d,y:3e,5:2,4:18,3:2f,1:c,3:0,1b:19,3m:s,3:1c,f:r,4:z,9:t,5:16,5:t,1:10,4:d,16:4d,2:9,6:z,4:z,4:13,8:1f,b:b,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,1:1z,8:8,1c:i,1:1,5:w,3:q,5:0,1s:1j,4:j,2:1d,1:1,5:7,1:2,1:s,2:2,4:9,7:8,7:1r,w:12,4:b,9:1h,3:s,2:q,5:p,7:3,c:6,28:20,1j:1e,d:1e,7:19,8:9,86:u,1:15,1:2,2:1,23:16,8:15,m:p,12:r,k:m,9:25,4:z,9:1v,a:0,2:o,7:9,6:1g,1:h,8:12,9:2n,1:j,b:h,1:1a,1q:6,1:0,1:3,1:e,1:a,6:1m,5:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,1:9,2:1,2:2,2:0,6:0,5:6,2:6,3:4,3v:2j,1:4,u:1z,8:9,4m:1h,2:11,y:1w,b:9,6:c,j:1l,6:9,1i:q,2:e,4:m,55:1n,2s:2a,c:7,2:0,2:7,1:1,1:t,1:1,2:b,9:9,1y:7,2:19,2:a,r:1z,8:2a,d:20,7:9,6u:8,1:18,1:d,a:s,3:v,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:8,8:9,6:5,1:1,1:10,1:1,1:5,7:9,8m:o,7:g,1:14,3:r,2e:0,f:1d,d:pm,2u:32,1:4,b:5f,218:2q,d:ut,33e:g6,6nt:fs,7:u,1:9,4:28,1:9,6:t,2:5,a:1x,a:9,1:6,1:k,5:i,j4:2i,2t:22,4:1k,7:g,1s:4,b:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,2:7,3mk:19,2:m,9:37,1o:6t,a:12,2:5d,l:1x,3e:j,c:j,c:2e,9:o,3r:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:83,2:jh,f:4,1:e,uo:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,3:d,2:9,4:1,8w:u,h:1l,5:0,cw:15,km:6,1:3,1:1,1:e,1:5g,2:f,15:23,4:9,4:1,lt:1v,24:1o,5e:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,1g:1,7i:17,4:2r,c:e,2:e,1:e,1:10,a:4t,1k:s,d:17,4:8,7:1,e:5,4a:rb,4:g,3:c,3:3a,4:2m,6:b,4:0,f:b,4:1j,8:9,6:13,8:t,2:1,26:9f,c:d,2:c,3:8,7:19,1:6,8:d,4:8,7:8,7:42,1:1i,11:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f,f975:0,u:2n,3k:6n,1e6o:1ekd,2:1ekd`,graph:`x:2l,x:k7,2:5,4:6,1:0,1:j,1:b0,1:11,2:1d,2:2,1:1i,8:q,4:5,b:7h,1:1n,2:2s,e:1m,2:1c,2:e,1:r,2:0,1:a,5:u,1:1,6:6j,1:7,2:1,2:l,1:6,1:0,3:3,2:8,2:1,2:3,8:0,4:1,1:4,2:o,2:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,2:0,1:4,4:1,2:2,3:0,7:3,1:0,7:g,a:2,1:8,1:2,1:l,1:6,1:1,1:4,2:9,1:2,1:2,2:0,f:3,2:b,7:6,1:2,1:7,2:1,2:l,1:6,1:1,1:4,2:8,2:1,2:2,7:2,4:1,1:4,2:h,a:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:3,2:0,6:0,e:k,5:c,1:2,1:m,1:f,2:8,1:2,1:3,7:1,1:2,2:0,2:3,2:9,7:l,1:2,1:m,1:9,1:4,2:8,1:2,1:3,7:1,6:1,1:3,2:9,1:2,c:c,1:2,1:1e,1:2,1:5,4:f,2:p,1:2,1:h,3:n,1:8,1:0,2:6,3:0,4:5,1:0,1:7,6:9,2:2,c:1l,4:s,11:1,1:0,1:4,1:n,1:0,1:m,2:4,1:0,1:6,1:9,2:3,w:1z,1:z,4:12,1:z,1:e,1:c,11:5h,1:0,5:0,2:ag,1:3,2:6,1:0,1:3,2:14,1:3,2:w,1:3,2:6,1:0,1:3,2:e,1:1k,1:3,2:1u,2:v,3:p,6:2d,2:5,2:hr,1:r,3:2g,7:l,9:n,9:j,c:c,1:2,1:1,c:2l,2:9,6:9,6:p,6:2g,7:16,5:1x,a:u,1:b,4:b,4:0,3:15,2:4,b:17,4:p,6:a,3:1p,2:1s,1:s,2:a,6:9,6:d,2:u,1d:24,3:1a,1:37,8:1n,3:e,3:1n,7:16,2:a,8:16,5:et,2:5,2:11,2:5,2:7,1:0,1:0,1:0,1:u,2:1g,1:e,1:d,2:5,1:i,2:2,1:8,8:0,3:s,2:1g,1:4,1:b,2:q,1:c,3:w,f:w,f:3v,4:ie,p:a,l:1eb,2:v,1:9o,5:18,1:0,5:0,2:1j,7:1,e:n,9:6,1:6,1:6,1:6,1:6,1:6,1:6,1:6,1:3h,y:p,1:2g,c:5x,q:f,1:1q,1:2d,2:2u,5:16,1:2l,1:2b,b:1b,1:mlo,3:1i,9:9n,k:53,8:5m,5:1,1:0,1:4,o:1m,3:9,6:1j,8:1x,8:b,6:37,b:t,3:25,1:a,4:w,1:1i,9:d,2:9,2:2u,o:r,a:5,2:5,2:5,9:6,1:6,1:1n,4:3h,2:9,6:8mb,c:m,4:1c,1l0:57x,2:2x,12:6,c:4,5:p,1:4,1:0,1:1,1:1,1:3g,g:cc,2:1h,7:0,w:15,6:1e,1:i,1:3,4:4,1:3q,2:0,1:59,3:5,2:5,2:5,2:2,3:6,1:6,a:4,2:b,1:p,1:i,1:1,1:e,2:d,y:3e,5:2,4:18,3:2f,1:c,3:0,1b:19,3m:s,3:1c,f:r,4:z,9:t,5:16,5:t,1:10,4:d,16:4d,2:9,6:z,4:z,4:13,8:1f,b:b,1:e,1:6,1:1,1:a,1:e,1:6,1:1,1v:8m,9:l,a:7,o:5,1:15,1:8,1x:5,2:0,1:17,1:1,3:0,2:m,1:1z,8:8,1c:i,1:1,5:w,3:q,5:0,1s:1j,4:j,2:1d,1:1,5:7,1:2,1:s,2:2,4:9,7:8,7:1r,w:12,4:b,9:1h,3:s,2:q,5:p,7:3,c:6,28:20,1j:1e,d:1e,7:19,8:9,86:u,1:15,1:2,2:1,23:16,8:15,m:p,12:r,k:m,9:25,4:z,9:1v,a:0,2:o,7:9,6:1g,1:h,8:12,9:2n,1:j,b:h,1:1a,1q:6,1:0,1:3,1:e,1:a,6:1m,5:9,6:3,1:7,2:1,2:l,1:6,1:1,1:4,1:9,2:1,2:2,2:0,6:0,5:6,2:6,3:4,3v:2j,1:4,u:1z,8:9,4m:1h,2:11,y:1w,b:9,6:c,j:1l,6:9,1i:q,2:e,4:m,55:1n,2s:2a,c:7,2:0,2:7,1:1,1:t,1:1,2:b,9:9,1y:7,2:19,2:a,r:1z,8:2a,d:20,7:9,6u:8,1:18,1:d,a:s,3:v,2:l,1:d,21:6,1:1,1:17,3:0,1:1,1:8,8:9,6:5,1:1,1:10,1:1,1:5,7:9,8m:o,7:g,1:14,3:r,2e:0,f:1d,d:pm,2u:32,1:4,b:5f,218:2q,d:ut,33e:g6,6nt:fs,7:u,1:9,4:28,1:9,6:t,2:5,a:1x,a:9,1:6,1:k,5:i,j4:2i,2t:22,4:1k,7:g,1s:4,b:1,e:4qf,8:yd,16:8,6w7:3,1:6,1:1,1:82,f:0,t:2,2:0,e:3,8:az,1s4:2y,5:c,3:8,7:9,2:7,3mk:19,2:m,9:37,1o:6t,a:12,2:5d,l:1x,3e:j,c:j,c:2e,9:o,3r:2c,1:1y,1:1,2:0,2:1,2:3,1:b,1:0,1:6,1:1s,1:3,2:7,1:6,1:r,1:3,1:4,1:0,3:6,1:9f,2:83,2:jh,f:4,1:e,uo:u,6:5,5x:6,1:g,2:6,1:1,1:4,5:1p,x:0,34:18,3:d,2:9,4:1,8w:u,h:1l,5:0,cw:15,km:6,1:3,1:1,1:e,1:5g,2:f,15:23,4:9,4:1,lt:1v,24:1o,5e:3,1:q,1:1,1:0,2:0,1:9,1:3,1:0,1:0,6:0,4:0,1:0,1:0,1:2,1:1,1:0,2:0,1:0,1:0,1:0,1:0,1:1,1:0,2:3,1:6,1:3,1:3,1:0,1:9,1:g,5:2,1:4,1:g,1g:1,7i:17,4:2r,c:e,2:e,1:e,1:10,a:4t,1k:s,d:17,4:8,7:1,e:5,4a:rb,4:g,3:c,3:3a,4:2m,6:b,4:0,f:b,4:1j,8:9,6:13,8:t,2:1,26:9f,c:d,2:c,3:8,7:19,1:6,8:d,4:8,7:8,7:42,1:1i,11:9,sm:wyn,w:37d,6:65,2:4g1,e:5rk,f:h9,1wi:f1,15u:3t6,5:38f,f975:0,u:2n,3k:6n,1e6o:1ekd,2:1ekd`},fn=`2p:q:-w:1,51:1:kn:1,68:n:-w:1,6w:7:-w:1,73:1:3d:1,75:o:-1:2,8h:1:-6g:1,8j:3:-1:2,8q:8:-1:2,97:n:-1:2,ai:3:-1:2,an:1:-8c:1,ao:1:5f:1,ar:2:-1:2,aw:1:-1:1,b0:1:-1:1,b6:1:-1:1,b9:1:2p:1,bd:1:-1:1,be:1:4j:1,bi:1:3m:1,bl:3:-1:2,bs:1:-1:1,bx:1:-1:1,c0:1:-1:1,c4:2:-1:2,c9:1:-1:1,cd:1:-1:1,cf:1:1k:1,cl:1:-1:1,cm:1:-2:1,co:1:-1:1,cp:1:-2:1,cr:1:-1:1,cs:1:-2:1,cu:8:-1:2,d9:1:-27:1,db:9:-1:2,du:1:-1:1,dv:1:-2:1,dx:1:-1:1,e1:k:-1:2,f7:9:-1:2,fw:1:-1:1,fz:2:8cf:1,g2:1:-1:1,g7:5:-1:2,gg:1:8bj:1,gh:1:8bg:1,gi:1:8bi:1,gj:1:-5u:1,gk:1:-5q:1,gm:2:-5p:1,gp:1:-5m:1,gr:1:-5n:1,gs:1:wnj:1,gw:1:-5p:1,gx:1:wnf:1,gz:1:-5r:1,h1:1:wmg:1,h2:1:wn8:1,h4:1:-5t:1,h5:1:-5v:1,h6:1:wn8:1,h7:1:8af:1,h8:1:wn5:1,hb:1:-5v:1,hd:1:8al:1,he:1:-5x:1,hh:1:-5y:1,hp:1:89z:1,hs:1:-62:1,hu:1:wn7:1,hv:1:-62:1,hz:1:wmi:1,i0:1:-62:1,i1:1:-1x:1,i2:2:-61:1,i4:1:-1z:1,ia:1:-63:1,il:1:wlx:1,im:1:wlu:1,n9:1:2c:1,oh:2:-1:2,on:1:-1:1,or:3:3m:1,q4:1:-12:1,q5:3:-11:1,q9:h:-w:1,qq:1:-v:1,qr:9:-w:1,r0:1:-1s:1,r1:2:-1r:1,r4:1:-1q:1,r5:1:-1l:1,r9:1:-1b:1,ra:1:-1i:1,rb:1:-8:1,rd:c:-1:2,s0:1:-2e:1,s1:1:-28:1,s2:1:7:1,s3:1:-38:1,s5:1:-2o:1,s8:1:-1:1,sb:1:-1:1,ts:w:-w:1,uo:g:-28:1,v5:h:-1:2,wb:r:-1:2,xu:7:-1:2,y7:1:-f:1,y9:1c:-1:2,129:12:-1c:1,3bk:17:2bk:1,3ct:3:2bk:1,3y0:6:-8:1,5mo:1:-4tq:1,5mp:1:-4tp:1,5mq:1:-4tg:1,5mr:2:-4te:1,5mt:1:-4tf:1,5mu:1:-4t8:1,5mv:1:-4rp:1,5mw:1:r7m:1,5tl:1:r9g:1,5tp:1:2xy:1,5u6:1:raw:1,5xd:23:-1:2,61n:1:-1n:1,61t:1c:-1:2,64g:8:8:1,64w:6:8:1,65c:8:8:1,65s:8:8:1,668:6:8:1,66p:4:8:2,674:8:8:1,67k:2:22:1,67m:4:2e:1,67q:2:2s:1,67s:2:3k:1,67u:2:34:1,67w:2:3i:1,680:8:8:1,68g:8:8:1,68w:8:8:1,69c:2:8:1,69f:1:9:1,69q:1:-5k5:1,69v:1:9:1,6a8:2:8:1,6ao:2:8:1,6at:1:7:1,6b7:1:9:1,6ku:1:-s:1,6ls:g:-g:1,6mc:1:-1:1,79s:q:-q:1,8q8:1c:-1c:1,8rl:1:-1:1,8rp:1:-8bv:1,8rq:1:-8bs:1,8rs:3:-1:2,8s3:1:-1:1,8s6:1:-1:1,8sh:1e:-1:2,8vg:2:-1:2,8vn:1:-1:1,8w0:12:-5ls:1,8x3:1:-5ls:1,8x9:1:-5ls:1,wu9:n:-1:2,ww1:e:-1:2,x0j:7:-1:2,x0z:v:-1:2,x2y:2:-1:2,x33:5:-1:2,x3g:1:-1:1,x3l:2:-1:2,x3o:1:1c:1,x3r:a:-1:2,x4l:8:-1:2,x54:2:-1:2,x5d:1:-1:1,x5j:2:-1:2,x6e:1:-1:1,xub:1:-ps:1,xv4:28:-tzk:1,1ef5:q:-w:1,1fe0:14:-14:1,1fiw:10:-14:1,1fo7:b:-13:1,1foj:f:-13:1,1foz:7:-13:1,1fp7:2:-13:1,1h34:1f:-1s:1,1jgg:w:-w:1,20dc:w:-w:1,2oma:y:-y:1`,pn=`1t:q:w:1,5c:n:w:1,60:7:w:1,74:o:1:2,8g:1:-5j:1,8i:3:1:2,8p:8:1:2,96:n:1:2,ag:1:-3d:1,ah:3:1:2,ap:1:5u:1,aq:2:1:2,au:1:5q:1,av:1:1:1,ax:2:5p:1,az:1:1:1,b2:1:27:1,b3:1:5m:1,b4:1:5n:1,b5:1:1:1,b7:1:5p:1,b8:1:5r:1,ba:1:5v:1,bb:1:5t:1,bc:1:1:1,bg:1:5v:1,bh:1:5x:1,bj:1:5y:1,bk:3:1:2,bq:1:62:1,br:1:1:1,bt:1:62:1,bw:1:1:1,by:1:62:1,bz:1:1:1,c1:2:61:1,c3:2:1:2,c7:1:63:1,c8:1:1:1,cc:1:1:1,ck:1:2:1,cl:1:1:1,cn:1:2:1,co:1:1:1,cq:1:2:1,cr:9:1:2,da:9:1:2,dt:1:2:1,du:2:1:2,dy:1:-2p:1,dz:1:-1k:1,e0:k:1:2,f4:1:-3m:1,f6:9:1:2,fu:1:8bv:1,fv:1:1:1,fx:1:-4j:1,fy:1:8bs:1,g1:1:1:1,g3:1:-5f:1,g4:1:1x:1,g5:1:1z:1,g6:5:1:2,og:2:1:2,om:1:1:1,ov:1:38:1,p2:1:12:1,p4:3:11:1,p8:1:1s:1,pa:2:1r:1,pd:h:w:1,pv:9:w:1,r3:1:8:1,rc:c:1:2,s4:1:-1o:1,s7:1:1:1,s9:1:-7:1,sa:1:1:1,sd:3:-3m:1,sg:g:28:1,sw:w:w:1,v4:h:1:2,wa:r:1:2,xs:1:f:1,xt:7:1:2,y8:1c:1:2,10x:12:1c:1,3a8:12:5ls:1,3bb:1:5ls:1,3bh:1:5ls:1,3vk:28:tzk:1,3xs:6:8:1,5n4:17:-2bk:1,5od:3:-2bk:1,5xc:23:1:2,61q:1:-5vj:1,61s:1c:1:2,64o:8:-8:1,654:6:-8:1,65k:8:-8:1,660:8:-8:1,66g:6:-8:1,66x:4:-8:2,67c:8:-8:1,688:8:-8:1,68o:8:-8:1,694:8:-8:1,69k:2:-8:1,69m:2:-22:1,69o:1:-9:1,6a0:4:-2e:1,6a4:1:-9:1,6ag:2:-8:1,6ai:2:-2s:1,6aw:2:-8:1,6ay:2:-34:1,6b0:1:-7:1,6bc:2:-3k:1,6be:2:-3i:1,6bg:1:-9:1,6jq:1:-5st:1,6ju:1:-6gv:1,6jv:1:-6di:1,6k2:1:s:1,6lc:g:g:1,6mb:1:1:1,792:q:q:1,8ow:1c:1c:1,8rk:1:1:1,8rm:1:-8af:1,8rn:1:-2xy:1,8ro:1:-89z:1,8rr:3:1:2,8rx:1:-8bg:1,8ry:1:-8al:1,8rz:1:-8bj:1,8s0:1:-8bi:1,8s2:1:1:1,8s5:1:1:1,8se:2:-8cf:1,8sg:1e:1:2,8vf:2:1:2,8vm:1:1:1,wu8:n:1:2,ww0:e:1:2,x0i:7:1:2,x0y:v:1:2,x2x:2:1:2,x31:1:-r9g:1,x32:5:1:2,x3f:1:1:1,x3h:1:-wmg:1,x3k:2:1:2,x3q:a:1:2,x4a:1:-wn8:1,x4b:1:-wnj:1,x4c:1:-wnf:1,x4d:1:-wn5:1,x4e:1:-wn8:1,x4g:1:-wlu:1,x4h:1:-wmi:1,x4i:1:-wlx:1,x4j:1:ps:1,x4k:8:1:2,x50:1:-1c:1,x51:1:-wn7:1,x52:1:-raw:1,x53:2:1:2,x5c:1:1:1,x5i:2:1:2,x6d:1:1:1,1ee9:q:w:1,1fcw:14:14:1,1fhs:10:14:1,1fn4:b:13:1,1fng:f:13:1,1fnw:7:13:1,1fo4:2:13:1,1h1c:1f:1s:1,1jfk:w:w:1,20cg:w:w:1,2olc:y:y:1`,P=`C.UTF-8`,mn=`only the C.UTF-8 locale is supported`,hn=e=>typeof e==`string`&&/^C\.UTF-?8$/iu.test(e),gn=new Set([`LANG`,`LC_ALL`,`LC_CTYPE`]);function _n(e){if(e.locale===void 0||hn(e.locale))return P;throw TypeError(`createTerminal: ${mn} (got ${JSON.stringify(e.locale)})`)}function vn(e,t){if(!(gn.has(e)?hn(t)||e!==`LANG`&&t===``:hn(t)||t===`C`||t===`POSIX`||t===``))throw new D(`feature`,e,`${e}: ${mn}`)}var yn=e=>e===`C`||e===`POSIX`,bn=e=>yn(e.locale);function xn(e){let t=[],n=-1;for(let r of e.split(`,`)){let[e,i]=r.split(`:`).map(e=>parseInt(e,36)),a=n+1+e;t.push([a,a+i]),n=a+i}return t}function Sn(e){let t=e.findIndex(([e])=>e>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function Cn(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):e<128?`\\x`+e.toString(16).padStart(2,`0`):String.fromCodePoint(e)}var wn=e=>e.map(([e,t])=>e===t?Cn(e):`${Cn(e)}-${Cn(t)}`).join(``);function Tn(e,t){let n=e.length-1,r=0;for(;r<=n;){let i=r+n>>1;if(t<e[i][0])n=i-1;else if(t>e[i][1])r=i+1;else return!0}return!1}var En=e=>e===`upper`||e===`lower`?`alpha`:e,Dn=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],On=/[\u1C80-\u1C88]/u;function kn(e){let t=new Map;for(let n of e.split(`,`)){let[e,r,i,a]=n.split(`:`).map(e=>parseInt(e,36));for(let n=0;n<r;n++)t.set(e+n*a,e+n*a+i)}return t}var An=(e,t)=>({up:e,low:t,folds:new Map});function jn(){let e=new Map,t=new Map;for(let n=97;n<=122;n++)e.set(n,n-32),t.set(n-32,n);return An(e,t)}function Mn(e){let t=[];for(let[n,r]of e.sort((e,t)=>e[0]-t[0])){let e=t.at(-1);e&&n<=e[1]+1?e[1]=Math.max(e[1],r):t.push([n,r])}return t}function Nn(e){let t=`[${e}]`;return{"<":`(?<!${t})(?=${t})`,">":`(?<=${t})(?!${t})`,boundary:`(?:(?<!${t})(?=${t})|(?<=${t})(?!${t}))`,inside:`(?:(?<=${t})(?=${t})|(?<!${t})(?!${t}))`}}function Pn(e,t,n,r,i){let a=new Map,o=new Map,s=null,c=e=>(o.has(e)||o.set(e,n(e)),o.get(e)),l=()=>s??=i(),u={name:e,multibyte:t,ranges:c,body(e){return a.has(e)||a.set(e,r(e,c(e))),a.get(e)},has(e,t){let n=c(e);return n!==void 0&&Tn(n,t)},assertions(){if(u.js)return u.js;let e=u.body(`space`);return u.js={__proto__:null,...Nn(u.body(`word`)),word:`[${u.body(`word`)}]`,nonWord:`[^${u.body(`word`)}]`,space:`[${e}]`,nonSpace:`[^${e}]`},u.js},up:e=>l().up.get(e)??e,low:e=>l().low.get(e)??e,fold(e){let{folds:t}=l(),n=t.get(e);if(n===void 0){let r=u.up(e),i=u.low(r),a=new Set([e,r]);i!==r&&u.up(i)===r&&a.add(i);for(let e of Dn)u.up(e)===r&&a.add(e);n=[...a].sort((e,t)=>e-t),t.set(e,n)}return n},foldRange(e,t){let{up:n}=l(),r=n.get(e)??e,i=n.get(t)??t;if(r>i)return null;let a=[],o=[];for(let[e,t]of n){let n=e>=r&&e<=i;n!==(t>=r&&t<=i)&&(n?a:o).push(e)}let s=[],c=r;for(let e of a.sort((e,t)=>e-t))e>c&&s.push([c,e-1]),c=e+1;return c<=i&&s.push([c,i]),Mn([...s,...o.map(e=>[e,e])])}};return u}var Fn=Pn(`C`,!1,e=>on[e],e=>an[e],jn),In=Pn(P,!0,e=>e===`word`?Sn(xn(dn.alnum)):Object.hasOwn(dn,e)?xn(dn[e]):void 0,(e,t)=>t===void 0?void 0:wn(t),()=>An(kn(fn),kn(pn)));function Ln(e){if(e===P)return In;if(yn(e))return Fn;throw new D(`feature`,`locale`,`matching in the ${e} locale is not supported`)}var Rn=(1n<<63n)-1n,zn=-Rn-1n,Bn=(1n<<64n)-1n;function F(e,t,n,r){let i=j(e.cwd,n,e.fs,r);return I(e,t,n,i.error),i}function I(e,t,n,r){if(r!==`No such file or directory`||typeof n!=`string`)return;let i=n.startsWith(`/`),a=i?`/`:e.cwd,o=n.replace(/^\/+/u,``),s=new Set;for(let t of new Set([`/`,e.mount??`/`,e.home??`/`])){if(t===a)continue;let n=j(t,o,e.fs);n.error||s.add(n.path)}if(!s.size)return;let c=i?``:` from cwd ${JSON.stringify(e.cwd)}`,l=`${i?`absolute`:`relative`} path ${JSON.stringify(n)} was not found${c}`;e.notes?.add(`${t}: ${l}. ${Vn(e,s)}`)}function Vn(e,t){let n=[...t].sort(N),r=n.map(e=>JSON.stringify(e));if(n.length===1)return`A ${e.fs.isDir(n[0])?`dir`:`file`} exists at ${r[0]}.`;let i=n.every(t=>!e.fs.isDir(t)&&e.fs.isFile(t))&&n.some(t=>!e.fs.sameFileContents(n[0],t)),a=`${r.slice(0,-1).join(`, `)} and ${r.at(-1)}`;return`${n.length===2?`Both`:`All`} of ${a} exist${i?`, and they differ in contents`:``}.`}function Hn(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(`.`)&&e.add(A(t,r))},emit(t,n,r,i=``){Jn(t,{command:n,action:`omitted`,noun:[`hidden entry`,`hidden entries`],explanation:r,context:i,paths:e})}}}var Un=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function Wn(e,t){for(let n of t.split(`
4
+ `))Un.test(n)&&e.discarded?.add(n)}function Gn(e,t,n){let r=new Map;for(let i of e){if(t.includes(i))continue;let{command:e,operand:a,reason:o}=Un.exec(i).groups,s=/'([^']*)'$/u.exec(a)?.[1]??a;if([...n].some(e=>e.includes(JSON.stringify(s))))continue;let c=`${e}: ${o}`;r.has(c)||r.set(c,new Set),r.get(c).add(s)}return[...r].map(([e,t])=>`${e}: ${[...t].map(e=>JSON.stringify(e)).join(`, `)}.`)}function Kn(e,t){return e===`status`?null:{name:t,search:e===`search`}}function qn(){let e=null,t=0;return{skip(n,r){!t&&n&&(e={...n,exitCode:r}),t++},flush(n){if(t&&e){let r=t===1?`the command`:`the ${t} commands`,i=e.search&&e.exitCode===1?` A search that selects no lines exits 1, which is not a failure.`:``;n.add(`${e.name}: exited ${e.exitCode}, so ${r} after && did not run.${i}`)}e=null,t=0}}}function Jn(e,t){Yn(e,t,t.paths.size,t.paths)}function Yn(e,{command:t,action:n,noun:r,explanation:i=``,context:a=``},o,s){if(!o)return;let c=o<10?`: `+[...s].sort(N).map(e=>JSON.stringify(e)).join(`, `):``,l=Array.isArray(r)?r[o===1?0:1]:r;e.add(`${t}: ${n} ${o} ${l}${a}${c}.${i?` `+i:``}`)}function Xn(e,t=`
5
+ `){if(e===``)return[];let n=e.split(t);return n.at(-1)===``&&n.pop(),n}function Zn(e){let t=0,n=typeof e==`string`?`
6
+ `:10;for(let r=e.indexOf(n);r>=0;r=e.indexOf(n,r+1))t++;return t}var Qn=(e,t=`
7
+ `)=>e.length===0?``:e.join(t)+t;function $n(e,t=`
8
+ `){let n=[];for(let r=0;r<e.length;){let i=e.indexOf(t,r),a=i<0?e.length:i+t.length;n.push(e.slice(r,a)),r=a}return n}var er=e=>e.stdinTerminal===!0,tr=e=>(e.outputFds?.[1]===`out`||e.outputFds?.[1]===`err`)&&!e.substitutionDepth;function L(e,t=``,n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&Lt(e.stdinBytes,ur(null,e)),e.stdinLeft=t,e.stdinBytes=r}function nr(e,t,n,r=``,i={}){let a=[],o=``,s=r,c=i.read??`text`,l=c===`bytes`||c===`loose-bytes`,u=l?`bytes`:`content`,d=e=>l?c===`loose-bytes`?b(e):O(e):e,f=(e,t)=>{l?e.bytes=ar(n.fs,t,c===`loose-bytes`):c===`text`||n.fs.isBytes?.(t)!==!0?e.content=n.fs.readFile(t):(e.bytes=n.fs.readBytes(t),e.content=c===`maybe-text`?vt(e.bytes):void 0)};for(let p of t){let t={name:p,[u]:d(``),kind:`file`},m;if(p===`/dev/stdin`&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),t[u]=d(n.stdinOrigin);else if(p===`-`||p===`/dev/stdin`){let i=s===r?n.stdinBytes??null:null;Object.assign(t,i===null?cr(s,c,l):lr(i,c,l,e,n)),t.shared=!0,s=``,L(n,``,!0)}else if(p!==`/dev/null`){let r=F(n,e,p);r.error?(t.kind=`missing`,m=r.error):n.fs.isDir(r.path)?(t.kind=`dir`,i.noRead||(m=`Is a directory`)):f(t,r.path)}if(a.push(t),m&&(o+=t.failure=ir(e,p,m,t.kind===`dir`)),t.kind!==`file`&&(i.stopOnError||t.kind===`dir`&&i.stopOnDir))break}return{inputs:a.filter(e=>e.kind===`file`),entries:a,stderr:o,failed:o!==``}}var rr={head:[`cannot open '%s' for reading: %r`,`error reading '%s': Is a directory`],tail:[`cannot open '%s' for reading: %r`,`error reading '%s': Is a directory`],sort:[`cannot read: %s: %r`,`read failed: %s: Is a directory`],sed:[`can't read %s: %r`,`read error on %s: Is a directory`],tac:[`failed to open '%s' for reading: %r`,`%s: read error: Invalid argument`],base32:[null,`read error: Is a directory`],base64:[null,`read error: Is a directory`],uniq:[null,`error reading '%s': Is a directory`]};function ir(e,t,n,r=!1){let i=rr[e]?.[+!!r];return`${e}: ${i?i.replace(/%[sr]/gu,e=>e===`%s`?t:n):`${t}: ${n}`}
9
+ `}function ar(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let i=e.readFile(t);if(i!==void 0)return n?b(i):O(i)}function or(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:vt(n),bytes:n}}function sr(e,t,n,r,i){if(t.length===0){let t=r.stdinBytes??null;L(r,``,!0);let a=i?.read,o=a===`bytes`||a===`loose-bytes`,s=[{name:null,kind:`file`,...t===null?cr(n,a,o):lr(t,a,o,e,r)}];return{inputs:s,entries:s,stderr:``,failed:!1}}return nr(e,t,r,n,i)}var cr=(e,t,n)=>n?{bytes:t===`loose-bytes`?b(e):O(e)}:{content:e};function lr(e,t,n,r,i){return n||t===`as-held`?{bytes:e}:t===`maybe-text`?{bytes:e,content:vt(e)}:{content:Lt(e,ur(null,i))}}function ur(e,t){return e===null||e===`-`||e===`/dev/stdin`?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):`standard input`:JSON.stringify(j(t.cwd,e,t.fs).path??e)}function dr(e,t,n,r){let i=sr(e,t,n,r);return{content:i.inputs.map(e=>e.content).join(``),stderr:i.stderr,failed:i.failed}}var R=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:+!!t.failed});function fr(e,t,n=e,{max:r=1/0,digitsOnly:i=!1}={}){if(typeof e!=`string`||!(i?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:C(`${t}: invalid count: ${n}`)};let a=Number(e);return a>r?{error:C(`${t}: out of range: ${n}`)}:{value:Math.min(a,2**53-1)}}function pr(e,t){if(typeof e!=`string`)return{error:C(`${t}: invalid count: ${e}`)};let n=e[0]===`+`||e[0]===`-`?e[0]:``,r=n===`-`?e.slice(1):e,i=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),a=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!i&&!a)return{error:C(`${t}: invalid count: ${e}`)};let o=i?.[2]??(a?r:``),s=mr(BigInt(i?.[1]??`1`),o,t,e);return s.error?s:{...s,sign:n}}function mr(e,t,n,r){let i=1n;t===`b`?i=512n:t&&(i=(t.length===2?1000n:1024n)**BigInt(`KMGTPEZYRQ`.indexOf(t[0].toUpperCase())+1));let a=e*i;return a>Bn?{error:C(`${n}: count out of range: ${r}`)}:{value:Number(a>BigInt(2**53-1)?BigInt(2**53-1):a)}}function z(e){try{let t=e?.message;return typeof t==`string`&&t!==``?t:String(e)}catch{return`threw a value with no message`}}var B=e=>e===`/tmp`||e.startsWith(`/tmp/`),hr=new Uint8Array;function gr(e){e.vfs.mkdir(`/tmp`,{recursive:!0}),e.writableAt(`/tmp`);let t=_r(e),n=e=>t.observer?.read(t.identity(e)??e),r={...e,observeIo:e=>{t.observer=e},fileIdentity:t.identity,readIdentity:n=>(t.observer?.read(n),k(yr(e.vfs,n))),readFile:t=>(n(t),e.readFile(t)),readBytes:t=>(n(t),e.readBytes(t)),openWritable:(e,n,i=!1)=>br(r,t,e,n,i),makeWritableDir:(e,n)=>xr(r,t,e,n),makeWritableLink:(e,n,i)=>Sr(r,t,e,n,i),removeWritableDir:(e,n)=>Er(r,t,e,n),copyWritable:(e,n,i)=>Cr(r,t,e,n,i),replaceWritable:(e,n,i,a)=>wr(r,t,e,n,i,a),removeWritable:(e,n)=>Tr(r,t,e,n)};return r}function _r(e){let{vfs:t}=e,n=new Map;return{base:e,vfs:t,observer:void 0,identity:r=>{if(!B(String(r))||!e.isFile(r))return;let{ino:i}=t.lstat(r),a=n.get(i);return a===void 0&&n.set(i,a={path:t.realpath(r),detached:void 0}),a},leaving:r=>{let i=e.isFile(r)?t.lstat(r).ino:void 0,a=n.get(i);return a&&{cell:a,ino:i,bytes:t.readFile(r)}},release:e=>{e&&(e.cell.detached=e.bytes,n.delete(e.ino))},change:(t,n)=>{try{return n()}catch(e){throw e instanceof x?kr(t,vr(e.code)):e}finally{e.reshaped()}}}}var vr=e=>new x(e,``).message.slice(2),yr=(e,t)=>t.detached??e.readFile(t.path);function br(e,t,n,r,i){let a=Mt(e,n,r);if(!B(a))return null;Dr(e,n,r);let o=t.identity(a);return o===void 0?(t.change(r,()=>t.vfs.writeFile(a,hr)),o=t.identity(a)):i||(t.observer?.write(o),t.vfs.writeFile(a,hr)),Ar(t.vfs,a,o,i,()=>t.observer?.write(o))}function xr(e,t,n,r){let i=Mt(e,n,r,!1);if(!B(i))return!1;if(e.isDir(i))return!0;if(Dr(e,n,r),e.isFile(i)||e.isLink(i))throw Error(`${r}: File exists`);return t.change(r,()=>t.vfs.mkdir(i)),!0}function Sr(e,t,n,r,i){let a=Mt(e,n,r,!1);return a.startsWith(`/tmp/`)?(Or(e,n,r),t.change(r,()=>t.vfs.symlink(i,a)),!0):!1}function Cr(e,t,n,r,i){let a=Mt(e,n,i);if(!a.startsWith(`/tmp/`))return!1;Dr(e,n,i);let o=t.identity(r);if(r===a||o!==void 0&&o===t.identity(a))throw Error(`source and destination are the same file`);return t.observer?.read(o??r),e.openWritable(n,i).writeBytes(t.base.readBytes(r)),!0}function wr(e,t,n,r,i,a){let o=Mt(e,n,r,!1),s=a===void 0?null:Mt(e,n,a,!1);if(!o.startsWith(`/tmp/`)||s!==null&&!s.startsWith(`/tmp/`))return!1;if(Dr(e,n,r),!e.isFile(o)&&!e.isLink(o))throw kr(r,`No such file or directory`);s!==null&&Dr(e,n,a);let c=O(i),{vfs:l}=t;return t.change(r,()=>{if(s!==null&&s!==o){let e=t.leaving(o),n=t.leaving(s);l.rename(o,s),t.release(n),e&&(e.cell.path=s)}else{let e=t.leaving(o);l.unlink(o),t.release(e)}l.writeFile(o,c)}),!0}function Tr(e,t,n,r){if(!B(Mt(e,n,r,!1)))return!1;let i=j(n,r,e,{follow:!1});if(i.error)throw kr(r,i.error);if(e.isDir(i.path))throw Error(`${r}: Is a directory`);if(!B(i.path))return!1;let a=t.leaving(i.path);return t.change(r,()=>t.vfs.unlink(i.path)),t.release(a),!0}function Er(e,t,n,r){if(!B(Mt(e,n,r,!1)))return!1;let i=j(n,r,e);if(i.error)throw kr(r,i.error);if(!B(i.path)||!e.isDir(i.path))throw Error(`${r}: Not a directory`);if(i.path===`/tmp`)throw Error(`${r}: Device or resource busy`);let{dirs:a,files:o,links:s}=e.listDir(i.path);if(a.length||o.length||s.length)throw Error(`${r}: Directory not empty`);return t.change(r,()=>t.vfs.rmdir(i.path)),!0}function Dr(e,t,n){let r=jt(t,n,e);if(r.error===null){if(e.isDir(r.path))throw Error(`${n}: Is a directory`);if(n.endsWith(`/`))throw kr(n,`Not a directory`)}else{if(r.rest.length>0||n.endsWith(`/`)||n.includes(`\0`))throw kr(n,r.error);if(!e.isDir(M(r.path)))throw kr(n,`No such file or directory`)}}function Or(e,t,n){if(n===``||n.includes(`\0`))throw kr(n,`No such file or directory`);let r=jt(t,n,e,{follow:!1});if(r.error===null)throw kr(n,`File exists`);if(r.rest.length>0||n.endsWith(`/`))throw kr(n,r.error);if(!e.isDir(M(r.path)))throw kr(n,`Not a directory`)}function kr(e,t){return Object.assign(Error(`${e}: ${t}`),{path:e,fsError:t})}function Ar(e,t,n,r,i){let a=0,o=t=>{let i=yr(e,n),o=r?i.length:a;n.detached===void 0?o===i.length?e.appendFile(n.path,t):e.writeFile(n.path,jr(i,o,t)):n.detached=jr(i,o,t),a=o+t.length};return{path:t,identity:n,get position(){return r?yr(e,n).length:a},write(e){e!==``&&(i(),o(O(e)))},writeBytes(e){e.length!==0&&(i(),o(e))}}}function jr(e,t,n){let r=Math.max(e.length,t+n.length),i=t===e.length&&e.byteOffset+r<=e.buffer.byteLength,a=i?new Uint8Array(e.buffer,e.byteOffset,r):new Uint8Array(Math.max(r,e.length*2)).subarray(0,r);return i||a.set(e),a.set(n,t),a}var Mr=[`cwd`,`home`,`user`,`inherit`];function Nr(e,t){let n=Fr(t,`mount`,`/`),r=Fr(t,`home`,n),i=Fr(t,`cwd`,n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!==`/tmp/`)throw TypeError(`createTerminal: writable must be '/tmp/', false, or undefined`);let a=t.writable===`/tmp/`;if(a&&(n===`/`||n===`/tmp`||n.startsWith(`/tmp/`)))throw Error(`createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'`);let o=Vt(e,n);return{fs:a?gr(o):o,cwd:i,home:r,mount:n,writable:a,locale:_n(t)}}function Pr(e,t){if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`fork: options must be an object (got ${t===null?`null`:Array.isArray(t)?`an array`:typeof t})`);for(let e of Object.keys(t))if(!Mr.includes(e))throw Error(`fork: unknown option \`${e}\` (known: ${Mr.join(`, `)}; the sources, the mount, the /tmp/ overlay, the network and the commands come from the parent)`);if(t.inherit!==void 0&&typeof t.inherit!=`boolean`)throw TypeError(`fork: inherit must be true or false (got ${t.inherit===null?`null`:typeof t.inherit})`);return{cwd:Fr(t,`cwd`,e.cwd,`fork`,e.cwd),home:Fr(t,`home`,e.home,`fork`,e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function Fr(e,t,n,r=`createTerminal`,i=`/`){let a=e[t]===void 0?n:e[t];if(typeof a!=`string`||a.includes(`\0`))throw TypeError(`${r}: ${t} must be a string without NUL characters`);return A(i,a)}function Ir(e,t=0,n=e.value.length){return{value:e.value.slice(t,n),mask:e.mask===null?null:e.mask.slice(t,n),...e.empty?{empty:e.empty.filter(e=>e>=t&&e<=n).map(e=>e-t)}:{}}}function Lr(e){let t=/^([A-Za-z_][A-Za-z0-9_]*)=/u.exec(e.value);return!t||e.mask!==null&&/[12]/u.test(e.mask.slice(0,t[0].length))||e.empty?.some(e=>e<t[0].length)?null:{name:t[1],end:t[0].length}}var Rr=(e,t)=>e.mask===null?`0`:e.mask[t];function zr(e,t=!1){let n=new Set;if(!e.value.includes(`~`))return n;let r=e.value,i=t=>Rr(e,t)===`0`,a=t?null:Lr(e)?.end??null,o=e=>t===!0||a!==null&&e>=a;for(let s=0;s<r.length;s++){let c=s===0||s===a||o(s)&&r[s-1]===`:`&&i(s-1),l=o(s)||t===`parameterAssign`;if(!c||r[s]!==`~`||!i(s)||!Br(e,s,l))continue;let u=r[s+1];if(u&&u!==`/`&&u!==`:`&&i(s+1))throw new D(`feature`,`tilde prefix`,`named-user and directory-stack tilde prefixes are not supported`);(u===void 0||i(s+1)&&(u===`/`||u===`:`&&l))&&n.add(s)}return n}function Br(e,t,n){for(let r=t;r<=e.value.length;r++){if(e.empty?.includes(r))return!1;if(r===e.value.length)return!0;if(Rr(e,r)!==`0`)return!1;if(e.value[r]===`/`||n&&e.value[r]===`:`)return!0}return!0}function Vr(...e){let t=``,n=``,r=[];for(let i of e){for(let e of i.empty??[])r.push(t.length+e);t+=i.value,n+=i.mask??`0`.repeat(i.value.length)}return{value:t,mask:e.every(e=>e.mask===null)?null:n,...r.length?{empty:r}:{}}}var Hr=64;function Ur(e,t){let n=``;for(let r=t+1;r<e.length;r++){let i=e[r];if(i==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(i!==`\\`){n+=i;continue}let a=e[r+1];if(a==="`")throw new D(`feature`,"\\`","nested backtick command substitution is not supported; use `$( )` instead");a===`$`||a===`\\`?(n+=a,r++):a===`
10
+ `?r++:n+=i}throw Error(`unterminated backtick substitution`)}var Wr=()=>({value:``,quoted:!1,started:!1}),Gr=()=>new D(`feature`,`command substitution depth`,`command substitution nesting above ${Hr} is not supported`);function Kr(e,t,n,r,i){if(r>=Hr)throw Gr();let a={line:e,i:n+1,depth:r,helpers:i,parens:0,quote:null,word:Wr(),command:!0,target:null,heredocs:[]};for(;a.i<e.length;)if(Yr(a))return{raw:e.slice(t,a.i+1),command:e.slice(n+1,a.i)};throw a.quote?Error(`unterminated ${a.quote===`'`?`single`:`double`} quote`):Error(`unterminated command substitution`)}function qr(e,t,n=!1){e.word.value+=t,e.word.quoted||=n,e.word.started=!0}function Jr(e){let t=e.word;if(t.started){if(e.target)e.target.op===`heredoc`&&(e.target.delim=t.value,e.target.quotedDelim=t.quoted),e.target=null;else if(e.command&&!t.quoted){if(t.value===`case`)throw new D(`feature`,`case`,"`case` patterns inside command substitutions are not supported");e.command=[`!`,`{`,`do`,`then`,`else`,`elif`,`if`,`while`,`until`].includes(t.value)||/^[A-Za-z_][A-Za-z0-9_]*=/u.test(t.value)}else e.command=!1;e.word=Wr()}}function Yr(e){let{line:t,i:n,quote:r}=e,i=t[n];if(r&&i===r)return e.quote=null,e.word.quoted=!0,e.i++,!1;if(r===`'`)return qr(e,i,!0),e.i++,!1;if(i===`\\`)return Xr(e),!1;if(i===`$`)return Zr(e),!1;if(i==="`")return Qr(e),!1;if(r)return qr(e,i,!0),e.i++,!1;if(i===`'`||i===`"`)return e.quote=i,e.word.started=!0,e.i++,!1;if(e.command&&!e.target&&!e.word.started&&t.startsWith(`[[`,n)&&/[ \t\n()<>;&|]|^$/u.test(t[n+2]??``)){let r=e.helpers.readConditional(t,n,e.helpers,e.depth+e.parens+1);return e.i+=r.raw.length,e.command=!1,!1}if(i===`#`&&!e.word.started){let r=t.indexOf(`
11
+ `,n);return e.i=r===-1?t.length:r,!1}if(i===`
12
+ `)return ei(e),!1;if(i===` `||i===` `)return Jr(e),e.i++,!1;let a;try{a=e.helpers.readOperator(t,n,!e.word.started)}catch(t){if(!(t instanceof D))throw t;return e.i++,!1}return a?$r(e,a):(qr(e,i),e.i++,!1)}function Xr(e){let t=e.line[e.i+1];t===`
13
+ `?e.i+=2:t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(qr(e,t,!0),e.i+=2):(qr(e,`\\`,!!e.quote),e.i++)}function Zr(e){let{line:t,i:n}=e,r=e.helpers.skipContinuations(t,n+1);if(!e.quote&&t[r]===`'`){let n=e.helpers.decodeAnsiC(t,r+1);qr(e,n.text,!0),e.i=n.end;return}if(!e.quote&&t[r]===`"`){e.quote=`"`,e.word.started=!0,e.i=r+1;return}let i=e.helpers.readExpansion(t,n,e.depth+e.parens+1,e.quote===`"`)?.raw??`$`;qr(e,i,!!e.quote),e.i+=i.length}function Qr(e){let t=e.i++;for(;e.i<e.line.length;){let n=e.line[e.i++];if(n==="`"){qr(e,e.line.slice(t,e.i),!!e.quote);return}n===`\\`&&e.i<e.line.length&&e.i++}throw Error(`unterminated backtick substitution`)}function $r(e,t){Jr(e);let n=t.token;if(n.kind===`paren_close`){if(e.parens===0){if(e.heredocs.length)throw new D(`feature`,`command substitution heredoc`,`a command substitution heredoc must finish before its closing parenthesis`);return!0}e.parens--,e.command=!1}else if(n.kind===`paren_open`){if(e.depth+ ++e.parens>=Hr)throw Gr();e.command=!0}else n.kind===`redir`?(e.command=!1,n.op===`heredoc`&&e.heredocs.push(n),[`dup`,`close`].includes(n.op)||(e.target=n)):e.command=!0;return e.i=t.end,!1}function ei(e){if(Jr(e),e.heredocs.some(e=>e.delim===null))throw Error(`heredoc requires a delimiter`);e.heredocs.length&&(e.i=e.helpers.readHeredocBodies(e.line,e.i,e.heredocs),e.heredocs=[]),e.command=!0,e.i++}function ti(e){return Number.isInteger(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)}var ni=e=>e>65535?2:1,ri=(e,t)=>ni(e.codePointAt(t)),ii=e=>`(?:^|(?<=[^]))(?:${e})`,ai=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])(?![\s\S])/u,oi=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])/u;function si(e,t=`unsupported or malformed parameter expansion`){return new D(`feature`,"${",`${t}: \${${e}}`)}var ci=e=>/^[0-9]+$/u.test(e)?e.replace(/^0+(?=[0-9])/u,``):e;function li(e){let t=e.replaceAll(`\\
14
+ `,``);if(t.startsWith(`#`)&&t.length>1&&ai.test(t.slice(1)))return{name:ci(t.slice(1)),operator:`length`};if(/^#[A-Za-z_0-9]/u.test(t))throw si(e);let n=oi.exec(t)?.[0];if(!n)throw si(e);let r=t.slice(n.length);if(!r)return{name:ci(n),operator:``};if(n===`#`&&/^[%:=+/]$/u.test(r))throw si(e);let i=/^(?::[-+=?]|[-+=?]|##?|%%?|:|\/\/?)/u.exec(r)?.[0];if(!i)throw si(e);return{name:ci(n),operator:i,word:e.slice(ui(e,n.length+i.length))}}function ui(e,t){let n=0;for(;t>0;)e[n]===`\\`&&e[n+1]===`
15
+ `?n+=2:(t--,n++);return n}var di=(e,t)=>new D(`feature`,e,t),fi=e=>{if(e>=64)throw di(`expansion depth`,`shell expansion nesting above 64 levels is not supported`)};function pi(e,t,n,r,i,a){fi(r);let o=n+1,s=null;for(let n=o;n<e.length;n++){let c=e[n];if(s===`'`)c===`'`&&(s=null);else if(c===`\\`)n++;else if(c===`"`)s=s===`"`?null:`"`;else if(c===`'`&&!s)s=`'`;else{if(c==="`")throw di("`",`command substitution (backticks) is not supported`);if(c===`$`){let t=n+1;for(;e[t]===`\\`&&e[t+1]===`
16
+ `;)t+=2;if(e[t]===`'`&&!s){let r=a.decodeAnsiC(e,t+1),s=li(e.slice(o,n)).operator;if(i&&/[-+?=]/u.test(s)&&/[$`"'\\}]/u.test(r.text))throw di("${",`active characters in ANSI-C quoted parameter operands are not supported`);n=r.end-1;continue}let c=a.readExpansion(e,n,r+1,i||s===`"`);if(c){n+=c.raw.length-1;continue}}if(c===`}`&&!s){let r=li(e.slice(o,n));return{raw:e.slice(t,n+1),parameter:r}}}}throw di("${",`unterminated parameter expansion`)}function mi(e,t,n,r,i){fi(r);let a=0;for(let o=n+1;o<e.length;o++){let s=e[o];if(s===`\\`){o++;continue}if(s===`$`){let t=i.readExpansion(e,o,r+1,!0);if(t){o+=t.raw.length-1;continue}}if(s==="`")throw di("`",`command substitution (backticks) is not supported`);if(s===`"`||s===`'`)throw di(`$((`,`quotes in arithmetic expressions are not supported`);if(s===`(`&&a++,s!==`)`)continue;if(a){a--;continue}let c=o+1;for(;e[c]===`\\`&&e[c+1]===`
17
+ `;)c+=2;if(e[c]!==`)`)throw di(`$((`,"arithmetic expansion requires a closing `))`");return{raw:e.slice(t,c+1),arithmetic:e.slice(n+1,o)}}throw di(`$((`,`unterminated arithmetic expansion`)}var hi=/^-[abcdefghknoprstuvwxzGLNORS]$/u,gi=new Set([`=`,`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`]),_i=new Set([`end`,`&&`,`||`,`)`]),vi=/^[A-Za-z_][A-Za-z0-9_]*$/u;function yi(e,t,n,r=0){let i={line:e,i:t+2,helpers:n,token:null,depth:0,terms:0,removed:0,expansionDepth:r};try{Ei(i,!0);let n=bi(i);return i.token.kind!==`end`&&wi(`unexpected token \`${i.token.value??i.token.kind}\``),{raw:e.slice(t,i.i+i.removed),expression:n}}catch(e){if(e instanceof D||e.conditional)throw e;wi(e.message)}}function bi(e){let t=xi(e);for(;e.token.kind===`||`;)Ei(e,!0),t={kind:`or`,left:t,right:xi(e)};return t}function xi(e){let t=Si(e);for(;e.token.kind===`&&`;)Ei(e,!0),t={kind:`and`,left:t,right:Si(e)};return t}function Si(e){if(++e.terms>128)throw new D(`feature`,`[[ complexity`,`conditional expressions above 128 terms are not supported`);if(++e.depth>64)throw new D(`feature`,`[[ nesting`,`conditional nesting above 64 levels is not supported`);try{let t=e.token;if(t.kind===`(`){Ei(e,!0);let t=bi(e);return e.token.kind!==`)`&&wi("expected `)`"),Ei(e,!0),t}if(Ci(t,`!`))return Ei(e,!0),{kind:`not`,expression:Si(e)};if(t.kind!==`word`&&wi(`expected an operand`),Ei(e),!t.quoted&&hi.test(t.value)){let n=Ti(e);return Ei(e,!0),{kind:`unary`,op:t.value,word:n}}if(_i.has(e.token.kind))return{kind:`unary`,op:`-n`,word:t};let n=e.token;if((n.quoted||!gi.has(n.value))&&wi(`conditional binary operator expected`),n.value===`=~`)throw new D(`feature`,`[[ =~`,`regular expression comparisons in [[ are not supported`);Ei(e);let r=Ti(e);return Ei(e,!0),{kind:`binary`,op:n.value,left:t,right:r}}finally{e.depth--}}var Ci=(e,t)=>e.kind===`word`&&!e.quoted&&e.value===t,wi=e=>{throw Object.assign(Error(`[[ ${e}`),{conditional:!0})};function Ti(e){return e.token.kind!==`word`&&wi(`expected an operand`),e.token}function Ei(e,t=!1){if(e.token=Di(e),t)for(;e.token.kind===`newline`;)e.token=Di(e)}function Di(e){for(;e.i<e.line.length;){let t=e.line[e.i];if(t===` `||t===` `){e.i++;continue}if(t===`\\`&&e.line[e.i+1]===`
18
+ `){e.i+=2;continue}if(t===`#`){let t=e.line.indexOf(`
19
+ `,e.i);e.i=t<0?e.line.length:t;continue}if(t===`
20
+ `)return e.i++,{kind:`newline`};let n=e.line.slice(e.i,e.i+2);if(n===`<(`||n===`>(`)throw new D(`feature`,n,`process substitution (\`${n}\u2026\`) is not supported`);if(n===`&&`||n===`||`)return e.i+=2,{kind:n};if(`()<>;&|`.includes(t))return e.i++,{kind:t,value:t};let r=Oi(e);return Ci(r,`]]`)?{kind:`end`}:r}wi("missing `]]`")}function Oi(e){let t={kind:`word`,value:``,mask:``,quoted:!1,empty:[]},n=null,r=0;for(;e.i<e.line.length;){let i=e.line[e.i];if(n&&i===n)t.value.length===r&&t.empty.push(r),t.quoted=!0,n=null,e.i++;else if(n===`'`)ki(t,i,`1`),e.i++;else if(i===`\\`)Ai(e,t,n);else if(i===`$`){if(ji(e),!n&&e.line[e.i+1]===`"`){n=`"`,r=t.value.length,e.i+=2;continue}Mi(e,t,n)}else if(i==="`"){let r=Ur(e.line,e.i);ki(t,"`",n?`2`:`0`),ki(t,r.raw.slice(1),`1`),e.i+=r.raw.length}else if(n)ki(t,i,`2`),e.i++;else if(i===`'`||i===`"`)n=i,r=t.value.length,e.i++;else{if(i===`(`&&t.mask.at(-1)===`0`&&/[?*+@!]/u.test(t.value.at(-1))&&!t.empty.includes(t.value.length))throw new D(`feature`,`[[ extglob`,`extended glob patterns in [[ are not supported`);if(/[ \t\n()<>;&|]/u.test(i))break;ki(t,i,`0`),e.i++}}return n&&wi(`unterminated ${n===`'`?`single`:`double`} quote`),!t.quoted&&!/[12]/u.test(t.mask)&&(t.mask=null),t.empty.length===0&&delete t.empty,t}function ki(e,t,n,r=n!==`0`){e.value+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function Ai(e,t,n){let r=e.line[e.i+1];r===`
21
+ `?e.i+=2:r!==void 0&&(!n||'$`"\\'.includes(r))?(ki(t,r,`1`),e.i+=2):(ki(t,`\\`,n?`2`:`1`),e.i++)}function ji(e){for(;e.line[e.i+1]===`\\`&&e.line[e.i+2]===`
22
+ `;)e.line=e.line.slice(0,e.i+1)+e.line.slice(e.i+3),e.removed+=2}function Mi(e,t,n){let r=n?`2`:`0`;if(!n&&e.line[e.i+1]===`'`){let n=e.helpers.decodeAnsiC(e.line,e.i+2);n.text===``&&t.empty.push(t.value.length),ki(t,n.text,`1`),e.i=n.end;return}let i=e.helpers.readExpansion(e.line,e.i,e.expansionDepth+1,!!n);if(!i)ki(t,`$`,`1`),e.i++;else{if(i.command!==void 0||i.parameter!==void 0||i.arithmetic!==void 0)ki(t,`$`,r),ki(t,i.raw.slice(1),`1`,!1);else{let n=e.line[e.i+i.raw.length];ki(t,vi.test(i.name)&&(n===`'`||n===`"`)?"${"+i.name+`}`:i.raw,r)}e.i+=i.raw.length}}var Ni=/^[A-Za-z_][A-Za-z0-9_]*$/u,Pi=/[A-Za-z0-9_]/u,Fi=/[?#@*$!0-9-]/u;function V(e,t){for(;e[t]===`\\`&&e[t+1]===`
23
+ `;)t+=2;return t}function Ii(e,t,n=null){let r=r=>r<e.length&&(n===null||n[r]===n[t]);if(!r(t+1))return null;let i=e[t+1];if(Fi.test(i))return{name:i,raw:e.slice(t,t+2)};if(!/[A-Za-z_]/u.test(i))return null;let a=t+2;for(;r(a)&&Pi.test(e[a]);)a++;return{name:e.slice(t+1,a),raw:e.slice(t,a)}}function Li(e,t,n=0,r=!1,i={}){let a=(e,t,n,r)=>Li(e,t,n,r,i),o=V(e,t+1),s=e[o];if(s===`(`){let r=V(e,o+1);if(e[r]===`(`)return mi(e,t,r,n,{readExpansion:a});let s=Kr(e,t,o,n,{readExpansion:a,decodeAnsiC:Vi,readHeredocBodies:Xi,readOperator:Hi,readConditional:yi,skipContinuations:V});return i.validateSubstitution?.(s.command),s}if(s===`{`)return pi(e,t,o,n,r,{readExpansion:a,decodeAnsiC:Vi});if(s===`[`)throw new D(`feature`,`$[`,"arithmetic expansion (`$[…]`) is not supported");return Ii(e,t)}function Ri(e,t,n={}){let r=Kr(e,t,V(e,t+1),0,{readExpansion:(e,t,r,i)=>Li(e,t,r,i,n),decodeAnsiC:Vi,readHeredocBodies:Xi,readOperator:Hi,readConditional:yi,skipContinuations:V});return n.validateSubstitution?.(r.command),r}var zi={a:`\x07`,b:`\b`,e:`\x1B`,E:`\x1B`,f:`\f`,n:`
24
+ `,r:`\r`,t:` `,v:`\v`,"\\":`\\`,"'":`'`,'"':`"`,"?":`?`};function Bi(e,t){for(let n=t;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`'`)return n;throw Error(`unterminated single quote`)}function Vi(e,t){let n=Bi(e,t),r=[],i=e=>{for(let t of b(e))r.push(t)};for(let a=t;a<n;a++){if(e[a]!==`\\`){let t=String.fromCodePoint(e.codePointAt(a));i(t),a+=t.length-1;continue}let t=e[a+1];if(t in zi){i(zi[t]),a++;continue}if(t===`x`&&e[a+2]===`{`)throw new D(`feature`,`ANSI-C hexadecimal escape`,`braced hexadecimal escapes in ANSI-C quotes are not supported`);let o=/^(?:[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{1,4}|U[0-9a-fA-F]{1,8})/u.exec(e.slice(a+1,n));if(o){let e=o[0],t=/^[0-7]/u.test(e),n=t?parseInt(e,8):parseInt(e.slice(1),16);if(t||e[0]===`x`)r.push(n&255);else{if(!ti(n))throw new D(`feature`,`ANSI-C Unicode escape`,`ANSI-C escapes outside Unicode scalar values are not supported`);i(String.fromCodePoint(n))}a+=e.length}else if(t===`c`&&a+2<n){let t=e.codePointAt(a+2);if(t>127)throw new D(`feature`,`ANSI-C control escape`,`ANSI-C control escapes require an ASCII character`);r.push(t===63?127:t&31),a+=2,t===92&&e[a+1]===`\\`&&a++}else i(`\\`)}let a=r.indexOf(0);return{text:k(Uint8Array.from(a===-1?r:r.slice(0,a))),end:n+1}}function Hi(e,t,n){let r=e[t];if(n&&/[0-9]/u.test(r)){let n=``,r=t;for(;/[0-9]/u.test(e[r]??``);)n+=e[r],r=V(e,r+1);return e[r]!==`>`&&e[r]!==`<`||e[V(e,r+1)]===`(`?null:Ji(e,r,Number(n))}let i=V(e,t+1),a=e[i];switch(r){case`|`:return a===`|`?Ki(`or`,i+1):a===`&`?Ki(`pipe_err`,i+1):Ki(`pipe`,t+1);case`&`:if(a===`&`)return Ki(`and`,i+1);if(a===`>`){let t=V(e,i+1),n=e[t]===`>`;return qi(1,n?`bothAppend`:`both`,(n?t:i)+1)}return Ki(`amp`,t+1);case`;`:return a===`;`?Ki(`dsemi`,i+1):Ki(`semi`,t+1);case`(`:return Ki(`paren_open`,t+1);case`)`:return Ki(`paren_close`,t+1);case`<`:case`>`:return Ji(e,t,r===`<`?0:1);default:return null}}var Ui={semi:`;`,dsemi:`;;`,pipe:`|`,pipe_err:`|&`,and:`&&`,or:`||`,amp:`&`,paren_open:`(`,paren_close:`)`},Wi={write:`>`,append:`>>`,read:`<`,heredoc:`<<`,herestring:`<<<`,both:`&>`,bothAppend:`&>>`,dup:`>&`,close:`>&-`};function Gi(e){if(e.kind===`word`)return e.quoted?`"${e.value}"`:e.value;if(e.kind===`redir`){let t=Wi[e.op];if(e.op===`both`||e.op===`bothAppend`)return t;let n=e.fd===(e.op===`read`||e.op===`heredoc`||e.op===`herestring`?0:1)?``:String(e.fd);return e.op===`dup`?`${n}${e.fd===0?`<&`:`>&`}${e.toFd}`:e.op===`close`?`${n}${e.fd===0?`<&-`:`>&-`}`:n+t}return Ui[e.kind]}var Ki=(e,t)=>({token:{kind:e},end:t}),qi=(e,t,n,r)=>({token:{kind:`redir`,fd:e,op:t,...r},end:n});function Ji(e,t,n){let r=e[t],i=V(e,t+1),a=e[i];if(a===`&`)return Yi(e,i,n,r===`<`?`<&`:`${n===1&&r===`>`?``:n}>&`);if(r===`<`){if(a===`>`)throw new D(`feature`,`<>`,`read/write file redirects are not supported`);if(a===`<`){let t=V(e,i+1);if(e[t]===`<`)return qi(n,`herestring`,t+1);let r=e[t]===`-`;return qi(n,`heredoc`,(r?t:i)+1,{strip:r,delim:null,body:null})}return qi(n,`read`,t+1)}return a===`>`?qi(n,`append`,i+1):qi(n,`write`,(a===`|`?i:t)+1)}function Yi(e,t,n,r){let i=V(e,t+1),a=e[i],o=e[V(e,i+1)],s=o===void 0||/[ \t\n|&>;()<]/u.test(o);if(/[0-9]/u.test(a??``)&&s)return qi(n,`dup`,i+1,{toFd:Number(a)});if(a===`-`&&s)return qi(n,`close`,i+1);throw new D(`feature`,`redirect target`,`redirect \`${r}\` requires a file descriptor number (or \`-\`) followed by a token boundary`)}function Xi(e,t,n){let r=t+1;for(let t of n){let n=[],i=!1;for(;r<e.length;){let a,o=``;for(;;){a=e.indexOf(`
25
+ `,r);let n=a===-1?e.length:a;if(o+=e.slice(r,n),r=n+1,t.quotedDelim||a===-1||!Zi(o))break;o=o.slice(0,-1)}if(a===-1&&o===``)break;if(t.strip&&(o=o.replace(/^\t+/u,``)),o===t.delim){i=!0;break}if(n.push(o),a===-1)break}t.body=n.length===0?``:n.join(`
26
+ `)+`
27
+ `,i||(t.warning=`warning: here-document delimited by end-of-file (wanted \`${t.delim}')
28
+ `)}return r-1}function Zi(e){let t=0;for(;t<e.length&&e[e.length-1-t]===`\\`;)t++;return t%2==1}var Qi=new Set([`semi`,`amp`,`and`,`or`,`pipe`,`pipe_err`,`paren_open`]),$i=e=>e===` `||e===` `;function ea(e,t={}){return na(ra(e,t),!1).tokens}function ta(e,t={}){let n=ra(e,t);return{read:()=>na(n,!0),reset:()=>{n.tokens=[]}}}function na(e,t){for(;e.i<e.line.length;){let n=e.line[e.i];if(e.quote&&n===e.quote){la(e),e.i++;continue}if(e.quote===`'`){H(e,n,`1`),e.i++;continue}if(n===`\\`){fa(e);continue}if(n===`$`){ma(e);continue}if(n==="`"){ga(e);continue}if(e.quote){H(e,n,`2`),e.i++;continue}if(n===`'`||n===`"`){ca(e,n),e.i++;continue}let r=e.cur!==``||e.empty.length>0;if(!r&&e.line.startsWith(`[[`,e.i)&&/[ \t\n()<>;&|]|^$/u.test(e.line[e.i+2]??``)&&sa(e.tokens)){let t=yi(e.line,e.i,{readExpansion:e.readExpansion,decodeAnsiC:Vi});da(e,{kind:`condition`,expression:t.expression}),e.i+=t.raw.length;continue}if(n===`#`&&!r){_a(e);continue}if(n===`
29
+ `){if(va(e),t)return{tokens:e.tokens,done:e.i>=e.line.length};continue}if($i(n)){ua(e),e.i++;continue}if(n===`(`&&e.mask.at(-1)===`0`&&/[?*+@!]/u.test(e.cur.at(-1))&&!e.empty.includes(e.cur.length))throw new D(`feature`,`extglob`,`extended glob patterns are not supported`);if((n===`<`||n===`>`)&&e.line[V(e.line,e.i+1)]===`(`){ha(e);continue}let i=Hi(e.line,e.i,!r);i?.token.kind===`paren_open`&&(i.token.wordAdjacent=r),i?(ua(e),da(e,i.token),e.i=i.end):(H(e,n,`0`),e.i++)}if(e.quote)throw Error(`unterminated ${e.quote===`'`?`single`:`double`} quote`);return ua(e),e.heredocs.length>0&&Xi(e.line,e.line.length,e.heredocs),{tokens:e.tokens,done:!0}}function ra(e,t={}){return{line:e,i:0,tokens:[],cur:``,mask:``,empty:[],quoted:!1,quoteStart:0,quote:null,heredocs:[],lastParenAt:-2,readExpansion:(e,n,r=0,i=!1)=>Li(e,n,r,i,t),readProcess:(e,n)=>Ri(e,n,t)}}function ia(e,t=!1){let n={...ra(e),fragment:!0,fragmentQuoted:t};for(;n.i<n.line.length;){let e=n.line[n.i];if(n.quote&&e===n.quote)la(n),n.i++;else if(n.quote===`'`)H(n,e,`1`),n.i++;else if(e===`\\`)fa(n);else if(e===`$`)ma(n);else if(e==="`")ga(n);else if(n.quote)H(n,e,`2`),n.i++;else if(e===`"`||e===`'`&&!t)ca(n,e),n.i++;else{if(!t&&(e===`<`||e===`>`)&&n.line[V(n.line,n.i+1)]===`(`)throw new D(`feature`,`${e}(`,`process substitution in parameter operands is not supported`);H(n,e,t?`2`:`0`),n.i++}}if(n.quote)throw new D(`feature`,"${",`unterminated quote in parameter operand`);return ua(n),n.tokens[0]??{value:``,mask:t?``:null}}var aa=new Set([`semi`,`and`,`or`,`pipe`,`pipe_err`,`amp`,`paren_open`]),oa=new Set([`!`,`{`,`if`,`then`,`else`,`elif`,`while`,`until`,`do`]);function sa(e){let t=!0,n=null,r=!1;for(let i of e){let e=aa.has(i.kind)||i.kind===`paren_close`&&n?.kind===`paren_open`;n=i,e?(t=!0,r=!1):i.kind===`redir`?(t=!1,r=![`dup`,`close`].includes(i.op)):r?r=!1:t&&i.kind===`word`&&!i.quoted&&oa.has(i.value)||(t=!1)}return t&&!r}function ca(e,t){e.quoteStart=e.cur.length,e.quote=t}function la(e){e.cur.length===e.quoteStart&&e.empty.push(e.cur.length),e.quote=null}function H(e,t,n,r=n!==`0`){e.cur+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function ua(e){if(e.cur!==``||e.empty.length>0){let t=e.empty.length>0||e.quoted,n={kind:`word`,value:e.cur,mask:/[12]/u.test(e.mask)||t?e.mask:null,quoted:t,...e.empty.length?{empty:e.empty}:{}};e.tokens.push(n);let r=e.heredocs.find(e=>e.delim===null);r&&(r.delim=n.value,r.quotedDelim=t)}e.cur=``,e.mask=``,e.empty=[],e.quoted=!1}function da(e,t){t.kind===`paren_open`&&(t.adjacent=V(e.line,e.lastParenAt+1)===e.i,e.lastParenAt=e.i),t.kind===`redir`&&t.op===`heredoc`&&e.heredocs.push(t),e.tokens.push(t)}function fa(e){let t=e.line[e.i+1];t===`
30
+ `?e.i+=2:t!==void 0&&(!(e.quote||e.fragmentQuoted)||'$`"\\'.includes(t)||e.fragment&&t===`}`)?(H(e,t,`1`),e.i+=2):(H(e,`\\`,e.quote||e.fragmentQuoted?`2`:`1`),e.i++)}function pa(e,t){let n=V(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function ma(e){pa(e,e.i+1);let{line:t}=e,n=e.quote===`"`||e.fragmentQuoted?`2`:`0`,r=t[e.i+1];if((n===`0`||e.fragmentQuoted&&!e.quote)&&r===`'`){let n=Vi(t,e.i+2);if(e.fragmentQuoted&&/[$`"\\]/u.test(n.text))throw new D(`feature`,"${",`active characters in ANSI-C quoted parameter operands are not supported`);n.text===``&&e.empty.push(e.cur.length),H(e,n.text,`1`),e.i=n.end;return}if((n===`0`||e.fragmentQuoted&&!e.quote)&&r===`"`){ca(e,`"`),e.i+=2;return}let i=e.readExpansion(t,e.i,0,n===`2`);if(!i){H(e,`$`,`1`),e.i++;return}if(i.command!==void 0||i.parameter!==void 0||i.arithmetic!==void 0){H(e,`$`,n),H(e,i.raw.slice(1),`1`,!1),e.i+=i.raw.length;return}let a=t[e.i+i.raw.length];H(e,Ni.test(i.name)&&(a===`"`||a===`'`)?"${"+i.name+`}`:i.raw,n),e.i+=i.raw.length}function ha(e){pa(e,e.i+1);let{raw:t}=e.readProcess(e.line,e.i);H(e,e.line[e.i],`0`),H(e,t.slice(1),`1`,!1),e.i+=t.length}function ga(e){let t=e.quote===`"`||e.fragmentQuoted?`2`:`0`,{raw:n}=Ur(e.line,e.i);H(e,"`",t),H(e,n.slice(1),`1`,!1),e.i+=n.length}function _a(e){for(;e.i<e.line.length&&e.line[e.i]!==`
31
+ `;)e.i++}function va(e){ua(e),e.heredocs.length>0&&(e.i=Xi(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!Qi.has(t.kind)?e.tokens.push({kind:`semi`,newline:!0}):(t?.kind===`semi`||t?.kind===`amp`)&&(t.lineEnd=!0),e.i++}function ya(e,t,n){let r={aliases:new Set(t),hasCommand:n};return xa(e,r),r.aliases}var ba=(e,t)=>new Set([...e,...t]);function xa(e,t){let n=null;for(let r of e){let e=r.gate===`and`||r.gate===`or`;if(e&&n!==null&&r.gate===`and`!=(n===0))continue;let i=e&&n===null?new Set(t.aliases):null,a=r.stages.length===1?r.stages[0]:null;n=a&&!a.isolate?Sa(a,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=ba(i,t.aliases),n=null)}return n}function Sa(e,t){if(e.group)return xa(e.group,t);if(e.conditional)return Ca(e.conditional,t);if(e.loop){if(e.loop.condition&&xa(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let n=new Set(t.aliases);xa(e.loop.body,t),t.aliases=ba(n,t.aliases)}return null}let n=e.words[0]?.value;if(e.redirs.length===0&&(n===`true`||n===`false`))return+(n===`false`);if(![`alias`,`unalias`].includes(n)||t.hasCommand(n))return null;let r=e.words.slice(1).map(e=>e.value);for(;r[0]?.startsWith(`-`)&&r[0]!==`-`;){let e=r.shift();if(e===`--`)break;if(!(n===`alias`?/^-p+$/u:/^-a+$/u).test(e))return null;if(n===`unalias`)return t.aliases.clear(),null}for(let e of r)if(n===`unalias`)t.aliases.delete(e);else{let n=e.indexOf(`=`),r=e.slice(0,n);n>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(r)&&t.aliases.add(r)}return null}function Ca(e,t){let n=new Set;for(let r of e.branches){let e=xa(r.condition,t);if(e===0)return xa(r.body,t),t.aliases=ba(n,t.aliases),null;if(e===null){let e={...t,aliases:new Set(t.aliases)};xa(r.body,e),n=ba(n,e.aliases)}}return e.otherwise&&xa(e.otherwise,t),t.aliases=ba(n,t.aliases),null}var wa=class extends Error{constructor(e){super(e.message),this.finalError=e}},Ta=e=>new wa(Error(e));function Ea(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let t=e.read();e.raw=t.tokens,e.done=t.done}return e.raw[t]}function Da(e,t,n){let r=t.validation??new Map;return{validateSubstitution(t){r.has(t)||(Oa(t,!0,e,{validation:r,syntaxOnly:!0},n),r.set(t,!0))}}}function Oa(e,t,n,r,i){try{return i(ea(e,Da(n,r,i)),t,n,r)}catch(e){throw e instanceof wa?e.finalError:e}}function ka(e,t,n,r){let i=ta(e,Da(n,{},r)),a=new Set,o=!1;return()=>{let e={aliases:a,aliasUsed:o,read:i.read,unit:!0},s=r([],t,n,e);return o=e.aliasUsed,a=ya(s,a,n),i.reset(),{steps:s,done:e.done}}}function*Aa(e,t,n,r){let i=ka(e,t,n,r);for(;;){let e;try{e=i()}catch(e){throw e instanceof wa?e.finalError:e}if(e.steps.length>0&&(yield e.steps),e.done)return}}var ja=[`elif`,`else`,`fi`];function Ma(e,t){let n=[],r;do{Va(e);let i=t(e,`then`);Va(e);let a=t(e,ja);n.push({condition:i,body:a}),r=e.raw[e.i-1].value}while(r===`elif`);let i=null;return r===`else`&&(Va(e),i=t(e,`fi`)),{branches:n,otherwise:i}}function Na(e,t){let{raw:n}=e,r=e.loop;e.loop=`for`;let i=Ea(e);if(i?.kind===`paren_open`)throw new D(`feature`,`for ((`,"arithmetic `for ((…))` loops are not supported; use `for NAME in WORD...`");if(i===void 0||i.kind!==`word`)throw Error(`for: expected a variable name`);let a=i.value;if(i.quoted||!Ni.test(a))throw Error(`for: \`${a}\` is not a valid variable name`);e.i++;let o=Ea(e);o?.kind===`semi`&&e.i++;let s=Ea(e);if(o?.kind===`semi`&&!o.newline&&Ha(s,`in`))throw Error("for: unexpected `in` after `;`");if(!Ha(s,`in`)){if(Ha(s,`do`)||s===void 0){let e=new D(`feature`,`for NAME; do`,`\`for ${a}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${a} in WORD...\``);throw s===void 0?new wa(e):e}throw Error(`for: expected \`in\` after \`${a}\``)}e.i++;let c=[],l=!1;for(let t;(t=Ea(e))&&t.kind!==`semi`;e.i++){if(t.kind!==`word`)throw Error(`for: unexpected \`${Gi(t)}\` in word list`);Ha(t,`do`)&&(l=!0),c.push(Ir(t))}n[e.i]?.kind===`semi`&&e.i++;let u=Ea(e);if(!Ha(u,`do`))throw u===void 0?Ta(l?"for: expected `;` or newline before `do`":"for: missing `do`"):Error(l?"for: expected `;` or newline before `do`":`for: expected \`do\`, got \`${Gi(u)}\``);e.i++,Va(e);let d={name:a,words:c,body:t(e,`done`)};return e.loop=r,d}function Pa(e,t,n){let r=e.loop;e.loop=t,Va(e);let i=n(e,`do`);Va(e);let a={until:t===`until`,condition:i,body:n(e,`done`)};return e.loop=r,a}function Fa(e,t,n){if(t.quoted||!Ni.test(t.value))throw new D(`feature`,`function`,`shell functions named \`${t.value}\` are not supported`);if(e.i+=2,Va(e),!Ha(Ea(e),`{`))throw new D(`feature`,`function`,`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,Va(e);let r=n(e,`}`);if(!Ia(r))throw new D(`feature`,`function`,`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:r}}var Ia=e=>e.every(e=>e.stages.every(La));function La(e){return e.assigns.length>0||e.define?!1:e.test?Ra(e.test)&&e.redirs.every(za):e.group?Ia(e.group):e.conditional?e.conditional.branches.every(e=>Ia(e.condition)&&Ia(e.body))&&Ia(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(Ba)&&Ia(e.loop.condition??[])&&Ia(e.loop.body):e.words.every(Ba)&&e.redirs.every(za)}function Ra(e){return e.kind===`and`||e.kind===`or`?Ra(e.left)&&Ra(e.right):e.kind===`not`?Ra(e.expression):e.kind===`unary`?Ba(e.word):Ba(e.left)&&Ba(e.right)}var za=e=>e.op===`text`?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||Ba(e.word);function Ba(e){for(let t=0;t<e.value.length;t++){let n=e.value[t];if((n===`$`||n==="`")&&(e.mask===null||e.mask[t]!==`1`))return!1}return!0}function Va(e){for(let t;(t=Ea(e))?.kind===`semi`&&t.newline;)e.i++}function Ha(e,t){return e!==void 0&&e.kind===`word`&&!e.quoted&&e.value===t}var Ua=(e,t=!1,n=()=>!1,r={})=>Oa(e,t,n,r,Ga),Wa=(e,t=!1,n=()=>!1)=>Aa(e,t,n,Ga);function Ga(e,t,n,r){let i={raw:e,i:0,done:!r.read,read:r.read,unitOnly:r.unit,emptyStage:!1,writable:t,aliases:r.aliases??new Set,aliasUsed:r.aliasUsed??!1,hasCommand:n,syntaxOnly:r.syntaxOnly};try{let e=Ea(i)?ao(i,null):[];if(i.emptyStage)throw Error(`empty pipeline stage`);return r.aliasUsed=i.aliasUsed,r.done=i.done,e}catch(e){if(i.aliasUsed&&!(e instanceof D)){let t=new D(`feature`,`alias expansion`,`alias expansion is not supported; input using aliases cannot be parsed`);throw e instanceof wa?new wa(t):t}throw e}}function Ka(e,t,n){t.stages.push(n),!Ja(n)&&!qa(n)&&(e.emptyStage=!0)}var qa=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,Ja=e=>e.group||e.loop||e.conditional||e.test||e.define,Ya=()=>({words:[],assigns:[],redirs:[]}),Xa=e=>({gate:e,stages:[],negate:!1,bang:!1}),Za=(e,t)=>e.bang&&e.stages.length===0&&Qa(t)&&t.redirs.length===0,Qa=e=>!Ja(e)&&e.words.length===0&&e.assigns.length===0,$a=new Set([`for`,`while`,`until`,`do`,`done`,`if`,`{`,`}`,`!`]),eo=new Set([`then`,`else`,`elif`,`fi`,`esac`,`in`]),to=new Map([[`case`,"`case` statements are not supported; gate on exit status with `&&` / `||` instead"],[`select`,"`select` loops are not supported"],[`function`,`shell functions are not supported`],[`time`,"`time` is not supported"],[`coproc`,"`coproc` is not supported"]]),no=new Set([`alias`,`declare`,`typeset`,`local`,`readonly`,`export`,`eval`,`let`]),ro=new Set([`pipe`,`pipe_err`,`and`,`or`,`semi`,`amp`]),io=new Set([`semi`,`amp`]);function ao(e,t){let{raw:n}=e,r=[Xa(`first`)];t===null&&(e.unit=r[0]);let i=0,a=Ya();for(let n;n=Ea(e);){if(n.kind===`condition`){if(!Qa(a))throw Error("unexpected `[[`");a.test=n.expression,e.i++;continue}if(n.kind===`paren_close`){if(t!==`)`)throw Error("unexpected `)`");return e.i++,uo(e,r,a,t)}if(n.kind===`paren_open`){oo(e,a);continue}if(ro.has(n.kind)){if(n.kind===`pipe_err`&&(qa(a)||Ja(a))&&a.redirs.push({fd:2,op:`dup`,toFd:1}),n.kind===`semi`&&Za(r.at(-1),a)||Ka(e,r.at(-1),a),n.kind===`amp`&&(r.at(-1).background=!0),a=Ya(),n.kind===`and`||n.kind===`or`?r.push(Xa(n.kind)):io.has(n.kind)&&r.push(Xa(`seq`)),t===null&&(n.newline||n.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=ya(r.slice(i,-1),e.aliases,e.hasCommand),i=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(n.kind===`dsemi`)throw Error("syntax error near unexpected token `;;`");if(n.kind===`redir`){if(n.warning&&(e.unit.warnings=(e.unit.warnings??``)+n.warning),a.define)throw new D(`feature`,`function`,`\`${a.define.name}()\` with a redirect of its own is not supported`);let t=po(e);t&&a.redirs.push(t);continue}if(a.group||a.define)throw Error(`unexpected token after \`${a.isolate?`)`:`}`}\``);if(a.loop)throw Error("unexpected token after `done`");if(a.conditional)throw Error("unexpected token after `fi`");if(a.test)throw Error("unexpected token after `]]`");if(!n.quoted&&a.words.length===0&&e.aliases.has(n.value)&&(e.aliasUsed=!0),!n.quoted&&Qa(a)){if(Array.isArray(t)?t.includes(n.value):n.value===t)return e.i++,uo(e,r,a,t);if(so(n,e,r.at(-1),a))continue}let o=a.words.length===0?Lr(n):null;o===null?a.words.push(Ir(n)):a.assigns.push({name:o.name,word:Ir(n,o.end)}),e.i++}if(t===`)`)throw Ta("unmatched `(`");if(t===`}`)throw Ta("unmatched `{`");if(t===`do`||t===`done`)throw Ta(`${e.loop}: missing \`${t}\``);if(t)throw Ta(`if: missing \`${t===`then`?`then`:`fi`}\``);if(!e.emptyStage&&!Ja(a)&&!qa(a)&&[`and`,`or`,`pipe`,`pipe_err`].includes(n.at(-1)?.kind))throw Ta(`empty pipeline stage`);return io.has(n.at(-1)?.kind)?r.pop():Za(r.at(-1),a)||Ka(e,r.at(-1),a),r}function oo(e,t){let{raw:n,i:r}=e,i=Ea(e,r+1),a=n[r-1],o=t.words[0],s=t.words.at(-1);if((n[r-2]?.kind!==`redir`||[`dup`,`close`].includes(n[r-2].op))&&(t.words.length===0&&t.assigns.length>0||s&&s.value===a?.value&&(t.words.length===1||o.mask===null&&no.has(o.value)))&&n[r].wordAdjacent&&a?.kind===`word`&&!a.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(a.value))throw new D(`feature`,`array assignment`,`shell array assignments are not supported`);if(i?.kind===`paren_open`&&i.adjacent&&Qa(t))throw new D(`feature`,`((`,"arithmetic evaluation (`((…))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&i?.kind===`paren_close`)t.define=Fa(e,t.words.pop(),ao);else{if(!Qa(t))throw Error("unexpected `(`");e.i++,t.group=ao(e,`)`),t.isolate=!0}}function so(e,t,n,r){let i=e.value;if(to.has(i))throw new D(`feature`,i,to.get(i));if(eo.has(i))throw Error(`syntax error near unexpected token \`${i}\``);if(!$a.has(i))return!1;if(t.i++,i===`!`){if(n.stages.length>0||r.redirs.length>0)throw Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(i===`{`)return Va(t),r.group=ao(t,`}`),r.isolate=!1,!0;if(i===`}`)throw Error("syntax error near unexpected token `}`");if(i===`done`)throw Error("unexpected `done`");if(i===`do`)throw Error("unexpected `do`");return i===`if`?r.conditional=Ma(t,ao):r.loop=i===`for`?Na(t,ao):Pa(t,i,ao),!0}var co={")":"empty subshell `()`","}":"empty group `{ }`"},lo=(e,t)=>t===`do`?`${e.loop}: empty condition`:t===`done`?`${e.loop}: empty loop body`:t===`then`?`if: empty condition`:`if: empty branch body`;function uo(e,t,n,r){let i=t.at(-1),a=Qa(n)&&n.redirs.length===0&&i.stages.length===0;if(a&&t.length===1)throw Error(co[r]??lo(e,r));if(a&&i.bang)throw Error("syntax error near unexpected token after `!`");return a&&i.gate===`seq`?t.pop():Ka(e,i,n),t}var fo=new Set([`/dev/null`,`/dev/stdout`,`/dev/stderr`]);function po(e){let t=e.raw[e.i++],n=Gi(t);if(e.syntaxOnly){if(![`dup`,`close`].includes(t.op)){let t=Ea(e,e.i++);if(!t||t.kind!==`word`)throw Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new D(`feature`,n,`only file descriptors 0, 1 and 2 are supported (got \`${n}\`)`);if(t.op===`dup`){if(t.fd===0&&t.toFd===0)return null;if(t.fd===0||t.toFd===0)throw new D(`feature`,n,`duplicating file descriptor 0 (\`${n}\`) is not supported`);return{fd:t.fd,op:`dup`,toFd:t.toFd}}if(t.op===`close`){if(t.fd===0)throw new D(`feature`,`0<&-`,`closing standard input is not supported`);return{fd:t.fd,op:`close`}}let r=Ea(e,e.i++);if(!r||r.kind!==`word`)throw Error(`redirect \`${n}\` requires a target`);if(t.op===`heredoc`||t.op===`herestring`||t.op===`read`){if(t.fd!==0)throw new D(`feature`,n,`reading into file descriptor ${t.fd} (\`${n}\`) is not supported`);return t.op===`heredoc`?{fd:0,op:`text`,body:t.body??``,expand:!t.quotedDelim}:{fd:0,op:t.op,word:Ir(r)}}if(t.fd===0)throw new D(`feature`,n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let i=t.op===`both`||t.op===`bothAppend`,a=t.op===`append`||t.op===`bothAppend`,o=Ir(r);if(mo(o))return{fd:t.fd,op:`to`,word:o,both:i,append:a,label:n};if(!e.writable&&!fo.has(o.value))throw ho(n,o.value,e.writable);return{fd:t.fd,op:`to`,target:o.value,both:i,append:a,label:n}}function mo(e){for(let t=0;t<e.value.length;t++){let n=e.value[t],r=e.mask===null?`0`:e.mask[t];if((n===`$`||n==="`")&&r!==`1`||r===`0`&&(/[~*?[{]/u.test(n)||(n===`<`||n===`>`)&&e.value[t+1]===`(`))return!0}return!1}function ho(e,t,n){return new D(`feature`,e,`\`${e}\` cannot write to \`${t}\`: ${n?"only `/tmp/` is writable":`the filesystem is read-only`}`)}var go=/^[a-zA-Z0-9][\w.+-]*$/u,_o=[`run`,`pipe`,`hidden`],vo=[`stdout`,`stderr`,`exitCode`];function yo(e,t){let n={__proto__:null},r=[],i=[];for(let[a,o]of bo(e)){let{run:e,pipe:s,hidden:c}=xo(a,o,t);c&&r.includes(a)||(n[a]=(t,n,r)=>So(a,e,t,n,r),!c&&(r.push(a),s&&i.push(a)))}return{handlers:n,names:r,pipeNames:i}}function bo(e){if(e==null)return[];if(Array.isArray(e))throw TypeError(`createTerminal: opts.commands must be an object or a Map (got an array)`);if(typeof e!=`object`)throw TypeError(`createTerminal: opts.commands must be an object or a Map (got ${typeof e})`);if(typeof e.entries==`function`)return[...e.entries()];let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw TypeError(`createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)`);return Object.entries(e)}function xo(e,t,n){if(typeof e!=`string`)throw TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!go.test(e))throw Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t==`function`){for(let n of Object.keys(t))if(_o.includes(n))throw Error(`createTerminal: ${e}: \`${n}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(typeof t!=`object`||!t)throw TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!=`function`)throw TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let n of Object.keys(t))if(!_o.includes(n))throw Error(`createTerminal: ${e}: unknown option \`${n}\` (known: ${_o.join(`, `)})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function So(e,t,n,r,i){i.io?.bufferOutput(),L(i);let a={cwd:i.cwd,fs:i.fs,mount:i.mount,home:i.home,get notes(){return i.notes},command:e,stdinFile:i.stdinFile,stdinOrigin:i.stdinOrigin},o=!0,s=()=>{o=!1},c=t({name:e,args:r,stdin:n,cwd:a.cwd,fs:Co(a),readInputs:(t=[])=>{if(typeof t==`string`)throw TypeError(`readInputs: expected an array of paths, got a string: ${t}`);return sr(e,[...t],n,a)},run:e=>{if(!o)throw Error(`run: the command this belongs to has finished, and its turn with it`);return i.runLine(e)}});return typeof c?.then==`function`?c.then(wo).finally(s):(s(),wo(c))}function Co(e){let t=t=>j(e.cwd,t,e.fs).path;return{resolve:t=>A(e.cwd,t),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:t=>e.fs.isLink?.(j(e.cwd,t,e.fs,{follow:!1}).path)===!0,readLink:t=>e.fs.readLink?.(j(e.cwd,t,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>ar(e.fs,t(n))?.slice(),listDir:t=>{let{path:n,error:r}=F(e,e.command,t);if(!e.fs.isDir(n))throw Error(`${t}: ${r??`Not a directory`}`);let{dirs:i,files:a,links:o=[]}=e.fs.listDir(n);return{dirs:[...i],files:[...a],links:[...o]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function wo(e){if(e==null)return S();if(typeof e==`string`)return S(e);if(typeof e!=`object`)throw TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw TypeError(`invalid result: expected a string or an object, got an array (join the lines first)`);let t=Object.keys(e);for(let e of t)if(!vo.includes(e))throw TypeError(`invalid result: unknown field \`${e}\` (known: ${vo.join(`, `)})`);if(t.length===0)throw TypeError(`invalid result: an object with none of ${vo.join(`, `)} \u2014 return a string for plain output`);let{stdout:n=``,stderr:r=``,exitCode:i=0}=e;if(typeof n!=`string`)throw TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!=`string`)throw TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(i)||i<0)throw TypeError(`invalid result: exitCode must be a non-negative integer (got ${i})`);return{stdout:n,stderr:r===``||r.endsWith(`
32
+ `)?r:r+`
33
+ `,exitCode:i}}var To=e=>e.type===`directory`?`${e.name}/`:e.name,Eo=e=>/(?:^|\/)\.(?:\/|$)/u.test(e)?[`dot-segment names`,"names stored with `.' segments are not supported"]:[`directory names`,`directories stored without a trailing slash are not supported`];function Do(e){return e.name===`.`||e.storedName!==To(e)?e.storedName:e.storedLinkname!==void 0&&e.storedLinkname!==e.linkname?e.storedLinkname:null}var Oo=new Map([[7,`a`],[8,`b`],[12,`f`],[10,`n`],[13,`r`],[9,`t`],[11,`v`]]),ko=e=>`\\`+e.toString(8).padStart(3,`0`);function Ao(e,t){let n=bn(t),r=Ln(t.locale),i=``;for(let t of e){let e=t.codePointAt(0);if(t===`\\`)i+=`\\\\`;else if(Oo.has(e))i+=`\\`+Oo.get(e);else if(e<128?e>=32&&e<127:!n&&r.has(`print`,e))i+=t;else for(let e of O(t))i+=ko(e)}return i}var jo={__proto__:null,file:`-`,"contiguous-file":`C`,directory:`d`,symlink:`l`,hardlink:`h`,fifo:`p`,"character-device":`c`,"block-device":`b`};function Mo(e,t){let n=[...`rwxrwxrwx`].map((e,n)=>t&256>>n?e:`-`),r=(e,r,i)=>{(t&e)!==0&&(n[r]=n[r]===`x`?i:i.toUpperCase())};return r(2048,2,`s`),r(1024,5,`s`),r(512,8,`t`),jo[e]+n.join(``)}var No=e=>O(e).length,Po=new Set([`character-device`,`block-device`]);function Fo(e,{numericOwner:t=!1,utc:n=!1}={}){let r=19,i=16,a=n||e.vars.has(`TZ`),o=n=>{let o=!t&&n.uname!==``?n.uname:String(n.uid),s=!t&&n.gname!==``?n.gname:String(n.gid),c=Po.has(n.type)?`${n.devmajor},${n.devminor}`:String(n.data.length),l=No(o)+1+No(s)+1+c.length;l>r&&(r=l);let u=Lo(n.mtime,a);return u.length>i&&(i=u.length),`${Mo(n.type,n.mode)} ${o}/${s} ${` `.repeat(r-l)}${c} ${u.padEnd(i)} `+Ao(To(n),e)+Io(n,e)};return o.mkdir=t=>`${Mo(`directory`,448)} ${`Creating directory:`.padStart(r+1+i)} ${Ao(t,e)}`,o}function Io(e,t){return e.type===`symlink`?` -> ${Ao(e.linkname,t)}`:e.type===`hardlink`?` link to ${Ao(e.linkname,t)}`:``}function Lo(e,t){let n=new Date(e*1e3);if(Number.isNaN(n.getTime()))throw new D(`feature`,`archive time`,`a modification time of ${e} seconds is past what this terminal can print`);return Wv(n,`%Y-%m-%d %H:%M`,t)}var Ro=(e,t)=>Ao(e,t).replaceAll(`:`,`\\:`);function zo(e,t){let n=Ao(e,t);return bn(t)?`'${n.replaceAll(`'`,`\\'`)}'`:`\u2018${n}\u2019`}function Bo(e){let t=e.length;for(;t>1&&e[t-1]===`/`;)t--;return e.slice(0,t)}function Vo(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`)t++;else if(`?*[]`.includes(e[t]))return!0;return!1}var Ho=(e,t)=>t===e||t.startsWith(e)&&t[e.length]===`/`;function Uo(e){let t=[],n=[];for(let r of e)r.dir===void 0?r.name!==``&&t.push({given:r.name,operand:Bo(r.name),dirs:[...n],found:!1}):n.push(r.dir);let r={dirs:n};return{names:t,match(e){if(t.length===0)return r;let n=t.find(t=>Ho(t.operand,e));return n!==void 0&&(n.found=!0),n??null}}}function Wo(e,t,n){for(let r of e.names)r.found||(!n&&Vo(r.operand)&&(t.warn(`Pattern matching characters used in file names`),t.warn(`Use --wildcards to enable pattern matching, or --no-wildcards to suppress this warning`)),t.error(`${Ro(r.operand,t.ctx)}: Not found in archive`))}function Go(e,t,n){let{ctx:r}=n,i=j(e,t,r.fs),a=i.error??(r.fs.isDir(i.path)?null:`Not a directory`);return a===null?i.path:(n.fatal(`${Ro(t,r)}: Cannot open: ${a}`),null)}async function Ko(e,t){try{return{bytes:await l(e,t),error:null}}catch(e){if(!(e instanceof o))throw e;return{bytes:e.bytes,error:e.cause?.cause?.message??e.cause?.message??`corrupt input`}}}var qo=10,Jo=8,Yo=8,Xo=16,Zo=4,Qo=2,$o=8,es=`gzip`,ts=`deflate-raw`,ns=(e,t)=>e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216;function rs(e,t){if(e[t]!==31||e[t+1]!==139||e[t+2]!==Yo)return-1;let n=e[t+3],r=t+qo;if((n&Zo)!==0){if(r+2>e.length)return-1;r+=2+e[r]+e[r+1]*256}for(let t of[$o,Xo])if((n&t)!==0){for(;r<e.length&&e[r]!==0;)r++;r++}return(n&Qo)!==0&&(r+=2),r<=e.length?r-t:-1}var is=64;async function as(e,t){let n=rs(e,t);if(n<0)return null;let r=(await Ko(e.subarray(t+n),ts)).bytes.length%4294967296,i=is;for(let a=t+n+Jo;a<=e.length&&i>0;a++){if(ns(e,a-4)!==r)continue;i--;let n=await Ko(e.subarray(t,a),es);if(n.error===null)return{bytes:n.bytes,end:a}}return null}async function os(e){let t=await Ko(e,es);if(t.error===null||!s(ts))return{...t,rest:null};let n=[],r=0;for(;;){let t=await as(e,r);if(t===null)break;n.push(t.bytes),r=t.end}return r===0||r===e.length?{...t,rest:null}:{bytes:Dt(n),error:t.error,rest:e.subarray(r)}}function U(e,t={}){let n=cs(t.short),r=cs(t.long),i=cs(t.valueShort),a=cs(t.valueLong),o=cs(t.repeatable),s=new Set,c=new Map,l=[],u=[],d=0;function f(t,l,f=!1){let p=(f?`--`:`-`)+t,m=(f?a:i).has(t)||o.has(t)&&(!f||t.length>1);if(m){let n=l??e[++d];if(l===null&&d>=e.length)throw Error(p+` requires an argument`);if(o.has(t)){let e=c.get(t);e?e.push(n):c.set(t,[n])}else c.set(t,n);u.push({name:t,value:n})}else{if(!(f?r:n).has(t))throw new D(`option`,p,`unknown option: `+p);if(f&&l!==null)throw Error(`option `+p+` doesn't allow an argument`);s.add(t),u.push({name:t})}return m}for(;d<e.length;d++){let r=e[d];if(r===`--`){l.push(...e.slice(d+1));break}if(r.startsWith(`--`)&&r.length>2){let e=r.indexOf(`=`);f(e===-1?r.slice(2):r.slice(2,e),e===-1?null:r.slice(e+1),!0)}else if(r.startsWith(`-`)&&r.length>1&&!(t.numericOperands&&ss(r,n,i,o)))for(let e=1;e<r.length&&!f(r[e],e+1<r.length?r.slice(e+1):null);e++);else{if(t.stopAtFirstPositional){l.push(...e.slice(d));break}l.push(r)}}return{flags:s,values:c,positional:l,order:u}}function ss(e,t,n,r){if(!/^-\d/u.test(e))return!1;let i=e[1];return!t.has(i)&&!n.has(i)&&!r.has(i)}function cs(e){return e instanceof Set?e:new Set(e??[])}var ls=`gzip`,us=(e,t,n)=>Os(e,[`-d`,...t],n),ds=(e,t,n)=>Os(e,[`-d`,`-c`,...t],n),fs=s(ls)?{gzip:Os,gunzip:us,zcat:ds,gzcat:ds}:{},ps=Object.freeze([31,139]),ms=e=>e!==void 0&&e.length>=2&&e[0]===ps[0]&&e[1]===ps[1],hs=Object.freeze([[31,158],[31,30],[31,157],[31,160]]),gs=Object.freeze([80,75,3,4]),_s=(e,t)=>e.length>=t.length&&t.every((t,n)=>e[n]===t),vs=(e,t)=>hs.some(t=>_s(e,t))||t&&_s(e,gs);function ys(e,t){return t.gap??=T(`feature`,`gzip`,`other formats`,`gzip: ${e}: data compressed other than by gzip is not supported`,1),!1}var bs={__proto__:null,"unexpected end of file":`unexpected end of file`,"incorrect data check":`invalid compressed data--crc error`},xs=e=>bs[e]??`invalid compressed data--format violated`,Ss=8;function Cs(e,t){let n=t.rest,r=t=>({text:`
34
+ gzip: ${e}: ${t}
35
+ `,status:1,whole:!1});return n===null?r(xs(t.error)):n.every(e=>e===0)?null:n.length>=2&&!ms(n)?{text:`
36
+ gzip: ${e}: decompression OK, trailing garbage ignored
37
+ `,status:2,whole:!0}:n.length>2&&n[2]!==Ss?{text:`gzip: ${e}: unknown method ${n[2]} -- not supported
38
+ `,status:1,whole:!0}:r(xs(t.error))}function ws(e,t,n){let r=Cs(t,n);return r===null||(e.stderr+=r.text,e.status=e.status===1?1:r.status),!1}var Ts=Object.freeze({__proto__:null,".gz":``,".tgz":`.tar`,".taz":`.tar`,"-gz":``,".z":``,"-z":``,_z:``}),Es=`.gz`,Ds=Object.freeze([`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]);async function Os(e,t,n){let{flags:r,positional:i}=U(t,{short:[...Ds,`d`,`c`,`k`,`f`],long:[`decompress`,`uncompress`,`stdout`,`to-stdout`,`keep`,`force`]}),a=Ds.find(e=>r.has(e));if(a!==void 0)return T(`option`,`gzip`,`-${a}`,`gzip: -${a}: choosing a compression level is not supported`,1);let o={decompressing:[`d`,`decompress`,`uncompress`].some(e=>r.has(e)),stdout:[`c`,`stdout`,`to-stdout`].some(e=>r.has(e)),keep:r.has(`k`)||r.has(`keep`),force:r.has(`f`)||r.has(`force`)},s={ctx:n,events:[],stderr:``,status:0,gap:null,stopped:!1};if(i.length===0)await ks(o,s);else for(let e of i)if(await As(e,o,s),s.stopped)break;if(s.gap)return s.gap;let c=[...s.events,...s.stderr?[{fd:2,text:s.stderr}]:[]];return{stdout:``,stderr:s.stderr,exitCode:s.status,events:c}}async function ks(e,t){if(!e.force&&(e.decompressing?er(t.ctx):tr(t.ctx))){let[n,r]=e.decompressing?[`read from`,`decompression`]:[`written to`,`compression`];t.stderr+=`gzip: compressed data not ${n} a terminal. Use -f to force ${r}.
39
+ For help, type: gzip -h
40
+ `,t.status=1,t.stopped=!0;return}let n=t.ctx.stdinLeft,r=t.ctx.stdinBytes;return L(t.ctx,``,!0),e.decompressing?Rs(`stdin`,r??O(n),{...e,stdout:!0},t):Vs(await c(r??O(n),ls),t)}function As(e,t,n){let{ctx:r}=n;if(e===`-`)return ks(t,n);if(!t.stdout&&!t.force&&js(e,r))return Gs(n,`${e}: Too many levels of symbolic links`,1);let i=F(r,`gzip`,e);return i.error?Gs(n,`${e}: ${i.error}`,1):r.fs.isDir(i.path)?Gs(n,`${e} is a directory -- ignored`,2):t.decompressing?Ls(e,i.path,t,n):Ms(e,i.path,t,n)}function js(e,t){let n=j(t.cwd,e,t.fs,{follow:!1});return n.path!==null&&t.fs.isLink?.(n.path)===!0}async function Ms(e,t,n,r){let{ctx:i}=r,a=zs(e);if(!n.stdout&&!n.force&&a!==void 0)return Ws(r,`${e} already has ${a} suffix -- unchanged`);let o=Is(await c(ar(i.fs,t),ls),e.slice(e.lastIndexOf(`/`)+1),Ns(i));return n.stdout?Vs(o,r):Hs(e+Es,o,e,n,r)}var Ns=e=>Math.floor(e.createdAt/1e3),Ps=10,Fs=8;function Is(e,t,n){let r=O(t);if(e.length<Ps||e[3]!==0||r.includes(0))return e;let i=new Uint8Array(e.length+r.length+1);i.set(e.subarray(0,Ps)),i[3]=Fs;for(let e=0;e<4;e++)i[4+e]=n>>>8*e&255;return i.set(r,Ps),i.set(e.subarray(Ps),Ps+r.length+1),i}function Ls(e,t,n,r){let{ctx:i}=r;return!n.stdout&&zs(e)===void 0?Gs(r,`${e}: unknown suffix -- ignored`,2):Rs(e,ar(i.fs,t),n,r,t)}async function Rs(e,t,n,r,i=null){let{ctx:a}=r,o=n.force&&n.stdout;if(t!==void 0&&vs(t,!0))return ys(e,r);if(!ms(t))return o?Vs(t,r):Us(r,`${e}: ${Bs(t,i,a)?`unexpected end of file`:`not in gzip format`}`);let s=await os(t),c=s.rest,l=c!==null&&c.length>0&&!ms(c)?c:null;if(l!==null&&vs(l,!1))return ys(e,r);let u=zs(e);if(n.stdout?Vs(s.bytes,r):Hs(e.slice(0,-u.length)+Ts[u],s.bytes,e,n,r)){if(l!==null&&o)return Vs(l,r);s.error&&ws(r,e,s)}}var zs=e=>Object.keys(Ts).find(t=>e.length>t.length&&e.endsWith(t));function Bs(e,t,n){let r=e??b(n.fs.readFile(t).slice(0,2));return r.length===0||r.length===1&&r[0]!==0}var Vs=(e,t)=>(t.events.push({fd:1,bytes:e}),!0);function Hs(e,t,n,r,i){let{ctx:a}=i,o=j(a.cwd,e,a.fs,{follow:!1}).path;if(o!==null&&!r.force)return Gs(i,`${e} already exists;${er(a)?` do you wish to overwrite (y or n)? `:``} not overwritten`,2);if(o!==null&&a.fs.isLink?.(o)!==!0&&a.fs.isDir(o))return Gs(i,`${e}: Is a directory`,1);o!==null&&a.fs.removeWritable(a.cwd,e);let s;try{s=a.writable&&a.fs.openWritable?.(a.cwd,e)}catch(t){return Gs(i,`${e}: ${t.message}`,1)}return s?(s.writeBytes(t),r.keep||a.fs.removeWritable(a.cwd,n),!0):(i.gap??=T(`feature`,`gzip`,`read-only target`,`gzip: ${e}: file system is read-only`,1),!1)}var Us=(e,t)=>Gs(e,t,1,`
41
+ `),Ws=(e,t)=>Gs(e,t,e.status);function Gs(e,t,n,r=``){return e.stderr+=`${r}gzip: ${t}
42
+ `,e.status=e.status===1?1:n,!1}var Ks=new Set([`atime`,`charset`,`comment`,`ctime`,`gid`,`gname`,`linkpath`,`mtime`,`path`,`size`,`uid`,`uname`,`RHT.security.selinux`,`SCHILY.acl.access`,`SCHILY.acl.default`]),qs=e=>Ks.has(e)||e.startsWith(`SCHILY.xattr.`),Js=e=>e===`GNU.dumpdir`||e.startsWith(`GNU.volume.`),Ys=-(2n**63n),Xs=2n**63n-1n;function Zs(e){let t=/^(-?[0-9]+)(?:\.([0-9]*))?$/u.exec(e);if(t===null)return!1;let n=BigInt(t[1])-(t[1].startsWith(`-`)&&/[1-9]/u.test(t[2]??``)?1n:0n);return n>=Ys&&n<=Xs}function Qs(e,t){for(let[n,r]of e){if(Js(n))return[`extended header`,`${t(n)}: records of multi-volume and incremental archives are not supported`];if((n===`atime`||n===`ctime`)&&!Zs(r))return[`extended header`,`${t(`${n}=${r}`)}: extended header times GNU would reject are not supported`]}return null}function $s(e,t){let n=[],r=[],i=null;for(let a of e){let e=(a.globalPax===i?null:Qs(a.globalPax,t))??Qs(a.pax,t);if(e!==null)return{gap:e};i=a.globalPax;let o=Do(a);if(o!==null){let[e,n]=Eo(o);return{gap:[e,`${t(o)}: ${n}`]}}n.push([...a.pax.keys()].filter(e=>!qs(e)).map(e=>`Ignoring unknown extended header keyword '${e}'`));let s=a.pax.get(`mtime`)??a.globalPax.get(`mtime`);r.push(s===void 0?a.mtime:Number(s))}return{warnings:n,mtimes:r}}var ec=512,tc=10,nc=e=>({entries:[],child:e,warnings:[],mtimes:[]}),rc=[{bytes:[31,157],option:`-Z`},{bytes:[31,139],option:`-z`},{bytes:[66,90,104],option:`-j`},{bytes:[76,90,73,80],option:`--lzip`},{bytes:[255,76,90,77,65,0],option:`--lzma`},{bytes:[93,0,0],option:`--lzma`},{bytes:[137,76,90,79],option:`--lzop`},{bytes:[253,55,122,88,90,0],option:`-J`},{bytes:[40,181,47,253],option:`--zstd`}],ic=e=>rc.find(({bytes:t})=>t.length<=e.length&&t.every((t,n)=>e[n]===t)),ac={__proto__:null,gz:`-z`,tgz:`-z`,taz:`-z`,Z:`-Z`,taZ:`-Z`,bz2:`-j`,tbz:`-j`,tbz2:`-j`,tz2:`-j`,lz:`--lzip`,lzma:`--lzma`,tlz:`--lzma`,lzo:`--lzop`,xz:`-J`,txz:`-J`,zst:`--zstd`,tzst:`--zstd`};function oc(e){let t=e.lastIndexOf(`.`);return t===-1?void 0:ac[e.slice(t+1)]}function sc(e,t){return e.refuse(`option`,t,`${t}: archives compressed other than with gzip are not supported`),null}var cc=e=>{let t=e.indexOf(`:`);return t!==-1&&!e.slice(0,t).includes(`/`)};function lc(e,t){let{ctx:n}=t,r=e.archive;if(r===`-`){if(er(n))return t.fatal(`Refusing to read archive contents from terminal (missing -f option?)`);let e=n.stdinBytes??O(n.stdinLeft);return L(n,``,!0),{bytes:e,name:r,stdin:!0}}if(cc(r))return t.refuse(`feature`,`remote archive`,`${r}: remote archives are not supported`);if(r===`/dev/null`)return{bytes:new Uint8Array,name:r,stdin:!1};if(r.startsWith(`/dev/`))return t.refuse(`feature`,`special file`,`${r}: reading an archive from a device is not supported`);let i=F(n,`tar`,r);return i.error?t.fatal(`${Ro(r,n)}: Cannot open: ${i.error}`):n.fs.isDir(i.path)?(t.warn(`${Ro(r,n)}: Cannot read: Is a directory`),t.fatal(`At beginning of tape, quitting now`)):{bytes:ar(n.fs,i.path),name:r,stdin:!1}}function uc(e,t){let n=lc(e,t);if(!n)return null;let r=n.bytes;if(e.gzip)return dc(r,t);let i=r.length>=ec?fc(r):null;if(i?.entries!==void 0)return mc(i.entries,t,0);let a=ic(r);if(a!==void 0)return n.stdin?t.fatal(`Archive is compressed. Use ${a.option} option`):a.option===`-z`?dc(r,t):sc(t,a.option);let o=r.length<ec;o&&t.error(`This does not look like a tar archive`);let s=n.stdin?void 0:oc(n.name);return s!==void 0&&s!==`-z`?sc(t,s):o?s===void 0?nc(0):dc(r,t):pc(i.error,t)}async function dc(e,t){if(!s(`gzip`))return t.refuse(`option`,`-z`,`this runtime has no gzip stream`);if(!ms(e))return t.say(2,`
43
+ gzip: stdin: ${e.length<2?`unexpected end of file`:`not in gzip format`}
44
+ `),nc(1);let n=await os(e),r=n.error===null?null:Cs(`stdin`,n);if(r!==null&&!r.whole&&e.length>tc)return t.refuse(`feature`,`damaged gzip stream`,`the gzip stream is damaged, and how much of it GNU gzip would inflate is not known here`),null;r!==null&&t.say(2,r.text);let i=r?.status??0;if(n.bytes.length<ec)return nc(i);let a=fc(n.bytes);return a.entries===void 0?pc(a.error,t):mc(a.entries,t,i)}function fc(e){try{return{entries:y(e)}}catch(e){if(!(e instanceof i))throw e;return{error:e}}}function pc(e,t){return t.refuse(`feature`,`archive`,`this archive is not one this terminal reads: ${e.message}`),null}function mc(e,t,n){let r=$s(e,e=>Ro(e,t.ctx));return r.gap===void 0?{entries:e,child:n,...r}:(t.refuse(`feature`,...r.gap),null)}var hc=512,gc={file:384,directory:448,symlink:511};async function _c(e,t){let{ctx:n}=t;if(e.archive===`-`&&tr(n))return t.fatal(`Refusing to write archive contents to terminal (missing -f option?)`);if(e.format===`pax`)return t.refuse(`option`,`--format=pax`,`the pax format records access and change times, which this tree does not have`);let r=vc(e,t),i=r&&yc(e,t);if(i===null||!r)return;if(i&&!s(`gzip`))return t.refuse(`option`,`-z`,`this runtime has no gzip stream`);let a=bc(e.archive,t);if(!a)return;if(i&&a.kind===`stdout`&&t.closedOut)return t.refuse(`feature`,`closed stdout`,`writing a compressed archive to a closed stdout is not supported`);(a.kind===`stdout`||e.toStdout)&&(t.listTo=2);let o={state:t,owners:r,target:a,entries:[],verbose:e.verbose,many:e.items.filter(e=>e.name!==void 0).length>1,mtime:Math.floor(n.createdAt/1e3),members:new Set,links:new Set,line:e.verbose>1?Fo(n,e):null,archived:new Map},c=n.cwd,l=[];for(let n of e.items)if(n.dir!==void 0)l.push(n.dir);else{for(let n of l)if(c=Go(c,n,t),c===null)return wc(o,e,i,!0);if(l=[],Sc(n.name,c,o),t.stopped)return}if(l.length){t.warn(`The following options were used after non-option arguments. These options are positional and affect only arguments that follow them. Please, rearrange them properly.`);for(let e of l)t.error(`-C ${zo(e,n)} has no effect`)}await wc(o,e,i,!1)}function vc(e,t){let{owner:n,group:r,numericOwner:i}=e,a=e=>e!==void 0&&e.id!==null&&(e.name!==null||i);return!a(n)||!a(r)?(t.refuse(`feature`,`file owners`,`the files here have no numeric owner or group to record; give them with --owner=NAME:UID and --group=NAME:GID, or as ids with --numeric-owner`),null):{uid:n.id,gid:r.id,uname:i?``:n.name,gname:i?``:r.name}}function yc(e,t){if(e.gzip)return!0;let n=e.auto&&e.archive!==`-`?oc(e.archive):void 0;return n===void 0?!1:n===`-z`||sc(t,n)}function bc(e,t){let{ctx:n}=t;if(e===`-`)return{kind:`stdout`};if(e===`/dev/null`)return{kind:`null`};if(cc(e))return t.refuse(`feature`,`remote archive`,`${e}: remote archives are not supported`);if(e.startsWith(`/dev/`))return t.refuse(`feature`,`special file`,`${e}: writing an archive to a device is not supported`);let r=Ro(e,n),i=A(n.cwd,e),a=j(n.cwd,e,n.fs);if(a.path!==null&&n.fs.isDir(a.path))return t.fatal(`${r}: Cannot open: Is a directory`);let o=j(n.cwd,M(i),n.fs);if(a.path===null&&(o.error||!n.fs.isDir(o.path)))return t.fatal(`${r}: Cannot open: ${o.error??`Not a directory`}`);let s=n.writable&&B(a.path??i)?n.fs.openWritable(n.cwd,e):null;return s?{kind:`file`,handle:s,path:s.path}:t.refuse(`feature`,`read-only target`,`${r}: Cannot open: Read-only file system`)}function xc(e,t){let n=0;for(let t=0;t<e.length;){e.startsWith(`..`,t)&&(t+2===e.length||e[t+2]===`/`)&&(n=t+2);let r=e.indexOf(`/`,t);t=r===-1?e.length:r+1}for(;e[n]===`/`;)n++;let r=e.slice(0,n);return e===``?t.state.warn("Substituting `.' for empty member name"):r!==``&&!t.members.has(r)&&(t.members.add(r),t.state.warn(`Removing leading \`${r}' from member names`)),{prefix:r,name:n===e.length?`.`:e.slice(n)}}function Sc(e,t,n){let{ctx:r}=n.state,i=Bo(e);if(i===`/dev`||i.startsWith(`/dev/`)){n.state.refuse(`feature`,`special file`,`${Ro(i,r)}: archiving special files is not supported`);return}let a=xc(i,n),o=j(t,i,r.fs,{follow:!1});o.error?n.state.error(`${Ro(i,r)}: Cannot stat: ${o.error}`):Cc(o.path,i,a,n)}function Cc(e,t,n,r){let{state:i}=r,{fs:a}=i.ctx,o=a.isDir(e),s=!o&&a.isLink?.(e)===!0;if(r.target.kind===`file`&&r.target.path===e)return i.warn(`${Ro(t,i.ctx)}: archive cannot contain itself; not dumped`);if(n.name!==`.`&&n.name.split(`/`).some(e=>e===`.`||e===``))return i.refuse(`feature`,`dot-segment names`,`${Ro(t,i.ctx)}: member names with \`.' or empty segments are not supported`);let c=o?`directory`:s?`symlink`:`file`,l=r.many&&!o?r.archived.get(e):void 0;if(l===n.name)return i.refuse(`feature`,`repeated name`,`${Ro(t,i.ctx)}: storing a name again, as a hard link to itself, is not supported`);r.many&&!o&&l===void 0&&r.archived.set(e,n.name);let u=l===void 0?{name:n.name,type:c,mode:gc[c],mtime:r.mtime,...r.owners,linkname:s?a.readLink(e):``,data:c===`file`?ar(a,e):void 0}:{name:n.name,type:`hardlink`,mode:gc[c],mtime:r.mtime,...r.owners,linkname:l};if(r.entries.push(u),r.verbose&&i.list(r.line?r.line({...u,name:t,data:u.data??new Uint8Array}):o?`${t}/`:t),r.many&&!o&&l===void 0&&n.prefix!==``&&!r.links.has(n.prefix)&&(r.links.add(n.prefix),i.warn(`Removing leading \`${n.prefix}' from hard link targets`)),!o)return;let{dirs:d,files:f,links:p=[]}=a.listDir(e);for(let n of[...new Set([...d,...f,...p])].sort(N)){let a=t===`/`?`/${n}`:`${t}/${n}`;if(Cc(Ft(e,n),a,xc(a,r),r),i.stopped)return}}async function wc(e,t,n,r){let{state:a,target:o}=e,s;try{s=v(e.entries,{format:t.format,blocking:r?1:t.blocking})}catch(e){if(!(e instanceof i))throw e;return a.refuse(`feature`,`archive`,`this archive cannot be written here: ${e.message}`)}if(r){let e=t.blocking*hc;s=s.subarray(0,Math.floor((s.length-2*hc)/e)*e)}n&&(s=await c(s,`gzip`)),o.kind===`stdout`&&!a.closedOut?a.bytes(s):o.kind===`file`&&o.handle.writeBytes(s)}var Tc=new Set([`file`,`contiguous-file`,`directory`,`symlink`]);function Ec(e,t){let n=e.split(`/`).filter(e=>e!==``);return n.length<=t?null:n.slice(t).join(`/`)}var Dc=(e,t)=>A(e,t);function Oc(e,t,n,r,i,a=()=>{}){let{ctx:o}=r,s=Ro(t,o);if(!Tc.has(e.type)){let t=e.type===`hardlink`?`hard links`:`special files`;return r.refuse(`feature`,e.type,`${s}: extracting ${t} is not supported`)}let c=e.type===`directory`?`mkdir`:`open`,l=()=>r.refuse(`feature`,`read-only target`,`${s}: Cannot ${c}: Read-only file system`);if(!o.writable||!B(n))return l();let u=kc(M(n),r);if(u===`read-only`)return l();if(typeof u==`string`)return r.error(`${s}: Cannot ${c}: ${u}`);if(u>0&&a(u),e.type===`directory`)return Ac(n,s,r);let d=e.type===`symlink`?`Cannot create symlink to ${zo(e.linkname,o)}`:`Cannot open`;if(j(`/`,n,o.fs,{follow:!1}).path!==null&&(i||!jc(n,o.fs)))return r.error(`${s}: ${d}: File exists`);if(e.type===`symlink`)return o.fs.makeWritableLink(`/`,n,e.linkname)||l();let f=o.fs.openWritable(`/`,n);return f?(f.writeBytes(e.data),!0):l()}function kc(e,t){let{fs:n}=t.ctx,r=[];for(let t=e;;t=M(t)){let e=j(`/`,t,n);if(e.path!==null){if(!n.isDir(e.path))return`Not a directory`;break}if(j(`/`,t,n,{follow:!1}).path!==null)return`File exists`;r.push(t)}for(let e of r.toReversed())if(!B(e)||!n.makeWritableDir(`/`,e))return`read-only`;return r.length}function Ac(e,t,n){let{fs:r}=n.ctx,i=j(`/`,e,r,{follow:!1});return i.path!==null&&r.isDir(i.path)&&!r.isLink?.(i.path)?!0:i.path!==null&&!jc(e,r)?n.error(`${t}: Cannot mkdir: File exists`):(r.makeWritableDir(`/`,e),!0)}function jc(e,t){let n=j(`/`,e,t,{follow:!1});if(t.isDir(n.path)&&!t.isLink?.(n.path)){let{dirs:r,files:i,links:a}=t.listDir(n.path);return r.length||i.length||a.length?!1:(t.removeWritableDir(`/`,e),!0)}return t.removeWritable(`/`,e),!0}var Mc=new Set([`create`,`list`,`extract`]),Nc={__proto__:null,c:`create`,t:`list`,x:`extract`,f:`file`,v:`verbose`,z:`gzip`,C:`directory`,O:`to-stdout`,a:`auto-compress`,H:`format`,b:`blocking-factor`,k:`keep-old-files`},Pc={__proto__:null,create:`create`,list:`list`,extract:`extract`,get:`extract`,file:`file`,verbose:`verbose`,gzip:`gzip`,gunzip:`gzip`,ungzip:`gzip`,directory:`directory`,"to-stdout":`to-stdout`,"auto-compress":`auto-compress`,format:`format`,"blocking-factor":`blocking-factor`,"keep-old-files":`keep-old-files`,"strip-components":`strip-components`,owner:`owner`,group:`group`,"numeric-owner":`numeric-owner`,utc:`utc`,"no-wildcards":`no-wildcards`,sort:`sort`},Fc=new Set([`file`,`directory`,`format`,`blocking-factor`,`strip-components`,`owner`,`group`,`sort`]),Ic=`Try 'tar --help' or 'tar --usage' for more information.`,Lc=(e,t=2)=>({usage:{text:`tar: ${e}
45
+ ${Ic}
46
+ `,status:t}});function Rc(e){if(e.length===0||e[0].startsWith(`-`))return{words:e};let t=e.slice(1),n=[],r=0;for(let i of e[0])if(n.push(`-`+i),Fc.has(Nc[i])){if(r>=t.length)return Lc(`Old option '${i}' requires an argument.`);n.push(t[r++])}return{words:[...n,...t.slice(r)],old:!0}}function zc(e,t){let n=Rc(e);if(n.usage)return n;let{words:r}=n,i={mode:null,items:[],verbose:0,values:new Map,flags:new Set,files:0};for(let e=0;e<r.length;e++){let n=r[e];if(n===`--`){for(let t of r.slice(e+1))i.items.push({name:t});break}let a=null;if(n.startsWith(`--`)){let o=n.indexOf(`=`),s=o===-1?n.slice(2):n.slice(2,o),c=Pc[s];if(c===void 0)throw new D(`option`,`--${s}`,`unknown option: --${s}`);a=Fc.has(c)?o===-1?e+1<r.length?Bc(i,c,r[++e],t):Lc(`option '--${s}' requires an argument`,64):Bc(i,c,n.slice(o+1),t):o===-1?Bc(i,c,void 0,t):Lc(`option '--${s}' doesn't allow an argument`,64)}else if(n.startsWith(`-`)&&n.length>1)for(let o=1;o<n.length&&a===null;o++){let s=n[o],c=Nc[s];if(c===void 0)throw new D(`option`,`-${s}`,`unknown option: -${s}`);if(!Fc.has(c))a=Bc(i,c,void 0,t);else{a=o+1<n.length?Bc(i,c,n.slice(o+1),t):e+1<r.length?Bc(i,c,r[++e],t):Lc(`option requires an argument -- '${s}'`,64);break}}else i.items.push({name:n});if(a!==null)return a}return Wc(i)}function Bc(e,t,n,r){if(Mc.has(t)){if(e.mode!==null&&e.mode!==t)return Lc(`You may not specify more than one '-Acdtrux', '--delete' or '--test-label' option`);e.mode=t,t===`list`&&e.verbose++}else if(t===`verbose`)e.verbose++;else if(t===`directory`)e.items.push({dir:n});else if(n===void 0)e.flags.add(t);else{let i=Vc[t]?.(n,r)??{value:n};if(i.gap)throw new D(`option`,i.gap.detail,i.gap.message);if(i.usage)return i;t===`file`&&e.files++,e.values.set(t,i.value)}return null}var Vc={__proto__:null,"strip-components":e=>{let t=Yc(e);return t===null||t<0?Lc(`${e}: Invalid number of elements`):{value:t}},"blocking-factor":e=>{let t=Yc(e);return t===null||t<1||t>0x7fffffff?Lc(`${e}: Invalid blocking factor`):{value:t}},format:e=>{let t=Gc[e];return t===void 0?Lc(`${e}: Invalid archive format`):t===null?{gap:{detail:`--format=${e}`,message:`the ${e} archive format is not supported`}}:{value:t}},sort:(e,t)=>{let n=qc(e,Kc);if(n.error){let r=Kc.map(e=>` - ${zo(e,t)}
47
+ `).join(``);return{usage:{text:`tar: ${n.error} argument ${zo(e,t)} for ${zo(`--sort`,t)}
48
+ Valid arguments are:
49
+ ${r}`,status:2}}}return n.value===`inode`?{gap:{detail:`--sort=inode`,message:`--sort=inode is not supported`}}:n},owner:(e,t)=>Uc(e,t),group:(e,t)=>Uc(e,t)},Hc=0xffffffff;function Uc(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(n+1),i=n===-1?/^\d+$/u.exec(e):/^[ \t\n\v\f\r]*\+?(\d+)$/u.exec(r);if(n===-1&&i===null)return{value:{name:e,id:null}};let a=i===null?null:Number(BigInt(i.at(-1))>BigInt(Hc)?-1:i.at(-1));return a===null||a<0?{usage:{text:`tar: ${Ro(r,t)}: Invalid owner or group ID
50
+ tar: Error is not recoverable: exiting now
51
+ `,status:2}}:{value:{name:n>0?e.slice(0,n):null,id:a}}}function Wc(e){return e.mode===null?Lc(`You must specify one of the '-Acdtrux', '--delete' or '--test-label' options`):e.files>1?Lc(`Multiple archive files require '-M' option`):e.mode===`create`&&!e.items.some(e=>e.name!==void 0)?Lc(`Cowardly refusing to create an empty archive`):{mode:e.mode,items:e.items,verbose:e.flags.has(`utc`)?Math.max(e.verbose,2):e.verbose,archive:e.values.get(`file`)??`-`,gzip:e.flags.has(`gzip`),auto:e.flags.has(`auto-compress`),toStdout:e.flags.has(`to-stdout`),keepOld:e.flags.has(`keep-old-files`),numericOwner:e.flags.has(`numeric-owner`),utc:e.flags.has(`utc`),noWildcards:e.flags.has(`no-wildcards`),owner:e.values.get(`owner`),group:e.values.get(`group`),strip:e.values.get(`strip-components`)??0,blocking:e.values.get(`blocking-factor`)??20,format:e.values.get(`format`)??`gnu`}}var Gc={__proto__:null,gnu:`gnu`,ustar:`ustar`,pax:`pax`,posix:`pax`,oldgnu:null,v7:null},Kc=[`none`,`name`,`inode`];function qc(e,t){if(t.includes(e))return{value:e};let n=t.filter(t=>t.startsWith(e));return n.length===1?{value:n[0]}:{error:n.length?`ambiguous`:`invalid`}}var Jc=2n**63n-1n;function Yc(e){let t=/^[ \t\n\v\f\r]*([+-]?)(\d+)$/u.exec(e);if(!t)return null;let n=BigInt(t[1]+t[2]);return n>Jc||n<-Jc-1n?null:n<0n?-1:Number(n>BigInt(2**53-1)?2**53-1:n)}function Xc(e){let t={ctx:e,events:[],status:0,stopped:!1,gap:null,listTo:1,closedOut:e.closed?.out===!0,lostListing:null,say(e,n){t.events.push({fd:e,text:n})},list(e,n=!0){t.listTo===1&&t.closedOut?t.lostListing=n?`flushed`:`pending`:t.say(t.listTo,e+`
52
+ `)},bytes(e){t.events.push({fd:1,bytes:e})},warn(e){t.say(2,`tar: ${e}
53
+ `)},error(e){t.warn(e),t.status=2},fatal(e){t.warn(e),t.warn(`Error is not recoverable: exiting now`),t.status=2,t.stopped=!0},refuse(e,n,r){t.warn(r),t.gap={kind:e,detail:n,message:`tar: ${r}`},t.status=2,t.stopped=!0}};return t}function Zc(e){!e.stopped&&e.status===2&&e.warn(`Exiting with failure status due to previous errors`),!e.stopped&&e.lostListing!==null&&(e.warn(e.lostListing===`pending`?`stdout: write error: Bad file descriptor`:`stdout: write error`),e.status=2);let t=t=>e.events.filter(e=>e.fd===t&&e.text!==void 0).map(e=>e.text).join(``),n={stdout:t(1),stderr:t(2),exitCode:e.status,events:e.events};return e.gap===null?n:E(n,e.gap.kind,`tar`,e.gap.detail,e.gap.message)}var Qc=32768;async function $c(e,t,n){let r=zc(t,n);if(r.usage)return{stdout:``,stderr:r.usage.text,exitCode:r.usage.status};let i=Xc(n);return r.blocking>Qc?i.refuse(`option`,`--blocking-factor`,`${r.blocking}: a record of that many blocks is more than this terminal holds`):r.mode===`create`?await _c(r,i):await el(r,i),Zc(i)}async function el(e,t){let{ctx:n}=t,r=Date.now(),i=await uc(e,t);if(!i)return;let a=Uo(e.items),o=e.mode===`extract`;e.toStdout&&(t.listTo=2);let s=e.verbose>1?Fo(n,e):null,c=new Map;for(let[l,u]of i.entries.entries()){for(let e of i.warnings[l])t.warn(e);let d=To(u),f=a.match(d);if(f===null)continue;let p=il(f,c,t);if(p===null)return;let m=o?Ec(d,e.strip):d;if(m!==null&&(e.verbose>0&&t.list(s?s(u):Ao(d,n)),o&&e.toStdout?(u.type===`file`||u.type===`contiguous-file`)&&tl(u.data,m,t):o&&Oc(u,m,Dc(p,m),t,e.keepOld,e=>nl(m,e,s,t))&&rl(i.mtimes[l],m,r,t),t.stopped))return}if(i.child)return t.fatal(`Child returned status ${i.child}`);Wo(a,t,e.noWildcards)}function tl(e,t,n){n.closedOut?e.length>0&&n.error(`${Ro(t,n.ctx)}: Cannot write: Bad file descriptor`):n.bytes(e)}function nl(e,t,n,r){if(!n)return;let i=e.split(`/`).slice(0,-1);for(let e=i.length-t;e<i.length;e++)r.list(n.mkdir(i.slice(0,e+1).join(`/`)),!1)}function rl(e,t,n,r){e>=0&&e*1e3<=n||r.refuse(`feature`,`archive times`,`${Ro(t,r.ctx)}: extracting an entry dated before 1970 or in the future is not supported`)}function il(e,t,n){if(t.has(e))return t.get(e);let r=n.ctx.cwd;for(let t of e.dirs)if(r=Go(r,t,n),r===null)return null;return t.set(e,r),r}var al=67324752,ol=33639248,sl=0x6054b50,cl=61440,ll={file:32768,directory:16384,symlink:40960},ul=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function dl(e){let t=new Uint8Array(e.reduce((e,[t])=>e+t,0)),n=ul(t),r=0;for(let[t,i]of e){if(!Number.isInteger(i)||i<0||i>=2**(8*t))throw RangeError(`${i} does not fit ${t} bytes`);t===1?n.setUint8(r,i):t===2?n.setUint16(r,i,!0):n.setUint32(r,i,!0),r+=t}return t}var fl=e=>c(e,`deflate-raw`),pl=1032;async function ml(e,t,n){if(t>e.length*pl)throw new i(`an entry declares more than its data can inflate to`,n);let r=await u(e,`deflate-raw`,new Uint8Array(t)).catch(e=>{throw new i(e.limited?`an entry inflates to more than its declared size`:`an entry does not inflate`,n)});if(r.length!==t)throw new i(`an entry inflates to less than its declared size`,n);return r}function hl(e){let t=new Date(e*1e3),n=t.getUTCFullYear();return n<1980||n>2107?null:{time:t.getUTCHours()<<11|t.getUTCMinutes()<<5|t.getUTCSeconds()>>1,date:n-1980<<9|t.getUTCMonth()+1<<5|t.getUTCDate()}}function gl(e,t,n){let r=Date.UTC(1980+(e>>9),(e>>5&15)-1,e&31,t>>11,t>>5&63,(t&31)*2)/1e3,a=hl(r);if(a===null||a.time!==t||a.date!==e)throw new i(`an entry has an invalid DOS time`,n);return r}var _l=new Set([`deflate`,`store`]),vl=788,yl=2048,bl=315532800,xl=0x7fffffff,Sl=65534,Cl=0xfffffffe;function wl(e,t,n,r){if(!Number.isSafeInteger(e)||e<n||e>r)throw new i(`${t} ${String(e)} is not an integer from ${n} to ${r}`);return e}function Tl(e,t){let n=h(e,ll),{name:r,type:i,linkname:a}=n;return{...n,mode:wl(e.mode??p[i],`mode`,0,4095),mtime:wl(e.mtime??bl,`mtime`,bl,xl),...g(r,i,a,t)}}var El=e=>dl([[2,21589],[2,5],[1,1],[4,e]]);async function Dl(e,{method:n=`deflate`,symlinksAbove:a}={}){if(!_l.has(n))throw new i(`method ${d(String(n))} is not deflate or store`);let o=new _(!0,a),s=[],c=[],l=0,u=0;for(let r of e){let e=Tl(r,o.above);if(o.add(e),++u>Sl)throw new i(`more than ${Sl} entries would need zip64`);let a=fe(m(e)),f=e.type===`symlink`?fe(e.linkname):e.data;if(f.length>Cl||l>Cl)throw new i(`${d(e.name)} would need zip64`);let p=n===`deflate`&&e.type===`file`&&f.length?await fl(f):f,h=p.length<f.length?p:f,g=h===f?0:8,{time:_,date:v}=hl(e.mtime),y=El(e.mtime),te=[[2,g===8?20:10],[2,t(a)?0:yl],[2,g],[2,_],[2,v],[4,ee(f)],[4,h.length],[4,f.length],[2,a.length],[2,y.length]];s.push(dl([[4,al],...te]),a,y,h);let ne=(ll[e.type]|e.mode)*65536+(e.type===`directory`?16:0);c.push(dl([[4,ol],[2,vl],...te,[2,0],[2,0],[2,0],[4,ne],[4,l]]),a,y),l+=30+a.length+y.length+h.length}let f=r(c);if(l+f.length>Cl)throw new i(`the archive would need zip64`);let p=dl([[4,sl],[2,0],[2,0],[2,u],[2,u],[4,f.length],[4,l],[2,0]]);return r([...s,f,p])}var Ol=0x8074b50,kl=0x7064b50,Al=1,jl=21589,Ml=28789,Nl=1,Pl=8,Fl=16;function Il(e,t=0){let n=ul(e),r=(n,r)=>{if(n<t||n+r>t+e.length)throw new i(`the archive is truncated`,n)};return{u16:e=>(r(e,2),n.getUint16(e-t,!0)),u32:e=>(r(e,4),n.getUint32(e-t,!0)),range:(n,i)=>(r(n,i),e.subarray(n-t,n-t+i))}}function Ll(e){if(e instanceof Uint8Array){let t=Il(e);return{size:e.length,read:(t,n)=>e.subarray(t,n),window:()=>t}}if(e instanceof Blob){let t=async(t,n)=>new Uint8Array(await e.slice(t,n).arrayBuffer());return{size:e.size,read:t,window:async(n,r)=>Il(await t(n,Math.min(r,e.size)),n)}}throw new i(`the archive is not a Uint8Array or a Blob`)}var Rl=65536;function zl(e){let t,n=0,r=0;return async(i,a,o=1/0)=>{let s=Math.min(i+a,e.size);return(t===void 0||i<n||s>r)&&(n=i,r=Math.max(s,Math.min(i+Rl,o,e.size)),t=await e.window(n,r)),t}}async function Bl(e){let{size:t}=e,n=await e.window(Math.max(0,t-22-65535-20),t);for(let e=t-22;e>=Math.max(0,t-22-65535);e--)if(n.u32(e)===sl&&e+22+n.u16(e+20)===t){if(e>=20&&n.u32(e-20)===kl)throw new i(`zip64 is not supported`,e-20);return{end:e,r:n}}throw new i(`no end of central directory record`)}function Vl(e,t){let n=[],r=Il(e);for(let a=0;a<e.length;){let o=r.u16(a),s=r.u16(a+2);if(a+4+s>e.length)throw new i(`an extra field runs past its room`,t);if(o===Al)throw new i(`zip64 is not supported`,t);if(o===Ml)throw new i(`an entry carries a second name in a Unicode path extra field`,t);n.push({id:o,data:e.slice(a+4,a+4+s)}),a+=4+s}return n}async function Hl(e,t){let n=await e(t,46);if(n.u32(t)!==ol)throw new i(`no central directory entry where one is counted`,t);let r=n.u16(t+28),a=n.u16(t+30);n=await e(t,46+r+a);let o={at:t,madeBy:n.u16(t+4),version:n.u16(t+6),flags:n.u16(t+8),method:n.u16(t+10),time:n.u16(t+12),date:n.u16(t+14),crc:n.u32(t+16),csize:n.u32(t+20),usize:n.u32(t+24),internal:n.u16(t+36),attributes:n.u32(t+38),offset:n.u32(t+42),name:n.range(t+46,r).slice(),next:t+46+r+a+n.u16(t+32)};if(n.u16(t+34)!==0)throw new i(`the archive spans several disks`,t);if(o.flags&Nl)throw new i(`an entry is encrypted`,t);if(o.method!==0&&o.method!==8)throw new i(`compression method ${o.method} is not stored or deflate`,t);if(o.csize===0xffffffff||o.usize===0xffffffff||o.offset===0xffffffff)throw new i(`zip64 is not supported`,t);o.mtime=gl(o.date,o.time,t),o.extra=Vl(n.range(t+46+r,a),t);let s=o.extra.find(e=>e.id===jl)?.data;if(s!==void 0&&s[0]&1){if(s.length<5)throw new i(`an extended timestamp is cut short`,t);o.mtime=ul(s).getInt32(1,!0)}return o}async function Ul(e,t){let{offset:r,boundary:a,stop:o}=t,s=await e(r,30,o);if(s.u32(r)!==al)throw new i(`no local header where the central directory points`,r);let c=s.u16(r+26),l=s.u16(r+28);if(s=await e(r,30+c+l,o),!n(s.range(r+30,c),t.name))throw new i(`the local header names a different entry`,r);for(let[e,n,a]of[[4,`version`,`a different version`],[6,`flags`,`different flags`],[8,`method`,`a different compression method`],[10,`time`,`a different time`],[12,`date`,`a different date`]])if(s.u16(r+e)!==t[n])throw new i(`the local header has ${a}`,r);Vl(s.range(r+30+c,l),r);let u=t.flags&Pl,d=(e,t)=>s.u32(r+e)===t||u&&s.u32(r+e)===0;if(!d(14,t.crc)||!d(18,t.csize)||!d(22,t.usize))throw new i(`the local header disagrees with the central directory`,r);t.dataAt=r+30+c+l;let f=t.dataAt+t.csize;if(u){let n=await e(f,16,a),r=e=>n.u32(e)===t.crc&&n.u32(e+4)===t.csize&&n.u32(e+8)===t.usize,o=n.u32(f)===Ol&&r(f+4);if(r(f)&&!(o&&f+16===a))f+=12;else if(o)f+=16;else throw new i(`the data descriptor disagrees with the central directory`,f)}return f}function Wl(e,t,n){let r=n&cl;if(t.endsWith(`/`)){if(r!==0&&r!==ll.directory)throw new i(`${d(t)} is a directory by its name but not by its mode`,e.at);return`directory`}if(r===ll.directory)throw new i(`${d(t)} is a directory by its mode but not by its name`,e.at);if(e.attributes&Fl)throw new i(`${d(t)} is a directory by its attributes but not by its name`,e.at);if(r===ll.symlink)return`symlink`;if(r===0||r===ll.file)return`file`;throw new i(`the mode of ${d(t)} (${n.toString(8)}) is not one this package reads`,e.at)}async function Gl(t,n,r){let{at:o,method:s,csize:c,usize:l}=n,u=f(n.name,`entry name`,o),m=n.madeBy>>8==3?n.attributes>>>16:0,h=Wl(n,u,m);if(h===`directory`&&l!==0)throw new i(`directory ${d(u)} has data`,o);if(s===0&&c!==l)throw new i(`a stored entry has two sizes`,o);let _=await t.read(n.dataAt,n.dataAt+c);if(_.length!==c)throw new i(`the archive is truncated`,n.dataAt);let v=s===8?await ml(_,l,o):_;if(ee(v)!==n.crc)throw new i(`the data does not match its CRC-32`,o);let y=h===`symlink`?f(v,`symlink target`,o):``,te={...a(()=>g(u,h,y,r.above),o),type:h,mode:m===0?p[h]:m&4095,mtime:n.mtime,data:h===`file`?v:e,storedName:u,system:n.madeBy>>8,version:n.version,flags:n.flags,internalAttributes:n.internal,attributes:n.attributes,extra:n.extra};return a(()=>r.add(te),o),te}async function*Kl(e,{limit:t=1/0,symlinksAbove:n,symlinkChains:r=!1}={},a=!1){if(t!==1/0&&!(Number.isSafeInteger(t)&&t>=0))throw new i(`limit ${String(t)} is not a whole number of bytes`);if(typeof r!=`boolean`)throw new i(`symlinkChains ${String(r)} is not a boolean`);if(r&&!a)throw new i(`symlinkChains is taken by unzip() alone, which answers no entry before every one is read`);let o=new _(a,n,r),{end:s,r:c}=await Bl(e),l=c.u16(s+8);if(c.u16(s+4)!==0||c.u16(s+6)!==0||l!==c.u16(s+10))throw new i(`the archive spans several disks`,s);let u=c.u32(s+12),d=c.u32(s+16);if(l===65535||u===0xffffffff||d===0xffffffff)throw new i(`zip64 is not supported`,s);if(d+u!==s)throw new i(`the central directory does not end at the end record`,s);let f=zl(e),p=[],m=d,h=0;for(let e=0;e<l;e++){let e=await Hl(f,m);if(h+=e.usize,h>t)throw new i(`the entries come to more than ${t} bytes`,m,{limited:!0});p.push(e),m=e.next}if(m!==s)throw new i(`the central directory does not hold what the end record counts`,m);let g=p.toSorted((e,t)=>e.offset-t.offset);for(let e=g.length-1;e>=0;e--){let[t,n]=[g[e],g[e+1]];t.boundary=n?.offset??d,t.stop=t.csize===0&&n?n.stop:t.boundary-t.csize}let v=zl(e),y=0;for(let e of g){if(e.offset!==y)throw new i(e.offset>y?`bytes belong to no entry`:`two entries overlap`,y);y=await Ul(v,e)}if(y!==d)throw new i(`bytes belong to no entry`,y);for(let t of p)yield await Gl(e,t,o);o.settle()}async function ql(e,t){if(!(e instanceof Uint8Array))throw new i(`the archive is not a Uint8Array`);return await Array.fromAsync(Kl(Ll(e),t,!0))}var Jl=(e,t)=>e===null?t:`${e.endsWith(`/`)?e.slice(0,-1):e}/${t}`;function Yl(e,t,n){let r=eu(t.exdir,n);if(r===null)return!1;let i=[],a=Xl(e,r,i,t,n);for(let e of i)Zl(e,n);return a}function Xl(e,t,n,r,i){let{ctx:a}=i;for(let o of e){let e=o.type===`directory`;if(r.junk&&e)continue;let s=r.junk?Pt(o.name):o.name,c=A(t,s),l=Jl(r.exdir,e?`${s}/`:s),u=Ql(c,a)?tu(M(c),a):`read-only`;if(u===`read-only`)return $l(l,i);if(u!==null)return i.refuse(`feature`,`name taken`,`${l}: extracting under a name that is not a directory is not supported`),!1;if(e){if(!nu(c,l,i))return!1;continue}if(i.quiet===0)return i.refuse(`feature`,`extraction listing`,`whether each file was stored or deflated is not known here, and an extraction that is not quiet names it (-q extracts without it)`),!1;let d=ru(c,l,r,i);if(d===null)return!1;if(d===`skip`)continue;let f=a.fs.openWritable(`/`,c);if(!f)return $l(l,i);let p=o.type===`symlink`;f.writeBytes(p?O(o.linkname):o.data),p&&n.push({path:c,shown:l,target:o.linkname})}return!0}function Zl({path:e,shown:t,target:n},r){let{fs:i}=r.ctx,a=j(`/`,e,i),o=a.path!==null&&i.isFile(a.path)?ar(i,a.path):null,s=O(n);o===null||o.length!==s.length||o.some((e,t)=>e!==s[t])?r.say(2,`warning: deferred symlink (${t}) failed:
54
+ invalid placeholder file
55
+ `):(i.removeWritable(`/`,e),i.makeWritableLink(`/`,e,n))}var Ql=(e,t)=>t.writable&&B(e);function $l(e,t){return t.refuse(`feature`,`read-only target`,`${e}: Read-only file system`),!1}function eu(e,t){let{ctx:n}=t;if(e===null)return n.cwd;let r=A(n.cwd,e),i=j(`/`,r,n.fs);if(i.path!==null&&n.fs.isDir(i.path))return i.path;if(i.path!==null)return t.refuse(`feature`,`extraction directory`,`${e}: an extraction directory that is not a directory is not supported`),null;let a=j(`/`,M(r),n.fs);return a.error===null?!Ql(r,n)||!n.fs.makeWritableDir(`/`,r)?($l(e,t),null):r:(t.say(2,`checkdir: cannot create extraction directory: ${e}
56
+ ${a.error}
57
+ `),t.status=2,null)}function tu(e,t){let n=[],r=e;for(;j(`/`,r,t.fs).path===null;r=M(r)){if(j(`/`,r,t.fs,{follow:!1}).path!==null)return`File exists`;n.push(r)}if(!t.fs.isDir(j(`/`,r,t.fs).path))return`Not a directory`;for(let e of n.toReversed())if(!B(e)||!t.fs.makeWritableDir(`/`,e))return`read-only`;return null}function nu(e,t,n){let{fs:r}=n.ctx,i=j(`/`,e,r,{follow:!1});return i.path===null?r.makeWritableDir(`/`,e)?(n.quiet===0&&n.say(1,` creating: ${t}
58
+ `),!0):$l(t,n):r.isDir(i.path)?!0:(n.refuse(`feature`,`name taken`,`${t}: a directory entry over a file already there is not supported`),!1)}function ru(e,t,n,r){let{fs:i}=r.ctx,a=j(`/`,e,i,{follow:!1});return a.path===null?`write`:i.isDir(a.path)?(r.refuse(`feature`,`name taken`,`${t}: a file entry over a directory already there is not supported`),null):(n.overwrite===null&&iu(t,n,r),n.overwrite===`none`?`skip`:(n.overwrite===`all`&&i.removeWritable(`/`,e),n.overwrite===`all`?`write`:null))}function iu(e,t,n){let{ctx:r}=n;r.stdinLeft!==``||r.stdinBytes!==null?n.refuse(`feature`,`overwrite prompt`,`answering the overwrite question from stdin is not supported (-o and -n answer it)`):(n.say(2,`replace ${e}? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL
59
+ (EOF or read error, treating as "[N]one" ...)
60
+ `),t.overwrite=`none`,n.status=1)}var au={__proto__:null,l:`list`,t:`test`,p:`pipe`,c:`crt`,v:`verbose`},ou={usage:{text:`error: must specify directory to which to extract with -d option
61
+ `,status:10}};function su(e){let t={modes:new Set,lists:0,quiet:0,overwriteAll:!1,overwriteNone:!1,junk:!1,exdir:null,archive:null,members:[],excludes:[]},n=0;for(;n<e.length&&e[n].startsWith(`-`)&&e[n].length>1;n++){let r=e[n];for(let i=1;i<r.length;i++){let a=r[i];if(a===`d`){if(t.exdir=i+1<r.length?r.slice(i+1):e[++n],t.exdir===void 0)return ou;break}if(a===`l`&&t.lists++,au[a])t.modes.add(au[a]);else if(a===`q`)t.quiet++;else if(a===`o`)t.overwriteAll=!0;else if(a===`n`)t.overwriteNone=!0;else if(a===`j`)t.junk=!0;else throw new D(`option`,`-${a}`,`unknown option: -${a}`)}}if(t.modes.size>1)throw new D(`option`,`modes`,`combining -c, -l, -p, -t and -v is not supported`);if(n>=e.length)throw new D(`feature`,`usage`,`printing the usage summary is not supported`);t.archive=e[n++];let r=!1;for(;n<e.length;n++){let i=e[n];if(i===`-x`)r=!0;else if(i.startsWith(`-d`)){if(t.exdir=i.length>2?i.slice(2):e[++n],t.exdir===void 0)return ou}else(r?t.excludes:t.members).push(i)}let[i=`extract`]=t.modes,a=i===`list`&&t.lists>1?`verbose`:i,o=t.overwriteNone?`none`:t.overwriteAll?`all`:null;return{...t,mode:a,overwrite:o,bothOverwrites:t.overwriteAll&&t.overwriteNone}}function cu(e,t,n,r){if(t>=e.length)return+(r>=n.length);let i=e[t++];if(i===63)return r<n.length?cu(e,t,n,r+1):0;if(i===42){if(t>=e.length)return 1;for(;r<n.length;r++){let i=cu(e,t,n,r);if(i!==0)return i}return 2}if(i===91)return lu(e,t,n,r);if(i===92){if(t>=e.length)return 0;i=e[t++]}return r<n.length&&n[r]===i?cu(e,t,n,r+1):0}function lu(e,t,n,r){if(r>=n.length)return 0;let i=e[t]===33||e[t]===94,a=t+ +!!i,o=a;for(let t=!1;o<e.length;o++)if(t)t=!1;else if(e[o]===92)t=!0;else if(e[o]===93)break;if(o>=e.length)return 0;let s=0,c=e[a]===45;for(;a<o;a++)if(!c&&e[a]===92)c=!0;else if(!c&&e[a]===45)s=e[a-1];else{if(e[a+1]!==45&&n[r]>=(s||e[a])&&n[r]<=e[a])return i?0:cu(e,o+1,n,r+1);s=0,c=!1}return i?cu(e,o+1,n,r+1):0}var uu=(e,t)=>cu(e,0,t,0)===1,du=` End-of-central-directory signature not found. Either this file is not
62
+ a zipfile, or it constitutes one disk of a multi-part archive. In the
63
+ latter case the central directory and zipfile comment will be found on
64
+ the last disk(s) of this archive.
65
+ `;async function fu(e,t,n){let r=su(t);if(r.usage)return{stdout:``,stderr:r.usage.text,exitCode:r.usage.status};let a=Su(n,r);if(r.bothOverwrites&&a.say(2,`caution: both -n and -o specified; ignoring -o
66
+ `),r.exdir!==null&&r.mode!==`extract`&&a.say(2,`caution: not extracting; -d ignored
67
+ `),r.mode===`crt`||r.mode===`verbose`){let e=r.mode===`crt`?`-c`:r.lists>1?`-ll`:`-v`;return a.refuse(`option`,e,`how each entry is stored is not known here, which this listing prints`)}let o=pu(r.archive,n);if(!o)return a.say(2,`unzip: cannot find or open ${r.archive}, ${r.archive}.zip or ${r.archive}.ZIP.
68
+ `),a.end(9);let s=ar(n.fs,o.path),c;try{c=await ql(s)}catch(e){if(!(e instanceof i))throw e;return mu(s)?a.refuse(`feature`,`archive`,`this archive is not one this terminal reads: ${e.message}`):(a.heading(o.name,!0),a.say(2,du),r.mode!==`pipe`&&a.say(2,`unzip: cannot find zipfile directory in one of ${r.archive} or
69
+ ${r.archive}.zip, and cannot find ${r.archive}.ZIP, period.
70
+ `),a.end(9))}let l=c.map(Do).find(e=>e!==null);if(l!==void 0){let[e,t]=Eo(l);return a.refuse(`feature`,e,`${l}: ${t}`)}if(c.length===0)return a.heading(o.name,!1),a.say(2,`warning [${o.name}]: zipfile is empty
71
+ `),a.end(1);let u=gu(c,r);if(r.mode===`list`)return xu(u,o.name,a);if(a.heading(o.name,!1),r.mode===`test`)yu(u,o.name,a);else if(r.mode===`pipe`)for(let e of u.entries)a.bytes(e.type===`symlink`?O(e.linkname):e.data);else if(!Yl(u.entries,r,a))return a.end(a.gap?1:a.status);return _u(u,a),r.mode===`test`&&bu(u,o.name,a),a.end(u.missed?11:a.status)}function pu(e,t){for(let n of[e,`${e}.zip`,`${e}.ZIP`]){let r=F(n===e?t:{...t,notes:null},`unzip`,n);if(!r.error&&!t.fs.isDir(r.path))return{name:n,path:r.path}}return null}function mu(e){for(let t=e.length-4;t>=Math.max(0,e.length-22-65535);t--)if(e[t]===80&&e[t+1]===75&&e[t+2]===5&&e[t+3]===6)return!0;return!1}var hu=e=>O(e);function gu(e,t){let n=t.members.map(e=>({text:e,pattern:hu(e),hit:!1})),r=t.excludes.map(e=>({text:e,pattern:hu(e),hit:!1})),i=(e,t)=>{let n=!1;for(let r of e)uu(r.pattern,t)&&(r.hit=!0,n=!0);return n};return{entries:e.filter(e=>{let t=hu(To(e)),a=n.length===0||i(n,t);return!i(r,t)&&a}),include:n,exclude:r,all:n.length===0&&r.length===0,missed:n.some(e=>!e.hit)}}function _u(e,t){for(let n of e.include)n.hit||t.say(2,`caution: filename not matched: ${n.text}
72
+ `);for(let n of e.exclude)n.hit||t.say(2,`caution: excluded filename not matched: ${n.text}
73
+ `)}var vu=(e,t)=>e+` `.repeat(Math.max(0,t-hu(e).length));function yu(e,t,n){if(n.quiet===0)for(let t of e.entries)n.say(1,` testing: ${vu(To(t),22)} OK
74
+ `)}function bu(e,t,n){n.quiet>1||(e.missed?n.say(1,`At least one error was detected in ${t}.
75
+ `):e.all?n.say(1,`No errors detected in compressed data of ${t}.
76
+ `):n.say(1,`No errors detected in ${t} for the ${e.entries.length} file${e.entries.length===1?``:`s`} tested.
77
+ `))}function xu(e,t,n){let{ctx:r}=n,i=r.vars.has(`TZ`),a=e=>Wv(new Date(e.mtime*1e3),`%Y-%m-%d %H:%M`,i);if(!i&&e.entries.some(e=>a(e)!==Wv(new Date(e.mtime*1e3),`%Y-%m-%d %H:%M`,!0)))return n.refuse(`feature`,`archive times`,`whether an entry's time is exact or a DOS time is not known here, and outside UTC the two are listed differently (TZ=UTC answers it)`);let o=e=>e.type===`symlink`?hu(e.linkname).length:e.data.length;n.heading(t,!1),n.quiet<2&&n.say(1,` Length Date Time Name
78
+ --------- ---------- ----- ----
79
+ `);let s=0;for(let t of e.entries)s+=o(t),n.say(1,`${String(o(t)).padStart(9)} ${a(t)} ${To(t)}
80
+ `);let c=e.entries.length;return n.quiet<2&&n.say(1,`--------- -------
81
+ ${String(s).padStart(9)} ${c} file${c===1?``:`s`}
82
+ `),n.end(c===0&&e.include.length>0?11:0)}function Su(e,t){let n=t.mode===`test`,r={ctx:e,events:[],status:0,gap:null,quiet:t.mode===`pipe`?Math.max(t.quiet,1):t.quiet,say(e,t){r.events.push({fd:n?1:e,text:t})},bytes(e){r.events.push({fd:1,bytes:e})},heading(e,t){r.quiet===0?r.say(1,`Archive: ${e}
83
+ `):t&&r.say(2,`[${e}]
84
+ `)},refuse(e,t,n){return r.say(2,`unzip: ${n}
85
+ `),r.gap={kind:e,detail:t,message:`unzip: ${n}`},r.end(1)},end(e=r.status){let t=e=>r.events.filter(t=>t.fd===e&&t.text!==void 0).map(e=>e.text).join(``),n={stdout:t(1),stderr:t(2),exitCode:e,events:r.events};return r.gap?E(n,r.gap.kind,`unzip`,r.gap.detail,r.gap.message):n}};return r}var Cu={file:384,directory:448,symlink:511},wu={__proto__:null,r:`recurse`,q:`quiet`,j:`junk`,0:`store`,y:`symlinks`,D:`noDirectories`};function Tu(e){let t={recurse:!1,quiet:!1,junk:!1,store:!1,symlinks:!1,noDirectories:!1,archive:null,names:[]};for(let n of e){if(n.startsWith(`--`))throw new D(`option`,n.split(`=`)[0],`unknown option: ${n.split(`=`)[0]}`);if(n.startsWith(`-`)&&n.length>1)for(let e of n.slice(1)){if(!wu[e])throw new D(`option`,`-${e}`,`unknown option: -${e}`);t[wu[e]]=!0}else t.archive===null?t.archive=n:t.names.push(n)}return t}async function Eu(e,t,n){let r=Tu(t);if(r.archive===null||r.archive===`-`){if(t.length>0&&tr(n))return{stdout:``,stderr:`
86
+ zip error: Invalid command arguments (cannot write zip file to terminal)
87
+ `,exitCode:16};throw new D(`feature`,`streamed archive`,`writing an archive to stdout is not supported`)}let a={events:[],status:0},o=e=>a.events.push({fd:1,text:e}),s=Pt(r.archive).includes(`.`)?r.archive:`${r.archive}.zip`;if(j(n.cwd,s,n.fs,{follow:!1}).path!==null)return Ru(a,`feature`,`existing archive`,`${s}: adding to an archive that is already there is not supported`);let c={ctx:n,opts:r,entries:[],seen:new Set,out:o,gap:null};for(let e of r.names){if(e===`-`)return Ru(a,`feature`,`stdin input`,"adding what stdin holds, as the entry `-`, is not supported");if(Pu(e,c),c.gap)return Ru(a,...c.gap)}if(c.entries.length===0)return o(`
88
+ zip error: Nothing to do! (${s})
89
+ `),zu(a,12);let l=Iu(c);if(l)return o(l),zu(a,16);let u=r.store?new Map:await Au(c.entries.filter(e=>e.type===`file`)),d=[...u.keys()].filter(ku);if(d.length>0&&d.length<u.size)return Ru(a,`feature`,`stored suffix`,`${d[0].name}: storing a file as Info-ZIP stores one by its suffix, beside files it deflates, is not supported`);for(let e of d)u.delete(e);let f=c.entries.map(e=>ju(e,u.get(e))),p;try{p=await Dl(c.entries,{method:u.size>0?`deflate`:`store`})}catch(e){if(!(e instanceof i))throw e;return Ru(a,`feature`,`archive`,`this archive cannot be written here: ${e.message}`)}let m=A(n.cwd,s),h=n.writable&&B(m)?Du(n,s):null;if(h===null)return Ru(a,`feature`,`read-only target`,`${s}: Read-only file system`);if(h.error)return o(`zip I/O error: ${h.error}
90
+ zip error: Could not create output file (${s})
91
+ `),zu(a,15);if(!r.quiet)for(let e of f)o(e);return h.writeBytes(p),zu(a,0)}function Du(e,t){try{return e.fs.openWritable(e.cwd,t)}catch(e){return{error:e.fsError??`No such file or directory`}}}var Ou=[`.Z`,`.zip`,`.zoo`,`.arc`,`.lzh`,`.arj`],ku=e=>Ou.some(t=>e.name.endsWith(t));async function Au(e){let t=await Promise.all(e.map(async e=>e.data.length===0?0:(await c(e.data,`deflate-raw`)).length));return new Map(e.flatMap((e,n)=>t[n]<e.data.length?[[e,t[n]]]:[]))}function ju(e,t){let n=e.type===`directory`?`${e.name}/`:e.name;return t===void 0?` adding: ${n} (stored 0%)
92
+ `:` adding: ${n} (deflated ${Mu(e.data.length,t)}%)
93
+ `}function Mu(e,t){let[n,r]=[e,t];return n>0xffffff&&(n=Math.floor((n+128)/256),r=Math.floor((r+128)/256)),n>r?Math.floor((1+Math.floor(200*(n-r)/n))/2):0}function Nu(e,t){if(t.junk)return Pt(e);let n=e.replace(/^\/+/u,``);for(;n.startsWith(`./`);)n=n.slice(2);return n===`.`?``:n}function Pu(e,t){let{ctx:n,opts:r}=t,i=j(n.cwd,e,n.fs,{follow:!r.symlinks});if(i.error){t.out(` zip warning: name not matched: ${e}
94
+ `);return}let a=e.length>1?e.replace(/\/+$/u,``):e,o=Nu(a,r);Fu(i.path,o,!r.junk&&o===``?``:a,t)}function Fu(e,t,n,r){let{ctx:i,opts:a}=r,{fs:o}=i,s=a.symlinks&&o.isLink?.(e)===!0,c=!s&&o.isDir(e);if(t!==``&&t.split(`/`).some(e=>e===`.`||e===`..`||e===``))return Lu(r,`dot-segment names`,`${t}: names with \`.', \`..' or empty segments are not supported`);let l=s?`symlink`:c?`directory`:`file`;if(t===``||c&&(a.junk||a.noDirectories)||r.entries.push({name:t,full:c?`${n}/`:n,type:l,mode:Cu[l],mtime:Math.floor(i.createdAt/1e3),linkname:s?o.readLink(e):``,data:l===`file`?ar(o,e):void 0}),!c||!a.recurse)return;if(r.seen.has(e))return Lu(r,`link loop`,`${t}: a directory inside itself through a link is not supported`);r.seen.add(e);let{dirs:u,files:d,links:f=[]}=o.listDir(e);for(let i of[...new Set([...u,...d,...f])].sort(N)){let s=j(`/`,Ft(e,i),o,{follow:!a.symlinks});if(s.error?r.out(` zip warning: name not matched: ${t}/${i}
95
+ `):Fu(s.path,a.junk||t===``?i:`${t}/${i}`,n===``?i:`${n}/${i}`,r),r.gap)break}r.seen.delete(e)}function Iu(e){let t=e.entries.toSorted((e,t)=>N(e.name,t.name)||N(e.full,t.full)),n=[];for(let r of t){let t=n.at(-1);if(t?.name!==r.name)n.push(r);else if(t.full!==r.full){let n=r.type===`directory`?`${r.name}/`:r.name,i=e.opts.junk?` this may be a result of using -j
96
+ `:``;return` zip warning: first full name: ${t.full}
97
+ second full name: ${r.full}
98
+ name in zip file repeated: ${n}
99
+ ${i}
100
+ zip error: Invalid command arguments (cannot repeat names in zip file)
101
+ `}}let r=new Set(n);return e.entries=e.entries.filter(e=>r.has(e)),null}function Lu(e,t,n){e.gap??=[`feature`,t,n]}function Ru(e,t,n,r){return e.events.push({fd:2,text:`zip: ${r}
102
+ `}),E(zu(e,1),t,`zip`,n,`zip: ${r}`)}function zu(e,t){let n=t=>e.events.filter(e=>e.fd===t).map(e=>e.text).join(``);return{stdout:n(1),stderr:n(2),exitCode:t,events:e.events}}var Bu={tar:$c,...s(`deflate-raw`)?{zip:Eu,unzip:fu}:{}},Vu=`brotli`,Hu=`.br`,Uu=s(Vu)?{brotli:qu}:{},Wu=`con`,Gu=Object.freeze([`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]),Ku=`Usage: brotli [OPTION]... [FILE]...
103
+ `;async function qu(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[...Gu,`d`,`c`,`k`,`j`,`f`,`Z`],long:[`decompress`,`stdout`,`keep`,`rm`,`force`,`best`],valueShort:[`q`],valueLong:[`quality`]}),o=Ju(r,i);if(o!==void 0)return T(`option`,`brotli`,o,`brotli: ${o}: choosing a compression level is not supported`,1);let s={decompressing:r.has(`d`)||r.has(`decompress`),stdout:r.has(`c`)||r.has(`stdout`),remove:r.has(`j`)||r.has(`rm`),force:r.has(`f`)||r.has(`force`)};if(s.stdout&&a.length>1)return{stdout:Ku,stderr:``,exitCode:1};let c={ctx:n,events:[],stderr:``,status:0,gap:null};for(let t of a.length===0?[`-`]:a)if(!await Yu(t,e,s,c))break;if(c.gap)return c.gap;let l=[...c.events,...c.stderr?[{fd:2,text:c.stderr}]:[]];return{stdout:``,stderr:c.stderr,exitCode:c.status,events:l}}function Ju(e,t){let n=[...Gu,`Z`].find(t=>e.has(t));return n===void 0?e.has(`best`)?`--best`:t.has(`q`)?`-q`:t.has(`quality`)?`--quality`:void 0:`-`+n}function Yu(e,t,n,r){let{ctx:i}=r;if(e===`-`){if(!n.force&&(n.decompressing?er(i):tr(i)))return Qu(r,`Use -h help. Use -f to force ${n.decompressing?`input from`:`output to`} a terminal.`);let e=i.stdinBytes,t=i.stdinLeft;return L(i,``,!0),Xu(e??O(t),Wu,null,n,r)}let a=null;if(!n.stdout){if(!n.decompressing)a=e+Hu;else{if(e.length<=Hu.length)return Qu(r,`empty output file name for [${e}] input file`);if(e.endsWith(Hu))a=e.slice(0,-Hu.length);else return Qu(r,`input file [${e}] suffix mismatch`)}}let o=F(i,`brotli`,e);return o.error?Qu(r,`failed to open input file [${e}]: ${o.error}`):a!==null&&!n.force&&F(i,`brotli`,a).error===null?Qu(r,`failed to open output file [${a}]: File exists`):a===null&&!n.decompressing&&!n.force&&tr(i)?Qu(r,`Use -h help. Use -f to force output to a terminal.`):i.fs.isDir(o.path)?Qu(r,`failed to read input [${e}]: Is a directory`):Xu(ar(i.fs,o.path),e,a,n,r)}async function Xu(e,t,n,r,i){let{ctx:a}=i,o=r.decompressing?await Ko(e,Vu):{bytes:await c(e,Vu),error:null};if(o.error)return Qu(i,`corrupt input [${t}]`);if(n===null)i.events.push({fd:1,bytes:o.bytes});else if(!Zu(n,o.bytes,i))return!1;return r.remove&&t!==Wu&&a.fs.removeWritable(a.cwd,t),!0}function Zu(e,t,n){let{ctx:r}=n,i;try{i=r.writable&&r.fs.openWritable?.(r.cwd,e)}catch(t){return Qu(n,`failed to open output file [${e}]: ${t.message}`)}return i?(i.writeBytes(t),!0):(n.gap??=T(`feature`,`brotli`,`read-only target`,`brotli: ${e}: file system is read-only`,1),!1)}function Qu(e,t){return e.stderr+=`${t}
104
+ `,e.status=1,!1}var $u=Object.freeze({__proto__:null,1:`SHA-1`,256:`SHA-256`,384:`SHA-384`,512:`SHA-512`}),ed=Object.freeze([`1`,`224`,`256`,`384`,`512`,`512224`,`512256`]),td=()=>{try{return typeof crypto?.subtle?.digest==`function`}catch{return!1}};async function nd(e,t){let n=new Uint8Array(await crypto.subtle.digest(e,t));return Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``)}function rd(e,t,n){let r=e===`shasum`?n.get(`a`)??`1`:String(t);if(e===`shasum`&&!ed.includes(r))return{error:C(`${e}: Unrecognized algorithm
105
+ Type shasum -h for help
106
+ `,1)};let i=$u[r];return i===void 0?{error:T(`feature`,e,`SHA-${r}`,`${e}: this runtime's crypto does not digest SHA-${r}`,1)}:{algorithm:i}}function id(e,t){return async(n,r,i)=>{let{flags:a,order:o,positional:s,values:c}=U(r,{short:e===`shasum`?[`b`,`t`,`c`]:[`b`,`t`,`c`,`z`],long:e===`shasum`?[`binary`,`text`,`check`,`tag`]:[`binary`,`text`,`check`,`tag`,`zero`],valueShort:e===`shasum`?[`a`]:[]});if(a.has(`c`)||a.has(`check`))return T(`feature`,e,`-c`,`${e}: reading a list of digests back is not supported`,1);let{algorithm:l,error:u}=rd(e,t,c);if(u)return u;let{mode:d,error:f}=cd(e,a,o);if(f)return f;let p=sr(e,s,n,i,{read:`bytes`}),m=await Promise.all(p.inputs.map(e=>nd(l,e.bytes))),h=ld(l,a,d);return R(p.inputs.map((e,t)=>h(m[t],e.name??`-`)).join(``),p)}}var ad=new Set([`b`,`binary`]),od=new Set([`t`,`text`]);function sd(e,t){let n=!1,r=null,i=!1;for(let{name:e}of t)ad.has(e)?(n=!0,r=`binary`):od.has(e)?(i=!0,r=`text`):e===`tag`&&(r=`binary`);return e===`shasum`?{binary:n,text:i&&!n,ambiguous:n&&i}:{binary:r===`binary`,text:r===`text`,ambiguous:!1}}function cd(e,t,n){let r=sd(e,n),i=e===`shasum`?`Type ${e} -h for help
107
+ `:`Try '${e} --help' for more information.
108
+ `;return r.ambiguous?{error:C(`${e}: Ambiguous file mode
109
+ ${i}`,1)}:t.has(`tag`)&&r.text?{error:C(`${e}: --tag does not support --text mode
110
+ ${i}`,1)}:{mode:r}}function ld(e,t,n){let r=t.has(`z`)||t.has(`zero`)?`\0`:`
111
+ `;if(t.has(`tag`)){let t=e.replace(`-`,``);return(e,n)=>`${t} (${n}) = ${e}${r}`}return(e,t)=>`${e}${n.binary?` *`:` `}${t}${r}`}var ud=td()?{sha1sum:id(`sha1sum`,1),sha256sum:id(`sha256sum`,256),sha384sum:id(`sha384sum`,384),sha512sum:id(`sha512sum`,512),shasum:id(`shasum`,1)}:{},dd=()=>typeof fetch==`function`;function fd(e){if(e.network!==void 0&&typeof e.network!=`boolean`)throw TypeError(`createTerminal: network must be true or false (got ${e.network===null?`null`:typeof e.network})`);return e.network===!0}var pd=Object.freeze([`http:`,`https:`]),md=/^[a-zA-Z][a-zA-Z0-9+.-]*:/u;function hd(e){let t=md.test(e)?e:`http://`+e,n;try{n=new URL(t)}catch{return{malformed:!0}}return pd.includes(n.protocol)?n.hostname===``?{malformed:!0}:{url:n}:{protocol:n.protocol.slice(0,-1)}}var gd=new Set([`ENOTFOUND`,`EAI_AGAIN`]),_d=new Set([`ETIMEDOUT`,`UND_ERR_CONNECT_TIMEOUT`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`]),vd=new Set([`ECONNRESET`,`ECONNABORTED`,`EPIPE`]),yd=new Set([`CERT_HAS_EXPIRED`,`CERT_NOT_YET_VALID`,`DEPTH_ZERO_SELF_SIGNED_CERT`,`SELF_SIGNED_CERT_IN_CHAIN`,`UNABLE_TO_GET_ISSUER_CERT_LOCALLY`,`UNABLE_TO_VERIFY_LEAF_SIGNATURE`,`ERR_TLS_CERT_ALTNAME_INVALID`]),bd=new Set([`TimeoutError`,`AbortError`]);function xd(e,t,n){let r=Cd(e),i=wd(e),a=`Failed to connect to ${t.hostname} port ${Sd(t)}`;return bd.has(e?.name)||_d.has(r)?{code:28,message:n===null?`Operation timed out: ${i}`:`Operation timed out after ${n} milliseconds`}:gd.has(r)?{code:6,message:`Could not resolve host: ${t.hostname}`}:yd.has(r)?{code:60,message:`SSL certificate problem: ${i}`}:vd.has(r)?{code:56,message:`Recv failure: ${i}`}:{code:7,message:`${a}: ${i}`}}var Sd=e=>e.port===``?e.protocol===`https:`?443:80:e.port;function Cd(e){for(let t=e,n=0;t!=null&&n<8;t=t.cause,n++)if(typeof t.code==`string`)return t.code;return null}function wd(e){let t=typeof e?.message==`string`&&e.message!==``?e.message:`transfer failed`;for(let n=e?.cause,r=0;n!=null&&r<8;n=n.cause,r++)typeof n.message==`string`&&n.message!==``&&(t=n.message);return t}async function Td(e,t,n=null){try{return{response:await fetch(e.href,t)}}catch(t){return{failed:xd(t,e,n)}}}async function Ed(e,t,n=null){try{return{bytes:new Uint8Array(await e.arrayBuffer())}}catch(e){let{code:r,message:i}=xd(e,t,n);return{failed:r===7?{code:56,message:`Recv failure: ${wd(e)}`}:{code:r,message:i}}}}async function Dd(e){try{await e.body?.cancel()}catch{}}var Od={short:[`h`,`s`,`S`,`i`,`I`,`L`,`f`,`O`,`k`,`v`,`G`,`n`],long:[`help`,`silent`,`show-error`,`no-progress-meter`,`include`,`head`,`location`,`location-trusted`,`fail`,`remote-name`,`compressed`,`insecure`,`verbose`,`get`,`netrc`],valueShort:[`X`,`A`,`m`,`u`,`e`,`b`,`c`,`w`,`x`,`T`,`r`,`C`,`E`,`D`,`F`],valueLong:[`request`,`user-agent`,`max-time`,`user`,`max-redirs`,`referer`,`cookie`,`cookie-jar`,`write-out`,`proxy`,`proxy-user`,`upload-file`,`range`,`continue-at`,`cert`,`key`,`cacert`,`capath`,`dump-header`,`connect-timeout`,`retry`,`limit-rate`,`resolve`,`interface`,`form`],repeatable:[`H`,`header`,`d`,`data`,`data-raw`,`data-ascii`,`data-binary`,`json`,`o`,`output`]},kd=new Map([[`k`,`certificates are the runtime's to check, and nothing here can tell it not to`],[`insecure`,`certificates are the runtime's to check, and nothing here can tell it not to`],[`v`,"the trace is of a connection this code never sees; `-i` prints the response headers"],[`verbose`,"the trace is of a connection this code never sees; `-i` prints the response headers"],[`location-trusted`,"a credential is for the origin it was given for; `-L` follows the hop without it"],[`G`,`moving the data into the query string is not implemented; put it in the URL`],[`get`,`moving the data into the query string is not implemented; put it in the URL`],[`n`,"there is no home directory here to read a `.netrc` from"],[`netrc`,"there is no home directory here to read a `.netrc` from"],[`b`,'there is no cookie jar here; a cookie to send is `-H "Cookie: …"`'],[`cookie`,'there is no cookie jar here; a cookie to send is `-H "Cookie: …"`'],[`c`,`there is no cookie jar here to write`],[`cookie-jar`,`there is no cookie jar here to write`],[`w`,`the transfer keeps no measurements of its own to write out`],[`write-out`,`the transfer keeps no measurements of its own to write out`],[`x`,`a proxy is the runtime's own setting, and nothing here passes it one`],[`proxy`,`a proxy is the runtime's own setting, and nothing here passes it one`],[`proxy-user`,`a proxy is the runtime's own setting, and nothing here passes it one`],[`F`,"a multipart body is not implemented; `--data-binary` sends one you spell out yourself"],[`form`,"a multipart body is not implemented; `--data-binary` sends one you spell out yourself"],[`T`,"uploading a file is not implemented; `-X PUT --data-binary @file` sends the same bytes"],[`upload-file`,"uploading a file is not implemented; `-X PUT --data-binary @file` sends the same bytes"],[`r`,'a ranged request is `-H "Range: bytes=…"`'],[`range`,'a ranged request is `-H "Range: bytes=…"`'],[`C`,`there is nothing to resume: a transfer here is one request and its answer`],[`continue-at`,`there is nothing to resume: a transfer here is one request and its answer`],[`E`,`client certificates are the runtime's own`],[`cert`,`client certificates are the runtime's own`],[`key`,`client certificates are the runtime's own`],[`cacert`,`the trust store is the runtime's own`],[`capath`,`the trust store is the runtime's own`],[`e`,'a referer is `-H "Referer: …"`'],[`referer`,'a referer is `-H "Referer: …"`'],[`D`,"writing the headers to a file of their own is not implemented; `-i` writes them in front of the body"],[`dump-header`,"writing the headers to a file of their own is not implemented; `-i` writes them in front of the body"],[`connect-timeout`,"only the whole transfer can be timed here, which is `--max-time`"],[`retry`,`retrying is not implemented: a transfer here is one request and its answer`],[`limit-rate`,`the runtime reads the response at its own pace`],[`resolve`,`name resolution is the runtime's own`],[`interface`,`the interface a request leaves by is the runtime's own`]]),Ad=new Map([[`d`,`text`],[`data`,`text`],[`data-ascii`,`text`],[`data-raw`,`raw`],[`data-binary`,`binary`],[`json`,`json`]]),jd=new Set([`H`,`header`]),Md=new Set([`o`,`output`]),Nd=new Set([`O`,`remote-name`]),Pd=`application/x-www-form-urlencoded`,Fd=`application/json`,Id=50,Ld=new Set([10,13]);function Rd(e,t,n){let{flags:r,values:i,positional:a,order:o}=U(e,Od);if(r.has(`h`)||r.has(`help`))return{help:!0};let s=zd(r,i);return s?{refusal:s}:{opts:Bd(r,i,o,t,n),urls:a,targets:Xd(o)}}function zd(e,t){for(let[n,r]of kd){if(!e.has(n)&&!t.has(n))continue;let i=(n.length===1?`-`:`--`)+n;return T(`option`,`curl`,i,`curl: ${i}: ${r}`,2)}return null}function Bd(e,t,n,r,i){i.quiet=(e.has(`s`)||e.has(`silent`))&&!e.has(`S`)&&!e.has(`show-error`);let a=Hd(n,r,i);if(a===null)return null;let o=Kd(t,n,a,i);if(o===null)return null;let s=Vd(t.get(`max-redirs`),`--max-redirs`,i),c=Vd(t.get(`m`)??t.get(`max-time`),`--max-time`,i);if(s===null||c===null)return null;if(c!==void 0&&typeof AbortSignal?.timeout!=`function`)return Qd(i,`feature`,`--max-time`,2,`this runtime cannot put a deadline on a request`);let l=e.has(`I`)||e.has(`head`);return{headers:o,body:a.bytes,head:l,include:e.has(`i`)||e.has(`include`),location:e.has(`L`)||e.has(`location`),failEarly:e.has(`f`)||e.has(`fail`),method:t.get(`X`)??t.get(`request`)??(l?`HEAD`:a.bytes===null?`GET`:`POST`),redirects:s===void 0?Id:s<0?1/0:s,timeout:c===void 0?null:Math.round(c*1e3)}}function Vd(e,t,n){if(e===void 0)return;let r=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/u.test(e.trim())?Number(e.trim()):NaN;return Number.isFinite(r)?r:(n.stderr+=`curl: option ${t}: expected a proper numerical parameter
112
+ `,n.status=2,null)}function Hd(e,t,n){let r=[],i=new Set;for(let{name:a,value:o}of e){let e=Ad.get(a);if(e===void 0)continue;let s=Ud(e,o,t,n);if(s===null)return null;i.add(e===`json`?`json`:`form`),r.push(s)}if(r.length===0)return{bytes:null,json:!1};if(i.size>1)return n.stderr+=`curl: --json cannot be mixed with --data
113
+ `,n.status=2,null;let a=i.has(`json`),o=[];for(let[e,t]of r.entries())e>0&&!a&&o.push(O(`&`)),o.push(t);return{bytes:Dt([...o,new Uint8Array]),json:a}}function Ud(e,t,n,r){if(e===`raw`||!t.startsWith(`@`))return O(t);let i=t.slice(1),a=i===`-`?Wd(n,r.ctx):Gd(i,r);return a===null?null:e===`text`?a.filter(e=>!Ld.has(e)):a}function Wd(e,t){let n=t.stdinBytes,r=t.stdinLeft===``?e:t.stdinLeft;return L(t,``,!0),n??O(r)}function Gd(e,t){let{ctx:n}=t,r=F(n,`curl`,e);return r.error||n.fs.isDir(r.path)?(Zd(t,26,`Failed to open/read local data from file/application`),null):ar(n.fs,r.path)}function Kd(e,t,n,r){let i=new Headers;n.bytes!==null&&i.set(`content-type`,n.json?Fd:Pd),n.json&&i.set(`accept`,Fd);let a=e.get(`A`)??e.get(`user-agent`);a!==void 0&&i.set(`user-agent`,a);let o=e.get(`u`)??e.get(`user`);if(o!==void 0){if(!o.includes(`:`))return Qd(r,`feature`,`-u`,2,`there is no interactive input here to read a password from`);i.set(`authorization`,`Basic ${ie(O(o))}`)}for(let{name:e,value:n}of t)if(jd.has(e)&&!qd(i,n,r))return null;return i}function qd(e,t,n){let r=t.indexOf(`:`);if(r===-1)return t.endsWith(`;`)?Jd(e,t.slice(0,-1),``,n):Yd(n,t);let i=t.slice(r+1).trim();return i===``?(Qd(n,`option`,`-H`,2,`-H "${t}": taking away a header the runtime sends is not supported`),!1):Jd(e,t.slice(0,r),i,n)}function Jd(e,t,n,r){try{e.set(t.trim(),n)}catch{return Yd(r,t.trim())}return!0}function Yd(e,t){return e.stderr+=`curl: -H: not a header: ${t}
114
+ `,e.status=2,!1}function Xd(e){let t=[];for(let{name:n,value:r}of e)Md.has(n)?t.push(r===`-`?null:{file:r}):Nd.has(n)&&t.push({remote:!0});return t}function Zd(e,t,n){return e.quiet||(e.stderr+=`curl: (${t}) ${n}
115
+ `),e.status=t,!1}function Qd(e,t,n,r,i){return e.gap??={kind:t,detail:n,message:`curl: (${r}) ${i}`},Zd(e,r,i),null}var $d=new Set([301,302,303,307,308]),ef=new Set([301,302,303]);async function tf(e,t,n){let r={ctx:n,events:[],stderr:``,status:0,gap:null,quiet:!1},{help:i,refusal:a,opts:o,urls:s,targets:c}=Rd(t,e,r);if(i)return{stdout:rf,stderr:``,exitCode:0};if(a)return a;if(o===null)return af(r);if(s.length===0)return nf();for(let[e,t]of s.entries())await of(t,c[e]??null,o,r);return af(r)}var nf=()=>({stdout:``,stderr:`curl: try 'curl --help' for more information
116
+ `,exitCode:2}),rf=`Usage: curl [options...] <url>
117
+ -d, --data <data> send data in a POST body; @file reads a file, @- the pipe
118
+ --data-raw <data> the same, taking a leading @ as data rather than a name
119
+ --data-binary <data> the same, keeping a file's line endings
120
+ --json <data> send data as JSON, and ask for JSON back
121
+ -f, --fail write no body, and exit 22, on a failing status
122
+ -H, --header <header> send a header: "Name: value", or "Name;" to send it empty
123
+ -A, --user-agent <name> send a user agent
124
+ -u, --user <user:pass> send basic authentication
125
+ -i, --include write the response headers in front of the body
126
+ -I, --head ask for the headers alone
127
+ -L, --location follow a redirect, up to --max-redirs <num>
128
+ -m, --max-time <seconds> give up on a transfer that takes longer
129
+ -o, --output <file> write to a file rather than to stdout ("-" is stdout)
130
+ -O, --remote-name write to a file named after the URL
131
+ -s, --silent say nothing about a transfer that failed
132
+ -S, --show-error say it anyway, alongside -s
133
+ -X, --request <method> use another method
134
+ --compressed ask for a compressed answer, which the runtime does anyway
135
+ -h, --help this list
136
+
137
+ Every other option curl carries is refused by name, and says what would have
138
+ to exist here for it to work.
139
+ `;function af(e){let t=[...e.events,...e.stderr?[{fd:2,text:e.stderr}]:[]],n={stdout:``,stderr:e.stderr,exitCode:e.status,events:t};return e.gap?E(n,e.gap.kind,`curl`,e.gap.detail,e.gap.message):n}async function of(e,t,n,r){let i=hd(e);if(i.protocol)return Qd(r,`feature`,`protocol`,1,sf(i.protocol));if(i.malformed)return Zd(r,3,`URL using bad/illegal format or missing URL`);let a=t?.remote?cf(i.url):t?.file??null,o={url:i.url,method:n.method,body:n.body,headers:n.headers},s=n.timeout===null?null:AbortSignal.timeout(n.timeout),c=``;for(let e=0;;e++){let{response:t,failed:i}=await Td(o.url,lf(o,s),n.timeout);if(i)return Zd(r,i.code,i.message);(n.include||n.head)&&(c+=_f(t,r.ctx));let l=uf(t,o,n);if(l===null)return mf(t,o.url,c,a,n,r);if(await Dd(t),e>=n.redirects)return Zd(r,47,`Maximum (${n.redirects}) redirects followed`);if(l.protocol)return Qd(r,`feature`,`protocol`,1,sf(l.protocol));Object.assign(o,l)}}var sf=e=>`Protocol "${e}" not supported or disabled in libcurl`,cf=e=>e.pathname.slice(e.pathname.lastIndexOf(`/`)+1),lf=(e,t)=>({method:e.method,headers:e.headers,redirect:`manual`,...e.body===null?{}:{body:e.body},...t===null?{}:{signal:t}});function uf(e,t,n){if(!n.location||!$d.has(e.status))return null;let r=e.headers.get(`location`);if(r===null||r===``)return null;let i;try{i=new URL(r,t.url)}catch{return null}if(i.protocol!==`http:`&&i.protocol!==`https:`)return{protocol:i.protocol.slice(0,-1)};let a=ef.has(e.status)&&t.method!==`HEAD`&&t.method!==`GET`;return{url:i,method:a?`GET`:t.method,body:a?null:t.body,headers:pf(t.headers,a,i.origin!==t.url.origin)}}var df=Object.freeze([`content-type`,`content-length`]),ff=Object.freeze([`authorization`,`cookie`,`proxy-authorization`]);function pf(e,t,n){if(!t&&!n)return e;let r=new Headers(e);if(t)for(let e of df)r.delete(e);if(n)for(let e of ff)r.delete(e);return r}async function mf(e,t,n,r,i,a){if(i.failEarly&&e.status>=400)return await Dd(e),Zd(a,22,`The requested URL returned error: ${e.status}`);if(i.head)return await Dd(e),hf(n,null,r,a);let o=await Ed(e,t,i.timeout);return o.failed?Zd(a,o.failed.code,o.failed.message):hf(n,o.bytes,r,a)}function hf(e,t,n,r){return n===null?(e!==``&&r.events.push({fd:1,text:e}),t!==null&&t.length>0&&r.events.push({fd:1,bytes:t}),!0):gf(n,e,t,r)}function gf(e,t,n,r){let{ctx:i}=r;if(e===``)return Zd(r,23,`Remote filename has no length`);let a;try{a=i.writable&&i.fs.openWritable?.(i.cwd,e)}catch(e){return Zd(r,23,`Failure writing output to destination: ${e.message}`)}return a?(a.writeBytes(Dt([O(t),n??new Uint8Array])),!0):Qd(r,`feature`,`read-only target`,23,`${e}: file system is read-only`)}function _f(e,t){t.notes?.add(`curl: response header names are lowercased and sorted, and the status line reads HTTP/1.1 whatever the connection spoke.`);let n=[`HTTP/1.1 ${e.status}${e.statusText===``?``:` ${e.statusText}`}`],r=e.headers.getSetCookie?.()??[],i=!1;for(let[t,a]of e.headers)if(t!==`set-cookie`)n.push(`${t}: ${a}`);else if(r.length===0)n.push(`${t}: ${a}`);else if(!i){i=!0;for(let e of r)n.push(`${t}: ${e}`)}return n.join(`\r
140
+ `)+`\r
141
+ \r
142
+ `}var vf={...fs,...Uu,...ud,...Bu},yf=Object.freeze({__proto__:null,curl:tf}),bf=Object.freeze(Object.keys(yf)),xf=e=>e===!0&&dd()?yf:null,Sf=new Uint8Array;function Cf(e,t,n,r,i){let a=wf(e,i.skip,i.skipFlag,0),o=wf(e,i.len,i.lenFlag,1/0);if(a.error||o.error)return{error:a.error??o.error};let s=o.value,c=a.value,l=0,u=n,d=r.stdinBytes,f=[],p={stderr:``,failed:!1};for(let n of t.length?t:[null]){let t=sr(e,n===null?[]:[n],u,r,{read:`loose-bytes`,noRead:s===0&&c===0}),o=t.entries[0]?.kind===`dir`;if(p.stderr+=t.stderr,p.failed||=t.failed&&!(e===`hexdump`&&o),c&&o)return{error:T(`feature`,e,`skip across unreadable input`,`${e}: skipping across a directory operand is not supported`)};if(o&&e===`xxd`)return{error:C(p.stderr,2)};if(!t.inputs.length&&!o)continue;let m=t.inputs[0],h=m&&(m.shared||m.name===null);if(e===`hexdump`&&c&&h&&!r.stdinFile)return L(r,u,!0,d),{error:C(`hexdump: standard input: Illegal seek`)};let g=h&&r.stdinFile&&i.skip!==void 0&&(e===`xxd`||e===`hexdump`&&a.value>0),_=g?b(r.stdinOrigin):m?.bytes??Sf,v=Math.min(c,_.length);c-=v,l+=v;let y=Math.min(s,_.length-v);if(f.push(_.subarray(v,v+y)),s-=y,h){let e=_.subarray(v+y),t=d!==null&&!g&&e.length>0?e:null;u=t===null?k(e):vt(e)??``,L(r,u,!0,t)}if(g&&c&&(l=a.value,c=0),s===0&&c===0)break}if(c&&i.skipPastEofErrors)return{error:C(p.stderr+`${e}: cannot skip past end of combined input`)};let m=new Uint8Array(f.reduce((e,t)=>e+t.length,0)),h=0;for(let e of f)m.set(e,h),h+=e.length;return{bytes:m,start:l,r:p}}function wf(e,t,n,r){if(t===void 0)return{value:r};if(e===`xxd`&&!/^(?:0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.test(t))return{error:T(`feature`,e,`${n} ${t}`,`xxd: this offset/count spelling is not supported: ${t}`)};if(e===`hexdump`)return/^[ \t\n\r\v\f]*[+\d-]/u.test(t)?!/^\d+$/u.test(t)||/^0\d/u.test(t)?{error:T(`feature`,e,`${n} ${t}`,`hexdump: this offset/count spelling is not supported: ${t}`)}:BigInt(t)>BigInt(2**53-1)?{error:T(`feature`,e,`large byte count`,`hexdump: counts beyond exact integer precision are not supported`)}:{value:Number(t)}:{error:C(`${e}: ${n}: invalid count: ${t}`)};let i=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(t);if(!i)return{error:C(`${e}: ${n}: invalid count: ${t}`)};let a=/^0\d/u.test(i[1])?`0o`+i[1].slice(1):i[1];return mr(BigInt(a),i[2],`${e}: ${n}`,t)}var Tf=16,Ef=47,Df=39;function Of(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`C`,`v`],valueShort:[`n`,`s`]});if(a.includes(`-`))return T(`feature`,`hexdump`,`hyphen input operand`,`hexdump: a hyphen input operand is not supported; omit operands to read stdin`);let o=Cf(`hexdump`,a,e,n,{skip:i.get(`s`),len:i.get(`n`),skipFlag:`-s`,lenFlag:`-n`});return o.error?o.error:R(jf(o.bytes,o.start,r.has(`v`),r.has(`C`)?Nf:Mf),o.r)}function kf(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`v`],valueShort:[`j`,`N`]});if(!r.size&&!i.size&&(a.length===1&&/^\+\d/u.test(a[0])||a.length===2&&/^\+?\d/u.test(a[1])))return T(`feature`,`od`,`legacy offset operand`,`od: legacy offset operands are not supported; use -j OFFSET`);let o=Cf(`od`,a,e,n,{skip:i.get(`j`),len:i.get(`N`),skipFlag:`-j`,lenFlag:`-N`,skipPastEofErrors:!0});return o.error?o.error:R(jf(o.bytes,o.start,r.has(`v`),Pf),o.r)}function Af(e,t,n){let{values:r,positional:i}=U(t,{valueShort:[`s`,`l`]});if(i.length>2)return C(`xxd: too many operands`);if(i.length===2&&i[1]!==`-`)return T(`feature`,`xxd`,`output file`,`xxd: output files are not supported (filesystem is read-only)`);let a=Cf(`xxd`,i.slice(0,1),e,n,{skip:r.get(`s`),len:r.get(`l`),skipFlag:`-s`,lenFlag:`-l`});return a.error?a.error:R(jf(a.bytes,a.start,!1,Ff),a.r)}function jf(e,t,n,r){let i=r.hex?re(e):``,a=[],o=null,s=!1;for(let c=0;c<e.length;c+=Tf){let l=e.subarray(c,c+Tf),u=r.hex?i.slice(c*2,(c+Tf)*2):``;r.compress&&!n&&o!==null&&l.length===Tf&&Uf(l,o)?s||=(a.push(`*`),!0):(a.push(r.row(t+c,l,u)),s=!1),o=l}let c=t+e.length;return(r.trailer===`always`||r.trailer===`nonzero`&&c>0)&&a.push(r.addr(c)),Qn(a)}var Mf={compress:!0,trailer:`nonzero`,addr:If,row:(e,t)=>(If(e)+` `+Bf(t).map(Wf).join(` `)).padEnd(Ef)},Nf={compress:!0,trailer:`nonzero`,addr:Lf,hex:!0,row:zf},Pf={compress:!0,trailer:`always`,addr:Rf,row:(e,t)=>Rf(e)+` `+Bf(t).map(Gf).join(` `)},Ff={compress:!1,trailer:`never`,hex:!0,row:(e,t,n)=>`${Lf(e)}: ${Vf(t,n).join(` `).padEnd(Df)} ${Hf(t)}`};function If(e){return e.toString(16).padStart(7,`0`)}function Lf(e){return e.toString(16).padStart(8,`0`)}function Rf(e){return e.toString(8).padStart(7,`0`)}function zf(e,t,n){let r=[];for(let e=0;e<Tf;e++)r.push(e<t.length?n.slice(e*2,e*2+2):` `);let i=r.slice(0,8).join(` `),a=r.slice(8).join(` `);return`${Lf(e)} ${i} ${a} |${Hf(t)}|`}function Bf(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(n+1<e.length?e[n]|e[n+1]<<8:e[n]);return t}function Vf(e,t){let n=[];for(let r=0;r<e.length;r+=2)n.push(t.slice(r*2,r*2+4));return n}function Hf(e){let t=``;for(let n of e)t+=n>=32&&n<=126?String.fromCodePoint(n):`.`;return t}function Uf(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var Wf=e=>e.toString(16).padStart(4,`0`),Gf=e=>e.toString(8).padStart(6,`0`),Kf=76;function qf(e,{encode:t,decode:n}){return(r,i,a)=>{let{flags:o,positional:s,order:c}=U(i,{short:[`d`,`i`],long:[`decode`,`ignore-garbage`],valueShort:[`w`],valueLong:[`wrap`]}),l=Kf;for(let{name:t,value:n}of c){if(t!==`w`&&t!==`wrap`)continue;if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(n)||BigInt(n)<0n)return C(`${e}: invalid wrap size: ${n}`);let r=BigInt(n);l=r>Rn?0:Number(r)}if(s.length>1)return C(`${e}: extra operand: ${s[1]}`);let u=sr(e,s,r,a,{read:`as-held`});if(u.failed)return C(u.stderr);let{content:d,bytes:f}=u.inputs[0];return o.has(`d`)||o.has(`decode`)?Yf(e,n(d??_t(f),o.has(`i`)||o.has(`ignore-garbage`))):Jf(t(f??O(d)),l)}}function Jf(e,t){if(!t||e===``)return S(e);let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return S(n.join(`
143
+ `)+`
144
+ `)}function Yf(e,{bytes:t,valid:n}){let r=vt(t),i=n?``:`${e}: invalid input
145
+ `;if(r!==void 0&&n)return S(r);let a=r===void 0?{fd:1,bytes:t}:{fd:1,text:r};return{stdout:r??``,stderr:i,exitCode:+!n,events:[...t.length?[a]:[],...i?[{fd:2,text:i}]:[]]}}var Xf=`ABCDEFGHIJKLMNOPQRSTUVWXYZ234567`,Zf=8,Qf=Object.freeze([2,4,5,7,8]),$f=qf(`base32`,{encode:e=>ne(e,{padding:!0}),decode:tp}),ep=/[a-z]/u;function tp(e,t=!1){let n=e.replace(t?/[^A-Z2-7=]/gu:/\n/gu,``);try{let e=te(n,{padding:!0});if(!ep.test(n))return{bytes:e,valid:!0}}catch(e){if(!(e instanceof SyntaxError))throw e}return np(n)}function np(e){let t=new Uint8Array(Math.ceil(e.length/Zf)*5),n=0,r=0,i=!0;for(;r<e.length;){if(e.length-r<Zf){i=!1;break}let a=e.slice(r,r+Zf),o=/^[A-Z2-7]*/u.exec(a)[0];if(n+=rp(a,o,t.subarray(n)),!Qf.includes(o.length)||a.slice(o.length)!==`=`.repeat(Zf-o.length)){i=!1;break}r+=Zf}return{bytes:t.subarray(0,n),valid:i}}function rp(e,t,n){let r=0,i=0,a=0;for(let e of t)i=i<<5|Xf.indexOf(e),r+=5,!(r<8)&&(r-=8,n[a++]=i>>r&255);return a}var ip=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,ap=qf(`base64`,{encode:ie,decode:op});function op(e,t=!1){let n=e.replace(t?/[^A-Za-z0-9+/=]/gu:/\n/gu,``);try{return{bytes:ae(n,{padding:!0}),valid:!0}}catch(e){if(!(e instanceof SyntaxError))throw e;return sp(n)}}function sp(e){let t=new Uint8Array(Math.ceil(e.length/4)*3),n=/[A-Za-z0-9+/]*/uy,r=0,i=0,a=!0;for(;i<e.length;){n.lastIndex=i;let o=n.exec(e)[0].length,s=o-o%4;if(s){let n=ae(e.slice(i,i+s));t.set(n,r),r+=n.length,i+=s}if(i===e.length)break;let c=o%4;if(c<2){a=!1;break}let l=ip.indexOf(e[i]),u=ip.indexOf(e[i+1]),d=c===3?ip.indexOf(e[i+2]):0;t[r++]=l<<2|u>>4,c===3&&(t[r++]=u<<4|d>>2);let f=4-c;if(i+=c,e.slice(i,i+f)!==`=`.repeat(f)){a=!1;break}i+=f}return{bytes:t.subarray(0,r),valid:a}}var cp={short:[`n`,`N`,`i`,`s`,`w`,`F`,`v`,`l`,`c`,`q`,`u`,`a`,`H`,`I`],long:[`line-number`,`no-line-number`,`ignore-case`,`case-sensitive`,`word-regexp`,`fixed-strings`,`invert-match`,`files-with-matches`,`files-without-match`,`count`,`quiet`,`hidden`,`no-ignore`,`no-heading`,`with-filename`,`no-filename`,`text`,`unrestricted`],valueShort:[`A`,`B`,`C`],valueLong:[`after-context`,`before-context`,`context`],repeatable:[`e`,`regexp`]},lp=new Map(Object.entries({"line-number":`n`,"no-line-number":`N`,"ignore-case":`i`,"case-sensitive":`s`,"word-regexp":`w`,"fixed-strings":`F`,"invert-match":`v`,"files-with-matches":`l`,"files-without-match":`L`,count:`c`,quiet:`q`,text:`a`,unrestricted:`u`,"with-filename":`H`,"no-filename":`I`,regexp:`e`,"after-context":`A`,"before-context":`B`,context:`C`})),up=new Set([`no-heading`,`no-ignore`]),dp=(e,t)=>new D(`feature`,e,`rg: ${t}`);function fp(e){let t={patterns:[],context:[],mode:null,showName:null,ignoreCase:!1,lineNumbers:!1,word:!1,literal:!1,invert:!1,quiet:!1,text:!1,hidden:!1,unrestricted:0};for(let{name:n,value:r}of e.order)up.has(n)||pp(t,lp.get(n)??n,r,hp(n));let n=e=>t.context.findLast(([t])=>t===e)?.[1],r=e=>t.context.findLast(([t])=>t===e)?.[2]??`-`+e;if(t.after=mp(n(`A`)??n(`C`),n(`A`)===void 0?r(`C`):r(`A`)),t.before=mp(n(`B`)??n(`C`),n(`B`)===void 0?r(`C`):r(`B`)),t.unrestricted>=2&&(t.hidden=!0),t.unrestricted>=3)throw dp(`-uuu`,`searching binary files is not supported`);return t}function pp(e,t,n,r){switch(t){case`i`:e.ignoreCase=!0;return;case`s`:e.ignoreCase=!1;return;case`n`:e.lineNumbers=!0;return;case`N`:e.lineNumbers=!1;return;case`l`:case`L`:case`c`:e.mode=t;return;case`H`:e.showName=`H`;return;case`I`:e.showName=`h`;return;case`w`:e.word=!0;return;case`F`:e.literal=!0;return;case`v`:e.invert=!0;return;case`q`:e.quiet=!0;return;case`a`:e.text=!0;return;case`e`:e.patterns.push(n);return;case`hidden`:e.hidden=!0;return;case`u`:e.unrestricted++;return;case`A`:case`B`:case`C`:e.context.push([t,n,r]);return;default:throw dp(hp(t),`${hp(t)} is not supported`)}}function mp(e,t){if(e===void 0)return 0;if(!/^\d+$/u.test(e))throw dp(`${t} value`,`error parsing flag ${t}: value is not a valid number`);return Number(e)}var hp=e=>(e.length===1?`-`:`--`)+e;function gp(e,t){return t?e.flatMap(e=>[`-e`,e]):[`-e`,e.length===1?e[0]:e.map(e=>`(?:${e})`).join(`|`)]}var _p=[[/\\[1-9]/u,`backreference`],[/\(\?<?[=!]/u,`look-around`],[/\\[QE]/u,`\\Q…\\E literal span`]];function vp(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`
146
+ `)return!0;if(n!==`\\`)continue;let r=e[t+1];if(r===`n`||r===`x`&&/^x\{?0*a\}?/iu.test(e.slice(t+1)))return!0;t++}return!1}function yp(e,t){if(!t)for(let t of e){for(let[e,n]of _p)if(e.test(t))throw dp(n,`${n} is not supported; ripgrep's regex engine rejects it too`);if(vp(t))throw dp(`newline in a pattern`,`a newline in a pattern is not supported; ripgrep rejects one outside multiline mode`)}}var W=class extends Error{constructor(e,t=null,n=null,r=`syntax error`){super(e),this.line=t,this.gap=n,this.kind=r}},bp=new Set([`BEGIN`,`END`,`BEGINFILE`,`ENDFILE`,`function`,`func`,`if`,`else`,`while`,`for`,`do`,`break`,`continue`,`next`,`nextfile`,`exit`,`return`,`delete`,`in`,`getline`,`print`,`printf`,`switch`,`case`,`default`]),xp={__proto__:null,length:[0,1],substr:[2,3],index:[2,2],split:[2,3],sub:[2,3],gsub:[2,3],gensub:[3,4],match:[2,3],sprintf:[1,1/0],sin:[1,1],cos:[1,1],atan2:[2,2],exp:[1,1],log:[1,1],sqrt:[1,1],int:[1,1],rand:[0,0],srand:[0,1],tolower:[1,1],toupper:[1,1],close:[1,2],fflush:[0,1],systime:[0,0],strtonum:[1,1],and:[2,1/0],or:[2,1/0],xor:[2,1/0],lshift:[2,2],rshift:[2,2],compl:[1,1],typeof:[1,1],isarray:[1,1]},Sp=new Map([[`system`,`system() is not supported: this terminal runs no processes`],[`strftime`,`strftime() is not supported (gawk extension)`],[`mktime`,`mktime() is not supported (gawk extension)`],[`asort`,`asort() is not supported (gawk extension)`],[`asorti`,`asorti() is not supported (gawk extension)`],[`patsplit`,`patsplit() is not supported (gawk extension)`]]),Cp=new Set([...Object.keys(xp),...Sp.keys()]),wp=5e6,Tp=100,Ep=1e6,Dp=`this terminal runs no processes`;function Op(e,t,n){switch(e){case`+`:return t+n;case`-`:return t-n;case`*`:return t*n;case`/`:return t/n;case`%`:return t%n;default:return t**n}}var kp={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},Ap=`^$.[]|()*+?{}\\/"`,jp=1e3,Mp=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),Np=e=>e!==void 0&&e>=`0`&&e<=`7`,Pp=class{constructor(e,t,n,r){this.src=e,this.i=0,this.warn=t,this.tables=n,this.ignoreCase=r,this.groups=0}fail(e){throw new W(`invalid regex /${this.src}/: ${e}`)}peek(){return this.src[this.i]}literal(){let e=this.src.codePointAt(this.i);return this.i+=ni(e),this.charNode(e)}charNode(e){let t=this.ignoreCase?this.tables.fold(e):[e];return t.length===1?{type:`char`,code:e}:{type:`set`,negate:!1,items:t.map(e=>[e,e])}}parse(){return this.alternation(0)}alternation(e){let t=[this.concatenation(e)];for(;this.peek()===`|`;)this.i++,t.push(this.concatenation(e));return t.length===1?t[0]:{type:`alt`,nodes:t}}concatenation(e){let t=[];for(;!this.endsConcatenation(e);)t.push(this.quantified(this.atom(t.length===0,e)));return t.length===1?t[0]:{type:`cat`,nodes:t}}endsConcatenation(e){let t=this.peek();return t===void 0||t===`|`||t===`)`&&e>0}quantified(e){let t=e;for(;;){let e=this.peek();if(e===`*`)this.i++,t={type:`rep`,node:t,min:0,max:null};else if(e===`+`)this.i++,t={type:`rep`,node:t,min:1,max:null};else if(e===`?`)this.i++,t={type:`rep`,node:t,min:0,max:1};else if(e===`{`){let e=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!e&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail(`invalid content of {}`),!e||e[1]===``&&e[2]===void 0)return t;let n=e[1]===``?0:Number(e[1]),r=e[2]===void 0?n:e[3]===``?null:Number(e[3]);if(r!==null&&r<n&&this.fail(`invalid interval {${n},${r}}`),n>jp||r!==null&&r>jp)throw new W(`interval count above ${jp} is not supported`,null,`regex interval limit`);this.i+=e[0].length,t={type:`rep`,node:t,min:n,max:r}}else return t}}atom(e,t){let n=this.peek();if(n===`(`){this.i++;let e=++this.groups,n=this.alternation(t+1);return this.peek()!==`)`&&this.fail("missing `)`"),this.i++,{type:`group`,index:e,node:n}}return n===`[`?this.bracket():n===`\\`?this.escape():(this.i++,n===`.`?{type:`any`}:n===`^`||n===`$`?{type:`assert`,kind:n}:(n!==`*`&&n!==`+`&&n!==`?`||e||this.fail(`unexpected \`${n}\``),this.i--,this.literal()))}escape(){this.i++;let e=this.peek();return e===void 0&&this.fail(`trailing backslash`),this.i++,e===`y`?{type:`assert`,kind:`y`}:e===`<`||e===`>`||e===`B`?{type:`assert`,kind:e}:e==="`"?{type:`assert`,kind:`^`}:e===`'`?{type:`assert`,kind:`$`}:e===`s`||e===`S`?{type:`set`,negate:e===`S`,items:this.tables.ranges(`space`)}:e===`w`||e===`W`?{type:`set`,negate:e===`W`,items:this.tables.ranges(`word`)}:(e===`b`&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(e,!0)))}escapedCode(e,t){if(e in kp)return kp[e];if(Np(e)){let t=e;for(;t.length<3&&Np(this.peek());)t+=this.src[this.i++];return Ip(t,8)}if(e===`x`&&Mp(this.peek())){let e=``;for(;e.length<2&&Mp(this.peek());)e+=this.src[this.i++];return Ip(e,16)}let n=this.src.codePointAt(this.i-1);return!Ap.includes(e)&&t&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(n)}' is not a known regexp operator`),this.i+=ni(n)-1,n}bracket(){this.i++;let e=!1;this.peek()===`^`&&(e=!0,this.i++);let t=[],n=!0;for(;;){this.i>=this.src.length&&this.fail(`unterminated bracket expression`);let e=this.peek();if(e===`]`&&!n){this.i++;break}if(n=!1,e===`[`&&this.src[this.i+1]===`:`){let e=this.src.indexOf(`:]`,this.i+2);if(e!==-1){let n=this.src.slice(this.i+2,e),r=this.tables.ranges(this.ignoreCase?En(n):n);r===void 0&&this.fail(`invalid character class \`[:${n}:]\``),t.push(...r),this.i=e+2;continue}}let r=this.bracketChar();if(this.peek()===`-`&&this.src[this.i+1]!==`]`&&this.src[this.i+1]!==void 0){this.i++;let e=this.bracketChar(),n=this.ignoreCase?this.tables.foldRange(r,e):e<r?null:[[r,e]];n===null&&this.fail(`invalid range end`),t.push(...n)}else this.ignoreCase?t.push(...this.tables.fold(r).map(e=>[e,e])):t.push([r,r])}return{type:`set`,negate:e,items:t}}bracketChar(){let e=this.peek();if(e===`[`&&(this.src[this.i+1]===`.`||this.src[this.i+1]===`=`)){let e=this.src.indexOf(this.src[this.i+1]+`]`,this.i+2);if(e!==-1&&e>this.i+2){Array.from(this.src.slice(this.i+2,e)).length!==1&&this.fail(`invalid collation character`);let t=this.src.codePointAt(this.i+2);return this.i=e+2,t}}if(e===`\\`){this.i++,this.peek()===void 0&&this.fail(`trailing backslash`);let e=this.src[this.i++];return this.escapedCode(e,!1)}let t=this.src.codePointAt(this.i);return this.i+=ni(t),t}};function Fp(e,t=null,n=Ln(P),r=!1){let i=new Pp(e,t,n,r);return{ast:i.parse(),groups:i.groups}}function Ip(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new W(`non-ASCII regex byte escapes are not supported`,null,`regex byte escapes`);return n}var Lp=e=>`\\u{${e.toString(16)}}`,Rp=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):Lp(e);function zp(e,t){if(e===`^`||e===`$`)return e;let n=t.assertions();return e===`y`?n.boundary:e===`B`?n.inside:n[e]}function Bp(e,t=Ln(P)){let n=e=>Bp(e,t);switch(e.type){case`char`:return Rp(e.code);case`any`:return`.`;case`set`:return`[${e.negate?`^`:``}${e.items.map(([e,t])=>e===t?Rp(e):`${Rp(e)}-${Rp(t)}`).join(``)}]`;case`assert`:return zp(e.kind,t);case`group`:return`(${n(e.node)})`;case`cat`:return e.nodes.map(n).join(``);case`alt`:return`(?:${e.nodes.map(n).join(`|`)})`;case`rep`:{let t=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${t}*`:e.min===1?`${t}+`:`${t}{${e.min},}`:e.min===0&&e.max===1?`${t}?`:`${t}{${e.min},${e.max}}`}default:throw new W(`internal: unknown regex node ${e.type}`)}}var Vp=5e4;function Hp(e,t){let n=t=>{for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1};return t?e=>!n(e):n}function Up(e,t=Ln(P)){let n=[],r=e=>{if(n.length>=Vp)throw new W(`regex too large`,null,`regex state limit`);return n.push(e),n.length-1};function i(e,t){switch(e.type){case`char`:return r({op:`char`,codes:[e.code],next:t});case`any`:return r({op:`any`,next:t});case`set`:return r({op:`set`,test:Hp(e.items,e.negate),next:t});case`assert`:return r({op:`assert`,kind:e.kind,next:t});case`group`:return i(e.node,t);case`cat`:{let n=t;for(let t=e.nodes.length-1;t>=0;t--)n=i(e.nodes[t],n);return n}case`alt`:{let n=e.nodes.map(e=>i(e,t)),a=n.at(-1);for(let e=n.length-2;e>=0;e--)a=r({op:`split`,x:n[e],y:a});return a}case`rep`:return a(e,t);default:throw new W(`internal: unknown regex node ${e.type}`)}}function a(e,t){let a=t;if(e.max===null){let o=r({op:`split`,x:-1,y:t});n[o].x=i(e.node,o),a=o}else for(let n=e.max-e.min;n>0;n--)a=r({op:`split`,x:i(e.node,a),y:t});for(let t=0;t<e.min;t++)a=i(e.node,a);return a}let o=i(e,r({op:`match`})),s=``,c=o;for(;n[c].op===`char`&&n[c].codes.length===1&&n[c].codes[0]<128;)s+=String.fromCodePoint(n[c].codes[0]),c=n[c].next;return(n[c].op!==`match`||s===``)&&(s=null),{states:n,start:o,literal:s,isWord:e=>t.has(`word`,e),gen:new Int32Array(n.length).fill(-1),stamp:0}}function Wp(e,t){if(t<=0)return-1;let n=e.codePointAt(t-1);if(n<56320||n>57343||t<2)return n;let r=e.codePointAt(t-2);return r>65535?r:n}function Gp(e,t,n,r){if(e===`^`)return n===0;if(e===`$`)return n===t.length;let i=r(Wp(t,n)),a=n<t.length&&r(t.codePointAt(n));return e===`y`?i!==a:e===`B`?i===a:e===`<`?!i&&a:i&&!a}function Kp(e,t){return e.op===`char`?e.codes.includes(t):e.op===`any`||e.test(t)}function qp(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let r=t.indexOf(e.literal,n);return r<0?null:{start:r,end:r+e.literal.length}}let{states:r,gen:i}=e,a=t.length,o=[],s=(n,a,s,c,l)=>{for(o.push(a);o.length>0;){let a=o.pop();if(i[a]===l)continue;i[a]=l;let u=r[a];u.op===`split`?o.push(u.y,u.x):u.op===`assert`?Gp(u.kind,t,c,e.isWord)&&o.push(u.next):n.push(a,s)}},c=[],l=[],u=null,d=n,f=++e.stamp;for(;;){u===null&&s(c,e.start,d,d,f);let n=d<a?t.codePointAt(d):-1,i=ni(n);if(c.length===0){if(u!==null||d>=a)break;d+=i,f=++e.stamp;continue}let o=++e.stamp;for(let e=0;e<c.length;e+=2){let t=c[e],a=c[e+1];if(u!==null&&a>u.start)continue;let f=r[t];f.op===`match`?(u===null||a<u.start||a===u.start&&d>u.end)&&(u={start:a,end:d}):n!==-1&&Kp(f,n)&&s(l,f.next,a,d+i,o)}if(c.length=0,[c,l]=[l,c],f=o,d>=a)break;d+=i}return u}var Jp=new Map,Yp=class{constructor(e,t,n,r=Ln(P)){let{ast:i,groups:a}=Fp(e,n,r,t);this.src=e,this.ignoreCase=t,this.tables=r,this.groupCount=a,this.source=Bp(i,r),this.flags=`su`;try{this.js=new RegExp(ii(this.source),this.flags)}catch(t){throw new W(`cannot compile regex /${e}/: ${t.message}`,null,`regex engine limit`)}this.ast=i,this.nfa=null,this.capture=null,this.captureShape=Xp(i)}test(e){return this.checkCase(e),this.js.test(e)}checkCase(e){if(this.ignoreCase&&On.test(e+this.src))throw new W(`case-insensitive matching over Cyrillic Extended-C letters is not supported`,null,`locale-sensitive regex`)}search(e,t=0){return this.checkCase(e),this.nfa===null&&(this.nfa=Up(this.ast,this.tables)),qp(this.nfa,e,t)}groups(e,t,n){if(this.captureShape.unsafe)throw new W(`capture extraction across repeated or alternative groups is not supported`,null,`regex capture semantics`);let r=this.capture??=new RegExp(this.source,this.flags+`dy`);r.lastIndex=t;let i=r.exec(e);if(!i||i.index!==t||t+i[0].length!==n){let r=Array.from(e.slice(n)).length,a=RegExp(`(?:${this.source})(?=.{${r}}(?![^]))`,this.flags+`dy`);a.lastIndex=t,i=a.exec(e)}if(!i)throw new W(`capture extraction for this match is not supported`,null,`regex capture semantics`);return i.indices.map((e,t)=>e===void 0?void 0:{text:i[t],start:e[0],end:e[1]})}};function Xp(e){let t=(e.nodes??(e.node?[e.node]:[])).map(Xp),n=t.reduce((e,t)=>e+t.groups,+(e.type===`group`));return{groups:n,nullable:e.type===`assert`||(e.type===`group`||e.type===`cat`)&&t.every(e=>e.nullable)||e.type===`alt`&&t.some(e=>e.nullable)||e.type===`rep`&&(e.min===0||t[0].nullable),unsafe:e.type===`rep`&&(e.max===null||e.max>1)&&(n>1||n>0&&t[0].nullable)||e.type===`alt`&&n>0||t.some(e=>e.unsafe)}}function Zp(e,t=!1,n=null,r=Ln(P)){let i=(t?`i`:`c`)+r.name+`\0`+e,a=Jp.get(i);if(a)return a;Jp.size>=500&&Jp.clear();let o=new Yp(e,t,n,r);return Jp.set(i,o),o}function Qp(e,t,n){for(;;){let r=t.search(e,n);if(!r||r.start!==r.end)return r;if(r.end>=e.length)return null;n=r.end+ri(e,r.end)}}function $p(e,t){let n=[],r=0;for(;;){let i=Qp(e,t,r);if(!i)break;n.push(e.slice(r,i.start)),r=i.end}return n.push(e.slice(r)),n}function em(e,t,n,r){let i=r!==`first`,a=e.length,o=``,s=0,c=-1,l=0;for(;s<=a;){let u=t.search(e,s);if(!u)break;let d=u.start===u.end;if(d&&u.start===c&&r!==`nth`){if(u.start>=a)break;let t=ri(e,u.start);o+=e.slice(s,u.start+t),s=u.start+t;continue}l++;let f=n(u.start,u.end,l);if(o+=e.slice(s,u.start)+(f===null?e.slice(u.start,u.end):f),c=u.end,d){if(u.end>=a){s=a;break}let t=ri(e,u.end);o+=e.slice(u.end,u.end+t),s=u.end+t}else s=u.end;if(!i)break}return{out:o+e.slice(s),count:l}}function tm(e,t){let n=`(){}+?|`,r=!1,i=0,a=!1,o=``;for(let s=0;s<e.length;s++){let c=e[s];if(a){if(c===`[`&&(e[s+1]===`.`||e[s+1]===`=`))throw new D(`feature`,`regex collating or equivalence class`,`grep: collating and equivalence classes are not supported`);if(c===`[`){let n=un(e,s,{classes:t});if(n){o+=n.body,s=n.end-1;continue}}o+=c,c===`]`&&(a=!1,r=!0)}else if(c===`[`)o+=c,a=!0,e[s+1]===`^`&&(o+=`^`,s++),e[s+1]===`]`&&(o+=`\\]`,s++);else if(c===`\\`){let t=e[++s];if(t===void 0)return{error:`trailing backslash (\\)`};if(n.includes(t)){if((t===`+`||t===`?`)&&!r){o+=`\\`+t,r=!0;continue}if(t===`(`&&i++,t===`)`&&i--===0)return{error:`Unmatched ) or \\)`};(t===`(`||t===`|`)&&(r=!1),(t===`)`||t===`}`)&&(r=!0),o+=t}else o+="^$\\.*[]/bBsSwW<>`'123456789".includes(t)?`\\`+t:t,r=!"bB<>`'".includes(t)}else c===`*`?(o+=r?`*`:`\\*`,r=!0):c===`^`?(r=!nm(e,s),o+=r?`\\^`:`^`):c===`$`?(r=s!==e.length-1&&(e[s+1]!==`\\`||e[s+2]!==`)`&&e[s+2]!==`|`),o+=r?`\\$`:`$`):(o+=n.includes(c)?`\\`+c:c,r=!0)}return i>0?{error:`Unmatched ( or \\(`}:{source:o}}function nm(e,t){if(t===0)return!0;if(t<2||e[t-2]!==`\\`||e[t-1]!==`(`&&e[t-1]!==`|`)return!1;let n=0;for(let r=t-3;r>=0&&e[r]===`\\`;r--)n++;return n%2==0}function rm(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,i=!1,a=0,o=!1,s=[],c=new Set,l=!1;for(let u=0;u<e.length;u++){let d=e[u];if(d===`\\`){let n=e[++u];if(!i&&/[1-9]/u.test(n??``)){let e=Number(n);if(!t.has(e))throw Error(`Invalid back reference`);(!c.has(e)||r.has(e))&&(o=!0)}s=[]}else if(i)d===`]`&&(i=!1);else if(d===`[`)i=!0,s=[];else if(d===`(`)n.push({id:++a,entry:new Set(c),branches:[],start:u}),s=[];else if(d===`|`){let e=n.at(-1);e&&e.branches.push(c),c=new Set(e?.entry),s=[]}else if(d===`)`){let r=n.pop();if(!r)continue;c=r.branches.reduce((e,t)=>e.intersection(t),c),c.add(r.id),t.add(r.id),s=[...c.difference(r.entry)],l=im(e.slice(r.start,u+1))}else if(d===`*`||d===`?`||d===`+`){if(d!==`?`&&l)for(let e of s)r.add(e);if(d!==`+`)for(let e of s)c.delete(e)}else if(d===`{`){let t=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(u));if(t){Number(t[1])===0&&(c=c.difference(new Set(s)));let e=t[2]===void 0?Number(t[1]):t[2]===``?1/0:Number(t[2]);l&&e>1&&s.forEach(e=>r.add(e)),u+=t[0].length-1}else s=[]}else s=[]}return o}function im(e){try{return RegExp(`^(?:${e})$`,`su`).test(``)}catch{return!0}}var am=`bBsSwW`;function om(e,t){let n=``;for(let r=0;r<e.length;){let i=e[r];if(i===`[`){let i=cm(e,r,t);n+=i.text,r=i.end;continue}let a=i===`\\`,o=e.codePointAt(r+ +!!a),s=+!!a+ni(o),c=a&&am.includes(e[r+1])?null:t.fold(o);n+=c===null||c.length===1?e.slice(r,r+s):`[${String.fromCodePoint(...c)}]`,r+=s}return n}function sm(e,t){let n=``;for(let r of e){let e=t.fold(r.codePointAt(0));n+=e.length===1?RegExp.escape(r):`[${String.fromCodePoint(...e)}]`}return n}function cm(e,t,n){let r=t+1,i=`[`;e[r]===`^`&&(i+=`^`,r++);let a=!0;for(;;){let t=e[r];if(t===`]`&&!a)return{text:i+`]`,end:r+1};if(a=!1,t===`[`&&`:.=`.includes(e[r+1])){let t=e[r+1],n=e.indexOf(t+`]`,r+2);i+=t===`:`?`[:${En(e.slice(r+2,n))}:]`:e.slice(r,n+2),r=n+2;continue}let o=e.codePointAt(r),s=r+ni(o);if(e[s]===`-`&&e[s+1]!==void 0&&e[s+1]!==`]`){let t=e.codePointAt(s+1),a=s+1+ni(t);i+=lm(o,t,e.slice(r,a),n),r=a}else i+=String.fromCodePoint(...n.fold(o)),r=s}}function lm(e,t,n,r){let i=r.foldRange(e,t);if(i===null)throw Error(`Invalid range end`);return i.length===1&&i[0][0]===e&&i[0][1]===t?n:i.map(([e,t])=>e===t?String.fromCodePoint(e):`${String.fromCodePoint(e)}-${String.fromCodePoint(t)}`).join(``)}function um({pattern:e,tables:t},n){return[...e].map(e=>(n?t.fold(e.codePointAt(0)):[e.codePointAt(0)]).map(e=>O(String.fromCodePoint(e))))}function dm(e,t){return t.every(t=>t.literal?(t.literalMask??=um(t.literal,t.folded),!pm(e,t.literalMask)):!1)}function fm(e,t,n,r=P){let i=Ln(r);return t.every(t=>(n||!hm.test(t))&&t.isWellFormed()&&!pm(e,um({pattern:t,tables:i},!1)))}function pm(e,t){if(t.length===0)return!0;for(let n of new Set(t[0].map(e=>e[0])))for(let r=e.indexOf(n);r>=0&&r+t.length<=e.length;r=e.indexOf(n,r+1))if(mm(e,r,t,0))return!0;return!1}function mm(e,t,n,r){return r===n.length||n[r].some(i=>i.every((n,r)=>e[t+r]===n)&&mm(e,t+i.length,n,r+1))}var hm=/[\\.^$*+?()[\]{}|]/u,gm=new Set(`\\.[*^$`),_m=new Set(`\\.[*^$+?(){}|`);function vm(e,t){if(t.has(`F`))return e;if(t.has(`P`))return hm.test(e)?null:e;let n=t.has(`E`)?_m:gm,r=``;for(let t=0;t<e.length;t++){let i=e[t]===`\\`,a=i?e[++t]:e[t];if(n.has(a)!==i)return null;r+=a}return r}var ym=new Map;function bm(e){if(ym.has(e))return ym.get(e);let t=e.assertions(),n=``;for(let t=128;t<=255;t++)e.has(`word`,t)&&(n+=`\\u${(56320+t).toString(16)}`);let r=Nn(e.body(`word`)+n),i={"<":r[`<`],">":r[`>`],b:r.boundary,B:r.inside,W:xm(t.nonWord),S:xm(t.nonSpace)};return ym.set(e,i),i}var xm=e=>`(?:(?![${St}])${e})`;function Sm(e){let t=Up(e.ast,e.tables),n=t.states.map(e=>e.op===`any`?{op:`set`,test:e=>!wt(e),next:e.next}:e.op===`set`?{...e,test:t=>!wt(t)&&e.test(t)}:e),r={...t,states:n,isWord:t=>e.tables.has(`word`,wt(t)?t-56320:t)};return{search:(e,t)=>qp(r,e,t)}}var Cm=[0,0,0,0,1114112,2097152,67108864],wm=(e,t)=>wt(e.codePointAt(t))?e.codePointAt(t)-56320:-1;function Tm(e,t){let n=wm(e,t),r=n===237?3:n>=240&&n<=247?4:n>=248&&n<=251?5:n===252||n===253?6:0,i=n&127>>r;for(let n=1;n<r;n++){let r=wm(e,t+n);if(r<128||r>191)return 0;i=i<<6|r&63}return r===3?i>=55296&&i<=57343?3:0:r&&i>=Cm[r]?r:0}function Em(e){for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n>65535&&t++,!wt(n))continue;let r=Tm(e,t);if(r===0||r===3)return!0;t+=r-1}return!1}var Dm=/[\uDCED\uDCF0-\uDCFD][\uDC80-\uDCBF]{2,5}/gu;function Om(e){let t={long:!1,surrogate:!1};for(let[n]of e.matchAll(Dm)){let e=Tm(n,0);if(e===3?t.surrogate=!0:e&&(t.long=!0),t.long&&t.surrogate)break}return t}function km(e,t){let n={negated:!1,dot:!1,regex:t,wordEdge:!1};for(let t=0;t<e.length;t++){let r=e[t];if(r===`\\`){let r=e[++t]??``;`<>bB`.includes(r)&&(n.wordEdge=!0),`<>bBwsWS`.includes(r)&&(n.regex=!0),`WS`.includes(r)&&(n.negated=!0)}else if(r===`.`)n.dot=!0;else if(r===`[`){let r=ln(e,t),i=e.slice(t+1,r);i.startsWith(`^`)&&(n.negated=!0),/\[:|.-./u.test(i.replace(/^\^?\]?/u,``))&&(n.regex=!0),t=r}}return n}function Am(e,t,n){return t.long||t.surrogate?e.wordEdge||(e.dot||e.negated)&&(e.regex||n)?!0:t.long&&e.negated:!1}var jm=new Map;function Mm(e){return jm.has(e)||jm.set(e,RegExp(`[^\\x00-\\x7f${St}${e.body(`word`)}]`,`u`)),jm.get(e)}function Nm(e){throw new D(`feature`,`PCRE `+e,`PCRE ${e} is not supported`)}function Pm(e){let t={captures:0,closed:new Set,names:new Map,stack:[],behind:0,references:!1,risky:!1},n=``;for(let r=0;r<e.length;){let i=e[r];if(i===`\\`){let i=Rm(e,r,t,!1);n+=i.source,r=i.end}else if(i===`[`){let i=Lm(e,r,t);n+=i.source,r=i.end}else if(i===`(`){let i=Fm(e,r,t);n+=i.source,r=i.end}else{if(i===`)`){let e=t.stack.pop();e?.capture&&t.closed.add(e.capture),e?.behind&&t.behind--}if(`*+?`.includes(i)&&(t.behind&&Nm(`variable-length lookbehind`),e[r+1]===`+`&&Nm(`possessive repetition`),i!==`+`&&(t.risky=!0)),i===`|`&&(t.risky=!0),i===`{`){let i=Im(e,r,t);n+=i.source,r=i.end}else n+=i===`]`||i===`}`?`\\`+i:i,r++}}return t.references&&t.risky&&Nm(`conditional backreference`),n}function Fm(e,t,n){let r=!1,i=null,a=`(`;if(e[t+1]===`*`&&Nm(`control verb`),e[t+1]===`?`){let o=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(o||Nm(`group`),a=o[0],r=a===`(?<=`||a===`(?<!`,!o[1]&&a!==`(?:`&&(n.risky=!0),o[1]){if(i=++n.captures,n.names.has(o[1]))throw Error(`duplicate PCRE capture name`);n.names.set(o[1],i)}}else i=++n.captures;return r&&n.behind++,n.stack.push({capture:i,behind:r}),{source:a,end:t+a.length}}function Im(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&Nm(`repetition`),{source:`\\{`,end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&Nm(`variable-length lookbehind`),Number(r[1])>65535||Number(r[2])>65535)throw Error(`PCRE repetition count exceeds 65535`);return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]===`+`&&Nm(`possessive repetition`),{source:r[0],end:t+r[0].length}}function Lm(e,t,n){let r=t+1,i=`[`;for(e[r]===`^`&&(i+=`^`,r++),e[r]===`]`&&(i+=`\\]`,r++);r<e.length&&e[r]!==`]`;)if(e[r]===`[`&&`:.=`.includes(e[r+1]??``)&&Nm(`character class`),e[r]===`\\`){let t=Rm(e,r,n,!0);i+=t.source,r=t.end}else i+=e[r]===`[`?`\\[`:e[r],r++;return{source:i+(e[r]===`]`?`]`:``),end:r+1}}function Rm(e,t,n,r){let i=e[t+1];if(i===void 0)throw Error(`trailing backslash`);if(i===`Q`){let n=e.indexOf(`\\E`,t+2);return{source:RegExp.escape(e.slice(t+2,n<0?void 0:n)),end:n<0?e.length:n+2}}if(i===`E`)return{source:``,end:t+2};if(i===`x`||i===`0`||r&&/[1-7]/u.test(i))return zm(e,t);if(i===`a`||i===`e`)return{source:i===`a`?`\\u0007`:`\\u001B`,end:t+2};if(`AzZ`.includes(i)&&!r)return{source:i===`A`?`^`:`$`,end:t+2};if(/[1-9]/u.test(i)&&!r)return(/\d/u.test(e[t+2]??``)||!n.closed.has(Number(i)))&&Nm(`forward or ambiguous backreference`),n.references=!0,{source:`\\`+i,end:t+2};if(i===`k`&&!r){let r=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return r&&n.closed.has(n.names.get(r[1]))||Nm(`named backreference`),n.references=!0,{source:r[0],end:t+r[0].length}}if(`dDsSwWfnrtbB`.includes(i))return{source:`\\`+i,end:t+2};/[A-Za-z0-9]/u.test(i)&&Nm(`escape \\`+i);let a=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(a),end:t+1+a.length}}function zm(e,t){let n=e[t+1]===`x`,r=(n?/^\\x(?:\{([\da-fA-F]+)\}|([\da-fA-F]{1,2}))/u:/^\\([0-7]{1,3})/u).exec(e.slice(t));if(!r)throw Error(`invalid PCRE character escape`);let i=n?16:8,a=parseInt(r[1]??r[2],i);return ti(a)||Nm(`character escape`),{source:`\\u{${a.toString(16)}}`,end:t+r[0].length}}function Bm(e,t){let n=``,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`){let t=e[++i]??``;n+=r?a+t:Vm(t)}else{if(r&&a===`[`){if(e[i+1]===`.`||e[i+1]===`=`)throw new D(`feature`,`regex collating or equivalence class`,`grep: collating and equivalence classes are not supported`);let r=un(e,i,{classes:t});if(r){n+=r.body,i=r.end-1;continue}}a===`[`&&!r?(n+=`[`,r=!0,e[i+1]===`^`&&(n+=`^`,i++),e[i+1]===`]`&&(n+=`\\]`,i++)):(a===`]`&&(r=!1),n+=a)}}return n}function Vm(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?`\\`+e:RegExp.escape(e)}function Hm(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`){if(`bBsSwW<>`.includes(e[++t]??``))return!0}else if(`.[*+?{`.includes(e[t]))return!0;return!1}function Um(e,t=`js`,n=Ln(P)){let r=t===`extent`,i=t===`marked`,a=r?{b:`\\y`}:i?{...Wm(n),...bm(n)}:Wm(n),o=``,s=!1;for(let t=0;t<e.length;t++){let n=e[t];if(n===`\\`){let i=e[++t];o+=!s&&Object.hasOwn(a,i)?a[i]:n+i,!r&&!s&&/[1-9]/u.test(i)&&/\d/u.test(e[t+1]??``)&&(o+=`(?:)`)}else if(i&&n===`[`){let n=rh(e,t);o+=xm(e.slice(t,n+1)),t=n}else i&&n===`.`?o+=`[^${St}]`:(n===`[`&&(s=!0),n===`]`&&(s=!1),o+=n)}return o}function Wm(e){let t=e.assertions();return{"<":t[`<`],">":t[`>`],b:t.boundary,B:t.inside,w:t.word,W:t.nonWord,s:t.space,S:t.nonSpace,"`":`^`,"'":`$`}}var Gm=e=>e.plain??=new RegExp(e.source,e.flags);function Km(e){return e.markedSource===void 0?Gm(e):(e.marked??=new RegExp(ii(Um(e.markedSource,`marked`,e.tables)),e.flags),e.marked)}var qm=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,Jm=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function Ym(e,t,n){let r=(n?qm:Jm).exec(e.slice(t));if(!r&&!n)throw Error(`invalid repetition count`);r&&cn(Number(r[1]),r[2]===void 0||r[2]===``?void 0:Number(r[2]))}var Xm={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function Zm(e){if(Xm[e])return Xm[e];let t=qm.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===``?1/0:Number(t[2])}}var Qm=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function $m(e,t){let n=Math.max(t.min,1);if(n>t.max)return{min:0,max:0};if(e.min>0&&(t.min===0&&e.min>1||e.max!==1/0&&t.max>n&&(n+1)*e.min>n*e.max+1))return null;let r=Qm(t.max,e.max);return r!==1/0&&r>sn?null:{min:Qm(t.min,e.min),max:r}}function eh(e){return e.max===1/0?e.min===0?`*`:e.min===1?`+`:`{${e.min},}`:e.min===0&&e.max===1?`?`:e.min===e.max?`{${e.min}}`:`{${e.min},${e.max}}`}var th=e=>!e.startsWith(`(`)&&!/^\\[1-9]/u.test(e);function nh(e,t){if(t.length===1)return e+eh(t[0].bounds);let n=t[0].bounds,r=null;for(let i=1;i<t.length;i++){let{bounds:a,text:o}=t[i],s=r===null?$m(n,a):null;if(s)n=s;else{if(!(r===null&&n.min===n.max&&th(e))&&a.max>1)throw Error(`stacked quantifier needs ambiguous nesting`);r=`(?:${r??e+eh(n)})${o}`}}return r??e+eh(n)}function rh(e,t){let n=t+1;for(e[n]===`^`&&n++;n<e.length;n++)if(e[n]===`\\`)n++;else if(e[n]===`]`)return n;return e.length-1}function ih(e){let t=``,n=-1,r=-1,i=[],a=()=>{i.length>0&&(t=t.slice(0,n)+nh(t.slice(n,r),i)),i=[]},o=e=>{a(),n=t.length,r=-1,t+=e},s=[];for(let c=0;c<e.length;c++){let l=e[c];if(l===`\\`){o(l+(e[++c]??``));continue}if(l===`[`){let t=rh(e,c);o(e.slice(c,t+1)),c=t;continue}if(l===`(`){a(),s.push(t.length),n=-1,t+=l;continue}if(l===`)`){a(),t+=l,n=s.pop()??-1,r=-1;continue}if(l===`|`||l===`^`||l===`$`){a(),t+=l,n=-1;continue}let u=l===`{`?qm.exec(e.slice(c)):null;if(l===`*`||l===`+`||l===`?`||u){let e=u?u[0]:l;if(c+=e.length-1,n<0){t+=e;continue}i.length===0&&(r=t.length),i.push({bounds:Zm(e),text:e})}else o(l)}return a(),t}function ah(e,t,n=!1){let r=-1;for(let i=0;i<e.length;i++){let a=i<=r,o=e[i];if(o===`\\`){let n=e[++i];if(n===void 0)throw Error(`trailing backslash`);if(a||n&&`dDxXuUpPkKcC`.includes(n))throw new D(`feature`,`regex escape`,`grep: this regex escape is not supported with GNU semantics`);!t&&n===`{`&&Ym(e,i-1,!1)}else if(o===`[`&&!a)r=ln(e,i,n);else{if(a)continue;if(t&&o===`{`)Ym(e,i,!0);else if(t&&o===`(`&&e[i+1]===`?`)throw new D(`feature`,`regex extension`,`grep: ECMAScript group extensions are not supported in ERE`)}}}function oh(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`&&/[1-9]/u.test(e[++t]??``))return!0;return!1}function sh(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];if(r===`\\`)n++;else if(t)r===`]`&&(t=!1);else if(r===`.`||r===`[`&&(t=!0,e[n+1]===`^`))return!0}return!1}function ch(e,t,n=P){let r=Ln(n),i=[],a=t.has(`x`),o=t.has(`w`)&&!a;if(t.has(`P`)&&new Set(e).size>1)return{error:C(`grep: -P only supports a single pattern`,2)};for(let n of e){let e=!t.has(`F`)&&!t.has(`P`);e&&ah(n,t.has(`E`),r.multibyte);let s=e&&oh(n),c=t.has(`i`)&&!t.has(`P`)&&!s,l=t.has(`i`)&&!c?`isu`:`su`,u;if(t.has(`F`))u=c?sm(n,r):RegExp.escape(n);else if(t.has(`P`))u=Pm(n);else if(t.has(`E`))u=Bm(c?om(n,r):n,r);else{let e=tm(c?om(n,r):n,r);if(e.error)return{error:C(`grep: ${e.error}`,2)};u=e.source}let d=u;if(e&&rm(d))return{error:T(`feature`,`grep`,`conditional backreference`,`grep: backreferences with conditional or repeated-empty captures are not supported`,2)};o&&(u=`(?<!${r.assertions().word})(?:${u})(?!${r.assertions().word})`),a&&(u=`^(?:${u})$`);try{let f=e?ih(u):u,p=new RegExp(ii(e?Um(f,`js`,r):u),l);e&&Object.assign(p,{markedSource:f,tables:r,shape:km(n,s)}),p.pcre=t.has(`P`),p.localeSensitive=p.pcre?t.has(`i`)||o||Hm(d)||/\\[dD]/u.test(d):t.has(`i`)&&s,p.folded=c,p.extendedC=c&&On.test(n),p.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(n),p.wellFormed=n.isWellFormed(),p.emptyWord=o&&!p.pcre&&new RegExp(e?Um(ih(d),`js`,r):d,l).test(``),p.anyCharacter=sh(d);let m=vm(n,t);if(m?.isWellFormed()&&(c||!t.has(`i`))&&(p.literal={pattern:m,tables:r}),t.has(`o`)&&e&&!a){if(o||/\\[1-9]|\(\?/u.test(u))return{error:T(`feature`,`grep`,`-o regex extent`,`grep: only-matching with backreferences, lookarounds or word constraints is not supported`,2)};try{p.extent=new Yp(Um(u,`extent`,r),!1,null,r)}catch{return{error:T(`feature`,`grep`,`-o regex extent`,`grep: POSIX match extent for this pattern is not supported`,2)}}}i.push(p)}catch(e){return!t.has(`P`)&&lh(d,t)?{error:T(`feature`,`grep`,`GNU regex syntax`,`grep: this GNU regular expression cannot be represented by the JavaScript matcher`,2)}:{error:C(`grep: invalid pattern (${t.has(`F`)?`fixed-string /${l}`:t.has(`P`)?`PCRE subset /${l}`:t.has(`E`)?`ERE / ECMAScript /${l}`:`BRE /${l}`}): ${e.message}`,2)}}}return{res:i}}function lh(e,t){if(!t.has(`E`)&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return Fp(Um(e,`extent`)),!0}catch(e){return!!e.gap}}function uh(e,t,n=P,r=!1){let i=(e,t)=>T(`feature`,`grep`,e,`grep: ${t}`,2);if(e.marked){if(t.some(e=>e.pcre))return i(`binary input`,`PCRE matching over bytes that spell no text is not supported`);if(t.some(e=>!e.wellFormed))return i(`unpaired surrogate`,`a pattern holding an unpaired UTF-16 surrogate cannot be matched against bytes`)}if(t.some(e=>e.emptyWord)&&Mm(Ln(n)).test(e.content))return i(`empty word match`,`-w with a pattern that can match nothing, over non-ASCII text that is not word characters, is not supported`);let a=e.marked?t.filter(e=>e.shape&&(e.shape.wordEdge||e.shape.dot||e.shape.negated)):[],o=a.length?Om(e.content):null;if(a.some(e=>Am(e.shape,o,r)))return i(`binary input`,`matching this pattern beside bytes glibc reads as a character is not supported`);let s=()=>t.some(e=>e.unicodePattern)||/[\u0080-\u{10FFFF}]/u.test(e.content);if(n!==P&&t.some(e=>e.localeSensitive||e.folded||e.anyCharacter)&&s())return i(`locale`,`matching non-ASCII text in the ${n} locale is not supported`);if(t.some(e=>e.extendedC)||t.some(e=>e.folded)&&On.test(e.content))return i(`locale-sensitive regex`,`case-insensitive matching over Cyrillic Extended-C letters is not supported`);let c=t.filter(e=>e.localeSensitive);return c.length===0||!s()?null:i(`non-ASCII regex semantics`,`${c.some(e=>e.pcre)?`PCRE matching`:`case-insensitive matching with backreferences`} on non-ASCII input is not supported`)}var dh=/[*?[]/u,fh=/\P{ASCII}/u,ph=/[.+*?^${}()|[\]\\/]/u;function mh(e,t={}){try{return hh(e,t)}catch(e){throw e instanceof D?e:new D(`feature`,`glob pattern`,`unsupported glob pattern: ${e.message}`)}}function hh(e,t){let n=`^`,r=!1;for(let i=0;i<e.length;i++){let a=e[i];if(a===`\\`&&i+1<e.length){let r=e[i+1];n+=gh(r,t.ignoreCase),i++}else if(a===`*`){for(;e[i+1]===`*`;)i++;n+=`.*`}else if(a===`?`)n+=`.`;else if(a===`[`){let a=yh(e,i,t);if(a?.voided)return/^(?!)$/u;a?(n+=a.source,i=a.end,r||=a.nonAsciiRange):n+=`\\[`}else n+=gh(a,t.ignoreCase)}return vh(RegExp(n+`(?![\\s\\S])`,`us`),e,t,r)}function gh(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:ph.test(e)?`\\`+e:e}function _h(e,t,n){let r=RegExp(`[${e}]`,`ui`),i=RegExp(`[${t}]`,`u`),a=``;for(let e=0;e<128;e++){let t=String.fromCodePoint(e);(r.test(t)||i.test(t))&&(a+=`\\x`+e.toString(16).padStart(2,`0`))}return`[${n?`^`:``}${a}]`}function vh(e,t,n,r){let i=/[?[]/u.test(t),a=fh.test(t);return{test(t){if(r||n.ignoreCase&&a||(i||n.ignoreCase)&&fh.test(t))throw new D(`feature`,`non-ASCII glob matching`,`locale-dependent glob matching of non-ASCII names is not supported`);return e.test(t)}}}function yh(e,t,n){let{ignoreCase:r}=n,i=t+1,a=!1;(e[i]===`!`||e[i]===`^`)&&(a=!0,i++);let o=``,s=``,c=!1,l=!1,u=!1,d=!1,f=``,p=0,m=``,h=0;for(e[i]===`]`&&(o+=`\\]`,i++,c=!0,f=`]`);i<e.length&&e[i]!==`]`;i++){let t=e[i];if(t===`[`&&(e[i+1]===`.`||e[i+1]===`=`))throw new D(`feature`,`glob collating or equivalence class`,`glob collating symbols and equivalence classes are not supported`);if(t===`[`&&e[i+1]===`:`){let t=n.bash?bh(e,i):un(e,i,{unknown:`empty`});if(t){if(!n.bash&&t.body===``)throw new D(`feature`,`glob character class`,`unknown POSIX classes in command filename patterns are not supported`);l&&(d=!0),r?s+=t.body:o+=t.body,i=t.end-1,c=!1,l=!1;continue}if(n.bash)continue}if(t===`-`&&c)h=p,m=f,o+=`-`,l=!0,c=!1;else{let n=t===`\\`&&i+1<e.length?e[++i]:t;p=o.length,f=n,l&&fh.test(m+n)&&(u=!0),l&&n.codePointAt(0)<m.codePointAt(0)?o=o.slice(0,h):o+=/[\]\\^[-]/u.test(n)?`\\${n}`:n,c=!l,l=!1}}return i>=e.length?null:d?{voided:!0,end:i}:{source:r?_h(o,s,a):`[${a?`^`:``}${o}]`,end:i,nonAsciiRange:u}}function bh(e,t){let n=e.indexOf(`:]`,t+2);if(n===-1)return null;let r=e.slice(t+2,n).replace(/\\([\s\S]|$)/gu,`$1`);return{body:r===`ascii`?`\\x00-\\x7F`:an[r]??``,end:n+2}}function xh(e,t){return mh(t).test(e)}function Sh(e){let{value:t,mask:n}=e;if(n===null)return dh.test(t);for(let e=0;e<t.length;e++)if(n[e]===`0`&&dh.test(t[e]))return!0;return!1}function Ch(e){let t=t=>!e.mask||e.mask[t]===`0`;for(let n=0;n<e.value.length;n++){let r=e.value[n];if(t(n)){if(r===`\\`)n++;else if(r===`[`)n=wh(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]===`(`&&t(n+1))return!0}}return!1}function wh(e,t,n){let{value:r}=e,i=t+1;for(/[!^]/u.test(r[i])&&n(i)&&i++,r[i]===`]`&&n(i)&&i++;i<r.length;i++)if(n(i)){if(r[i]===`\\`)i++;else{if(r[i]===`]`)return i;if(r[i]===`[`&&/[.:=]/u.test(r[i+1])&&n(i+1)){let e=r.indexOf(r[i+1]+`]`,i+2);e!==-1&&(i=e+1)}}}return t}var Th=/[*?[\]^!\\:.=-]/u;function Eh(e){let{value:t,mask:n}=e;if(n===null)return t;let r=``;for(let e=0;e<t.length;e++){let i=t[e];r+=n[e]!==`0`&&Th.test(i)?`\\`+i:i}return r}function Dh(e,t){let n=Eh(e),r=n.match(/[^/]+|\/+/gu)??[],i=Hn(),a=new Set,o=[{path:``,marks:null}],s;try{for(let e=0;e<r.length;e++){let n=r[e];o=n.startsWith(`/`)||!dh.test(n)?o.map(e=>({...e,path:e.path+kh(n)})):Ah(o,n,e===r.length-1,t,a)}let e=o.filter(e=>j(t.cwd,e.path,t.fs,{follow:!1}).path!==null);for(let t of e)for(let e of t.marks??[])i.add(e);return s=e.filter(e=>e.marks===null).map(e=>e.path).sort(N),s}finally{if(s===void 0)for(let e of a)i.add(e);i.emit(t.notes,`glob`,``,` while expanding ${JSON.stringify(n)}`),s?.length===0&&r.some(Oh)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function Oh(e){for(let t=0;t<e.length;t++)if(e[t]===`\\`)t++;else{if(e[t]===`*`||e[t]===`?`)return!0;if(e[t]===`[`)try{if(yh(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var kh=e=>e.replace(/\\(.)/gu,`$1`);function Ah(e,t,n,r,i){let a=mh(t,{bash:!0}),o=t.startsWith(`.`)||t.startsWith(`\\.`),s=[];for(let t of e){let e=j(r.cwd,t.path||`.`,r.fs).path;if(!r.fs.isDir(e))continue;let{dirs:c,files:l,links:u}=r.fs.listDir(e),d=n?u:u.filter(t=>r.fs.isDir(j(e,t,r.fs).path));for(let r of n?[...c,...l,...d]:[...c,...d]){let n=!o&&r.startsWith(`.`);if(!n&&t.marks===null)a.test(r)&&s.push({path:t.path+r,marks:null});else if(jh(a,r)){if(!n){s.push({path:t.path+r,marks:t.marks});continue}let a=A(e,r);i.add(a),s.push({path:t.path+r,marks:[...t.marks??[],a]})}}}return s}function jh(e,t){try{return e.test(t)}catch{return!0}}var Mh=(e,t)=>e.some(e=>e.test(t)),Nh=()=>({stdout:``,stderr:``,exitCode:1}),Ph=e=>e.failure!==void 0,Fh=e=>e.name??`(standard input)`,Ih=e=>e.binaryLine===void 0?e.content:e.content.replaceAll(`\0`,`
147
+ `),Lh=(e,t)=>t.map(e.marked?Km:Gm);function Rh(e,t,n,r){if(r===0)return 0;let i=Lh(e,t),a=Ih(e),o=0;if(r===1/0){for(let e of Xn(a))Mh(i,e)!==n&&o++;return o}let s=0;for(;s<a.length&&o<r;){let e=a.indexOf(`
148
+ `,s);e<0&&(e=a.length),Mh(i,a.slice(s,e))!==n&&o++,s=e+1}return o}function zh(){let e=[],t=(t,n)=>{let r=e.at(-1);r?.fd===t&&r.text!==void 0?r.text+=n:e.push({fd:t,text:n})};return{events:e,out(e){e&&t(1,e)},lines(t,n,r){if(!n||!Ct.test(t))return this.out(t);if(!r.isWellFormed())throw new D(`feature`,`unpaired surrogate`,`unpaired UTF-16 surrogates cannot be encoded as UTF-8`);e.push({fd:1,bytes:Tt(t)})},err(e){e&&t(2,e)}}}function Bh(e,t){let n=t=>e.filter(e=>e.fd===t&&e.text!==void 0).map(e=>e.text).join(``);return{stdout:e.some(e=>e.bytes!==void 0)?``:n(1),stderr:n(2),exitCode:+!t,events:e}}function Vh(e,t,n){let r={used:!1,write:zh(),selected:!1};for(let i of e)Ph(i)?r.write.err(i.failure):Hh(i,t,n,r);return Bh(r.write.events,r.selected)}function Hh(e,t,n,r){if(e.binaryLine===0)return Uh(e,t,n,r);let i=Ih(e),a={input:e,opts:n,run:r,lines:Xn(i),res:t,tests:Lh(e,t),bufbeg:0,name:n.showName??e.recursive?Fh(e):null,out:[],lastout:null,pending:0,outleft:n.max??1/0,quiet:!1,heldBack:!1},o=a.lines.length,s=o>0&&!i.endsWith(`
149
+ `)?o-1:o,c=Gh(a,0,s);if(a.pending>0&&qh(a,s),s<o&&(a.outleft!==0||a.pending!==0)&&!a.quiet){let e=s;for(let t=0;t<n.before&&e>0&&e!==a.lastout;t++)e--;e!==a.lastout&&(a.lastout=null),a.bufbeg=e,a.outleft>0&&(c+=Gh(a,s,o)),a.pending>0&&qh(a,o)}r.write.lines(Qn(a.out),e.marked,a.name??``),c>0&&(r.selected=!0),(a.heldBack||a.quiet)&&Wh(e,n,r)}function Uh(e,t,n,r){Rh(e,t,n.invert,1)!==0&&(r.used=r.selected=!0,Wh(e,n,r))}function Wh(e,t,n){t.binaryFiles===`binary`&&n.write.err(`grep: ${Fh(e)}: binary file matches
150
+ `)}function Gh(e,t,n){let{invert:r}=e.opts,i=e.input.binaryLine??1/0,a=0;for(let o=t;o<n;){let t=o;for(;t<n&&!Mh(e.tests,e.lines[t]);)t++;if(t===n&&!r)break;if(!r||o<t){if(r&&o<i&&t>i){if(a+=Kh(e,o,i),e.outleft===0)break;o=i}if(!e.quiet&&(r?o:t)>=i&&(e.pending>0&&qh(e,i),e.quiet=!0),a+=r?Kh(e,o,t):Kh(e,t,t+1),e.outleft===0||e.quiet)break}o=t+1}return a}function Kh(e,t,n){let{before:r,after:i,hasContext:a,invert:o}=e.opts;!e.quiet&&e.pending>0&&qh(e,t);let s=t;if(!e.quiet){let n=e.lastout??e.bufbeg;for(let e=0;e<r;e++)s>n&&s--;for(a&&e.run.used&&s!==e.lastout&&e.out.push(`--`);s<t;s++)Jh(e,s,!1)}let c;if(o)for(c=0;s<n&&c<e.outleft;c++,s++)e.quiet||Jh(e,s,!0);else e.quiet||Jh(e,t,!0),c=1;return e.pending=e.quiet?0:i,e.run.used=!0,e.outleft-=c,c}function qh(e,t){for(e.lastout??=e.bufbeg;e.pending>0&&e.lastout<t;e.pending--)Jh(e,e.lastout,!1)}function Jh(e,t,n){let r=e.lines[t];if(e.opts.only)n!==e.opts.invert&&Yh(e,r,t,n);else{if(e.input.marked&&e.opts.binaryFiles!==`text`&&Ct.test(r)&&Em(r)){e.heldBack=!0;return}e.out.push(Qh(e,r,t,n))}e.lastout=t+1}function Yh(e,t,n,r){let i=e.input.marked&&Ct.test(t),a=0;for(;a<t.length;){let o=null;for(let n=0;n<e.res.length;n++){let r=Zh(e.res[n],e.tests[n],t,a,i);r&&(!o||r.start<o.start||r.start===o.start&&r.end>o.end)&&(o=r)}if(!o)break;o.end===o.start?a=o.end+ri(t,o.end):(e.out.push(Qh(e,t.slice(o.start,o.end),n,r)),a=o.end)}}var Xh=new WeakMap;function Zh(e,t,n,r,i){if(e.extent)return(i?e.markedExtent??=Sm(e.extent):e.extent).search(n,r);let a=Xh.get(t);a||Xh.set(t,a=new RegExp(t.source,t.flags+`g`)),a.lastIndex=r;let o=a.exec(n);if(o&&o[0]===``&&e.pcre)throw new D(`feature`,`PCRE empty match extent`,`only-matching with empty PCRE matches is not supported`);return o?{start:o.index,end:o.index+o[0].length}:null}function Qh(e,t,n,r){let i=r?`:`:`-`;return(e.name===null?``:e.name+i)+(e.opts.showLine?n+1+i:``)+t}function $h(e,t,{mode:n,invert:r,showName:i,max:a=1/0}){let o=zh(),s=!1,c=n===`c`?a:Math.min(1,a);for(let a of e){if(Ph(a)){o.err(a.failure);continue}let e=Rh(a,t,r,c);e>0&&(s=!0),n===`c`?o.out((i??a.recursive?Fh(a)+`:`+e:String(e))+`
151
+ `):e>0==(n===`l`)&&o.out(Fh(a)+`
152
+ `)}return Bh(o.events,s)}function eg(e,t,n){let r=e.order.filter(e=>[`e`,`f`,`file`].includes(e.name)),i=e.positional;if(r.length===0)return i.length?{patterns:i[0].split(`
153
+ `),rest:i.slice(1),stdin:t}:null;let a=new Set;for(let{name:e,value:i}of r){if(e===`e`){for(let e of i.split(`
154
+ `))a.add(e);continue}let r=nr(`grep`,[i],n,t);if(r.failed)return{error:C(r.stderr,2)};let o=r.inputs[0];for(let e of Xn(o.content))a.add(e);o.shared&&(t=``)}return{patterns:[...a],rest:i,stdin:t}}var tg=`[-i] [-a|-I] [-s] [-v] [-n] [-r|-R] [-w] [-x] [-o] [-E|-F|-G|-P] [-l] [-L] [-c] [-q] [-m N] [-h] [-H] [-A N] [-B N] [-C N] [--include=GLOB] [--exclude=GLOB] [--exclude-dir=GLOB]`,ng=`grep ${tg} PATTERN [PATH...]
155
+ or: grep ${tg} [-e PATTERN] [-f FILE] ... [PATH...]`,rg={short:[`i`,`v`,`n`,`r`,`R`,`l`,`L`,`c`,`w`,`x`,`h`,`H`,`o`,`E`,`F`,`G`,`P`,`q`,`I`,`a`,`s`],long:[`text`,`no-messages`],valueShort:[`A`,`B`,`C`,`m`],repeatable:[`e`,`f`,`file`,`include`,`exclude`,`exclude-dir`]};function ig(e){try{return U(e,rg).flags.has(`q`)}catch{return!1}}function ag(e,t,n){let r;try{r=U(t,rg)}catch(e){return dt(e,`grep`,`grep: ${e.message}`,2)}let{flags:i,values:a}=r,o=eg(r,e,n);if(!o)return lt(ng,2);if(o.error)return o.error;let{patterns:s,rest:c}=o;e=o.stdin;let l=gg(i);if(l)return l;let u;try{u=ch(s,i,n.locale)}catch(e){return dt(e,`grep`,`grep: ${e.message}`,2)}if(u.error)return u.error;let d=vg(a);if(d.error)return d.error;if((d.max===0||_g(s,i))&&(!i.has(`L`)||i.has(`q`)))return Nh();if(d.max!==0&&n.stdinFile&&(i.has(`q`)||i.has(`l`)||i.has(`L`)||a.has(`m`))&&(c.length===0||c.includes(`-`)))return T(`feature`,`grep`,`partial stdin reads`,`grep: early termination on shared file input is not supported`,2);let f=i.has(`r`)||i.has(`R`),p=Cg(r,n),m=r.order.findLast(e=>[`a`,`I`,`text`].includes(e.name))?.name;p.binaryFiles=m===`a`||m===`text`?`text`:m===`I`?`without-match`:`binary`,p.silent=i.has(`s`)||i.has(`no-messages`),p.follow=i.has(`R`);try{return og(e,c,n,f,p,u,i,d)}finally{hg(p,n.notes)}}function og(e,t,n,r,i,a,o,s){if(o.has(`q`))return sg(e,t,n,r,i,a.res,o.has(`v`));let c=bg(r,e,t,n,i);s.max===0&&L(n,e);let l=o.has(`v`),u=[`l`,`L`,`c`].find(e=>o.has(e)),d=c.items;i.name.length>0&&(d=d.filter(e=>Ph(e)||Tg(e,i)));let f=null;if(s.max!==0&&(d=d.flatMap(e=>{if(Ph(e))return[e];let t=cg(e,i,a.res,l,n),r=uh(t,a.res,n.locale,!u&&o.has(`o`))??(u?null:fg(t,a.res,l,s.after)??pg(t,s,o,i,n));return f??=r,r?[]:[t]}),f&&d.every(Ph)))return f;let p={showName:yg(o,t.length),invert:l,showLine:o.has(`n`),only:o.has(`o`),binaryFiles:i.binaryFiles,...s},m;try{m=u?$h(d,a.res,{...p,mode:u}):Vh(d,a.res,p)}catch(e){return e instanceof W&&e.gap?T(`feature`,`grep`,e.gap,`grep: ${e.message}`,2):dt(e,`grep`,`grep: ${e.message}`,2)}if(f){let e=w(f);return E({...m,stderr:m.stderr+f.stderr,exitCode:2,events:[...m.events,{fd:2,text:f.stderr}]},e.kind,e.command,e.detail,e.message)}return c.failed?{...m,exitCode:2}:m}function sg(e,t,n,r,i,a,o){let s=``,c=!1;for(let l of t.length?t.map(e=>[e]):[[]]){let t=bg(r,e,l,n,i);c||=t.failed,(l.includes(`-`)||l.includes(`/dev/stdin`)&&!n.stdinFile)&&(e=``);for(let e of t.items){if(Ph(e)){s+=e.failure;continue}if(!Tg(e,i))continue;let t=cg(e,i,a,o,n),r=uh(t,a,n.locale);if(r)return r.stderr=s+r.stderr,r;if(Rh(t,a,o,1)>0)return{stdout:``,stderr:s,exitCode:0}}}return{stdout:``,stderr:s,exitCode:c?2:1}}function cg(e,t,n,r,i){let a=dg(e,i),o=t.binaryFiles===`without-match`,s=t.binaryFiles===`text`;if(e.content===void 0){if(!r&&dm(e.bytes,n))return{...e,content:``};let i=s?-1:e.bytes.indexOf(0);if(i>=0&&o)return mg(e,t,i>=a);let c={...e,content:yt(e.bytes),marked:!0};return i<0?c:lg(c,e.bytes,i,a)}let c=s?-1:e.content.indexOf(`\0`);if(c<0)return e;let l=b(e.content.slice(0,Math.min(c,a)));return o?mg(e,t,l.length>=a):lg(e,l,l.length,a)}function lg(e,t,n,r){if(n<r)return{...e,binaryLine:0};let i=e.content.lastIndexOf(`
156
+ `,e.content.indexOf(`\0`))+1;return{...e,lineStart:i,readLines:Zn(t.subarray(0,r)),binaryLine:Zn(e.content.slice(0,i))}}var ug=e=>e.name===null||e.name===`/dev/stdin`,dg=(e,t)=>ug(e)&&!t.stdinFile?65536:98304;function fg(e,t,n,r){if(e.readLines===void 0)return null;let i=Xn(e.content.slice(0,e.lineStart)),a=Lh(e,t),o=(e,t)=>i.slice(e,t).some(e=>Mh(a,e)!==n);return!o(e.readLines)&&!(r>0&&o(Math.max(0,e.readLines-r),e.readLines))?null:T(`feature`,`grep`,`late binary detection`,`grep: binary detection after the initial input buffer is not supported`,2)}function pg(e,t,n,r,i){return!e.marked||e.binaryLine!==void 0||!t.hasContext||n.has(`o`)||r.binaryFiles===`text`||e.bytes.length<=dg(e,i)?null:T(`feature`,`grep`,`binary context across reads`,`grep: context around lines held back past the first read is not supported`,2)}function mg(e,t,n){if(n)throw new D(`feature`,`late binary detection`,`grep: binary detection after the initial input buffer is not supported`);let r=ug(e)?t.stdinPath:A(t.cwd,e.name);return r?t.binary.add(r):t.binaryStdin=!0,{...e,content:``}}function hg(e,t){let n=`Binary input is treated as text with -a.`;Jn(t,{command:`grep`,action:`skipped`,noun:[`binary file`,`binary files`],paths:e.binary,explanation:n}),e.binaryStdin&&t.add(`grep: skipped binary standard input. `+n),Jn(t,{command:`grep`,action:`excluded`,noun:[`entry`,`entries`],paths:e.excluded,context:` by --include/--exclude/--exclude-dir rules`})}function gg(e){if(e.has(`h`)&&e.has(`H`))return T(`option`,`grep`,`-h -H`,`grep: combining -h and -H is not supported`);let t=[`l`,`L`,`c`].filter(t=>e.has(t));if(t.length>1)return T(`option`,`grep`,`combined output modes`,`grep: ${t.map(e=>`-${e}`).join(` / `)} are mutually exclusive`);let n=[`E`,`F`,`G`,`P`].filter(t=>e.has(t));return n.length>1?C(`grep: ${n.map(e=>`-${e}`).join(` / `)} are mutually exclusive`,2):null}function _g(e,t){return e.length===0?!t.has(`v`):t.has(`v`)&&!t.has(`x`)&&!t.has(`w`)&&e.every(e=>e===``)}function vg(e){let t={A:0,B:0,m:void 0};for(let n of[`C`,`A`,`B`,`m`]){if(!e.has(n))continue;let r=fr(e.get(n),`grep: -`+n);if(r.error)return n===`m`&&(r.error.exitCode=2),r;n===`C`?t.A=t.B=r.value:t[n]=r.value}return{after:t.A,before:t.B,max:t.m,hasContext:[`A`,`B`,`C`].some(t=>e.has(t))}}function yg(e,t){return e.has(`h`)?!1:e.has(`H`)||t>1?!0:void 0}function bg(e,t,n,r,i){let a=e=>i.silent?[]:[{failure:e}];if(!e){let e=sr(`grep`,n,t,r,{read:`maybe-text`});return{items:e.entries.flatMap(e=>e.kind===`file`?[e.name===`-`?{...e,name:null}:e]:a(e.failure)),failed:e.failed}}let o=[],s=!1,c=e=>{o.push(...a(e)),s=!0};for(let e of n.length?n:[`.`]){if(e===`-`||e===`/dev/stdin`||e===`/dev/null`){let n=nr(`grep`,[e],r,t);o.push(...n.inputs.map(t=>({...t,name:e===`-`?null:e}))),(e===`-`||e===`/dev/stdin`)&&(t=``);continue}let{path:a,error:s}=F(r,`grep`,e);if(r.fs.isFile(a)){o.push({name:e,...Sg(r,a)});continue}if(s){c(`grep: ${e}: ${s}
157
+ `);continue}if(Dg(e,i.dir)){i.excluded.add(a);continue}let l=e=>e===a||i.dir.length===0||!wg(i.dir,Pt(e))||(i.excluded.add(e),!1);for(let t of zt(r.fs,a,1/0,l)){if(t.kind===`link`){if(!i.follow)continue;let s=xg(t.path,Og(n.length?e:``,a,t.path),r,i);s?.input&&o.push(s.input),s?.error&&c(s.error);continue}if(t.kind!==`file`)continue;let s=t.path;o.push({name:Og(n.length?e:``,a,s),...Sg(r,s),recursive:!0})}}return{items:o,failed:s}}function xg(e,t,n,r){let i=j(n.cwd,e,n.fs),a=n.fs.isDir(i.path);if(!(a?r.dir.length===0||!wg(r.dir,Pt(e)):Eg(Pt(e),r.name)))return r.excluded.add(e),null;if(a)throw new D(`option`,`-R`,`following a symbolic link to a directory is not supported: ${t}`);return i.error?{error:`grep: ${t}: ${i.error}
158
+ `}:{input:{name:t,...Sg(n,i.path),recursive:!0}}}function Sg(e,t){let{text:n,bytes:r}=or(e.fs,t);return n===void 0?{content:void 0,bytes:r}:{content:n}}function Cg(e,t){return{name:e.order.filter(e=>e.name===`include`||e.name===`exclude`).map(e=>({include:e.name===`include`,re:mh(e.value)})),dir:(e.values.get(`exclude-dir`)??[]).map(e=>mh(e)),binary:new Set,excluded:new Set,cwd:t.cwd,stdinPath:t.stdinHandle?.path}}function wg(e,t){return e.some(e=>e.test(t))}function Tg(e,t){return e.name===null||Eg(Pt(e.name),t.name)?!0:(t.excluded.add(A(t.cwd,e.name)),!1)}function Eg(e,t){if(t.length===0)return!0;let n=null;for(let r of t)r.re.test(e)&&(n=r);return n?n.include:!t[0].include}function Dg(e,t){return t.length===0||e.endsWith(`/`)?!1:wg(t,e.slice(e.lastIndexOf(`/`)+1))}function Og(e,t,n){let r=It(t,n);return e===``?r:e.endsWith(`/`)?e+r:e+`/`+r}var kg=(e,t)=>T(`feature`,`rg`,e,`rg: ${t}`,2);function Ag(e,t,n){let r=w(e)??e.note;return r?T(r.kind,`rg`,r.detail,t,2):T(n,`rg`,e.detail??t.replace(/^rg: /u,``),t,2)}function jg(e,t,n){let r,i;try{i=U(t,cp),r=fp(i)}catch(e){return Ag(e,e.message.startsWith(`rg: `)?e.message:`rg: ${e.message}`,`option`)}let a=[...i.positional];if(!r.patterns.length){if(!a.length)return kg(`usage`,`a pattern is required`);r.patterns.push(a.shift())}try{yp(r.patterns,r.literal)}catch(e){return Ag(e,e.message,`feature`)}let o=!a.length&&n.stdinPiped?{roots:[],recursive:!1,stdin:!0}:Ig(a,n,r.hidden);if(o.error)return o.error;if(!i.flags.has(`no-ignore`)&&!r.unrestricted&&o.recursive){let e=Lg(o.roots,n);if(e)return kg(`ignore rules`,`${JSON.stringify(e)} would change which files are searched, and its rules are not implemented`)}let s=Mg(a,o,r,n),c=r.text?null:zg(a,n);if(c)return kg(`named binary file`,`${JSON.stringify(c)} is binary, and reporting a binary match is not supported`);let l=Ng(s,r,n)??(o.stdin?Fg(r,n):null);return l?kg(l.detail,l.message):(o.stdin||a.length?1:s.length)===0?{stdout:``,exitCode:2,stderr:`rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
159
+ Running with --debug will show why files are being skipped.
160
+ `}:Bg(e,r,a,o,n)}function Mg(e,t,n,r){let i=e.map(e=>j(r.cwd,e,r.fs).path).filter(Boolean).map(e=>({path:e,named:!0}));for(let e of t.roots)for(let t of zt(r.fs,e)){if(t.kind!==`file`)continue;let r=It(e===`/`?`/`:e,t.path).split(`/`);(n.hidden||r.every(e=>!e.startsWith(`.`)))&&i.push({path:t.path,named:!1})}return i}function Ng(e,t,n){for(let{path:r,named:i}of e){if(n.fs.isDir(r))continue;let{text:e,bytes:a}=or(n.fs,r);if(e!==void 0&&!e.startsWith(``)||(a===void 0?e.includes(`\0`):a.includes(0))&&!i&&!t.text)continue;let o=JSON.stringify(It(n.cwd===`/`?`/`:n.cwd,r)||r);if(e===void 0){let e=Pg(a,o,t,n);if(e)return e}else if(e.startsWith(``))return{detail:`byte-order mark`,message:`${o} begins with a byte-order mark, which ripgrep strips before matching`}}return null}function Pg(e,t,n,r){return!n.invert&&!n.ignoreCase&&fm(e,n.patterns,n.literal,r.locale)?null:{detail:`unreadable bytes`,message:`${t} holds bytes that are not text, and searching them is not supported`}}function Fg(e,t){let n=t.stdinBytes;return!n||!e.text&&n.includes(0)||vt(n)!==void 0?null:Pg(n,ur(null,t),e,t)}function Ig(e,t,n){let r=[],i=!1;for(let n of e){let e=j(t.cwd,n,t.fs);e.path!==null&&t.fs.isDir(e.path)&&r.push(e.path),n.split(`/`).some(e=>e.startsWith(`.`)&&e!==`.`&&e!==`..`)&&(i=!0)}e.length||r.push(t.cwd);let a=r.length>0;return!n&&a&&i&&e.length?{error:kg(`named hidden path`,`a hidden path named beside a directory is searched by ripgrep but skipped while walking, and both cannot apply at once`)}:{roots:r,recursive:a}}function Lg(e,t){let n=e=>It(t.cwd===`/`?`/`:t.cwd,e)||e,r=(n,r=!0)=>{for(let i of e){for(let e of zt(t.fs,i))if(Pt(e.path)===n&&Rg(e.path,r,t))return e.path;for(let e=i;e!==`/`;e=M(e)){let i=j(M(e),n,t.fs);if(i.path!==null&&Rg(i.path,r,t))return i.path}}return null},i=r(`.ignore`)??r(`.rgignore`);if(i)return n(i);let a=r(`.git`,!1);if(!a)return null;let o=j(a,`info/exclude`,t.fs).path,s=o!==null&&Rg(o,!0,t)?o:null,c=r(`.gitignore`)??s;return c?n(c):null}function Rg(e,t,n){if(!t||n.fs.isDir(e))return!0;let r=j(`/`,e,n.fs).path,{text:i}=or(n.fs,r??e);return(i??` `).split(`
161
+ `).some(e=>e.trim()!==``&&!e.trimStart().startsWith(`#`))}function zg(e,t){for(let n of e){let e=j(t.cwd,n,t.fs);if(e.path===null||t.fs.isDir(e.path))continue;let{text:r,bytes:i}=or(t.fs,e.path);if(i===void 0?r?.includes(`\0`):i.includes(0))return n}return null}function Bg(e,t,n,r,i){let a=t.literal?[`-F`]:[`-P`];t.ignoreCase&&a.push(`-i`),t.lineNumbers&&a.push(`-n`),t.word&&a.push(`-w`),t.invert&&a.push(`-v`),t.quiet&&a.push(`-q`),t.mode&&a.push(`-`+t.mode),t.showName&&a.push(`-`+t.showName),a.push(t.text?`-a`:`-I`),t.after&&a.push(`-A`,String(t.after)),t.before&&a.push(`-B`,String(t.before)),r.recursive&&a.push(`-r`),r.recursive&&!t.hidden&&a.push(`--exclude=.*`,`--exclude-dir=.[!.]*`,`--exclude-dir=..?*`),a.push(...gp(t.patterns,t.literal)),r.stdin||a.push(`--`,...n.length?n:[`.`]);let o=new Set(i.notes),s=ag(e,a,i);return delete s.events,Kg(i.notes,o,r),Gg(Vg(s,t),n,t.patterns)}function Vg(e,t){if(t.mode!==`c`)return e;let n=e.stdout.split(`
162
+ `).filter(e=>e!==``&&e!==`0`&&!e.endsWith(`:0`));return{...e,stdout:n.length?n.join(`
163
+ `)+`
164
+ `:``}}var Hg=new Map([[`No such file or directory`,2],[`Not a directory`,20],[`Is a directory`,21]]),Ug=e=>e.replaceAll(/^(rg: .*: )([A-Z][a-z].*)$/gmu,(e,t,n)=>Hg.has(n)?`${t}${n} (os error ${Hg.get(n)})`:e),Wg=/^rg: (?:invalid pattern[^\n]*|trailing backslash)$/mu;function Gg(e,t,n){let r=e=>t.length?e:e.replaceAll(/^\.\//gmu,``),i={...e,stdout:r(e.stdout),stderr:Ug(r(e.stderr).replaceAll(/^grep: /gmu,`rg: `))},a=w(e);return a?.detail===`non-ASCII regex semantics`?T(`feature`,`rg`,`non-ASCII matching`,`rg: Unicode-aware matching on non-ASCII input is not supported`,2):a?T(a.kind,`rg`,a.detail,i.stderr.trimEnd()||a.message,e.exitCode):Wg.test(i.stderr)?T(`feature`,`rg`,`regex parse error`,`rg: regex parse error in ${JSON.stringify(n.join(` `))}; the reason ripgrep gives is not reproduced here`,2):i}function Kg(e,t,n){let r=[];for(let n of e)!t.has(n)&&n.startsWith(`grep: excluded `)&&r.push(n);for(let t of r)e.delete(t),n.recursive&&e.add(t.replace(/^grep: excluded (\d+) (entry|entries) by --include\/--exclude\/--exclude-dir rules/u,`rg: skipped $1 hidden $2`).replace(/\.$/u,`. Hidden entries are searched with --hidden.`))}var qg=6,Jg=` `,Yg=` `.repeat(qg+Jg.length);function Xg(e,t,n){let{values:r,positional:i,order:a}=U(t,{valueShort:[`b`,`v`],valueLong:[`starting-line-number`]}),o=r.get(`b`)??`t`;if(![`a`,`t`,`n`].includes(o)){let e=`nl: -b: only \`a\`, \`t\` and \`n\` are supported (got \`${o}\`)`;return o.startsWith(`p`)?T(`option`,`nl`,`-b p`,e):C(e)}let s=1n;for(let{name:e,value:t}of a)if((e===`v`||e===`starting-line-number`)&&(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(t)||(s=BigInt(t),s<zn||s>Rn)))return C(`nl: invalid starting line number: ${t}`);let c=sr(`nl`,i,e,n);if(c.inputs.some(({content:e})=>/(?:^|\n)(?:\\:){1,3}(?:\n|$)/u.test(e)))return T(`feature`,`nl`,`logical pages`,`nl: logical page delimiters are not supported`);let l=[];for(let{content:e}of c.inputs)for(let t of Xn(e))if(o===`a`||o===`t`&&t!==``){if(s>Rn)return{stdout:Qn(l),stderr:c.stderr+`nl: line number overflow
165
+ `,exitCode:1};l.push(`${String(s).padStart(qg)}${Jg}${t}`),s++}else l.push(Yg+t);return R(Qn(l),c)}function Zg(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`s`],valueShort:[`d`,`f`,`c`]}),o=i.has(`f`),s=i.has(`c`);if(o===s)return lt(`cut -f LIST [-d DELIM] [-s] [file...] | cut -c LIST [file...]`);if(s&&i.has(`d`))return C(`cut: -d is only valid with -f`);if(s&&r.has(`s`))return C(`cut: -s is only valid with -f`);let c=t_(o?i.get(`f`):i.get(`c`),o?`field`:`position`);if(c.error)return c.error;let l=i.get(`d`)===``?`\0`:i.get(`d`)??` `;if(o&&b(l).length!==1)return C(`cut: -d delimiter must be a single byte`);let u=sr(`cut`,a,e,n),d=[];for(let{content:e}of u.inputs)for(let t of o&&l===`
166
+ `?e===``?[]:[e]:Xn(e))o&&!t.includes(l)?r.has(`s`)||d.push(t):d.push(o?r_(t,l,c.ranges):Qg(t,c.ranges));return R(Qn(d),u)}function Qg(e,t){let n=b(e);return k(Uint8Array.from(n_(n,t)))}var $g={field:{zero:`fields are numbered from 1`,range:`invalid field range`,value:e=>`invalid field value '${e}'`,large:e=>`field number '${e}' is too large`},position:{zero:`byte/character positions are numbered from 1`,range:`invalid byte or character range`,value:e=>`invalid byte/character position '${e}'`,large:e=>`byte/character offset '${e}' is too large`}},e_=/^(\d*)(-?)(\d*)/u;function t_(e,t){let n=$g[t],r=e=>({error:C(`cut: ${e}`)}),i=[];for(let t of e.split(/[, \t]/u)){if(t===``)return r(n.zero);let[e,a,o,s]=e_.exec(t),c=t.slice(e.length);if(c!==``)return r(c.startsWith(`-`)?n.range:n.value(c));for(let e of[a,s])if(e!==``&&BigInt(e)>Bn)return r(n.large(e));if(a===``&&s===``&&o===``)return r(n.value(t));let l=a===``?1:Number(a),u=o===``?l:s===``?1/0:Number(s);if(l<1)return r(n.zero);if(u<l)return r(`invalid decreasing range`);i.push([l,u])}i.sort((e,t)=>e[0]-t[0]);let a=[];for(let e of i){let t=a.at(-1);t&&e[0]<=t[1]+1?t[1]=Math.max(t[1],e[1]):a.push(e)}return{ranges:a}}function n_(e,t){return t.flatMap(([t,n])=>Array.from(e.slice(t-1,n)))}function r_(e,t,n){return n_(t===`
167
+ `?Xn(e):e.split(t),n).join(t)}function i_(e,t,n){let{flags:r,positional:i}=U(t,{short:[`c`,`d`,`s`]}),a=r.has(`d`),o=r.has(`s`),s=r.has(`c`);if(a&&o)return T(`option`,`tr`,`-d -s`,`tr: -d combined with -s is not supported`);if(o&&!a&&i.length===2)return T(`feature`,`tr`,`translate and squeeze`,`tr: combined translation and squeezing is not supported`);let c=a||o?1:2;if(i.length!==c)return lt(`tr [-c] SET1 SET2 | tr [-c] -d SET | tr [-c] -s SET`);if(/\P{ASCII}/u.test(e+i.join(``)))return T(`feature`,`tr`,`non-ASCII bytes`,`tr: translation of non-ASCII bytes is not supported`);if(i.some(e=>/\[[.=]/u.test(e)))return T(`feature`,`tr`,`set expressions`,`tr: equivalence classes and collating symbols are not supported`);if(i.some(e=>/\[[^\]]*\*/u.test(e)))return T(`feature`,`tr`,`repeat expressions`,`tr: repetition expressions in a set are not supported`);if(i.some(e=>/\\[0-7]{2}|\\[1-7abfrv]/u.test(e)))return T(`feature`,`tr`,`set escapes`,`tr: these set escape sequences are not supported`);if(i.some(e=>/(?:^|[^\\])(?:\\\\)*\\$/u.test(e)))return T(`feature`,`tr`,`trailing backslash`,`tr: an unescaped trailing backslash in a set is not supported`);let l=l_(i[0]);if(l.error)return l.error;let u=new Set(l.chars),d=e=>s!==u.has(e);if(a)return L(n),S([...e].filter(e=>!d(e)).join(``));if(o)return L(n),S(u_(e,d));let f=l_(i[1]);if(f.error)return f.error;let p=c_(l,f,s);if(p)return p;if(f.chars.length===0)return C(`tr: when not truncating set1, string2 must be non-empty`);L(n);let m=s?Array.from({length:256},(e,t)=>String.fromCodePoint(t)).filter(e=>!u.has(e)):l.chars,h=new Map,g=f.chars.at(-1);for(let e=0;e<m.length;e++)h.set(m[e],f.chars[e]??g);return S([...e].map(e=>h.get(e)??e).join(``))}var a_=Object.freeze(Object.fromEntries(Object.entries(on).filter(([e])=>e!==`word`).map(([e,t])=>[e,t.flatMap(([e,t])=>Array.from({length:t-e+1},(t,n)=>String.fromCodePoint(e+n)))]))),o_={__proto__:null,lower:`upper`,upper:`lower`};function s_(e,t){if(e[t]!==`[`||e[t+1]!==`:`)return null;let n=e.indexOf(`:]`,t+2);return n<0?null:{name:e.slice(t+2,n),next:n+2,text:e.slice(t,n+2)}}function c_(e,t,n){if(t.classes.find(e=>o_[e.name]===void 0))return C(`tr: when translating, the only character classes that may appear in
168
+ string2 are 'upper' and 'lower'`);let r=t=>e.classes.some(e=>e.name===o_[t.name]&&e.start===t.start&&e.end===t.end);return!n&&t.classes.find(e=>!r(e))?C(`tr: misaligned [:upper:] and/or [:lower:] construct`):t.classes.some(e=>e.end===t.chars.length)&&(n||e.chars.length>t.chars.length)?C(`tr: when translating with string1 longer than string2,
169
+ the latter string must not end with a character class`):n&&e.classes.length>0&&t.chars.length!==1?C(`tr: when translating with complemented character classes,
170
+ string2 must map all characters in the domain to one`):null}function l_(e){let t=[],n=[],r=0,i=()=>{if(e[r]!==`\\`)return e[r++];if(r+1>=e.length)return null;let t=e[r+1];return r+=2,t===`n`?`
171
+ `:t===`t`?` `:t===`\\`?`\\`:t===`0`?`\0`:t};for(;r<e.length;){let a=s_(e,r);if(a){if(a.name===``)return{error:C(`tr: missing character class name '${a.text}'`)};let e=a_[a.name];if(e===void 0)return{error:C(`tr: invalid character class '${a.name}'`)};n.push({name:a.name,start:t.length,end:t.length+e.length}),t.push(...e),r=a.next;continue}let o=i();if(e[r]===`-`&&r+1<e.length){r++;let e=i();if(e===null)return{error:C(`tr: trailing backslash in set`)};let n=o.codePointAt(0),a=e.codePointAt(0);if(a<n)return{error:C(`tr: range-endpoints of '${o}-${e}' are in reverse collating sequence order`)};for(let e=n;e<=a;e++)t.push(String.fromCodePoint(e))}else t.push(o)}return{chars:t,classes:n}}function u_(e,t){let n=``,r=null;for(let i of e)t(i)&&i===r||(n+=i,r=i);return n}var d_=e=>e.text??k(e.bytes),f_=(e,t)=>{e.bytes===void 0?t.write(e.text):t.writeBytes(e.bytes)},p_=e=>e.events??[...e.stdout?[{fd:1,text:e.stdout}]:[],...e.stderr?[{fd:2,text:e.stderr}]:[]],m_=e=>e.unordered??(!e.events&&e.stdout!==``&&e.stderr!==``),G=(e=``)=>({stdout:``,stderr:e,exitCode:0,ignored:!1,events:e?[{fd:2,text:e}]:[],unordered:!1});function K(e,t){e.stdout+=t.stdout,e.stderr+=t.stderr,e.exitCode=t.exitCode,e.ignored=t.ignored??!1,e.events.push(...p_(t)),e.unordered||=m_(t)}function h_(e,t){t&&K(e.expansionOutput,g_(G(t),{fds:e.expansionFds},e))}function g_(e,t,n){let r=r=>__(e,t,n,r);return n.io?n.io.output(e,t,r):r(f_)}function __(e,t,n,r){let i=e,a=t.fds[1],o=t.fds[2];(a===o&&a!==`null`&&a!==`closed`||(a?.identity&&o?.identity?a.identity===o.identity:a?.path&&a.path===o?.path))&&m_(i)&&(i=T(`feature`,null,`combined output ordering`,`error: merging this command’s stdout and stderr in order is not supported`),n.unsupported.add(w(i)));let s=[],c=``,l=``;for(let e of p_(i)){let i=t.fds[e.fd];if(typeof i==`object`){r(e,i);continue}if(t.deferred?.[e.fd]&&e.bytes!==void 0){s.push(e);continue}if(i!==`out`&&i!==`err`){e.fd===2&&Wn(n,d_(e));continue}let a=d_(e);s.push({fd:i===`out`?1:2,text:a}),i===`out`?l+=a:c+=a}return{...i,stdout:l,stderr:c,events:s,unordered:m_(i)&&l!==``&&c!==``}}var v_=new Map([[`ls`,2],[`grep`,2],[`egrep`,2],[`fgrep`,2],[`sort`,2],[`xxd`,3],[`sed`,4],[`diff`,2],[`patch`,2],[`xargs`,123],[`hexdump`,0],[`tree`,0],[`zip`,0],[`unzip`,0]]),y_=e=>e.stdout!==``||p_(e).some(e=>e.fd===1&&(e.bytes?.length??0)>0);function b_(e,t,n){return n.closed.out&&y_(t)?x_(e,t,n):t}function x_(e,t,n){let r=v_.get(n.registry.resolveCommand(e))??1,i=p_(t).filter(e=>e.fd!==1),a=r===0?``:`${e}: write error: Bad file descriptor
172
+ `;a&&i.push({fd:2,text:a});let o={...t,stdout:``,stderr:t.stderr+a,exitCode:r||t.exitCode,events:i,unordered:!1},s=w(t);return s?E(o,s.kind,s.command,s.detail,s.message):o}var S_=new Map([[`\0`,`0`],[`\x07`,`a`],[`\b`,`b`],[`\f`,`f`],[`
173
+ `,`n`],[`\r`,`r`],[` `,`t`],[`\v`,`v`]]);function q(e,t){let n=bn(t),r=n?Array.from(O(e),e=>String.fromCodePoint(e)):[...e];if(!n&&r.some(e=>e.codePointAt(0)>127&&/[\p{C}\p{Zl}\p{Zp}]/u.test(e)))throw new D(`feature`,`filename quoting`,`quoting nonprinting Unicode filenames is not supported`);if(e.includes(`'`)&&r.every(e=>/[-a-zA-Z0-9 %+,./:_\]']/u.test(e)||!n&&e.codePointAt(0)>127))return`"`+e+`"`;let i=!1,a=`'`;for(let e of r){let t=e.codePointAt(0),r=S_.get(e)??(t<32||t===127||n&&t>127?t.toString(8).padStart(3,`0`):null);r===null?e===`'`?(a+=`'\\''`,i=!1):(i&&(a+=`''`),i=!1,a+=e):(i||(a+=`'$'`),i=!0,a+=`\\`+r)}return a+`'`}var C_=/^[#%+,\-./0-9@A-Z\]_a-z{}~]+$/u;function w_(e,t){return C_.test(e)&&!`#~`.includes(e[0])?e:q(e,t)}var T_=new Map([[`\x07`,`a`],[`\b`,`b`],[`\f`,`f`],[`
174
+ `,`n`],[`\r`,`r`],[` `,`t`],[`\v`,`v`],[`"`,`"`],[`\\`,`\\`]]);function E_(e,t){let n=bn(t),r=``,i=!1;for(let t of e){let e=t.codePointAt(0),a=T_.get(t);if(a!==void 0)r+=`\\`+a,i=!0;else if(t===` `)r+=t,i=!0;else if(e<32||e===127||e>127&&(n||/[\p{C}\p{Zl}\p{Zp}]/u.test(t))){for(let e of b(t))r+=`\\`+e.toString(8).padStart(3,`0`);i=!0}else r+=t}return i?`"${r}"`:e}var D_=new Set([`/dev/null`,`/dev/stdin`,`/dev/stdout`,`/dev/stderr`]);function O_(e,t,n){let r=U(t,{short:[`f`,`n`,`v`,`T`,`r`,`R`],long:[`force`,`no-clobber`,`verbose`,`no-target-directory`,`recursive`],valueShort:[`t`],valueLong:[`target-directory`]}),i=k_(r,n);if(i.error)return C(`cp: `+i.error);let{sources:a,target:o,directory:s}=i,{flags:c}=r,l=c.has(`v`)||c.has(`verbose`),u=c.has(`r`)||c.has(`R`)||c.has(`recursive`),d=a.map(e=>[e,s?o.replace(/\/+$/u,``)+`/`+F_(e):o]),f=c.has(`n`)||c.has(`no-clobber`),p={ctx:n,result:G(),failed:!1,sources:new Set,copied:new Set,noClobber:f,force:c.has(`f`)||c.has(`force`),verbose:l,recursive:u,outputOverlap:l&&H_(d,n,{recursive:u,noClobber:f})};for(let[e,t]of d){n.io.setReads([]);try{I_(e,t,p)}catch(e){I(n,`cp`,e?.path,e?.fsError);let t=w(e),r=`cp: `+z(e);if(t)return n.unsupported.add({...t,command:t.command??`cp`,message:r}),K(p.result,C(r)),p.result;Z_(p,r+`
175
+ `,!0)}}return p.result.exitCode=+!!p.failed,p.result}function k_({positional:e,flags:t,order:n},r){let i=n.filter(({name:e})=>e===`t`||e===`target-directory`);if(i.length>1)return{error:`multiple target directories specified`};let a=i[0]?.value,o=t.has(`T`)||t.has(`no-target-directory`);if(e.length===0)return{error:`missing file operand`};if(a===void 0&&e.length===1)return{error:`missing destination file operand after `+q(e[0],r)};if(a!==void 0&&o)return{error:`cannot combine --target-directory (-t) and --no-target-directory (-T)`};if(o&&e.length>2)return{error:`extra operand `+q(e[2],r)};let s=a??e.at(-1),c=j(r.cwd,s,r.fs),l=!o&&r.fs.isDir(c.path);return!l&&(a!==void 0||e.length>2)?(I(r,`cp`,s,c.error),{error:`${a===void 0?`target`:`target directory`} ${q(s,r)}: ${c.error??`Not a directory`}`}):{target:s,directory:l,sources:a===void 0?e.slice(0,-1):e}}function A_(e,t,n){let{ctx:r}=n,i=j(r.cwd,e,r.fs,{follow:!1}).path;if(i===null)return;let a=e.replace(/\/+$/u,``),o=t.replace(/\/+$/u,``);for(let s of zt(r.fs,i)){if(s.kind!==`link`)continue;let r=s.path===i?null:It(i,s.path);if(!j_(r===null?t:`${o}/${r}`,n)&&!(r!==null&&M_(o,r,n)))throw N_(r===null?e:`${a}/${r}`)}}var j_=(e,t)=>t.noClobber&&j(t.ctx.cwd,e,t.ctx.fs,{follow:!1}).path!==null;function M_(e,t,n){let{ctx:r}=n,i=t.split(`/`);for(let t=1;t<i.length;t++){let n=j(r.cwd,`${e}/${i.slice(0,t).join(`/`)}`,r.fs,{follow:!1});if(n.path!==null&&!r.fs.isDir(n.path))return!0}return!1}var N_=e=>new D(`feature`,`symbolic link`,`copying a symbolic link is not supported: ${e} (a recursive copy keeps the link, which cp does not make here)`),P_=(e,t,n)=>n.path===null&&e.fs.isLink?.(j(e.cwd,t,e.fs,{follow:!1}).path)===!0,F_=e=>{let t=e.replace(/\/+$/u,``).split(`/`).at(-1);return t===`..`?`.`:t};function I_(e,t,n,r=null){let{ctx:i}=n;if(X_(e,i.cwd)||X_(t,i.cwd))throw new D(`feature`,`special file`,`copying special files is not supported`);let a=q(e,i),o=q(t,i);if(n.recursive&&i.fs.isLink?.(j(i.cwd,e,i.fs,{follow:!1}).path)){if(!j_(t,n))throw N_(e);return}let s=F(i,`cp`,e),c=e=>Z_(n,`cp: `+e+`
176
+ `,!0);if(s.error)return c(`cannot stat ${a}: ${s.error}`);if(i.fs.isDir(s.path))return n.recursive?L_(e,s.path,t,n,r??{source:a,target:o},r===null):c(`-r not specified; omitting directory ${a}`);if(r===null){if(n.sources.has(s.path))return Z_(n,`cp: warning: source file ${a} specified more than once
177
+ `,!1,!0);n.sources.add(s.path)}let l=j(i.cwd,t,i.fs);if(l.error&&l.error!==`No such file or directory`)return c(`cannot stat ${o}: ${l.error}`);if(n.noClobber&&l.path!==null)return;if(V_(s.path,l.path,i.fs))return c(`${a} and ${o} are the same file`);if(i.fs.isDir(l.path))return c(`cannot overwrite directory ${o} with non-directory ${a}`);let u=Mt(i.fs,i.cwd,t);if(r===null&&n.copied.has(u))return c(`will not overwrite just-created ${o} with ${a}`);let d=Nt(i.cwd,t,i.fs,l);if(z_(a,o,n),P_(i,t,l))return c(`not writing through dangling symlink ${o}`);if(d)return I(i,`cp`,t,d),c(`cannot create regular file ${o}: ${d}`);try{if(!i.fs.copyWritable?.(i.cwd,s.path,t))return c(`${n.force&&l.path!==null?`cannot remove`:`cannot create regular file`} ${o}: Read-only file system`)}catch(e){if(w(e))throw e;I(i,`cp`,e?.path,e?.fsError);let n=z(e);return c(`cannot create regular file ${o}: ${n.startsWith(t+`: `)?n.slice(t.length+2):n}`)}r===null&&n.copied.add(u)}function L_(e,t,n,r,i,a){let{ctx:o}=r,s=q(e,o),c=q(n,o),l=e=>Z_(r,`cp: `+e+`
178
+ `,!0),u=j(o.cwd,n,o.fs,{follow:!1});if(u.error&&u.error!==`No such file or directory`)return l(`cannot stat ${c}: ${u.error}`);let d=n.replace(/\/+$/u,``)||n;if(Mt(o.fs,o.cwd,d,!0)===t)return l(`${s} and ${c} are the same file`);if(u.path!==null&&!o.fs.isDir(u.path))return l(`cannot overwrite non-directory ${c} with directory ${s}`);let f=Mt(o.fs,o.cwd,d,!1);if(u.path===null){let e=Nt(o.cwd,d,o.fs);if(e)return I(o,`cp`,d,e),l(`cannot create directory ${c}: ${e}`);if(!o.writable||!B(f))return l(`cannot create directory ${c}: Read-only file system`)}if(f.startsWith(t===`/`?`/`:t+`/`))return l(`cannot copy a directory, ${i.source}, into itself, ${i.target}`);if(a){if(r.sources.has(t))return Z_(r,`cp: warning: source directory ${s} specified more than once
179
+ `,!1,!0);r.sources.add(t)}a&&A_(e,n,r);let{dirs:p,files:m,links:h}=o.fs.listDir(t);if(u.path===null&&!R_(e,n,d,f,r))return;let g=e.replace(/\/+$/u,``),_=n.replace(/\/+$/u,``);for(let e of[...p,...m,...h].sort(N))o.io.setReads([]),I_(`${g}/${e}`,`${_}/${e}`,r,i)}function R_(e,t,n,r,i){let{ctx:a}=i,o=q(t,a),s=e=>(Z_(i,`cp: cannot create directory `+o+`: `+e+`
180
+ `,!0),!1),c=a.writable&&B(r);c&&B_(i);try{if(!c||!a.fs.makeWritableDir?.(a.cwd,n))return s(`Read-only file system`)}catch(e){if(w(e))throw e;I(a,`cp`,e?.path,e?.fsError);let t=z(e);return s(t.startsWith(n+`: `)?t.slice(n.length+2):t)}return z_(q(e,a),o,i),!0}function z_(e,t,n){n.verbose&&(B_(n),Z_(n,`${e} -> ${t}
181
+ `))}function B_(e){if(e.outputOverlap)throw new D(`feature`,`copy output buffering`,`buffered verbose output sharing a copied file is not supported`)}function V_(e,t,n){if(e===t)return!0;let r=n.fileIdentity?.(e);return r!==void 0&&r===n.fileIdentity(t)}function H_(e,t,{recursive:n,noClobber:r}){let i=t.outputFds[1];if(typeof i!=`object`)return!1;let a={ctx:t,recursive:n,noClobber:r,holds:e=>i.identity===void 0?i.path===e:i.identity===t.fs.fileIdentity?.(e),made:new Set,sources:new Set,copied:new Set};return e.some(([e,t])=>U_(e,t,a))}function U_(e,t,n){let{ctx:r}=n,i=j(r.cwd,e,r.fs),a=i.path??A(r.cwd,e),o=i.error===`No such file or directory`&&(n.made.has(a)||K_(a,n));if(i.error&&!o)return!1;let s=Mt(r.fs,r.cwd,t);return(i.error===null?r.fs.isDir(i.path):!n.made.has(a))?!n.recursive||!Y_(a,t,r)||n.sources.has(a)?!1:(n.sources.add(a),W_(a,s,n)):n.sources.has(a)||(n.sources.add(a),n.copied.has(s)||!J_(a,s,t,r,n.noClobber))?!1:(n.copied.add(s),n.made.add(s),n.holds(a)||n.holds(s))}function W_(e,t,n){let{ctx:r}=n,i=e===`/`?0:e.length;for(let a of G_(e,n)){let e=t+a.slice(i);if(!q_(a,e,j(r.cwd,e,r.fs),r,n.noClobber)&&(n.made.add(e),n.holds(a)||n.holds(e)))return!0}return!1}function G_(e,t){let n=e===`/`?`/`:e+`/`,r=t.ctx.fs.isDir(e)?[...t.ctx.fs.walkFiles(e)]:[];return new Set([...r,...[...t.made].filter(e=>e.startsWith(n))])}var K_=(e,t)=>[...t.made].some(t=>t.startsWith(e+`/`));function q_(e,t,n,r,i){return n.error&&n.error!==`No such file or directory`||i&&n.path!==null||V_(e,n.path,r.fs)||r.fs.isDir(n.path)?!0:!r.writable||!B(t)}function J_(e,t,n,r,i){let a=j(r.cwd,n,r.fs);return!q_(e,t,a,r,i)&&!P_(r,n,a)&&!Nt(r.cwd,n,r.fs,a)}function Y_(e,t,n){let r=j(n.cwd,t,n.fs,{follow:!1});if(r.error&&r.error!==`No such file or directory`)return!1;let i=t.replace(/\/+$/u,``)||t;if(r.path!==null&&!n.fs.isDir(r.path)||r.path===null&&Nt(n.cwd,i,n.fs))return!1;let a=Mt(n.fs,n.cwd,i,!1);return Mt(n.fs,n.cwd,i,!0)===e||a.startsWith(e===`/`?`/`:e+`/`)?!1:!!n.writable&&B(a)}function X_(e,t){let n=e.startsWith(`/`)?e:t+`/`+e;return D_.has(n.replace(/\/\.(?=\/)/gu,``).replace(/\/+/gu,`/`))}function Z_(e,t,n=!1,r=!1){let i=n||r?G(t):{...G(),stdout:t,events:[{fd:1,text:t}]};K(e.result,e.ctx.flushOutput(i)),e.failed||=n}function Q_(e,t,n){let{flags:r,positional:i}=U(t,{short:[`f`,`v`,`r`,`R`],long:[`force`,`verbose`,`recursive`]}),a=r.has(`f`)||r.has(`force`),o=r.has(`v`)||r.has(`verbose`),s=r.has(`r`)||r.has(`R`)||r.has(`recursive`);if(i.length===0)return a?S(``):C(`rm: missing operand`);let c={ctx:n,force:a,verbose:o,recursive:s,events:[],stdout:``,stderr:``};try{for(let e of i)$_(e,c)}catch(e){I(n,`rm`,e?.path,e?.fsError);let t=dt(e,`rm`,`rm: `+z(e));return t.events=[...c.events,{fd:2,text:t.stderr}],t.stdout=c.stdout,t.stderr=c.stderr+t.stderr,t}return{stdout:c.stdout,stderr:c.stderr,events:c.events,exitCode:+!!c.stderr}}function $_(e,t){let{ctx:n}=t,r=j(n.cwd,e,n.fs,{follow:!1}),i=r.error;if(!t.force||i!==`No such file or directory`&&i!==`Not a directory`){if(I(n,`rm`,e,i),i===null&&n.fs.isDir(r.path)){if(!t.recursive)i=`Is a directory`;else{if([`.`,`..`].includes(e.replace(/\/+$/u,``).split(`/`).at(-1)))return rv(t,`rm: refusing to remove '.' or '..' directory: skipping ${q(e,n)}
182
+ `);if(r.path===`/tmp`)i=`Device or resource busy`;else if(!n.writable||!B(r.path))i=`Read-only file system`;else return tv(e,r.path,t,ev(n,e)?`Not a directory`:null)}}nv(e,r.path,t,!1,i)}}function ev(e,t){let n=t.replace(/\/+$/u,``);return n===t||n===``?!1:e.fs.isLink?.(j(e.cwd,n,e.fs,{follow:!1}).path)===!0}function tv(e,t,n,r=null){let{ctx:i}=n,{dirs:a,files:o,links:s=[]}=i.fs.listDir(t),c=e.replace(/\/+$/u,``);for(let e of[...a,...o,...s].sort(N)){let r=Ft(t,e);i.fs.isDir(r)?tv(`${c}/${e}`,r,n):nv(`${c}/${e}`,r,n,!1,null)}nv(e,t,n,!0,r)}function nv(e,t,n,r,i){let{ctx:a}=n,o=n.verbose||i!==null||!a.writable||!t?.startsWith(`/tmp/`)?q(e,a):``,s=()=>r?a.fs.removeWritableDir?.(a.cwd,e):a.fs.removeWritable?.(a.cwd,e);try{i===null&&!s()&&(i=`Read-only file system`)}catch(t){if(w(t))throw t;I(a,`rm`,t?.path,t?.fsError);let n=z(t);i=t?.fsError??(n.startsWith(e+`: `)?n.slice(e.length+2):n)}if(i)return rv(n,`rm: cannot remove ${o}: ${i}
183
+ `);n.verbose&&rv(n,`removed ${r?`directory `:``}${o}
184
+ `,1)}function rv(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function iv(e,t,n){let{flags:r,positional:i}=U(t,{short:[`p`,`v`],long:[`parents`,`verbose`]});if(i.length===0)return C(`mkdir: missing operand`);let a={ctx:n,events:[],stdout:``,stderr:``,parents:r.has(`p`)||r.has(`parents`),verbose:r.has(`v`)||r.has(`verbose`)};try{for(let e of i)a.parents?av(e,a):ov(e,a,!0)}catch(e){I(n,`mkdir`,e?.path,e?.fsError);let t=dt(e,`mkdir`,`mkdir: `+z(e));return t.events=[...a.events,{fd:2,text:t.stderr}],t.stdout=a.stdout,t.stderr=a.stderr+t.stderr,t}return{stdout:a.stdout,stderr:a.stderr,events:a.events,exitCode:+!!a.stderr}}function av(e,t){let n=e.split(`/`),r=[];for(let e=0;e<n.length;e++)n[e]!==``&&r.push(n.slice(0,e+1).join(`/`));if(r.length===0)e===``&&ov(e,t,!0);else{r[r.length-1]=e;for(let[e,n]of r.entries())if(!ov(n,t,e===r.length-1))return}}function ov(e,t,n){let{ctx:r}=t,i=q(e,r),a=e=>(sv(t,`mkdir: cannot create directory ${i}: ${e}
185
+ `),!1),o=e.replace(/\/+$/u,``)||e,s=j(r.cwd,o,r.fs);if(s.error===null)return t.parents?r.fs.isDir(s.path)?!0:a(n?`File exists`:`Not a directory`):a(`File exists`);if(j(r.cwd,o,r.fs,{follow:!1}).error===null)return a(!t.parents||n||s.error!==`Not a directory`?`File exists`:`Not a directory`);let c=Nt(r.cwd,o,r.fs,s);if(c)return I(r,`mkdir`,o,c),a(c);try{if(!r.fs.makeWritableDir?.(r.cwd,o))return a(`Read-only file system`)}catch(e){if(w(e))throw e;I(r,`mkdir`,e?.path,e?.fsError);let t=z(e);return a(t.startsWith(o+`: `)?t.slice(o.length+2):t)}return t.verbose&&sv(t,`mkdir: created directory ${i}
186
+ `,1),!0}function sv(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function cv(e,t,n){let{flags:r,positional:i}=U(t,{short:[`c`],long:[`no-create`]});if(i.length===0)return C(`touch: missing file operand`);let a=r.has(`c`)||r.has(`no-create`),o={ctx:n,stderr:``,failed:!1,gap:null};for(let e of i)lv(e,a,o);let s={stdout:``,stderr:o.stderr,exitCode:+!!o.failed};return o.gap?E(s,`feature`,`touch`,`times`,o.gap):s}function lv(e,t,n){let{ctx:r}=n,i=q(e,r),a=j(r.cwd,e,r.fs);if(a.error===null)return uv(e,i,a.path,n);let o=t||e.endsWith(`/`);if(t&&a.error===`No such file or directory`)return;if(I(r,`touch`,e,a.error),o)return dv(n,`setting times of ${i}: ${a.error}`);let s=Nt(r.cwd,e,r.fs,a);if(s)return dv(n,`cannot touch ${i}: ${s}`);try{r.fs.openWritable?.(r.cwd,e,!0)||dv(n,`cannot touch ${i}: Read-only file system`)}catch(t){if(w(t))throw t;I(r,`touch`,t?.path,t?.fsError);let a=z(t);dv(n,`cannot touch ${i}: ${a.startsWith(e+`: `)?a.slice(e.length+2):a}`)}}function uv(e,t,n,r){let{ctx:i}=r;if(!i.writable||!B(n))return dv(r,`setting times of ${t}: Read-only file system`);let a=`touch: setting the times of ${t} is not supported (every entry here carries the one time this filesystem keeps)`;r.gap??=a,r.stderr+=a+`
187
+ `,r.failed=!0}function dv(e,t){e.stderr+=`touch: ${t}
188
+ `,e.failed=!0}function fv(e,t,n,r){if(t===``||t.includes(`\0`))return{error:`No such file or directory`};if(r===`none`)return pv(e,t,n);let i=t;if(r===`logical`){let r=n===`m`?{path:A(e.cwd,t)}:mv(e,t);if(r.error)return r;i=r.path+(t.endsWith(`/`)?`/`:``)}let a=jt(e.cwd,i,e.fs,{lenient:n===`m`});return n===`m`?{path:a.rest.length?A(a.path,a.rest.join(`/`)):a.path}:a.error===`No such file or directory`&&a.rest.length===0&&n!==`e`?{path:a.path}:a.error?{error:a.error}:t.endsWith(`/`)&&!e.fs.isDir(a.path)?{error:`Not a directory`}:{path:a.path}}function pv(e,t,n){if(n===`m`)return{path:A(e.cwd,t)};let r=mv(e,t);if(r.error||n!==`e`)return r;let i=j(`/`,r.path,e.fs);return i.error?{error:i.error}:r}function mv(e,t){let n=(t.startsWith(`/`)?t:e.cwd+`/`+t).split(`/`).filter(Boolean),r=`/`;for(let i=0;i<n.length;i++){let a=n[i];if(a===`..`)r=M(r);else if(a!==`.`){r=Ft(r,a);let o=i+1;for(;n[o]===`.`;)o++;let s=n[o]===`..`||o===n.length&&(i<n.length-1||t.endsWith(`/`));if(s||i===n.length-1){let t=j(`/`,r+(s?`/`:``),e.fs);if(t.error&&(t.error!==`No such file or directory`||i!==n.length-1))return t}}}return{path:r}}function hv(e,t){let n=e.split(`/`).filter(Boolean),r=t.split(`/`).filter(Boolean),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;return[...n.slice(i).map(()=>`..`),...r.slice(i)].join(`/`)||`.`}var gv=(e,t)=>e===`/`||t===e||t.startsWith(e+`/`),_v={e:`e`,"canonicalize-existing":`e`,m:`m`,"canonicalize-missing":`m`},vv={P:`physical`,physical:`physical`,L:`logical`,logical:`logical`,s:`none`,strip:`none`,"no-symlinks":`none`};function yv(e,t,n,r){let i=t.get(`relative-base`),a=t.get(`relative-to`)??i,o={};for(let[t,s]of[[`target`,a],[`base`,i]]){if(s===void 0)continue;let i=fv(e,s,n,r),a=i.error??(n===`e`&&!e.fs.isDir(i.path)?`Not a directory`:null);if(a)return I(e,`realpath`,s,a),{error:C(`realpath: ${w_(s,e)}: ${a}`)};o[t]=i.path}return o.base&&!gv(o.base,o.target)&&delete o.target,o}function bv(e,t,n){let{flags:r,values:i,positional:a,order:o}=U(t,{short:[`e`,`m`,`L`,`P`,`s`,`q`,`z`],long:[`canonicalize-existing`,`canonicalize-missing`,`logical`,`physical`,`strip`,`no-symlinks`,`quiet`,`zero`],valueLong:[`relative-to`,`relative-base`]});if(!a.length)return C(`realpath: missing operand`);let s=`physical`,c=`E`;for(let{name:e}of o)Object.hasOwn(_v,e)&&(c=_v[e]),Object.hasOwn(vv,e)&&(s=vv[e]);let l=yv(n,i,c,s);if(l.error)return l.error;let u=r.has(`q`)||r.has(`quiet`),d=r.has(`z`)||r.has(`zero`)?`\0`:`
189
+ `,f=G(),p=!1;for(let e of a){let t=fv(n,e,c,s);t.error?(I(n,`realpath`,e,t.error),u||K(f,C(`realpath: ${w_(e,n)}: ${t.error}`)),p=!0):K(f,S((l.target&&(!l.base||gv(l.base,t.path))?hv(l.target,t.path):t.path)+d))}return f.exitCode=+!!p,f}var xv={symbolic:`s`,force:`f`,"no-dereference":`n`,"no-target-directory":`T`,verbose:`v`,relative:`r`,logical:`L`,physical:`P`};function Sv(e,t,n){let r=U(t,{short:Object.values(xv),long:Object.keys(xv),valueShort:[`t`],valueLong:[`target-directory`]}),i=e=>r.flags.has(e)||r.flags.has(Object.keys(xv).find(t=>xv[t]===e)),a={force:i(`f`),noDereference:i(`n`),noTargetDirectory:i(`T`),verbose:i(`v`),relative:i(`r`)},o=r.order.findLast(({name:e})=>e===`t`||e===`target-directory`)?.value??null,s=r.positional;if(o!==null&&a.noTargetDirectory)return C(`ln: cannot combine --target-directory and --no-target-directory`);if(a.relative&&!i(`s`))return C(`ln: cannot do --relative without --symbolic`);if(s.length===0)return C(`ln: missing file operand`);if(!i(`s`))return T(`feature`,`ln`,`hard link`,`ln: hard links are not supported: ${q(s[0],n)} (ln -s makes a symbolic one)`);let c={ctx:n,events:[],stdout:``,stderr:``};try{let e=Cv(s,o,a,n);if(e.error)return e.error;for(let[t,n,r]of e)Tv(t,n,a,c,r)}catch(e){I(n,`ln`,e?.path,e?.fsError);let t=dt(e,`ln`,`ln: `+z(e));return t.events=[...c.events,{fd:2,text:t.stderr}],t.stdout=c.stdout,t.stderr=c.stderr+t.stderr,t}return{stdout:c.stdout,stderr:c.stderr,events:c.events,exitCode:+!!c.stderr}}function Cv(e,t,n,r){let i=e=>q(e,r);if(t!==null){let n=j(r.cwd,t,r.fs);return n.error?(I(r,`ln`,t,n.error),{error:C(`ln: failed to access ${i(t)}: ${n.error}`)}):r.fs.isDir(n.path)?e.map(e=>wv(t,e)):{error:C(`ln: target ${i(t)} is not a directory`)}}if(e.length===1)return n.noTargetDirectory?{error:C(`ln: missing destination file operand after ${i(e[0])}`)}:[wv(`.`,e[0])];if(e.length===2){let t=j(r.cwd,e[1],r.fs,{follow:!n.noDereference});if(n.noTargetDirectory||t.error!==null||!r.fs.isDir(t.path))return[[e[0],e[1]]]}if(n.noTargetDirectory)return{error:C(`ln: extra operand ${i(e[2])}`)};let a=e.at(-1),o=j(r.cwd,a,r.fs),s=o.error??(r.fs.isDir(o.path)?null:`Not a directory`);return s?(I(r,`ln`,a,s),{error:C(`ln: target ${i(a)}: ${s}`)}):e.slice(0,-1).map(e=>wv(a,e))}function wv(e,t){let n=t.replace(/\/+$/u,``).split(`/`).at(-1);return[t,e+(e.endsWith(`/`)?``:`/`)+n,n===``]}function Tv(e,t,n,r,i=!1){let{ctx:a}=r,o=q(t,a),s=n.relative?Dv(a,e,t):e,c=e=>kv(r,`ln: failed to create symbolic link ${o}${e}
190
+ `);if(s===``)return c(` -> ${q(s,a)}: No such file or directory`);if(i)return c(`: No such file or directory`);if(n.force){let e=j(a.cwd,t,a.fs,{follow:!1});if(e.error===null){if(a.fs.isDir(e.path))return kv(r,`ln: ${w_(t,a)}: cannot overwrite directory
191
+ `);try{if(!a.fs.removeWritable?.(a.cwd,t))return c(`: Read-only file system`)}catch(e){if(w(e))throw e;return c(`: ${Ov(e,t)}`)}}}let l=Ev(a,t);if(l)return I(a,`ln`,t,l),c(`: ${l}`);try{if(!a.fs.makeWritableLink?.(a.cwd,t,s))return c(`: Read-only file system`)}catch(e){if(w(e))throw e;return I(a,`ln`,e?.path,e?.fsError),c(`: ${Ov(e,t)}`)}n.verbose&&kv(r,`${o} -> ${q(s,a)}
192
+ `,1)}function Ev(e,t){if(t===``||t.includes(`\0`))return`No such file or directory`;let n=t.replace(/\/+$/u,``);if(n===``)return`File exists`;let r=j(e.cwd,n,e.fs,{follow:!1});if(r.error===null)return`File exists`;if(r.error!==`No such file or directory`||t!==n)return r.error;let i=jt(e.cwd,n,e.fs);return i.rest.length>0?i.error:null}function Dv(e,t,n){let r=fv(e,M(n),`m`,`physical`),i=fv(e,t,`m`,`physical`);return r.error||i.error?t:hv(r.path,i.path)}function Ov(e,t){let n=z(e);return e?.fsError??(n.startsWith(t+`: `)?n.slice(t.length+2):n)}function kv(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Av(e,t,n){let{flags:r,positional:i}=U(t,{short:[`a`,`i`,`p`],long:[`append`,`ignore-interrupts`]}),a=r.has(`a`)||r.has(`append`),o=n.stdinBytes;L(n,``,!0);let s=o??O(e),c={stderr:``,status:0,gap:null};for(let e of i)jv(e,s,a,c,n);let l=[{fd:1,bytes:s},...c.stderr?[{fd:2,text:c.stderr}]:[]],u=o===null?{stdout:e,stderr:c.stderr,exitCode:c.status}:{stdout:``,stderr:c.stderr,exitCode:c.status,events:l};if(!c.gap)return u;let d=w(c.gap);return E({...u,exitCode:1},d.kind,d.command,d.detail,d.message)}function jv(e,t,n,r,i){if(e===`/dev/null`)return;let a;try{a=i.writable&&i.fs.openWritable?.(i.cwd,e,n)}catch(e){r.stderr+=`tee: ${e.message}
193
+ `,r.status=1;return}a?a.writeBytes(t):(r.gap??=T(`feature`,`tee`,`read-only target`,`tee: ${e}: Read-only file system`,1),r.stderr+=`tee: ${e}: Read-only file system
194
+ `)}var Mv={cp:O_,rm:Q_,mkdir:iv,touch:cv,ln:Sv,tee:Av};function Nv(e,t,n){let{positional:r}=U(t),i=sr(`tac`,r,e,n),a=[];for(let{content:e}of i.inputs)a.push(...$n(e).toReversed());return R(a.join(``),i)}var Pv=1e6;function Fv(e,t){let{flags:n,values:r,positional:i}=U(t,{short:[`w`],valueShort:[`s`],numericOperands:!0});if(i.length===0||i.length>3)return lt(`seq [-w] [-s SEP] LAST | seq FIRST LAST | seq FIRST INCR LAST`);let a=[];for(let e of i){if(!/^[+-]?\d+$/u.test(e))return Number.isFinite(Number(e))&&e.trim()!==``||/^[+-]?inf(?:inity)?$/iu.test(e)?T(`feature`,`seq`,`non-integer operands`,`seq: non-integer operands are not supported`):C(`seq: invalid integer: ${e}`);a.push(BigInt(e))}let o=a.length===1?1n:a[0],s=a.length===3?a[1]:1n,c=a.at(-1);if(s===0n)return C(`seq: increment must be non-zero`);let l=(s>0?o<=c:o>=c)?(c>o?c-o:o-c)/(s>0n?s:-s)+1n:0;if(l>Pv)return T(`feature`,`seq`,`sequence limit`,`seq: range too large: ${l} elements exceeds limit of ${Pv}`);let u=n.has(`w`)?Math.max(...[i[0],i.at(-1)].map(e=>e.replace(/^\+/u,``).length)):0,d=[];for(let e=0,t=o;e<l;e++,t+=s)d.push(Iv(String(t),u));return S(d.length===0?``:d.join(r.get(`s`)??`
195
+ `)+`
196
+ `)}function Iv(e,t){if(e.length>=t)return e;let n=e.startsWith(`-`),r=n?e.slice(1):e;return(n?`-`:``)+r.padStart(t-+!!n,`0`)}function Lv(e,t,n){let{positional:r}=U(t);if(r.length===0)return lt(`which COMMAND...`);let i=[],a=0;for(let e of r)n.hasCommand(e)?i.push(`/usr/bin/${e}`):(i.push(`${e} not found`),a=1);return{stdout:Qn(i),stderr:``,exitCode:a}}function Rv(e,t,n){let{positional:r}=U(t);return r.length>0?C(`whoami: extra operand: ${r[0]}`):S((n.user??`user`)+`
197
+ `)}function zv(e,t,n){let{flags:r,positional:i}=U(t,{short:[`u`]});if(i.length>1)return C(`date: at most one +FORMAT argument is supported (got: ${i[1]})`);let a=`%a %b %e %T %Z %Y`;if(i.length===1){if(!i[0].startsWith(`+`))return lt(`date [-u] [+FORMAT]`);a=i[0].slice(1)}return(a.match(/%./gu)??[]).some(e=>/%[-_0^#0-9:EOcCDgGhIjklNpPrRuUVwWxXy+]/u.test(e))?T(`feature`,`date`,`format`,`date: this format directive or modifier is not supported`):S(Wv(new Date,a,r.has(`u`)||n.vars.has(`TZ`))+`
198
+ `)}var Bv=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],Vv=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],Hv=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],Uv=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`];function Wv(e,t,n){let r=`get`+(n?`UTC`:``),[i,a,o,s,c,l,u]=[`FullYear`,`Month`,`Date`,`Hours`,`Minutes`,`Seconds`,`Day`].map(t=>e[r+t]()),d=(e,t=`0`)=>String(e).padStart(2,t),f={__proto__:null,Y:String(i),m:d(a+1),d:d(o),e:d(o,` `),H:d(s),M:d(c),S:d(l),T:[s,c,l].map(e=>d(e)).join(`:`),F:[i,d(a+1),d(o)].join(`-`),q:String(Math.floor(a/3)+1),s:String(Math.floor(e.getTime()/1e3)),a:Bv[u],A:Vv[u],b:Hv[a],B:Uv[a],Z:()=>Gv(e,n),z:()=>Kv(e,n),n:`
199
+ `,t:` `,"%":`%`};return t.replace(/%./gu,e=>{let t=f[e[1]];return typeof t==`function`?t():t??e})}function Gv(e,t){if(t)return`UTC`;try{return new Intl.DateTimeFormat(`en-US`,{timeZoneName:`short`}).formatToParts(e).find(e=>e.type===`timeZoneName`)?.value??`Local`}catch{return`Local`}}function Kv(e,t){if(t)return`+0000`;let n=-e.getTimezoneOffset(),r=n>=0?`+`:`-`,i=Math.abs(n);return`${r}${String(Math.floor(i/60)).padStart(2,`0`)}${String(i%60).padStart(2,`0`)}`}var qv={rg:jg,cut:Zg,tac:Nv,tr:i_,seq:Fv,nl:Xg,which:Lv,hexdump:Of,base64:ap,...Mv},Jv={whoami:Rv,date:zv,od:kf,xxd:Af,base32:$f,...vf},Yv=new Map(Object.entries({all:`a`,"apparent-size":`A`,bytes:`b`,total:`c`,null:`0`,"count-links":`l`,summarize:`s`,"separate-dirs":`S`,"human-readable":`h`,"max-depth":`d`,"block-size":`B`,dereference:`L`,"dereference-args":`D`,"no-dereference":`P`})),Xv={P:`none`,D:`args`,H:`args`,L:`all`};function Zv(e,t){let n=U(e,{short:[`0`,`a`,`A`,`b`,`c`,`h`,`H`,`k`,`l`,`m`,`s`,`S`,`L`,`D`,`P`],long:[...Yv.keys()].filter(e=>![`d`,`B`].includes(Yv.get(e))).concat([`inodes`,`si`]),valueShort:[`d`,`B`],valueLong:[`max-depth`,`block-size`]}),r={operands:n.positional.length?n.positional:[`.`],depth:1/0,flags:new Set,links:`none`,scale:null,stderr:``};for(let{name:e,value:t}of n.order){let n=Yv.get(e)??e;r.flags.add(n),Object.hasOwn(Xv,n)&&(r.links=Xv[n]),n===`d`&&(r.depth=$v(t)),n===`B`&&(r.scale=ty(t)),n===`b`&&(r.flags.add(`A`),r.scale={unit:1n}),(n===`k`||n===`m`)&&(r.scale={unit:n===`k`?1024n:1024n**2n}),(n===`h`||n===`si`)&&(r.scale={base:n===`h`?1024n:1000n,unit:1n})}let{flags:i}=r;if(i.has(`a`)&&i.has(`s`))throw Error(`cannot both summarize and show all entries`);if(i.has(`s`)&&i.has(`d`)){if(r.depth!==0)throw Error(`summarizing conflicts with --max-depth=${r.depth}`);r.stderr+=`du: warning: summarizing is the same as using --max-depth=0
200
+ `}if(i.has(`s`)&&(r.depth=0),i.has(`inodes`)&&i.has(`A`)&&(r.stderr+=`du: warning: options --apparent-size and -b are ineffective with --inodes
201
+ `),!r.scale){let e=t.vars.get(`DU_BLOCK_SIZE`)??t.vars.get(`BLOCK_SIZE`)??t.vars.get(`BLOCKSIZE`);try{r.scale=e===void 0?{unit:t.vars.has(`POSIXLY_CORRECT`)?512n:1024n}:ty(e)}catch(e){throw e instanceof D?e:new D(`feature`,`invalid block size environment`,`invalid block size environment settings are not supported`)}}return i.has(`inodes`)&&(r.scale={...r.scale,unit:1n,suffix:r.scale.suffix?.endsWith(`B`)?`B`:``}),r.scale.base&&Qv(t,r.scale.base),r}function Qv(e,t=1024n){let n=e.vars.get(`LC_ALL`)||e.vars.get(`LC_NUMERIC`)||e.locale;if(!/^(?:C|POSIX|C\.UTF-?8)$/iu.test(n))throw new D(`feature`,`numeric locale`,`human-readable sizes in this numeric locale are not supported`);return{base:t,unit:1n}}function $v(e){let t=/^[ \t\n\r\v\f]*([+-]?)(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.exec(e);if(!t)throw Error(`invalid maximum depth: ${e}`);let n=ey(t[2]);if(n>Rn||t[1]===`-`&&n!==0n)throw Error(`invalid maximum depth: ${e}`);return Number(n)}function ey(e){return BigInt(/^0[0-7]+$/u.test(e)?`0o`+e:e)}function ty(e){let t=e&&[`human-readable`,`si`].find(t=>t.startsWith(e));if(t)return{base:t===`si`?1000n:1024n,unit:1n};if(e.startsWith(`'`))throw new D(`feature`,`grouped block sizes`,`grouped block sizes are not supported`);let n=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)?([kKmMgGtTPEZYRQ](?:i?B|D)?)?$/u.exec(e);if(!n||!n[1]&&e!==n[2])throw Error(`invalid block size: ${e}`);let r=n[2]??``,i=r?`KMGTPEZYRQ`.indexOf(r[0].toUpperCase())+1:0,a=/[BD]$/u.test(r)&&!r.endsWith(`iB`)?1000n:1024n,o=(n[1]?ey(n[1]):1n)*a**BigInt(i);if(o===0n||o>Bn)throw Error(`invalid block size: ${e}`);return{unit:o,suffix:n[1]||!r?``:(i===1&&r.endsWith(`B`)&&a===1000n?`k`:r[0].toUpperCase())+(r.endsWith(`B`)?a===1000n?`B`:`iB`:``)}}var ny=4096,ry=60,iy=(e,t)=>t===`dir`?ny:t===`link`&&e<ry?0:Math.ceil(e/ny)*ny,ay=(e,t)=>(e+t-1n)/t;function oy(e,{base:t,unit:n,suffix:r=``}){if(!t)return String(ay(e,n))+r;let i=1n,a=0;for(;e>=i*t;)i*=t,a++;if(!a)return String(e);let o=ay(e*10n,i),s;return o<100n?s=`${o/10n}.${o%10n}`:(o=ay(e,i),o===t?(a++,s=`1.0`):s=String(o)),s+(a===1&&t===1000n?`k`:`KMGTPEZYRQ`[a-1])}var sy=15778476e3;function cy(e,t){for(let t of[`LS_BLOCK_SIZE`,`BLOCK_SIZE`,`BLOCKSIZE`])if(e.vars.has(t))throw new D(`feature`,`block size environment`,`${t} is not supported in a long listing`);let n=t?Qv(e):null,r=e.user??`user`,i=e.createdAt,a=Date.now(),o=i<=a&&a-i<sy,s=Wv(new Date(i),o?`%b %e %H:%M`:`%b %e %Y`,e.vars.has(`TZ`)),c=e=>n?oy(BigInt(e),n):String(e),l=e=>Math.max(0,...e.map(e=>e.length));return{lines(t,i){let a=t.map(({name:t,abs:n,kind:r,target:i})=>{let a=r===`dir`,o=a?ny:e.fs.fileSize(n)??O(e.fs.readFile(n)).length,s=a?`drwx------`:r===`link`?`lrwxrwxrwx`:`-rw-------`,l=iy(o,r)/512;return{name:r===`link`?`${t} -> ${i}`:t,mode:s,units:l,links:String(a?2+e.fs.listDir(n).dirs.length:1),size:c(o)}}),o=l(a.map(e=>e.links)),u=l(a.map(e=>e.size)),d=a.map(e=>`${e.mode} ${e.links.padStart(o)} ${r} ${r} ${e.size.padStart(u)} ${s} ${e.name}`);if(i){let e=a.reduce((e,t)=>e+t.units,0);d.unshift(`total `+(n?oy(BigInt(e)*512n,n):String(e/2)))}return d}}}var ly=Object.freeze({utf8:{down:`├── `,last:`└── `,through:`│\xA0\xA0 `,past:` `},ascii:{down:`|-- `,last:"`-- ",through:`| `,past:` `}}),uy=e=>bn(e)?ly.ascii:ly.utf8;function dy(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`a`,`d`,`F`],long:[`noreport`],valueShort:[`L`]});if(a.length>1)return T(`feature`,`tree`,`multiple roots`,`tree: multiple roots are not supported`);let o=i.has(`L`)?fr(i.get(`L`),`tree: -L`,i.get(`L`),{max:0x7fffffff}):{value:1/0};if(o.error)return o.error;if(!o.value)return C(`tree: -L must be greater than zero`);let s=a[0]??`.`,{path:c,error:l}=F(n,`tree`,s),u=!l&&n.fs.isDir(c),d=j(n.cwd,s,n.fs,{follow:!1}),f=!!l&&!!d.error,p={dirs:u&&my(n.fs,c,r).length?1:0,files:+(!f&&!u)},m=[s+fy(n,r,d,u)+(u?``:` [error opening dir]`)];if(u){let e=new Set,t=Hn();try{let i=py(n.fs,c,m,r,o.value,p,e,t,uy(n));if(i)return i}finally{Jn(n.notes,{command:`tree`,action:`depth limit omitted contents of`,noun:[`directory`,`directories`],paths:e}),t.emit(n.notes,`tree`,`Hidden entries are included with -a.`)}}if(!r.has(`noreport`)){let e=`${p.dirs} ${p.dirs===1?`directory`:`directories`}`,t=`${p.files} ${p.files===1?`file`:`files`}`;m.push(``,r.has(`d`)?e:`${e}, ${t}`)}return{stdout:m.join(`
202
+ `)+`
203
+ `,stderr:``,exitCode:f?2:0}}function fy(e,t,n,r){return t.has(`F`)?!n.error&&e.fs.isLink?.(n.path)===!0?`@`:r&&!t.has(`d`)?`/`:``:``}function py(e,t,n,r,i,a,o,s,c){let l=[{dir:t,prefix:``,items:my(e,t,r,s),i:0,depth:0}];for(;l.length;){let t=l.at(-1);if(t.i>=t.items.length){l.pop();continue}let{n:u,isDir:d,target:f}=t.items[t.i++];if([...u+(f??``)].some(e=>e.codePointAt(0)<32||e.codePointAt(0)===127||e===`\\`))return T(`feature`,`tree`,`filename escaping`,`tree: listing names requiring escaping is not supported`);let p=t.i===t.items.length,m=d&&r.has(`F`)&&!r.has(`d`)?`/`:``;if(n.push(t.prefix+(p?c.last:c.down)+u+(f===void 0?m:` -> `+f+m)),a[d?`dirs`:`files`]++,!d||f!==void 0)continue;let h=Ft(t.dir,u);if(t.depth+1>=i){my(e,h,r).length&&o.add(h);continue}let g=my(e,h,r,s);l.push({dir:h,prefix:t.prefix+(p?c.past:c.through),items:g,i:0,depth:t.depth+1})}}function my(e,t,n,r=null){let{dirs:i,files:a,links:o}=e.listDir(t),s=o.map(n=>{let r=j(t,n,e);return{n,isDir:!r.error&&e.isDir(r.path),target:e.readLink(Ft(t,n))}}),c=n.has(`d`)?s.filter(({isDir:e})=>e):[...a.map(e=>({n:e,isDir:!1})),...s];return r&&!n.has(`a`)&&r.collect(t,[...i,...c.map(({n:e})=>e)]),[...i.map(e=>({n:e,isDir:!0})),...c].filter(({n:e})=>n.has(`a`)||!e.startsWith(`.`)).sort((e,t)=>N(e.n,t.n))}var hy=new Set([`name`,`iname`,`type`,`path`,`ipath`,`lname`,`ilname`,`size`,`mindepth`,`maxdepth`]),gy=(e,t)=>e===`-`+t||e===`--`+t;function _y(e){let t={tokens:e,i:0,depth:{minDepth:0,maxDepth:1/0,deepestFirst:!1},hasAction:!1,batches:[],error:null},n=[];for(e[0]===`--`&&t.i++;t.i<e.length&&!/^(?:-.+|!|\()$/u.test(e[t.i]);)n.push(e[t.i++]);let r=vy(t,0);if(t.error)return{error:t.error};if(!t.hasAction)for(let e of r)e.push({kind:`print`});return{starts:n.length?n:[`.`],...t.depth,groups:r,batches:t.batches}}function vy(e,t){let n=[[]],r=!1;if(t>128)return e.error=T(`feature`,`find`,`expression depth`,`find: expression nesting above 128 is not supported`),n;for(;e.i<e.tokens.length&&!e.error;){let i=e.tokens[e.i];if(i===`)`){t||(e.error=C(`find: unexpected closing parenthesis`));break}if(i===`-a`||gy(i,`and`)||i===`-o`||gy(i,`or`)){if(r||n.at(-1).length===0){e.error=C(`find: ${i} with no left-hand expression`);break}(i===`-o`||gy(i,`or`))&&n.push([]),e.i++,r=i;continue}let a=yy(e,t);a&&n.at(-1).push(a),r=!1}return!e.error&&r&&(e.error=C(`find: ${r} with no right-hand expression`)),!e.error&&t&&n.at(-1).length===0&&(e.error=C(`find: expected an expression`)),!e.error&&t&&(e.tokens[e.i]===`)`?e.i++:e.error=C(`find: missing closing parenthesis`)),n}function yy(e,t){let n=e.i,r=!1;for(;e.tokens[e.i]===`!`||e.tokens[e.i]===`-not`;)r=!r,e.i++;let i=e.tokens[e.i++];if(i===`(`)return{kind:`group`,groups:vy(e,t+1),negate:r};if(i===void 0||i===`)`||i===`-a`||i===`-o`||gy(i,`and`)||gy(i,`or`))return e.error=C(`find: -not or operator ${i??``} must be followed by a primary`),null;let a=i.startsWith(`--`)?i.slice(2):i.startsWith(`-`)?i.slice(1):null;if([`print`,`print0`,`prune`,`empty`].includes(a))return(a===`print`||a===`print0`)&&(e.hasAction=!0),{kind:a,negate:r};if(a===`depth`||a===`d`)return e.depth.deepestFirst=!0,{kind:`true`,negate:r};if(a===`exec`){let t=Dy(e.tokens,e.i-1,r);return t.error?(e.error=t.error,null):(e.i=t.nextI+1,e.hasAction=!0,t.pred.mode===`batch`&&e.batches.push(t.pred),t.pred)}if(hy.has(a)){if(e.i===e.tokens.length)return e.error=C(`find: ${i} requires a value`),null;let t=by(a,e.tokens[e.i++],r,e.depth);return t.error?(e.error=t.error,null):t}return i===`,`?(e.error=T(`feature`,`find`,`comma operator`,`find: comma expressions are not supported`),null):e.i-1>n&&!i.startsWith(`-`)?(e.error=C(`find: -not must be followed by a primary, got: ${i}`),null):(e.error=i===`--`||!i.startsWith(`-`)?C(`find: paths must precede expression: ${i}`):T(`option`,`find`,i,`find: unknown option: ${i}`),null)}function by(e,t,n,r){if(e===`type`){let r=Ey(t);return r.error?r:{kind:e,negate:n,types:r.types}}if(e===`size`)return Cy(t,n);if(e===`mindepth`||e===`maxdepth`){let i=fr(t,`find: -${e}`,t,{max:0x7fffffff,digitsOnly:!0});return i.error?i:(r[e===`mindepth`?`minDepth`:`maxDepth`]=i.value,{kind:`true`,negate:n})}return{kind:e,negate:n,re:mh(t,{ignoreCase:e.startsWith(`i`)})}}var xy={__proto__:null,b:512,c:1,w:2,k:1024,M:1048576,G:0x40000000},Sy=/^([+-]?)(\d+)([a-zA-Z]?)$/u;function Cy(e,t){if(e===``)return{error:C(`find: invalid null argument to -size`)};let n=Sy.exec(e);if(!n||!Number.isSafeInteger(Number(n[2])))return{error:C(`find: Invalid argument \`${e}' to -size`)};let[,r,i,a]=n,o=xy[a===``?`b`:a];return o===void 0?{error:C(`find: invalid -size type \`${a}'`)}:{kind:`size`,negate:t,sign:r,count:Number(i),unit:o}}var wy=`fdl`,Ty=`bcps`;function Ey(e){let t=e.split(`,`),n=t.find((e,n)=>t.indexOf(e)!==n);if(n!==void 0)return{error:C(`find: Duplicate file type '${n}' in the argument list to -type.`)};if(t.every(e=>e.length===1&&wy.includes(e)))return{types:t};let r=`find: -type/--type expects 'f', 'd' or 'l', got: ${e}`;return{error:t.every(e=>e.length===1&&(wy+Ty).includes(e))?T(`option`,`find`,`-type ${e}`,r):C(r)}}function Dy(e,t,n){let r=t+1;for(;r<e.length&&e[r]!==`;`&&(e[r]!==`+`||e[r-1]!==`{}`);)r++;if(r>=e.length)return{error:C("find: -exec: missing terminator (`;` or `{} +`); quote or escape `;`")};if(r===t+1)return{error:C(`find: -exec: requires a command`)};let i=e.slice(t+1,r),a=e[r]===`;`?`each`:`batch`;if(a===`batch`){if(i.slice(0,-1).some(e=>e.includes(`{}`)))return{error:C("find: -exec ... +: only one instance of `{}` is supported")};if(n)return{error:T(`feature`,`find`,`-not -exec ... +`,"find: `-not -exec ... +` is not supported (the `+` form has no meaningful negation)")}}let o={kind:`exec`,mode:a,cmd:i[0],args:i.slice(1),negate:n};return a===`batch`&&(o.collected=[]),{pred:o,nextI:r}}var Oy={file:`f`,dir:`d`,link:`l`},ky=(e,t)=>e.kind===`dir`?ny:t.fs.fileSize?.(e.abs)??O(t.fs.readFile(e.abs)).length;async function Ay(e,t,n){let r=_y(t);if(r.error)return r.error;if(e!==``&&t.some(e=>e===`-exec`||e===`--exec`))return T(`feature`,`find`,`-exec stdin`,`find: passing shared standard input to -exec is not supported`);let{starts:i,minDepth:a,maxDepth:o,deepestFirst:s,groups:c,batches:l}=r,u=G(),d=new Set;try{for(let e of i){let{path:t,error:r}=F(n,`find`,e,{follow:!1});if(r){Fy(u,n.flushOutput(G(`find: '${e}': ${r}
204
+ `))),u.exitCode=1;continue}let i=new Set,l=zt(n.fs,t,o,e=>!i.has(e));for(let r of s?jy(l):l){let s=Iy(e,t,r.path);if(r.depth>=a&&await My(c,{kind:r.kind,path:s,abs:r.path,prune:i},n,u),r.kind!==`dir`||r.depth!==o||i.has(r.path))continue;let{dirs:l,files:f,links:p}=n.fs.listDir(r.path);(l.length||f.length||p.length)&&d.add(s)}}for(let e of l){if(e.collected.length===0)continue;let t=e.args.slice(0,-1).concat(e.collected);await Py(e.cmd,t,n,u)||(u.exitCode=1)}}finally{Jn(n.notes,{command:`find`,action:`depth limit omitted contents of`,noun:[`directory`,`directories`],paths:d})}return u}function*jy(e){let t=[];for(let n of e){for(;t.length>0&&t.at(-1).depth>=n.depth;)yield t.pop();n.kind===`dir`?t.push(n):yield n}for(;t.length>0;)yield t.pop()}async function My(e,t,n,r){for(let i of e){let e=!0;for(let a of i)if(await Ny(a,t,n,r)===!!a.negate){e=!1;break}if(e)return!0}return!1}function Ny(e,t,n,r){if(e.kind===`group`)return My(e.groups,t,n,r);if(e.kind===`true`)return!0;if(e.kind===`type`)return e.types.includes(Oy[t.kind]);if(e.kind===`name`||e.kind===`iname`)return e.re.test(t.path.replace(/\/+$/u,``).split(`/`).at(-1)||`/`);if(e.kind===`prune`)return t.kind===`dir`&&t.prune.add(t.abs),!0;if(e.kind===`empty`){if(t.kind===`link`)return!1;if(t.kind===`file`)return n.fs.isEmptyFile(t.abs);let{dirs:e,files:r,links:i}=n.fs.listDir(t.abs);return e.length+r.length+i.length===0}if(e.kind===`path`||e.kind===`ipath`)return e.re.test(t.path);if(e.kind===`lname`||e.kind===`ilname`)return t.kind===`link`&&e.re.test(n.fs.readLink?.(t.abs)??``);if(e.kind===`size`){let r=Math.ceil(ky(t,n)/e.unit);return e.sign===`+`?r>e.count:e.sign===`-`?r<e.count:r===e.count}return e.kind===`print`||e.kind===`print0`?(Fy(r,n.flushOutput({stdout:t.path+(e.kind===`print`?`
205
+ `:`\0`),stderr:``,exitCode:0})),!0):e.mode===`batch`?(e.collected.push(t.path),!0):Py(e.cmd,e.args.map(e=>e.replaceAll(`{}`,t.path)),n,r)}async function Py(e,t,n,r){let i=await n.dispatch(e,t,``);return Fy(r,i),i.exitCode===0}function Fy(e,t){let n=e.exitCode;K(e,t),e.exitCode=n}function Iy(e,t,n){if(n===t)return e;let r=It(t,n);return e.endsWith(`/`)?e+r:e+`/`+r}var Ly=1e5,Ry=/^([+-]?\d+)\.\.([+-]?\d+)(?:\.\.([+-]?\d+))?$/u,zy=/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([+-]?\d+))?$/u,By=2n**63n-1n,Vy=-(2n**63n),Hy=e=>{let t=BigInt(e);return t>By||t<Vy?null:t},Uy=(e,t)=>e.mask===null?`0`:e.mask[t];function Wy(e,t=Ly){if(!e.value.includes(`{`))return[e];let n=Gy(e);for(let r=0;r<e.value.length;r++){if(e.value[r]!==`{`||Uy(e,r)!==`0`)continue;let i=n.get(r);if(!i)continue;let{end:a,commas:o}=i,s=o.length?[]:qy(Ir(e,r+1,a));if(o.length){let t=r+1;for(let n of[...o,a])s.push(Ir(e,t,n)),t=n+1}if(s===null)continue;let c=Ir(e,0,r),l=Ir(e,a+1),u=[];for(let n of s)if(u.push(...Wy(Vr(c,n,l),t)),u.length>t)throw new D(`feature`,`brace expansion limit`,`brace expansion \`${e.value}\` would produce more than ${t} words`);return u}return[e]}function Gy(e){let t=[],n=new Map;for(let r=0;r<e.value.length;r++){if(Uy(e,r)!==`0`)continue;let i=e.value[r];if(i===`{`)t.push({start:r,commas:[]});else if(i===`}`&&t.length){let{start:e,commas:i}=t.pop();n.set(e,{end:r,commas:i})}else i===`,`&&t.length&&t.at(-1).commas.push(r)}return n}function Ky(e){if(e.mask!==null&&/[12]/u.test(e.mask))return null;let t=Ry.exec(e.value),n=t??zy.exec(e.value);if(!n)return null;let[r,i]=t?[Hy(t[1]),Hy(t[2])]:[BigInt(n[1].codePointAt(0)),BigInt(n[2].codePointAt(0))],a=n[3]===void 0?1n:Hy(n[3]);if(r===null||i===null||a===null||a===Vy)return null;let o=i>=r?i-r:r-i;return o>By?null:{num:t,range:n,from:r,to:i,step:(a<0n?-a:a)||1n,span:o}}function qy(e){let t=Ky(e);if(t===null)return null;let{num:n,from:r,to:i,step:a,span:o}=t,s=o/a+1n;if(s>Ly)throw new D(`feature`,`brace expansion limit`,`brace expansion \`{${e.value}}\` would produce ${s} words (limit ${Ly})`);let c=n?Jy(n[1],n[2]):0,l=[],u=i>=r?1n:-1n;for(let e=0n;e<s;e++){let t=r+u*e*a,i=n?Yy(t,c):String.fromCodePoint(Number(t));l.push({value:i,mask:null})}return l}function Jy(e,t){let n=e=>/^-?0\d/u.test(e);return n(e)||n(t)?Math.max(e.length,t.length):0}function Yy(e,t){let n=String(e<0n?-e:e),r=e<0n?`-`:``;return r+n.padStart(t-r.length,`0`)}var Xy=new Set([`CDPATH`,`GLOBIGNORE`,`GLOBSORT`,`BASH_COMPAT`,`POSIXLY_CORRECT`,`PATH`,`RANDOM`,`SRANDOM`,`SECONDS`,`EPOCHSECONDS`,`EPOCHREALTIME`,`BASHOPTS`,`SHELLOPTS`,`OPTIND`]),Zy=class extends Map{constructor(e){super(e),this.unsetNames=new Set(e?.unsetNames)}set(e,t){if(this.expansionTargets?.has(e))throw new D(`feature`,`temporary assignment side effects`,`modifying a temporary assignment target while expanding assignment values is not supported`);if(Xy.has(e)||e===`TZ`&&![`UTC`,`UTC0`,``].includes(t))throw new D(`feature`,e,`shell variable ${e} is not supported with this value`);return(e===`LANG`||e.startsWith(`LC_`))&&vn(e,t),this.bound?.add(e),this.unsetNames?.delete(e),super.set(e,t)}delete(e){return this.unsetNames.add(e),super.delete(e)}},Qy=new Set([`$`,`!`,`0`,`-`,`_`]),$y=new Set(`PPID.UID.EUID.BASHPID.BASH_SUBSHELL.BASH_VERSION.BASH_VERSINFO.BASH_REMATCH.DIRSTACK.PIPESTATUS.FUNCNAME.LINENO.REPLY.BASH.BASH_COMMAND.BASH_ARGV0.BASH_ARGC.BASH_ARGV.BASH_SOURCE.BASH_LINENO.BASH_ALIASES.BASH_CMDS.GROUPS.HOSTTYPE.OSTYPE.MACHTYPE.HOSTNAME.SHLVL.SHELL.TERM.PS4.OPTERR.HISTCMD.BASH_EXECUTION_STRING.BASH_LOADABLES_PATH.COMP_WORDBREAKS`.split(`.`));function eb(e,t){if(Qy.has(e))throw nb(e);let n=ib(e,t);if(n)return n;if(tb(e))throw nb(e);return{value:``,set:!1}}var tb=e=>Xy.has(e)||$y.has(e),nb=e=>new D(`feature`,`$${e}`,`shell parameter ${e} is not supported`),rb=(e,t)=>ib(e,t)?.value??``;function ib(e,t){return e===`?`?{value:String(t.lastExit),set:!0}:e===`#`?{value:`0`,set:!0}:e===`@`?{value:``,set:!1,omit:!0}:e===`*`||/^[1-9][0-9]*$/u.test(e)?{value:``,set:!1}:t.vars.has(e)?{value:t.vars.get(e),set:!0}:t.vars.unsetNames.has(e)?{value:``,set:!1}:e===`IFS`?{value:`
206
+ `,set:!0}:e===`PWD`?{value:t.cwd,set:!0}:e===`HOME`?{value:t.home,set:!0}:e===`USER`||e===`LOGNAME`?{value:t.user,set:!0}:e===`LANG`?{value:t.locale,set:!0}:null}function ab(e,t){if(Qy.has(e))throw new D(`feature`,`$${e}`,`shell parameter ${e} is not supported (this terminal runs no process)`);let n=ib(e,t);if(n)return n;if(tb(e))throw nb(e);return ob(t,`$${e}`,`warning: $${e} is unset (this shell has no environment variables; only \`for\` bindings and \`NAME=value\` assignments)`),{value:``}}function ob(e,t,n){h_(e,n+`
207
+ `),e.unsupported.add({kind:`feature`,command:null,detail:t,message:n})}var sb=16e6,cb=e=>new D(`feature`,"${",e);function lb(e,t,n){if(Ch(t))throw cb(`extended glob patterns in parameter expansion are not supported`);let r=Eh({value:t.value,mask:t.mask??null}),i=n[0]===`#`,a=gb(r);if(a!==null)return i?e.startsWith(a)?e.slice(a.length):e:e.endsWith(a)?e.slice(0,e.length-a.length):e;let o=mh(r,{bash:!0}),s=i===(n.length===2),c=s?e.length:0,l=0;for(;c>=0&&c<=e.length;){let t=i?e.slice(0,c):e.slice(c);if(l+=t.length+r.length,l>sb)throw cb(`parameter pattern removal exceeds the matching work limit`);if(o.test(t))return i?e.slice(c):e.slice(0,c);c=hb(e,c,s)}return e}function ub(e,t,n,r){let i=``;if(r||!/^[#%]/u.test(t.value)||t.mask&&t.mask[0]!==`0`||(i=t.value[0],t={value:t.value.slice(1),mask:t.mask?.slice(1)??null}),Ch(t))throw cb(`extended glob patterns in parameter expansion are not supported`);let a=Eh({value:t.value,mask:t.mask??null}),o={work:0},s=mb(n,o);if(!a)return i===`#`?s(``)+e:i===`%`?e+s(``):e;if((/\\+$/u.exec(a)?.[0].length??0)%2)throw cb(`unescaped trailing backslashes in replacement patterns are not supported`);let c=gb(a),l=c===null?fb(e,a,i,o):db(e,c,i),u=[],d=0;do{let t=l(d);if(!t)break;let[n,i]=t,a=s(e.slice(n,i));if(pb(o,n-d),u.push(e.slice(d,n),a),d=i,!r)break;if(n===i){let t=hb(e,d,!1);u.push(e.slice(d,t)),d=t}}while(d<e.length);return u.push(e.slice(d)),u.join(``)}function db(e,t,n){return r=>{let i=n===`%`?e.length-t.length:e.indexOf(t,r);return i<r||n===`#`&&i!==0||e.slice(i,i+t.length)!==t?null:[i,i+t.length]}}function fb(e,t,n,r){let i=mh(t,{bash:!0});return a=>{for(let o=a;o<=e.length;o=hb(e,o,!1)){for(let a=e.length;a>=o;a=hb(e,a,!0)){if(pb(r,a-o+t.length),i.test(e.slice(o,a)))return[o,a];if(n===`%`)break}if(n===`#`)break}return null}}function pb(e,t){if(e.work+=t,e.work>sb)throw cb(`parameter replacement exceeds the matching work limit`)}function mb(e,t){let n=``;for(let t=0;t<e.value.length;t++){let r=e.value[t];e.mask?.[t]!==void 0&&e.mask[t]!==`0`&&(r===`&`||r===`\\`)&&(n+=`\\`),n+=r}return e=>{let r=[];for(let i=0;i<n.length;i++){let a=n[i],o=a===`\\`&&/[&\\]/u.test(n[i+1]??``)?n[++i]:a===`&`?e:a;pb(t,o.length),r.push(o)}return r.join(``)}}function hb(e,t,n){let r=t+(n?-1:1);return r>0&&r<e.length&&/[\uDC00-\uDFFF]/u.test(e[r])&&/[\uD800-\uDBFF]/u.test(e[r-1])?r+(n?-1:1):r}function gb(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(r===`\\`&&n+1<e.length)t+=e[++n];else{if(/[*?[]/u.test(r))return null;t+=r}}return t}var _b=e=>BigInt.asIntN(64,e),J=(e,t)=>new D(`feature`,`arithmetic `+e,`arithmetic expansion: `+t);function vb(e){let t=10n,n=!1,r=0n,i=0;if(e[0]===`0`&&(i=1,t=8n,n=!0,(e[1]===`x`||e[1]===`X`)&&(t=16n,i=2)),i===2&&e.length===2)throw J(`number`,`hexadecimal constant has no digits`);for(;i<e.length;i++){let a=e[i];if(a===`#`){if(n||r<2n||r>64n||i===e.length-1)throw J(`number`,`invalid arithmetic base or integer constant`);t=r,r=0n,n=!0;continue}let o=a.codePointAt(0),s=o>=48&&o<=57?o-48:o>=97&&o<=122?o-87:o>=65&&o<=90?o-(t<=36n?55:29):a===`@`?62:a===`_`?63:-1;if(s<0||BigInt(s)>=t)throw J(`number`,`value too great for base in `+e.slice(0,40));r=_b(r*t+BigInt(s))}return r}function yb(e,t){if(t<0n)throw J(`exponent`,`exponent less than zero`);let n=1n;for(let r=t,i=e;r!==0n;r>>=1n,i=_b(i*i))r&1n&&(n=_b(n*i));return n}function bb(e,t,n,r){switch(e){case`+`:return _b(t+n);case`-`:return _b(t-n);case`*`:return _b(t*n);case`/`:case`%`:{if(n===0n&&r)throw J(`division`,`division by zero`);let i=n===0n?1n:n;return _b(e===`/`?t/i:t%i)}case`**`:return yb(t,n);case`<<`:case`>>`:if(n<0n||n>63n)throw J(`shift count`,`shift counts outside 0..63 are not supported`);return _b(e===`<<`?t<<n:t>>n);case`&`:return t&n;case`^`:return t^n;case`|`:return t|n;case`<`:return BigInt(t<n);case`<=`:return BigInt(t<=n);case`>`:return BigInt(t>n);case`>=`:return BigInt(t>=n);case`==`:return BigInt(t===n);case`!=`:return BigInt(t!==n);default:throw J(`operator`,`unsupported operator `+e)}}var xb=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`^=`,`|=`]),Sb=new Map([[`||`],[`&&`],[`|`],[`^`],[`&`],[`==`,`!=`],[`<`,`<=`,`>`,`>=`],[`<<`,`>>`],[`+`,`-`],[`*`,`/`,`%`],[`**`]].flatMap((e,t)=>e.map(e=>[e,t+3]))),Cb=/^(?:<<=|>>=|\+\+|--|\*\*|&&|\|\||<<|>>|[+\-*/%&^|=!<>]=|[+\-*/%&^|=!~<>?:,()])/u;function wb(e){let t=[];for(let n=0;n<e.length;){if(t.length>=1e4)throw J(`limit`,`expression token limit exceeded`);let r=e.slice(n),i=/^[ \t\n]+/u.exec(r);if(i){n+=i[0].length;continue}let a=/^[0-9][A-Za-z0-9#@_]*/u.exec(r),o=/^[A-Za-z_][A-Za-z0-9_]*/u.exec(r),s=Cb.exec(r);if(a)t.push({type:`number`,value:vb(a[0]),raw:a[0]});else if(o)t.push({type:`name`,value:o[0],raw:o[0]});else if(s)t.push({type:`operator`,value:s[0],raw:s[0]});else throw J(r[0]===`[`||r[0]===`]`?`arrays`:`syntax`,`unsupported expression token `+JSON.stringify(r[0]));n+=t.at(-1).raw.length}return t.push({type:`end`,value:``}),t}function Tb(e){let t=new Eb(wb(e));if(t.token.type===`end`)return{type:`number`,value:0n};let n=t.expression();if(t.token.type!==`end`)throw J(`syntax`,`unexpected token `+t.token.value);return n}var Eb=class{constructor(e){this.tokens=e,this.at=0,this.depth=0}get token(){return this.tokens[this.at]}next(){return this.tokens[this.at++]}accept(e){return this.token.value===e?this.next():null}expect(e){if(!this.accept(e))throw J(`syntax`,`expected `+e)}expression(e=0){if(++this.depth>128)throw J(`limit`,`expression nesting limit exceeded`);let t=this.prefix();for(;;){let n=this.token.value;if(n===`?`&&e<=2){this.next();let e=this.expression();this.expect(`:`),t={type:`condition`,test:t,consequent:e,alternate:this.expression(2)};continue}let r=xb.has(n),i=n===`,`?0:r?1:Sb.get(n);if(i===void 0||i<e)break;if(this.next(),r&&t.type!==`name`)throw J(`assignment`,`attempted assignment to non-variable`);let a=this.expression(i+(r||n===`**`?0:1));t={type:r?`assignment`:`binary`,op:n,left:t,right:a}}return this.depth--,t}prefix(){let e=this.next();if([`+`,`-`,`!`,`~`].includes(e.value))return{type:`unary`,op:e.value,value:this.expression(14)};if(e.value===`++`||e.value===`--`){let t=this.next();if(t.type!==`name`)throw J(`increment`,`increment requires a scalar variable`);return{type:`increment`,op:e.value,name:t.value,post:!1}}if(e.value===`(`){let e=this.expression();return this.expect(`)`),{type:`group`,value:e}}if(e.type!==`number`&&e.type!==`name`)throw J(`syntax`,`operand expected`);return e.type===`name`&&(this.token.value===`++`||this.token.value===`--`)?{type:`increment`,op:this.next().value,name:e.value,post:!0}:e}};function Db(e,t,n=0){return Ob(e,{ctx:t,steps:1e4,characters:2e5},n,!0)}function Ob(e,t,n,r){if(typeof e!=`string`)throw J(`value`,`expression must be a string`);if(t.characters-=e.length,e.length>1e5||t.characters<0)throw J(`limit`,`expression size limit exceeded`);if(n>128)throw J(`limit`,`variable recursion limit exceeded`);return jb(Tb(e),t,n+1,r)}function kb(e,t,n,r){if(!r)return 0n;let i;try{i=eb(e,t.ctx)}catch(e){throw J(`variable`,z(e))}return i.set&&i.value!==``?Ob(i.value,t,n+1,!0):0n}function Ab(e,t,n,r){if(r)try{eb(e,n.ctx),n.ctx.vars.set(e,t.toString())}catch(e){throw J(`assignment`,z(e))}return t}function jb(e,t,n,r){if(--t.steps<0||n>128)throw J(`limit`,`expression evaluation limit exceeded`);let i=(e,i=r)=>jb(e,t,n+1,i);switch(e.type){case`number`:return e.value;case`name`:return kb(e.value,t,n,r);case`group`:return i(e.value);case`unary`:{let t=i(e.value);return e.op===`+`?t:e.op===`-`?_b(-t):e.op===`!`?BigInt(t===0n):~t}case`increment`:{let i=kb(e.name,t,n,r),a=Ab(e.name,_b(i+(e.op===`++`?1n:-1n)),t,r);return e.post?i:a}case`assignment`:{let a=e.left.value,o=e.op===`=`?0n:kb(a,t,n,r),s=i(e.right);return Ab(a,e.op===`=`?s:bb(e.op.slice(0,-1),o,s,r),t,r)}case`condition`:{let t=i(e.test)!==0n,n=i(e.consequent,r&&t),a=i(e.alternate,r&&!t);return t?n:a}case`binary`:{let t=i(e.left),n=r&&(e.op===`&&`?t!==0n:e.op!==`||`||t===0n),a=i(e.right,n);return e.op===`,`?a:e.op===`&&`?BigInt(t!==0n&&a!==0n):e.op===`||`?BigInt(t!==0n||a!==0n):bb(e.op,t,a,r)}default:throw J(`syntax`,`unsupported expression`)}}var Mb=e=>new D(`feature`,"${",e);async function Nb(e,t,n,r){if(e.name===`@`||e.name===`*`)throw Mb(`substring and replacement of positional parameter lists are not supported`);if(!t.set)return t;if(e.operator===`:`)try{return{value:await Pb(t.value,e.word,n,r)}}catch(e){throw e.halt=!0,e}let i=e.word,a=0;for(;i[a]===`\\`&&i[a+1]===`
208
+ `;)a+=2;let o=Fb(i,`/`,r.readExpansion,i[a]===`/`?a+1:0),s=await r.expand(i.slice(0,o),{pattern:!0}),c=await r.expand(o<i.length?i.slice(o+1):``,{replacement:!0});return{value:ub(t.value,s,c,e.operator===`//`)}}async function Pb(e,t,n,r){if(/\P{ASCII}/u.test(e))throw Mb(`locale-dependent slicing of non-ASCII parameters is not supported`);let i=Fb(t,`:`,r.readExpansion),a=async e=>Db((await r.expand(e,{arithmetic:!0})).value,n),o=await a(t.slice(0,i)),s=BigInt(e.length);if(o<0n&&(o+=s),o<0n||o>s)return``;let c=s;if(i<t.length){let e=await a(t.slice(i+1));if(c=e<0n?s+e:o+e,c>Rn)throw Mb(`substring length overflows the shell integer range`);if(c<o){let e=Error(`${t.slice(i+1)}: substring expression < 0`);throw e.exitCode=1,e.halt=!0,e}}return e.slice(Number(o),Number(c>s?s:c))}function Fb(e,t,n,r=0){let i=0,a=null,o=0;for(let s=r;s<e.length;s++){let r=e[s];if(a===`'`)r===`'`&&(a=null);else if(a===`ansi`)r===`\\`?s++:r===`'`&&(a=null);else if(r===`\\`)s++;else{if(t===`:`&&(r===`'`||r===`"`))throw Mb(`quoted substring arithmetic is not supported`);if(r===`"`)a=a===`"`?null:`"`;else if(r===`'`&&!a)a=r;else{if(r===`$`){let r=n(e,s,0,t===`:`||a===`"`);if(r){s+=r.raw.length-1;continue}let i=s+1;for(;e[i]===`\\`&&e[i+1]===`
209
+ `;)i+=2;if(!a&&e[i]===`'`){a=`ansi`,s=i;continue}}if(!a){if(t===`:`){if(r===`(`)i++;else if(r===`)`)i--;else if(i===0&&r===`?`)o++;else if(i===0&&r===`:`&&o){o--;continue}if(i!==0)continue}if(r===t)return s}}}}return e.length}var Ib=/^[A-Za-z_][A-Za-z0-9_]*$/u;async function Lb(e,t,n){let{lookup:r,expand:i}=n,{name:a,operator:o,word:s=``}=e,c=r(a,{quiet:o!==``});if(!o)return c;if(o===`length`)return Rb(a,c.value,t);if(o===`:`||o.startsWith(`/`))return Nb(e,c,t,n);if(o[0]===`#`||o[0]===`%`)return!c.value||!s?c:{value:lb(c.value,await i(s,{pattern:!0}),o)};let l=!c.set||o.startsWith(`:`)&&c.value===``,u=o[o.length-1];if(u===`+`)return l?{value:``,...c.omit?{omit:!0}:{}}:i(s,{});if(!l)return c;if(u===`?`)throw await zb(a,s,o.startsWith(`:`),i,t);if(u!==`=`)return i(s,{});if(!Ib.test(a)){let e=Error(`$${a}: cannot assign in this way`);throw e.exitCode=1,e.halt=!0,e}let d=await i(s,{assignment:!0});return t.vars.set(a,d.value),{value:t.vars.get(a)}}function Rb(e,t,n){if(e===`*`||e===`@`)return{value:`0`};if(bn(n))return{value:String(b(t).length)};if(/\P{ASCII}/u.test(t))throw si(`#`+e,`locale-dependent length of non-ASCII parameters is not supported`);return{value:String(t.length)}}async function zb(e,t,n,r,i){let a=t?Bb(await r(t,{error:!0}),i):n?`parameter null or not set`:`parameter not set`,o=Error(`${e}: ${a}`);return o.exitCode=1,o.halt=!0,o}function Bb(e,t){let n=t.vars.get(`IFS`)??`
210
+ `;if(n===``)return e.value;if(n!==`
211
+ `)throw si(`?`,`custom IFS separators in parameter errors are not supported`);let r=new Set(e.empty),i=[],a=!1,o=``,s=()=>{(o||a)&&i.push(o),o=``,a=!1};for(let t=0;t<=e.value.length&&(r.has(t)&&(a=!0),t!==e.value.length);t++){let n=e.value[t],r=!e.mask||e.mask[t]===`0`;r&&/[ \t\n]/u.test(n)?s():(o+=n,a||=!r)}return s(),i.join(` `)}function Vb(e,t){return Hb(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new Zy(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function Hb(e,t,n){let r=Object.fromEntries(Object.keys(t).map(t=>[t,e[t]]));Object.assign(e,t);try{return await n()}finally{Object.assign(e,r)}}async function Ub(e,t){let n=[],r=e[0],i=r?.value===`export`&&!/[12]/u.test(r.mask??``)&&!r.empty?.length;for(let r of e)for(let e of Wy(r)){let a=i&&e===r&&Lr(r);if(a){let r=await Kb(e,a.end,t);n.push({value:r,mask:`1`.repeat(r.length),q:!0})}else n.push(...await Qb(Xb(e,t,e!==r&&`word`),t,!0))}return{argv:Wb(n,t)}}function Wb(e,t){let n=[];for(let r of e){if(Sh(r)){let e=Dh(r,t);if(e.length>0){n.push(...e);continue}}(r.value!==``||r.q)&&n.push(r.value)}return n}async function Gb(e,t){let{argv:n}=await Ub([e],t);return n.length===1?{value:n[0]}:{error:`${e.value}: ambiguous redirect`}}async function Kb(e,t,n){let r=Ir(e,t);return e.value.slice(0,t)+await qb(r,n,!0)}async function qb(e,t,n=!1){return(await Qb(Xb(e,t,n),t,!1,n))[0].value}var Jb=e=>e.vars.get(`HOME`)??e.home,Yb=(e,t)=>e.mask===null?`0`:e.mask[t];function Xb(e,t,n=!1){let r=zr(e,n);if(r.size===0)return e;let i=e.value,a=Jb(t),o=``,s=``,c=[];for(let t=0;t<i.length;t++)if(e.empty?.includes(t)&&c.push(o.length),r.has(t)){let e=a===`/`&&i[t+1]===`/`?``:a;o+=e,s+=`1`.repeat(e.length)}else o+=i[t],s+=Yb(e,t);return e.empty?.includes(i.length)&&c.push(o.length),{value:o,mask:/[12]/u.test(s)?s:null,...c.length?{empty:c}:{}}}function Zb(e,t){return Hb(t,{strictExpansion:!0},()=>$b(Xb(e,t),t))}async function Qb(e,t,n,r=!1){let i=await $b(e,t,r);return n?nx(i,t):[i]}async function $b(e,t,n=!1){let r={value:``,mask:``,empty:[],split:!1},i=(e,t)=>{r.value+=e,r.mask+=t};e.value===``&&e.mask!==null&&r.empty.push(0);for(let a=0;a<=e.value.length&&(e.empty?.includes(a)&&r.empty.push(r.value.length),a!==e.value.length);a++){let o=Yb(e,a),s=e.value[a];if(o===`0`&&(s===`<`||s===`>`)&&e.value[a+1]===`(`)throw new D(`feature`,`${s}(`,`process substitution (\`${s}(\u2026)\`) is not supported`);let c=o!==`1`&&(s===`$`||s==="`"),l=e.value[a+1]===`(`||e.value[a+1]===`{`,u=c?ex(e,a,s,o,l):null;if(!u){i(e.value[a],o);continue}a+=u.raw.length-1;let d=await tx(u,t,o===`2`,n);if(d.literal)i(u.raw,o.repeat(u.raw.length));else if(!d.omit){if(o===`2`)d.value===``&&r.empty.push(r.value.length),i(d.value,`2`.repeat(d.value.length));else{r.split=!0;for(let e of d.empty??[])r.empty.push(r.value.length+e);d.q&&!d.value&&!d.empty?.length&&r.empty.push(r.value.length),i(d.value,d.mask??`0`.repeat(d.value.length))}}}return r.q=r.empty.length>0||/[12]/u.test(r.mask),r}function ex(e,t,n,r,i){return n==="`"?Ur(e.value,t):i?Li(e.value,t,0,r===`2`):Ii(e.value,t,e.mask)}async function tx(e,t,n,r){if(e.command!==void 0)return{value:await t.substitute(e.command,e.backtick)};if(e.arithmetic!==void 0)try{let n=await Hb(t,{strictExpansion:!0},()=>qb(ia(e.arithmetic,!0),t));return{value:String(Db(n,t))}}catch(e){throw e.halt=!0,e}return e.parameter===void 0?t.strictExpansion?eb(e.name,t):ab(e.name,t):e.parameter.operator===``&&!t.strictExpansion&&!/^[0-9]{2,}$/u.test(e.parameter.name)?ab(e.parameter.name,t):Lb(e.parameter,t,{lookup:e=>eb(e,t),readExpansion:Li,expand:(e,i={})=>{let a=i.pattern||i.error||i.replacement||i.arithmetic,o=ia(e,i.arithmetic||!a&&n),s=!a&&(i.assignment||r),c=i.assignment?`parameterAssign`:s?!0:`parameter`;return Hb(t,{strictExpansion:!0},()=>$b(i.arithmetic?o:Xb(o,t,c),t,s))}})}function nx(e,t){if(!e.split)return e.value!==``||e.q?[e]:[];let n=t.vars.get(`IFS`)??`
212
+ `;if(n!==``&&n!==`
213
+ `)throw new D(`feature`,`IFS`,`custom IFS separators are not supported`);let r=[],i={value:``,mask:``,q:!1},a=()=>{(i.value!==``||i.q)&&r.push(i),i={value:``,mask:``,q:!1}},o=new Set(e.empty);for(let t=0;t<=e.value.length&&(o.has(t)&&(i.q=!0),t!==e.value.length);t++){let r=e.value[t],o=e.mask[t];n!==``&&o===`0`&&/[ \t\n]/u.test(r)?a():(i.value+=r,i.mask+=o,i.q||=o!==`0`)}return a(),r}function rx(e,t,n){let r=Zv(t,n),i={ctx:n,options:r,seen:new Set,result:G(),total:0n,failed:!1};r.stderr&&K(i.result,n.flushOutput(G(r.stderr)));for(let e of r.operands){let t=e.length>2?e.replace(/\/+$/u,`/`):e,a=F(n,`du`,t,{follow:r.links!==`none`});if(a.error)K(i.result,n.flushOutput(C(`du: cannot access ${q(t,n)}: ${a.error}`))),i.failed=!0;else try{ix(a.path,t,i)}catch(e){let t=w(e),r=`du: `+z(e);if(t&&n.unsupported.add({...t,command:t.command??`du`,message:r}),K(i.result,n.flushOutput(C(r))),i.failed=!0,t)return i.result}}return r.flags.has(`c`)&&ax(i.total,`total`,i),i.result.exitCode=+!!i.failed,i.result}function ix(e,t,n){let{ctx:r,options:i}=n;if(!i.flags.has(`inodes`)&&r.fs.isDir(e)&&Object.values(r.outputFds??{}).some(t=>typeof t==`object`&&t.path?.startsWith(e===`/`?`/`:e+`/`)))throw new D(`feature`,`recursive metadata output overlap`,`output within a measured directory is not supported`);let a=[{path:e,name:t,depth:0}];for(;a.length;){let e=a.pop();if(e.total!==void 0){e.depth<=i.depth&&ax(e.total,e.name,n),e.parent&&!i.flags.has(`S`)&&(e.parent.total+=e.total);continue}let t=r.fs.isDir(e.path);if(!t&&i.links===`all`&&r.fs.isLink?.(e.path))throw new D(`option`,`dereference`,`following symbolic links is not supported: ${e.name}`);let o=t?e.path:r.fs.fileIdentity?.(e.path)??e.path;if(!i.flags.has(`l`)&&n.seen.has(o))continue;n.seen.add(o);let s=t?`dir`:r.fs.isLink?.(e.path)?`link`:`file`,c=t?0:r.fs.fileSize(e.path),l=i.flags.has(`inodes`)?1n:i.flags.has(`A`)?BigInt(c):BigInt(iy(c,s));if(n.total+=l,t){e.total=l,a.push(e);let t=r.fs.listDir(e.path),n=[...new Set([...t.dirs,...t.files,...t.links])].sort(N),i=e.name.endsWith(`/`)?e.name:e.name+`/`;for(let t=n.length-1;t>=0;t--)a.push({path:Ft(e.path,n[t]),name:i+n[t],depth:e.depth+1,parent:e})}else e.parent&&(e.parent.total+=l),(e.depth===0||i.flags.has(`a`)&&e.depth<=i.depth)&&ax(l,e.name,n)}}function ax(e,t,n){let r=`${oy(e,n.options.scale)} ${t}${n.options.flags.has(`0`)?`\0`:`
214
+ `}`;K(n.result,n.ctx.flushOutput({...G(),stdout:r,events:[{fd:1,text:r}]}))}var ox=/^%([-+ 0#']*)(\d+|\*)?'?(?:\.(\d+|\*)?)?[hlL]?(.)?/su,sx=`diouxXeEfFgGcs`;function cx(e){let t=[],n=``;for(let r=0;r<e.length;r++){if(e[r]!==`%`){n+=e[r];continue}if(e[r+1]===`%`){n+=`%`,r++;continue}if(/^%[^a-zA-Z%]*\$/u.test(e.slice(r)))throw new W(`positional printf arguments are not supported`,null,`positional format arguments`);let i=ox.exec(e.slice(r)),a=i[4];if(a===`a`||a===`A`)throw new W(`hexadecimal floating-point formats are not supported`,null,`hexadecimal float format`);if(a===`%`){n+=`%`,r+=i[0].length-1;continue}if(a===void 0||!sx.includes(a)){n+=i[0],r+=i[0].length-1;continue}n!==``&&(t.push(n),n=``);let o=i[1];t.push({minus:o.includes(`-`),plus:o.includes(`+`),space:o.includes(` `),zero:o.includes(`0`),alt:o.includes(`#`),width:i[2]===void 0?null:i[2]===`*`?`*`:Number(i[2]),precision:i[3]===void 0?i[0].includes(`.`)?0:null:i[3]===`*`?`*`:Number(i[3]),conv:a}),r+=i[0].length-1}return n!==``&&t.push(n),t}function lx(e,t,n,r){let i=n.width??0;if(i>Ep)throw new W(`format width exceeds the output limit`,null,`format size limit`);let a=i-e.length-[...t].length;return a<=0?e+t:n.minus?e+t+` `.repeat(a):n.zero&&r?e+`0`.repeat(a)+t:` `.repeat(a)+e+t}var ux=e=>e.plus?`+`:e.space?` `:``,dx=e=>e===`X`||e===`E`||e===`G`||e===`F`;function fx(e,t){if(t.precision>Ep)throw new W(`format precision exceeds the output limit`,null,`format size limit`);let{conv:n}=t;if(!Number.isFinite(e)){if(Number.isNaN(e))throw new W(`formatting signed NaN is not supported`,null,`signed NaN`);let t=e<0?`-inf`:`+inf`;return dx(n)?t.toUpperCase():t}return`ouxX`.includes(n)&&(e>=2**64||e<-(2**63))?hx(e,{...t,conv:`g`}):`diouxX`.includes(n)?px(e,t):hx(e,t)}function px(e,t){let{conv:n}=t,r=n===`d`||n===`i`,i=r?Math.trunc(e)===0:e===0,a=BigInt(Math.trunc(e)),o=!1;a<0n&&(r?(o=!0,a=-a):a=BigInt.asUintN(64,a));let s=n===`o`?8:n===`x`||n===`X`?16:10,c=a.toString(s);n===`X`&&(c=c.toUpperCase()),t.precision!==null&&(c=t.precision===0&&i?t.alt&&!r?`0`:``:c.padStart(t.precision,`0`));let l=o?`-`:r&&c!==``?ux(t):``;return t.alt&&!i&&(n===`o`&&(c=`0`+c),(n===`x`||n===`X`)&&(l+=n===`x`?`0x`:`0X`)),lx(l,c,t,t.precision===null)}var mx=100;function hx(e,t){let{conv:n}=t;if(t.precision>mx)throw new W(`floating-point precision above ${mx} is not supported`,null,`float precision limit`);let r=t.precision??6,i=e<0||Object.is(e,-0),a=Math.abs(e),o;return o=n===`e`||n===`E`?_x(a,r):n===`f`||n===`F`?vx(a,r):yx(a,r,t.alt),t.alt&&r===0&&n!==`g`&&n!==`G`&&(o=n===`e`||n===`E`?o.replace(`e`,`.e`):o+`.`),dx(n)&&(o=o.toUpperCase()),lx(i?`-`:ux(t),o,t,!0)}function gx(e,t,n,r){let i=t.slice(r);if(!/^50*$/u.test(i))return e;let a=t.slice(0,n),o=a.at(-1);return Number(o)%2==0?a:e}function _x(e,t){let n=e.toExponential(mx),r=n.indexOf(`.`),i=n.indexOf(`e`),[a,o]=e.toExponential(t).split(`e`),s=gx(a,n.slice(0,i),t===0?r:r+1+t,r+1+t),c=Number(s===a?o:n.slice(i+1));return`${s}e${c<0?`-`:`+`}${String(Math.abs(c)).padStart(2,`0`)}`}function vx(e,t){if(e>=1e21)return BigInt(e).toString()+(t>0?`.`+`0`.repeat(t):``);let n=e.toFixed(mx),r=n.indexOf(`.`);return gx(e.toFixed(t),n,t===0?r:r+1+t,r+1+t)}function yx(e,t,n){let r=t===0?1:t;if(e===0)return n?`0.`+`0`.repeat(r-1):`0`;let i=_x(e,r-1),a=i.indexOf(`e`),o=Number(i.slice(a+1));if(o<-4||o>=r)return n?i.includes(`.`)?i:i.slice(0,a)+`.`+i.slice(a):bx(i.slice(0,a))+i.slice(a);let s=vx(e,r-1-o);return n?s.includes(`.`)?s:s+`.`:bx(s)}var bx=e=>e.includes(`.`)?e.replace(/\.?0+$/u,``):e,xx=/^[+-]?(?:0[bB][01]+|0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)/u,Sx=/^[+-]?(?:0[xX](?:[\da-fA-F]+(?:\.[\da-fA-F]*)?|\.[\da-fA-F]+)(?:[pP][+-]?\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|inf(?:inity)?|nan(?:\([\w]*\))?)/iu;function Cx(e,t){if(e?.[0]!==`'`&&e?.[0]!==`"`)return null;let n=e.slice(1);if(n===``)return null;let r=b(n),i=t.byteLocale?1:b(String.fromCodePoint(n.codePointAt(0))).length;return r.length>i&&(t.stderr+=`printf: warning: ${k(r.slice(i))}: character(s) following character constant have been ignored
215
+ `),t.byteLocale?r[0]:n.codePointAt(0)}function wx(e,t,n){if(e===void 0||e===``)return`0`;let r=e.replace(/^[ \t\n\r\f\v]+/u,``),i=t.exec(r)?.[0]??``;return(i.length!==r.length||i===``)&&(n.stderr+=`printf: ${Dx(e,n)}: ${i?`value not completely converted`:`expected a numeric value`}
216
+ `,n.failed=!0),i||`0`}var Tx={"\x07":`\\a`,"\b":`\\b`," ":`\\t`,"\n":`\\n`,"\v":`\\v`,"\f":`\\f`,"\r":`\\r`,"\\":`\\\\`,"'":`\\'`},Ex=e=>`\\`+e.toString(8).padStart(3,`0`);function Dx(e,t){let n=``;for(let r of e){if(Tx[r]!==void 0){n+=Tx[r];continue}let e=r.codePointAt(0);n+=e<32||e===127?Ex(e):e>127&&t.byteLocale?b(r).map(Ex).join(``):r}return`'${n}'`}function Ox(e,t,n){let r=Cx(e,n);if(r!==null)return BigInt(r);let i=wx(e,xx,n),a=i[0]===`-`,o=i.replace(/^[+-]/u,``),s=BigInt(/^0[0-7]+$/u.test(o)?`0o`+o:o),c=a?-s:s;return(t?s>Bn:c<zn||c>Rn)?(n.stderr+=`printf: ${Dx(e,n)}: Numerical result out of range
217
+ `,n.failed=!0,t?Bn:a?zn:Rn):t?BigInt.asUintN(64,c):c}function kx(e,t){let{conv:n}=t,r=n===`d`||n===`i`,i=e<0n,a=n===`o`?8:n===`x`||n===`X`?16:10,o=(i?-e:e).toString(a);n===`X`&&(o=o.toUpperCase()),e===0n&&t.precision===0&&(o=``),o=o.padStart(t.precision??0,`0`);let s=i?`-`:r?t.plus?`+`:t.space?` `:``:``;return t.alt&&(n===`o`&&!o.startsWith(`0`)&&(o=`0`+o),e!==0n&&(n===`x`||n===`X`)&&(s=n===`x`?`0x`:`0X`)),lx(s,o,t,t.precision===null)}function Ax(e,t,n){let r=Cx(e,n),i=r===null?wx(e,Sx,n):String(r),a=i.replace(/^[+-]/u,``);if(/^(?:inf|nan)/iu.test(a)){let e=i.startsWith(`-`)?`-`:t.plus?`+`:t.space?` `:``,n=/^nan/iu.test(a)?`nan`:`inf`;return t.conv===t.conv.toUpperCase()&&(n=n.toUpperCase()),lx(e,n,t,!1)}let o=Rx(a),s=i.startsWith(`-`)?-o.value:o.value;if(t.precision>100||`gG`.includes(t.conv)&&t.precision>96)throw new D(`feature`,`float precision limit`,`floating-point precision exceeds the supported limit`);try{let e=fx(s,t);if(!o.exact){let[n,r]=Nx(o.value);for(let a of[n,r])if(fx(i.startsWith(`-`)?-a:a,t)!==e)throw new D(`feature`,`floating-point precision`,`floating-point formatting at this precision is not supported`)}return e}catch(e){throw e.gap?new D(`feature`,e.gap,e.message):e}}var jx=new DataView(new ArrayBuffer(8));function Mx(e){return jx.setFloat64(0,e),jx.getBigUint64(0)}function Nx(e){let t=Mx(e);jx.setBigUint64(0,t-1n);let n=jx.getFloat64(0);return jx.setBigUint64(0,t+1n),[n,jx.getFloat64(0)]}function Px(e){let t=Mx(e),n=Number(t>>52n);return{coefficient:t&(1n<<52n)-1n|(n?1n<<52n:0n),exponent:n?n-1075:-1074}}function Fx(e,t){let n=e.replace(/^0+|0+$/gu,``);return{digits:n||`0`,exponent:n?t+e.length-e.replace(/0+$/u,``).length:0}}function Ix({coefficient:e,exponent:t}){return t<0?Fx((e*5n**BigInt(-t)).toString(),t):Fx((e<<BigInt(t)).toString(),0)}function Lx(e,t){let n=e.exponent-t.exponent;return n>=0?e.coefficient<<BigInt(n)===t.coefficient:e.coefficient===t.coefficient<<BigInt(-n)}function Rx(e){let t=/^0x/iu.test(e),n,r;if(t)n=zx(e),r=Bx(n);else{let[t,i=`0`]=e.split(/[eE]/u),[a,o=``]=t.split(`.`);n=Fx(a+o,Number(i)-o.length),r=Number(e)}if(!Number.isFinite(r))throw new D(`feature`,`floating-point range`,`floating-point values outside the JavaScript number range are not supported`);if(r===0){if(t?n.coefficient!==0n:n.digits!==`0`)throw new D(`feature`,`floating-point range`,`floating-point underflow is not supported`);return{value:r,exact:!0}}let i=Px(r),a=Ix(i),o=t?Lx(n,i):n.digits===a.digits&&n.exponent===a.exponent;return{value:r,exact:o&&a.exponent>=-100&&a.digits.length<=101}}function zx(e){let[t,n=`0`]=e.slice(2).split(/[pP]/u),[r,i=``]=t.split(`.`),a=(r+i).replace(/^0+/u,``)||`0`;if(a.length>4096)throw new D(`feature`,`floating-point input limit`,`hexadecimal floating-point significands above 4096 digits are not supported`);return{coefficient:BigInt(`0x`+a),exponent:Number(n)-4*i.length}}function Bx({coefficient:e,exponent:t}){if(e===0n)return 0;let n=e.toString(2).length,r=t+n-1;if(r>1023)return 1/0;if(r<-1075)return 0;let i=Math.max(0,n-53,-1074-t),a=e>>BigInt(i);if(i>0){let t=e-(a<<BigInt(i)),n=1n<<BigInt(i-1);(t>n||t===n&&a%2n!=0n)&&a++}return Number(a)*2**(t+i)}var Vx={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,'"':34,"\\":92};function Hx(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]===`%`){if(e[r+1]===`%`||r+1===e.length){n.push([37]),r+=2;continue}let t=/^%([-+ #0']*)(\d+)?(?:\.(\d*))?([\s\S])?/u.exec(e.slice(r)),[,i,a,o,s]=t;if(!s||s===`%`)throw Error(`invalid directive: ${t[0]}`);if(!`nsF`.includes(s))throw new D(`feature`,`%`+s,`format %${s} is not supported`);if(i.includes(`'`))throw new D(`feature`,`grouped format`,`digit grouping in stat formats is not supported`);let c={field:s,conv:`u`,width:Number(a??0),precision:o===void 0?null:Number(o||0),minus:i.includes(`-`),zero:i.includes(`0`),plus:i.includes(`+`),space:i.includes(` `),alt:i.includes(`#`)};if(c.width>Ep||c.precision>Ep)throw new D(`feature`,`format size limit`,`format width or precision exceeds the output limit`);n.push(c),r+=t[0].length}else if(e[r]===`\\`&&t){let t=e[r+1],i=/^(?:[0-7]{1,3}|x[\da-fA-F]{1,2})/u.exec(e.slice(r+1))?.[0];if(i){let e=i[0]===`x`?16:8;n.push([parseInt(e===16?i.slice(1):i,e)&255]),r+=i.length+1}else if(Object.hasOwn(Vx,t))n.push([Vx[t]]),r+=2;else throw new D(`feature`,`format escape`,`format escape ${JSON.stringify(e.slice(r,r+2))} is not supported`)}else{let i=r+1;for(;i<e.length&&e[i]!==`%`&&!(t&&e[i]===`\\`);)i++;n.push(O(e.slice(r,i))),r=i}return t||n.push([10]),n}function Ux(e,t,n,r){let i=r.isDir(n),a=!i&&r.isLink?.(n)===!0,o,s=e.map(e=>{if(!e.field)return e;if(e.field===`n`)return Wx(t,e);if(e.field===`s`&&i)throw new D(`feature`,`directory byte size`,`directory byte sizes are not available: ${t}`);return o??=i?0:r.fileSize(n),e.field===`F`?Wx(i?`directory`:a?`symbolic link`:o===0?`regular empty file`:`regular file`,e):O(kx(BigInt(o),e))}),c=new Uint8Array(s.reduce((e,t)=>e+t.length,0)),l=0;for(let e of s)c.set(e,l),l+=e.length;return k(c)}function Wx(e,t){let n=O(e);t.precision!==null&&(n=n.subarray(0,t.precision));let r=Math.max(0,t.width-n.length);if(!r)return n;let i=new Uint8Array(n.length+r).fill(32);return i.set(n,t.minus?0:r),i}function Gx(e,t,n){let{order:r,positional:i}=U(t,{short:[`L`,`t`],long:[`dereference`,`terse`],valueShort:[`c`],valueLong:[`format`,`printf`,`cached`]});if(!i.length)return C(`stat: missing operand`);let a=r.some(({name:e})=>e===`L`||e===`dereference`),o;for(let e of r)if(e.name===`cached`){if(!e.value||![`always`,`never`,`default`].some(t=>t.startsWith(e.value)))return C(`stat: invalid cache mode: ${e.value}`)}else[`c`,`format`,`printf`].includes(e.name)&&(o=e);if(!o)return T(`feature`,`stat`,`default metadata`,`stat: default output requires filesystem metadata that is not available`);let s=Hx(o.value,o.name===`printf`);if(s.some(e=>e.field===`s`||e.field===`F`)&&qx(i,n,a))return T(`feature`,`stat`,`metadata output overlap`,`stat: buffered output sharing a measured file is not supported`);let c=G(),l=!1;for(let e of i){let t=Kx(s,e,n,a);K(c,t),l||=t.exitCode!==0}return c.exitCode=+!!l,c}function Kx(e,t,n,r){if(t===`-`){let e=T(`feature`,`stat`,`standard input metadata`,`stat: standard input metadata is not supported`);return n.unsupported.add({kind:`feature`,command:`stat`,detail:`standard input metadata`,message:e.stderr.trimEnd()}),e}let i=F(n,`stat`,t,{follow:r});if(i.error)return C(`stat: cannot statx ${q(t,n)}: ${i.error}`);try{return S(Ux(e,t,i.path,n.fs))}catch(e){let t=dt(e,`stat`,`stat: `+z(e)),r=w(t);return r&&n.unsupported.add(r),t}}function qx(e,t,n){let r=Object.values(t.outputFds).filter(e=>typeof e==`object`);return r.length?e.some(e=>{let i=j(t.cwd,e,t.fs,{follow:n});return!i.error&&r.some(e=>e.path===i.path||e.identity!==void 0&&e.identity===t.fs.fileIdentity?.(i.path))}):!1}var Jx=[` 1970-01-01 00:00:00.000000000 +0000`,` Thu Jan 1 00:00:00 1970`];function Yx(e,t,n,r,i){let{ctx:a,opts:o}=e,s=Xx(o,t);if(s===``)return``;let c=e=>o.labels[e]??E_(n[e],a)+(r[e]?Jx[+(o.style===`context`)]:``),l=e=>o.labels[e]??E_(n[e],a),u=i?`diff${o.switches} ${l(0)} ${l(1)}
218
+ `:``;return o.style===`unified`?`${u}--- ${c(0)}
219
+ +++ ${c(1)}
220
+ ${s}`:o.style===`context`?`${u}*** ${c(0)}
221
+ --- ${c(1)}
222
+ ${s}`:u+s}function Xx(e,t){let n=e.showFunction?$n(t[0]):null;return de(t[0],t[1],{format:e.style??`normal`,context:e.context,label:n?e=>Qx(n,e):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace,horizon:e.horizon})}var Zx=/^[A-Za-z$_]/u;function Qx(e,t){for(let n=t-1;n>=0;n--){if(!Zx.test(e[n]))continue;let t=b(e[n].replace(/\n$/u,``)),r=Math.min(40,t.length);for(;r>0&&$x(t[r-1]);)r--;return eS(t.subarray(0,r))}return null}var $x=e=>e===32||e>=9&&e<=13;function eS(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return k(e.subarray(0,t))}catch{}return``}var tS=[`q`,`s`,`r`,`N`,`a`,`i`,`w`,`b`,`Z`,`p`,`d`,`u`,`c`,`e`,`n`,`y`,`t`,`T`,`l`,`E`,`B`,`P`,`v`,`H`],nS=`brief.report-identical-files.recursive.new-file.text.ignore-case.ignore-all-space.ignore-space-change.ignore-trailing-space.strip-trailing-cr.show-c-function.minimal.normal.unified.context.ed.rcs.side-by-side.expand-tabs.initial-tab.paginate.ignore-tab-expansion.ignore-blank-lines.unidirectional-new-file.version.help.suppress-common-lines.speed-large-files.ignore-file-name-case.no-ignore-file-name-case.no-dereference.left-column`.split(`.`),rS=[`U`,`C`,`x`,`X`,`S`,`F`,`W`,`I`,`D`],iS=[`show-function-line`,`exclude-from`,`starting-file`,`from-file`,`to-file`,`ifdef`,`width`,`tabsize`,`horizon-lines`,`ignore-matching-lines`,`line-format`,`old-line-format`,`new-line-format`,`unchanged-line-format`,`old-group-format`,`new-group-format`,`unchanged-group-format`,`changed-group-format`,`color`,`palette`],aS=[`L`,`label`,`x`,`exclude`],oS=new Map([[`e`,`ed script output`],[`ed`,`ed script output`],[`n`,`RCS output`],[`rcs`,`RCS output`],[`y`,`side-by-side output`],[`side-by-side`,`side-by-side output`],[`W`,`side-by-side output`],[`width`,`side-by-side output`],[`suppress-common-lines`,`side-by-side output`],[`left-column`,`side-by-side output`],[`t`,`tab expansion`],[`expand-tabs`,`tab expansion`],[`T`,`initial tabs`],[`initial-tab`,`initial tabs`],[`tabsize`,`tab expansion`],[`E`,`tab expansion`],[`ignore-tab-expansion`,`tab expansion`],[`B`,`ignoring blank lines`],[`ignore-blank-lines`,`ignoring blank lines`],[`I`,`ignoring matching lines`],[`ignore-matching-lines`,`ignoring matching lines`],[`D`,`merged #ifdef output`],[`ifdef`,`merged #ifdef output`],[`l`,`pagination`],[`paginate`,`pagination`],[`F`,`a custom function regex`],[`show-function-line`,`a custom function regex`],[`X`,`reading exclusions from a file`],[`exclude-from`,`reading exclusions from a file`],[`S`,`a starting file`],[`starting-file`,`a starting file`],[`from-file`,`comparing one file to many`],[`to-file`,`comparing one file to many`],[`P`,`one-sided new files`],[`unidirectional-new-file`,`one-sided new files`],[`v`,`a version banner`],[`version`,`a version banner`],[`help`,`a help text`],[`H`,`large-file heuristics`],[`speed-large-files`,`large-file heuristics`],[`ignore-file-name-case`,`case-insensitive names`],[`no-ignore-file-name-case`,`case-insensitive names`],[`no-dereference`,`symbolic links`],[`color`,`colored output`],[`palette`,`colored output`],[`line-format`,`custom line formats`],[`old-line-format`,`custom line formats`],[`new-line-format`,`custom line formats`],[`unchanged-line-format`,`custom line formats`],[`old-group-format`,`custom group formats`],[`new-group-format`,`custom group formats`],[`unchanged-group-format`,`custom group formats`],[`changed-group-format`,`custom group formats`]]),sS=e=>C(`diff: ${e}
223
+ diff: Try 'diff --help' for more information.`,2);function cS(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`){t.push(...e.slice(n));break}if(r===`--unified`||r===`--context`)t.push(`-`+(r===`--unified`?`u`:`c`));else if(r.startsWith(`--unified=`)||r.startsWith(`--context=`))t.push(r.startsWith(`--u`)?`-U`:`-C`,r.slice(10));else{if(r.startsWith(`--color`))return{refused:`colored output`,label:r};t.push(r)}}return{tokens:t}}function lS(e){let t=cS(e);if(t.refused)return{refused:T(`option`,`diff`,t.label.replace(/=.*/u,``),`diff: ${t.label}: ${t.refused} is not supported`,2)};let n;try{n=U(t.tokens,{short:tS,long:nS,valueShort:rS,valueLong:iS,repeatable:aS})}catch(e){let t=w(e);return t?{refused:T(t.kind,`diff`,t.detail,`diff: ${e.message}`,2)}:{error:sS(e.message)}}let r={style:null,context:-1,horizon:0,labels:[],excludes:[],whitespace:`none`,switches:fS(e)};for(let{name:e,value:t}of n.order){let n=oS.get(e),i=(e.length===1?`-`:`--`)+e;if(n)return{refused:T(`option`,`diff`,i,`diff: ${i}: ${n} is not supported`,2)};let a=uS(r,e,t);if(a)return{error:a}}return r.showFunction&&r.style===null&&(r.style=`context`),r.context<0&&(r.context=3),n.positional.length<2?{error:sS(`missing operand after '${n.positional[0]??`diff`}'`)}:n.positional.length>2?{error:sS(`extra operand '${n.positional[2]}'`)}:{opts:r,operands:n.positional}}function uS(e,t,n){let r=t=>e.style!==null&&e.style!==t?sS(`conflicting output style options`):(e.style=t,null);switch(t){case`u`:case`c`:{let n=r(t===`u`?`unified`:`context`);return e.context<3&&(e.context=3),n}case`U`:case`C`:{let i=dS(n);if(i===null)return sS(`invalid context length '${n}'`);let a=r(t===`U`?`unified`:`context`);return e.context<i&&(e.context=i),a}case`normal`:return r(`normal`);case`horizon-lines`:{let t=dS(n);return t===null?sS(`invalid horizon length '${n}'`):(e.horizon=Math.max(e.horizon,t),null)}case`q`:case`brief`:return e.brief=!0,null;case`s`:case`report-identical-files`:return e.identical=!0,null;case`r`:case`recursive`:return e.recursive=!0,null;case`N`:case`new-file`:return e.newFile=!0,null;case`a`:case`text`:return e.text=!0,null;case`i`:case`ignore-case`:return e.ignoreCase=!0,null;case`w`:case`ignore-all-space`:return e.whitespace=`all`,null;case`b`:case`ignore-space-change`:return e.whitespace!==`all`&&(e.whitespace=`change`),null;case`Z`:case`ignore-trailing-space`:return e.whitespace===`none`&&(e.whitespace=`trailing`),null;case`strip-trailing-cr`:return e.stripCr=!0,null;case`p`:case`show-c-function`:return e.showFunction=!0,null;case`d`:case`minimal`:return e.minimal=!0,null;case`L`:case`label`:return e.labels.length===2?C(`diff: too many file label options`,2):(e.labels.push(n),null);case`x`:case`exclude`:return e.excludes.push(n),null;default:return null}}function dS(e){if(e===``)return 0;let t=/^[ \t\n\v\f\r]*([-+]?)(\d+)$/u.exec(e);return!t||t[1]===`-`&&/[1-9]/u.test(t[2])?null:Math.min(Number(t[2]),2**53-1)}function fS(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`--`)break;!r.startsWith(`-`)||r===`-`||(t.push(r),pS(r)&&n+1<e.length&&t.push(e[++n]))}return t.map(e=>` `+w_(e,{vars:new Map})).join(``)}function pS(e){if(e.startsWith(`--`))return!e.includes(`=`)&&(iS.includes(e.slice(2))||e===`--label`||e===`--exclude`);for(let t=1;t<e.length;t++){let n=e[t];if(rS.includes(n)||n===`L`)return t+1===e.length}return!1}function mS(e,t,n){let{ctx:r,opts:i}=e,a=SS(xS(e,t),xS(e,n));for(let[o,s,c]of a){let a=wS(t,o),l=wS(n,o),u=s?yS(r,a):null,d=c?yS(r,l):null;s&&c?gS(e,[a,l],[u,d]):i.newFile?hS(e,[a,l],u??d,[s,c]):DS(e,`Only in ${s?t:n}: ${o}
224
+ `,1)}}function hS(e,[t,n],r,i){vS(r)?e.opts.recursive?bS(e,[t,n],i.map(e=>e?r:null)):DS(e,`Common subdirectories: ${t} and ${n}
225
+ `):OS(e,t,n,!0,i)}function gS(e,[t,n],[r,i]){let{opts:a}=e,o=[r,i].indexOf(`gone`);if(o!==-1&&vS([r,i][1-o])){let r=[t,n][o];return DS(e,`diff: ${r}: ${j(e.ctx.cwd,r,e.ctx.fs).error}
226
+ `,2,!0)}if(vS(r)&&vS(i))a.recursive?bS(e,[t,n],[r,i]):DS(e,`Common subdirectories: ${t} and ${n}
227
+ `);else if(r===i||o!==-1)OS(e,t,n,!0,[!0,!0]);else{let o=(e,t)=>a.labels[e]??t;DS(e,`File ${o(0,t)} is a ${_S[r]} while file ${o(1,n)} is a ${_S[i]}
228
+ `,1)}}var _S={dir:`directory`,link:`directory`,file:`regular file`},vS=e=>e===`dir`||e===`link`;function yS(e,t){let n=j(e.cwd,t,e.fs);return n.error?`gone`:e.fs.isDir(n.path)?e.fs.isLink?.(j(e.cwd,t,e.fs,{follow:!1}).path)?`link`:`dir`:`file`}function bS(e,[t,n],[r,i]){for(let[e,a]of[[r,t],[i,n]])if(e===`link`)throw new D(`feature`,`symbolic link to a directory`,`comparing what a symbolic link to a directory holds is not supported: ${a}`);mS(e,t,n)}function xS(e,t){let{ctx:n,opts:r}=e,i=j(n.cwd,t,n.fs);if(i.error||!n.fs.isDir(i.path))return[];let{dirs:a,files:o,links:s}=n.fs.listDir(i.path),c=[...a,...o,...s].sort(N);return r.excludes.length?c.filter(e=>!r.excludes.some(t=>xh(e,t))):c}function SS(e,t){let n=[],r=0,i=0;for(;r<e.length||i<t.length;){let a=r===e.length?1:i===t.length?-1:N(e[r],t[i]);a===0?(n.push([e[r++],!0,!0]),i++):a<0?n.push([e[r++],!0,!1]):n.push([t[i++],!1,!0])}return n}function CS(e,t,n){let r=lS(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:i,operands:a}=r,o={ctx:n,opts:i,stdin:e,out:G(),status:0},[s,c]=a,l=a.map(e=>ES(o,e));if(l[0]===`dir`&&l[1]===`dir`&&TS(o,s,c))return o.out;if(l[0]===`dir`&&l[1]===`dir`)mS(o,s,c);else if(l[0]===`dir`||l[1]===`dir`){let e=l[0]===`dir`?0:1,t=a[1-e];if(t===`-`)return C(`diff: cannot compare '-' to a directory`,2);if(l[1-e]===`missing`){let e=j(o.ctx.cwd,t,o.ctx.fs).error;i.newFile&&e===`No such file or directory`?mS(o,s,c):DS(o,`diff: ${t}: ${e}
229
+ `,2,!0)}else{let n=wS(a[e],Pt(t)),r=e===0?[n,t]:[t,n];ES(o,n)===`missing`?DS(o,`diff: ${n}: No such file or directory
230
+ `,2,!0):OS(o,r[0],r[1],!1)}}else OS(o,s,c,!1);return o.out.exitCode=o.status,o.out}function wS(e,t){let n=e.replace(/\/+$/u,``);return(n===``?`/`:n+`/`)+t}function TS(e,t,n){return j(e.ctx.cwd,t,e.ctx.fs).path===j(e.ctx.cwd,n,e.ctx.fs).path}function ES(e,t){if(t===`-`)return`stdin`;let n=j(e.ctx.cwd,t,e.ctx.fs);return n.error?`missing`:e.ctx.fs.isDir(n.path)?`dir`:`file`}function DS(e,t,n=0,r=!1){K(e.out,r?G(t):{...G(),stdout:t,events:[{fd:1,text:t}]}),e.status=Math.max(e.status,n)}function OS(e,t,n,r,i=null){let{opts:a}=e,o=[t,n].map(t=>PS(e,t)),s=o.map(e=>e.content===null),c=a.newFile&&!(s[0]&&s[1]),l=!1;for(let r=0;r<2;r++)!s[r]||(i?!i[r]:c)||(DS(e,`diff: ${[t,n][r]}: ${o[r].error??`No such file or directory`}
231
+ `,2,!0),l=!0);if(l)return;if(o[0].identity!==void 0&&o[0].identity===o[1].identity&&!s[0])return kS(e,t,n);let u=e=>a.labels[e]??[t,n][e];if(!a.text&&o.some(jS))return MS(o)?kS(e,t,n):DS(e,`${a.brief?`Files`:`Binary files`} ${u(0)} and ${u(1)} differ
232
+ `,1);if(o.some(e=>e.content===void 0)){if(MS(o))return kS(e,t,n);if(a.brief&&!a.ignoreCase&&!a.stripCr&&a.whitespace===`none`)return DS(e,`Files ${u(0)} and ${u(1)} differ
233
+ `,1)}for(let[e,t]of o.entries())t.content===void 0&&Lt(t.bytes,JSON.stringify(u(e)));let d=o.map(e=>e.content??``);if(a.stripCr&&(d=d.map(AS)),a.brief)return de(d[0],d[1],{format:`brief`,ignoreCase:a.ignoreCase,whitespace:a.whitespace})===``?kS(e,t,n):DS(e,`Files ${u(0)} and ${u(1)} differ
234
+ `,1);let f;try{f=Yx(e,d,[t,n],s,r)}catch(r){if(!(r instanceof oe)&&!(r instanceof ue))throw r;let i=`diff: ${t} ${n}: ${r.message}`,a=r instanceof oe?`change set verification`:`diff rendering verification`;K(e.out,T(`feature`,`diff`,a,i,2)),e.status=2;return}if(f===``)return kS(e,t,n);DS(e,f,1)}function kS(e,t,n){e.opts.identical&&DS(e,`Files ${t} and ${n} are identical
235
+ `)}var AS=e=>e.replace(/\r\n/gu,`
236
+ `),jS=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes(`\0`)===!0,MS=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:Rt(e.bytes??NS,t.bytes??NS),NS=new Uint8Array;function PS(e,t){let{ctx:n}=e;if(t===`-`)return L(n),{content:e.stdin,identity:n.stdinHandle?.identity??Symbol(`stdin`)};let r=F(n,`diff`,t);if(r.error||n.fs.isDir(r.path))return{content:null,bytes:null,identity:void 0,error:r.error};let{text:i,bytes:a}=or(n.fs,r.path);return{content:i,bytes:a,identity:n.fs.fileIdentity?.(r.path)??r.path}}var FS=(e,t,n)=>{throw new Y(`malformed patch at line ${Math.min(t,e.lines.length-1)+1}: ${n??``}`)};function IS(e,t){return!!e.lines[t+1]?.startsWith(`\\`)}function LS(e){let{lines:t}=e,n=e.pos,r=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: (.*))?\n$/u.exec(t[n]??``);if(!r)return null;let i=n,a=Number(r[3]),o=Number(r[1]),s=r[2]===void 0?1:Number(r[2]),c=r[4]===void 0?1:Number(r[4]);s===0&&o++,c===0&&a++;let l=[],u=[],d=0,f=n,p=-1;for(n++;u.length<s||l.length<c;n+=1){let r=t[n]!==void 0;if(!r&&c-l.length>3)throw new Y(`unexpected end of file in patch`);let i=r?t[n]:`
237
+ `;r&&(f=n);let a=i[0],o=i;a===` `||a===`
238
+ `?a=` `:o=i.slice(1),a!==`-`&&a!==`+`&&a!==` `&&FS(e,n,i);let m=!1;a!==`+`&&(u.length>=s&&FS(e,n,i),m=r&&u.length+1===s&&IS(e,n),m&&(o=o.replace(/\n$/u,``)),u.push({tag:a,text:o}),a===` `&&d++),a!==`-`&&(l.length>=c&&FS(e,n,i),!m&&r&&l.length+1===c&&IS(e,n)&&(m=!0,o=o.replace(/\n$/u,``)),l.push({tag:a,text:o})),a!==` `&&(p===-1&&(p=d),d=0),m&&n++}return p===-1&&FS(e,f,t[f]),e.pos=n,{oldStart:o,oldLines:u,newStart:a,newLines:l,prefix:p,suffix:d,fn:r[5]===void 0?null:` `+r[5],marks:null,line:i}}function RS(e){let{lines:t}=e,n=e.pos;if(!t[n]?.startsWith(`********`))return null;let r=n,i=/^\*+( .*)?\n$/u.exec(t[n])?.[1]??null,a=/^\*\*\* (\d+)(?:,(\d+))?/u.exec(t[++n]??``);if(!a)throw new Y(`unexpected '***' at line ${n+1}: ${t[n]??``}`);let o=zS(a),s=[],c=e=>/^--- (\d+)(?:,(\d+))? ----/u.exec(t[e]??``)??/^--- (\d+)(?:,(\d+))?/u.exec(t[e]??``);for(n++;!c(n);n++){if(t[n]===void 0||s.length>=o.count)throw new Y(`no '---' found in patch at line ${r+1}`);s.push(BS(e,n,s.length+1===o.count)),s.at(-1).skip&&n++}let l=zS(c(n)),u=[];for(n++;u.length<l.count;n++){let r=t[n];if(r===void 0||!/^[ !+\-\t\n]/u.test(r)||r.startsWith(`***`))break;u.push(BS(e,n,u.length+1===l.count)),u.at(-1).skip&&n++}return u.length!==0&&u.length<l.count&&FS(e,n,t[n]),e.pos=n,VS({oldRange:o,oldSide:s,newRange:l,newSide:u,fn:i,line:r})}function zS(e){let t=Number(e[1]),n=e[2]===void 0?t:Number(e[2]);return t===0&&e[2]===void 0?{first:1,count:0}:{first:t,count:n-t+1}}function BS(e,t,n){let r=e.lines[t],i=r[0];i===` `||i===`
239
+ `?i=` `:(r=r.slice(1),(r[0]===` `||r[0]===` `)&&(r=r.slice(1)));let a=n&&IS(e,t);return{mark:i,text:a?r.replace(/\n$/u,``):r,skip:a}}function VS({oldRange:e,oldSide:t,newRange:n,newSide:r,fn:i,line:a}){let o=r,s=t;if(t.length===0&&e.count&&(s=r.filter(e=>e.mark===` `)),r.length===0&&n.count&&(o=t.filter(e=>e.mark===` `)),s.length!==e.count||o.length!==n.count)throw new Y(`replacement text or line numbers mangled in hunk at line ${a+1}`);let c=s.map(e=>({tag:e.mark===` `?` `:`-`,text:e.text})),l=o.map(e=>({tag:e.mark===` `?` `:`+`,text:e.text})),u=e=>{let t=0;for(let n of e){if(n.tag!==` `)break;t++}return t},d=Math.min(u(c),u(l)),f=Math.min(u(c.toReversed()),u(l.toReversed()));if(c.every(e=>e.tag===` `)&&l.every(e=>e.tag===` `))throw new Y(`replacement text or line numbers mangled in hunk at line ${a+1}`);return{oldStart:e.first,oldLines:c,newStart:n.first,newLines:l,prefix:d,suffix:f,fn:i,marks:{old:s.map(e=>e.mark),new:o.map(e=>e.mark)},line:a}}function HS(e){let{lines:t}=e,n=e.pos,r=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n$/u.exec(t[n]??``);if(!r)return null;let i=n,a=Number(r[1]),o=r[3]===`a`?0:r[2]===void 0?1:Number(r[2])-a+1;r[3]===`a`&&a++;let s=Number(r[4]),c=r[5]===void 0?s:Number(r[5]);r[3]===`d`&&s++;let l=c-s+1;(o<0||l<0)&&FS(e,n,t[n]);let u=[],d=[];n++;for(let r=0;r<o;r++,n++){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!/^<[ \t]/u.test(t[n]))throw new Y(`'<' followed by space or tab expected at line ${n+1} of patch`);let i=r+1===o&&IS(e,n);d.push({tag:`-`,text:i?t[n].slice(2).replace(/\n$/u,``):t[n].slice(2)}),i&&n++}if(r[3]===`c`){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!t[n].startsWith(`-`))throw new Y(`'---' expected at line ${n+1} of patch`);n++}for(let r=0;r<l;r++,n++){if(t[n]===void 0)throw new Y(`unexpected end of file in patch at line ${n}`);if(!/^>[ \t]/u.test(t[n]))throw new Y(`'>' followed by space or tab expected at line ${n+1} of patch`);let i=r+1===l&&IS(e,n);u.push({tag:`+`,text:i?t[n].slice(2).replace(/\n$/u,``):t[n].slice(2)}),i&&n++}return e.pos=n,{oldStart:a,oldLines:d,newStart:s,newLines:u,prefix:0,suffix:0,fn:null,marks:null,line:i}}function US(e){let t=(e,t,n)=>e.map(e=>({tag:e.tag===t?n:e.tag,text:e.text})),n=(e,t,n)=>e.map(e=>e===t?n:e);return{...e,oldStart:e.newStart,newStart:e.oldStart,oldLines:t(e.newLines,`+`,`-`),newLines:t(e.oldLines,`-`,`+`),marks:e.marks&&{old:n(e.marks.new,`+`,`-`),new:n(e.marks.old,`-`,`+`)}}}var Y=class extends Error{constructor(e){super(e),this.name=`PatchFatal`}},WS=(e,t)=>{throw new D(`feature`,e,t)};function GS(e){let t=$n(e);return t.length&&!t.at(-1).endsWith(`
240
+ `)&&(t[t.length-1]+=`
241
+ `),{lines:t,pos:0,base:0,empty:e===``}}var KS=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u,qS=/^(?:\d+(?:,\d+)?)?(?:[acdi]|s\/\.\/\/)[ \t]*\n$/u,JS=/^[0-9a-fA-F]+/u;function YS(e,{needHeader:t,strip:n,format:r}){let{lines:i}=e,a={names:{old:null,new:null,index:null},stamps:{old:-1,new:-1},timestrs:{old:null,new:null},says:[0,0],git:!1,rename:[!1,!1],copy:[!1,!1],extended:!1},o=t&&r!==`normal`&&r!==`ed`,s=!1,c=-1,l=!1,u=!1;for(let t=e.pos;;t++){if(t>=i.length)return s&&WS(`ed script`,`ed scripts are not supported`),a.extended?{...a,type:`unified`,start:t,hunkLine:t,empty:!0}:null;let d=i[t],f=d.replace(/^[ \tX]+/u,``),p=/^\d/u.test(f)&&KS.test(f);!o&&c<0&&(qS.test(f)||p)&&(c=t,s=qS.test(f));let m=XS(d,a,n,u);if(m===`binary`&&WS(`git binary patch`,`git binary diffs are not supported`),m===`prereq`&&WS(`Prereq`,`Prereq: lines are not supported`),m===`git`&&a.extended)return{...a,type:`unified`,start:t,hunkLine:t,empty:!0};m&&(o=!1);let h=d.startsWith(`********`);if(/^[ \t]+(?:@@ -\d|\*{8})/u.test(d)&&WS(`indented patch`,`indented patches are not supported`),!o){if(d.endsWith(`\r
242
+ `)&&(d.startsWith(`@@ -`)||u)&&WS(`CRLF patch`,`patches with CRLF line endings are not supported`),(r===null||r===`ed`)&&c>=0&&d===`.
243
+ `&&WS(`ed script`,`ed scripts are not supported`),(r===null||r===`unified`)&&d.startsWith(`@@ -`))return $S(a,t,d);if((r===null||r===`context`)&&u&&d.startsWith(`*** `))return eC(e,a,t,d);if((r===null||r===`normal`)&&l&&(d.startsWith(`< `)||d.startsWith(`> `)))return{...a,type:`normal`,start:t-1,hunkLine:t-1}}u=h,l=p}}function XS(e,t,n,r){if(!r&&e.startsWith(`*** `)||e.startsWith(`+++ `))return QS(t,`old`,e.slice(4),n);if(e.startsWith(`Index:`))return t.names.index=nC(e.slice(6),n,!1).name,`index`;if(e.startsWith(`Prereq:`))return`prereq`;if(e.startsWith(`diff --git `)){let r=aC(e.slice(11),n),i=r.name===null?null:aC(r.rest,n);return t.names.old=i&&i.rest.trim()===``?r.name:null,t.names.new=t.names.old===null?null:i.name,t.git=!0,t.stamps.old=t.stamps.new=-1,`git`}if(t.git){let n=ZS(e,t);if(n)return n}let i=e;for(;i.startsWith(`- `);)i=i.slice(2);return i.startsWith(`--- `)?QS(t,`new`,i.slice(4),n):null}function ZS(e,t){if(e.startsWith(`index `)){let n=JS.exec(e.slice(6)),r=n?e.slice(6+n[0].length):``,i=r.startsWith(`..`)?JS.exec(r.slice(2)):null;return i?(t.says[0]=/^0+$/u.test(n[0])?2:0,t.says[1]=/^0+$/u.test(i[0])?2:0,t.extended=!0,`index`):null}return e.startsWith(`old mode `)||e.startsWith(`new mode `)?(t.extended=!0,`mode`):e.startsWith(`deleted file mode `)?(t.says[1]=2,t.extended=!0,`mode`):e.startsWith(`new file mode `)?(t.says[0]=2,t.extended=!0,`mode`):e.startsWith(`rename from `)?(t.rename[0]=!0,t.extended=!0,`rename`):e.startsWith(`rename to `)?(t.rename[1]=!0,t.extended=!0,`rename`):e.startsWith(`copy from `)?(t.copy[0]=!0,t.extended=!0,`copy`):e.startsWith(`copy to `)?(t.copy[1]=!0,t.extended=!0,`copy`):e.startsWith(`GIT binary patch`)?`binary`:null}function QS(e,t,n,r){let i=nC(n,r,!0);return i.stamp!==void 0&&(e.stamps[t]=i.stamp),i.name!==void 0&&(e.names[t]=i.name,e.timestrs[t]=i.timestr),`name`}function $S(e,t,n){let r={names:{...e.names,old:e.names.new,new:e.names.old},stamps:{old:e.stamps.new,new:e.stamps.old},timestrs:{old:e.timestrs.new,new:e.timestrs.old}},i=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/u.exec(n),a=[...e.says];return i&&i[1]===`0`&&(a[0]=1+ +(r.stamps.old===0)),i&&i[3]===`0`&&(a[1]=1+ +(r.stamps.new===0)),{...e,...r,says:a,type:`unified`,start:t,hunkLine:t}}function eC(e,t,n,r){let i=[...t.says];/^\*\*\* 0(?!\d)/u.test(r)&&(i[0]=1+ +(t.stamps.old===0));let a={...e,pos:n-1};try{let e=RS(a);e&&e.newLines.length===0&&e.newStart===1&&(i[1]=1+ +(t.stamps.new===0))}catch{}return{...t,says:i,type:`context`,start:n-1,hunkLine:n-1}}function tC(e,t){return t===`unified`?LS(e):t===`context`?RS(e):HS(e)}function nC(e,t,n){let r=e.replace(/^[ \t\n\v\f\r]+/u,``),i,a;if(r.startsWith(`"`)){let e=sC(r);if(!e)return{};i=e.value,a=e.rest}else{let e=0;for(;e<r.length;e++){if(!/[ \t\n\v\f\r]/u.test(r[e]))continue;let t=e;for(;r[t]!==` `&&/[ \t\n\v\f\r]/u.test(r[t+1]??``);)t++;if(r[t]===` `||r.indexOf(n?` `:`
244
+ `,t+1)===-1)break}i=r.slice(0,e),a=r.slice(e)}if(i===`/dev/null`)return{stamp:0};let o=iC(i,t);if(o===null)return{};let s=a.replace(/\r?\n$/u,``);return{name:o,timestr:s,stamp:n&&s!==``?rC(s):-1}}function rC(e){let t=/^\s*(\d{4})-(\d\d)-(\d\d)[ T](\d\d):(\d\d):(\d\d)(?:\.\d+)?\s*(?:([+-])(\d\d):?(\d\d))?/u.exec(e),n;if(t){let[,e,r,i,a,o,s,c,l,u]=t;n=Date.UTC(Number(e),Number(r)-1,Number(i),Number(a),Number(o),Number(s))/1e3,c&&(n-=(c===`-`?-1:1)*(Number(l)*3600+Number(u)*60))}else{let t=/^\s*[A-Z][a-z]{2} ([A-Z][a-z]{2}) +(\d+) (\d\d):(\d\d):(\d\d) (\d{4})/u.exec(e);if(!t)return-1;let r=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],[,i,a,o,s,c,l]=t;n=Date.UTC(Number(l),r.indexOf(i),Number(a),Number(o),Number(s),Number(c))/1e3}return n>-9e4&&n<93600?0:n}function iC(e,t){let n=t,r=0;for(let i=0;i<e.length;i++)if(e[i]===`/`){for(;e[i+1]===`/`;)i++;(t<0||--n>=0)&&(r=i+1)}return(t<0||n<=0)&&r<e.length?e.slice(r):null}function aC(e,t){let n=e.replace(/^[ \t\n\v\f\r]+/u,``),r,i;if(n.startsWith(`"`)){let e=sC(n);if(!e)return{name:null,rest:``};r=e.value,i=e.rest}else{let e=n.search(/[ \t\n\v\f\r]/u);r=e<0?n:n.slice(0,e),i=e<0?``:n.slice(e)}return{name:iC(r,t),rest:i}}var oC={a:`\x07`,b:`\b`,f:`\f`,n:`
245
+ `,r:`\r`,t:` `,v:`\v`,"\\":`\\`,'"':`"`};function sC(e){let t=``;for(let n=1;n<e.length;n++){let r=e[n];if(r===`"`)return{value:t,rest:e.slice(n+1)};if(r!==`\\`){t+=r;continue}let i=e[++n];if(i===void 0)return null;if(/[0-7]/u.test(i)){let r=/^[0-7]{1,3}/u.exec(e.slice(n))[0];t+=String.fromCodePoint(Number.parseInt(r,8)),n+=r.length-1}else if(i in oC)t+=oC[i];else return null}return null}function cC(e,t){let n=e=>e.split(`/`).length-1,r=e=>e.slice(e.lastIndexOf(`/`)+1).length,i=-1;for(let a=0;a<e.length;a++){let o=e[a];if(o===null||t[a])continue;if(i===-1){i=a;continue}let[s,c]=[n(o),n(e[i])];if(s!==c){s<c&&(i=a);continue}let[l,u]=[r(o),r(e[i])];l===u?o.length<e[i].length&&(i=a):l<u&&(i=a)}return i}function lC(e,t){let{opts:n}=e;return(n.noReverse||!(n.force&&n.silent))&&e.say(t),n.noReverse?(e.say(` Skipping patch.
246
+ `),e.skipRest=!0,!1):n.force?(n.silent||e.say(` Applying it anyway.
247
+ `),!1):n.batch?(e.say(e.reverse?` Ignoring -R.
248
+ `:` Assuming -R.
249
+ `),!0):(e.say(e.reverse?` Ignore -R? [n]
250
+ `:` Assume -R? [n]
251
+ `),e.say(`Apply anyway? [n]
252
+ `),n.silent||e.say(`Skipping patch.
253
+ `),e.skipRest=!0,!1)}function uC(e,t,n,r,i){let a=+!!e.reverse,o=t.says,s=+!i<o[a^+!!i];if(i&&o[a^+!!r]===1&&o[1-a^!!r]===2)return!1;if(s){let t=r?`delete`:i?`empty out`:`create`,a=r?`does not exist`:i?`is already empty`:`already exists`;lC(e,`The next patch${e.reverse?`, when reversed,`:``} would ${t} the file ${e.quote(n)},
254
+ which ${a}!`)&&(e.reverse=!e.reverse)}return s}function dC(e,t,n,r){let i=[t.names.old,t.names.new,t.names.index];(i[0]!==null||i[1]!==null)&&i[2]!==null&&(i[2]=null);let a=-1;if(n===null){let n=i.map(e=>e===null?null:r(e));a=cC(i,n.map(e=>e===null||!e.exists));let o=i.findIndex(e=>e!==null);if(o!==-1&&(a===-1||!n[a].isDir)){let r=a===-1;uC(e,t,i[r?o:a],r,r||n[a].size===0)&&r&&(a=o)}a===-1&&t.says[+!!e.reverse]&&(a=cC(i,i.map(()=>!1)))}if((t.rename[0]||t.rename[1]||t.copy[0]||t.copy[1])&&n===null&&(a!==0&&a!==1||i[0]===null||i[1]===null)&&(e.say(`Cannot ${t.rename[0]||t.rename[1]?`rename`:`copy`} file without two valid file names
255
+ `),e.skipRest=!0),a===-1){if(n===null)return null;let i=r(n);return i.exists&&i.isDir||uC(e,t,n,!i.exists,!i.exists||i.size===0),n}return i[a]}function fC(e){return{input:e,frozen:0,inOffset:0,outOffset:0,out:[]}}var pC=(e,t)=>t<1||t>e.input.length?``:e.input[t-1];function mC(e,t){let n=e=>e.replace(/\n$/u,``).replace(/[ \t]+$/u,``).replace(/[ \t]+/gu,` `);return n(e)===n(t)}function hC(e,t,n,r,i,a,o){let s=t.oldLines,c=s.length-a;for(let t=n+r+i,a=i;a<c;a++,t++){let n=pC(e,t),r=s[a].text;if(o?!mC(n,r):n!==r)return!1}return!0}function gC(e,t,n,r){let i=t.oldStart+e.inOffset,a=t.oldLines.length,o=Math.max(t.prefix,t.suffix),s=n+t.prefix-o,c=n+t.suffix-o,l=e.input.length,u=l-(a-c)+1,d=e.frozen+1,f=u-i,p=i-d,m=Math.max(f,p);if(!a)return i;i<=p&&(p=i-1);let h=t=>(e.inOffset+=t,i+t);if(s<0&&t.oldStart<=1){if(c<0&&(a!==l||t.prefix<e.frozen))return 0;let n=1-i;return e.frozen<=t.prefix&&n<=f&&hC(e,t,i,n,0,c,r)?h(n):0}if(s<0&&(s=0),c<0){let n=i-(l-a+1);return n<=p&&hC(e,t,i,-n,s,0,r)?h(-n):0}let g=f<0?i-u:p<0?i-d:0;for(let n=g;n<=m;n++){if(n<=f&&hC(e,t,i,n,s,c,r))return h(n);if(n<=p&&hC(e,t,i,-n,s,c,r))return h(-n)}return 0}function _C(e,t){if(e.frozen>t)return!1;for(;e.frozen<t;)e.frozen<e.input.length&&e.out.push(e.input[e.frozen]),e.frozen++;return!0}function vC(e,t,n){let r=n-1,i=t.newLines,a=t.oldLines,o=0,s=0,c=()=>{throw new Y(`Out-of-sync patch, lines ${t.line+1+s+1},${t.line+1+a.length+o+1} -- mangled text or line numbers, maybe?`)};for(;s<a.length;)if(a[s].tag===`-`){if(!_C(e,r+s))return!1;e.frozen++,s++}else{if(o>=i.length)break;if(i[o].tag===`+`){if(!_C(e,r+s))return!1;e.out.push(i[o++].text)}else i[o].tag===a[s].tag?(s++,o++):c()}for(;o<i.length&&i[o].tag===`+`;o++){if(!_C(e,r+s))return!1;e.out.push(i[o].text)}return e.outOffset+=i.length-a.length,!0}var yC=e=>e.frozen>=e.input.length||_C(e,e.input.length),bC=e=>e.map((t,n)=>n<e.length-1&&!t.endsWith(`
256
+ `)?t+`
257
+ `:t).join(``);function xC(e,t,n,r,i){let{opts:a}=e,o={count:0,failed:0,mismatch:!1,applyAnyway:!1};for(let s=n();s;s=n()){o.count++;let{hunk:n,where:c,fuzz:l}=e.skipRest?{hunk:e.reverse?US(s):s,where:0,fuzz:0}:SC(e,r,e.reverse?US(s):s,o),u=(c||n.oldStart)+r.outOffset,d=c===1&&t.says[+!!e.reverse]===2&&r.input.length>0;if(e.skipRest||d||!c||!vC(r,n,c))e.skipRejectFile||i.add(n,o.failed===0,r.outOffset,e.reverse),o.failed++,!e.skipRest&&!a.silent&&e.say(`Hunk #${o.count} FAILED at ${u}.
258
+ `);else if(!a.silent&&(l||r.inOffset)){let t=r.inOffset?` (offset ${r.inOffset} line${r.inOffset===1?``:`s`})`:``;e.say(`Hunk #${o.count} succeeded at ${u}${l?` with fuzz ${l}`:``}${t}.
259
+ `)}}return o}function SC(e,t,n,r){let{opts:i}=e,a=0,o=n,s=0,c=Math.min(i.fuzz,Math.max(o.prefix,o.suffix));do if(s=gC(t,o,a,i.loose),(!s||a||t.inOffset)&&(r.mismatch=!0),r.count===1&&!s&&!(i.force||r.applyAnyway)&&e.reverse===e.reverseFlag){let n=US(o);s=gC(t,n,a,i.loose),s&&lC(e,`${e.reverse?`Unreversed`:`Reversed (or previously applied)`} patch detected!`)?(e.reverse=!e.reverse,o=n):s&&=(r.applyAnyway=!0,a--,0)}while(!e.skipRest&&!s&&++a<=c);return{hunk:o,where:s,fuzz:a}}var CC=(e,t)=>e+t;function wC(e,t){let n=``,r=(t,n)=>`${t} ${e.names[n]??`/dev/null`}${e.timestrs[n]??``}
260
+ `,i=e.names.index===null?``:`Index: ${e.names.index}
261
+ `;return{get text(){return n},add(e,a,o,s){let c=s?[`new`,`old`]:[`old`,`new`];t===`unified`?(a&&(n+=i+r(`---`,c[0])+r(`+++`,c[1])),n+=EC(e,o)):(a&&(n+=i+r(`***`,c[0])+r(`---`,c[1])),n+=OC(e,o,t))}}}var TC=(e,t)=>t===0?`${e-1},0`:t===1?`${e}`:`${e},${t}`;function EC(e,t){let n=e.newLines,r=e.oldLines,i=`@@ -${TC(e.oldStart+t,r.length)} +${TC(e.newStart+t,n.length)} @@${e.fn??``}
262
+ `,a=0,o=0;for(;;o++,a++){for(;o<r.length&&r[o].tag===`-`;o++)i+=CC(`-`,r[o].text);for(;a<n.length&&n[a].tag===`+`;a++)i+=CC(`+`,n[a].text);if(o>=r.length)break;i+=CC(` `,r[o].text)}return i}function DC(e,t){let n=e+t-1;return n<e?`0`:n===e?`${e}`:`${e},${n}`}function OC(e,t,n){let r=n!==`normal`,i=e.marks??(n===`normal`?kC(e):AC(e)),a=`***************${e.fn??``}
263
+ `;return a+=`*** ${DC(e.oldStart+t,e.oldLines.length)}${r?` ****`:``}
264
+ `,e.oldLines.forEach((e,t)=>{a+=CC(i.old[t]+` `,e.text)}),a+=`--- ${DC(e.newStart+t,e.newLines.length)}${r?` ----`:` -----`}
265
+ `,e.newLines.forEach((e,t)=>{a+=CC(i.new[t]+` `,e.text)}),a}var kC=e=>({old:e.oldLines.map(e=>e.tag),new:e.newLines.map(e=>e.tag)});function AC(e){let t=e.newLines.map(e=>e.tag),n=e.oldLines.map(e=>e.tag),r=0,i=0;for(;i<n.length;)if(n[i]===`-`){if(r<t.length&&t[r]===`+`){do n[i++]=`!`;while(i<n.length&&n[i]===`-`);do t[r++]=`!`;while(r<t.length&&t[r]===`+`)}else do i++;while(i<n.length&&n[i]===`-`)}else if(r<t.length&&t[r]===`+`)do r++;while(r<t.length&&t[r]===`+`);else i++,r++;return{old:n,new:t}}var jC=[`R`,`N`,`f`,`t`,`s`,`b`,`l`,`E`,`T`,`Z`,`e`,`u`,`c`,`n`,`v`],MC=[`reverse`,`forward`,`force`,`batch`,`silent`,`quiet`,`backup`,`ignore-whitespace`,`remove-empty-files`,`dry-run`,`verbose`,`unified`,`context`,`normal`,`ed`,`binary`,`no-backup-if-mismatch`,`backup-if-mismatch`,`posix`,`follow-symlinks`,`help`,`version`,`set-time`,`set-utc`],NC=[`p`,`i`,`o`,`d`,`r`,`F`,`z`,`B`,`Y`,`V`,`g`,`D`,`x`],PC=[`strip`,`input`,`output`,`directory`,`reject-file`,`fuzz`,`suffix`,`prefix`,`basename-prefix`,`version-control`,`get`,`reject-format`,`quoting-style`,`read-only`,`merge`,`debug`],FC=new Map([[`T`,`setting file times`],[`Z`,`setting file times`],[`set-time`,`setting file times`],[`set-utc`,`setting file times`],[`e`,`ed scripts`],[`ed`,`ed scripts`],[`v`,`a version banner`],[`version`,`a version banner`],[`help`,`a help text`],[`verbose`,`verbose output`],[`B`,`backup prefixes`],[`prefix`,`backup prefixes`],[`Y`,`backup prefixes`],[`basename-prefix`,`backup prefixes`],[`V`,`numbered backups`],[`version-control`,`numbered backups`],[`g`,`version control`],[`get`,`version control`],[`D`,`merged #ifdef output`],[`x`,`debugging output`],[`debug`,`debugging output`],[`posix`,`POSIX mode`],[`follow-symlinks`,`symbolic links`],[`quoting-style`,`quoting styles`],[`read-only`,`read-only handling`],[`merge`,`merging`]]),IC=e=>C(`patch: ${e}
266
+ patch: Try 'patch --help' for more information.`,2);function LC(e){for(let t of e){if(t===`--`)break;let e=t.replace(/=.*/u,``);if(e===`--merge`||e===`--read-only`)return{refused:T(`option`,`patch`,e,`patch: ${e}: ${FC.get(e.slice(2))} is not supported`,2)}}let t;try{t=U(e,{short:jC,long:MC,valueShort:NC,valueLong:PC})}catch(e){let t=w(e);return t?{refused:T(t.kind,`patch`,t.detail,`patch: ${e.message}`,2)}:{error:IC(e.message)}}let n={strip:-1,input:null,output:null,directory:null,rejectFile:null,fuzz:2,suffix:`.orig`,format:null,rejectFormat:null,reverse:!1,noReverse:!1,force:!1,batch:!1,silent:!1,backup:!1,backupIfMismatch:!0,loose:!1,removeEmpty:!1,dryRun:!1};for(let{name:e,value:r}of t.order){let t=(e.length===1?`-`:`--`)+e,i=FC.get(e);if(i)return{refused:T(`option`,`patch`,t,`patch: ${t}: ${i} is not supported`,2)};let a=zC(n,e,r);if(a)return{error:a}}return t.positional.length>2?{error:IC(`${t.positional[2]}: extra operand`)}:{opts:n,operands:t.positional}}function RC(e,t){if(!/^[+-]?\d+$/u.test(e))return{error:C(`patch: **** ${t} ${w_(e,{vars:new Map})} is not a number`,2)};let n=Number(e);return n<0?{error:C(`patch: **** ${t} ${e} is negative`,2)}:{value:Math.min(n,2**53-1)}}function zC(e,t,n){switch(t){case`p`:case`strip`:{let t=RC(n,`strip count`);return t.error?t.error:(e.strip=t.value,null)}case`F`:case`fuzz`:{let t=RC(n,`fuzz factor`);return t.error?t.error:(e.fuzz=t.value,null)}case`i`:case`input`:return e.input=n,null;case`o`:case`output`:return e.output=n,null;case`d`:case`directory`:return e.directory=n,null;case`r`:case`reject-file`:return e.rejectFile=n,null;case`z`:case`suffix`:return n===``?C(`patch: **** backup suffix is empty`,2):(e.suffix=n,null);case`R`:case`reverse`:return e.reverse=!0,null;case`N`:case`forward`:return e.noReverse=!0,null;case`f`:case`force`:return e.force=!0,null;case`t`:case`batch`:return e.batch=!0,null;case`s`:case`silent`:case`quiet`:return e.silent=!0,null;case`b`:case`backup`:return e.backup=!0,null;case`l`:case`ignore-whitespace`:return e.loose=!0,null;case`E`:case`remove-empty-files`:return e.removeEmpty=!0,null;case`dry-run`:return e.dryRun=!0,null;case`u`:case`unified`:return e.format=`unified`,null;case`c`:case`context`:return e.format=`context`,null;case`n`:case`normal`:return e.format=`normal`,null;case`no-backup-if-mismatch`:return e.backupIfMismatch=!1,null;case`backup-if-mismatch`:return e.backupIfMismatch=!0,null;case`reject-format`:return n!==`unified`&&n!==`context`?C(`patch: **** unknown reject format ${n}`,2):(e.rejectFormat=n,null);default:return null}}function BC(e,t,n){let r=LC(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:i,operands:a}=r,o={ctx:n,opts:i,dir:n.cwd,events:[],stdout:``,stderr:``,skipRest:!1,skipRejectFile:!1,reverse:i.reverse,reverseFlag:i.reverse,someFailed:!1,rejectsMade:new Set,output:``},s=i.output===`-`?2:1;o.quote=e=>w_(e,n),o.say=e=>{s===1?o.stdout+=e:o.stderr+=e,o.events.push({fd:s,text:e})};try{if(i.directory!==null){let e=j(n.cwd,i.directory,n.fs);if(e.error||!n.fs.isDir(e.path))throw new Y(`Can't change to directory ${w_(i.directory,n)} : ${e.error??`Not a directory`}`);o.dir=e.path}HC(o,GS(VC(o,e,i.input??a[1]??null)),a[0]??null),i.output!==null&&i.output!==`-`&&XC(o,i.output,o.output,!1)}catch(e){if(!(e instanceof Y)){let t=w(e);if(!t)throw e;let n=`patch: ${e.message}`;return E({stdout:o.stdout,stderr:o.stderr+n+`
267
+ `,events:[...o.events,{fd:2,text:n+`
268
+ `}],exitCode:2},t.kind,`patch`,t.detail,n)}let t=`patch: **** ${e.message}
269
+ `;return{stdout:o.stdout,stderr:o.stderr+t,events:[...o.events,{fd:2,text:t}],exitCode:2}}return{stdout:o.stdout,stderr:o.stderr,events:o.events,exitCode:+!!o.someFailed}}function VC(e,t,n){if(n===null||n===`-`)return L(e.ctx),t;let r=F(e.ctx,`patch`,n);if(r.error||e.ctx.fs.isDir(r.path))throw new Y(`Can't open patch file ${w_(n,e.ctx)} : ${r.error??`Is a directory`}`);return e.ctx.fs.readFile(r.path)}function HC(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let i=YS(t,{needHeader:n===null,strip:r.strip,format:r.format});if(i===null){if(t.base===0&&!t.empty)throw new Y(`Only garbage was found in the patch input.`);return}e.skipRest=!1,e.skipRejectFile=!1,e.reverse=e.reverseFlag;let a=dC(e,i,n,t=>JC(e,t));a===null&&(a=UC(e,t,i)),e.skipRest&&(e.someFailed=!0),t.pos=i.start,WC(e,t,i,a),t.base=t.pos}}function UC(e,t,n){let{opts:r}=e;if(r.silent||(e.say(`can't find file to patch at input line ${n.hunkLine+1}
270
+ `),n.type!==`normal`&&e.say(r.strip===-1?`Perhaps you should have used the -p or --strip option?
271
+ `:`Perhaps you used the wrong -p or --strip option?
272
+ `)),t.base<n.start){e.say(`The text leading up to this was:
273
+ --------------------------
274
+ `);for(let r=t.base;r<n.start;r++)e.say(`|`+t.lines[r]);e.say(`--------------------------
275
+ `)}return r.force||r.batch?e.say(`No file to patch. Skipping patch.
276
+ `):(e.say(`File to patch:
277
+ `),e.say(`Skip this patch? [y]
278
+ `),r.silent||e.say(`Skipping patch.
279
+ `)),e.skipRest=!0,null}function WC(e,t,n,r){let{opts:i}=e,a=n.copy[0]||n.copy[1]||n.rename[0]||n.rename[1],o=null;e.skipRest||(o=i.output??(a?n.names[e.reverse?`old`:`new`]:r));let s={exists:!1,isDir:!1,content:``};e.skipRest||(s=JC(e,r),(s.isDir||s.link)&&(e.say(`File ${w_(r,e.ctx)} is not a regular file -- refusing to patch
280
+ `),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!i.dryRun&&i.output===null&&(YC(e,o),a&&r!==o&&YC(e,r));let c=fC($n(s.exists?s.content:``));if(!e.skipRest&&!i.silent){let t=r!==o,a=!t&&(n.rename[0]||n.rename[1]),s=n.copy[0]||n.copy[1]?`copied`:n.rename[0]||n.rename[1]?`renamed`:`read`,c=a?n.names[r===n.names.old?`new`:`old`]:r,l=t||a?` (${a?`already `:``}${s} from ${c})`:``;e.say(`${i.dryRun?`checking`:`patching`} file ${w_(o,e.ctx)}${l}
281
+ `)}let l=wC(n,i.rejectFormat??n.type),u=xC(e,n,()=>n.empty?null:tC(t,n.type),c,l);!e.skipRest&&!yC(c)&&(e.say(`misordered hunks! output would be garbled
282
+ Skipping patch.
283
+ `),e.skipRest=!0);let d=bC(c.out);i.output!==null&&!e.skipRest&&(i.output===`-`?(e.stdout+=d,e.events.push({fd:1,text:d})):e.output+=d),!e.skipRest&&i.output===null&&GC(e,n,{inname:r,outname:o,input:s,content:d,result:u,empty:c.out.length===0,renaming:a}),u.failed&&!e.skipRejectFile&&KC(e,o,u,l.text)}function GC(e,t,n){let{opts:r}=e,{inname:i,outname:a,input:o,content:s,result:c,empty:l,renaming:u}=n,d=r.backup||r.backupIfMismatch&&(c.mismatch||c.failed>0),f=t.says[+!e.reverse]===2;if(l&&(r.removeEmpty||f))r.dryRun||ZC(e,a,d);else if(!l&&f&&(e.someFailed=!0,r.silent||e.say(`Not deleting file ${w_(a,e.ctx)} as content differs from patch
284
+ `)),!r.dryRun){if(c.failed<c.count||u)XC(e,a,s,d),u&&i!==a&&(t.rename[0]||t.rename[1])&&ZC(e,i,!1);else if(d){if(!o.exists)throw new Y(`Can't reopen file ${w_(a,e.ctx)} : No such file or directory`);XC(e,qC(e,a),o.content,!1)}}}function KC(e,t,n,r){let{opts:i}=e;if(e.someFailed=!0,e.say(`${n.failed} out of ${n.count} hunk${n.count===1?``:`s`} ${e.skipRest?`ignored`:`FAILED`}`),t===null||i.rejectFile===`-`){e.say(`
285
+ `);return}let a=i.rejectFile??t+`.rej`;if(i.dryRun){e.say(`
286
+ `);return}e.say(` -- saving rejects to file ${w_(a,e.ctx)}
287
+ `),YC(e,a);let o=e.rejectsMade.has(A(e.dir,a));e.rejectsMade.add(A(e.dir,a)),XC(e,a,(o?JC(e,a).content:``)+r,!1)}var qC=(e,t)=>t+e.opts.suffix;function JC(e,t){let n=j(e.dir,t,e.ctx.fs,{follow:!1}),r=!n.error&&e.ctx.fs.isLink?.(n.path)===!0,i=j(e.dir,t,e.ctx.fs);if(i.error)return{exists:!1,isDir:!1,link:r,size:0,content:``};if(e.ctx.fs.isDir(i.path))return{exists:!0,isDir:!0,link:r,size:0,content:``};let a=e.ctx.fs.readFile(i.path);return{exists:!0,isDir:!1,link:r,size:a.length,content:a}}function YC(e,t){let n=Mt(e.ctx.fs,e.dir,t,!1);if(!(e.ctx.writable&&n.startsWith(`/tmp/`)))throw new D(`feature`,`read-only target`,`${t}: file system is read-only`)}function XC(e,t,n,r){let{ctx:i}=e;YC(e,t);let a=j(e.dir,t,i.fs);try{if(!a.error){i.fs.replaceWritable(e.dir,t,n,r?qC(e,t):void 0);return}r&&i.fs.openWritable(e.dir,qC(e,t)),i.fs.openWritable(e.dir,t).write(n)}catch(n){throw new Y(`Can't create file ${w_(t,e.ctx)} : ${n?.fsError??n.message}`)}}function ZC(e,t,n){let{ctx:r}=e;YC(e,t);let i=JC(e,t);i.exists&&(n&&r.fs.openWritable(e.dir,qC(e,t)).write(i.content),r.fs.removeWritable(e.dir,t))}var QC={du:rx,stat:Gx,realpath:bv,diff:CS,patch:BC};function $C(e,t,n){return U(t),S(n.cwd+`
288
+ `)}function ew(e,t,n){let{positional:r}=U(t);if(r.length>1)return C(`cd: too many arguments`);if(!r.length&&n.vars.unsetNames.has(`HOME`))return C(`cd: HOME not set`);let i=r[0]??Jb(n);if(i===`-`){if(!n.vars.has(`OLDPWD`))return C(`cd: OLDPWD not set`);i=n.vars.get(`OLDPWD`)}let a=r[0]===`-`?i+`
289
+ `:``;if(i===``)return S(a);let{path:o,error:s}=F(n,`cd`,i);return s?C(`cd: ${i}: ${s}`):n.fs.isDir(o)?o===A(n.cwd,i)?(n.vars.set(`OLDPWD`,n.cwd),n.vars.set(`PWD`,o),n.cwd=o,S(a)):T(`feature`,`cd`,`symbolic link cwd`,`cd: ${i}: a working directory reached through a symbolic link is not supported (it leads to ${o})`):C(`cd: ${i}: Not a directory`)}var tw={dir:`/`,link:`@`,file:``};function nw(e,t,n){let{flags:r,positional:i}=U(t,{short:[`1`,`l`,`a`,`A`,`R`,`d`,`r`,`F`,`h`]}),a=r.has(`l`)?cy(n,r.has(`h`)):null,o=(i.length?i:[`.`]).toSorted(N);r.has(`r`)&&o.reverse();let s=[],c=[],l=[],u=Hn(),d=r.has(`a`)||r.has(`A`),f=e=>n.fs.isDir(e)?`dir`:n.fs.isLink?.(e)?`link`:`file`,p=e=>r.has(`F`)?tw[e]:``,m=(e,t,r)=>({raw:e,abs:t,kind:r,name:r===`link`&&a?e:e+(e.endsWith(`/`)?``:p(r)),target:r===`link`?n.fs.readLink(t)+p(f(j(n.cwd,t,n.fs).path??``)):null}),h=(e,t)=>a?a.lines(e,t):e.map(e=>e.name),g=!(r.has(`l`)||r.has(`F`)||r.has(`d`));for(let e of o){let{path:t,error:i}=F(n,`ls`,e,{follow:!1}),a=i||!g||!n.fs.isLink?.(t)?t:j(n.cwd,e,n.fs).path;i?c.push(`ls: cannot access '${e}': ${i}`):r.has(`d`)||n.fs.isFile(t)||!n.fs.isDir(a)?l.push(m(e,t,f(t))):s.push({path:e,abs:a})}let _=l.length?[h(l,!1).join(`
290
+ `)]:[];for(let e of s){let t=[e];for(;t.length;){let{path:e,abs:i}=t.pop(),a=n.fs.listDir(i);d||u.collect(i,[...a.dirs,...a.files,...a.links]);let s=(e,t)=>e.filter(e=>d||!e.startsWith(`.`)).map(e=>m(e,A(i,e),t)),c=[...s(a.dirs,`dir`),...s(a.files,`file`),...s(a.links,`link`)];r.has(`a`)&&c.push(m(`.`,i,`dir`),m(`..`,A(i,`..`),`dir`)),c.sort((e,t)=>N(e.raw,t.raw)),r.has(`r`)&&c.reverse();let l=h(c,!0);if((o.length>1||r.has(`R`))&&l.unshift(e+`:`),l.length&&_.push(l.join(`
291
+ `)),r.has(`R`))for(let r of c.toReversed())r.raw===`.`||r.raw===`..`||!n.fs.isDir(r.abs)||t.push({path:e.endsWith(`/`)?e+r.raw:e+`/`+r.raw,abs:r.abs})}}return u.emit(n.notes,`ls`,`Hidden entries are included with -a.`),{stdout:_.length?_.join(`
292
+
293
+ `)+`
294
+ `:``,stderr:c.length?c.join(`
295
+ `)+`
296
+ `:``,exitCode:c.length?2:0}}function rw(e,t){let{positional:n}=U(t);if(n.length===0)return lt(`basename PATH [SUFFIX]`);if(n.length>2)return C(`basename: extra operand: ${n[2]}`);let r=n[0].replace(/\/+$/u,``);return S(iw(r===``?n[0]===``?``:`/`:r.slice(r.lastIndexOf(`/`)+1),n[1])+`
297
+ `)}function iw(e,t){return!t||t===e||!e.endsWith(t)?e:e.slice(0,-t.length)}function aw(e,t){let{positional:n}=U(t);return n.length===0?lt(`dirname PATH`):S(n.map(e=>{let t=e.replace(/\/+$/u,``),n=t.lastIndexOf(`/`);return n<0?e.startsWith(`/`)?`/`:`.`:t.slice(0,n).replace(/\/+$/u,``)||`/`}).join(`
298
+ `)+`
299
+ `)}var ow={pwd:$C,cd:ew,ls:nw,find:Ay,tree:dy,basename:rw,dirname:aw,...QC};function sw(e,t,n){let{flags:r,positional:i}=U(t,{short:[`n`,`b`,`s`,`v`,`E`,`T`,`A`,`e`,`t`]}),a=e=>pw(e,r),o=uw(i,e,n,a,r.size!==0);if(o.bytes===void 0)return R(a(o.content),o);if(r.size)throw new D(`feature`,`binary file`,`cat: formatting bytes that spell no text is not supported`);return{stdout:``,stderr:o.stderr,exitCode:+!!o.failed,events:[{fd:1,bytes:o.bytes},...o.stderr?[{fd:2,text:o.stderr}]:[]]}}function cw(e,t,n){let r=sr(`cat`,e,t,n,{read:`maybe-text`});return{parts:r.inputs.map(e=>e.content??e.bytes),stderr:r.stderr,failed:r.failed}}var lw=e=>e.every(e=>typeof e==`string`)?{content:e.join(``)}:{bytes:Dt([...e.map(e=>typeof e==`string`?O(e):e),new Uint8Array])};function uw(e,t,n,r,i){let a=n.outputFds[1];if(!a?.path&&!n.outputFds[2]?.path){let r=cw(e,t,n);return{...lw(r.parts),stderr:r.stderr,failed:r.failed}}let o=[],s=``,c=t,l=``;for(let t of e.length?e:[`-`]){let e=t===`-`,u=e||t===`/dev/stdin`,d=u?n.stdinHandle?.path:j(n.cwd,t,n.fs).path,f=u?n.stdinHandle?.identity:n.fs.fileIdentity?.(d);if(l&&fw(d,f,n.outputFds[2]))throw new D(`feature`,`cat input modified by diagnostics`,`cat: reading an input after writing diagnostics to the same file is not supported`);if(fw(d,f,a)){if((e?b(n.stdinHandle.content).length-b(c).length:0)<a.position+dw(o,s,r)){l+=`cat: ${t}: input file is output file
300
+ `;continue}let f=e?c:u?n.stdinOrigin:n.fs.readFile(d);if(i&&f!==``)throw new D(`feature`,`cat transforms its input file`,`cat: transforming an input file through its own output descriptor is not supported`)}let p=cw([t],c,n);o.push(...p.parts),s+=p.parts.filter(e=>typeof e==`string`).join(``),l+=p.stderr,(e||t===`/dev/stdin`&&!n.stdinFile)&&(c=``)}return{...lw(o),stderr:l,failed:l!==``}}var dw=(e,t,n)=>e.every(e=>typeof e==`string`)?b(n(t)).length:e.reduce((e,t)=>e+(typeof t==`string`?b(t).length:t.length),0);function fw(e,t,n){return!e||!n?.path?!1:t!==void 0&&n.identity!==void 0?t===n.identity:e===n.path}function pw(e,t){if(!t.size)return e;let n=t.has(`E`)||t.has(`A`)||t.has(`e`),r=t.has(`T`)||t.has(`A`)||t.has(`t`),i=t.has(`v`)||t.has(`A`)||t.has(`e`)||t.has(`t`),a=t.has(`s`)?hw(e):e,o=0;return $n(a).map(e=>{let a=e.endsWith(`
301
+ `),s=a?e.slice(0,-1):e,c=(t.has(`b`)?s!==``:t.has(`n`))?`${String(++o).padStart(6)} `:``;return i?s=[...b(s)].map(e=>mw(e,r)).join(``):(r&&(s=s.replaceAll(` `,`^I`)),n&&a&&s.endsWith(`\r`)&&(s=s.slice(0,-1)+`^M`)),c+s+(a?n?`$
302
+ `:`
303
+ `:``)}).join(``)}function mw(e,t){return e===9?t?`^I`:` `:e>=128?`M-`+mw(e-128,!0):e<32?`^`+String.fromCodePoint(e+64):e===127?`^?`:String.fromCodePoint(e)}function hw(e){return e.replace(/(^|\n)\n+/gu,`$1
304
+ `)}var gw=`sed: supported commands are p, P, n, N, d, D, a, i, c, g, G, h, H, x, w, q, =, y, :, b, t, T, { }, and s/regexp/replacement/[NgiIpw]`,_w=1e6,vw=16777216,yw=67108864;function bw(e=`script`){throw new D(`feature`,e,gw)}function xw(e){return e.gap?T(`feature`,`sed`,e.gap,`sed: ${e.message}`):e instanceof RangeError?T(`feature`,`sed`,`regex runtime limit`,`sed: ${e.message}`):dt(e,`sed`,`sed: ${e.message.replace(/^sed: /u,``)}`,e.exitCode)}function Sw(e){let t=[],n=null;for(let r=0;r<e.length;r++){let i=e[r];if(i===`--`){t.push(...e.slice(r));break}if(i===`--in-place`||i.startsWith(`--in-place=`)){n=i===`--in-place`?``:i.slice(11);continue}if(i.startsWith(`--`)||!i.startsWith(`-`)){t.push(i),(i===`--expression`||i===`--file`)&&r+1<e.length&&t.push(e[++r]);continue}let a=i;for(let o=1;o<i.length;o++){let s=i[o];if(s===`i`){n=i.slice(o+1),a=i.slice(0,o);break}if(s===`e`||s===`f`){t.push(i),o+1===i.length&&r+1<e.length&&t.push(e[++r]),a=``;break}if(!`nErsz`.includes(s))break}a&&(a!==`-`||i===`-`)&&t.push(a)}return{tokens:t,inPlace:n}}function Cw(e,t,n,r,i){if(e.files.length===0)return C(`sed: no input files`,4);let a=G(),o=new Set([...t,`s`]),s=!1;for(let t of e.files){let c=ww(t,n);if(c.error){if(K(a,n.flushOutput(c.error)),c.error.exitCode!==2)return Dw(a,c.error);s=!0;continue}let l=i({...e,files:[c.path]},o),{content:u,...d}=l;if(K(a,d),l.failed||w(l))return Dw(a,l);let f=Tw(t,r),p;try{p=n.fs.replaceWritable(n.cwd,t,u,f)}catch(e){I(n,`sed`,e?.path,e?.fsError);let t=dt(e,`sed`,`sed: ${e.message}`,4);return K(a,t),Dw(a,t)}if(!p){let e=Ew(f??t);return K(a,e),Dw(a,e)}if(l.quit)break}return s&&(a.exitCode=2),a}function ww(e,t){if(e===`/dev/null`||e===`/dev/stdin`&&!t.stdinFile||e===`/dev/stdout`&&!t.outputFds[1]?.path||e===`/dev/stderr`&&!t.outputFds[2]?.path)return{error:C(`sed: couldn't edit ${e}: not a regular file`,4)};if(e===`/dev/stdin`||e===`/dev/stdout`||e===`/dev/stderr`)return{error:Ew(e)};let n=F(t,`sed`,e);if(n.error)return{error:C(ir(`sed`,e,n.error).trimEnd(),2)};if(t.fs.isDir(n.path))return{error:C(`sed: couldn't edit ${e}: not a regular file`,4)};let r=j(t.cwd,e,t.fs,{follow:!1}).path;return!t.writable||!r.startsWith(`/tmp/`)?{error:Ew(e)}:n}function Tw(e,t){if(t!==``&&t!==`*`)return t.includes(`*`)?t.replaceAll(`*`,()=>e):e+t}function Ew(e){return T(`feature`,`sed`,`-i`,`sed: ${e}: file system is read-only`)}function Dw(e,t){let n=w(t);return n?E(e,n.kind,n.command,n.detail,n.message):e}function Ow(e,t){let n=!1;return(r,i)=>{e((n?t:``)+r+(i??``)),n=i===``}}function kw(e,t){let n=new Map,r=0,i,a,o,s=()=>e.io.setReads([i,a?.identity]);function c(t,n){if(n===``)return;l(n),s();let r=e.outputFds[t];if(r?.path)r.write(n);else{if(r===`closed`){let e=Error(`write error: Bad file descriptor`);throw e.exitCode=4,e}o[t===1?`stdout`:`stderr`]+=n,o.events.push({fd:t,text:n})}}function l(e){if(r+=e.length,r>yw)throw new D(`feature`,`output limit`,`sed: output limit exceeded`)}return{start(e){return o=G(),a=e,i=void 0,s(),o},record(e){i=e?.identity,s()},finish(){i=void 0,a=null,s()},stream:c,account:l,openWrite(r){if(n.has(r))return n.get(r);let i;if(r===`/dev/null`)i=()=>{};else if(r===`/dev/stdout`||r===`/dev/stderr`)i=e=>c(r===`/dev/stdout`?1:2,e);else{let t;try{t=e.writable&&e.fs.openWritable(e.cwd,r)}catch(t){throw I(e,`sed`,t?.path,t?.fsError),t.exitCode=4,t}if(!t)throw new D(`feature`,`output file`,`sed: ${r}: Read-only file system`);i=e=>{l(e),s(),t.write(e)}}let a=Ow(i,t);return n.set(r,a),a}}}function Aw(e,t){let n=t.stdinHandle;if(!n)return e;let r=t.io.bufferReads(()=>t.fs.readIdentity(n.identity));if(r===n.content)return e;if(e!==n.content)throw new D(`feature`,`modified redirected input`,`sed: reading an input file changed after partial consumption is not supported`);return t.stdinHandle={...n,content:r},t.stdinOrigin=t.stdinLeft=r,r}function jw(e,t,n,r,i,a){let o=e.length?e:[`-`],s={stderr:``,failed:!1},c=0,l=0,u=t,d=null;function f(){for(;d===null||d.pos===d.content.length;){if(c===o.length)return!1;d=null;let e=o[c++];e===`-`?u=Aw(u,n):e===`/dev/stdin`&&n.stdinHandle&&(n.stdinOrigin=n.io.bufferReads(()=>n.fs.readIdentity(n.stdinHandle.identity)));let t=nr(`sed`,[e],n,u);if(s.stderr+=t.stderr,s.failed||=t.failed,d=t.inputs.length?{...t.inputs[0],identity:Mw(e,n),pos:0,first:!0}:null,t.stderr&&a&&a(t.stderr),t.entries.some(e=>e.kind===`dir`))return s.directory=!0,c=o.length,!1;d?.shared&&L(n,u),i&&(l=0)}return!0}function p(){if(!f())return null;let e=d.pos,t=d.content.indexOf(r,e),a=t<0?``:r,o=d.content.slice(e,t<0?d.content.length:t);d.pos=t<0?d.content.length:t+r.length,d.shared&&(u=d.content.slice(d.pos),L(n,u));let s=d.first;d.first=!1;let c;return{text:o,terminator:a,line:++l,reset:s,identity:d.identity,last:()=>c??=d.pos<d.content.length?!1:i||!f()}}return{next:p,status:s,get identity(){return d?.identity}}}function Mw(e,t){return e===`-`||e===`/dev/stdin`?t.stdinHandle?.identity:t.fs.fileIdentity?.(j(t.cwd,e,t.fs).path??A(t.cwd,e))}var Nw={n:`
305
+ `,t:` `,r:`\r`,a:`\x07`,f:`\f`,v:`\v`};function Pw(e,t=`substitute command`){let n=e.script[e.i++];if(n===void 0||n===`
306
+ `)throw Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw Error(`delimiter character is not a single-byte character`);return n}function Fw(e,t,n,r=`substitute command`){let i=``,a=!1;for(;e.i<e.script.length;){let o=e.script[e.i++];if(o===`
307
+ `)throw Error(`unterminated ${r}`);if(o===t&&!a)return i;if(o===`\\`){let s=e.script[e.i++];if(s===void 0||s===`
308
+ `&&a)throw Error(`unterminated ${r}`);if(s===`
309
+ `){i+=s;continue}i+=!a&&s===t&&(n||s!==`&`)?s:o+s}else if(n&&o===`[`&&!a)a=!0,i+=o,e.script[e.i]===`^`&&(i+=e.script[e.i++]),e.script[e.i]===`]`&&(i+=e.script[e.i++]);else if(n&&a&&o===`[`&&/[:.=]/u.test(e.script[e.i]??``)){let t=e.script.indexOf(e.script[e.i]+`]`,e.i+1);if(t<0)throw Error(`unterminated character class`);if(e.script.slice(e.i,t).includes(`
310
+ `))throw Error(`unterminated ${r}`);i+=o+e.script.slice(e.i,t+2),e.i=t+2}else n&&o===`]`&&(a=!1),i+=o}throw Error(`unterminated ${r}`)}function Iw(e){let t=Pw(e),n=Fw(e,t,!0),r=Hw(Fw(e,t,!1)),i=Lw(e);if(n===``&&(i.ignoreCase||i.multiline))throw Error(`cannot specify modifiers on empty regexp`);i.multiline&&Rw(i.multiline);let a=Bw(n,e.extended,!1,i.ignoreCase,e.locale);for(let e of r)if(typeof e==`number`&&e>a.re?.groupCount)throw Error(`invalid reference \\${e} in replacement`);return{...a,parts:r,...i}}function Lw(e){let t={global:!1,print:!1,nth:null};for(;e.i<e.script.length;){let n=e.script[e.i];if(/[;\n#}]/u.test(n))break;if(e.i++,!/[ \t]/u.test(n)){if(n===`\r`&&e.script[e.i]===`
311
+ `)break;if(/\d/u.test(n)){if(t.nth!==null)throw Error(`multiple number options to substitute command`);let r=/^\d*/u.exec(e.script.slice(e.i))[0];if(e.i+=r.length,t.nth=Number(n+r),t.nth===0)throw Error(`number option to substitute command may not be zero`);Number.isSafeInteger(t.nth)||bw(`substitution occurrence limit`)}else if(n===`g`||n===`p`){let e=n===`g`?`global`:`print`;if(t[e])throw Error(`multiple substitution flags`);t[e]=!0}else if(n===`w`){Object.assign(t,zw(e));break}else if(n===`i`||n===`I`)t.ignoreCase=!0;else if(n===`m`||n===`M`)t.multiline=n;else if(n===`e`)Rw(n);else throw Error(`unknown option to substitute command: '${n}'`)}}return t}function Rw(e){let t=e===`e`?`command evaluation`:`multiline regex matching`;throw new D(`feature`,`substitution flag ${e}`,`sed: substitution flag '${e}' (${t}) is not supported`)}function zw(e){let t=/^[ \t]*([^\n]*)/u.exec(e.script.slice(e.i));e.i+=t[0].length;let n=t[1].split(`\0`,1)[0];if(n===``)throw Error(`missing filename in r/R/w/W commands`);return e.openWrite?{writer:e.openWrite(n)}:{writeName:n}}function Bw(e,t,n=!1,r=!1,i=P){if(!e){if(r)throw Error(`cannot specify modifiers on empty regexp`);return{re:null}}let a=Ln(i);ah(e,t,a.multibyte);let o=e.replace(/\\(.)/gu,(e,t)=>(t===`o`&&bw(`regex escape`),Object.hasOwn(Nw,t)?Nw[t]:e)),s=r?om(o,a):o,c=t?{source:Bm(s,a)}:tm(s,a);if(c.error)throw Error(c.error);Vw(c.source,t),rm(c.source);for(let[,e]of c.source.matchAll(/\\(.)/gu))/[1-9]/u.test(e)&&bw(`regex backreferences`);return{re:new Yp(Um(c.source,`extent`,a),!1,null,a),noSub:n,locale:i,ignoreCase:r,pattern:o}}function Vw(e,t){let n=!1,r=0,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(s===`\\`){let t=e[++o];n||(i=!"bB<>`'".includes(t),a=!1)}else if(n)s===`]`&&(n=!1,i=!0,a=!1);else if(s===`[`)n=!0;else if(s===`(`)r++,i=!1,a=!1;else{if(s===`)`){if(--r<0)throw Error(`unmatched )`)}else if(s===`|`||s===`^`||s===`$`){i=!1,a=!1;continue}else if(`*+?{`.includes(s)){let n=s===`{`?/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u.exec(e.slice(o)):null;if(s===`{`&&n===null)throw Error(`invalid repetition count`);if(!i||!t&&a&&(s===`*`||s===`{`))throw Error(`Invalid preceding regular expression`);n&&(o+=n[0].length-1),a=!0;continue}i=!0,a=!1}}if(r>0)throw Error(`unmatched (`)}function Hw(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`&`){t.push(0);continue}if(r!==`\\`){t.push(r);continue}let i=e[++n];/[0-9]/u.test(i)?t.push(Number(i)):i===`\\`||i===`&`?t.push(i):Object.hasOwn(Nw,i)?t.push(Nw[i]):bw(`replacement escape`)}return t}function Uw(e,t){if(/[\u0080-\u{10FFFF}]/u.test(e+t.re.src)){if(t.locale!==P)throw new D(`feature`,`locale`,`matching non-ASCII text in the ${t.locale} locale is not supported`);t.ignoreCase&&On.test(e+t.pattern)&&bw(`case folding of Cyrillic Extended-C letters`)}}function Ww(e,t,n=null){let r=e.re===null?t.last:e;if(!r)throw Error(`no previous regular expression`);if(t.last=r,n!==null&&r.noSub){if(n>r.re.groupCount)throw Error(`invalid reference \\${n} in replacement`);r.noSub=!1}return r}function Gw(e,t,n){let r=Ww(t,n,t.parts.reduce((e,t)=>typeof t==`number`?Math.max(e,t):e,0));Uw(e,r);let i=t.parts.some(e=>typeof e==`number`&&e>0&&e<=r.re.groupCount),a=0;return{out:em(e,t.nth&&!t.global?{search:(e,t)=>a?null:r.re.search(e,t)}:r.re,(n,o,s)=>{if(t.nth&&s<t.nth)return null;a++;let c=i?r.re.groups(e,n,o):null;return t.parts.map(t=>typeof t==`string`?t:t===0?e.slice(n,o):c?.[t]?.text??``).join(``)},t.global||t.nth?`global`:`first`).out,count:a}}var Kw={a:7,f:12,n:10,r:13,t:9,v:11,"\n":10},qw={d:10,o:8,x:16};function Jw(e,t){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;if(e.i===e.script.length)throw Error(`expected \\ after 'a', 'c' or 'i'`);if(t.text=null,e.textState.pending={command:t,raw:``},e.script[e.i]===`\\`){let t=e.script[++e.i];if(t===void 0)return;e.i++,t!==`
312
+ `&&(e.textState.pending.raw=t)}Yw(e)}function Yw(e){let t=e.textState.pending;if(!t)return;let n=t.raw;for(;e.i<e.script.length&&e.script[e.i]!==`
313
+ `;){let r=e.script[e.i++];if(r===`\\`){if(e.i===e.script.length){t.raw=n+`
314
+ `;return}n+=r+e.script[e.i++]}else n+=r}t.command.text=Zw(n+`
315
+ `),e.textState.pending=null}function Xw(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function Zw(e){return k(Qw(e))}function Qw(e){let t=b(e),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r!==92||e+1===t.length){n.push(r);continue}let i=String.fromCodePoint(t[++e]);if(Object.hasOwn(Kw,i))n.push(Kw[i]);else if(Object.hasOwn(qw,i)){let r=qw[i],a=r===16?2:3,o=0,s=0;for(;o<a&&e+1<t.length;){let n=t[e+1],i=n>=48&&n<=57?n-48:(n|32)>=97&&(n|32)<=102?(n|32)-87:-1;if(i<0||i>=r)break;s=s*r+i,o++,e++}n.push(o?s&255:i.codePointAt(0))}else if(i===`c`){if(++e===t.length)continue;let r=t[e];if(r===92&&t[++e]!==92)throw Error(`recursive escaping after \\c not allowed`);n.push((r>=97&&r<=122?r-32:r)^64)}else n.push(i.codePointAt(0))}return Uint8Array.from(n)}function $w(e){let t=Pw(e,`'y' command`),n=Qw(eT(e,t)),r=Qw(eT(e,t)),i=e.byteLocale?n:[...k(n)],a=e.byteLocale?r:[...k(r)];if(i.length!==a.length)throw Error(`'y' command strings have different lengths`);let o=e.byteLocale?Uint8Array.from({length:256},(e,t)=>t):new Map;for(let t=0;t<i.length;t++)e.byteLocale?o[i[t]]=a[t]:o.has(i[t])||o.set(i[t],a[t]);return{translation:o,byteLocale:e.byteLocale}}function eT(e,t){let n=``;for(;e.i<e.script.length;){let r=e.script[e.i++];if(r===`
316
+ `)break;if(r===t)return n;if(r!==`\\`){n+=r;continue}let i=e.script[e.i++];if(i===void 0)break;n+=i===t||i===`
317
+ `?i:r+i}throw Error(`unterminated 'y' command`)}function tT(e,t){if(t.byteLocale)return k(b(e).map(e=>t.translation[e]));let n=``;for(let r of e)n+=t.translation.get(r)??r;return n}function nT(e,t=!1,n=P,r=null){let i={script:e,i:0,extended:t,locale:n,byteLocale:yn(n),textState:r??{},openWrite:r?.openWrite},a=[];for(Yw(i);i.i<e.length;){if(/[;\n\r\f\v \t]/u.test(e[i.i])){i.i++;continue}e[i.i]===`#`&&bw(`comments`);let t=oT(i),n=null;if(t&&e[i.i]===`,`&&(i.i++,n=oT(i,!0),n===null))throw Error(`missing second address`);e[i.i]===`~`&&bw(`step address`);let r=t?.type===`line`&&t.value===0;if(r&&n?.type!==`regex`)throw Error(`line numbers must be >= 1`);let o=!1;if(e[i.i]===`!`){for(o=!0,i.i++;/[ \t]/u.test(e[i.i]??``);)i.i++;if(e[i.i]===`!`)throw Error(`multiple '!'s`)}let s=e[i.i++],c={kind:s,start:t,end:n,active:r,negated:o};if(s&&`pPnNdD=gGhHx`.includes(s))a.push(c);else if(s===`w`){a.push({...c,...zw(i)});continue}else if(s===`:`||s===`b`||s===`t`||s===`T`){a.push({...c,label:iT(i,c)});continue}else if(s===`s`)a.push({...c,...Iw(i)});else if(s===`a`||s===`i`||s===`c`)Jw(i,c),a.push(c);else if(s===`y`)a.push({...c,...$w(i)});else if(s===`q`){if(n!==null)throw Error(`command only uses one address`);let t=/^[ \t]*(\d*)/u.exec(e.slice(i.i));i.i+=t[0].length;let r=BigInt.asIntN(32,BigInt(t[1]||`0`));a.push({...c,exitCode:r===-1n?0:Number(BigInt.asUintN(8,r))})}else if(s===`{`){i.textState.blockDepth=(i.textState.blockDepth??0)+1,a.push(c);continue}else if(s===`}`){if(!i.textState.blockDepth)throw Error(`unexpected '}'`);if(t!==null)throw Error(`'}' doesn't want any addresses`);i.textState.blockDepth--,a.push(c)}else{if(s===void 0)throw Error(`missing command`);if(`QlLFzrRWev`.includes(s))bw();else throw Error(`unknown command: '${s}'`)}for(;/[ \t]/u.test(e[i.i]??``);)i.i++;if(e[i.i]===`#`&&bw(`comments`),i.i<e.length&&!/[;\n}]/u.test(e[i.i]))throw Error(`extra characters after command`)}return r===null&&Xw(i.textState),a}function rT(e,t){let n=[];for(let t=0;t<e.length;t++){let r=e[t];if(r.kind===`{`&&n.push(r),r.kind===`}`){if(n.length===0)throw Error(`unexpected '}'`);n.pop().jump=t}}if(n.length)throw Error(`unmatched '{'`);return Xw(t),aT(e),e}function iT(e,t){if(t.kind===`:`&&t.start!==null)throw Error(`':' doesn't want any addresses`);let n=/^[ \t]*([^ \t\n;}#]*)/u.exec(e.script.slice(e.i));e.i+=n[0].length;let r=n[1].split(`\0`,1)[0];if(t.kind===`:`&&r===``)throw Error(`':' lacks a label`);return r}function aT(e){let t=new Map;for(let n=0;n<e.length;n++)e[n].kind===`:`&&t.set(e[n].label,n);for(let n=e.length-1;n>=0;n--){let r=e[n];if(![`b`,`t`,`T`].includes(r.kind))continue;let i=r.label===``?e.length:t.get(r.label);if(i===void 0)throw Object.assign(Error(`can't find label for jump to \`${r.label}'`),{exitCode:4});r.jump=i}}function oT(e,t=!1){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;e.script[e.i]===`~`&&bw(`step address`);let n=/^(\d+|\+[ \t]*\d+)/u.exec(e.script.slice(e.i)),r=null;if(n){let i=n[0][0]===`+`;if(i&&!t)throw Error(`relative address requires a range`);let a=Number(n[0].replace(/[ \t]/gu,``));Number.isSafeInteger(a)||bw(`address limit`),e.i+=n[0].length,r={type:i?`offset`:`line`,value:a}}else if(e.script[e.i]===`$`)e.i++,r={type:`last`};else if(e.script[e.i]===`/`||e.script[e.i]===`\\`){e.script[e.i]===`\\`&&e.i++;let t=Fw(e,Pw(e,`address regex`),!0,`address regex`),n=!1;for(;;){for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;let r=e.script[e.i];if(r!==`I`&&r!==`M`)break;if(t===``)throw Error(`cannot specify modifiers on empty regexp`);r===`M`&&bw(`address regex flags`),n=!0,e.i++}r={type:`regex`,...Bw(t,e.extended,!0,n,e.locale)}}for(;/[ \t]/u.test(e.script[e.i]??``);)e.i++;return r}function sT(e,t,n,r,i){let{start:a,end:o}=e;if(a===null)return!0;if(o===null)return cT(a,t,n,r,i);if(!e.active){if(a.type===`line`){if(e.closed||n<a.value)return!1}else if(!cT(a,t,n,r,i))return!1;if(e.active=!0,o.type===`regex`)return!0;if(o.type===`offset`&&(e.until=n+o.value),o.type===`line`)return e.active=n<o.value,e.closed=!e.active,n<=o.value||cT(a,t,n,r,i)}return o.type===`line`?(e.active=n<o.value,e.closed=!e.active,n<=o.value):((o.type===`offset`?n>=e.until:cT(o,t,n,r,i))&&(e.active=!1,e.closed=!0),!0)}function cT(e,t,n,r,i){if(e.type===`line`)return n===e.value;if(e.type===`last`)return typeof r==`function`?r():r;let a=Ww(e,i);return Uw(t,a),a.re.search(t)!==null}function lT(e,t,n,r=!1){let{output:i,delimiter:a}=e,o=t.has(`n`)||t.has(`quiet`)||t.has(`silent`),s=t.has(`s`)||t.has(`separate`),c=jw(e.files,e.stdin,n,a,s,e=>i.stream(2,e)),l=i.start(c),u=[],d=Ow(r?e=>{i.account(e),u.push(e)}:e=>i.stream(1,e),a),f={delimiter:a,quiet:o,separate:s,hold:e.hold,regexState:e.regexState,budget:e.budget,emit:d,input:c,output:i};try{let t=uT(e.commands,f);l.quit=t!==null,l.exitCode=c.status.failed?c.status.directory?4:2:t??0,l.failed=c.status.failed}catch(e){let t=xw(e);K(l,t);let n=w(t);n&&E(l,n.kind,n.command,n.detail,n.message),l.failed=!0}finally{i.finish()}return r&&(l.content=u.join(``)),l}function uT(e,t){let n=!0;for(let r=t.input.next();r;r=t.input.next()){if(n||t.separate&&r.reset){t.hold.text=``;for(let t of e)t.active=t.start?.type===`line`&&t.start.value===0,t.closed=!1;n=!1}t.output.record(r);let i={...r,...t,append:[],exitCode:null,replaced:!1},a=dT(e,i);if(!t.quiet&&!a&&t.emit(i.text,i.terminator),i.exitCode!==null&&t.emit(``),hT(i),i.exitCode!==null)return i.exitCode;t.output.record(null)}return null}function dT(e,t){for(let n=0;n<e.length;n++){if(++t.budget.steps>_w)throw new D(`feature`,`execution limit`,`sed: execution limit reached after ${_w} commands (infinite loop?)`);let r=e[n];if(r.kind===`}`||r.kind===`:`)continue;if(sT(r,t.text,t.line,t.last,t.regexState)===!!r.negated){r.kind===`{`&&(n=r.jump);continue}let i=r.kind;if(i!==`{`){if(i===`b`||i===`t`||i===`T`){let e=i===`b`||(i===`t`?t.replaced:!t.replaced);i!==`b`&&(t.replaced=!1),e&&(n=r.jump-1);continue}if(i===`q`){t.exitCode=r.exitCode;break}if(i===`d`)return!0;if(i===`D`){let e=t.text.indexOf(t.delimiter);if(e<0)return!0;t.text=t.text.slice(e+t.delimiter.length),n=-1;continue}if(i===`n`||i===`N`){if(!mT(t,i===`N`))return!0;continue}if(i===`c`)return!r.active&&r.text!==null&&t.emit(r.text.slice(0,-1),t.delimiter),!0;if(fT(r,t),t.text.length>vw)throw new D(`feature`,`pattern space limit`,`sed: pattern space limit exceeded`)}}return!1}function fT(e,t){let{kind:n}=e;if(n===`a`)t.append.push(e.text);else if(n===`i`)e.text!==null&&t.emit(e.text.slice(0,-1),t.delimiter);else if(n===`p`)t.emit(t.text,t.terminator);else if(n===`P`){let e=t.text.indexOf(t.delimiter);t.emit(e<0?t.text:t.text.slice(0,e),e<0?t.terminator:t.delimiter)}else if(n===`=`)t.emit(String(t.line),t.delimiter);else if(n===`w`)e.writer(t.text,t.terminator);else if(`gGhHx`.includes(n))pT(n,t);else if(n===`y`)t.text=tT(t.text,e);else{let n=Gw(t.text,e,t.regexState);if(t.text=n.out,!n.count)return;t.replaced=!0,e.print&&t.emit(t.text,t.terminator),e.writer&&e.writer(t.text,t.terminator)}}function pT(e,t){let n=t.hold;if(e===`x`){let{text:e,terminator:r}=t;Object.assign(t,n),Object.assign(n,{text:e,terminator:r})}else{let r=e===`h`||e===`H`?t:n,i=r===n?t:n;i.text=e===`G`||e===`H`?i.text+t.delimiter+r.text:r.text,i.terminator=r.terminator}if(n.text.length>vw)throw new D(`feature`,`hold space limit`,`sed: hold space limit exceeded`)}function mT(e,t){if(!t&&!e.quiet&&e.emit(e.text,e.terminator),e.last())return t&&!e.quiet&&e.emit(e.text,e.terminator),!1;hT(e);let n=e.input.next();if(!n)return t&&!e.quiet&&e.emit(e.text,e.delimiter),!1;let r=t?e.text+e.delimiter+n.text:n.text;if(r.length>vw)throw new D(`feature`,`pattern space limit`,`sed: pattern space limit exceeded`);return Object.assign(e,n,{text:r,replaced:!1}),e.output.record(n),!0}function hT(e){if(e.append.length!==0){e.emit(``);for(let t of e.append)e.emit(t??``);e.append.length=0}}function gT(e,t,n){try{let{tokens:r,inPlace:i}=Sw(t),a=U(r,{short:[`n`,`E`,`r`,`s`,`z`],long:[`regexp-extended`,`quiet`,`silent`,`separate`,`null-data`,`zero-terminated`],repeatable:[`e`,`expression`,`f`,`file`]}),o=a.flags.has(`z`)||a.flags.has(`null-data`)||a.flags.has(`zero-terminated`)?`\0`:`
318
+ `,s=kw(n,o),c=_T(a,e,n,s.openWrite);return c===null?C(gw):c.error?c.error:(Object.assign(c,{output:s,delimiter:o,hold:{text:``,terminator:o},regexState:{last:null},budget:{steps:0}}),c.stdin=Aw(c.stdin,n),i===null?lT(c,a.flags,n):Cw(c,a.flags,n,i,(e,t)=>lT(e,t,n,!0)))}catch(e){return xw(e)}}function _T({order:e,positional:t},n,r,i){let a=[],o={openWrite:i},s=!1,c=!1;for(let{name:t,value:i}of e){if((t===`E`||t===`r`||t===`regexp-extended`)&&(s=!0),![`e`,`expression`,`f`,`file`].includes(t))continue;c=!0;let e=i;if(t===`f`||t===`file`){n=Aw(n,r);let t=n,a=r.io.bufferReads(()=>nr(`sed`,[i],r,t));if(a.failed)return{error:C(a.stderr,4)};e=a.inputs[0].content,a.inputs[0].shared&&(n=``)}for(let t of nT(e,s,r.locale,o))a.push(t)}return c?{commands:rT(a,o),files:t,stdin:n}:t.length===0?null:{commands:rT(nT(t[0],s,r.locale,o),o),files:t.slice(1),stdin:n}}var vT=new Set([`-b`,`-c`,`-g`,`-k`,`-p`,`-r`,`-t`,`-u`,`-v`,`-w`,`-x`,`-G`,`-N`,`-O`,`-R`,`-S`,`-o`]),yT=new Set([`-nt`,`-ot`,`-ef`,`<`,`>`]),bT={__proto__:null,"-eq":(e,t)=>e===t,"-ne":(e,t)=>e!==t,"-lt":(e,t)=>e<t,"-le":(e,t)=>e<=t,"-gt":(e,t)=>e>t,"-ge":(e,t)=>e>=t},xT=String(Rn).length,ST=new Set([`/dev/stdin`,`/dev/stdout`,`/dev/stderr`]);function CT(e,t,n){return TT(`test`,t,n)}function wT(e,t,n){return t.at(-1)===`]`?TT(`[`,t.slice(0,-1),n):C("[: missing `]'",2)}function TT(e,t,n){try{return{...S(),exitCode:+!ET(t,n)}}catch(t){return dt(t,e,`${e}: ${t.message}`,2)}}function ET(e,t){let[n,r,i]=e;if(e.length===0)return!1;if(e.length===1)return n!==``;if(e.length===2){if(n===`!`)return r===``;if(n===`-n`)return r!==``;if(n===`-z`)return r===``;if([`-a`,`-e`,`-f`,`-d`,`-h`,`-L`,`-s`].includes(n))return OT(n,r,t);throw vT.has(n)&&jT(n),Error(`${n}: unary operator expected`)}if(e.length===3){if(r===`=`||r===`==`)return n===i;if(r===`!=`)return n!==i;if(Object.hasOwn(bT,r))return bT[r](DT(n),DT(i));yT.has(r)&&jT(r),(r===`-a`||r===`-o`)&&jT(`compound expressions`)}if(e.length<=4){if(n===`!`)return!ET(e.slice(1),t);if(n===`(`&&e.at(-1)===`)`)return ET(e.slice(1,-1),t)}throw e.some(e=>[`-a`,`-o`,`!`,`(`,`)`].includes(e))&&jT(`compound expressions`),Error(e.length>3?`too many arguments`:`${r}: binary operator expected`)}function DT(e){let t=/^[ \t\n\r\f\v]*([+-]?)(\d+)[ \t]*$/u.exec(e);if(t&&t[0].length===e.length){let e=t[2].replace(/^0+/u,``)||`0`;if(e.length<=xT){let n=BigInt(t[1]+e);if(n>=zn&&n<=Rn)return n}}throw Error(`${e}: integer expression expected`)}function OT(e,t,n){let r={isDir:e=>e===`/dev`||e===`/dev/fd`||n.fs.isDir(e),isFile:e=>e===`/dev/null`||AT(e)||n.fs.isFile(e),isLink:e=>n.fs.isLink?.(e)===!0,readLink:e=>n.fs.readLink?.(e)},i=e===`-h`||e===`-L`,{path:a,error:o}=j(n.cwd,t,r,{follow:!i});return!o&&(AT(a)&&jT(`stream device metadata`),i?r.isLink(a):e===`-e`||e===`-a`?!0:e===`-d`?r.isDir(a):e===`-s`?r.isDir(a)||a!==`/dev/null`&&kT(n,a)>0:a!==`/dev/null`&&n.fs.isFile(a))}var kT=(e,t)=>e.fs.fileSize?.(t)??O(e.fs.readFile(t)).length;function AT(e){return ST.has(e)||/^\/dev\/fd\/\d+$/u.test(e)}function jT(e){throw new D(`feature`,e,`${e} is not supported`)}function MT(e){let t=e.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/gu,``),n=/^[+-]?\d+$/u.test(t)?BigInt(t):null;return{arg:t,n:n!==null&&n>=zn&&n<=Rn?n:null}}var NT=e=>({...e,halt:!0});function PT(e,t,n){let r=t[0]===`--`?t.slice(1):t;if(r.length===0)return NT({...S(),exitCode:n.lastExit});let{arg:i,n:a}=MT(r[0]);return a===null?NT(C(`exit: ${i}: numeric argument required`,2)):r.length>1?NT(C(`exit: too many arguments`)):NT({...S(),exitCode:Number((a%256n+256n)%256n)})}function FT(e){return(t,n,r)=>{let i=n[0]===`--`?n.slice(1):n;if(i.length>1)return NT(C(`${e}: too many arguments`));let{arg:a,n:o}=MT(i[0]??`1`);return o===null?NT(C(`${e}: ${a}: numeric argument required`,128)):o<=0?{...C(`${e}: ${a}: loop count out of range`),control:r.loopDepth?{type:`break`,levels:r.loopDepth}:void 0}:r.loopDepth===0?C(`${e}: only meaningful in a \`for\`, \`while\` or \`until\` loop`,0):{...S(),control:{type:e,levels:Number(o>BigInt(r.loopDepth)?BigInt(r.loopDepth):o)}}}}function IT(e,t,n){let r=t[0]===`--`,i=r?t.slice(1):t;if(i.length===0||!r&&i[0]===`-p`)return T(`option`,`export`,`-p`,`export: listing the environment is not supported (there is none)`);let a=``;for(let e of i){let t=e.indexOf(`=`),i=t>0&&e[t-1]===`+`,o=t===-1?e:e.slice(0,i?t-1:t);if(!r&&e.startsWith(`-`))return T(`option`,`export`,e,`export: option \`${e}\` is not supported`);Ni.test(o)?t===-1?n.vars.has(o)&&n.vars.set(o,n.vars.get(o)):n.vars.set(o,(i?rb(o,n):``)+e.slice(t+1)):a+=`export: \`${o}': not a valid identifier
319
+ `}return{stdout:``,stderr:a,exitCode:+!!a}}function LT(e,t,n){let r=+(t[0]===`-v`),i=t[r]===`--`;i&&r++;let a=t.slice(r);for(let e of a){if(!i&&e.startsWith(`-`))return T(`option`,`unset`,e,`unset: option \`${e}\` is not supported`);if(e.includes(`[`))return T(`feature`,`unset`,`array subscript`,`unset: array subscripts are not supported`);if(e===`LANG`)return T(`feature`,`unset`,`LANG`,`unset: LANG: ${mn}`);n.vars.delete(e)}return S()}function RT(e,t,n){let r=null;for(let e=0;e<t.length;e++){let n=t[e];if(n===`-e`||n===`+e`)r=n===`-e`;else if((n===`-o`||n===`+o`)&&t[e+1]===`errexit`)r=n===`-o`,e++;else return zT()}return r===null?zT():(n.errexit=r,S())}var zT=()=>T(`feature`,`set`,`set`,"set: `set` is supported only as `set -e` or `set +e`",127),BT={exit:PT,break:FT(`break`),continue:FT(`continue`),export:IT,set:RT,unset:LT},VT=new Map([[`return`,` (there are no shell functions)`],[`source`,` (nothing can be sourced into this shell)`],[`.`,``,"`.` (source)"],`eval`,`exec`,[`read`,` (there is no interactive input)`],[`shift`,` (there are no positional parameters)`],`shopt`,[`local`,` (there are no shell functions)`],[`declare`,"; use `NAME=value`"],[`typeset`,"; use `NAME=value`"],[`readonly`,"; use `NAME=value`"],[`let`,` (no arithmetic)`],[`type`,"; use `which`"],[`command`,`; run the command directly`],`builtin`,`hash`,`alias`,`unalias`,`trap`,[`wait`,` (nothing runs in the background)`],[`kill`,` (there are no processes)`],[`jobs`,` (there are no processes)`],[`bg`,` (there are no processes)`],[`fg`,` (there are no processes)`],[`disown`,` (there are no processes)`],`suspend`,`times`,`ulimit`,`umask`,[`pushd`,"; use `cd`"],[`popd`,"; use `cd -`"],`dirs`,`history`,`help`,`logout`,`getopts`,`mapfile`,`readarray`,`caller`,`enable`,`compgen`,`complete`,`bind`,`fc`].map(e=>{let[t,n=``,r="`"+t+"`"]=Array.isArray(e)?e:[e];return[t,r+` is not supported`+n]}));function HT(e,t){let n=0,r=!0,i=!1;for(;n<t.length&&/^-[neE]+$/u.test(t[n]);n++)for(let e of t[n].slice(1))e===`n`?r=!1:i=e===`e`;let a=t.slice(n).join(` `);if(i){let e=UT(a);a=e.text,e.stop&&(r=!1)}return S(r?a+`
320
+ `:a)}function UT(e){let t={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92},n=[],r=e=>{for(let t of b(e))n.push(t)},i=e=>({text:k(Uint8Array.from(n)),stop:e});for(let a=0;a<e.length;a++){if(e[a]!==`\\`||a+1>=e.length){let t=e.indexOf(`\\`,a+1),n=t<0?e.length:t;r(e.slice(a,n)),a=n-1;continue}let o=e[++a];if(o===`c`)return i(!0);if(o in t){n.push(t[o]);continue}if(o===`0`){let t=``;for(;t.length<3&&/[0-7]/u.test(e[a+1]??``);)t+=e[++a];n.push(t===``?0:parseInt(t,8)&255);continue}let s=o===`x`?2:o===`u`?4:o===`U`?8:0;if(s>0&&/[0-9a-fA-F]/u.test(e[a+1]??``)){let t=``;for(;t.length<s&&/[0-9a-fA-F]/u.test(e[a+1]??``);)t+=e[++a];let i=parseInt(t,16);if(o===`x`)n.push(i);else{if(!ti(i))throw new D(`feature`,`echo Unicode escape`,`echo: escapes outside Unicode scalar values are not supported`);r(String.fromCodePoint(i))}continue}let c=a+ri(e,a);r(`\\`+e.slice(a,c)),a=c-1}return i(!1)}var WT={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92};function GT(e,t,n,r){let i=e[t+1],a=t+2;if(i===void 0)return{bytes:[92],end:t+1};if(n&&i===`c`)return{bytes:[],end:a,stop:!0};if(Object.hasOwn(WT,i))return{bytes:[WT[i]],end:a};if(!n&&`'"?`.includes(i))return{bytes:[i.codePointAt(0)],end:a};if(/[0-7]/u.test(i)){let r=n&&i===`0`?4:3;for(;a<t+1+r&&/[0-7]/u.test(e[a]??``);)a++;return{bytes:[parseInt(e.slice(t+1,a),8)&255],end:a}}let o=i===`x`?2:i===`u`?4:i===`U`?8:0;if(o){for(;a<t+2+o&&/[\da-fA-F]/u.test(e[a]??``);)a++;if(a===t+2||i!==`x`&&a!==t+2+o)return r.stderr+=`printf: missing hexadecimal number in escape
321
+ `,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let n=parseInt(e.slice(t+2,a),16);if(i===`x`)return{bytes:[n],end:a};if(!ti(n))throw new D(`feature`,`Unicode escape`,`escapes outside Unicode scalar values are not supported`);if(r.byteLocale&&n>127)throw new D(`feature`,`Unicode escape in C locale`,`non-ASCII Unicode escapes in the C locale are not supported`);return{bytes:b(String.fromCodePoint(n)),end:a}}return a=t+1+ri(e,t+1),{bytes:b(e.slice(t,a)),end:a}}function KT(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]===`\\`){let i=GT(e,r,!0,t);for(let e of i.bytes)n.push(e);if(r=i.end,i.stop){t.stop=!0;break}}else{let t=e.indexOf(`\\`,r),i=t<0?e.length:t;for(let t of b(e.slice(r,i)))n.push(t);r=i}return Uint8Array.from(n)}var qT=/^%([-+ #0']*)(\d+|\*)?(?:\.(-?\d+|\*)?)?([hlLjzt]*)(.)?/su,JT=8e6;function YT(e,t,n){let r=t[0]===`--`?t.slice(1):t;if(r.length===0)return lt(`printf format [arguments]`);if(t[0]!==`--`&&/^-./su.test(t[0])){let e=t[0].startsWith(`-v`)?`-v`:t[0];return T(`option`,`printf`,e,`printf: option ${e} is not supported`,2)}let i={args:r.slice(1),index:0,chunks:[],size:0,stderr:``,failed:!1,stop:!1,byteLocale:bn(n)},a;try{if(r.some(e=>e.includes(`\0`)))throw new D(`feature`,`NUL in argument`,`NUL bytes in command arguments are not supported`);do{let e=i.index;if($T(r[0],i),i.index===e)break}while(!i.stop&&i.index<i.args.length);a=S()}catch(e){a=dt(e,`printf`,`printf: ${e.message}`)}try{a.stdout=ZT(i)}catch(e){let t=w(a);t&&n.unsupported.add(t,`printf`);let r=dt(e,`printf`,`printf: ${e.message}`);r.stderr=a.stderr+r.stderr,a=r}return a.stderr=i.stderr+a.stderr,i.failed&&a.exitCode===0&&(a.exitCode=1),a}function XT(e,t){if(e.size+t.length>JT)throw new D(`feature`,`format size limit`,`formatted output exceeds the output limit`);t.length&&e.chunks.push(t),e.size+=t.length}function ZT(e){let t=new Uint8Array(e.size),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return k(t)}var QT=e=>e.args[e.index++];function $T(e,t){for(let n=0;n<e.length&&!t.stop;)if(e[n]===`\\`){let r=GT(e,n,!1,t);XT(t,r.bytes),n=r.end}else if(e[n]===`%`){if(e[n+1]===`%`){XT(t,[37]),n+=2;continue}let r=eE(e.slice(n),t);n+=r.length;let i=QT(t);if(`sbc`.includes(r.conv))tE(i??``,r,t);else{let e=`diouxX`.includes(r.conv)?kx(Ox(i,`ouxX`.includes(r.conv),t),r):Ax(i,r,t);XT(t,b(e))}}else{let r=n+1;for(;r<e.length&&e[r]!==`%`&&e[r]!==`\\`;)r++;XT(t,b(e.slice(n,r))),n=r}}function eE(e,t){if(/^%[-+ #0'\d.*]*\$/u.test(e))throw new D(`feature`,`positional format arguments`,`positional format arguments are not supported`);let n=qT.exec(e),[,r,i,a,o,s]=n;if(s===void 0)throw Error(`missing format character`);if(!`sbcdiouxXeEfFgG`.includes(s))throw`aAqQnCS(p%I`.includes(s)?new D(`feature`,`%`+s,`format %${s} is not supported`):Error(`invalid format character: ${s}`);if(o&&`sbc`.includes(s))throw new D(`feature`,`format length modifier`,`length modifiers on string and character formats are not supported`);let c={conv:s,length:n[0].length,minus:r.includes(`-`),plus:r.includes(`+`),space:r.includes(` `),zero:r.includes(`0`),alt:r.includes(`#`),width:Number(i===`*`?Ox(QT(t),!1,t):i??0),precision:a===`*`?Number(Ox(QT(t),!1,t)):a===void 0?n[0].includes(`.`)?0:null:Number(a)};if(i===`*`&&Math.abs(c.width)>0x7fffffff||a===`*`&&(c.precision<-0x80000000||c.precision>0x7fffffff))throw new D(`feature`,`format size limit`,`star width or precision outside the signed 32-bit range is not supported`);if(c.width<0&&(c.minus=!0,c.width=-c.width),c.precision<0&&(c.precision=null),c.width>Ep||c.precision>Ep)throw new D(`feature`,`format size limit`,`format width or precision exceeds the output limit`);return c}function tE(e,t,n){let r=t.conv===`b`?KT(e,n):b(e);t.conv===`c`?r=r.length?r.subarray(0,1):new Uint8Array(1):t.precision!==null&&(r=r.subarray(0,t.precision));let i=Math.max(0,t.width-r.length),a=i?new Uint8Array(i).fill(32):[];t.minus||XT(n,a),XT(n,r),t.minus&&XT(n,a)}function nE(e,t){if(!e.includes(`
322
+ `))return e;let n=bn(t);if(!n&&/[\u0080-\u009F\u2028\u2029]/u.test(e))throw new D(`feature`,`filename quoting`,`wc: locale-sensitive filename quoting is not supported`);let r=n?Array.from(b(e),e=>String.fromCodePoint(e)):[...e],i={7:`\\a`,8:`\\b`,9:`\\t`,10:`\\n`,11:`\\v`,12:`\\f`,13:`\\r`},a=!1,o=`'`;for(let e of r){let t=e.codePointAt(0);t<32||t===127||n&&t>127?(a||(o+=`'$'`),o+=i[t]??`\\`+t.toString(8).padStart(3,`0`),a=!0):(o+=e===`'`?`'\\''`:(a?`''`:``)+e,a=!1)}return o+`'`}function rE(e,t,n,r,i){let a=[];for(let t of[`l`,`w`,`m`,`c`])n[t]&&a.push(String(e[t]).padStart(r));return a.join(` `)+(t?` `+nE(t,i):``)}var iE=`**=.**.++.--.+=.-=.*=./=.%=.^=.==.!=.<=.>=.&&.||.!~.>>.|&.+.-.*./.%.^.!.>.<.|.?.:.~.$.=.(.).{.}.[.].;.,`.split(`.`),aE=new Set([`number`,`string`,`name`,`builtin`]),oE=new Set([`)`,`]`,`++`,`--`]),sE=/^(?:0[xX][0-9a-fA-F]+|\d+\.?\d*(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/u,cE=e=>e!==void 0&&/[A-Za-z_]/u.test(e),lE=e=>e!==void 0&&/[A-Za-z0-9_]/u.test(e),uE=e=>e!==void 0&&e>=`0`&&e<=`9`;function dE(e,t=null){let n=[],r=1,i=0,a=(e,t)=>n.push({type:e,value:t,line:r}),o=()=>{let e=n.at(-1);return!e||!aE.has(e.type)&&!(e.type===`punct`&&oE.has(e.value))};for(;i<e.length;){let s=e[i];if(s===`
323
+ `){n.at(-1)?.type!==`newline`&&a(`newline`,`
324
+ `),r++,i++;continue}if(s===` `||s===` `||s===`\r`){i++;continue}if(s===`\\`&&(e[i+1]===`
325
+ `||e[i+1]===`\r`&&e[i+2]===`
326
+ `)){i+=e[i+1]===`
327
+ `?2:3,r++;continue}if(s===`#`){for(;i<e.length&&e[i]!==`
328
+ `;)i++;continue}if(s===`"`){let n=hE(e,i+1,t,r);a(`string`,n.value),i=n.end;continue}if(s===`/`&&o()){let t=gE(e,i+1,r);a(`regex`,t.value),i=t.end;continue}if(uE(s)||s===`.`&&uE(e[i+1])){let t=fE(e,i);a(`number`,t.value),i=t.end;continue}if(cE(s)){let t=i+1;for(;lE(e[t]);)t++;let n=e.slice(i,t);if(e.slice(t,t+2)===`::`)throw new W(`namespaces are not supported`,r,`namespaces`);i=t,bp.has(n)?a(`keyword`,n===`func`?`function`:n):Cp.has(n)?a(`builtin`,n):a(e[t]===`(`?`funcname`:`name`,n);continue}let c=i,l=iE.find(t=>e.startsWith(t,c));if(s===`@`)throw new W(`typed regexes, indirect calls and source directives are not supported`,r,`@ extensions`);if(!l)throw new W(`unexpected character \`${s}\``,r);a(`punct`,l),i+=l.length}return a(`eof`,``),n}function fE(e,t){let n=sE.exec(e.slice(t))[0],r=n;return/^0[xX]/u.test(n)?r=String(Number.parseInt(n.slice(2),16)):/^0[0-7]+$/u.test(n)&&(r=String(Number.parseInt(n,8))),{value:r,end:t+n.length}}var pE={__proto__:null,n:`
329
+ `,t:` `,r:`\r`,a:`\x07`,b:`\b`,f:`\f`,v:`\v`,'"':`"`,"\\":`\\`};function mE(e,t,n){let r=e[t+1];if(r===void 0)return{text:`\\`,end:t+1};if(r in pE)return{text:pE[r],end:t+2};if(r>=`0`&&r<=`7`){let n=t+1;for(;n<t+4&&e[n]>=`0`&&e[n]<=`7`;)n++;return{byte:Number.parseInt(e.slice(t+1,n),8)&255,end:n}}if(r===`x`&&/[0-9a-fA-F]/u.test(e[t+2]??``)){let n=t+2;for(;n<t+4&&/[0-9a-fA-F]/u.test(e[n]??``);)n++;return{byte:Number.parseInt(e.slice(t+2,n),16),end:n}}if(r.codePointAt(0)>127)throw new W(`non-ASCII characters after an escape are not supported`,null,`non-ASCII string escape`);return n?.(`escape sequence \`\\${r}' treated as plain \`${r}'`),{text:r,end:t+2}}function hE(e,t,n,r=null){let i=[],a=t;for(;a<e.length;){let t=e[a];if(r!==null){if(t===`"`)return{value:k(Uint8Array.from(i)),end:a+1};if(t===`
330
+ `)break;if(t===`\\`&&e[a+1]===`
331
+ `){a+=2;continue}}if(t===`\\`){let t=mE(e,a,n);vE(i,t),a=t.end}else{let t=String.fromCodePoint(e.codePointAt(a));vE(i,{text:t}),a+=t.length}}if(r!==null)throw new W(`unterminated string`,r);return{value:k(Uint8Array.from(i)),end:a}}function gE(e,t,n){let r=t,i=!1;for(;r<e.length;){let n=e[r];if(n===`
332
+ `)break;if(n===`\\`)r+=2;else if(i){if(n===`[`&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){r=t+2;continue}}n===`]`&&(i=!1),r++}else if(n===`[`)i=!0,r++,e[r]===`^`&&r++,e[r]===`]`&&r++;else{if(n===`/`)return{value:e.slice(t,r),end:r+1};r++}}throw new W(`unterminated regexp`,n)}function _E(e,t=null){return hE(e,0,t).value}function vE(e,t){if(t.byte===void 0)for(let n of b(t.text))e.push(n);else e.push(t.byte)}var yE=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`^=`,`**=`]),bE=new Set([`<`,`<=`,`==`,`!=`,`>`,`>=`]),xE=e=>e.type===`var`||e.type===`index`||e.type===`field`;function SE(e){let t=e.tok;return ME(e)||t.type===`regex`||t.type===`keyword`&&t.value===`getline`||t.type===`punct`&&[`!`,`-`,`+`].includes(t.value)}function CE(e,t){let n=[wE(e,t)];for(;e.accept(`,`);)e.skipNewlines(),n.push(wE(e,t));return n}function wE(e,t){let n=TE(e,t),r=e.tok;if(r.type===`punct`&&yE.has(r.value)){xE(n)||e.fail(`cannot assign to ${n.type===`regex`?`a regex`:`a non-variable`} (left side of \`${r.value}\`)`),e.next();let i=wE(e,t);return{type:`assign`,op:r.value===`**=`?`^=`:r.value,target:n,value:i}}return n}function TE(e,t){let n=kE(e,t);if(!e.accept(`?`))return n;e.skipNewlines();let r=wE(e,t);return e.skipNewlines(),e.expect(`:`),e.skipNewlines(),{type:`cond`,test:n,consequent:r,alternate:wE(e,t)}}var EE=[[`or`,[`||`]],[`and`,[`&&`]],[`in`,[`in`]],[`match`,[`~`,`!~`]],[`compare`,[...bE]],[`concat`,[]],[`binary`,[`+`,`-`]],[`binary`,[`*`,`/`,`%`]]],DE=new Map(EE.flatMap(([e,t],n)=>t.map(t=>[t,{type:e,precedence:n}]))),OE={type:`concat`,precedence:5};function kE(e,t,n=0){let r=IE(e,t),i=1/0;for(;;){let a=e.tok;n<=4&&i>4&&!t.noGt&&(e.is(`|`)||e.is(`|&`))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${Dp}`,`"cmd" | getline`);let o=ME(e)?OE:a.type===`punct`||a.type===`keyword`&&a.value===`in`?DE.get(a.value):void 0;if(!o||o.precedence<n||o.precedence>i||t.noGt&&e.is(`>`))return r;let{type:s,precedence:c}=o,l=s===`concat`?null:e.next().value;if(i=c,(s===`or`||s===`and`)&&e.skipNewlines(),s===`in`){r={type:s,keys:[r],array:AE(e)};continue}let u=kE(e,t,c+1);(l===`/`||l===`%`)&&PE(u)===0&&PE(r)!==null&&e.fail(l===`/`?`division by zero attempted`:"division by zero attempted in `%`",null,`error`),s===`compare`&&jE(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),r=s===`binary`||s===`compare`?{type:s,op:l,left:r,right:u}:s===`match`?{type:s,negate:l===`!~`,left:r,right:u}:{type:s,left:r,right:u}}}function AE(e){return e.tok.type!==`name`&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var jE=(e,t)=>e.tok.type===`punct`&&bE.has(e.tok.value)&&!(t.noGt&&e.tok.value===`>`);function ME(e){let t=e.tok;return t.type===`number`||t.type===`string`||t.type===`name`||t.type===`funcname`||t.type===`builtin`||t.type===`punct`&&[`$`,`(`,`++`,`--`].includes(t.value)}function NE(e,t){return kE(e,t,5)}function PE(e){if(e.type===`num`)return e.value;if(e.type===`neg`||e.type===`plus`){let t=PE(e.expr);return t===null?null:e.type===`neg`?-t:t}if(e.type!==`binary`)return null;let t=PE(e.left),n=PE(e.right);return t===null||n===null?null:Op(e.op,t,n)}var FE={__proto__:null,"!":`not`,"-":`neg`,"+":`plus`};function IE(e,t,n=!1){if(n&&(e.is(`$`)||e.is(`++`)||e.is(`--`)))return zE(e,t);let r=e.tok.type===`punct`&&FE[e.tok.value];return r?(e.next(),{type:r,expr:IE(e,t,n)}):n?BE(e,t):LE(e,t)}function LE(e,t){let n=RE(e,t);return!e.is(`^`)&&!e.is(`**`)?n:(e.next(),{type:`binary`,op:`^`,left:n,right:IE(e,t)})}function RE(e,t){let n=zE(e,t);for(;(e.is(`++`)||e.is(`--`))&&xE(n);)n={type:`postinc`,op:e.next().value,target:n};return n}function zE(e,t){if(e.accept(`$`))return{type:`field`,index:IE(e,t,!0)};if(e.is(`++`)||e.is(`--`)){let n=e.next().value,r=zE(e,t);return xE(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:`preinc`,op:n,target:r}}return BE(e,t)}function BE(e,t){let n=e.tok;switch(n.type){case`number`:return e.next(),{type:`num`,value:Number(n.value)};case`string`:return e.next(),{type:`str`,value:n.value};case`regex`:return e.next(),{type:`regex`,source:n.value,re:VE(e,n.value)};case`name`:return UE(e);case`funcname`:return WE(e);case`builtin`:return qE(e);case`keyword`:return n.value===`getline`?JE(e,t):e.unexpected();case`punct`:return n.value===`(`?KE(e):e.unexpected();default:return e.unexpected()}}function VE(e,t){try{return Zp(t,!1,t=>e.warn(t))}catch(t){return e.fail(t.message,t.gap??null)}}function HE(e){if(!e.accept(`[`))return null;let t=CE(e,{});return e.expect(`]`),e.is(`[`)&&e.fail(`arrays of arrays are not supported`,`arrays of arrays`),t}function UE(e){let t=e.next().value,n=HE(e);return n===null?(e.is(`(`)&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:`var`,name:t}):{type:`index`,name:t,subs:n}}function WE(e){return{type:`call`,name:e.next().value,args:GE(e)}}function GE(e){e.expect(`(`);let t=e.is(`)`)?[]:CE(e,{});return e.expect(`)`),t}function KE(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=CE(e,{});if(e.expect(`)`),n.length===1){for(;t-->0;)e.expect(`)`);return n[0]}return e.isKw(`in`)||e.fail("a parenthesized list must be followed by `in ARRAY`"),e.next(),{type:`in`,keys:n,array:AE(e)}}function qE(e){let t=e.next().value;if(Sp.has(t)&&e.fail(Sp.get(t),`${t}()`),!e.is(`(`)){if(t===`length`)return{type:`builtin`,name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=GE(e),[r,i]=xp[t];return(n.length<r||n.length>i)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?``:`s`}; it takes ${r===i?r:`${r} to ${i===1/0?`any number`:i}`}`),(t===`sub`||t===`gsub`)&&n[2]&&!xE(n[2])&&e.fail(`${t}(): substitution into a temporary value is not supported`,`substitution into temporary value`),t===`split`&&n[1].type!==`var`&&e.fail(`split(): second argument must be an array name`),t===`match`&&n[2]&&n[2].type!==`var`&&e.fail(`match(): third argument must be an array name`),{type:`builtin`,name:t,args:n}}function JE(e,t){e.next();let n=null;(e.tok.type===`name`||e.is(`$`))&&(n=zE(e,t),xE(n)||e.fail(`getline: target must be a variable, field or array element`));let r=null;return e.accept(`<`)&&(r=RE(e,t)),{type:`getline`,target:n,file:r}}var YE=new Set([`/dev/stdout`,`/dev/stderr`,`/dev/null`]),XE=class{constructor(e,t){this.toks=e,this.i=0,this.warnings=t,this.funcs=new Set,this.parens=new Map;let n=[];for(let t=0;t+1<e.length;t++){let r=e[t],i=e[t+1];r.type===`punct`&&(r.value===`(`?n.push(t):r.value===`)`&&n.length>0&&this.parens.set(n.pop(),t)),r.type===`keyword`&&r.value===`function`&&(i.type===`name`||i.type===`funcname`)&&this.funcs.add(i.value)}this.loopDepth=0,this.switchDepth=0,this.context=`main`}get tok(){return this.toks[this.i]}peek(e){return this.toks[Math.min(this.i+e,this.toks.length-1)]}is(e,t=`punct`){return this.tok.type===t&&this.tok.value===e}isKw(e){return this.is(e,`keyword`)}next(){return this.toks[this.i++]}accept(e,t=`punct`){return this.is(e,t)?this.next():null}expect(e,t=`punct`){return this.is(e,t)||this.fail(`expected \`${e}\` but found ${ZE(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type===`newline`;)this.i++}skipTerminators(){for(;this.tok.type===`newline`||this.is(`;`);)this.i++}fail(e,t=null,n=`syntax error`){throw new W(e,this.tok.line,t,n)}warn(e){this.warnings.push(e)}unexpected(){this.fail(`unexpected ${ZE(this.tok)}`)}};function ZE(e){return e.type===`eof`?`end of program`:e.type===`newline`?`newline`:e.type===`string`?`string "${e.value}"`:e.type===`regex`?`regex /${e.value}/`:`\`${e.value}\``}var QE={__proto__:null,BEGIN:`begin`,END:`end`,BEGINFILE:`beginFile`,ENDFILE:`endFile`};function $E(e){let t=[],n=new XE(dE(e,e=>t.push(e)),t),r={begin:[],end:[],beginFile:[],endFile:[],rules:[],functions:new Map,warnings:t};for(n.skipNewlines();n.tok.type!==`eof`;)n.is(`;`)&&n.fail(`each rule must have a pattern or an action part`),eD(n,r),n.accept(`;`),n.skipNewlines();return r}function eD(e,t){if(e.isKw(`function`)){tD(e,t);return}if(e.tok.type===`keyword`&&e.tok.value in QE){let n=e.next().value;e.is(`{`)||e.fail(`${n} requires an action: ${n} { ... }`),t[QE[n]].push(...nD(e,n.toLowerCase()));return}if(e.is(`{`)){t.rules.push({pattern:null,action:nD(e,`main`)});return}let n=wE(e,{}),r=n;e.accept(`,`)&&(e.skipNewlines(),r={type:`range`,from:n,to:wE(e,{})});let i=e.is(`{`)?nD(e,`main`):null;i===null&&!(e.tok.type===`newline`||e.tok.type===`eof`||e.is(`;`))&&e.unexpected(),t.rules.push({pattern:r,action:i})}function tD(e,t){e.next();let n=e.tok;n.type===`builtin`&&e.fail(`cannot redefine builtin function \`${n.value}\``),n.type!==`name`&&n.type!==`funcname`&&e.fail(`expected a function name but found ${ZE(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect(`(`);let i=[];for(;!e.is(`)`);){let t=e.tok;if(t.type!==`name`&&e.fail(`expected a parameter name but found ${ZE(t)}`),(t.value===r||i.includes(t.value))&&e.fail(`duplicate parameter \`${t.value}\` in function \`${r}\``),i.push(e.next().value),!e.accept(`,`))break;e.skipNewlines()}e.expect(`)`),e.skipNewlines(),t.functions.set(r,{params:i,body:nD(e,`function`)})}function nD(e,t=e.context){let n=e.context;e.context=t,e.expect(`{`);let r=[];for(e.skipTerminators();!e.is(`}`);)e.tok.type===`eof`&&e.fail("missing `}` at end of program"),r.push(aD(e)),e.skipTerminators();return e.next(),e.context=n,r}function rD(e){e.is(`;`)||e.tok.type===`newline`?e.next():e.is(`}`)||e.tok.type===`eof`||e.unexpected()}var iD={__proto__:null,if:cD,while:lD,do:uD,for:dD,switch:fD,break:e=>mD(e,`break`),continue:e=>mD(e,`continue`),next:e=>mD(e,`next`),nextfile:e=>mD(e,`nextfile`),exit:e=>mD(e,`exit`),return:e=>mD(e,`return`),delete:hD,print:e=>_D(e,`print`),printf:e=>_D(e,`printf`)};function aD(e){if(e.is(`{`))return{type:`block`,body:nD(e)};if(e.is(`;`))return e.next(),{type:`empty`};let t=e.tok.type===`keyword`?iD[e.tok.value]:void 0;if(t)return t(e);let n=wE(e,{});return rD(e),{type:`expr`,expr:n}}function oD(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=aD(e);return t&&e.loopDepth--,n}function sD(e){e.next(),e.expect(`(`);let t=wE(e,{});return e.expect(`)`),t}function cD(e){let t=sD(e),n=oD(e,!1),r=e.i;return e.skipNewlines(),e.isKw(`else`)?(e.next(),{type:`if`,test:t,consequent:n,alternate:oD(e,!1)}):(e.i=r,{type:`if`,test:t,consequent:n,alternate:null})}function lD(e){return{type:`while`,test:sD(e),body:oD(e,!0)}}function uD(e){e.next();let t=oD(e,!0);e.skipTerminators(),e.isKw(`while`)||e.fail("`do` body must be followed by `while (...)`");let n=sD(e);return rD(e),{type:`do`,body:t,test:n}}function dD(e){if(e.next(),e.expect(`(`),e.tok.type===`name`&&e.peek(1).type===`keyword`&&e.peek(1).value===`in`&&e.peek(2).type===`name`&&e.peek(3).value===`)`){let t=e.next().value;e.next();let n=e.next().value;return e.next(),{type:`forin`,name:t,array:n,body:oD(e,!0)}}let t=e.is(`;`)?null:wE(e,{});e.expect(`;`),e.skipNewlines();let n=e.is(`;`)?null:wE(e,{});e.expect(`;`),e.skipNewlines();let r=e.is(`)`)?null:wE(e,{});return e.expect(`)`),{type:`for`,init:t,test:n,step:r,body:oD(e,!0)}}function fD(e){let t=sD(e);e.skipNewlines(),e.expect(`{`);let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is(`}`);e.skipTerminators()){let t=null;e.accept(`case`,`keyword`)?t=pD(e):e.accept(`default`,`keyword`)||e.fail(`expected \`case\` or \`default\` in switch body but found ${ZE(e.tok)}`);let i=t===null?`default`:t.type===`regex`?`/${t.source}/`:String(t.value);r.has(i)&&e.fail(`duplicate case values in switch body: ${i}`),r.add(i),e.expect(`:`);let a=[];for(e.skipTerminators();!e.is(`}`)&&!e.isKw(`case`)&&!e.isKw(`default`);)e.tok.type===`eof`&&e.fail("missing `}` at end of program"),a.push(aD(e)),e.skipTerminators();n.push({test:t,body:a})}return e.switchDepth--,e.next(),{type:`switch`,expr:t,cases:n}}function pD(e){let t=e.accept(`-`)?-1:(e.accept(`+`),1),n=e.tok;return n.type===`number`?(e.next(),{type:`num`,value:t*Number(n.value)}):t===1&&n.type===`string`?(e.next(),{type:`str`,value:n.value}):t===1&&n.type===`regex`?(e.next(),{type:`regex`,source:n.value,re:Zp(n.value,!1,t=>e.warn(t))}):e.fail(`case value must be a number, string or regex constant, found ${ZE(n)}`)}function mD(e,t){t===`break`&&e.loopDepth===0&&e.switchDepth===0&&e.fail("`break` is not allowed outside a loop or switch"),t===`continue`&&e.loopDepth===0&&e.fail("`continue` is not allowed outside a loop"),t===`next`&&e.context!==`main`&&e.context!==`function`&&e.fail(`\`next\` cannot be used in a ${e.context.toUpperCase()} action`),t===`nextfile`&&(e.context===`begin`||e.context===`end`||e.context===`endfile`)&&e.fail(`\`nextfile\` cannot be used in a ${e.context.toUpperCase()} action`),t===`return`&&e.context!==`function`&&e.fail("`return` is only allowed inside a function"),e.next();let n={type:t};return(t===`exit`||t===`return`)&&(n.value=SE(e)?wE(e,{}):null),rD(e),n}function hD(e){e.next(),e.tok.type!==`name`&&e.fail(`\`delete\` needs an array name but found ${ZE(e.tok)}`);let t=e.next().value,n=HE(e);return rD(e),{type:`delete`,name:t,subs:n}}var gD=e=>e.is(`;`)||e.is(`}`)||e.is(`>`)||e.is(`>>`)||e.is(`|`)||e.is(`|&`)||e.tok.type===`newline`||e.tok.type===`eof`;function _D(e,t){e.next();let n=null;if(e.is(`(`)){let t=e.i;e.next();let r=e.is(`)`)?[]:CE(e,{});e.accept(`)`)&&gD(e)?n=r:e.i=t}n===null&&(n=gD(e)?[]:CE(e,{noGt:!0})),t===`printf`&&n.length===0&&e.fail(`printf needs a format string`);let r=null;return(e.is(`|`)||e.is(`|&`))&&e.fail(`output pipes (\`${t} ... | "cmd"\`) are not supported: ${Dp}`,`${t} | "cmd"`),(e.accept(`>`)||e.accept(`>>`))&&(r=NE(e,{noGt:!0}),r.type===`str`&&!YE.has(r.value)&&e.fail(vD(r.value),`${t} > FILE`)),rD(e),{type:t,args:n,dest:r}}function vD(e){return`cannot redirect output to \`${e}\`: the filesystem is read-only (only /dev/stdout, /dev/stderr and /dev/null). To print a comparison, parenthesize it: print (a > b)`}var X=class{constructor(e){this.s=e,this.number=void 0,this.numeric=void 0}},yD=`[ \\t\\n\\r\\f\\v]*`,bD=`[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?`,xD=RegExp(`^${yD}${bD}${yD}$`,`u`),SD=RegExp(`^${yD}(${bD})`,`u`),CD=RegExp(`^${yD}([+-])(inf|nan)${yD}$`,`iu`),wD=e=>xD.test(e)||CD.test(e);function TD(e){let t=SD.exec(e);if(t)return Number(t[1]);let n=CD.exec(e);return n?n[2].toLowerCase()===`nan`?NaN:n[1]===`-`?-1/0:1/0:0}var ED=()=>new W(`attempt to use an array in a scalar context`);function Z(e){if(typeof e==`number`)return e;if(e===void 0)return 0;if(e instanceof X)return e.number??=TD(e.s);if(typeof e==`string`)return TD(e);throw ED()}var DD=new Map;function OD(e,t){if(Number.isNaN(e))throw new W(`formatting signed NaN is not supported`,null,`signed NaN`);if(!Number.isFinite(e))return e<0?`-inf`:`+inf`;if(Number.isInteger(e))return Math.abs(e)<2**53?String(e):BigInt(e).toString();let n=DD.get(t);if(n===void 0){DD.size>64&&DD.clear(),n=cx(t);let e=n.filter(e=>typeof e!=`string`);if(e.length>1||e.some(e=>!`diouxXeEfFgG`.includes(e.conv)||e.width===`*`||e.precision===`*`))throw new W(`this numeric conversion format is not supported`,null,`numeric conversion format`);DD.set(t,n)}return n.map(t=>typeof t==`string`?t:fx(e,t)).join(``)}var kD=e=>typeof e==`string`?e:e instanceof X?e.s:`%.6g`,AD=e=>kD(e.globals.get(`CONVFMT`)),jD=e=>kD(e.globals.get(`OFMT`));function Q(e,t){if(typeof e==`string`)return MD(t,e);if(e instanceof X)return MD(t,e.s);if(typeof e==`number`)return OD(e,AD(t));if(e===void 0)return``;throw ED()}function MD(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new W(`non-ASCII AWK text in a byte locale is not supported`,null,`byte locale text`);return t}function ND(e,t=!1){return[...e].map(e=>{let n=t?e.toUpperCase():e.toLowerCase();if([...n].length!==1)throw new W(`Unicode case expansion is not supported`,null,`Unicode case mapping`);return n}).join(``)}function PD(e,t){return typeof e==`number`?OD(e,jD(t)):Q(e,t)}var FD=e=>e.numeric??=wD(e.s),ID=e=>typeof e==`number`||e===void 0||e instanceof X&&FD(e),LD=e=>zD(e.globals.get(`IGNORECASE`));function RD(e,t,n){if(ID(e)&&ID(t)){let n=Z(e),r=Z(t);return n<r?-1:n>r?1:n===r?0:NaN}let r=Q(e,n),i=Q(t,n);return LD(n)&&(r=ND(r),i=ND(i)),N(r,i)}function zD(e){if(typeof e==`number`)return e!==0&&!Number.isNaN(e);if(typeof e==`string`)return e!==``;if(e instanceof X)return FD(e)?Z(e)!==0:e.s!==``;if(e===void 0)return!1;throw ED()}var BD=(e,t)=>Number.isSafeInteger(e)?String(e):Q(e,t);function VD(e){return e instanceof Map?`array`:e===void 0?`untyped`:typeof e==`number`?`number`:e instanceof X&&FD(e)?`strnum`:`string`}function HD(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t===``)return UD(e);let i,a;if(t.length===1){let n=r.indexOf(t,e.pos);a=n===-1?r.length:n,i=n===-1?r.length:n+1}else{let o=Qp(r,Zp(t,n),e.pos);a=o?.start??r.length,i=o?.end??r.length}let o=r.slice(e.pos,a);return e.pos=i,{rec:o,rt:r.slice(a,i)}}function UD(e){let{text:t}=e,n=e.pos;for(;t[n]===`
333
+ `;)n++;if(n>=t.length)return e.pos=n,null;let r=/\n\n+/gu;r.lastIndex=n;let i=r.exec(t);if(!i){e.pos=t.length;let r=t.slice(n).replace(/\n+$/u,``);return{rec:r,rt:t.slice(n+r.length)}}return e.pos=i.index+i[0].length,{rec:t.slice(n,i.index),rt:i[0]}}function WD(e,t,n,r){if(e===``)return[];if(t instanceof Yp)return $p(e,t);if(t===` `){let t=e.replace(/^[ \t\n]+|[ \t\n]+$/gu,``);return t===``?[]:t.split(/[ \t\n]+/u)}if(t===``)return[...e];if(t.length===1&&(!n||t===`
334
+ `))return e.split(t);if(n&&t===`^`)throw new W(`paragraph splitting with FS="^" is not supported`,null,`paragraph FS caret`);return $p(e,Zp(t.length===1?`[${`^$.[]|()*+?{}\\`.includes(t)?`\\`+t:t}
335
+ ]`:t,r))}function GD(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let i=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),a=i?.[1]===void 0?0:Number(i[1]),o=i?.[2]===`*`?0xffffffff:Number(i?.[2]);if(!i||i[1]!==void 0&&a===0||a>0xffffffff||!(o>0&&o<=0xffffffff)||i[2]===`*`&&r!==t.length-1)throw new W(`invalid FIELDWIDTHS value \`${e}'`);return{skip:a,width:o}})}function KD(e,t){let n=[...e],r=[],i=0;for(let{skip:e,width:a}of t){if(i>=n.length)break;i+=e,r.push(n.slice(i,i+a).join(``)),i+=a}return r}function qD(e,t){let n=[],r=0;for(;r<e.length;){let i=t.search(e.slice(r));if(n.length>0&&i?.end===0&&(r+=ri(e,r),i=t.search(e.slice(r))),!i)break;n.push(e.slice(r+i.start,r+i.end)),r+=i.end}return n}function JD(e,t){let n=LD(e);return e.fieldMode===`FIELDWIDTHS`?KD(t,e.widths):e.fieldMode===`FPAT`?qD(t,Zp(Q(e.globals.get(`FPAT`),e),n,e.warn)):WD(t,Q(e.globals.get(`FS`),e),Q(e.globals.get(`RS`),e)===``,n)}var YD=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,XD=e=>e!==void 0&&e.type===`exit`,ZD=class{constructor(e,t){this.ctx=e,this.stdin=t,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(e){for(;this.exitSignal===void 0;)if(this.src){let t=HD(this.src,Q(e.globals.get(`RS`),e),LD(e));if(t!==null)return e.globals.set(`NR`,Z(e.globals.get(`NR`))+1),e.globals.set(`FNR`,Z(e.globals.get(`FNR`))+1),e.globals.set(`RT`,t.rt),t.rec;this.closeFile(e)}else if(!this.open(e))return null;return null}open(e){for(;this.idx<Math.trunc(Z(e.globals.get(`ARGC`)));){if(++e.steps>wp)throw new W(`input operand scan exceeded execution limit`,null,`execution limit`);let t=Q(e.globals.get(`ARGV`).get(String(this.idx++)),e);if(t===``)continue;e.globals.set(`ARGIND`,this.idx-1);let n=YD.exec(t);if(n){e.assign(n[1],new X(_E(n[2],e.warn)));continue}this.sawFile=!0;let{text:r,error:i}=this.readOperand(t);if(i===`Is a directory`)this.failFile(e,t,i),this.exitSignal===void 0&&e.warn(`command line argument \`${t}' is a directory: skipped`);else{if(i){let n=this.failFile(e,t,i);if(n!==void 0&&n.type===`nextfile`)continue;if(this.exitSignal!==void 0)return!1;throw new W(`${t}: ${i}`)}if(this.use(e,t,r))return!0}}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(e,`-`,this.takeStdin()))}readOperand(e){if(e===`/dev/null`)return{text:``};if(e===`-`||e===`/dev/stdin`)return{text:e===`/dev/stdin`&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:t,error:n}=F(this.ctx,`awk`,e);return this.ctx.fs.isDir(t)?{error:`Is a directory`}:n?{error:n}:{text:this.ctx.fs.readFile(t)}}takeStdin(){let e=this.stdin;return this.stdin=``,L(this.ctx),e}use(e,t,n){this.src={text:n,pos:0},e.globals.set(`FILENAME`,t),e.globals.set(`FNR`,0),e.globals.set(`ERRNO`,``);let r=e.fileRule(`begin`);return XD(r)?(this.exitSignal=r,this.src=null,!1):r!==void 0&&r.type===`nextfile`?(this.closeFile(e),!1):(MD(e,n),!0)}failFile(e,t,n){if(e.globals.set(`ERRNO`,n),!e.hasFileRules)return;e.globals.set(`FILENAME`,t),e.globals.set(`FNR`,0);let r=e.fileRule(`begin`);return XD(r)&&(this.exitSignal=r),r}closeFile(e){this.src=null;let t=e.fileRule(`end`);XD(t)&&(this.exitSignal=t)}readNamed(e,t){let n=this.readers.get(t);if(!n){let{text:r,error:i}=this.readOperand(t);if(i)return e.globals.set(`ERRNO`,i),{status:-1};n={text:MD(e,r),pos:0},this.readers.set(t,n)}let r=HD(n,Q(e.globals.get(`RS`),e),LD(e));return r===null?{status:0}:(e.globals.set(`RT`,r.rt),{status:1,record:r.rec})}close(e,t){return this.readers.delete(t)?0:(e.globals.set(`ERRNO`,`close of redirection that was never opened`),-1)}},QD=(e,t)=>({isRef:!0,scope:e,name:t}),$D=e=>typeof e==`object`&&!!e&&e.isRef===!0,eO=class extends Error{constructor(e){super(e.type),this.signal=e}},tO=e=>new W(`attempt to use array \`${e}\` in a scalar context`);function nO(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function rO(e){let t=e;for(;$D(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function iO(e,t){let n=nO(e,t).get(t);return $D(n)?rO(n):n}var aO=new Set([`FS`,`FIELDWIDTHS`,`FPAT`]);function oO(e,t,n){let r=nO(e,t);if(r.get(t)instanceof Map)throw tO(t);if(r===e.globals){if(t===`NF`){fO(e,n);return}if(t===`FIELDWIDTHS`&&(e.widths=GD(Q(n,e))),(t===`FPAT`||(t===`FS`||t===`RS`)&&Q(n,e).length>1)&&Zp(Q(n,e),LD(e),e.warn,e.tables),aO.has(t)){e.fieldMode=t;let n=e.globals.get(`PROCINFO`);n instanceof Map&&n.set(`FS`,t)}}r.set(t,n)}function sO(e,t){let n=nO(e,t),r=t,i=n,a=i.get(r);if(a instanceof Map)return a;let o=$D(a);for(;$D(a);)i=a.scope,r=a.name,a=i.get(r);if(!(a instanceof Map)){if(a!==void 0)throw new W(`attempt to use scalar \`${r}\` as an array`);a=new Map,i.set(r,a)}return o&&n.set(t,a),a}function cO(e,t,n=new X(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...JD(e,t).map(e=>new X(e))],e.nf=e.fields.length-1,e.globals.set(`NF`,e.nf)}function lO(e){let t=Q(e.globals.get(`OFS`),e);e.record=e.fields.slice(1).map(t=>Q(t,e)).join(t),e.recordValue=e.record}function uO(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function dO(e,t,n){if(t===0){let t=Q(n,e);cO(e,t,typeof n==`number`?t:n)}else{for(;e.nf<t;)e.fields[++e.nf]=``;e.fields[t]=n,e.globals.set(`NF`,e.nf),lO(e)}}function fO(e,t){let n=Math.trunc(Z(t));if(n<0)throw new W(`NF set to negative value ${n}`);for(;e.nf<n;)e.fields[++e.nf]=``;e.fields.length=n+1,e.nf=n,e.globals.set(`NF`,n),lO(e)}function pO(e,t){let n=Z($(e,t));if(!(n>=0))throw new W(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function mO(e,t){if(t.length===1)return BD($(e,t[0]),e);let n=Q(e.globals.get(`SUBSEP`),e);return t.map(t=>BD($(e,t),e)).join(n)}function hO(e,t){return t.type===`var`?t:t.type===`index`?{type:`index`,arr:sO(e,t.name),key:mO(e,t.subs)}:{type:`field`,i:pO(e,t.index)}}function gO(e,t){return t.type===`var`?SO(iO(e,t.name),t.name):t.type===`index`?t.arr.get(t.key):uO(e,t.i)}function _O(e,t,n){t.type===`var`?oO(e,t.name,n):t.type===`index`?t.arr.set(t.key,n):dO(e,t.i,n)}function vO(e,t,n){_O(e,hO(e,t),n)}function yO(e,t,n){if(n===0&&(e===`/`||e===`%`))throw new W(e===`/`?`division by zero attempted`:"division by zero attempted in `%`");return Op(e,t,n)}var bO={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function xO(e,t){let n=LD(e);return t.type===`regex`?n?Zp(t.source,!0,null,e.tables):t.re:Zp(Q($(e,t),e),n,e.warn,e.tables)}function SO(e,t){if(e instanceof Map)throw tO(t);return e}function CO(e,t,n){let r=hO(e,t.target),i=Z(gO(e,r)),a=t.op===`++`?i+1:i-1;return _O(e,r,a),n?i:a}function $(e,t){switch(t.type){case`num`:case`str`:return t.value;case`regex`:return+!!xO(e,t).test(e.record);case`var`:return SO(iO(e,t.name),t.name);case`index`:{let n=sO(e,t.name),r=mO(e,t.subs),i=n.get(r);return i===void 0&&n.set(r,void 0),i}case`field`:return uO(e,pO(e,t.index));case`assign`:{let n=hO(e,t.target),r=$(e,t.value);if(r instanceof Map)throw new W(`attempt to use an array in a scalar context`);return t.op!==`=`&&(r=yO(t.op[0],Z(gO(e,n)),Z(r))),_O(e,n,r),r}case`cond`:return $(e,zD($(e,t.test))?t.consequent:t.alternate);case`or`:return zD($(e,t.left))||zD($(e,t.right))?1:0;case`and`:return zD($(e,t.left))&&zD($(e,t.right))?1:0;case`not`:return+!zD($(e,t.expr));case`neg`:return-Z($(e,t.expr));case`plus`:return Z($(e,t.expr));case`binary`:return yO(t.op,Z($(e,t.left)),Z($(e,t.right)));case`concat`:return Q($(e,t.left),e)+Q($(e,t.right),e);case`compare`:return+!!bO[t.op](RD($(e,t.left),$(e,t.right),e));case`match`:{let n=Q($(e,t.left),e);return xO(e,t.right).test(n)===t.negate?0:1}case`in`:return+!!sO(e,t.array).has(mO(e,t.keys));case`preinc`:return CO(e,t,!1);case`postinc`:return CO(e,t,!0);case`call`:return wO(e,t);case`builtin`:return e.callBuiltin(e,t);case`getline`:return EO(e,t);default:throw new W(`unknown expression: ${t.type}`)}}function wO(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new W(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new W(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=Tp)throw new W(`function call nesting deeper than ${Tp} levels (runaway recursion?)`,null,`call depth limit`);let r=e.frame,i=new Map;for(let r=0;r<n.params.length;r++)i.set(n.params[r],r<t.args.length?TO(e,t.args[r]):void 0);e.frame=i,e.callDepth++;try{let t=e.execStmts(e,n.body);if(t===void 0||t.type===`return`)return t?.value;throw new eO(t)}finally{e.frame=r,e.callDepth--}}function TO(e,t){if(t.type!==`var`)return $(e,t);let n=nO(e,t.name),r=n.get(t.name);return r instanceof Map||$D(r)?r:r===void 0?QD(n,t.name):r}function EO(e,t){let n;if(t.file===null){if(n=e.input.next(e),n===null)return 0}else{let r=e.input.readNamed(e,Q($(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?cO(e,n):vO(e,t.target,new X(n)),1}var DO=(e,t)=>Z($(e,t)),OO=2**32;function kO(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var AO=()=>({seed:1,state:kO(1)});function jO(e){e.rng.state=(e.rng.state+0x6d2b79f5)%OO;let t=e.rng.state;t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61);let n=t^t>>>14;return(n<0?n+OO:n)/OO}function MO(e,t){let n=e.rng.seed,r=t.length>0?DO(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=kO(r),n}function NO(e,t){let n=DO(e,t[0]);return n<0&&e.warn(`log: received negative argument ${Q(n,e)}`),Math.log(n)}function PO(e,t){let n=DO(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${Q(n,e)}`),Math.sqrt(n)}function FO(e,t){let n=DO(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${Q(n,e)} is out of range`),r}function IO(e,t){let n=$(e,t[0]);if(typeof n==`number`)return n;let r=n instanceof X?n.s:Q(n,e),i=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(i)return i[1]===``?0:Number.parseInt(i[1],16);let a=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return a?Number.parseInt(a[0],8):Z(new X(r))}function LO(e,t,n,r){let i=DO(e,n);if(i<0)throw new W(`${t}: argument ${r} negative value ${Q(i,e)} is not allowed`);if(!Number.isFinite(i))throw new W(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(i)))}function RO(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function zO(e,t){return(n,r)=>{if(r.length<2)throw new W(`${e}: called with less than two arguments`);let i=LO(n,e,r[0],1);for(let a=1;a<r.length;a++)i=t(i,LO(n,e,r[a],a+1));return RO(i)}}function BO(e,t){return(n,r)=>{let i=LO(n,e,r[0],1),a=LO(n,e,r[1],2)%64n;return RO(BigInt.asUintN(64,t?i<<a:i>>a))}}var VO={__proto__:null,sin:(e,t)=>Math.sin(DO(e,t[0])),cos:(e,t)=>Math.cos(DO(e,t[0])),atan2:(e,t)=>Math.atan2(DO(e,t[0]),DO(e,t[1])),exp:FO,log:NO,sqrt:PO,int:(e,t)=>Math.trunc(DO(e,t[0])),rand:jO,srand:MO,systime:()=>Math.floor(Date.now()/1e3),strtonum:IO,and:zO(`and`,(e,t)=>e&t),or:zO(`or`,(e,t)=>e|t),xor:zO(`xor`,(e,t)=>e^t),lshift:BO(`lshift`,!0),rshift:BO(`rshift`,!1),compl:(e,t)=>RO(BigInt.asUintN(64,~LO(e,`compl`,t[0],1)))},HO=new Map;function UO(e){let t=HO.get(e);return t||(HO.size>=256&&HO.clear(),t=cx(e),HO.set(e,t)),t}function WO(e,t,n){let r=0,i=()=>{if(r>=n.length)throw new W(`printf: not enough arguments to satisfy format string`);return n[r++]},a=``;for(let n of UO(t)){if(typeof n==`string`){a+=n;continue}let t={...n};if(n.width===`*`){let e=Math.trunc(Z(i()));e<0?(t.minus=!0,t.width=-e):t.width=e}if(n.precision===`*`){let e=Math.trunc(Z(i()));t.precision=e<0?null:e}if(t.width>Ep||t.precision>Ep)throw new W(`printf: field width or precision above ${Ep} is not supported`,null,`format size limit`);a+=GO(e,t,i())}return a}function GO(e,t,n){if(t.conv===`s`){let r=Q(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join(``)),lx(``,r,t,!1)}return t.conv===`c`?lx(``,MD(e,KO(n)),t,!1):fx(Z(n),t)}function KO(e){if(typeof e==`number`||e instanceof X&&wD(e.s)){let t=Math.trunc(Z(e));if(!ti(t))throw new W(`printf: character code outside Unicode scalar values is not supported`,null,`character code`);return String.fromCodePoint(t)}let t=e instanceof X?e.s:e??``;return t===``?`\0`:String.fromCodePoint(t.codePointAt(0))}var qO=(e,t)=>Q($(e,t),e),JO=(e,t)=>Z($(e,t)),YO={type:`field`,index:{type:`num`,value:0}};function XO(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`){if(e[r+1]===`\\`&&e[r+2]===`\\`&&(e[r+3]===`&`||e[r+3]===`\\`)){n+=`\\`+e[r+3],r+=3;continue}if(e[r+1]===`\\`&&e[r+2]===`&`){n+=`\\`+t,r+=2;continue}if(e[r+1]===`&`){n+=`&`,r++;continue}}n+=i===`&`?t:i}return n}function ZO(e,t,n){let r=xO(e,t[0]),i=qO(e,t[1]),a=t[2]??YO,o=qO(e,a),{out:s,count:c}=em(o,r,(e,t)=>XO(i,o.slice(e,t)),n?`global`:`first`);return c>0&&vO(e,a,s),c}function QO(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`\\`&&r+1===e.length)throw new W(`gensub with a trailing replacement backslash is not supported`,null,`gensub trailing backslash`);if(i===`\\`&&r+1<e.length){let i=e[++r];n+=i>=`0`&&i<=`9`?t[Number(i)]?.text??``:i}else n+=i===`&`?t[0].text:i}return n}function $O(e,t){let n=xO(e,t[0]),r=qO(e,t[1]),i=$(e,t[2]),a=Q(i,e),o=a.startsWith(`g`)||a.startsWith(`G`),s=0;o||(s=Math.trunc(Z(i)),s<1&&(e.warn(`gensub: third argument \`${a}' treated as 1`),s=1));let c=t[3]?qO(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return em(c,n,(e,t,i)=>!o&&i!==s?null:QO(r,l?n.groups(c,e,t):[{text:c.slice(e,t)}]),o?`global`:`nth`).out}function ek(e,t){let n=qO(e,t[0]),r=xO(e,t[1]),i=r.search(n,0),a=i?Array.from(n.slice(0,i.start)).length+1:0;if(e.globals.set(`RSTART`,a),e.globals.set(`RLENGTH`,i?Array.from(n.slice(i.start,i.end)).length:-1),t[2]){let a=sO(e,t[2].name);if(a.clear(),i){let t=Q(e.globals.get(`SUBSEP`),e);r.groups(n,i.start,i.end).forEach((e,r)=>{e!==void 0&&(a.set(String(r),new X(e.text)),a.set(`${r}${t}start`,Array.from(n.slice(0,e.start)).length+1),a.set(`${r}${t}length`,[...e.text].length))})}}return a}function tk(e,t){let n=qO(e,t[0]),r=sO(e,t[1].name),i;i=t[2]===void 0?Q(e.globals.get(`FS`),e):t[2].type===`regex`?xO(e,t[2]):qO(e,t[2]);let a=WD(n,i,!1,LD(e));return r.clear(),a.forEach((e,t)=>r.set(String(t+1),new X(e))),a.length}function nk(e,t){let n=[...qO(e,t[0])],r=Math.trunc(JO(e,t[1])),i=Number.isNaN(r)?1:Math.max(r,1),a=n.length+1;if(t[2]){let n=Math.trunc(JO(e,t[2]));if(!(n>=1))return``;a=Math.min(a,i+n)}return a>i?n.slice(i-1,a-1).join(``):``}function rk(e,t){if(t.length===0)return[...e.record].length;if(t[0].type===`var`){let n=iO(e,t[0].name);return n instanceof Map?n.size:[...Q(n,e)].length}return[...qO(e,t[0])].length}function ik(e,t){let n=qO(e,t[0]),r=qO(e,t[1]);LD(e)&&(n=ND(n),r=ND(r));let i=n.indexOf(r);return i<0?0:Array.from(n.slice(0,i)).length+1}function ak(e,t){let n=qO(e,t[0]);return n===`/dev/stdout`||n===`/dev/stderr`||n===`/dev/null`?0:e.input.close(e,n)}var ok=(e,t)=>t[0].type===`var`?VD(iO(e,t[0].name)):VD($(e,t[0])),sk={__proto__:null,...VO,length:rk,substr:nk,index:ik,split:tk,sub:(e,t)=>ZO(e,t,!1),gsub:(e,t)=>ZO(e,t,!0),gensub:$O,match:ek,sprintf:(e,t)=>WO(e,qO(e,t[0]),t.slice(1).map(t=>$(e,t))),tolower:(e,t)=>ND(qO(e,t[0])),toupper:(e,t)=>ND(qO(e,t[0]),!0),close:ak,fflush:()=>0,typeof:ok,isarray:(e,t)=>+(t[0].type===`var`&&iO(e,t[0].name)instanceof Map)};function ck(e,t){let n=sk[t.name];if(!n)throw new W(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var lk={type:`break`},uk={type:`continue`},dk={type:`next`},fk={type:`nextfile`},pk={type:`exit`};function mk(e,t,n,r){let i=new Map([[`0`,`awk`]]);r.forEach((e,t)=>i.set(String(t+1),new X(e)));let a={program:e,globals:new Map([[`FS`,` `],[`OFS`,` `],[`ORS`,`
336
+ `],[`RS`,`
337
+ `],[`RT`,``],[`NR`,0],[`NF`,0],[`FNR`,0],[`FILENAME`,``],[`SUBSEP`,`\x1C`],[`CONVFMT`,`%.6g`],[`OFMT`,`%.6g`],[`RSTART`,0],[`RLENGTH`,-1],[`ERRNO`,``],[`IGNORECASE`,0],[`FIELDWIDTHS`,``],[`FPAT`,`[^[:space:]]+`],[`ENVIRON`,new hk(`ENVIRON`)],[`PROCINFO`,new hk(`PROCINFO`,[[`FS`,`FS`]])],[`ARGC`,r.length+1],[`ARGV`,i],[`ARGIND`,0]]),frame:void 0,callDepth:0,record:``,recordValue:new X(``),fields:[void 0],nf:0,fieldMode:`FS`,out:[],errOut:[],steps:0,exitCode:0,ranges:[],rng:AO(),input:new ZD(t,n),byteLocale:bn(t),tables:Ln(t.locale),hasFileRules:e.beginFile.length>0,callBuiltin:ck,execStmts:wk,assign:(e,t)=>oO(a,e,t),warn:e=>a.errOut.push(`awk: warning: ${e}
338
+ `),fileRule:e=>yk(a,e)};return a}var hk=class extends Map{constructor(e,t=[]){super(t),this.systemName=e}check(e){if(!this.systemName||this.systemName===`PROCINFO`&&e===`FS`)return;let t=this.systemName===`ENVIRON`?`ENVIRON`:`PROCINFO[${e??`*`}]`;throw new W(`${t} is not supported without the corresponding environment or process metadata`,null,t)}get(e){return this.check(e),super.get(e)}has(e){return this.check(e),super.has(e)}set(e,t){return this.check(e),super.set(e,t)}delete(e){return this.check(e),super.delete(e)}clear(){return this.check(),super.clear()}get size(){return this.check(),super.size}keys(){return this.check(),super.keys()}values(){return this.check(),super.values()}entries(){return this.check(),super.entries()}[Symbol.iterator](){return this.check(),super[Symbol.iterator]()}};function gk(e){let{program:t}=e,n=vk(e,t.begin,`BEGIN`),r=t.rules.length>0||t.end.length>0||t.beginFile.length>0||t.endFile.length>0;return!_k(n)&&r&&bk(e),vk(e,t.end,`END`),e.exitCode}var _k=e=>e!==void 0&&e.type===`exit`;function vk(e,t,n){let r=Sk(e,t);if(r!==void 0&&(r.type===`next`||r.type===`nextfile`&&(n===`BEGIN`||n===`END`)))throw new W(`\`${r.type}' cannot be called from a ${n} rule`);return r}function yk(e,t){let n=t===`begin`?e.program.beginFile:e.program.endFile;return n.length===0?void 0:vk(e,n,t===`begin`?`BEGINFILE`:`ENDFILE`)}function bk(e){for(;;){let t=e.input.next(e);if(t===null)return e.input.exitSignal;cO(e,t);let n=xk(e);if(_k(n))return n;n!==void 0&&n.type===`nextfile`&&e.input.closeFile(e)}}function xk(e){let{rules:t}=e.program;for(let n=0;n<t.length;n++){let r=t[n];if(!Ck(e,r,n))continue;if(r.action===null){kk(e,null,e.record+Q(e.globals.get(`ORS`),e));continue}let i=Sk(e,r.action);if(i!==void 0)return i}}function Sk(e,t){try{return wk(e,t)}catch(e){if(!(e instanceof eO))throw e;return e.signal}}function Ck(e,t,n){let{pattern:r}=t;if(r===null)return!0;if(r.type!==`range`)return zD($(e,r));if(!e.ranges[n]){if(!zD($(e,r.from)))return!1;e.ranges[n]=!0}return zD($(e,r.to))&&(e.ranges[n]=!1),!0}function wk(e,t){for(let n of t){let t=Tk(e,n);if(t!==void 0)return t}}function Tk(e,t){if(++e.steps>wp)throw new W(`execution stopped after ${wp} statements (infinite loop?)`,null,`execution limit`);switch(t.type){case`block`:return wk(e,t.body);case`empty`:return;case`expr`:$(e,t.expr);return;case`print`:return Ak(e,t);case`printf`:return jk(e,t);case`if`:return zD($(e,t.test))?Tk(e,t.consequent):t.alternate===null?void 0:Tk(e,t.alternate);case`while`:case`do`:case`for`:return Ek(e,t);case`forin`:return Dk(e,t);case`switch`:return Ok(e,t);case`break`:return lk;case`continue`:return uk;case`next`:return dk;case`nextfile`:return fk;case`exit`:return Mk(e,t);case`return`:return{type:`return`,value:t.value===null?void 0:$(e,t.value)};case`delete`:{let n=sO(e,t.name);t.subs===null?n.clear():n.delete(mO(e,t.subs));return}default:throw new W(`unknown statement: ${t.type}`)}}function Ek(e,t){t.init&&$(e,t.init);let n=!0;for(;t.type===`do`&&n||t.test===null||zD($(e,t.test));){n=!1;let r=Tk(e,t.body);if(r===lk)return;if(r!==void 0&&r!==uk)return r;t.step&&$(e,t.step)}}function Dk(e,t){let n=sO(e,t.array);for(let r of Array.from(n.keys())){oO(e,t.name,new X(r));let n=Tk(e,t.body);if(n===lk)return;if(n!==void 0&&n!==uk)return n}}function Ok(e,t){let n=$(e,t.expr),r=t=>t.test.type===`regex`?xO(e,t.test).test(Q(n,e)):RD(n,t.test.value,e)===0,i=t.cases.findIndex(e=>e.test!==null&&r(e));if(i===-1&&(i=t.cases.findIndex(e=>e.test===null)),i!==-1)for(let n=i;n<t.cases.length;n++){let r=wk(e,t.cases[n].body);if(r===lk)return;if(r!==void 0)return r}}function kk(e,t,n){if(t===null){e.out.push(n);return}let r=Q($(e,t),e);if(r===`/dev/stdout`)e.out.push(n);else if(r===`/dev/stderr`)e.errOut.push(n);else if(r!==`/dev/null`)throw new W(vD(r),null,`output redirection`)}function Ak(e,t){let n=Q(e.globals.get(`ORS`),e),r;if(t.args.length===0)r=e.record;else{let n=Q(e.globals.get(`OFS`),e);r=t.args.map(t=>PD($(e,t),e)).join(n)}kk(e,t.dest,r+n)}function jk(e,t){let n=t.args.map(t=>$(e,t));kk(e,t.dest,WO(e,Q(n[0],e),n.slice(1)))}function Mk(e,t){return t.value!==null&&(e.exitCode=(Math.trunc(Z($(e,t.value)))%256+256)%256),pk}var Nk=`awk [-F fs] [-v var=value] 'program' [file ...] | awk [-F fs] [-v var=value] -f progfile [file ...]`,Pk=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u;function Fk(e,t,n){let{values:r,positional:i}=U(Lk(t),{valueShort:[`F`],repeatable:[`v`,`f`],stopAtFirstPositional:!0}),a=Rk(r.get(`f`)??[],i,n);if(a.error)return a.error;let o;try{MD({byteLocale:bn(n)},a.text),o=$E(a.text)}catch(e){if(e instanceof RangeError)return T(`feature`,`awk`,`parser depth limit`,`awk: program too deeply nested (${e.message})`);if(w(e))return dt(e,`awk`,`awk: ${e.message}`);if(!(e instanceof W))throw e;let t=e.line===null?`awk: ${e.message}`:`awk: ${e.kind} at line ${e.line}: ${e.message}`;return e.gap===null?C(t):T(`feature`,`awk`,e.gap,t)}let s=mk(o,n,e,a.operands);for(let e of o.warnings)s.warn(e);let c,l=null;try{r.has(`F`)&&s.assign(`FS`,_E(r.get(`F`),s.warn));for(let e of r.get(`v`)??[]){let t=Pk.exec(e);if(!t)return C(`awk: -v: expected var=value but got \`${e}\``);s.assign(t[1],new X(_E(t[2],s.warn)))}c=gk(s)}catch(e){let t=w(e);if(!(e instanceof W)&&!(e instanceof RangeError)&&!t)throw e;s.errOut.push(`awk: ${e.message}
339
+ `),c=2,e instanceof RangeError&&(l={detail:`runtime limit`,message:`awk: ${e.message}`}),e.gap&&(l={detail:e.gap,message:`awk: ${e.message}`}),t&&(l={detail:t.detail,message:`awk: ${e.message}`})}let u={stdout:s.out.join(``),stderr:s.errOut.join(``),exitCode:c};return l===null?u:E(u,`feature`,`awk`,l.detail,l.message)}var Ik=/^-[Fvf]\S*\s/su;function Lk(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r===`-F`||r===`-v`||r===`-f`)t.push(r),n+1<e.length&&t.push(e[++n]);else if(Ik.test(r))t.push(r.slice(0,2),r.slice(2));else{if(!r.startsWith(`-`)||r===`-`||r===`--`){t.push(...e.slice(n));break}t.push(r)}}return t}function Rk(e,t,n){if(e.length===0)return t.length===0?{error:lt(Nk,2)}:{text:t[0],operands:t.slice(1)};let r=[];for(let t of e){let{path:e,error:i}=F(n,`awk`,t);if(i||!n.fs.isFile(e))return{error:C(`awk: cannot open program file \`${t}\`: ${i??`Is a directory`}`,2)};r.push(n.fs.readFile(e))}return{text:r.join(`
340
+ `),operands:t}}function zk(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`n`,`r`,`u`,`f`,`b`,`z`],valueShort:[`t`,`o`],valueLong:[`output`],repeatable:[`k`,`o`,`output`]}),o=[...i.get(`o`)??[],...i.get(`output`)??[]];if(o.length>1)return C(`sort: multiple output files specified`,2);let s=i.get(`t`);if(s!==void 0&&b(s).length!==1)return C(`sort: multi-character tab '${s}'`,2);let c={n:r.has(`n`),f:r.has(`f`),b:r.has(`b`),r:r.has(`r`)},l=qk(i.get(`k`)??[],c);if(l.error)return l.error;let u=sr(`sort`,a,e,n,{stopOnError:!0});if(u.failed)return{stdout:``,stderr:u.stderr,exitCode:2};let d=r.has(`z`)?`\0`:`
341
+ `,f=Qn(Zk(u.inputs.flatMap(({content:e})=>Xn(e,d)),l.specs.length?l.specs:[{start:1,...c}],s,r.has(`u`),c.r),d);return o.length===0?R(f,u):Bk(o[0],f,n,u)}function Bk(e,t,n,r){if(e===`/dev/null`)return R(``,r);if(e===`/dev/stdout`)return R(t,r);n.io?.setReads([]);let i;try{i=n.writable&&n.fs.openWritable(n.cwd,e),i&&i.write(t)}catch(e){return I(n,`sort`,e?.path,e?.fsError),dt(e,`sort`,`sort: open failed: ${e.message}`,2)}return i?R(``,r):T(`feature`,`sort`,`-o`,`sort: open failed: ${e}: Read-only file system`,2)}var Vk=`nrfb`,Hk=`bdfghiMnRrV`,Uk=/^[ \t]*\+?(\d+)/u,Wk=(e,t)=>C(`sort: ${e}: invalid count at start of '${t}'`,2),Gk=(e,t)=>C(`sort: ${e}: invalid field specification '${t}'`,2);function Kk(e){let t=0,n=null,r=r=>{let i=Uk.exec(e.slice(t));return i===null?(n=Wk(r,e.slice(t)),null):(t+=i[0].length,Number(i[1]))},i=n=>{let i=r(n);if(i===null)return null;let a=null;if(e[t]===`.`&&(t++,a=r(`invalid number after '.'`),a===null))return null;let o=t;for(;t<e.length&&/[a-zA-Z]/u.test(e[t]);)t++;return{field:i,offset:a,mods:e.slice(o,t)}},a=i(`invalid number at field start`);if(a===null)return{error:n};let o=null;return e[t]===`,`&&(t++,o=i(`invalid number after ','`),o===null)?{error:n}:a.field===0||o?.field===0?{error:Gk(`field number is zero`,e)}:a.offset===0?{error:Gk(`character offset is zero`,e)}:t===e.length?{from:a,to:o}:{error:Gk(`stray character in field spec`,e)}}function qk(e,t){let n=[];for(let r of e){let e=Kk(r);if(e.error)return{error:e.error};let{from:i,to:a}=e,o=i.mods+(a?.mods??``);for(let e of o)if(!Vk.includes(e))return Hk.includes(e)?{error:T(`option`,`sort`,`-k${r}`,`sort: unknown key option \`${e}\` in ${r}`,2)}:{error:Gk(`stray character in field spec`,r)};if(i.offset!==null||(a?.offset??0)!==0)return{error:T(`option`,`sort`,`-k${r}`,`sort: invalid key specification: ${r} (character offsets are not supported)`,2)};let s=o.length>0;n.push({start:i.field,end:a?.field,n:s?o.includes(`n`):t.n,r:s?o.includes(`r`):t.r,f:s?o.includes(`f`):t.f,b:s?i.mods.includes(`b`):t.b})}return{specs:n}}function Jk(e,t){let n=[];if(t!==void 0){let r=0;for(;;){let i=e.indexOf(t,r);if(i===-1){n.push([r,e.length]);break}n.push([r,i]),r=i+t.length}return n}let r=0;do{let t=r;for(;r<e.length&&/[ \t]/u.test(e[r]);)r++;for(;r<e.length&&!/[ \t]/u.test(e[r]);)r++;n.push([t,r])}while(r<e.length);return n}function Yk(e,t,n){if(t.start>n.length)return``;let r=n[t.start-1][0],i=t.end===void 0||t.end>n.length?e.length:n[t.end-1][1];if(t.b)for(;r<i&&/[ \t]/u.test(e[r]);)r++;return e.slice(r,Math.max(r,i))}var Xk=e=>e.replace(/[a-z]/gu,e=>e.toUpperCase());function Zk(e,t,n,r,i){let a=t.every(e=>e.start===1&&e.end===void 0);if(a&&t.length===1&&!t[0].n&&!t[0].f&&!t[0].b)return e.sort(e.some(e=>/[\u{10000}-\u{10FFFF}]/u.test(e))?N:void 0),t[0].r&&e.reverse(),r?e.filter((t,n)=>n===0||t!==e[n-1]):e;let o=e.map(e=>{let r=a?[[0,e.length]]:Jk(e,n);return{line:e,keys:t.map(t=>{let n=Yk(e,t,r);return t.n?Qk(n):t.f?Xk(n):n})}}),s=(e,n)=>{for(let r=0;r<t.length;r++){let i=t[r],a=i.n?eA(e.keys[r],n.keys[r]):N(e.keys[r],n.keys[r]);if(a!==0)return i.r?-a:a}return r?0:(i?-1:1)*N(e.line,n.line)};o.sort(s);let c=[];for(let e=0;e<o.length;e++)r&&e>0&&s(o[e-1],o[e])===0||c.push(o[e].line);return c}function Qk(e){let t=/^[ \t]*(-?)(?:(\d+)(?:\.(\d*))?|\.(\d+))/u.exec(e),n=(t?.[2]??``).replace(/^0+/u,``)||`0`,r=(t?.[3]??t?.[4]??``).replace(/0+$/u,``);return{integer:n,fraction:r,negative:t?.[1]===`-`&&(n!==`0`||r!==``)}}var $k=(e,t)=>e<t?-1:+(e>t);function eA(e,t){if(e.negative!==t.negative)return e.negative?-1:1;let n=e.integer.length-t.integer.length||$k(e.integer,t.integer)||$k(e.fraction,t.fraction);return e.negative?-n:n}async function tA(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`r`,`0`],valueShort:[`n`,`I`],stopAtFirstPositional:!0}),[o=`echo`,...s]=a,c=i.get(`I`),l=i.has(`n`)?fr(i.get(`n`),`xargs: -n`):{value:void 0};if(l.error)return l.error;if(l.value===0)return C(`xargs: -n: must be at least 1`);if(c===``)return C(`xargs: -I: replacement string must not be empty`);if(c!==void 0&&l.value!==void 0)return T(`option`,`xargs`,`-I -n`,`xargs: combining replacement and chunk limits is not supported`);if(L(n),!r.has(`0`)&&e.includes(`\0`))return T(`feature`,`xargs`,`NUL input`,`xargs: NUL input requires -0`);let u;if(r.has(`0`))u=Xn(e,`\0`);else if(c===void 0)u=rA(e);else{if(/["'\\]/u.test(e))return T(`feature`,`xargs`,`-I input quoting`,`xargs: quoted or escaped replacement lines are not supported`);u=Xn(e).map(e=>e.replace(/^[ \t\r\f\v]+/u,``)).filter(Boolean)}if(u.length===0&&(r.has(`r`)||c!==void 0))return S();let d=c===void 0?l.value??Math.max(1,u.length):1,f=G(),p=0;for(let e=0;e<Math.max(1,u.length);e+=d){let t=u[e],r=c===void 0?[...s,...u.slice(e,e+d)]:s.map(e=>e.replaceAll(c,t)),i=await n.dispatch(o,r,``,{devNull:!0});if(K(f,i),i.exitCode===255)return K(f,{...G(`xargs: ${o}: exited with status 255; aborting
342
+ `),exitCode:124}),f;if(i.exitCode===127&&!n.hasCommand(n.registry.resolveCommand(o)))return{...f,exitCode:127};i.exitCode!==0&&(p=123)}return{...f,exitCode:p,ignored:!1}}var nA=e=>Error(`unmatched ${e===`'`?`single`:`double`} quote; by default quotes are special to xargs unless you use the -0 option`);function rA(e){let t=[],n=null,r=!1,i=``;for(let a=0;a<e.length;a++){let o=e[a];if(r||!/[ \t\n\r\f\v]/u.test(o)){if(n){if(o===n)n=null;else{if(o===`
343
+ `)throw nA(n);i+=o}}else if(o===`"`||o===`'`)n=o,r=!0;else if(o===`\\`){if(a+1>=e.length)break;i+=e[++a],r=!0}else o===` `||o===` `||o===`
344
+ `?(r&&t.push(i),i=``,r=!1):(i+=o,r=!0)}}if(n)throw nA(n);return r&&t.push(i),t}function iA(e,t,n,r){let{values:i,positional:a,order:o}=U(sA(n),{short:[`q`,`v`],valueShort:[`c`,`n`]}),s=o.findLast(e=>e.name===`n`||e.name===`c`)?.name??`n`,c=pr(i.get(s)??`10`,e+`: -`+s);if(c.error)return c.error;let l=o.findLast(e=>e.name===`q`||e.name===`v`),u=l?l.name===`v`:null,d=e===`head`,f=c.sign===`+`;if(d&&c.value===0&&c.sign!==`-`)return lA(e,t,a,r,()=>``,{unit:s,banner:u,leftover:e=>e,readOptions:{noRead:!0}});if(!d&&c.value===0&&!f){if(!r.stdinFile&&(!a.length||a.includes(`-`)||a.includes(`/dev/stdin`))){let n=dA(e,t,``,s,`standard input`);n&&r.notes.add(n)}return S()}let p=e=>d?[0,c.sign===`-`?Math.max(0,e-c.value):c.value]:[f?Math.min(e,Math.max(0,c.value-1)):Math.max(0,e-c.value),e];return lA(e,t,a,r,e=>{if(s===`c`)return cA(e,p);let t=d?c.sign===`-`:!f,n=oA(e,d||t?c.value:Math.max(0,c.value-1),t);return d?e.slice(0,n):e.slice(n)},{unit:s,banner:u,leftover:d?aA(c,s,r):void 0,readOptions:!d&&f?{stopOnDir:!0}:void 0})}function aA(e,t,n){return e.sign===`-`||t===`n`&&!n.stdinFile?()=>``:t===`c`?t=>cA(t,t=>[Math.min(e.value,t),t]):t=>t.slice(oA(t,e.value))}function oA(e,t,n=!1){if(n){if(t===0)return e.length;let n=e.length-Number(e.endsWith(`
345
+ `));for(let r=0;r<t;r++)if(n<=0||(n=e.lastIndexOf(`
346
+ `,n-1),n<0))return 0;return n+1}let r=0;for(let n=0;n<t&&r<e.length;n++){let t=e.indexOf(`
347
+ `,r);r=t===-1?e.length:t+1}return r}function sA(e){return/^-\d+$/u.test(e[0]??``)?[`-n`,e[0].slice(1),...e.slice(1)]:e}function cA(e,t){let n=b(e),[r,i]=t(n.length);return r===0&&i>=n.length?e:k(n.subarray(r,i))}function lA(e,t,n,r,i,{unit:a,banner:o,leftover:s=()=>``,readOptions:c}){let l=sr(e,n,t,r,c),u=o??n.length>1,d=l.entries.filter(e=>e.kind!==`missing`),f=[],p=[],m=null;for(let t=0;t<d.length;t++){let{name:n,kind:o,shared:c}=d[t],{content:l}=d[t];(c||n===null)&&(m!==null&&(l=m),m=s(l),L(r,m));let h=o===`dir`?``:i(l);if(o===`file`&&h!==l){let t=dA(e,l,h,a,ur(n,r));t&&p.push(t)}let g=n===null||n===`-`?`standard input`:n;f.push(u?`${t>0?`
348
+ `:``}==> ${g} <==
349
+ ${h}`:h)}for(let e of p)r.notes.add(e);return R(f.join(``),l)}function uA(e){let t=+(e.length>0&&!e.endsWith(`
350
+ `));for(let n=e.indexOf(`
351
+ `);n!==-1;n=e.indexOf(`
352
+ `,n+1))t++;return t}function dA(e,t,n,r,i){let a=r===`c`?e=>b(e).length:uA,o=a(n),s=a(t);return o>=s?null:`${e}: selected ${o} of ${s} ${(r===`c`?`byte`:`line`)+(s===1?``:`s`)} from ${i}.`}function fA(e,t,n){let{flags:r,positional:i}=U(t,{short:[`l`,`w`,`c`,`m`]}),a=mA(r),o=sr(`wc`,i,e,n,{read:`as-held`}),s=i.length>1||Object.values(a).filter(Boolean).length>1,c=[],l={l:0,w:0,m:0,c:0};for(let{name:e,content:t,bytes:r,kind:i,shared:u}of o.entries.filter(e=>e.kind!==`missing`)){let o=hA(r??t,n,a,s);c.push({counts:o,name:e,kind:i,shared:u}),l.l+=o.l,l.w+=o.w,l.m+=o.m,l.c+=o.c}let u=s?pA(c,n.stdinFile):1;return i.length>1&&c.push({counts:l,name:`total`}),R(Qn(c.map(e=>rE(e.counts,e.name,a,u,n))),o)}function pA(e,t){let n=0,r=1;for(let{name:i,kind:a,shared:o,counts:s}of e)a===`dir`||(i===null||o)&&!t?r=7:n+=s.c;return Math.max(r,String(n).length)}function mA(e){return e.size===0?{l:!0,w:!0,m:!1,c:!0}:{l:e.has(`l`),w:e.has(`w`),m:e.has(`m`),c:e.has(`c`)}}function hA(e,t,n,r){let i=bn(t),a=n.c||r||n.m&&i?gA(e):0;return{l:n.l?Zn(e):0,w:n.w?TA(e,t):0,m:n.m?i?a:_A(e):0,c:a}}var gA=e=>typeof e==`string`?b(e).length:e.length;function _A(e){if(typeof e==`string`)return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of mt(e))n>=0&&t++;return t}var vA=new Set([9,10,11,12,13,32]),yA=new Set([160,8199,8239,8288]),bA=1,xA=0,SA=2,CA=Uint8Array.from({length:128},(e,t)=>vA.has(t)?bA:t>32&&t<127?SA:xA),wA=(e,t)=>t.has(`print`,e)?t.has(`space`,e)||yA.has(e)?bA:SA:xA;function TA(e,t){let n=Ln(t.locale),r=0,i=!1;for(let a of EA(e,t)){let e=a<0?xA:a<128?CA[a]:wA(a,n);e===bA?(i&&r++,i=!1):e===SA&&(i=!0)}return i?r+1:r}function*EA(e,t){if(typeof e!=`string`)yield*bn(t)?e:mt(e);else if(bn(t))yield*b(e);else for(let t=0;t<e.length;){let n=e.codePointAt(t);yield n>=55296&&n<=57343?65533:n,t+=n>65535?2:1}}function DA(e,t){let n=0;for(let r=0;r<t&&n<e.length;r++){for(;n<e.length&&/[ \t]/u.test(e[n]);)n++;for(;n<e.length&&!/[ \t]/u.test(e[n]);)n++}return e.slice(n)}function OA(e,t,n){let{flags:r,values:i,positional:a}=U(t,{short:[`c`,`d`,`u`,`i`,`D`],valueShort:[`f`,`s`,`w`]});if(a.length>2)return C(`uniq: extra operand: ${a[2]}`);if(a.length===2&&a[1]!==`-`)return T(`feature`,`uniq`,`output file`,`uniq: output files are not supported (filesystem is read-only)`);let o=fr(i.get(`f`)??`0`,`uniq: -f`);if(o.error)return o.error;let s=fr(i.get(`s`)??`0`,`uniq: -s`);if(s.error)return s.error;let c=i.has(`w`)?fr(i.get(`w`),`uniq: -w`):{value:void 0};if(c.error)return c.error;let l=r.has(`D`),u=r.has(`c`);if(l&&u)return C(`uniq: printing all duplicated lines and repeat counts is meaningless`);let d=dr(`uniq`,a.slice(0,1),e,n),f=r.has(`d`),p=r.has(`u`),m=r.has(`i`),h=e=>{let t=o.value>0?DA(e,o.value):e;if(s.value===0&&c.value===void 0){let e=t.toWellFormed();return m?e.replace(/[A-Z]/gu,e=>e.toLowerCase()):e}let n=b(t).subarray(s.value,c.value===void 0?void 0:s.value+c.value);return(m?n.map(e=>e>=65&&e<=90?e+32:e):n).join(`,`)},g=Xn(d.content),_=[],v=0,y=g.length?h(g[0]):null;for(let e=1;e<=g.length;e++){let t=e===g.length?null:h(g[e]);if(e<g.length&&t===y)continue;let n=e-v,r=n>=2;(l?r:!(f&&p)&&(f?r:!p||!r))&&(l?_.push(...g.slice(v+ +!!p,e)):_.push(u?String(n).padStart(7)+` `+g[v]:g[v])),v=e,y=t}return R(Qn(_),d)}function kA(){return S()}function AA(){return{stdout:``,stderr:``,exitCode:1}}var jA={grep:ag,head:(e,t,n)=>iA(`head`,e,t,n),tail:(e,t,n)=>iA(`tail`,e,t,n),wc:fA,sort:zk,uniq:OA,echo:HT,printf:YT,xargs:tA,awk:Fk},MA={true:kA,false:AA,":":kA},NA={test:CT,cat:sw,...jA,...ow,...qv},PA=(e,t)=>(n,r,i)=>{let a=jA.grep(n,[t,...r],i),o=w(a);return o?E(a,o.kind,e,o.detail,o.message):a},FA={__proto__:null,sed:gT,egrep:PA(`egrep`,`-E`),fgrep:PA(`fgrep`,`-F`),"[":wT,...Jv,...MA,...BT,...NA},IA=new Set([`cd`,`:`,...Object.keys(BT)]),LA=e=>!!FA[e],RA=new Set([`basename`,`cp`,`dirname`,`ln`,`mkdir`,`patch`,`rm`,`tee`,`touch`]),zA=Object.fromEntries(Object.entries(NA).filter(([e])=>!RA.has(e))),BA=`ls.cd.cat.grep.rg.find.head.tail.wc.tree.du.stat.realpath.sort.uniq.cut.tr.awk.nl.tac.hexdump.base64.xargs.echo.printf.test.diff.pwd.seq.which`.split(`.`),VA=Object.keys(FA).filter(e=>!IA.has(e)&&!Object.hasOwn(zA,e)).sort(),HA=new Set([`base32`,`brotli`,`egrep`,`fgrep`,`gunzip`,`gzcat`,`gzip`,`od`,`sed`,`sha1sum`,`sha256sum`,`sha384sum`,`sha512sum`,`shasum`,`tar`,`tee`,`xxd`,`zcat`]),UA=GA(),WA=[`grep`,`head`,`tail`,`wc`,`sort`,`uniq`,`cut`,`xargs`,`awk`,`tr`,`nl`,`tac`,`hexdump`,`cat`,`base64`,`diff`,`patch`];function GA(){let e=new Set(Object.keys(zA)),t=[];for(let n of BA)e.delete(n)&&t.push(n);return t.push(...[...e].sort()),t}var KA=Object.freeze([`/usr/local/bin/`,`/usr/bin/`,`/bin/`,`/sbin/`]);function qA(e,t){for(let n of KA)if(e.startsWith(n)){let r=e.slice(n.length);if(t(r))return r}return e}var JA=new Set([`test`,`[`,`true`,`false`]),YA=new Set([`grep`,`egrep`,`fgrep`]);function XA(e,t){let n=qA(e[0],t);return JA.has(n)?`status`:YA.has(n)?ig(e.slice(1))?`status`:`search`:`work`}function ZA(e,t=!1){let n=xf(t),r=n===null?[]:bf,i=yo(e,e=>LA(e)||r.includes(e)),a=Object.freeze({__proto__:null,...FA,...n,...i.handlers}),o=e=>!!a[e],s=Object.freeze([...UA,...r,...VA,...i.names]);return Object.freeze({commands:a,names:s,pipeNames:Object.freeze([...WA,...r,...VA.filter(e=>HA.has(e)),...i.pipeNames]),binPrefixes:KA,has:o,shellOnly:e=>IA.has(e),resolveCommand:e=>qA(e,o),chainRole:e=>XA(e,o),known:[...UA,...r,...i.names].join(`, `)})}var QA=ZA(),$A=null,ej=e=>e?($A??=ZA(void 0,!0),$A):QA;function tj(e,t){let n=VT.get(e);return n===void 0?T(`command`,e,e,`${e}: command not found. Available: ${t.known}`,127):T(`feature`,e,e,`${e}: ${n}`,127)}function nj(e,t,n){let r=oj(e);if(!r)return[];let{start:i,pipe:a,quote:o,words:s}=r;for(;rj.has(s[0]);)s.shift();if(ij.has(s[0])||s[0]===`for`&&s.length<=2)return[];let c=e.slice(i),l=sj(c,o);if(!l)return[];let u=s.length===0,d=u?``:n.resolveCommand(sj(s[0],null)?.value??``),f=u?aj(l.value,a,n,t.functions):a?[]:lj(l,t,d===`cd`),p=e.slice(0,i),m=a&&c===``&&p.endsWith(`|`)?` `:``;return f.map(e=>p+m+c+cj(e.slice(l.value.length),o))}var rj=new Set([`!`,`{`,`do`,`then`,`else`,`elif`,`if`,`while`,`until`]),ij=new Set([`done`,`fi`,`}`,`esac`]);function aj(e,t,n,r){let i=t?n.pipeNames:n.names;for(let t of n.binPrefixes)if(e.startsWith(t))return i.filter(n=>n.startsWith(e.slice(t.length))).map(e=>t+e);if(e.startsWith(`/`)||e.startsWith(`./`))return[];let a=[...r.keys()].filter(e=>!i.includes(e));return[...i,...a].filter(t=>t.startsWith(e))}function oj(e){let t=0,n=!1,r=null,i=!1,a=-1,o=[];for(let s=0;s<e.length;s++){let c=e[s];if(r===`'`){c===r&&(r=null);continue}if(c===`\\`&&(!r||`$\`"\\
353
+ `.includes(e[s+1]))){if(s+1===e.length)return null;e[++s]!==`
354
+ `&&(i=!0);continue}if(c==="`"||c===`$`&&e[s+1]===`(`)return null;if(r){c===r&&(r=null);continue}if(c===`'`||c===`"`){r=c,i=!0;continue}if(c===`#`&&!i){let t=e.indexOf(`
355
+ `,s);if(t===-1)return null;s=t-1;continue}if(c===` `||c===` `){i&&o.push(e.slice(t,s)),t=s+1,i=!1;continue}let l=c===`|`&&e[s+1]===`|`,u=c===`&`&&e[s+1]===`&`;c===`|`||u||c===`;`||c===`
356
+ `||c===`(`||c===`)`&&a===s-1?((l||u)&&s++,c===`(`&&(a=s),t=s+1,n=c===`|`&&!l,o.length=0,i=!1):i=!0}return{start:t,pipe:n,quote:r,words:o}}function sj(e,t){if(e===``)return{value:``,mask:null};try{let n=ea(e+(t??``));if(n.length!==1||n[0].kind!==`word`)return null;let r=n[0];for(let e=0;e<r.value.length;e++){let t=r.mask?.[e]??`0`;if(t!==`1`&&r.value[e]===`$`||t===`0`&&`*?[{`.includes(r.value[e]))return null}return r}catch{return null}}function cj(e,t){return t===`'`?e.replaceAll(`'`,`'\\''`)+`'`:t===`"`?e.replace(/[\\$`"]/gu,`\\$&`)+`"`:e.replace(/[\s\\'"`$&|;()<>*?[\]{}!#~]/gu,e=>e===`
357
+ `?`'
358
+ '`:`\\`+e)}function lj(e,t,n=!1){let r=e.value,i=r.startsWith(`~`)&&(e.mask?.[0]??`0`)===`0`&&!e.empty?.some(e=>e<=1)&&(r.length===1||(e.mask?.[1]??`0`)===`0`);if(i&&r===`~`)return t.fs.isDir(j(t.cwd,Jb(t),t.fs).path)?[`~/`]:[];if(i&&!r.startsWith(`~/`))return[];let a=r.lastIndexOf(`/`),o=r.slice(0,a+1),s=r.slice(a+1),c=i?Jb(t)+o.slice(1):o||`.`,l=j(t.cwd,c,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:u,files:d,links:f}=t.fs.listDir(l),p=u.map(e=>e+`/`);for(let e of f)t.fs.isDir(j(l,e,t.fs).path)?p.push(e+`/`):n||p.push(e);return n||p.push(...d),p.filter(e=>e.startsWith(s)&&(s.startsWith(`.`)||!e.startsWith(`.`))).filter(e=>o!==``||s===``||!e.startsWith(`-`)).map(e=>o===``&&e.startsWith(`-`)?`./`+e:o+e)}async function uj(e,t,n,r=!1){let i=(t.substitutionDepth??0)+1;if(i>Hr)throw new D(`feature`,`command substitution nesting limit`,`command substitution nesting beyond ${Hr} levels is not supported`);let a=t.expansionFds[2],o=await Hb(t,{substitutionDepth:i,outputFds:{1:`out`,2:typeof a==`object`||a===`closed`?a:`err`},errexitOff:!0,closed:{out:!1,err:a===`closed`}},()=>Vb(t,()=>{let i;try{i=Ua(e,t.writable,t.registry.has)}catch(e){let n=w(e);if(!n){if(r)return C(`error: command substitution: ${e.message}`,2);throw new D(`feature`,`command substitution syntax`,`runtime command substitution syntax errors are not supported: ${e.message}`)}return t.unsupported.add(n),C(`error: ${e.message}`,1)}let a=i.length===1&&!i[0].negate&&i[0].stages.length===1?i[0].stages[0]:null;return!a||a.group||a.loop||a.conditional||a.test||a.words.length!==0||a.assigns.length!==0||a.redirs.length!==1||a.redirs[0].op!==`read`||a.words.push({value:`cat`,mask:null}),n(i,t,{text:t.stdinLeft,bytes:t.stdinBytes})}));t.lastExit=t.substitutionExit=o.exitCode;let s=o.stdout,c=o.stderr;if(s.includes(`\0`)){let e=s.length;s=s.replaceAll(`\0`,``);let n=e-s.length;t.notes.add(`command substitution: discarded ${n} NUL ${n===1?`byte`:`bytes`}.`),c+=`warning: command substitution: ignored null byte in input
359
+ `}h_(t,c);let l=s.length;for(;l>0&&s[l-1]===`
360
+ `;)l--;return s.slice(0,l)}async function dj(e,t){return{stdout:``,stderr:``,exitCode:+!await pj(e,t)}}var fj=async(e,t)=>(await Zb(e,t)).value;async function pj(e,t){let{kind:n}=e;if(n===`not`)return!await pj(e.expression,t);if(n===`and`)return await pj(e.left,t)&&await pj(e.right,t);if(n===`or`)return await pj(e.left,t)||await pj(e.right,t);let{op:r}=e;if(n===`unary`){let n=await fj(e.word,t);if(r===`-n`)return n!==``;if(r===`-z`)return n===``;if([`-a`,`-e`,`-f`,`-d`].includes(r))return OT(r,n,t);if(r===`-v`)return mj(n,t);hj(r)}[`<`,`>`,`-nt`,`-ot`,`-ef`].includes(r)&&hj(r);let i=await fj(e.left,t);if(Object.hasOwn(bT,r)){let n=await fj(e.right,t);return bT[r](Db(i,t),Db(n,t))}let a=await Zb(e.right,t);Ch(a)&&hj(`extglob`);let o=mh(Eh(a),{bash:!0}).test(i);return r===`!=`?!o:o}function mj(e,t){return e.includes(`[`)&&hj(`-v array subscript`),/^[ \t\n\r\f\v]*[+-]?0+[ \t]*$/u.test(e)&&hj(`-v positional parameter`),/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?eb(e,t).set:!1}function hj(e){throw new D(`feature`,`[[ ${e}`,`${e} in [[ is not supported`)}function gj(e,t,n,r){return e.define?(t.functions.set(e.define.name,e.define.body),G()):e.test?dj(e.test,t):e.group?Cj(e,t,n,r):e.loop?e.loop.words?xj(e.loop,t,r):yj(e.loop,t,r):Sj(e.conditional,t,n,r)}var _j=1e4,vj={kind:`feature`,command:null,detail:`loop limit`,message:`a loop running more than ${_j} times is not supported`};async function yj(e,t,n){let r=G(),i={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let a=0;;a++){if(a===_j){t.unsupported.add(vj),K(r,C(`error: ${vj.message}`,1));break}let o=r.ignored,s=r.exitCode,c=await n(e.condition,t,i,!0);if(K(r,c),r.exitCode=s,r.ignored=o,c.halt||c.control)return{...r,halt:c.halt,control:c.control,blame:c.blame};if(c.exitCode===0==!!e.until)break;let l=await n(e.body,t,i);if(K(r,l),r.blame=l.blame,l.halt)return{...r,halt:!0};if(l.control?.levels>1)return{...r,control:{...l.control,levels:l.control.levels-1}};if(l.control?.type===`break`)break}}finally{t.loopDepth--}return r}var bj={value:`for`,mask:null};async function xj(e,t,n){let r=await Ub([bj,...e.words],t),i=G(),a={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let o of r.argv.slice(1)){t.vars.set(e.name,o);let r=await n(e.body,t,a);if(K(i,r),i.blame=r.blame,r.halt)return{...i,halt:!0};if(r.control?.levels>1)return{...i,control:{...r.control,levels:r.control.levels-1}};if(r.control?.type===`break`)break}}finally{t.loopDepth--}return i}async function Sj(e,t,n,r){let i=G(),a={text:n,bytes:t.stdinBytes};for(let n of e.branches){let e=await r(n.condition,t,a,!0);if(K(i,e),e.halt||e.control)return{...i,halt:e.halt,control:e.control,blame:e.blame};if(e.exitCode!==0)continue;let o=await r(n.body,t,a);return K(i,o),{...i,halt:o.halt,control:o.control,blame:o.blame}}if(!e.otherwise)return i.exitCode=0,i.ignored=!1,i;let o=await r(e.otherwise,t,a);return K(i,o),{...i,halt:o.halt,control:o.control,blame:o.blame}}async function Cj(e,t,n,r){let i={text:n,bytes:t.stdinBytes};return e.isolate?{...await Vb(t,()=>r(e.group,t,i)),halt:!1,control:void 0,ignored:!1}:r(e.group,t,i)}var wj=new Set([`sort`,`cat`]),Tj=new Set([`wc`,`tac`]);function Ej(e){let t=null,n=null,r=e=>{t&&!t.bufferReads&&t.reads.push(e)},i=e=>{if(e!==void 0)for(let r=t;r;r=r.parent){if(!r.reads.includes(e)||r===t&&n?.scope===r&&(n.unsupported||r.buffered||n.fd===1&&(wj.has(r.name)||Tj.has(r.name)&&!r.reads.slice(1).includes(e))))continue;if(r.failure)throw r.failure;let i=r===t&&n?.fd===2,a=i?`input modified by diagnostics`:`streaming self-output`,o=i?`reading input while diagnostics write to the same file is not supported`:`writing to an actively read input file is not supported`;throw r.failure=E(new D(`feature`,a,o),`feature`,r.name,a,o),r.failure}};return e.observeIo?.({read:r,write:i}),{read:r,bufferOutput(){t&&(t.buffered=!0)},bufferReads(e){if(!t)return e();let n=t,r=n.bufferReads;n.bufferReads=!0;try{return e()}finally{n.bufferReads=r}},setReads(e){t&&(t.reads=e)},async run(e,n){let r=t;t={name:e,reads:[],parent:r};try{return await n()}finally{t=r}},output(e,r,a){let o=n;n={scope:t,fd:null,unsupported:!!w(e)};try{for(let t of p_(e))t.text!==``&&(n.fd=t.fd,i(r.fds[t.fd]?.identity));return a((e,t)=>{n.fd=e.fd,f_(e,t)})}finally{n=o}}}}function Dj(e,t){return g_(e,{fds:{1:t.outputFds[1]?.path?t.outputFds[1]:`out`,2:t.outputFds[2]?.path?t.outputFds[2]:`err`},deferred:{1:Oj(t.outputFds[1]),2:Oj(t.outputFds[2])}},t)}var Oj=e=>e!==`out`&&e!==`err`&&!e?.path;async function kj(e,t,n,r=!1){if(e.some(e=>e.background))throw new D(`feature`,`&`,"background processes (`&`) are not supported");let i=G(),a=null,o=null;for(let[s,c]of e.entries()){if(c.warnings&&K(i,g_({...G(c.warnings),exitCode:i.exitCode,ignored:i.ignored},{fds:t.outputFds},t)),c.gate===`and`&&i.exitCode!==0){(o??=qn()).skip(r?null:a,i.exitCode);continue}if(c.gate===`or`&&i.exitCode===0)continue;o?.flush(t.notes);let l=r||c.negate||Aj(e,s),u=await(l?Hb(t,{errexitOff:!0},()=>jj(c.stages,t,n)):jj(c.stages,t,n));if(K(i,u),c.negate&&!u.halt&&(i.exitCode=+(u.exitCode===0)),l&&(i.ignored=!0),a=c.negate?null:u.blame,t.lastExit=i.exitCode,u.halt||u.control){Object.assign(i,{halt:u.halt,control:u.control});break}if(i.exitCode!==0&&!i.ignored&&t.errexit&&!t.errexitOff){i.halt=!0;break}}return o?.flush(t.notes),t.stdinLeft=n.text,t.stdinBytes=n.bytes??null,Object.assign(i,{blame:a})}var Aj=(e,t)=>[`and`,`or`].includes(e[t+1]?.gate);async function jj(e,t,n){let r=G(),i=n.text,a=n.bytes??null;for(let o=0;o<e.length;o++){let s=e[o],c=o===0,l=o<e.length-1?Mj():null,u={...t.outputFds};l&&(u[1]=l);let d=a,f=i,p=()=>Nj(s,t,{stdin:f,stdinBytes:d,stdinFile:c&&t.stdinFile,fds:u,stdinPiped:!c||t.stdinPiped,stdinTerminal:c&&t.stdinTerminal}),m=e.length>1?{...await Vb(t,p),ignored:!1}:await p();c&&(n.text=m.inputLeft,n.bytes=m.bytesLeft??null),K(r,m);let h=l?.carried()??{text:``};a=h.bytes??null,i=h.text??vt(h.bytes)??``,r.blame=m.blame,e.length===1&&(r.halt=m.halt,r.control=m.control)}return r}function Mj(){let e=``,t=null;return{write(n){t===null?e+=n:n!==``&&t.push(O(n))},writeBytes(n){t===null&&(t=e===``?[]:[O(e)],e=``),t.push(n)},carried:()=>t===null?{text:e}:{bytes:Dt([...t,new Uint8Array])}}}function Nj(e,t,{stdin:n,stdinBytes:r,stdinFile:i,fds:a,stdinPiped:o,stdinTerminal:s}){let c={fds:a,stdin:n,stdinBytes:r,stdinFile:i,stdinPiped:o,stdinTerminal:s,stdinOrigin:i?t.stdinOrigin:null,stdinHandle:i?t.stdinHandle:null};return Hb(t,{substitutionExit:null,expansionOutput:G(),expansionFds:a},()=>Rj(c,t,async()=>{let n=!e.group&&!e.loop&&!e.conditional&&!e.test&&!e.define,r,o;try{n&&(r=await Ub(e.words,t),r.argv.length===0?await Hj(e.assigns,t):r.temps=await Uj(e.assigns,t))}catch(e){o=Ij(t,e)}if(o)return K(t.expansionOutput,Pj(o,c,t)),{...t.expansionOutput,inputLeft:t.stdinLeft,bytesLeft:t.stdinBytes,halt:o.halt};let s=await Fj(e,t,t.stdinLeft,i,a);t.expansionFds=s.fds;let l=!1,u=null,d=await Rj(s,t,()=>Lj(t,async()=>{if(s.error)return s.error;if(!n){let n=await gj(e,t,s.stdin,kj);return l=!0,u=n.blame??null,n}let i=r.argv.length>0?r.argv[0]:null,a=i===null?void 0:t.functions.get(i);if(a){if(l=!0,t.calling.has(i)){let e=T(`feature`,i,`function recursion`,`${i}: a function calling itself is not supported`);return t.unsupported.add(w(e)),e}t.calling.add(i);try{return await Hb(t,{loopDepth:0},async()=>({...await Wj(r.temps,t,()=>kj(a,t,{text:s.stdin,bytes:s.stdinBytes})),ignored:!1}))}finally{t.calling.delete(i)}}let o=await Vj(t,r);return r.argv.length&&(u=Kn(t.registry.chainRole(r.argv),r.argv[0])),o})),f=s.inherited?t.stdinLeft:s.parentLeft,p=s.inherited?t.stdinBytes:s.parentBytes;return K(t.expansionOutput,l?d:Pj(d,s,t)),{...t.expansionOutput,inputLeft:f,bytesLeft:p,halt:d.halt,control:d.control,blame:u}}))}function Pj(e,t,n){try{return g_(e,t,n)}catch(e){return g_(Ij(n,e),t,n)}}async function Fj(e,t,n,r,i){let a={...i},o=n,s=r,c=s?t.stdinOrigin:null,l=s?t.stdinHandle:null,u=!0,d=n,f=!1,p=t.stdinTerminal,m=t.stdinBytes,h=m,g=e=>({error:e,fds:a,stdin:o,stdinBytes:m,stdinFile:s,stdinPiped:f||t.stdinPiped,stdinTerminal:p,stdinOrigin:s?c:null,stdinHandle:s?l:null,inherited:u,parentLeft:d,parentBytes:h}),_=async e=>{let n=await Hb(t,{expansionFds:a},()=>Rj({fds:a,stdin:o,stdinBytes:m,stdinFile:s,stdinOrigin:c,stdinHandle:l},t,e));return o=t.stdinLeft,m=t.stdinBytes,u&&(d=o,h=m),n};try{for(let n of e.redirs)if(n.op===`dup`){if(a[n.toFd]===void 0||a[n.toFd]===`closed`)return g(C(`error: ${n.toFd}: Bad file descriptor`));a[n.fd]=a[n.toFd]}else if(n.op===`close`)a[n.fd]=`closed`;else if(n.op===`to`){let e=n.target===void 0?await _(()=>Gb(n.word,t)):{value:n.target};if(e.error)return g(C(`error: ${e.error}`));let r=e.value===`/dev/null`?`null`:e.value===`/dev/stdout`?a[1]:e.value===`/dev/stderr`?a[2]:t.writable?t.fs.openWritable(t.cwd,e.value,n.append):null;if(r===null){let r=ho(n.label,e.value,t.writable);return t.unsupported.add(w(r)),g(C(`error: ${r.message}`))}if(r===`closed`)return g(C(`error: ${e.value}: No such file or directory`));a[n.fd]=r,n.both&&(a[2]=r)}else if(n.op===`text`)o=n.expand?await _(()=>qb(zj(n.body),t)):n.body,s=!1,u=!1,m=null,p=!1;else if(n.op===`herestring`)o=await _(()=>qb(n.word,t))+`
361
+ `,s=!1,u=!1,m=null,p=!1;else{let e=await _(()=>Gb(n.word,t)),r=e.error?{error:C(`error: ${e.error}`)}:Bj(e.value,t,s?c:o);if(r.error)return g(r.error);o=r.content,e.value!==`/dev/stdin`&&(m=r.bytes??null),(e.value!==`/dev/stdin`||s)&&(u=!1),e.value!==`/dev/stdin`&&(s=e.value!==`/dev/null`,c=s?o:null,l=r.handle,f=s,p=!1)}if(s&&l){let e=t.io.bufferReads(()=>t.fs.readIdentity(l.identity));if(e!==l.content){if(u||o!==l.content)throw new D(`feature`,`modified redirected input`,`reading an inherited input file after it changes is not supported`);o=c=e,l={...l,content:e}}}}catch(e){return g(Ij(t,e))}return g()}function Ij(e,t){I(e,`shell`,t?.path,t?.fsError);let n=w(t);return n&&e.unsupported.add(n),{...C(`error: ${z(t)}`,1),...t?.halt?{halt:!0}:{}}}async function Lj(e,t){try{return await t()}catch(t){return Ij(e,t)}}function Rj(e,t,n){let r={outputFds:e.fds,closed:{out:e.fds[1]===`closed`,err:e.fds[2]===`closed`},stdinFile:!!e.stdinFile,stdinPiped:e.stdinPiped??t.stdinPiped,stdinTerminal:e.stdinTerminal??t.stdinTerminal,stdinOrigin:e.stdinOrigin,stdinHandle:e.stdinHandle};return t.stdinLeft=e.stdin,t.stdinBytes=e.stdinBytes??null,Hb(t,r,n)}function zj(e){let t=``,n=``;for(let r=0;r<e.length;r++){let i=e[r],a=e[r+1];if(i===`\\`&&(a===`$`||a===`\\`||a==="`"))t+=a,n+=`1`,r++;else if(i==="`"){let i=Ur(e,r);t+=i.raw,n+=`2`+`1`.repeat(i.raw.length-1),r+=i.raw.length-1}else{if(i===`$`){let i=Li(e,r,0,!0);if(i?.command!==void 0||i?.parameter!==void 0||i?.arithmetic!==void 0){t+=i.raw,n+=`2`+`1`.repeat(i.raw.length-1),r+=i.raw.length-1;continue}}t+=i,n+=`2`}}return{value:t,mask:n}}function Bj(e,t,n){if(e===`/dev/null`)return{content:``};if(e===`/dev/stdin`)return{content:n};let{path:r,error:i}=F(t,`shell`,e);if(i)return{error:C(`error: ${e}: ${i}`)};if(t.fs.isFile(r)){let{text:e,bytes:n}=or(t.fs,r),i=e??``;return{content:i,bytes:e===void 0?n:void 0,handle:t.writable&&r.startsWith(`/tmp/`)?{path:r,content:i,identity:t.fs.fileIdentity(r)}:null}}return{error:C(`error: ${e}: Is a directory`)}}function Vj(e,t){let{argv:n}=t;return n.length===0?{stdout:``,stderr:``,exitCode:e.substitutionExit??0}:Wj(t.temps,e,()=>e.invoke(n[0],n.slice(1),e.stdinLeft))}async function Hj(e,t){for(let n of e)t.vars.set(n.name,await qb(n.word,t,!0))}async function Uj(e,t){if(e.length===0)return null;let n=t.vars,r=new Zy(n),i=new Set(e.map(e=>e.name));r.bound=new Set;try{await Hb(t,{vars:r},async()=>{for(let n of e){r.expansionTargets=i;let e=await qb(n.word,t,!0);r.expansionTargets=null,r.set(n.name,e)}})}finally{r.expansionTargets=null;for(let e of r.bound)i.has(e)||n.set(e,r.get(e))}return{vars:r,names:i}}async function Wj(e,t,n){if(!e)return n();let r=t.vars,i=new Zy(r),a=e.names;for(let t of a)i.set(t,e.vars.get(t));t.vars=i;try{return i.bound=new Set,await n()}finally{t.vars=r;for(let[e,t]of i)(!a.has(e)||i.bound?.has(e))&&r.set(e,t);for(let e of i.unsetNames)a.has(e)||r.delete(e)}}function Gj(e,t={}){let{fs:n,cwd:r,home:i,mount:a,writable:o,locale:s}=Nr(e,t),c=fd(t),l=t.commands===void 0?ej(c):ZA(t.commands,c);return Xj(Yj({fs:n,io:Ej(n),mount:a,writable:o,registry:l,createdAt:Date.now(),lock:{turn:Promise.resolve()}},{cwd:r,home:i,user:t.user??`user`,locale:s,...Kj()}),`createTerminal`)}var Kj=()=>({vars:new Zy,functions:new Map,lastExit:0,errexit:!1}),qj=e=>({vars:new Zy(e.vars),functions:new Map(e.functions),lastExit:e.lastExit,errexit:e.errexit});function Jj(e,t={}){let{cwd:n,home:r,user:i,locale:a,inherit:o}=Pr(e,t);return Xj(Yj(e,{cwd:n,home:r,user:i,locale:a,...o?qj(e):Kj()}),`fork`)}function Yj({fs:e,io:t,mount:n,writable:r,registry:i,createdAt:a,lock:o},s){let c={fs:e,io:t,mount:n,writable:r,registry:i,createdAt:a,lock:o,...s,calling:new Set,outputFds:{1:`out`,2:`err`},loopDepth:0,closed:{out:!1,err:!1},stdinFile:!1,stdinPiped:!1,stdinTerminal:!0,stdinOrigin:null,stdinHandle:null,stdinLeft:``,stdinBytes:null,unsupported:ft(),notes:new Set};return c.dispatch=(e,t,n,{devNull:r=!1}={})=>Hb(c,{stdinLeft:c.stdinLeft,stdinBytes:c.stdinBytes,stdinFile:!1,stdinPiped:!1,stdinTerminal:c.stdinTerminal&&!r,stdinOrigin:null,stdinHandle:null},()=>Vb(c,()=>Zj(e,t,n,c,!0))),c.flushOutput=e=>Dj(e,c),c.hasCommand=e=>i.has(e)&&!i.shellOnly(e),c.invoke=(e,t,n)=>Zj(e,t,n,c),c.substitute=(e,t)=>uj(e,c,kj,t),c.runLine=e=>eM(e,c),c}function Xj(e,t){if(!e.fs.isDir(e.cwd))throw Error(`${t}: cwd is not a directory: ${e.cwd}`);return{run:t=>$j(e,t),cwd:()=>e.cwd,complete:t=>nj(t,e,e.registry),fork:t=>Jj(e,t)}}async function Zj(e,t,n,r,i=!1){let a=r.registry,o=a.resolveCommand(e),s=()=>{if((i||e!==o)&&a.shellOnly(o))return T(`command`,e,e,`${e}: shell builtin cannot be invoked as an external command`,127);let s=a.commands[o];return s?s(n,t,r):tj(e,a)},c=t=>Dj(Qj(r,b_(e,t,r),o),r);try{return await r.io.run(o,async()=>c(await s()))}catch(t){I(r,e,t?.path,t?.fsError);let n=`${e}: ${z(t)}`,i=w(t);return i&&r.unsupported.add({...i,command:i.command??e,message:n},i.command??o),c(C(n))}}function Qj(e,t,n){let r=w(t);return r&&e.unsupported.add(r,n),t}function $j(e,t){let{lock:n}=e,r=n.turn.then(()=>eM(t,e));return n.turn=r.then(()=>null,()=>null),r}function eM(e,t){let n=ft();return Hb(t,{unsupported:n,notes:new Set,discarded:new Set,stdinFile:!1,stdinPiped:!1,stdinTerminal:!0,stdinOrigin:null,stdinHandle:null,stdinBytes:null,closed:{out:!1,err:!1},outputFds:{1:`out`,2:`err`}},async()=>{let r={stdout:``,stderr:``,exitCode:0},i={text:``};try{for(let n of Wa(e,t.writable,t.registry.has)){let e=await kj(n,t,i);if(r.stdout+=e.stdout,r.stderr+=e.stderr,r.exitCode=e.exitCode,e.halt||e.control)break}}catch(e){let i=w(e);i&&n.add(i),t.lastExit=e.exitCode??(i?1:2),r.stderr+=`error: ${e.message}
362
+ `,r.exitCode=t.lastExit}return tM(r,t,n)})}var tM=(e,t,n)=>({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,cwd:t.cwd,unsupported:Object.freeze(n.entries),notes:Object.freeze([...t.notes,...Gn(t.discarded,e.stderr,t.notes)])}),nM={unified:[[/^--- /u,`bold`],[/^\+\+\+ /u,`bold`],[se,`cyan`],[/^\+/u,`green`],[/^-/u,`red`],[/^\\ /u,`gray`]],context:[[ce,`cyan`],[/^\*{3} \d/u,`cyan`],[/^--- \d/u,`cyan`],[/^\*{3} /u,`bold`],[/^--- /u,`bold`],[/^! /u,`yellow`],[/^\+ /u,`green`],[/^- /u,`red`]],normal:[[le,`cyan`],[/^< /u,`red`],[/^> /u,`green`],[/^---$/u,`gray`]]},rM=[[`context`,ce],[`unified`,se],[`normal`,le]],iM=e=>rM.find(([,t])=>e.some(e=>t.test(e)))?.[0]??null;function aM(e){let t=e.split(`
363
+ `),n=nM[iM(t)];return n===void 0?null:t.map(e=>n.find(([t])=>t.test(e))?.[1]??null)}var oM={bold:`head`,cyan:`hunk`,green:`add`,red:`del`,yellow:`chg`,gray:`meta`};function sM(e){let t=aM(e);return t===null?null:e.split(`
364
+ `).map((e,n)=>({text:e,kind:t[n]===null?``:oM[t[n]]??``}))}function cM({stdout:e,stderr:t,unsupported:n}){return n.filter(n=>!t.includes(n.message)&&!e.includes(n.message)).map(e=>e.message)}var lM=`:host{display:flex;flex-direction:column;position:relative;height:100%;min-height:0;background:var(--bg);color:var(--text);font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:13px;line-height:1.45}.output{flex:1 1 auto;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;padding:var(--terminal-output-padding, 12px 14px 6px);cursor:text}.banner{color:var(--muted);margin-bottom:8px;user-select:none}.banner .cmd{color:var(--accent)}.banner .cmd:hover{text-decoration:underline}.line{white-space:pre-wrap;overflow-wrap:break-word}.cwd{color:var(--accent)}.sigil{color:var(--muted)}.stdout,.stderr{margin:0 0 4px;font:inherit;white-space:pre-wrap;overflow-wrap:break-word}.stderr{color:var(--critical)}.diff-head{color:var(--text);font-weight:600}.diff-hunk{color:var(--accent)}.diff-add{color:var(--green)}.diff-del{color:var(--critical)}.diff-chg{color:var(--yellow)}.diff-meta{color:var(--muted)}.form{flex:0 0 auto;display:flex;align-items:center;padding:var(--terminal-form-padding, 8px 14px 10px);border-top:1px solid var(--border)}.form:focus-within{border-top-color:var(--accent)}.form[aria-busy=true] .sigil{opacity:.4}.form[aria-busy=true] .input{caret-color:transparent}.form .cwd{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none}.form .sigil{flex:0 0 auto;user-select:none;margin:0 1ch}.input-wrap{flex:1 1 auto;min-width:0;position:relative;display:flex;align-items:center}.input{width:100%;background:transparent;border:none;outline:none;color:inherit;font:inherit;padding:0;position:relative}.ghost{position:absolute;inset:0;display:flex;align-items:center;font:inherit;white-space:pre;overflow:hidden;pointer-events:none;user-select:none;color:var(--muted);opacity:.55}.ghost-pad{color:transparent}.notes{position:absolute;top:8px;right:14px;z-index:2;display:flex;flex-direction:column;align-items:flex-end;gap:6px;max-width:min(52%,320px);pointer-events:none}.note{box-sizing:border-box;padding:5px 9px;border:1px solid var(--border);border-radius:var(--ui-radius, 5px);background:var(--bg);color:var(--muted);font-size:12px;line-height:1.4;text-align:left;overflow-wrap:break-word;animation:note-in .14s ease-out,note-out .4s ease-in var(--dwell-out, 5.6s) forwards}.note-gap{border-color:var(--warning);color:var(--text)}@keyframes note-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}@keyframes note-out{to{opacity:0;transform:translateY(-4px)}}@media(prefers-reduced-motion:reduce){.note{animation:none}}:host-context(body.theme-w95) *{overscroll-behavior:none}
365
+ `,uM=`/sources`,dM={mount:uM,home:`/`,writable:`/tmp/`};function fM(e){let t=[`ls`,`find /`,`grep -r ${mM(e)} .`];if(!e||e.size===0)return t;let n=null;for(let[t,r]of e){if(typeof r!=`string`)continue;let e=t.replace(/^\.?\//u,``);(n===null||e.length<n.length)&&(n=e)}return n&&t.push(`cat ${n} | head -n 20`),t}var pM=[`TODO`,`FIXME`,`XXX`,`HACK`,`NOTE`,`BUG`,`export`,`import`,`require`,`//`];function mM(e){if(!e||e.size===0)return pM[0];for(let t of pM)for(let n of e.values())if(typeof n==`string`&&n.includes(t))return t;return pM[0]}var hM=class e extends be{static properties={sources:{attribute:!1},_lines:{state:!0},_input:{state:!0},_cwd:{state:!0},_ghost:{state:!0},_notes:{state:!0},_running:{state:!0}};static styles=_e(lM);#e=null;#t=null;#n=[];#r=-1;#i=``;#a=null;#o=null;static#s=200;#c=new Map;#l=0;static#u=3;static#d=400;constructor(){super(),this.sources=null,this._lines=[],this._input=``,this._cwd=uM,this._ghost=``,this._notes=[],this._running=!1}willUpdate(e){e.has(`sources`)&&this.sources!==this.#t&&(this.#e=this.sources?Gj(this.sources,dM):null,this._cwd=this.#e?this.#e.cwd():uM,this._lines=[{kind:`banner`,commands:fM(this.sources)}],this.#n=[],this.#r=-1,this.#i=``,this.#a=null,this._input=``,this.#T(),this.#t=this.sources),e.has(`_input`)&&(this.#g(),this.#_())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#f())}disconnectedCallback(){super.disconnectedCallback(),this.#g(),this.#T()}firstUpdated(){this.focusInput()}updated(e){(e.has(`_lines`)||e.has(`sources`))&&this.#f()}focusInput(){let e=this.renderRoot.querySelector(`.input`);e&&e.focus()}#f(){let e=this.renderRoot.querySelector(`.output`);e&&(e.scrollTop=e.scrollHeight)}#p=async e=>{if(e.preventDefault(),!this.#e||this._running)return;let t=this._input,n=this._cwd;if(t.trim().length>0&&(this.#n=[...this.#n,t]),this.#r=-1,this._input=``,t.trim()===`clear`){this._lines=[],this.#T();return}let r;this._running=!0;try{r=await this.#e.run(t)}catch(e){this._lines=[...this._lines,{kind:`prompt`,cwd:n,text:t},{kind:`stderr`,text:`${e?.message??e}
366
+ `}];return}finally{this._running=!1}this._cwd=r.cwd;let i=[...this._lines,{kind:`prompt`,cwd:n,text:t}];r.stdout&&i.push({kind:`stdout`,text:r.stdout,diff:sM(r.stdout)}),r.stderr&&i.push({kind:`stderr`,text:r.stderr}),this._lines=i,this.#y(r)};#m=e=>{e.key===`Tab`&&!e.shiftKey?(e.preventDefault(),this.#h()):(this.#a=null,e.key===`ArrowUp`?(e.preventDefault(),this.#E()):e.key===`ArrowDown`&&(e.preventDefault(),this.#D()),this.#g(),this.#_())};#h(){if(!this.#e)return;let e=this.#a;if(e&&e.items[e.index]===this._input){e.index=(e.index+1)%e.items.length,this._input=e.items[e.index];return}let t=this.#e.complete(this._input);t.length===0?this.#a=null:(this._input=t[0],this.#a=t.length>1?{items:t,index:0}:null)}#g(){this._ghost=``,this.#o!==null&&(clearTimeout(this.#o),this.#o=null)}#_(){this.#o=setTimeout(()=>{this.#o=null,this.#v()},e.#s)}#v(){if(!this.#e||this.#a)return;let e=this._input,t=e.slice(-1),n=e===``||t===` `||t===`|`,r=/[\w./]/u.test(t);if(!n&&!r)return;let i=this.#e.complete(e);if(i.length===0)return;let a=i[0];!a.startsWith(e)||a===e||r&&i.includes(e)||(this._ghost=a.slice(e.length))}#y(e){let t=e.notes.map(e=>({text:e,kind:`note`}));for(let n of cM(e))t.push({text:`silenced: ${n}`,kind:`gap`});this.#b(t)}#b(t){if(t.length===0)return;let n=[...this._notes];for(let{text:r,kind:i}of t){let t=n.findIndex(e=>e.text===r);t!==-1&&this.#S(n,t),n.push({id:++this.#l,text:r,kind:i,dwell:e.#x(r)})}for(;n.length>e.#u;)this.#S(n,0);for(let e of n)this.#c.has(e.id)||this.#c.set(e.id,setTimeout(()=>this.#w(e.id),e.dwell));this._notes=n}static#x(e){return Math.min(1e4,3200+e.length*55)}#S(e,t){let[n]=e.splice(t,1);this.#C(n.id)}#C(e){let t=this.#c.get(e);t!==void 0&&(clearTimeout(t),this.#c.delete(e))}#w(e){this.#c.delete(e),this._notes=this._notes.filter(t=>t.id!==e)}#T(){for(let e of this.#c.values())clearTimeout(e);this.#c.clear(),this._notes=[]}#E(){this.#n.length!==0&&(this.#r<0?(this.#i=this._input,this.#r=this.#n.length-1):this.#r=Math.max(0,this.#r-1),this._input=this.#n[this.#r])}#D(){if(this.#r<0)return;let e=this.#r+1;e>=this.#n.length?(this.#r=-1,this._input=this.#i,this.#i=``):(this.#r=e,this._input=this.#n[e])}#O=e=>{this._input=e.target.value};#k=e=>{this._input=e,this.#r=-1,this.#i=``,this.focusInput()};#A=()=>{let e=this.renderRoot.getSelection?.()??document.getSelection();e&&!e.isCollapsed||this.focusInput()};render(){return ve`<div class="notes" role="log" aria-atomic="false">${ge(this._notes,e=>e.id,t=>ve`<div class="note ${t.kind===`gap`?`note-gap`:``}" style="${he({"--dwell-out":`${t.dwell-e.#d}ms`})}">${t.text}</div>`)}</div><div class="output" @click="${this.#A}">${this._lines.map(e=>this.#j(e))}</div><form class="form" @submit="${this.#p}" aria-busy="${this._running?`true`:`false`}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?ve`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:ye} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#O}" @keydown="${this.#m}"></div></form>`}#j(e){return e.kind===`banner`?ve`<div class="banner">Virtual shell over the bundle source tree. Try ${e.commands.map((e,t)=>ve`${t>0?`, `:``}\`<span class="cmd" @click="${()=>this.#k(e)}">${e}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:e.kind===`prompt`?ve`<div class="line"><span class="cwd">${e.cwd}</span>${` `}<span class="sigil">$</span>${` `}${e.text}</div>`:e.kind===`stdout`?this.#M(e):e.kind===`stderr`?ve`<pre class="stderr">${e.text}</pre>`:ye}#M(e){if(!e.diff)return ve`<pre class="stdout">${e.text}</pre>`;let t=e.diff.flatMap((e,t)=>{let n=e.kind?ve`<span class="diff-${e.kind}">${e.text}</span>`:e.text;return t===0?[n]:[`
367
+ `,n]});return ve`<pre class="stdout">${t}</pre>`}};customElements.define(`bundle-terminal`,hM);function gM(e,t){let n=document.createElement(`bundle-terminal`);return n.dataset.integrity=t??``,n.sources=e,n}export{gM as createTerminalElement};