sliccy 5.0.1 → 5.2.0

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 (93) hide show
  1. package/README.md +1 -1
  2. package/dist/ui/assets/{account-store-BTIDJ0D4.js → account-store-B9L-iw3_.js} +2 -2
  3. package/dist/ui/assets/{account-store-CMUhavj7.js → account-store-J1i56LXB.js} +2 -2
  4. package/dist/ui/assets/{adobe-BJ8xXfgr.js → adobe-BE4O6RpW.js} +1 -1
  5. package/dist/ui/assets/{adobe-oauth-state-BKLNg5pX.js → adobe-oauth-state-BSzOZOb6.js} +1 -1
  6. package/dist/ui/assets/{adobe-Bfg41Sm0.js → adobe-uU9WScyf.js} +1 -1
  7. package/dist/ui/assets/{agent-message-to-chat-DfH2TOaj.js → agent-message-to-chat-BDsWz4XM.js} +1 -1
  8. package/dist/ui/assets/{apps-lJRD56s5.js → apps-D9vX8Iuh.js} +1 -1
  9. package/dist/ui/assets/{azure-openai-qyHZFjc5.js → azure-openai-BANs3KGr.js} +1 -1
  10. package/dist/ui/assets/{azure-openai-DLJjg2yI.js → azure-openai-D6toPyQ8.js} +1 -1
  11. package/dist/ui/assets/{browser-ukv9lM61.js → browser-D0vICVpZ.js} +50 -45
  12. package/dist/ui/assets/{cdp-z9uzg44m.js → cdp-Ds3-0d7E.js} +2 -2
  13. package/dist/ui/assets/{connect-surface-DCR9Fin6.js → connect-surface-DAC3CNei.js} +1 -1
  14. package/dist/ui/assets/dip-3VX86RoF.js +1 -0
  15. package/dist/ui/assets/{dist-DDGRY8xT.js → dist--TcGqpJG.js} +1 -1
  16. package/dist/ui/assets/{dist-Dh3Yf9I8.js → dist-BWYQOlqM.js} +1 -1
  17. package/dist/ui/assets/{ensure-speech-assets-CZKsXlsO.js → ensure-speech-assets-B-pBwbKb.js} +1 -1
  18. package/dist/ui/assets/esp8266-DEulqnXg.js +1 -0
  19. package/dist/ui/assets/{esptool-operations-PEsKHcvX.js → esptool-operations-CP9wpmtB.js} +2 -2
  20. package/dist/ui/assets/extension-bridge-transport-B4WmKl7n.js +1 -0
  21. package/dist/ui/assets/follower-navigate-watcher-CnHWEu_l.js +1 -0
  22. package/dist/ui/assets/{fs-BFpCPBBZ.js → fs-BMm4juUO.js} +2 -2
  23. package/dist/ui/assets/{fs-BAgteKng.js → fs-CDxFmHhs.js} +1 -1
  24. package/dist/ui/assets/{github-DAbVUH3-.js → github-Bv3awCy-.js} +2 -2
  25. package/dist/ui/assets/{github-copilot-CznXozwK.js → github-copilot-Bo6St-mj.js} +1 -1
  26. package/dist/ui/assets/{github-copilot-7ZJcKEfr.js → github-copilot-EhpEoXT_.js} +1 -1
  27. package/dist/ui/assets/{github-CKJk6KAd.js → github-igAb2Tr3.js} +1 -1
  28. package/dist/ui/assets/handoff-link-ywwq4k0t.js +1 -0
  29. package/dist/ui/assets/{hear-DoOBx2IM.js → hear-CTBETRuZ.js} +1 -1
  30. package/dist/ui/assets/{kernel-worker-C3Zv0cFP.js → kernel-worker-DU2Lsjyz.js} +1103 -1094
  31. package/dist/ui/assets/{kokoro-engine-DvUa426X.js → kokoro-engine-qxvtO16S.js} +1 -1
  32. package/dist/ui/assets/lick-ws-bridge-CAy0-YSl.js +1 -0
  33. package/dist/ui/assets/lick-ws-bridge-D_Q0B4_w.js +1 -0
  34. package/dist/ui/assets/{local-llm-VxY6Rihr.js → local-llm-yvkTurpV.js} +1 -1
  35. package/dist/ui/assets/main-DYwi5YqO.js +24 -0
  36. package/dist/ui/assets/{main-cherry-BRV9Q0tu.js → main-cherry-CpYPaCCM.js} +1 -1
  37. package/dist/ui/assets/{mount-D4sVsAe9.js → mount-BMTmsC-u.js} +1 -1
  38. package/dist/ui/assets/{mount-DfhfmOn6.js → mount-C0n7eObT.js} +2 -2
  39. package/dist/ui/assets/navigation-watcher-BxAAD5To.js +1 -0
  40. package/dist/ui/assets/new-session-BgzUQaQk.js +2 -0
  41. package/dist/ui/assets/{oauth-bootstrap-B6gbcpSf.js → oauth-bootstrap-B35kl1hZ.js} +2 -2
  42. package/dist/ui/assets/{openai-codex-ChP4AOf5.js → openai-codex-BziCxD0k.js} +1 -1
  43. package/dist/ui/assets/{openai-codex-xhF7lncq.js → openai-codex-CNXAYokU.js} +1 -1
  44. package/dist/ui/assets/page-follower-tray-tXYeooU8.js +4 -0
  45. package/dist/ui/assets/{panel-rpc-handlers-B_UznVxB.js → panel-rpc-handlers-Cxg9OE7o.js} +1 -1
  46. package/dist/ui/assets/{provider-CvyNCTJa.js → provider-CzdDndd-.js} +2 -2
  47. package/dist/ui/assets/{provider-Co8OCo7w.js → provider-DOAeQgJY.js} +1 -1
  48. package/dist/ui/assets/provider-store-access-02kN2Pzi.js +1 -0
  49. package/dist/ui/assets/provider-store-access-DOOb1KbA.js +1 -0
  50. package/dist/ui/assets/{providers-CU0-WZx1.js → providers-Kx_BEFqJ.js} +1 -1
  51. package/dist/ui/assets/{quick-llm-Bsr48RSH.js → quick-llm-BW-brmSb.js} +1 -1
  52. package/dist/ui/assets/{remote-terminal-view-Qv9yhXQm.js → remote-terminal-view-DMnqOfIb.js} +1 -1
  53. package/dist/ui/assets/session-freezer-D6kbwY6i.js +1 -0
  54. package/dist/ui/assets/{speak-CCE3xUWF.js → speak-B8c3oh9Y.js} +1 -1
  55. package/dist/ui/assets/{sprinkle-manager-8YNPbXXp.js → sprinkle-manager-BpLedeCo.js} +1 -1
  56. package/dist/ui/assets/{store-Dd5SZXO7.js → store-Ccl5ODaE.js} +1 -1
  57. package/dist/ui/assets/{sudo-D-B_nWdG.js → sudo-D6_01n3k.js} +1 -1
  58. package/dist/ui/assets/{transformers-env-5eefnAKA.js → transformers-env-D2tn9gLL.js} +1 -1
  59. package/dist/ui/assets/tray-leader-DGFajpwM.js +1 -0
  60. package/dist/ui/assets/{tray-leave-runtime-5JqY7-Mf.js → tray-leave-runtime-taK1Ebp7.js} +1 -1
  61. package/dist/ui/assets/{upgrade-detection-CpQEZh6h.js → upgrade-detection-DrfEt3Mi.js} +1 -1
  62. package/dist/ui/assets/{wc-attach-CJB9Bygt.js → wc-attach-DBF_z5mw.js} +2 -2
  63. package/dist/ui/assets/{wc-detached--iRc1rNo.js → wc-detached-Wt3lzK1R.js} +1 -1
  64. package/dist/ui/assets/{wc-extension-f-Y8gbFv.js → wc-extension-DfX8q6Ih.js} +2 -2
  65. package/dist/ui/assets/wc-follower-BVeqP5KF.js +2 -0
  66. package/dist/ui/assets/wc-live-DqgXrP0F.js +253 -0
  67. package/dist/ui/assets/wc-nav-6aYy7HCy.js +2 -0
  68. package/dist/ui/assets/{wc-onboarding-CdQ6tw8X.js → wc-onboarding-CEjOIdK5.js} +2 -2
  69. package/dist/ui/assets/{wc-permissions-mVh0SOdZ.js → wc-permissions-Wqap3kzM.js} +2 -2
  70. package/dist/ui/assets/{wc-placeholder-DD8_MSOp.js → wc-placeholder-CHDb9Kuo.js} +3 -3
  71. package/dist/ui/assets/{wc-settings-7Kbtrg5p.js → wc-settings-qlpR6Q6T.js} +2 -2
  72. package/dist/ui/assets/{wc-shell-PklxeZ6D.js → wc-shell-DTsW2ra1.js} +4 -4
  73. package/dist/ui/assets/{wc-sprinkles-ClY0Bpba.js → wc-sprinkles-D_fwWOq8.js} +2 -2
  74. package/dist/ui/assets/wc-tray-2mdLomRm.js +2 -0
  75. package/dist/ui/assets/{whisper-engine-BonGdnOP.js → whisper-engine-CvJzjL-a.js} +1 -1
  76. package/dist/ui/assets/{xai-grok-x_rql0uW.js → xai-grok-BoTmSfDH.js} +1 -1
  77. package/dist/ui/assets/{xai-grok-Cpf3Hypg.js → xai-grok-U2afiu3-.js} +1 -1
  78. package/dist/ui/electron-overlay-entry.js +51 -51
  79. package/dist/ui/index.html +2 -2
  80. package/dist/ui/packages/webapp/index.html +2 -2
  81. package/package.json +1 -1
  82. package/dist/ui/assets/dip-B9XK8NtT.js +0 -1
  83. package/dist/ui/assets/esp8266-Cj1Ntxw5.js +0 -1
  84. package/dist/ui/assets/extension-bridge-transport-DYOF2OYC.js +0 -1
  85. package/dist/ui/assets/lick-ws-bridge-DodKv_gI.js +0 -1
  86. package/dist/ui/assets/main-BDgWldfd.js +0 -24
  87. package/dist/ui/assets/new-session-B2rDFglN.js +0 -2
  88. package/dist/ui/assets/provider-store-access-DXSPPtDF.js +0 -1
  89. package/dist/ui/assets/provider-store-access-DpQ0Ni0t.js +0 -1
  90. package/dist/ui/assets/session-freezer-C4fFg5qr.js +0 -1
  91. package/dist/ui/assets/wc-live-Cmyb8YU6.js +0 -253
  92. package/dist/ui/assets/wc-nav-Btf9Z40L.js +0 -2
  93. package/dist/ui/assets/wc-tray-MDjEKWqg.js +0 -5
@@ -68,7 +68,7 @@ import{r as e,t}from"./chunk-aKtaBQYM.js";t((e=>{(function(){var t={not_string:/
68
68
 
69
69
  `.substring(0,i)+r}function Pn(e){return e!=null&&(typeof e==`string`||e.nodeType&&(e.nodeType===1||e.nodeType===9||e.nodeType===11))}var Fn=Object.defineProperty,In=(t=>typeof e<`u`?e:typeof Proxy<`u`?new Proxy(t,{get:(t,n)=>(typeof e<`u`?e:t)[n]}):t)(function(t){if(typeof e<`u`)return e.apply(this,arguments);throw Error(`Dynamic require of "`+t+`" is not supported`)}),g=(e,t)=>()=>(e&&(t=e(e=0)),t),_=(e,t)=>{for(var n in t)Fn(e,n,{get:t[n],enumerable:!0})};function Ln(){let e=[{prop:`Function`,target:globalThis,violationType:`function_constructor`,strategy:`throw`,reason:`Function constructor allows arbitrary code execution`},{prop:`eval`,target:globalThis,violationType:`eval`,strategy:`throw`,reason:`eval() allows arbitrary code execution`},{prop:`setTimeout`,target:globalThis,violationType:`setTimeout`,strategy:`throw`,reason:`setTimeout with string argument allows code execution`},{prop:`setInterval`,target:globalThis,violationType:`setInterval`,strategy:`throw`,reason:`setInterval with string argument allows code execution`},{prop:`setImmediate`,target:globalThis,violationType:`setImmediate`,strategy:`throw`,reason:`setImmediate could be used to escape sandbox context`},{prop:`env`,target:process,violationType:`process_env`,strategy:`throw`,reason:`process.env could leak sensitive environment variables`,allowedKeys:new Set([`NODE_V8_COVERAGE`,`NODE_DEBUG`,`NODE_DEBUG_NATIVE`,`NODE_COMPILE_CACHE`,`WATCH_REPORT_DEPENDENCIES`,`FORCE_COLOR`,`DEBUG`,`UNDICI_NO_FG`,`JEST_WORKER_ID`,`__MINIMATCH_TESTING_PLATFORM__`,`LOG_TOKENS`,`LOG_STREAM`])},{prop:`binding`,target:process,violationType:`process_binding`,strategy:`throw`,reason:`process.binding provides access to native Node.js modules`},{prop:`_linkedBinding`,target:process,violationType:`process_binding`,strategy:`throw`,reason:`process._linkedBinding provides access to native Node.js modules`},{prop:`dlopen`,target:process,violationType:`process_dlopen`,strategy:`throw`,reason:`process.dlopen allows loading native addons`},{prop:`getBuiltinModule`,target:process,violationType:`process_get_builtin_module`,strategy:`throw`,reason:`process.getBuiltinModule allows loading native Node.js modules (fs, child_process, vm)`},{prop:`exit`,target:process,violationType:`process_exit`,strategy:`throw`,reason:`process.exit could terminate the interpreter`},{prop:`abort`,target:process,violationType:`process_exit`,strategy:`throw`,reason:`process.abort could crash the interpreter`},{prop:`kill`,target:process,violationType:`process_kill`,strategy:`throw`,reason:`process.kill could signal other processes`},{prop:`setuid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setuid could escalate privileges`},{prop:`setgid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setgid could escalate privileges`},{prop:`seteuid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.seteuid could escalate effective user privileges`},{prop:`setegid`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setegid could escalate effective group privileges`},{prop:`initgroups`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.initgroups could modify supplementary group IDs`},{prop:`setgroups`,target:process,violationType:`process_setuid`,strategy:`throw`,reason:`process.setgroups could modify supplementary group IDs`},{prop:`umask`,target:process,violationType:`process_umask`,strategy:`throw`,reason:`process.umask could modify file creation permissions`},{prop:`argv`,target:process,violationType:`process_argv`,strategy:`throw`,reason:`process.argv may contain secrets in CLI arguments`},{prop:`cwd`,target:process,violationType:`process_chdir`,strategy:`throw`,reason:`process.cwd could disclose real host working directory path`},{prop:`chdir`,target:process,violationType:`process_chdir`,strategy:`throw`,reason:`process.chdir could confuse the interpreter's CWD tracking`},{prop:`report`,target:process,violationType:`process_report`,strategy:`throw`,reason:`process.report could disclose full environment, host paths, and system info`},{prop:`loadEnvFile`,target:process,violationType:`process_env`,strategy:`throw`,reason:`process.loadEnvFile could load env files bypassing env proxy`},{prop:`setUncaughtExceptionCaptureCallback`,target:process,violationType:`process_exception_handler`,strategy:`throw`,reason:`setUncaughtExceptionCaptureCallback could intercept security errors`},{prop:`send`,target:process,violationType:`process_send`,strategy:`throw`,reason:`process.send could communicate with parent process in IPC contexts`},{prop:`channel`,target:process,violationType:`process_channel`,strategy:`throw`,reason:`process.channel could access IPC channel to parent process`},{prop:`cpuUsage`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.cpuUsage could enable timing side-channel attacks`},{prop:`memoryUsage`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.memoryUsage could enable timing side-channel attacks`},{prop:`hrtime`,target:process,violationType:`process_timing`,strategy:`throw`,reason:`process.hrtime could enable timing side-channel attacks`},{prop:`WeakRef`,target:globalThis,violationType:`weak_ref`,strategy:`throw`,reason:`WeakRef could be used to leak references outside sandbox`},{prop:`FinalizationRegistry`,target:globalThis,violationType:`finalization_registry`,strategy:`throw`,reason:`FinalizationRegistry could be used to leak references outside sandbox`},{prop:`Reflect`,target:globalThis,violationType:`reflect`,strategy:`freeze`,reason:`Reflect provides introspection capabilities`},{prop:`Proxy`,target:globalThis,violationType:`proxy`,strategy:`throw`,reason:`Proxy allows intercepting and modifying object behavior`},{prop:`WebAssembly`,target:globalThis,violationType:`webassembly`,strategy:`throw`,reason:`WebAssembly allows executing arbitrary compiled code`},{prop:`SharedArrayBuffer`,target:globalThis,violationType:`shared_array_buffer`,strategy:`throw`,reason:`SharedArrayBuffer could enable side-channel communication or timing attacks`},{prop:`Atomics`,target:globalThis,violationType:`atomics`,strategy:`throw`,reason:`Atomics could enable side-channel communication or timing attacks`},{prop:`performance`,target:globalThis,violationType:`performance_timing`,strategy:`throw`,reason:`performance.now() provides sub-millisecond timing for side-channel attacks`},{prop:`stdout`,target:process,violationType:`process_stdout`,strategy:`throw`,reason:`process.stdout could bypass interpreter output to write to host stdout`},{prop:`stderr`,target:process,violationType:`process_stderr`,strategy:`throw`,reason:`process.stderr could bypass interpreter output to write to host stderr`},{prop:`__defineGetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__defineGetter__ allows prototype pollution via getter injection`},{prop:`__defineSetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__defineSetter__ allows prototype pollution via setter injection`},{prop:`__lookupGetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__lookupGetter__ enables introspection for prototype pollution attacks`},{prop:`__lookupSetter__`,target:Object.prototype,violationType:`prototype_mutation`,strategy:`throw`,reason:`__lookupSetter__ enables introspection for prototype pollution attacks`},{prop:`JSON`,target:globalThis,violationType:`json_mutation`,strategy:`freeze`,reason:`Freeze JSON to prevent mutation of parsing/serialization`},{prop:`Math`,target:globalThis,violationType:`math_mutation`,strategy:`freeze`,reason:`Freeze Math to prevent mutation of math utilities`}];try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&e.push({prop:`constructor`,target:Object.getPrototypeOf(async()=>{}),violationType:`async_function_constructor`,strategy:`throw`,reason:`AsyncFunction constructor allows arbitrary async code execution`})}catch{}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&e.push({prop:`constructor`,target:Object.getPrototypeOf(function*(){}),violationType:`generator_function_constructor`,strategy:`throw`,reason:`GeneratorFunction constructor allows arbitrary generator code execution`})}catch{}try{let t=Object.getPrototypeOf(async function*(){}).constructor;t&&t!==Function&&t!==Object.getPrototypeOf(async()=>{}).constructor&&e.push({prop:`constructor`,target:Object.getPrototypeOf(async function*(){}),violationType:`async_generator_function_constructor`,strategy:`throw`,reason:`AsyncGeneratorFunction constructor allows arbitrary async generator code execution`})}catch{}return e.filter(e=>{try{return e.target[e.prop]!==void 0}catch{return!1}})}var Rn=g(()=>{});function zn(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}function Bn(e,t,...n){return y.run(e,()=>t(...n))}function Vn(e){return e===void 0?{...Kn,enabled:!1}:typeof e==`boolean`?{...Kn,enabled:e}:{...Kn,...e}}var Hn,Un,Wn,v,y,Gn,Kn,qn,Jn=g(()=>{if(Rn(),Hn=!0,Un=null,!Hn)try{let{AsyncLocalStorage:e}=In(`node:async_hooks`);Un=e}catch{}Wn=`
70
70
 
71
- This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,v=class extends Error{violation;constructor(e,t){super(e+Wn),this.violation=t,this.name=`SecurityViolationError`}},y=!Hn&&Un?new Un:null,Gn=1e3,Kn={enabled:!0,auditMode:!1},qn=class e{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(t){let n=Vn(t);if(!e.instance)e.instance=new e(n);else{let t=e.instance.config;if(n.enabled!==t.enabled||n.auditMode!==t.auditMode)throw Error(`DefenseInDepthBox config conflict: requested {enabled: ${n.enabled}, auditMode: ${n.auditMode}} but singleton already has {enabled: ${t.enabled}, auditMode: ${t.auditMode}}. All Bash instances must use the same defense-in-depth security settings, or call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return e.instance}static resetInstance(){e.instance&&=(e.instance.forceDeactivate(),null),e.trustedExecutionDepth.clear()}static isInSandboxedContext(){return y?y?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(y)return y?.getStore()?.executionId}static enterTrustedScope(t){let n=e.trustedExecutionDepth.get(t)??0;e.trustedExecutionDepth.set(t,n+1)}static leaveTrustedScope(t){let n=e.trustedExecutionDepth.get(t);if(n){if(n===1){e.trustedExecutionDepth.delete(t);return}e.trustedExecutionDepth.set(t,n-1)}}static isTrustedScopeActive(t){return t?(e.trustedExecutionDepth.get(t)??0)>0:!1}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}getPreferredActiveExecutionId(){if(this.activeExecutionIds.size!==0)for(let e of this.activeExecutionIds)return e}static bindCurrentContext(t){if(!y)return t;let n=e.instance,r=y.getStore(),i=r?.sandboxActive===!0?r.executionId:n?.getPreferredActiveExecutionId();if(!i)return t;let a=n?.getCachedContext(i)??{sandboxActive:!0,executionId:i};return((...n)=>{let r=e.instance;if(!(r&&!r.isExecutionIdActive(i)&&(r.recordViolation(`bound_callback_after_deactivate`,`bound callback`,`Bound callback blocked after originating execution was deactivated`),!r.config.auditMode)))return Bn(a,t,...n)})}isEnabled(){return this.config.enabled===!0&&y!==null&&!Hn}updateConfig(e){this.config={...this.config,...e}}activate(){if(Hn||!this.config.enabled||!y){let e=zn(),t=!1;return{run:e=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):e(),deactivate:()=>{t=!0},executionId:e}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let e=zn(),t=!1;return{run:n=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):(this.activeExecutionIds.add(e),y.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(t){if(!y)return t();let n=y.getStore();if(!n)return t();let{executionId:r}=n;return y.run({...n,trusted:!0},()=>{e.enterTrustedScope(r);try{let n=t();return typeof n==`object`&&n&&`finally`in n&&typeof n.finally==`function`?n.finally(()=>{e.leaveTrustedScope(r)}):(e.leaveTrustedScope(r),n)}catch(t){throw e.leaveTrustedScope(r),t}})}static async runTrustedAsync(t){if(!y)return t();let n=y.getStore();if(!n)return t();let{executionId:r}=n;return y.run({...n,trusted:!0},async()=>{e.enterTrustedScope(r);try{return await t()}finally{e.leaveTrustedScope(r)}})}shouldBlock(){if(Hn||this.config.auditMode||!y)return!1;let t=y?.getStore();return!(t?.sandboxActive!==!0||t.trusted||e.isTrustedScopeActive(t.executionId))}recordViolation(e,t,n){let r={timestamp:Date.now(),type:e,message:n,path:t,stack:Error().stack,executionId:y?.getStore()?.executionId};if(this.violations.length<Gn&&this.violations.push(r),this.config.onViolation)try{this.config.onViolation(r)}catch(e){console.debug(`[DefenseInDepthBox] onViolation callback threw:`,e instanceof Error?e.message:e)}return r}createBlockingProxy(e,t,n){let r=this;return new Proxy(e,{apply(e,i,a){if(r.shouldBlock()){let e=`${t} is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}return r.config.auditMode&&y?.getStore()?.sandboxActive===!0&&r.recordViolation(n,t,`${t} called (audit mode)`),Reflect.apply(e,i,a)},construct(e,i,a){if(r.shouldBlock()){let e=`${t} constructor is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}return r.config.auditMode&&y?.getStore()?.sandboxActive===!0&&r.recordViolation(n,t,`${t} constructor called (audit mode)`),Reflect.construct(e,i,a)}})}createBlockingObjectProxy(e,t,n,r){let i=this;return new Proxy(e,{get(e,a,o){if(i.shouldBlock()){if(r&&typeof a==`string`&&r.has(a))return Reflect.get(e,a,o);let s=`${t}.${String(a)}`,c=`${s} is blocked during script execution`,l=i.recordViolation(n,s,c);throw new v(c,l)}if(i.config.auditMode&&y?.getStore()?.sandboxActive===!0){let e=`${t}.${String(a)}`;i.recordViolation(n,e,`${e} accessed (audit mode)`)}return Reflect.get(e,a,o)},set(e,r,a,o){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} modification is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.set(e,r,a,o)},ownKeys(e){if(i.shouldBlock()){let e=`${t} enumeration is blocked during script execution`,r=i.recordViolation(n,t,e);throw new v(e,r)}return Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} descriptor access is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.getOwnPropertyDescriptor(e,r)},has(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} existence check is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.has(e,r)},deleteProperty(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} deletion is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.deleteProperty(e,r)},setPrototypeOf(e,r){if(i.shouldBlock()){let e=`${t} setPrototypeOf is blocked during script execution`,r=i.recordViolation(n,t,e);throw new v(e,r)}return Reflect.setPrototypeOf(e,r)},defineProperty(e,r,a){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} defineProperty is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.defineProperty(e,r,a)}})}applyPatches(){this.patchFailures=[];let e=Ln(),t=new Set([`process_send`,`process_channel`,`process_stdout`,`process_stderr`]);for(let n of e)t.has(n.violationType)||this.applyPatch(n);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.lockWellKnownSymbols(),this.protectProxyRevocable();let n=[`Function.prototype.constructor`,`Module._load`],r=this.patchFailures.filter(e=>n.includes(e));if(r.length>0)throw this.restorePatches(),Error(`DefenseInDepthBox: critical patches failed: ${r.join(`, `)}`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,`Function.prototype.constructor`,`function_constructor`);try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`AsyncFunction.prototype.constructor`,`async_function_constructor`)}catch(e){this.patchFailures.push(`AsyncFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`GeneratorFunction.prototype.constructor`,`generator_function_constructor`)}catch(e){this.patchFailures.push(`GeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,`AsyncGeneratorFunction.prototype.constructor`,`async_generator_function_constructor`)}catch(e){this.patchFailures.push(`AsyncGeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,`prepareStackTrace`);this.originalDescriptors.push({target:Error,prop:`prepareStackTrace`,descriptor:t});let n=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(t){if(e.shouldBlock()){let t=`Error.prepareStackTrace modification is blocked during script execution`,n=e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,t);throw new v(t,n)}e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,`Error.prepareStackTrace set (audit mode)`),n=t},configurable:!0})}catch(e){this.patchFailures.push(`Error.prepareStackTrace`),console.debug(`[DefenseInDepthBox] Could not protect Error.prepareStackTrace:`,e instanceof Error?e.message:e)}}protectPromiseThen(){let e=this;try{let t=function(...e){return y.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation(`promise_then_after_deactivate`,`Promise.then`,`Promise.then callback is blocked after defense deactivation`),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,e);if(this.kind===`fulfilled`)return e[0];throw e[0]}return Reflect.apply(this.cb,void 0,e)})},n=Object.getOwnPropertyDescriptor(Promise.prototype,`then`);this.originalDescriptors.push({target:Promise.prototype,prop:`then`,descriptor:n});let r=n?.value;if(typeof r!=`function`)return;Object.defineProperty(Promise.prototype,"then",{value:function(n,i){if(!y)return Reflect.apply(r,this,[n,i]);let a=y.getStore(),o=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!o)return Reflect.apply(r,this,[n,i]);let s=e.getCachedContext(o),c=(n,r)=>typeof n==`function`?t.bind({box:e,executionId:o,captured:s,cb:n,kind:r}):n;return Reflect.apply(r,this,[c(n,`fulfilled`),c(i,`rejected`)])},writable:!0,configurable:!0})}catch(e){this.patchFailures.push(`Promise.prototype.then`),console.debug(`[DefenseInDepthBox] Could not protect Promise.prototype.then:`,e instanceof Error?e.message:e)}}patchPrototypeConstructor(e,t,n){let r=this;try{let i=Object.getOwnPropertyDescriptor(e,`constructor`);this.originalDescriptors.push({target:e,prop:`constructor`,descriptor:i});let a=i?.value;Object.defineProperty(e,"constructor",{get(){if(r.shouldBlock()){let e=`${t} access is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}return r.config.auditMode&&y?.getStore()?.sandboxActive===!0&&r.recordViolation(n,t,`${t} accessed (audit mode)`),a},set(e){if(r.shouldBlock()){let e=`${t} modification is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}Object.defineProperty(this,"constructor",{value:e,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,e instanceof Error?e.message:e)}}protectProcessMainModule(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`mainModule`);this.originalDescriptors.push({target:process,prop:`mainModule`,descriptor:t});let n=t?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let t=`process.mainModule access is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new v(t,n)}return e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`process_main_module`,`process.mainModule`,`process.mainModule accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.mainModule modification is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new v(t,n)}Object.defineProperty(process,"mainModule",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.mainModule`),console.debug(`[DefenseInDepthBox] Could not protect process.mainModule:`,e instanceof Error?e.message:e)}}protectProcessExecPath(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`execPath`);this.originalDescriptors.push({target:process,prop:`execPath`,descriptor:t});let n=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let t=`process.execPath access is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new v(t,n)}return e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`process_exec_path`,`process.execPath`,`process.execPath accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.execPath modification is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new v(t,n)}Object.defineProperty(process,"execPath",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.execPath`),console.debug(`[DefenseInDepthBox] Could not protect process.execPath:`,e instanceof Error?e.message:e)}}lockWellKnownSymbols(){let e=(e,t)=>{try{let n=Object.getOwnPropertyDescriptor(e,t);if(n?.configurable){if(`value`in n){Object.defineProperty(e,t,{...n,configurable:!1,writable:!1});return}Object.defineProperty(e,t,{...n,configurable:!1})}}catch{}};for(let t of[Array,Map,Set,RegExp,Promise])e(t,Symbol.species);for(let t of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(t,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let t of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,t);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let t of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(t,Symbol.toStringTag);try{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);this.originalDescriptors.push({target:Error,prop:`stackTraceLimit`,descriptor:e}),Object.defineProperty(Error,"stackTraceLimit",{value:Error.stackTraceLimit,writable:!1,configurable:!0})}catch{}}protectProxyRevocable(){let e=this;try{let t=Proxy.revocable;if(typeof t!=`function`)return;let n=Object.getOwnPropertyDescriptor(Proxy,`revocable`);this.originalDescriptors.push({target:Proxy,prop:`revocable`,descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(n,r){if(e.shouldBlock()){let t=`Proxy.revocable is blocked during script execution`,n=e.recordViolation(`proxy`,`Proxy.revocable`,t);throw new v(t,n)}return e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`proxy`,`Proxy.revocable`,`Proxy.revocable called (audit mode)`),t(n,r)},writable:!1,configurable:!0})}catch(e){this.patchFailures.push(`Proxy.revocable`),console.debug(`[DefenseInDepthBox] Could not protect Proxy.revocable:`,e instanceof Error?e.message:e)}}protectDynamicImport(){if(!(Hn||e.importHooksRegistered))try{let t=this,n=In(`node:module`),r=new Set;for(let e of n.builtinModules??[]){let t=e.startsWith(`node:`)?e.slice(5):e;r.add(t);let n=t.indexOf(`/`);n>0&&r.add(t.slice(0,n))}let i=e=>{if(e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/`)||e.startsWith(`file:`)||e.startsWith(`data:`)||e.startsWith(`blob:`)||e.startsWith(`http:`)||e.startsWith(`https:`))return!1;let t=e.startsWith(`node:`)?e.slice(5):e;if(!t)return!1;if(typeof n.isBuiltin==`function`&&n.isBuiltin(t)||r.has(t))return!0;let i=t.indexOf(`/`);return i>0&&r.has(t.slice(0,i))},a=()=>{let n=y?.getStore();return t.config.auditMode===!0&&n?.sandboxActive===!0&&n.trusted!==!0&&!e.isTrustedScopeActive(n.executionId)};if(typeof n.registerHooks==`function`){n.registerHooks({resolve(e,n,r){if(e.startsWith(`data:`)||e.startsWith(`blob:`))throw Error(`dynamic import of ${e.startsWith(`data:`)?`data:`:`blob:`} URLs is blocked by defense-in-depth`);if(i(e)){let n=`import(${e})`,r=`dynamic import of Node.js builtin '${e}' is blocked during script execution`;if(t.shouldBlock()){let e=t.recordViolation(`dynamic_import_builtin`,n,r);throw new v(r,e)}a()&&t.recordViolation(`dynamic_import_builtin`,n,`dynamic import of Node.js builtin '${e}' called (audit mode)`)}return r(e,n)}}),e.importHooksRegistered=!0;return}if(typeof n.register==`function`){let t=[`export async function resolve(specifier, context, nextResolve) {`,` if (specifier.startsWith("data:") || specifier.startsWith("blob:")) {`,` throw new Error("dynamic import of " + (specifier.startsWith("data:") ? "data:" : "blob:") + " URLs is blocked by defense-in-depth");`,` }`,` return nextResolve(specifier, context);`,`}`].join(`
71
+ This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,v=class extends Error{violation;constructor(e,t){super(e+Wn),this.violation=t,this.name=`SecurityViolationError`}},y=!Hn&&Un?new Un:null,Gn=1e3,Kn={enabled:!0,auditMode:!1},qn=class e{static instance=null;static importHooksRegistered=!1;static trustedExecutionDepth=new Map;config;refCount=0;patchFailures=[];activeExecutionIds=new Set;contextCache=new Map;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(e){this.config=e}static getInstance(t){let n=Vn(t);if(!e.instance)e.instance=new e(n);else{let t=e.instance.config;if(n.enabled!==t.enabled||n.auditMode!==t.auditMode)throw Error(`DefenseInDepthBox config conflict: requested {enabled: ${n.enabled}, auditMode: ${n.auditMode}} but singleton already has {enabled: ${t.enabled}, auditMode: ${t.auditMode}}. All Bash instances must use the same defense-in-depth security settings, or call DefenseInDepthBox.resetInstance() between incompatible configurations.`)}return e.instance}static resetInstance(){e.instance&&=(e.instance.forceDeactivate(),null),e.trustedExecutionDepth.clear()}static isInSandboxedContext(){return y?y?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(y)return y?.getStore()?.executionId}static enterTrustedScope(t){let n=e.trustedExecutionDepth.get(t)??0;e.trustedExecutionDepth.set(t,n+1)}static leaveTrustedScope(t){let n=e.trustedExecutionDepth.get(t);if(n){if(n===1){e.trustedExecutionDepth.delete(t);return}e.trustedExecutionDepth.set(t,n-1)}}static isTrustedScopeActive(t){return t?(e.trustedExecutionDepth.get(t)??0)>0:!1}isExecutionIdActive(e){return this.activeExecutionIds.has(e)}getCachedContext(e){let t=this.contextCache.get(e);return t||(t={sandboxActive:!0,executionId:e},this.contextCache.set(e,t)),t}getPreferredActiveExecutionId(){if(this.activeExecutionIds.size!==0)for(let e of this.activeExecutionIds)return e}static bindCurrentContext(t){if(!y)return t;let n=e.instance,r=y.getStore(),i=r?.sandboxActive===!0?r.executionId:n?.getPreferredActiveExecutionId();if(!i)return t;let a=n?.getCachedContext(i)??{sandboxActive:!0,executionId:i};return((...n)=>{let r=e.instance;if(!(r&&!r.isExecutionIdActive(i)&&(r.recordViolation(`bound_callback_after_deactivate`,`bound callback`,`Bound callback blocked after originating execution was deactivated`),!r.config.auditMode)))return Bn(a,t,...n)})}isEnabled(){return this.config.enabled===!0&&y!==null&&!Hn}updateConfig(e){this.config={...this.config,...e}}activate(){if(Hn||!this.config.enabled||!y){let e=zn(),t=!1;return{run:e=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):e(),deactivate:()=>{t=!0},executionId:e}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let e=zn(),t=!1;return{run:n=>t?Promise.reject(Error(`DefenseInDepthBox handle is deactivated and cannot run new work`)):(this.activeExecutionIds.add(e),y.run({sandboxActive:!0,executionId:e},n)),deactivate:()=>{t||(t=!0,this.activeExecutionIds.delete(e),this.contextCache.delete(e),this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0))},executionId:e}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.activeExecutionIds.clear(),this.contextCache.clear(),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}getPatchFailures(){return[...this.patchFailures]}clearViolations(){this.violations=[]}getPathForTarget(e,t){return e===globalThis?`globalThis.${t}`:e===process?`process.${t}`:e===Error?`Error.${t}`:e===Function.prototype?`Function.prototype.${t}`:e===Object.prototype?`Object.prototype.${t}`:`<object>.${t}`}static runTrusted(t){if(!y)return t();let n=y.getStore();if(!n)return t();let{executionId:r}=n;return y.run({...n,trusted:!0},()=>{e.enterTrustedScope(r);try{let n=t();return typeof n==`object`&&n&&`finally`in n&&typeof n.finally==`function`?n.finally(()=>{e.leaveTrustedScope(r)}):(e.leaveTrustedScope(r),n)}catch(t){throw e.leaveTrustedScope(r),t}})}static async runTrustedAsync(t){if(!y)return t();let n=y.getStore();if(!n)return t();let{executionId:r}=n;return y.run({...n,trusted:!0},async()=>{e.enterTrustedScope(r);try{return await t()}finally{e.leaveTrustedScope(r)}})}shouldBlock(){if(Hn||this.config.auditMode||!y)return!1;let t=y?.getStore();return!(t?.sandboxActive!==!0||t.trusted||e.isTrustedScopeActive(t.executionId))}recordViolation(e,t,n){let r={timestamp:Date.now(),type:e,message:n,path:t,stack:Error().stack,executionId:y?.getStore()?.executionId};if(this.violations.length<Gn&&this.violations.push(r),this.config.onViolation)try{this.config.onViolation(r)}catch(e){console.debug(`[DefenseInDepthBox] onViolation callback threw:`,e instanceof Error?e.message:e)}return r}createBlockingProxy(e,t,n){let r=this;return new Proxy(e,{apply(e,i,a){if(r.shouldBlock()){let e=`${t} is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}return r.config.auditMode&&y?.getStore()?.sandboxActive===!0&&r.recordViolation(n,t,`${t} called (audit mode)`),Reflect.apply(e,i,a)},construct(e,i,a){if(r.shouldBlock()){let e=`${t} constructor is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}return r.config.auditMode&&y?.getStore()?.sandboxActive===!0&&r.recordViolation(n,t,`${t} constructor called (audit mode)`),Reflect.construct(e,i,a)}})}createBlockingObjectProxy(e,t,n,r){let i=this;return new Proxy(e,{get(e,a,o){if(i.shouldBlock()){if(r&&typeof a==`string`&&r.has(a))return Reflect.get(e,a,o);let s=`${t}.${String(a)}`,c=`${s} is blocked during script execution`,l=i.recordViolation(n,s,c);throw new v(c,l)}if(i.config.auditMode&&y?.getStore()?.sandboxActive===!0){let e=`${t}.${String(a)}`;i.recordViolation(n,e,`${e} accessed (audit mode)`)}return Reflect.get(e,a,o)},set(e,r,a,o){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} modification is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return t===`process.env`&&r===`DEBUG`?Reflect.set(e,r,a):Reflect.set(e,r,a,o)},ownKeys(e){if(i.shouldBlock()){let e=`${t} enumeration is blocked during script execution`,r=i.recordViolation(n,t,e);throw new v(e,r)}return Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} descriptor access is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.getOwnPropertyDescriptor(e,r)},has(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} existence check is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.has(e,r)},deleteProperty(e,r){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} deletion is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.deleteProperty(e,r)},setPrototypeOf(e,r){if(i.shouldBlock()){let e=`${t} setPrototypeOf is blocked during script execution`,r=i.recordViolation(n,t,e);throw new v(e,r)}return Reflect.setPrototypeOf(e,r)},defineProperty(e,r,a){if(i.shouldBlock()){let e=`${t}.${String(r)}`,a=`${e} defineProperty is blocked during script execution`,o=i.recordViolation(n,e,a);throw new v(a,o)}return Reflect.defineProperty(e,r,a)}})}applyPatches(){this.patchFailures=[];let e=Ln(),t=new Set([`process_send`,`process_channel`,`process_stdout`,`process_stderr`]);for(let n of e)t.has(n.violationType)||this.applyPatch(n);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectPromiseThen(),this.protectDynamicImport(),this.protectModuleLoad(),this.protectModuleResolveFilename(),this.protectProcessMainModule(),this.protectProcessExecPath(),this.lockWellKnownSymbols(),this.protectProxyRevocable();let n=[`Function.prototype.constructor`,`Module._load`],r=this.patchFailures.filter(e=>n.includes(e));if(r.length>0)throw this.restorePatches(),Error(`DefenseInDepthBox: critical patches failed: ${r.join(`, `)}`)}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,`Function.prototype.constructor`,`function_constructor`);try{let e=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`AsyncFunction.prototype.constructor`,`async_function_constructor`)}catch(e){this.patchFailures.push(`AsyncFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(function*(){}).constructor;e&&e!==Function&&this.patchPrototypeConstructor(e.prototype,`GeneratorFunction.prototype.constructor`,`generator_function_constructor`)}catch(e){this.patchFailures.push(`GeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}try{let e=Object.getPrototypeOf(async function*(){}).constructor,t=Object.getPrototypeOf(async()=>{}).constructor;e&&e!==Function&&e!==t&&this.patchPrototypeConstructor(e.prototype,`AsyncGeneratorFunction.prototype.constructor`,`async_generator_function_constructor`)}catch(e){this.patchFailures.push(`AsyncGeneratorFunction.prototype.constructor`),console.debug(`[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:`,e instanceof Error?e.message:e)}}protectErrorPrepareStackTrace(){let e=this;try{let t=Object.getOwnPropertyDescriptor(Error,`prepareStackTrace`);this.originalDescriptors.push({target:Error,prop:`prepareStackTrace`,descriptor:t});let n=t?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return n},set(t){if(e.shouldBlock()){let t=`Error.prepareStackTrace modification is blocked during script execution`,n=e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,t);throw new v(t,n)}e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`error_prepare_stack_trace`,`Error.prepareStackTrace`,`Error.prepareStackTrace set (audit mode)`),n=t},configurable:!0})}catch(e){this.patchFailures.push(`Error.prepareStackTrace`),console.debug(`[DefenseInDepthBox] Could not protect Error.prepareStackTrace:`,e instanceof Error?e.message:e)}}protectPromiseThen(){let e=this;try{let t=function(...e){return y.run(this.captured,()=>{if(!this.box.isExecutionIdActive(this.executionId)){if(this.box.recordViolation(`promise_then_after_deactivate`,`Promise.then`,`Promise.then callback is blocked after defense deactivation`),this.box.config.auditMode)return Reflect.apply(this.cb,void 0,e);if(this.kind===`fulfilled`)return e[0];throw e[0]}return Reflect.apply(this.cb,void 0,e)})},n=Object.getOwnPropertyDescriptor(Promise.prototype,`then`);this.originalDescriptors.push({target:Promise.prototype,prop:`then`,descriptor:n});let r=n?.value;if(typeof r!=`function`)return;Object.defineProperty(Promise.prototype,"then",{value:function(n,i){if(!y)return Reflect.apply(r,this,[n,i]);let a=y.getStore(),o=a?.sandboxActive===!0&&a.trusted!==!0?a.executionId:void 0;if(!o)return Reflect.apply(r,this,[n,i]);let s=e.getCachedContext(o),c=(n,r)=>typeof n==`function`?t.bind({box:e,executionId:o,captured:s,cb:n,kind:r}):n;return Reflect.apply(r,this,[c(n,`fulfilled`),c(i,`rejected`)])},writable:!0,configurable:!0})}catch(e){this.patchFailures.push(`Promise.prototype.then`),console.debug(`[DefenseInDepthBox] Could not protect Promise.prototype.then:`,e instanceof Error?e.message:e)}}patchPrototypeConstructor(e,t,n){let r=this;try{let i=Object.getOwnPropertyDescriptor(e,`constructor`);this.originalDescriptors.push({target:e,prop:`constructor`,descriptor:i});let a=i?.value;Object.defineProperty(e,"constructor",{get(){if(r.shouldBlock()){let e=`${t} access is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}return r.config.auditMode&&y?.getStore()?.sandboxActive===!0&&r.recordViolation(n,t,`${t} accessed (audit mode)`),a},set(e){if(r.shouldBlock()){let e=`${t} modification is blocked during script execution`,i=r.recordViolation(n,t,e);throw new v(e,i)}Object.defineProperty(this,"constructor",{value:e,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(t),console.debug(`[DefenseInDepthBox] Could not patch ${t}:`,e instanceof Error?e.message:e)}}protectProcessMainModule(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`mainModule`);this.originalDescriptors.push({target:process,prop:`mainModule`,descriptor:t});let n=t?.value;n!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(e.shouldBlock()){let t=`process.mainModule access is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new v(t,n)}return e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`process_main_module`,`process.mainModule`,`process.mainModule accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.mainModule modification is blocked during script execution`,n=e.recordViolation(`process_main_module`,`process.mainModule`,t);throw new v(t,n)}Object.defineProperty(process,"mainModule",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.mainModule`),console.debug(`[DefenseInDepthBox] Could not protect process.mainModule:`,e instanceof Error?e.message:e)}}protectProcessExecPath(){if(typeof process>`u`)return;let e=this;try{let t=Object.getOwnPropertyDescriptor(process,`execPath`);this.originalDescriptors.push({target:process,prop:`execPath`,descriptor:t});let n=t?.value??process.execPath;Object.defineProperty(process,"execPath",{get(){if(e.shouldBlock()){let t=`process.execPath access is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new v(t,n)}return e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`process_exec_path`,`process.execPath`,`process.execPath accessed (audit mode)`),n},set(t){if(e.shouldBlock()){let t=`process.execPath modification is blocked during script execution`,n=e.recordViolation(`process_exec_path`,`process.execPath`,t);throw new v(t,n)}Object.defineProperty(process,"execPath",{value:t,writable:!0,configurable:!0})},configurable:!0})}catch(e){this.patchFailures.push(`process.execPath`),console.debug(`[DefenseInDepthBox] Could not protect process.execPath:`,e instanceof Error?e.message:e)}}lockWellKnownSymbols(){let e=(e,t)=>{try{let n=Object.getOwnPropertyDescriptor(e,t);if(n?.configurable){if(`value`in n){Object.defineProperty(e,t,{...n,configurable:!1,writable:!1});return}Object.defineProperty(e,t,{...n,configurable:!1})}}catch{}};for(let t of[Array,Map,Set,RegExp,Promise])e(t,Symbol.species);for(let t of[Array.prototype,String.prototype,Map.prototype,Set.prototype])e(t,Symbol.iterator);e(Symbol.prototype,Symbol.toPrimitive),e(Date.prototype,Symbol.toPrimitive);for(let t of[Symbol.match,Symbol.matchAll,Symbol.replace,Symbol.search,Symbol.split])e(RegExp.prototype,t);e(Function.prototype,Symbol.hasInstance),e(Array.prototype,Symbol.unscopables);for(let t of[Map.prototype,Set.prototype,Promise.prototype,ArrayBuffer.prototype])e(t,Symbol.toStringTag);try{let e=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);this.originalDescriptors.push({target:Error,prop:`stackTraceLimit`,descriptor:e}),Object.defineProperty(Error,"stackTraceLimit",{value:Error.stackTraceLimit,writable:!1,configurable:!0})}catch{}}protectProxyRevocable(){let e=this;try{let t=Proxy.revocable;if(typeof t!=`function`)return;let n=Object.getOwnPropertyDescriptor(Proxy,`revocable`);this.originalDescriptors.push({target:Proxy,prop:`revocable`,descriptor:n}),Object.defineProperty(Proxy,"revocable",{value:function(n,r){if(e.shouldBlock()){let t=`Proxy.revocable is blocked during script execution`,n=e.recordViolation(`proxy`,`Proxy.revocable`,t);throw new v(t,n)}return e.config.auditMode&&y?.getStore()?.sandboxActive===!0&&e.recordViolation(`proxy`,`Proxy.revocable`,`Proxy.revocable called (audit mode)`),t(n,r)},writable:!1,configurable:!0})}catch(e){this.patchFailures.push(`Proxy.revocable`),console.debug(`[DefenseInDepthBox] Could not protect Proxy.revocable:`,e instanceof Error?e.message:e)}}protectDynamicImport(){if(!(Hn||e.importHooksRegistered))try{let t=this,n=In(`node:module`),r=new Set;for(let e of n.builtinModules??[]){let t=e.startsWith(`node:`)?e.slice(5):e;r.add(t);let n=t.indexOf(`/`);n>0&&r.add(t.slice(0,n))}let i=e=>{if(e.startsWith(`./`)||e.startsWith(`../`)||e.startsWith(`/`)||e.startsWith(`file:`)||e.startsWith(`data:`)||e.startsWith(`blob:`)||e.startsWith(`http:`)||e.startsWith(`https:`))return!1;let t=e.startsWith(`node:`)?e.slice(5):e;if(!t)return!1;if(typeof n.isBuiltin==`function`&&n.isBuiltin(t)||r.has(t))return!0;let i=t.indexOf(`/`);return i>0&&r.has(t.slice(0,i))},a=()=>{let n=y?.getStore();return t.config.auditMode===!0&&n?.sandboxActive===!0&&n.trusted!==!0&&!e.isTrustedScopeActive(n.executionId)};if(typeof n.registerHooks==`function`){n.registerHooks({resolve(e,n,r){if(e.startsWith(`data:`)||e.startsWith(`blob:`))throw Error(`dynamic import of ${e.startsWith(`data:`)?`data:`:`blob:`} URLs is blocked by defense-in-depth`);if(i(e)){let n=`import(${e})`,r=`dynamic import of Node.js builtin '${e}' is blocked during script execution`;if(t.shouldBlock()){let e=t.recordViolation(`dynamic_import_builtin`,n,r);throw new v(r,e)}a()&&t.recordViolation(`dynamic_import_builtin`,n,`dynamic import of Node.js builtin '${e}' called (audit mode)`)}return r(e,n)}}),e.importHooksRegistered=!0;return}if(typeof n.register==`function`){let t=[`export async function resolve(specifier, context, nextResolve) {`,` if (specifier.startsWith("data:") || specifier.startsWith("blob:")) {`,` throw new Error("dynamic import of " + (specifier.startsWith("data:") ? "data:" : "blob:") + " URLs is blocked by defense-in-depth");`,` }`,` return nextResolve(specifier, context);`,`}`].join(`
72
72
  `);n.register(`data:text/javascript,${encodeURIComponent(t)}`),e.importHooksRegistered=!0}}catch(e){console.debug(`[DefenseInDepthBox] Could not register import() hooks:`,e instanceof Error?e.message:e)}}protectModuleLoad(){if(!Hn)try{let e=null;if(typeof process<`u`){let t=process.mainModule;t&&typeof t==`object`&&(e=t.constructor)}if(!e&&typeof In<`u`&&typeof In.main<`u`&&(e=In.main.constructor),!e||typeof e._load!=`function`)return;let t=e._load,n=Object.getOwnPropertyDescriptor(e,`_load`);this.originalDescriptors.push({target:e,prop:`_load`,descriptor:n});let r=this.createBlockingProxy(t,`Module._load`,`module_load`);Object.defineProperty(e,"_load",{value:r,writable:!0,configurable:!0})}catch(e){this.patchFailures.push(`Module._load`),console.debug(`[DefenseInDepthBox] Could not protect Module._load:`,e instanceof Error?e.message:e)}}protectModuleResolveFilename(){if(!Hn)try{let e=null;if(typeof process<`u`){let t=process.mainModule;t&&typeof t==`object`&&(e=t.constructor)}if(!e&&typeof In<`u`&&typeof In.main<`u`&&(e=In.main.constructor),!e||typeof e._resolveFilename!=`function`)return;let t=e._resolveFilename,n=Object.getOwnPropertyDescriptor(e,`_resolveFilename`);this.originalDescriptors.push({target:e,prop:`_resolveFilename`,descriptor:n});let r=this.createBlockingProxy(t,`Module._resolveFilename`,`module_resolve_filename`);Object.defineProperty(e,"_resolveFilename",{value:r,writable:!0,configurable:!0})}catch(e){this.patchFailures.push(`Module._resolveFilename`),console.debug(`[DefenseInDepthBox] Could not protect Module._resolveFilename:`,e instanceof Error?e.message:e)}}applyPatch(e){let{target:t,prop:n,violationType:r,strategy:i}=e;try{let a=t[n];if(a===void 0)return;let o=Object.getOwnPropertyDescriptor(t,n);if(this.originalDescriptors.push({target:t,prop:n,descriptor:o}),i===`freeze`)typeof a==`object`&&a&&Object.freeze(a);else{let i=this.getPathForTarget(t,n),o=typeof a==`function`?this.createBlockingProxy(a,i,r):this.createBlockingObjectProxy(a,i,r,e.allowedKeys);Object.defineProperty(t,n,{value:o,writable:!0,configurable:!0})}}catch(e){let r=this.getPathForTarget(t,n);this.patchFailures.push(r),console.debug(`[DefenseInDepthBox] Could not patch ${r}:`,e instanceof Error?e.message:e)}}restorePatches(){for(let e=this.originalDescriptors.length-1;e>=0;e--){let{target:t,prop:n,descriptor:r}=this.originalDescriptors[e];try{r?Object.defineProperty(t,n,r):delete t[n]}catch(e){let r=this.getPathForTarget(t,n);console.debug(`[DefenseInDepthBox] Could not restore ${r}:`,e instanceof Error?e.message:e)}}this.originalDescriptors=[]}}}),Yn=g(()=>{Jn(),globalThis.setTimeout.bind(globalThis),globalThis.clearTimeout.bind(globalThis),globalThis.setInterval.bind(globalThis),globalThis.clearInterval.bind(globalThis)});_({},{echoCommand:()=>Xn,flagsForFuzzing:()=>Zn});var Xn,Zn;function Qn(e){let t=e;if(!t)return t;let n=!1;for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);if(r>255)return t;r>127&&(n=!0)}if(!n)return t;let r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);try{return $n.decode(r)}catch{return t}}var $n,er=g(()=>{$n=new TextDecoder(`utf-8`,{fatal:!0}),new TextEncoder}),tr=g(()=>{});_({},{catCommand:()=>nr,flagsForFuzzing:()=>rr});var nr,rr,ir,ar,or,sr,cr,lr,ur,b,x=g(()=>{ir=class extends Error{stdout;stderr;constructor(e,t=``,n=``){super(e),this.stdout=t,this.stderr=n}prependOutput(e,t){this.stdout=e+this.stdout,this.stderr=t+this.stderr}},ar=class extends ir{varName;name=`NounsetError`;constructor(e,t=``){super(`${e}: unbound variable`,t,`bash: ${e}: unbound variable
73
73
  `),this.varName=e}},or=class extends ir{exitCode;name=`ExitError`;constructor(e,t=``,n=``){super(`exit`,t,n),this.exitCode=e}},sr=class extends ir{name=`ArithmeticError`;fatal;constructor(e,t=``,n=``,r=!1){super(e,t,n),this.stderr=n||`bash: ${e}
74
74
  `,this.fatal=r}},cr=class extends ir{name=`BadSubstitutionError`;constructor(e,t=``,n=``){super(e,t,n),this.stderr=n||`bash: ${e}: bad substitution
@@ -106,7 +106,7 @@ This is a defense-in-depth measure and indicates a bug in just-bash. Please repo
106
106
  `)-1&&e.runes[2]===C.CODES.get(`
107
107
  `)+1&&e.runes[3]===T.MAX_RUNE&&(e.runes=[],e.op=A.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let n=0;for(let r of e)n+=r.op===t?r.subs.length:1;let r=Array(n).fill(null),i=0;for(let n of e)n.op===t?(r.splice(i,n.subs.length,...n.subs),i+=n.subs.length,this.reuse(n)):r[i++]=n;let a=this.newRegexp(t);if(a.subs=r,t===A.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let e=a;a=a.subs[0],this.reuse(e)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,i=0,a=null,o=0,s=0,c=0;for(let e=0;e<=r;e++){let l=null,u=0,d=0;if(e<r){let r=t[n+e];if(r.op===A.Op.CONCAT&&r.subs.length>0&&(r=r.subs[0]),r.op===A.Op.LITERAL&&(l=r.runes,u=r.runes.length,d=r.flags&S.FOLD_CASE),d===s){let e=0;for(;e<o&&e<u&&a[e]===l[e];)e++;if(e>0){o=e;continue}}}if(e!==c)if(e===c+1)t[i++]=t[n+c];else{let r=this.newRegexp(A.Op.LITERAL);r.flags=s,r.runes=a.slice(0,o);for(let r=c;r<e;r++)t[n+r]=this.removeLeadingString(t[n+r],o),this.checkLimits(t[n+r]);let l=this.collapse(t.slice(n+c,n+e),A.Op.ALTERNATE),u=this.newRegexp(A.Op.CONCAT);u.subs=[r,l],t[i++]=u}c=e,a=l,o=u,s=d}r=i,n=0,c=0,i=0;let l=null;for(let a=0;a<=r;a++){let o=null;if(!(a<r&&(o=e.leadingRegexp(t[n+a]),l!==null&&l.equals(o)&&(e.isCharClass(l)||l.op===A.Op.REPEAT&&l.min===l.max&&e.isCharClass(l.subs[0]))))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let e=l;for(let e=c;e<a;e++){let r=e!==c;t[n+e]=this.removeLeadingRegexp(t[n+e],r),this.checkLimits(t[n+e])}let r=this.collapse(t.slice(n+c,n+a),A.Op.ALTERNATE),o=this.newRegexp(A.Op.CONCAT);o.subs=[e,r],t[i++]=o}c=a,l=o}}r=i,n=0,c=0,i=0;for(let a=0;a<=r;a++)if(!(a<r&&e.isCharClass(t[n+a]))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let r=c;for(let e=c+1;e<a;e++){let i=t[n+r],a=t[n+e];(i.op<a.op||i.op===a.op&&(i.runes===null?0:i.runes.length)<(a.runes===null?0:a.runes.length))&&(r=e)}let o=t[n+c];t[n+c]=t[n+r],t[n+r]=o;for(let r=c+1;r<a;r++)e.mergeCharClass(t[n+c],t[n+r]),this.reuse(t[n+r]);this.cleanAlt(t[n+c]),t[i++]=t[n+c]}a<r&&(t[i++]=t[n+a]),c=a+1}r=i,n=0,c=0,i=0;for(let e=0;e<r;++e)e+1<r&&t[n+e].op===A.Op.EMPTY_MATCH&&t[n+e+1].op===A.Op.EMPTY_MATCH||(t[i++]=t[n+e]);return r=i,n=0,t.slice(n,r)}removeLeadingString(e,t){if(e.op===A.Op.CONCAT&&e.subs.length>0){let n=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=n,n.op===A.Op.EMPTY_MATCH)switch(this.reuse(n),e.subs.length){case 0:case 1:e.op=A.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let t=e;e=e.subs[1],this.reuse(t);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===A.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=A.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===A.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=A.Op.EMPTY_MATCH,e.subs=A.emptySubs();break;case 1:{let t=e;e=e.subs[0],this.reuse(t);break}}return e}return t&&this.reuse(e),this.newRegexp(A.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&S.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,i=new Ui(this.wholeRegexp);for(;i.more();){let a=-1;e:switch(i.peek()){case C.CODES.get(`(`):if((this.flags&S.PERL_X)!==0&&i.lookingAt(`(?`)){this.parsePerlFlags(i);break}this.op(A.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case C.CODES.get(`|`):this.parseVerticalBar(),i.skip(1);break;case C.CODES.get(`)`):this.parseRightParen(),i.skip(1);break;case C.CODES.get(`^`):(this.flags&S.ONE_LINE)===0?this.op(A.Op.BEGIN_LINE):this.op(A.Op.BEGIN_TEXT),i.skip(1);break;case C.CODES.get(`$`):(this.flags&S.ONE_LINE)===0?this.op(A.Op.END_LINE):this.op(A.Op.END_TEXT).flags|=S.WAS_DOLLAR,i.skip(1);break;case C.CODES.get(`.`):(this.flags&S.DOT_NL)===0?this.op(A.Op.ANY_CHAR_NOT_NL):this.op(A.Op.ANY_CHAR),i.skip(1);break;case C.CODES.get(`[`):this.parseClass(i);break;case C.CODES.get(`*`):case C.CODES.get(`+`):case C.CODES.get(`?`):{a=i.pos();let e=null;switch(i.pop()){case C.CODES.get(`*`):e=A.Op.STAR;break;case C.CODES.get(`+`):e=A.Op.PLUS;break;case C.CODES.get(`?`):e=A.Op.QUEST;break}this.repeat(e,n,r,a,i,t);break}case C.CODES.get(`{`):{a=i.pos();let o=e.parseRepeat(i);if(o<0){i.rewindTo(a),this.literal(i.pop());break}n=o>>16,r=(o&T.MAX_BMP)<<16>>16,this.repeat(A.Op.REPEAT,n,r,a,i,t);break}case C.CODES.get(`\\`):{let t=i.pos();if(i.skip(1),(this.flags&S.PERL_X)!==0&&i.more())switch(i.pop()){case C.CODES.get(`A`):this.op(A.Op.BEGIN_TEXT);break e;case C.CODES.get(`b`):this.op(A.Op.WORD_BOUNDARY);break e;case C.CODES.get(`B`):this.op(A.Op.NO_WORD_BOUNDARY);break e;case C.CODES.get(`C`):throw new O(e.ERR_INVALID_ESCAPE,`\\C`);case C.CODES.get(`Q`):{let e=i.rest(),t=e.indexOf(`\\E`);t>=0&&(e=e.substring(0,t)),i.skipString(e),i.skipString(`\\E`);let n=0;for(;n<e.length;){let t=e.codePointAt(n);this.literal(t),n+=E.charCount(t)}break e}case C.CODES.get(`z`):this.op(A.Op.END_TEXT);break e;default:i.rewindTo(t);break}let n=this.newRegexp(A.Op.CHAR_CLASS);if(n.flags=this.flags,i.lookingAt(`\\p`)||i.lookingAt(`\\P`)){let e=new Vi;if(this.parseUnicodeClass(i,e)){n.runes=e.toArray(),this.push(n);break e}}let r=new Vi;if(this.parsePerlClassEscape(i,r)){n.runes=r.toArray(),this.push(n);break e}i.rewindTo(t),this.reuse(n),this.literal(e.parseEscape(i));break}default:this.literal(i.pop());break}t=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new O(e.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){let n=t.pos(),r=t.rest();if(r.startsWith(`(?P<`)||r.startsWith(`(?<`)){let n=r.charAt(2)===`P`?4:3,i=r.indexOf(`>`);if(i<0)throw new O(e.ERR_INVALID_NAMED_CAPTURE,r);let a=r.substring(n,i);if(t.skipString(a),t.skip(n+1),!e.isValidCaptureName(a))throw new O(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,i+1));let o=this.op(A.Op.LEFT_PAREN);if(o.cap=++this.numCap,this.namedGroups[a])throw new O(e.ERR_DUPLICATE_NAMED_CAPTURE,a);this.namedGroups[a]=this.numCap,o.name=a;return}t.skip(2);let i=this.flags,a=1,o=!1;e:for(;t.more();){let e=t.pop();switch(e){case C.CODES.get(`i`):i|=S.FOLD_CASE,o=!0;break;case C.CODES.get(`m`):i&=-17,o=!0;break;case C.CODES.get(`s`):i|=S.DOT_NL,o=!0;break;case C.CODES.get(`U`):i|=S.NON_GREEDY,o=!0;break;case C.CODES.get(`-`):if(a<0)break e;a=-1,i=~i,o=!1;break;case C.CODES.get(`:`):case C.CODES.get(`)`):if(a<0){if(!o)break e;i=~i}e===C.CODES.get(`:`)&&this.op(A.Op.LEFT_PAREN),this.flags=i;return;default:break e}}throw new O(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(A.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===A.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let e=r;r=n,n=e,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let e=this.stack[t-1],n=this.stack[t-2];if(n.op===A.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=e,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new O(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let t=this.pop(),n=this.pop();if(n.op!==A.Op.LEFT_PAREN)throw new O(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=n.flags,n.cap===0?this.push(t):(n.op=A.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(e,t){let n=e.pos();if((this.flags&S.PERL_X)===0||!e.more()||e.pop()!==C.CODES.get(`\\`)||!e.more())return!1;e.pop();let r=e.from(n),i=Ti.has(r)?Ti.get(r):null;return i===null?!1:(t.appendGroup(i,(this.flags&S.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),i=r.indexOf(`:]`);if(i<0)return!1;let a=r.substring(0,i+2);t.skipString(a);let o=Bi.has(a)?Bi.get(a):null;if(o===null)throw new O(e.ERR_INVALID_CHAR_RANGE,a);return n.appendGroup(o,(this.flags&S.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&S.UNICODE_GROUPS)===0||!t.lookingAt(`\\p`)&&!t.lookingAt(`\\P`))return!1;t.skip(1);let i=1,a=t.pop();if(a===C.CODES.get(`P`)&&(i=-1),!t.more())throw t.rewindTo(r),new O(e.ERR_INVALID_CHAR_RANGE,t.rest());a=t.pop();let o;if(a!==C.CODES.get(`{`))o=E.runeToString(a);else{let n=t.rest(),i=n.indexOf(`}`);if(i<0)throw t.rewindTo(r),new O(e.ERR_INVALID_CHAR_RANGE,t.rest());o=n.substring(0,i),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===C.CODES.get(`^`)&&(i=0-i,o=o.substring(1));let s=e.unicodeTable(o);if(s===null)throw new O(e.ERR_INVALID_CHAR_RANGE,t.from(r));let c=s.first,l=s.second;if((this.flags&S.FOLD_CASE)===0||l===null)n.appendTableWithSign(c,i);else{let e=new Vi().appendTable(c).appendTable(l).cleanClass().toArray();n.appendClassWithSign(e,i)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(A.Op.CHAR_CLASS);r.flags=this.flags;let i=new Vi,a=1;t.more()&&t.lookingAt(`^`)&&(a=-1,t.skip(1),(this.flags&S.CLASS_NL)===0&&i.appendRange(C.CODES.get(`
108
108
  `),C.CODES.get(`
109
- `)));let o=!0;for(;!t.more()||t.peek()!==C.CODES.get(`]`)||o;){if(t.more()&&t.lookingAt(`-`)&&(this.flags&S.PERL_X)===0&&!o){let r=t.rest();if(r===`-`||!r.startsWith(`-]`))throw t.rewindTo(n),new O(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let r=t.pos();if(t.lookingAt(`[:`)){if(this.parseNamedClass(t,i))continue;t.rewindTo(r)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(r);let a=e.parseClassChar(t,n),s=a;if(t.more()&&t.lookingAt(`-`)){if(t.skip(1),t.more()&&t.lookingAt(`]`))t.skip(-1);else if(s=e.parseClassChar(t,n),s<a)throw new O(e.ERR_INVALID_CHAR_RANGE,t.from(r))}(this.flags&S.FOLD_CASE)===0?i.appendRange(a,s):i.appendFoldedRange(a,s)}t.skip(1),i.cleanClass(),a<0&&i.negateClass(),r.runes=i.toArray(),this.push(r)}},Gi=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e?(this.value=t,!0):!1}},Ki=class e{static initTest(t){let n=e.compile(t),r=new e(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(t){return e.compileImpl(t,S.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,S.POSIX,!0)}static compileImpl(t,n,r){let i=Wi.parse(t,n),a=i.maxCap();i=xi.simplify(i);let o=bi.compileRegexp(i),s=new e(t,o,a,r),[c,l]=o.prefix();return s.prefixComplete=c,s.prefix=l,s.prefixUTF8=E.stringToUtf8ByteArray(s.prefix),s.prefix.length>0&&(s.prefixRune=s.prefix.codePointAt(0)),s.namedGroups=i.namedGroups,s}static match(t,n){return e.compile(t).match(n)}constructor(e,t,n=0,r=0){this.expr=e,this.prog=t,this.numSubexp=n,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new Gi,this.dfa=new _i(t)}executeEngine(e,t,n,r){if(r>0)return this.doExecuteNFA(e,t,n,r);let i=this.dfa.match(e,t,n);return i===null?this.doExecuteNFA(e,t,n,r):i?[]:null}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let n=this.pooled.get();do n=this.pooled.get(),!t&&n&&(e=pi.fromMachine(e),t=!0),e.next!==n&&(e.next=n);while(!this.pooled.compareAndSet(n,e))}toString(){return this.expr}doExecuteNFA(e,t,n,r){let i=this.get(),a=!1;i?i.next!==null&&(i=pi.fromMachine(i),a=!0):(i=pi.fromRE2(this),a=!0),i.init(r);let o=i.match(e,t,n)?i.submatches():null;return this.put(i,a),o}match(e){return this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,0)!==null}matchWithGroup(e,t,n,r,i){return e instanceof $r||(e=ni.utf16(e)),this.matchMachineInput(e,t,n,r,i)}matchMachineInput(e,t,n,r,i){if(t>n)return[!1,null];let a=e.isUTF16Encoding()?D.fromUTF16(e.asCharSequence(),0,n):D.fromUTF8(e.asBytes(),0,n),o=this.executeEngine(a,t,r,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(e){return this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,n){let r=0,i=0,a=``,o=D.fromUTF16(e),s=0;for(;i<=e.length;){let c=this.executeEngine(o,i,S.UNANCHORED,2);if(c===null||c.length===0)break;a+=e.substring(r,c[0]),(c[1]>r||c[0]===0)&&(a+=t(e.substring(c[0],c[1])),s++),r=c[1];let l=o.step(i)&7;if(i+l>c[1]?i+=l:i+1>c[1]?i++:i=c[1],s>=n)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let n=Array(t).fill(-1);for(let t=0;t<e.length;t++)n[t]=e[t];e=n}return e}allMatches(e,t,n=e=>e){let r=[],i=e.endPos();t<0&&(t=i+1);let a=0,o=0,s=-1;for(;o<t&&a<=i;){let t=this.executeEngine(e,a,S.UNANCHORED,this.prog.numCap);if(t===null||t.length===0)break;let c=!0;if(t[1]===a){t[0]===s&&(c=!1);let n=e.step(a);n<0?a=i+1:a+=n&7}else a=t[1];s=t[1],c&&(r.push(n(this.pad(t))),o++)}return r}findUTF8(e){let t=this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){let t=this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){let t=this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,2);return t===null?``:e.substring(t[0],t[1])}findIndex(e){return this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,2)}findUTF8Submatch(e){let t=this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n}findUTF8SubmatchIndex(e){return this.pad(this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,this.prog.numCap))}findSubmatch(e){let t=this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n}findSubmatchIndex(e){return this.pad(this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){let n=this.allMatches(D.fromUTF8(e),t,t=>e.slice(t[0],t[1]));return n.length===0?null:n}findAllUTF8Index(e,t){let n=this.allMatches(D.fromUTF8(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAll(e,t){let n=this.allMatches(D.fromUTF16(e),t,t=>e.substring(t[0],t[1]));return n.length===0?null:n}findAllIndex(e,t){let n=this.allMatches(D.fromUTF16(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(e,t){let n=this.allMatches(D.fromUTF8(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllUTF8SubmatchIndex(e,t){let n=this.allMatches(D.fromUTF8(e),t);return n.length===0?null:n}findAllSubmatch(e,t){let n=this.allMatches(D.fromUTF16(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllSubmatchIndex(e,t){let n=this.allMatches(D.fromUTF16(e),t);return n.length===0?null:n}},qi=class e{static isUpperCaseAlpha(e){return`A`<=e&&e<=`Z`}static isHexadecimal(e){return`0`<=e&&e<=`9`||`A`<=e&&e<=`F`||`a`<=e&&e<=`f`}static getUtf8CharSize(e){let t=e.charCodeAt(0);return t<128?1:t<2048?2:t<65536?3:4}static translate(t){if(typeof t!=`string`)return t;let n=``,r=!1,i=t.length;i===0&&(n=`(?:)`,r=!0);let a=0;for(;a<i;){let o=t[a];if(o===`\\`){if(a+1<i)switch(o=t[a+1],o){case`\\`:n+=`\\\\`,a+=2;continue;case`c`:if(a+2<i){let i=t[a+2];if(e.isUpperCaseAlpha(i)){n+=`\\x`,n+=(i.charCodeAt(0)-64>>4).toString(16).toUpperCase(),n+=(i.charCodeAt(0)-64&15).toString(16).toUpperCase(),a+=3,r=!0;continue}}n+=`\\c`,a+=2;continue;case`u`:if(a+2<i){let o=t[a+2];if(e.isHexadecimal(o)){n+=`\\x{`+o,a+=3;for(let r=0;r<3&&a<i&&(o=t[a],e.isHexadecimal(o));++a,++r)n+=o;n+=`}`,r=!0;continue}else if(o===`{`){n+=`\\x`,a+=2,r=!0;continue}}n+=`\\u`,a+=2;continue;default:{n+=`\\`;let r=e.getUtf8CharSize(o);n+=t.substring(a+1,a+1+r),a+=r+1;continue}}}else if(o===`/`){n+=`\\/`,a+=1,r=!0;continue}else if(o===`(`&&a+2<i&&t[a+1]===`?`&&t[a+2]===`<`&&(a+3>=i||t[a+3]!==`=`&&t[a+3]!==`!`)){n+=`(?P<`,a+=3,r=!0;continue}let s=e.getUtf8CharSize(o);n+=t.substring(a,a+s),a+=s}return r?n:t}},Ji=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return E.quoteMeta(e)}static quoteReplacement(e,t=!1){return ui.quoteReplacement(e,t)}static translateRegExp(e){return qi.translate(e)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new li(`Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH`);let i=S.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(i&=-129);let a=new e(t,n);return a.re2Input=Ki.compileImpl(r,i,(n&e.LONGEST_MATCH)!==0),a}static matches(t,n){return e.compile(t).testExact(n)}static initTest(t,n,r){if(t==null)throw Error(`pattern is null`);if(r==null)throw Error(`re2 is null`);let i=new e(t,n);return i.re2Input=r,i}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.testExact(e)}matcher(e){return Array.isArray(e)&&(e=ni.utf8(e)),new ui(this,e)}test(e){return Array.isArray(e)?this.re2Input.matchUTF8(e):this.re2Input.match(e)}testExact(e){let t=Array.isArray(e)?D.fromUTF8(e):D.fromUTF16(e);return this.re2Input.executeEngine(t,0,S.ANCHOR_BOTH,0)!==null}split(e,t=0){let n=this.matcher(e),r=[],i=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(t>0&&r.length===t-1)break;if(a===n.start()){if(t===0){i+=1,a=n.end();continue}}else for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.start())),a=n.end()}if(t===0&&a!==n.inputLength()){for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.inputLength()))}return(t!==0||r.length===0)&&r.push(n.substring(a,n.inputLength())),r}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}});function Xi(e){let t=0;return e.includes(`i`)&&(t|=Ji.CASE_INSENSITIVE),e.includes(`m`)&&(t|=Ji.MULTILINE),e.includes(`s`)&&(t|=Ji.DOTALL),t}function Zi(e){return Ji.translateRegExp(e)}function M(e,t=``){return new Qi(e,t)}var Qi,$i,ea=g(()=>{Yi(),Qi=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;_matcher=null;_matcherInput=null;acquireMatcher(e){return this._matcher===null?(this._matcher=this._re2.matcher(e),this._matcherInput=e,this._matcher):(this._matcherInput!==e&&(this._matcher.matcherInput.charSequence=e,this._matcherInput=e),this._matcher.reset(),this._matcher)}constructor(e,t=``){this._pattern=e,this._flags=t,this._global=t.includes(`g`),this._ignoreCase=t.includes(`i`),this._multiline=t.includes(`m`);try{let n=Zi(e),r=Xi(t);this._re2=Ji.compile(n,r)}catch(t){if(t instanceof O){let n=t.message||``,r=``;throw n.includes(`(?=`)||n.includes(`(?!`)||n.includes(`(?<`)||n.includes(`(?<!`)||e.includes(`(?=`)||e.includes(`(?!`)||e.includes(`(?<=`)||e.includes(`(?<!`)?r=` Lookahead (?=, ?!) and lookbehind (?<=, ?<!) assertions are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support these features.`:(n.includes(`backreference`)||/\\[1-9]/.test(e))&&(r=` Backreferences (\\1, \\2, etc.) are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support backreferences.`),SyntaxError(`Invalid regular expression: /${e}/: ${n}${r}`)}throw t}}test(e){return this._global&&(this._lastIndex=0),this.acquireMatcher(e).find()}exec(e){let t=this.acquireMatcher(e),n=this._global?this._lastIndex:0;if(!t.find(n))return this._global&&(this._lastIndex=0),null;let r=this._re2.groupCount(),i=[];i.push(t.group(0)??``);for(let e=1;e<=r;e++){let n=t.group(e);i.push(n)}let a=i;a.index=t.start(0),a.input=e;let o=this._re2.namedGroups();if(o&&Object.keys(o).length>0){let e=Object.create(null);for(let[n,r]of Object.entries(o)){let i=t.group(r);i!==null&&(e[n]=i)}a.groups=e}return this._global&&(this._lastIndex=t.end(0),t.start(0)===t.end(0)&&this._lastIndex++),a}match(e){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(e);let t=[],n=this._re2.matcher(e),r=0;for(;n.find(r);){let i=n.group(0)??``;if(t.push(i),r=n.end(0),n.start(0)===n.end(0)&&r++,r>e.length)break}return t.length>0?t:null}replace(e,t){if(this._global&&(this._lastIndex=0),typeof t==`string`){let n=this._re2.matcher(e);return this._global?n.replaceAll(t,!0):n.replaceFirst(t,!0)}let n=[],r=this._re2.matcher(e),i=0,a=0,o=this._re2.groupCount(),s=this._re2.namedGroups();for(;r.find(a);){n.push(e.slice(i,r.start(0)));let c=[],l=r.group(0)??``;for(let e=1;e<=o;e++)c.push(r.group(e));if(c.push(r.start(0)),c.push(e),s&&Object.keys(s).length>0){let e=Object.create(null);for(let[t,n]of Object.entries(s))e[t]=r.group(n)??``;c.push(e)}if(n.push(t(l,...c)),i=r.end(0),a=i,r.start(0)===r.end(0)&&a++,!this._global||a>e.length)break}return n.push(e.slice(i)),n.join(``)}split(e,t){return t===void 0||t<0?this._re2.split(e,-1):t===0?[]:this._re2.split(e,-1).slice(0,t)}search(e){let t=this._re2.matcher(e);return t.find()?t.start(0):-1}*matchAll(e){if(!this._global)throw Error(`matchAll requires global flag`);this._lastIndex=0;let t=this._re2.matcher(e),n=this._re2.groupCount(),r=this._re2.namedGroups(),i=0;for(;t.find(i);){let a=[];a.push(t.group(0)??``);for(let e=1;e<=n;e++)a.push(t.group(e));let o=a;if(o.index=t.start(0),o.input=e,r&&Object.keys(r).length>0){let e=Object.create(null);for(let[n,i]of Object.entries(r)){let r=t.group(i);r!==null&&(e[n]=r)}o.groups=e}if(yield o,i=t.end(0),t.start(0)===t.end(0)&&i++,i>e.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=RegExp(``,this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(e){this._lastIndex=e}},$i=class{_regex;constructor(e){this._regex=e}test(e){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(e)}exec(e){return this._regex.exec(e)}match(e){return this._regex.global&&(this._regex.lastIndex=0),e.match(this._regex)}replace(e,t){return this._regex.global&&(this._regex.lastIndex=0),e.replace(this._regex,t)}split(e,t){return e.split(this._regex,t)}search(e){return e.search(this._regex)}*matchAll(e){if(!this._regex.global)throw Error(`matchAll requires global flag`);this._regex.lastIndex=0;let t=this._regex.exec(e);for(;t!==null;)yield t,t[0].length===0&&this._regex.lastIndex++,t=this._regex.exec(e)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(e){this._regex.lastIndex=e}}}),ta=g(()=>{ea()});function na(e,t,n){let r=typeof n==`boolean`?{ignoreCase:n}:n??{},i=t;r.stripQuotes&&(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1));let a=r.ignoreCase?`i:${i}`:i,o=aa.get(a);if(!o){if(o=ra(i,r.ignoreCase),aa.size>=ia){let e=aa.keys().next().value;e!==void 0&&aa.delete(e)}aa.set(a,o)}return o.test(e)}function ra(e,t){let n=`^`;for(let t=0;t<e.length;t++){let r=e[t];if(r===`*`)n+=`.*`;else if(r===`?`)n+=`.`;else if(r===`[`){let r=t+1;for(;r<e.length&&e[r]!==`]`;)r++;n+=e.slice(t,r+1),t=r}else r===`.`||r===`+`||r===`^`||r===`$`||r===`{`||r===`}`||r===`(`||r===`)`||r===`|`||r===`\\`?n+=`\\${r}`:n+=r}return n+=`$`,M(n,t?`i`:``)}var ia,aa;_({},{egrepCommand:()=>da,egrepFlagsForFuzzing:()=>ma,fgrepCommand:()=>ua,fgrepFlagsForFuzzing:()=>pa,flagsForFuzzing:()=>fa,grepCommand:()=>ca});async function oa(e,t,n,r,i=0){if(i>=la)return;let a=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(a)).isDirectory){let n=e.split(`/`).pop()||``;t&&na(n,t.replace(/^\//,``),{stripQuotes:!0})&&r.push(e);return}let o=await n.fs.readdir(a);for(let a of o){let o=e===`.`?a:`${e}/${a}`,s=n.fs.resolvePath(n.cwd,o);(await n.fs.stat(s)).isDirectory?await oa(o,t,n,r,i+1):t&&na(a,t.replace(/^\//,``),{stripQuotes:!0})&&r.push(o)}}catch{}}async function sa(e,t,n=[],r=[],i=[],a,o=0){if(o>=la)return[];let s=t.fs.resolvePath(t.cwd,e),c=[];try{let l,u;if(a!==void 0)l=a,u=!a;else{let e=await t.fs.stat(s);l=e.isFile,u=e.isDirectory}if(l){let t=e.split(`/`).pop()||e;return r.length>0&&r.some(e=>na(t,e,{stripQuotes:!0}))||n.length>0&&!n.some(e=>na(t,e,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!u)return[];let d=e.split(`/`).pop()||e;if(i.length>0&&i.some(e=>na(d,e,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let a=await t.fs.readdirWithFileTypes(s);for(let s of a){if(s.name.startsWith(`.`))continue;let a=await sa(e===`.`?s.name:`${e}/${s.name}`,t,n,r,i,s.isFile,o+1);c.push(...a)}}else{let a=await t.fs.readdir(s);for(let s of a){if(s.startsWith(`.`))continue;let a=await sa(e===`.`?s:`${e}/${s}`,t,n,r,i,void 0,o+1);c.push(...a)}}}catch{}return c}var ca,la,ua,da,fa,pa,ma;function ha(e,t){if(Array.isArray(e))throw TypeError(`${t}: expected object, got array`);if(Object.getPrototypeOf(e)!==null)throw TypeError(`${t}: expected null-prototype object, got prototypal object`)}function N(e){return!ba.has(e)}function P(e,t,n){ha(e,`safeSet`),N(t)&&(e[t]=n)}function ga(e,t){return ha(e,`safeHasOwn`),Object.hasOwn(e,t)}function _a(e){let t=new WeakMap,n=e=>{if(typeof e!=`object`||!e||e instanceof Date)return e;let r=t.get(e);if(r!==void 0)return r;if(Array.isArray(e)){let r=[];t.set(e,r);for(let t of e)r.push(n(t));return r}let i=Object.create(null);t.set(e,i);for(let t of Object.keys(e))i[t]=n(e[t]);return i};return n(e)}function F(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function va(e){return Object.assign(Object.create(null),e)}function ya(...e){return Object.assign(Object.create(null),...e)}var ba,xa;async function Sa(e,t,n,r,i,a,o,s){if(!(r>=i.maxDepth)){a&&await a.loadForDirectory(n);try{let c=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(n):(await e.fs.readdir(n)).map(e=>({name:e,isFile:void 0}));for(let l of c){let c=l.name;if(!i.noIgnore&&xa.isCommonIgnored(c))continue;let u=c.startsWith(`.`),d=t===`.`?c:t===`./`?`./${c}`:t.endsWith(`/`)?`${t}${c}`:`${t}/${c}`,f=e.fs.resolvePath(n,c),p,m,h=!1;if(l.isFile!==void 0&&`isDirectory`in l){let t=l;if(h=t.isSymbolicLink===!0,h&&!i.followSymlinks)continue;if(h&&i.followSymlinks)try{let t=await e.fs.stat(f);p=t.isFile,m=t.isDirectory}catch{continue}else p=t.isFile,m=t.isDirectory}else try{let t=e.fs.lstat?await e.fs.lstat(f):await e.fs.stat(f);if(h=t.isSymbolicLink===!0,h&&!i.followSymlinks)continue;let n=h&&i.followSymlinks?await e.fs.stat(f):t;p=n.isFile,m=n.isDirectory}catch{continue}if(!a?.matches(f,m)&&!(u&&!i.hidden&&!a?.isWhitelisted(f,m))){if(m)await Sa(e,d,f,r+1,i,a,o,s);else if(p){if(i.maxFilesize>0)try{if((await e.fs.stat(f)).size>i.maxFilesize)continue}catch{continue}Ca(d,i,a,f,o)&&s.push(d)}}}}catch{}}}function Ca(e,t,n,r,i){let a=e.split(`/`).pop()||e;if(n?.matches(r,!1)||t.types.length>0&&!i.matchesType(a,t.types)||t.typesNot.length>0&&i.matchesType(a,t.typesNot))return!1;if(t.globs.length>0){let n=t.globCaseInsensitive,r=t.globs.filter(e=>!e.startsWith(`!`)),i=t.globs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(r.length>0){let t=!1;for(let i of r)if(wa(a,i,n)||wa(e,i,n)){t=!0;break}if(!t)return!1}for(let t of i)if(t.startsWith(`/`)){if(wa(e,t.slice(1),n))return!1}else if(wa(a,t,n)||wa(e,t,n))return!1}if(t.iglobs.length>0){let n=t.iglobs.filter(e=>!e.startsWith(`!`)),r=t.iglobs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(n.length>0){let t=!1;for(let r of n)if(wa(a,r,!0)||wa(e,r,!0)){t=!0;break}if(!t)return!1}for(let t of r)if(t.startsWith(`/`)){if(wa(e,t.slice(1),!0))return!1}else if(wa(a,t,!0)||wa(e,t,!0))return!1}return!0}function wa(e,t,n=!1){let r=`^`;for(let e=0;e<t.length;e++){let n=t[e];if(n===`*`)t[e+1]===`*`?(r+=`.*`,e++):r+=`[^/]*`;else if(n===`?`)r+=`[^/]`;else if(n===`[`){let n=e+1;for(n<t.length&&t[n]===`!`&&n++,n<t.length&&t[n]===`]`&&n++;n<t.length&&t[n]!==`]`;)n++;if(n<t.length){let i=t.slice(e,n+1);i.startsWith(`[!`)&&(i=`[^${i.slice(2)}`),r+=i,e=n}else r+=`\\[`}else r+=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}return r+=`$`,M(r,n?`i`:``).test(e)}_({},{flagsForFuzzing:()=>Ea,rgCommand:()=>Ta});var Ta,Ea;function Da(e,t,n){if(!e||qn.isInSandboxedContext())return;let r=`${t} ${n} attempted outside defense context`;throw new v(r,{timestamp:Date.now(),type:`missing_defense_context`,message:r,path:`DefenseInDepthBox.context`,stack:Error().stack,executionId:qn.getCurrentExecutionId()})}async function Oa(e,t,n,r){Da(e,t,`${n} (pre-await)`);let i=await r();return Da(e,t,`${n} (post-await)`),i}var ka=g(()=>{Jn()});function Aa(e){let t=``,n=0,r=!1;for(;n<e.length;){if(e[n]===`[`&&!r){if(e[n+1]===`[`&&e[n+2]===`:`){let r=e.indexOf(`:]]`,n+3);if(r!==-1){let i=e.slice(n+3,r),a=Na.get(i);if(a){t+=`[${a}]`,n=r+3;continue}}}if(e[n+1]===`^`&&e[n+2]===`[`&&e[n+3]===`:`){let r=e.indexOf(`:]]`,n+4);if(r!==-1){let i=e.slice(n+4,r),a=Na.get(i);if(a){t+=`[^${a}]`,n=r+3;continue}}}t+=`[`,n++,r=!0,n<e.length&&e[n]===`^`&&(t+=`^`,n++),n<e.length&&e[n]===`]`&&(t+=`\\]`,n++);continue}if(r){if(e[n]===`]`){t+=`]`,n++,r=!1;continue}if(e[n]===`[`&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r),a=Na.get(i);if(a){t+=a,n=r+2;continue}}}if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++;continue}if(e[n]===`\\`&&n+1<e.length){let r=e[n+1];if(r===`+`||r===`?`||r===`|`){t+=r,n+=2;continue}if(r===`(`||r===`)`){t+=r,n+=2;continue}if(r===`{`||r===`}`){t+=r,n+=2;continue}if(r===`t`){t+=` `,n+=2;continue}if(r===`n`){t+=`
109
+ `)));let o=!0;for(;!t.more()||t.peek()!==C.CODES.get(`]`)||o;){if(t.more()&&t.lookingAt(`-`)&&(this.flags&S.PERL_X)===0&&!o){let r=t.rest();if(r===`-`||!r.startsWith(`-]`))throw t.rewindTo(n),new O(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let r=t.pos();if(t.lookingAt(`[:`)){if(this.parseNamedClass(t,i))continue;t.rewindTo(r)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(r);let a=e.parseClassChar(t,n),s=a;if(t.more()&&t.lookingAt(`-`)){if(t.skip(1),t.more()&&t.lookingAt(`]`))t.skip(-1);else if(s=e.parseClassChar(t,n),s<a)throw new O(e.ERR_INVALID_CHAR_RANGE,t.from(r))}(this.flags&S.FOLD_CASE)===0?i.appendRange(a,s):i.appendFoldedRange(a,s)}t.skip(1),i.cleanClass(),a<0&&i.negateClass(),r.runes=i.toArray(),this.push(r)}},Gi=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e?(this.value=t,!0):!1}},Ki=class e{static initTest(t){let n=e.compile(t),r=new e(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(t){return e.compileImpl(t,S.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,S.POSIX,!0)}static compileImpl(t,n,r){let i=Wi.parse(t,n),a=i.maxCap();i=xi.simplify(i);let o=bi.compileRegexp(i),s=new e(t,o,a,r),[c,l]=o.prefix();return s.prefixComplete=c,s.prefix=l,s.prefixUTF8=E.stringToUtf8ByteArray(s.prefix),s.prefix.length>0&&(s.prefixRune=s.prefix.codePointAt(0)),s.namedGroups=i.namedGroups,s}static match(t,n){return e.compile(t).match(n)}constructor(e,t,n=0,r=0){this.expr=e,this.prog=t,this.numSubexp=n,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new Gi,this.dfa=new _i(t)}executeEngine(e,t,n,r){if(r>0)return this.doExecuteNFA(e,t,n,r);let i=this.dfa.match(e,t,n);return i===null?this.doExecuteNFA(e,t,n,r):i?[]:null}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let n=this.pooled.get();do n=this.pooled.get(),!t&&n&&(e=pi.fromMachine(e),t=!0),e.next!==n&&(e.next=n);while(!this.pooled.compareAndSet(n,e))}toString(){return this.expr}doExecuteNFA(e,t,n,r){let i=this.get(),a=!1;i?i.next!==null&&(i=pi.fromMachine(i),a=!0):(i=pi.fromRE2(this),a=!0),i.init(r);let o=i.match(e,t,n)?i.submatches():null;return this.put(i,a),o}match(e){return this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,0)!==null}matchWithGroup(e,t,n,r,i){return e instanceof $r||(e=ni.utf16(e)),this.matchMachineInput(e,t,n,r,i)}matchMachineInput(e,t,n,r,i){if(t>n)return[!1,null];let a=e.isUTF16Encoding()?D.fromUTF16(e.asCharSequence(),0,n):D.fromUTF8(e.asBytes(),0,n),o=this.executeEngine(a,t,r,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(e){return this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,n){let r=0,i=0,a=``,o=D.fromUTF16(e),s=0;for(;i<=e.length;){let c=this.executeEngine(o,i,S.UNANCHORED,2);if(c===null||c.length===0)break;a+=e.substring(r,c[0]),(c[1]>r||c[0]===0)&&(a+=t(e.substring(c[0],c[1])),s++),r=c[1];let l=o.step(i)&7;if(i+l>c[1]?i+=l:i+1>c[1]?i++:i=c[1],s>=n)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let n=Array(t).fill(-1);for(let t=0;t<e.length;t++)n[t]=e[t];e=n}return e}allMatches(e,t,n=e=>e){let r=[],i=e.endPos();t<0&&(t=i+1);let a=0,o=0,s=-1;for(;o<t&&a<=i;){let t=this.executeEngine(e,a,S.UNANCHORED,this.prog.numCap);if(t===null||t.length===0)break;let c=!0;if(t[1]===a){t[0]===s&&(c=!1);let n=e.step(a);n<0?a=i+1:a+=n&7}else a=t[1];s=t[1],c&&(r.push(n(this.pad(t))),o++)}return r}findUTF8(e){let t=this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){let t=this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){let t=this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,2);return t===null?``:e.substring(t[0],t[1])}findIndex(e){return this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,2)}findUTF8Submatch(e){let t=this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n}findUTF8SubmatchIndex(e){return this.pad(this.executeEngine(D.fromUTF8(e),0,S.UNANCHORED,this.prog.numCap))}findSubmatch(e){let t=this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n}findSubmatchIndex(e){return this.pad(this.executeEngine(D.fromUTF16(e),0,S.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){let n=this.allMatches(D.fromUTF8(e),t,t=>e.slice(t[0],t[1]));return n.length===0?null:n}findAllUTF8Index(e,t){let n=this.allMatches(D.fromUTF8(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAll(e,t){let n=this.allMatches(D.fromUTF16(e),t,t=>e.substring(t[0],t[1]));return n.length===0?null:n}findAllIndex(e,t){let n=this.allMatches(D.fromUTF16(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(e,t){let n=this.allMatches(D.fromUTF8(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllUTF8SubmatchIndex(e,t){let n=this.allMatches(D.fromUTF8(e),t);return n.length===0?null:n}findAllSubmatch(e,t){let n=this.allMatches(D.fromUTF16(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllSubmatchIndex(e,t){let n=this.allMatches(D.fromUTF16(e),t);return n.length===0?null:n}},qi=class e{static isUpperCaseAlpha(e){return`A`<=e&&e<=`Z`}static isHexadecimal(e){return`0`<=e&&e<=`9`||`A`<=e&&e<=`F`||`a`<=e&&e<=`f`}static getUtf8CharSize(e){let t=e.charCodeAt(0);return t<128?1:t<2048?2:t<65536?3:4}static translate(t){if(typeof t!=`string`)return t;let n=``,r=!1,i=t.length;i===0&&(n=`(?:)`,r=!0);let a=0;for(;a<i;){let o=t[a];if(o===`\\`){if(a+1<i)switch(o=t[a+1],o){case`\\`:n+=`\\\\`,a+=2;continue;case`c`:if(a+2<i){let i=t[a+2];if(e.isUpperCaseAlpha(i)){n+=`\\x`,n+=(i.charCodeAt(0)-64>>4).toString(16).toUpperCase(),n+=(i.charCodeAt(0)-64&15).toString(16).toUpperCase(),a+=3,r=!0;continue}}n+=`\\c`,a+=2;continue;case`u`:if(a+2<i){let o=t[a+2];if(e.isHexadecimal(o)){n+=`\\x{`+o,a+=3;for(let r=0;r<3&&a<i&&(o=t[a],e.isHexadecimal(o));++a,++r)n+=o;n+=`}`,r=!0;continue}else if(o===`{`){n+=`\\x`,a+=2,r=!0;continue}}n+=`\\u`,a+=2;continue;default:{n+=`\\`;let r=e.getUtf8CharSize(o);n+=t.substring(a+1,a+1+r),a+=r+1;continue}}}else if(o===`/`){n+=`\\/`,a+=1,r=!0;continue}else if(o===`(`&&a+2<i&&t[a+1]===`?`&&t[a+2]===`<`&&(a+3>=i||t[a+3]!==`=`&&t[a+3]!==`!`)){n+=`(?P<`,a+=3,r=!0;continue}let s=e.getUtf8CharSize(o);n+=t.substring(a,a+s),a+=s}return r?n:t}},Ji=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return E.quoteMeta(e)}static quoteReplacement(e,t=!1){return ui.quoteReplacement(e,t)}static translateRegExp(e){return qi.translate(e)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new li(`Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH`);let i=S.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(i&=-129);let a=new e(t,n);return a.re2Input=Ki.compileImpl(r,i,(n&e.LONGEST_MATCH)!==0),a}static matches(t,n){return e.compile(t).testExact(n)}static initTest(t,n,r){if(t==null)throw Error(`pattern is null`);if(r==null)throw Error(`re2 is null`);let i=new e(t,n);return i.re2Input=r,i}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.testExact(e)}matcher(e){return Array.isArray(e)&&(e=ni.utf8(e)),new ui(this,e)}test(e){return Array.isArray(e)?this.re2Input.matchUTF8(e):this.re2Input.match(e)}testExact(e){let t=Array.isArray(e)?D.fromUTF8(e):D.fromUTF16(e);return this.re2Input.executeEngine(t,0,S.ANCHOR_BOTH,0)!==null}split(e,t=0){let n=this.matcher(e),r=[],i=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(t>0&&r.length===t-1)break;if(a===n.start()){if(t===0){i+=1,a=n.end();continue}}else for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.start())),a=n.end()}if(t===0&&a!==n.inputLength()){for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.inputLength()))}return(t!==0||r.length===0)&&r.push(n.substring(a,n.inputLength())),r}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}}});function Xi(e){let t=0;return e.includes(`i`)&&(t|=Ji.CASE_INSENSITIVE),e.includes(`m`)&&(t|=Ji.MULTILINE),e.includes(`s`)&&(t|=Ji.DOTALL),t}function Zi(e){return Ji.translateRegExp(e)}function M(e,t=``){return new Qi(e,t)}var Qi,$i,ea=g(()=>{Yi(),Qi=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;_matcher=null;_matcherInput=null;acquireMatcher(e){return this._matcher===null?(this._matcher=this._re2.matcher(e),this._matcherInput=e,this._matcher):(this._matcherInput!==e&&(this._matcher.matcherInput.charSequence=e,this._matcherInput=e),this._matcher.reset(),this._matcher)}constructor(e,t=``){this._pattern=e,this._flags=t,this._global=t.includes(`g`),this._ignoreCase=t.includes(`i`),this._multiline=t.includes(`m`);try{let n=Zi(e),r=Xi(t);this._re2=Ji.compile(n,r)}catch(t){if(t instanceof O){let n=t.message||``,r=``;throw n.includes(`(?=`)||n.includes(`(?!`)||n.includes(`(?<`)||n.includes(`(?<!`)||e.includes(`(?=`)||e.includes(`(?!`)||e.includes(`(?<=`)||e.includes(`(?<!`)?r=` Lookahead (?=, ?!) and lookbehind (?<=, ?<!) assertions are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support these features.`:(n.includes(`backreference`)||/\\[1-9]/.test(e))&&(r=` Backreferences (\\1, \\2, etc.) are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support backreferences.`),SyntaxError(`Invalid regular expression: /${e}/: ${n}${r}`)}throw t}}test(e){return this._global&&(this._lastIndex=0),this.acquireMatcher(e).find()}exec(e){let t=this.acquireMatcher(e),n=this._global?this._lastIndex:0;if(!t.find(n))return this._global&&(this._lastIndex=0),null;let r=this._re2.groupCount(),i=[];i.push(t.group(0)??``);for(let e=1;e<=r;e++){let n=t.group(e);i.push(n)}let a=i;a.index=t.start(0),a.input=e;let o=this._re2.namedGroups();if(o&&Object.keys(o).length>0){let e=Object.create(null);for(let[n,r]of Object.entries(o)){let i=t.group(r);i!==null&&(e[n]=i)}a.groups=e}return this._global&&(this._lastIndex=t.end(0),t.start(0)===t.end(0)&&this._lastIndex++),a}match(e){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(e);let t=[],n=this.acquireMatcher(e),r=0;for(;n.find(r);){let i=n.group(0)??``;if(t.push(i),r=n.end(0),n.start(0)===n.end(0)&&r++,r>e.length)break}return t.length>0?t:null}replace(e,t){if(this._global&&(this._lastIndex=0),typeof t==`string`){let n=this.acquireMatcher(e);return this._global?n.replaceAll(t,!0):n.replaceFirst(t,!0)}let n=[],r=this._re2.matcher(e),i=0,a=0,o=this._re2.groupCount(),s=this._re2.namedGroups();for(;r.find(a);){n.push(e.slice(i,r.start(0)));let c=[],l=r.group(0)??``;for(let e=1;e<=o;e++)c.push(r.group(e));if(c.push(r.start(0)),c.push(e),s&&Object.keys(s).length>0){let e=Object.create(null);for(let[t,n]of Object.entries(s))e[t]=r.group(n)??``;c.push(e)}let u=r.start(0),d=r.end(0);if(n.push(t(l,...c)),i=d,a=i,u===d&&a++,!this._global||a>e.length)break}return n.push(e.slice(i)),n.join(``)}split(e,t){return t===void 0||t<0?this._re2.split(e,-1):t===0?[]:this._re2.split(e,-1).slice(0,t)}search(e){let t=this.acquireMatcher(e);return t.find()?t.start(0):-1}*matchAll(e){if(!this._global)throw Error(`matchAll requires global flag`);this._lastIndex=0;let t=this._re2.matcher(e),n=this._re2.groupCount(),r=this._re2.namedGroups(),i=0;for(;t.find(i);){let a=[];a.push(t.group(0)??``);for(let e=1;e<=n;e++)a.push(t.group(e));let o=a;if(o.index=t.start(0),o.input=e,r&&Object.keys(r).length>0){let e=Object.create(null);for(let[n,i]of Object.entries(r)){let r=t.group(i);r!==null&&(e[n]=r)}o.groups=e}if(yield o,i=t.end(0),t.start(0)===t.end(0)&&i++,i>e.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=RegExp(``,this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(e){this._lastIndex=e}},$i=class{_regex;constructor(e){this._regex=e}test(e){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(e)}exec(e){return this._regex.exec(e)}match(e){return this._regex.global&&(this._regex.lastIndex=0),e.match(this._regex)}replace(e,t){return this._regex.global&&(this._regex.lastIndex=0),e.replace(this._regex,t)}split(e,t){return e.split(this._regex,t)}search(e){return e.search(this._regex)}*matchAll(e){if(!this._regex.global)throw Error(`matchAll requires global flag`);this._regex.lastIndex=0;let t=this._regex.exec(e);for(;t!==null;)yield t,t[0].length===0&&this._regex.lastIndex++,t=this._regex.exec(e)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(e){this._regex.lastIndex=e}}}),ta=g(()=>{ea()});function na(e,t,n){let r=typeof n==`boolean`?{ignoreCase:n}:n??{},i=t;r.stripQuotes&&(i.startsWith(`"`)&&i.endsWith(`"`)||i.startsWith(`'`)&&i.endsWith(`'`))&&(i=i.slice(1,-1));let a=r.ignoreCase?`i:${i}`:i,o=aa.get(a);if(!o){if(o=ra(i,r.ignoreCase),aa.size>=ia){let e=aa.keys().next().value;e!==void 0&&aa.delete(e)}aa.set(a,o)}return o.test(e)}function ra(e,t){let n=`^`;for(let t=0;t<e.length;t++){let r=e[t];if(r===`*`)n+=`.*`;else if(r===`?`)n+=`.`;else if(r===`[`){let r=t+1;for(;r<e.length&&e[r]!==`]`;)r++;n+=e.slice(t,r+1),t=r}else r===`.`||r===`+`||r===`^`||r===`$`||r===`{`||r===`}`||r===`(`||r===`)`||r===`|`||r===`\\`?n+=`\\${r}`:n+=r}return n+=`$`,M(n,t?`i`:``)}var ia,aa;_({},{egrepCommand:()=>da,egrepFlagsForFuzzing:()=>ma,fgrepCommand:()=>ua,fgrepFlagsForFuzzing:()=>pa,flagsForFuzzing:()=>fa,grepCommand:()=>ca});async function oa(e,t,n,r,i=0){if(i>=la)return;let a=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(a)).isDirectory){let n=e.split(`/`).pop()||``;t&&na(n,t.replace(/^\//,``),{stripQuotes:!0})&&r.push(e);return}let o=await n.fs.readdir(a);for(let a of o){let o=e===`.`?a:`${e}/${a}`,s=n.fs.resolvePath(n.cwd,o);(await n.fs.stat(s)).isDirectory?await oa(o,t,n,r,i+1):t&&na(a,t.replace(/^\//,``),{stripQuotes:!0})&&r.push(o)}}catch{}}async function sa(e,t,n=[],r=[],i=[],a,o=0){if(o>=la)return[];let s=t.fs.resolvePath(t.cwd,e),c=[];try{let l,u;if(a!==void 0)l=a,u=!a;else{let e=await t.fs.stat(s);l=e.isFile,u=e.isDirectory}if(l){let t=e.split(`/`).pop()||e;return r.length>0&&r.some(e=>na(t,e,{stripQuotes:!0}))||n.length>0&&!n.some(e=>na(t,e,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!u)return[];let d=e.split(`/`).pop()||e;if(i.length>0&&i.some(e=>na(d,e,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let a=await t.fs.readdirWithFileTypes(s);for(let s of a){if(s.name.startsWith(`.`))continue;let a=await sa(e===`.`?s.name:`${e}/${s.name}`,t,n,r,i,s.isFile,o+1);c.push(...a)}}else{let a=await t.fs.readdir(s);for(let s of a){if(s.startsWith(`.`))continue;let a=await sa(e===`.`?s:`${e}/${s}`,t,n,r,i,void 0,o+1);c.push(...a)}}}catch{}return c}var ca,la,ua,da,fa,pa,ma;function ha(e,t){if(Array.isArray(e))throw TypeError(`${t}: expected object, got array`);if(Object.getPrototypeOf(e)!==null)throw TypeError(`${t}: expected null-prototype object, got prototypal object`)}function N(e){return!ba.has(e)}function P(e,t,n){ha(e,`safeSet`),N(t)&&(e[t]=n)}function ga(e,t){return ha(e,`safeHasOwn`),Object.hasOwn(e,t)}function _a(e){let t=new WeakMap,n=e=>{if(typeof e!=`object`||!e||e instanceof Date)return e;let r=t.get(e);if(r!==void 0)return r;if(Array.isArray(e)){let r=[];t.set(e,r);for(let t of e)r.push(n(t));return r}let i=Object.create(null);t.set(e,i);for(let t of Object.keys(e))i[t]=n(e[t]);return i};return n(e)}function F(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function va(e){return Object.assign(Object.create(null),e)}function ya(...e){return Object.assign(Object.create(null),...e)}var ba,xa;async function Sa(e,t,n,r,i,a,o,s){if(!(r>=i.maxDepth)){a&&await a.loadForDirectory(n);try{let c=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(n):(await e.fs.readdir(n)).map(e=>({name:e,isFile:void 0}));for(let l of c){let c=l.name;if(!i.noIgnore&&xa.isCommonIgnored(c))continue;let u=c.startsWith(`.`),d=t===`.`?c:t===`./`?`./${c}`:t.endsWith(`/`)?`${t}${c}`:`${t}/${c}`,f=e.fs.resolvePath(n,c),p,m,h=!1;if(l.isFile!==void 0&&`isDirectory`in l){let t=l;if(h=t.isSymbolicLink===!0,h&&!i.followSymlinks)continue;if(h&&i.followSymlinks)try{let t=await e.fs.stat(f);p=t.isFile,m=t.isDirectory}catch{continue}else p=t.isFile,m=t.isDirectory}else try{let t=e.fs.lstat?await e.fs.lstat(f):await e.fs.stat(f);if(h=t.isSymbolicLink===!0,h&&!i.followSymlinks)continue;let n=h&&i.followSymlinks?await e.fs.stat(f):t;p=n.isFile,m=n.isDirectory}catch{continue}if(!a?.matches(f,m)&&!(u&&!i.hidden&&!a?.isWhitelisted(f,m))){if(m)await Sa(e,d,f,r+1,i,a,o,s);else if(p){if(i.maxFilesize>0)try{if((await e.fs.stat(f)).size>i.maxFilesize)continue}catch{continue}Ca(d,i,a,f,o)&&s.push(d)}}}}catch{}}}function Ca(e,t,n,r,i){let a=e.split(`/`).pop()||e;if(n?.matches(r,!1)||t.types.length>0&&!i.matchesType(a,t.types)||t.typesNot.length>0&&i.matchesType(a,t.typesNot))return!1;if(t.globs.length>0){let n=t.globCaseInsensitive,r=t.globs.filter(e=>!e.startsWith(`!`)),i=t.globs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(r.length>0){let t=!1;for(let i of r)if(wa(a,i,n)||wa(e,i,n)){t=!0;break}if(!t)return!1}for(let t of i)if(t.startsWith(`/`)){if(wa(e,t.slice(1),n))return!1}else if(wa(a,t,n)||wa(e,t,n))return!1}if(t.iglobs.length>0){let n=t.iglobs.filter(e=>!e.startsWith(`!`)),r=t.iglobs.filter(e=>e.startsWith(`!`)).map(e=>e.slice(1));if(n.length>0){let t=!1;for(let r of n)if(wa(a,r,!0)||wa(e,r,!0)){t=!0;break}if(!t)return!1}for(let t of r)if(t.startsWith(`/`)){if(wa(e,t.slice(1),!0))return!1}else if(wa(a,t,!0)||wa(e,t,!0))return!1}return!0}function wa(e,t,n=!1){let r=`^`;for(let e=0;e<t.length;e++){let n=t[e];if(n===`*`)t[e+1]===`*`?(r+=`.*`,e++):r+=`[^/]*`;else if(n===`?`)r+=`[^/]`;else if(n===`[`){let n=e+1;for(n<t.length&&t[n]===`!`&&n++,n<t.length&&t[n]===`]`&&n++;n<t.length&&t[n]!==`]`;)n++;if(n<t.length){let i=t.slice(e,n+1);i.startsWith(`[!`)&&(i=`[^${i.slice(2)}`),r+=i,e=n}else r+=`\\[`}else r+=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}return r+=`$`,M(r,n?`i`:``).test(e)}_({},{flagsForFuzzing:()=>Ea,rgCommand:()=>Ta});var Ta,Ea;function Da(e,t,n){if(!e||qn.isInSandboxedContext())return;let r=`${t} ${n} attempted outside defense context`;throw new v(r,{timestamp:Date.now(),type:`missing_defense_context`,message:r,path:`DefenseInDepthBox.context`,stack:Error().stack,executionId:qn.getCurrentExecutionId()})}async function Oa(e,t,n,r){Da(e,t,`${n} (pre-await)`);let i=await r();return Da(e,t,`${n} (post-await)`),i}var ka=g(()=>{Jn()});function Aa(e){let t=``,n=0,r=!1;for(;n<e.length;){if(e[n]===`[`&&!r){if(e[n+1]===`[`&&e[n+2]===`:`){let r=e.indexOf(`:]]`,n+3);if(r!==-1){let i=e.slice(n+3,r),a=Na.get(i);if(a){t+=`[${a}]`,n=r+3;continue}}}if(e[n+1]===`^`&&e[n+2]===`[`&&e[n+3]===`:`){let r=e.indexOf(`:]]`,n+4);if(r!==-1){let i=e.slice(n+4,r),a=Na.get(i);if(a){t+=`[^${a}]`,n=r+3;continue}}}t+=`[`,n++,r=!0,n<e.length&&e[n]===`^`&&(t+=`^`,n++),n<e.length&&e[n]===`]`&&(t+=`\\]`,n++);continue}if(r){if(e[n]===`]`){t+=`]`,n++,r=!1;continue}if(e[n]===`[`&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r),a=Na.get(i);if(a){t+=a,n=r+2;continue}}}if(e[n]===`\\`&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++;continue}if(e[n]===`\\`&&n+1<e.length){let r=e[n+1];if(r===`+`||r===`?`||r===`|`){t+=r,n+=2;continue}if(r===`(`||r===`)`){t+=r,n+=2;continue}if(r===`{`||r===`}`){t+=r,n+=2;continue}if(r===`t`){t+=` `,n+=2;continue}if(r===`n`){t+=`
110
110
  `,n+=2;continue}if(r===`r`){t+=`\r`,n+=2;continue}t+=e[n]+r,n+=2;continue}if(e[n]===`+`||e[n]===`?`||e[n]===`|`||e[n]===`(`||e[n]===`)`){t+=`\\${e[n]}`,n++;continue}if(e[n]===`^`&&!(t===``||t.endsWith(`(`))){t+=`\\^`,n++;continue}if(e[n]===`$`){let r=n===e.length-1,i=n+2<e.length&&e[n+1]===`\\`&&e[n+2]===`)`;if(!r&&!i){t+=`\\$`,n++;continue}}t+=e[n],n++}return t}function ja(e){let t=``,n=!1;for(let r=0;r<e.length;r++)e[r]===`[`&&!n?(n=!0,t+=`[`,r++,r<e.length&&e[r]===`^`&&(t+=`^`,r++),r<e.length&&e[r]===`]`&&(t+=`]`,r++),r--):e[r]===`]`&&n?(n=!1,t+=`]`):!n&&e[r]===`{`&&e[r+1]===`,`?(t+=`{0,`,r++):t+=e[r];return t}function Ma(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=r.charCodeAt(0);r===`\\`?t+=`\\\\`:r===` `?t+=`\\t`:r===`
111
111
  `?t+=`$
112
112
  `:r===`\r`?t+=`\\r`:r===`\x07`?t+=`\\a`:r===`\b`?t+=`\\b`:r===`\f`?t+=`\\f`:r===`\v`?t+=`\\v`:i<32||i>=127?t+=`\\${i.toString(8).padStart(3,`0`)}`:t+=r}return`${t}$`}var Na;function Pa(e){return typeof e==`object`&&`first`in e&&`step`in e}function Fa(e){return typeof e==`object`&&`offset`in e}function Ia(e,t,n,r,i){if(e===`$`)return t===n;if(typeof e==`number`)return t===e;if(Pa(e)){let{first:n,step:r}=e;return r===0?t===n:(t-n)%r===0&&t>=n}if(typeof e==`object`&&`pattern`in e)try{let t=e.pattern;return t===``&&i?.lastPattern?t=i.lastPattern:t!==``&&i&&(i.lastPattern=t),M(ja(Aa(t))).test(r)}catch{return!1}return!1}function La(e){let t=e=>e===void 0?`undefined`:e===`$`?`$`:typeof e==`number`?String(e):`pattern`in e?`/${e.pattern}/`:`first`in e?`${e.first}~${e.step}`:`unknown`;return`${t(e.start)},${t(e.end)}`}function Ra(e,t,n,r,i,a){if(!e||!e.start&&!e.end)return!0;let o=e.start,s=e.end;if(o!==void 0&&s===void 0)return Ia(o,t,n,r,a);if(o!==void 0&&s!==void 0){let c=typeof o==`object`&&`pattern`in o,l=typeof s==`object`&&`pattern`in s,u=Fa(s);if(u&&i){let c=La(e),l=i.get(c);return l||(l={active:!1},i.set(c,l)),l.active?(t>=(l.startLine||t)+s.offset&&(l.active=!1,i.set(c,l)),!0):Ia(o,t,n,r,a)?(l.active=!0,l.startLine=t,i.set(c,l),s.offset===0&&(l.active=!1,i.set(c,l)),!0):!1}if(!c&&!l&&!u){let r=typeof o==`number`?o:o===`$`?n:1,a=typeof s==`number`?s:n;if(r<=a)return t>=r&&t<=a;if(i){let n=La(e),a=i.get(n);return a||(a={active:!1},i.set(n,a)),!a.completed&&t>=r?(a.completed=!0,i.set(n,a),!0):!1}return!1}if(i){let c=La(e),l=i.get(c);if(l||(l={active:!1},i.set(c,l)),l.active)return Ia(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0;{if(l.completed)return!1;let e=!1;return e=typeof o==`number`?t>=o:Ia(o,t,n,r,a),e?(l.active=!0,l.startLine=t,i.set(c,l),Ia(s,t,n,r,a)&&(l.active=!1,typeof o==`number`&&(l.completed=!0),i.set(c,l)),!0):!1}}return Ia(o,t,n,r,a)}return!0}function za(e,t,n,r,i,a){let o=Ra(e,t,n,r,i,a);return e?.negated?!o:o}function Ba(e,t,n,r){let i=``,a=0,o=!1;for(;a<=e.length;){t.lastIndex=a;let n=t.exec(e);if(!n){i+=e.slice(a);break}if(n.index!==a){i+=e.slice(a,n.index),a=n.index,o=!1;continue}let s=n[0],c=n.slice(1);if(o&&s.length===0){if(a<e.length)i+=e[a],a++;else break;o=!1;continue}if(i+=r(s,c),o=!1,s.length===0)if(a<e.length)i+=e[a],a++;else break;else a+=s.length,o=!0}return i}function Va(e,t,n){let r=``,i=0;for(;i<e.length;){if(e[i]===`\\`&&i+1<e.length){let a=e[i+1];if(a===`&`){r+=`&`,i+=2;continue}if(a===`n`){r+=`
@@ -148,37 +148,44 @@ ${o.repeat(a)}}`}return String(e)}var Cl,wl;_({},{base64Command:()=>Tl,flagsForF
148
148
  `,exitCode:1};let i=uu(n),u;try{u=Ct(l,{level:i})}catch(e){return{stdout:``,stderr:`${r}: ${t}: ${e instanceof Error?e.message:`unknown error`}
149
149
  `,exitCode:1}}if(a)return{stdout:mu(u),stderr:``,exitCode:0};if(c=s+o,!n.force)try{return await e.fs.stat(c),{stdout:``,stderr:`${r}: ${c} already exists; not overwritten
150
150
  `,exitCode:1}}catch{}return await e.fs.writeFile(c,u),!n.keep&&!a&&await e.fs.rm(s),n.verbose?{stdout:``,stderr:`${t}: ${l.length>0?((1-u.length/l.length)*100).toFixed(1):`0.0`}% -- replaced with ${c.split(`/`).pop()}
151
- `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}}async function vu(e,t,n,r,i,a){let o=await e.fs.readdir(t),s=``,c=``,l=0;for(let u of o){let o=e.fs.resolvePath(t,u),d=await e.fs.stat(o);if(d.isDirectory){let t=await vu(e,o,n,r,i,a);s+=t.stdout,c+=t.stderr,t.exitCode!==0&&(l=t.exitCode)}else if(d.isFile){let t=n.suffix;if(i&&!u.endsWith(t)||!i&&u.endsWith(t))continue;let d=await _u(e,o.startsWith(`${e.cwd}/`)?o.slice(e.cwd.length+1):o,n,r,i,a);s+=d.stdout,c+=d.stderr,d.exitCode!==0&&(l=d.exitCode)}}return{stdout:s,stderr:c,exitCode:l}}var yu,bu,xu,Su,Cu,wu,Tu=g(()=>{new TextEncoder,new TextDecoder});_({},{curlCommand:()=>Eu});var Eu,Du,Ou=g(()=>{Du=`5.1.0(1)-release`});function ku(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let n=e.slice(t[0].length);if(n===``||n===`+`)return!0;if(n[0]===`[`){let e=0,t=0;for(;t<n.length;t++)if(n[t]===`[`)e++;else if(n[t]===`]`&&(e--,e===0))break;if(e!==0||t>=n.length)return!1;let r=n.slice(t+1);return r===``||r===`+`}return!1}function Au(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r===`[`)t++;else if(r===`]`)t--;else{if(t===0&&r===`=`)return n;if(t===0&&r===`+`&&e[n+1]===`=`)return n+1}}return-1}function ju(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Mu(e){return e===` `||e===` `||e===`
152
- `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`}var U,Nu,Pu,Fu,Iu,Lu,Ru,zu=g(()=>{(function(e){e.EOF=`EOF`,e.NEWLINE=`NEWLINE`,e.SEMICOLON=`SEMICOLON`,e.AMP=`AMP`,e.PIPE=`PIPE`,e.PIPE_AMP=`PIPE_AMP`,e.AND_AND=`AND_AND`,e.OR_OR=`OR_OR`,e.BANG=`BANG`,e.LESS=`LESS`,e.GREAT=`GREAT`,e.DLESS=`DLESS`,e.DGREAT=`DGREAT`,e.LESSAND=`LESSAND`,e.GREATAND=`GREATAND`,e.LESSGREAT=`LESSGREAT`,e.DLESSDASH=`DLESSDASH`,e.CLOBBER=`CLOBBER`,e.TLESS=`TLESS`,e.AND_GREAT=`AND_GREAT`,e.AND_DGREAT=`AND_DGREAT`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.DSEMI=`DSEMI`,e.SEMI_AND=`SEMI_AND`,e.SEMI_SEMI_AND=`SEMI_SEMI_AND`,e.DBRACK_START=`DBRACK_START`,e.DBRACK_END=`DBRACK_END`,e.DPAREN_START=`DPAREN_START`,e.DPAREN_END=`DPAREN_END`,e.IF=`IF`,e.THEN=`THEN`,e.ELSE=`ELSE`,e.ELIF=`ELIF`,e.FI=`FI`,e.FOR=`FOR`,e.WHILE=`WHILE`,e.UNTIL=`UNTIL`,e.DO=`DO`,e.DONE=`DONE`,e.CASE=`CASE`,e.ESAC=`ESAC`,e.IN=`IN`,e.FUNCTION=`FUNCTION`,e.SELECT=`SELECT`,e.TIME=`TIME`,e.COPROC=`COPROC`,e.WORD=`WORD`,e.NAME=`NAME`,e.NUMBER=`NUMBER`,e.ASSIGNMENT_WORD=`ASSIGNMENT_WORD`,e.FD_VARIABLE=`FD_VARIABLE`,e.COMMENT=`COMMENT`,e.HEREDOC_CONTENT=`HEREDOC_CONTENT`})(U||={}),Nu=class extends Error{line;column;constructor(e,t,n){super(`line ${t}: ${e}`),this.line=t,this.column=n,this.name=`LexerError`}},Pu=new Map([[`if`,U.IF],[`then`,U.THEN],[`else`,U.ELSE],[`elif`,U.ELIF],[`fi`,U.FI],[`for`,U.FOR],[`while`,U.WHILE],[`until`,U.UNTIL],[`do`,U.DO],[`done`,U.DONE],[`case`,U.CASE],[`esac`,U.ESAC],[`in`,U.IN],[`function`,U.FUNCTION],[`select`,U.SELECT],[`time`,U.TIME],[`coproc`,U.COPROC]]),Fu=[[`;`,`;`,`&`,U.SEMI_SEMI_AND],[`<`,`<`,`<`,U.TLESS],[`&`,`>`,`>`,U.AND_DGREAT]],Iu=[[`[`,`[`,U.DBRACK_START],[`]`,`]`,U.DBRACK_END],[`(`,`(`,U.DPAREN_START],[`)`,`)`,U.DPAREN_END],[`&`,`&`,U.AND_AND],[`|`,`|`,U.OR_OR],[`;`,`;`,U.DSEMI],[`;`,`&`,U.SEMI_AND],[`|`,`&`,U.PIPE_AMP],[`>`,`>`,U.DGREAT],[`<`,`&`,U.LESSAND],[`>`,`&`,U.GREATAND],[`<`,`>`,U.LESSGREAT],[`>`,`|`,U.CLOBBER],[`&`,`>`,U.AND_GREAT]],Lu=new Map([[`|`,U.PIPE],[`&`,U.AMP],[`;`,U.SEMICOLON],[`(`,U.LPAREN],[`)`,U.RPAREN],[`<`,U.LESS],[`>`,U.GREAT]]),Ru=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];dparenDepth=0;maxHeredocSize;constructor(e,t){this.input=e,this.maxHeredocSize=t?.maxHeredocSize??10485760}tokenize(){let e=this.input.length,t=this.tokens,n=this.pendingHeredocs;for(;this.pos<e;){if(n.length>0&&t.length>0&&t[t.length-1].type===U.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=e)break;let r=this.nextToken();r&&t.push(r)}return t.push({type:U.EOF,value:``,start:this.pos,end:this.pos,line:this.line,column:this.column}),t}skipWhitespace(){let e=this.input,t=e.length,n=this.pos,r=this.column,i=this.line;for(;n<t;){let t=e[n];if(t===` `||t===` `)n++,r++;else if(t===`\\`&&e[n+1]===`
151
+ `,exitCode:0}:{stdout:``,stderr:``,exitCode:0}}}async function vu(e,t,n,r,i,a){let o=await e.fs.readdir(t),s=``,c=``,l=0;for(let u of o){let o=e.fs.resolvePath(t,u),d=await e.fs.stat(o);if(d.isDirectory){let t=await vu(e,o,n,r,i,a);s+=t.stdout,c+=t.stderr,t.exitCode!==0&&(l=t.exitCode)}else if(d.isFile){let t=n.suffix;if(i&&!u.endsWith(t)||!i&&u.endsWith(t))continue;let d=await _u(e,o.startsWith(`${e.cwd}/`)?o.slice(e.cwd.length+1):o,n,r,i,a);s+=d.stdout,c+=d.stderr,d.exitCode!==0&&(l=d.exitCode)}}return{stdout:s,stderr:c,exitCode:l}}var yu,bu,xu,Su,Cu,wu,Tu=g(()=>{new TextEncoder,new TextDecoder});_({},{curlCommand:()=>Eu});var Eu,Du,Ou=g(()=>{Du=`5.1.0(1)-release`}),U,ku=g(()=>{U={script(e){return{type:`Script`,statements:e}},statement(e,t=[],n=!1,r,i){let a={type:`Statement`,pipelines:e,operators:t,background:n};return r&&(a.deferredError=r),i!==void 0&&(a.sourceText=i),a},pipeline(e,t=!1,n=!1,r=!1,i){return{type:`Pipeline`,commands:e,negated:t,timed:n,timePosix:r,pipeStderr:i}},simpleCommand(e,t=[],n=[],r=[]){return{type:`SimpleCommand`,name:e,args:t,assignments:n,redirections:r}},word(e){return{type:`Word`,parts:e}},literal(e){return{type:`Literal`,value:e}},singleQuoted(e){return{type:`SingleQuoted`,value:e}},doubleQuoted(e){return{type:`DoubleQuoted`,parts:e}},escaped(e){return{type:`Escaped`,value:e}},parameterExpansion(e,t=null){return{type:`ParameterExpansion`,parameter:e,operation:t}},commandSubstitution(e,t=!1){return{type:`CommandSubstitution`,body:e,legacy:t}},arithmeticExpansion(e){return{type:`ArithmeticExpansion`,expression:e}},assignment(e,t,n=!1,r=null){return{type:`Assignment`,name:e,value:t,append:n,array:r}},redirection(e,t,n=null,r){let i={type:`Redirection`,fd:n,operator:e,target:t};return r&&(i.fdVariable=r),i},hereDoc(e,t,n=!1,r=!1){return{type:`HereDoc`,delimiter:e,content:t,stripTabs:n,quoted:r}},ifNode(e,t=null,n=[]){return{type:`If`,clauses:e,elseBody:t,redirections:n}},forNode(e,t,n,r=[]){return{type:`For`,variable:e,words:t,body:n,redirections:r}},whileNode(e,t,n=[]){return{type:`While`,condition:e,body:t,redirections:n}},untilNode(e,t,n=[]){return{type:`Until`,condition:e,body:t,redirections:n}},caseNode(e,t,n=[]){return{type:`Case`,word:e,items:t,redirections:n}},caseItem(e,t,n=`;;`){return{type:`CaseItem`,patterns:e,body:t,terminator:n}},subshell(e,t=[]){return{type:`Subshell`,body:e,redirections:t}},group(e,t=[]){return{type:`Group`,body:e,redirections:t}},functionDef(e,t,n=[],r){return{type:`FunctionDef`,name:e,body:t,redirections:n,sourceFile:r}},conditionalCommand(e,t=[],n){return{type:`ConditionalCommand`,expression:e,redirections:t,line:n}},arithmeticCommand(e,t=[],n){return{type:`ArithmeticCommand`,expression:e,redirections:t,line:n}}}});function Au(e,t){let n=e.length,r=t+3,i=2,a=!1,o=!1;for(;r<n&&i>0;){let t=e[r];if(a){t===`'`&&(a=!1),r++;continue}if(o){if(t===`\\`){r+=2;continue}t===`"`&&(o=!1),r++;continue}if(t===`'`){a=!0,r++;continue}if(t===`"`){o=!0,r++;continue}if(t===`\\`){r+=2;continue}if(t===`(`){i++,r++;continue}if(t===`)`){if(i--,i===1){let t=r+1;return!(t<n&&e[t]===`)`)}if(i===0)return!1;r++;continue}if(i===1&&(t===`|`&&r+1<n&&e[r+1]===`|`||t===`&`&&r+1<n&&e[r+1]===`&`||t===`|`&&r+1<n&&e[r+1]!==`|`))return!0;r++}return!1}function ju(e,t){let n=``,r=t,i=e=>e===` `||e===` `||e===`
152
+ `||e===`;`||e===`&`||e===`|`||e===`<`||e===`>`||e===`(`||e===`)`;for(;r<e.length;){let t=e[r];if(t===`'`){for(r++;r<e.length&&e[r]!==`'`;)n+=e[r],r++;r<e.length&&r++;continue}if(t===`"`){for(r++;r<e.length&&e[r]!==`"`;)e[r]===`\\`&&r+1<e.length&&r++,n+=e[r],r++;r<e.length&&r++;continue}if(t===`\\`&&r+1<e.length){n+=e[r+1],r+=2;continue}if(i(t))break;n+=t,r++}return{delim:n,endPos:r}}function Mu(e,t,n){let r=t+1;for(let{delim:t,stripTabs:i}of n)for(;;){if(r>=e.length)return e.length;let n=e.indexOf(`
153
+ `,r);n===-1&&(n=e.length);let a=e.slice(r,n);if(i&&(a=a.replace(/^\t+/,``)),a===t){r=n+1;break}if(n>=e.length)return e.length;r=n+1}return Math.min(r,e.length)}function Nu(e,t,n,r){let i=t+2,a=1,o=i,s=!1,c=!1,l=0,u=!1,d=``,f=[],p=0;for(;o<e.length&&a>0;){let t=e[o];if(s)t===`'`&&(s=!1);else if(c)t===`\\`&&o+1<e.length?o++:t===`"`&&(c=!1);else{if(t===`(`&&e[o+1]===`(`?p++:t===`)`&&e[o+1]===`)`&&p>0&&p--,p===0&&t===`<`&&e[o+1]===`<`&&e[o+2]!==`<`){let t=o+2,n=!1;for(e[t]===`-`&&(n=!0,t++);e[t]===` `||e[t]===` `;)t++;let{delim:r,endPos:i}=ju(e,t);if(r.length>0){f.push({delim:r,stripTabs:n}),d=``,o=i;continue}}if(t===`
154
+ `&&f.length>0){let t=Mu(e,o,f);f.length=0,d=``,o=t;continue}t===`'`?(s=!0,d=``):t===`"`?(c=!0,d=``):t===`\\`&&o+1<e.length?(o++,d=``):/[a-zA-Z_]/.test(t)?d+=t:(d===`case`?(l++,u=!1):d===`in`&&l>0?u=!0:d===`esac`&&l>0&&(l--,u=!1),d=``,t===`(`?o>0&&e[o-1]===`$`?a++:u||a++:t===`)`?u?u=!1:a--:t===`;`&&l>0&&o+1<e.length&&e[o+1]===`;`&&(u=!0))}a>0&&o++}a>0&&r("unexpected EOF while looking for matching `)'");let m=e.slice(i,o),h=n().parse(m);return{part:U.commandSubstitution(h,!1),endIndex:o+1}}function Pu(e,t,n,r,i){let a=t+1,o=``;for(;a<e.length&&e[a]!=="`";)if(e[a]===`\\`){let t=e[a+1];t===`$`||t==="`"||t===`\\`||t===`
155
+ `||n&&t===`"`?(t!==`
156
+ `&&(o+=t),a+=2):(o+=e[a],a++)}else o+=e[a],a++;a>=e.length&&i("unexpected EOF while looking for matching ``'");let s=r().parse(o);return{part:U.commandSubstitution(s,!0),endIndex:a+1}}var Fu=g(()=>{ku()});function Iu(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let n=e.slice(t[0].length);if(n===``||n===`+`)return!0;if(n[0]===`[`){let e=0,t=0;for(;t<n.length;t++)if(n[t]===`[`)e++;else if(n[t]===`]`&&(e--,e===0))break;if(e!==0||t>=n.length)return!1;let r=n.slice(t+1);return r===``||r===`+`}return!1}function Lu(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r===`[`)t++;else if(r===`]`)t--;else{if(t===0&&r===`=`)return n;if(t===0&&r===`+`&&e[n+1]===`=`)return n+1}}return-1}function Ru(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function zu(e){return e===` `||e===` `||e===`
157
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`}var Bu,W,Vu,Hu,Uu,Wu,Gu,Ku,qu=g(()=>{Fu(),Bu=10485760,(function(e){e.EOF=`EOF`,e.NEWLINE=`NEWLINE`,e.SEMICOLON=`SEMICOLON`,e.AMP=`AMP`,e.PIPE=`PIPE`,e.PIPE_AMP=`PIPE_AMP`,e.AND_AND=`AND_AND`,e.OR_OR=`OR_OR`,e.BANG=`BANG`,e.LESS=`LESS`,e.GREAT=`GREAT`,e.DLESS=`DLESS`,e.DGREAT=`DGREAT`,e.LESSAND=`LESSAND`,e.GREATAND=`GREATAND`,e.LESSGREAT=`LESSGREAT`,e.DLESSDASH=`DLESSDASH`,e.CLOBBER=`CLOBBER`,e.TLESS=`TLESS`,e.AND_GREAT=`AND_GREAT`,e.AND_DGREAT=`AND_DGREAT`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.DSEMI=`DSEMI`,e.SEMI_AND=`SEMI_AND`,e.SEMI_SEMI_AND=`SEMI_SEMI_AND`,e.DBRACK_START=`DBRACK_START`,e.DBRACK_END=`DBRACK_END`,e.DPAREN_START=`DPAREN_START`,e.DPAREN_END=`DPAREN_END`,e.IF=`IF`,e.THEN=`THEN`,e.ELSE=`ELSE`,e.ELIF=`ELIF`,e.FI=`FI`,e.FOR=`FOR`,e.WHILE=`WHILE`,e.UNTIL=`UNTIL`,e.DO=`DO`,e.DONE=`DONE`,e.CASE=`CASE`,e.ESAC=`ESAC`,e.IN=`IN`,e.FUNCTION=`FUNCTION`,e.SELECT=`SELECT`,e.TIME=`TIME`,e.COPROC=`COPROC`,e.WORD=`WORD`,e.NAME=`NAME`,e.NUMBER=`NUMBER`,e.ASSIGNMENT_WORD=`ASSIGNMENT_WORD`,e.FD_VARIABLE=`FD_VARIABLE`,e.COMMENT=`COMMENT`,e.HEREDOC_CONTENT=`HEREDOC_CONTENT`})(W||={}),Vu=class extends Error{line;column;constructor(e,t,n){super(`line ${t}: ${e}`),this.line=t,this.column=n,this.name=`LexerError`}},Hu=new Map([[`if`,W.IF],[`then`,W.THEN],[`else`,W.ELSE],[`elif`,W.ELIF],[`fi`,W.FI],[`for`,W.FOR],[`while`,W.WHILE],[`until`,W.UNTIL],[`do`,W.DO],[`done`,W.DONE],[`case`,W.CASE],[`esac`,W.ESAC],[`in`,W.IN],[`function`,W.FUNCTION],[`select`,W.SELECT],[`time`,W.TIME],[`coproc`,W.COPROC]]),Uu=[[`;`,`;`,`&`,W.SEMI_SEMI_AND],[`<`,`<`,`<`,W.TLESS],[`&`,`>`,`>`,W.AND_DGREAT]],Wu=[[`[`,`[`,W.DBRACK_START],[`]`,`]`,W.DBRACK_END],[`(`,`(`,W.DPAREN_START],[`)`,`)`,W.DPAREN_END],[`&`,`&`,W.AND_AND],[`|`,`|`,W.OR_OR],[`;`,`;`,W.DSEMI],[`;`,`&`,W.SEMI_AND],[`|`,`&`,W.PIPE_AMP],[`>`,`>`,W.DGREAT],[`<`,`&`,W.LESSAND],[`>`,`&`,W.GREATAND],[`<`,`>`,W.LESSGREAT],[`>`,`|`,W.CLOBBER],[`&`,`>`,W.AND_GREAT]],Gu=new Map([[`|`,W.PIPE],[`&`,W.AMP],[`;`,W.SEMICOLON],[`(`,W.LPAREN],[`)`,W.RPAREN],[`<`,W.LESS],[`>`,W.GREAT]]),Ku=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];dparenDepth=0;maxHeredocSize;constructor(e,t){this.input=e,this.maxHeredocSize=t?.maxHeredocSize??Bu}tokenize(){let e=this.input.length,t=this.tokens,n=this.pendingHeredocs;for(;this.pos<e;){if(n.length>0&&t.length>0&&t[t.length-1].type===W.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=e)break;let r=this.nextToken();r&&t.push(r)}return t.push({type:W.EOF,value:``,start:this.pos,end:this.pos,line:this.line,column:this.column}),t}skipWhitespace(){let e=this.input,t=e.length,n=this.pos,r=this.column,i=this.line;for(;n<t;){let t=e[n];if(t===` `||t===` `)n++,r++;else if(t===`\\`&&e[n+1]===`
153
158
  `)n+=2,i++,r=1;else break}this.pos=n,this.column=r,this.line=i}nextToken(){let e=this.input,t=this.pos,n=this.line,r=this.column,i=e[t],a=e[t+1],o=e[t+2];if(i===`#`&&this.dparenDepth===0)return this.readComment(t,n,r);if(i===`
154
- `)return this.pos=t+1,this.line++,this.column=1,{type:U.NEWLINE,value:`
155
- `,start:t,end:t+1,line:n,column:r};if(i===`<`&&a===`<`&&o===`-`)return this.pos=t+3,this.column=r+3,this.registerHeredocFromLookahead(!0),this.makeToken(U.DLESSDASH,`<<-`,t,n,r);for(let[e,s,c,l]of Fu)if(i===e&&a===s&&o===c)return this.pos=t+3,this.column=r+3,this.makeToken(l,e+s+c,t,n,r);if(i===`<`&&a===`<`)return this.pos=t+2,this.column=r+2,this.registerHeredocFromLookahead(!1),this.makeToken(U.DLESS,`<<`,t,n,r);if(i===`(`&&a===`(`)return this.dparenDepth>0?(this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(U.LPAREN,`(`,t,n,r)):this.looksLikeNestedSubshells(t+2)||this.dparenClosesWithSpacedParens(t+2)?(this.pos=t+1,this.column=r+1,this.makeToken(U.LPAREN,`(`,t,n,r)):(this.pos=t+2,this.column=r+2,this.dparenDepth=1,this.makeToken(U.DPAREN_START,`((`,t,n,r));if(i===`)`&&a===`)`)return this.dparenDepth===1?(this.pos=t+2,this.column=r+2,this.dparenDepth=0,this.makeToken(U.DPAREN_END,`))`,t,n,r)):this.dparenDepth>1?(this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(U.RPAREN,`)`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(U.RPAREN,`)`,t,n,r));for(let[o,s,c]of Iu)if(!(o===`(`&&s===`(`||o===`)`&&s===`)`)&&!(this.dparenDepth>0&&o===`;`&&(c===U.DSEMI||c===U.SEMI_AND||c===U.SEMI_SEMI_AND))&&i===o&&a===s){if(c===U.DBRACK_START||c===U.DBRACK_END){let n=e[t+2];if(n!==void 0&&n!==` `&&n!==` `&&n!==`
156
- `&&n!==`;`&&n!==`&`&&n!==`|`&&n!==`(`&&n!==`)`&&n!==`<`&&n!==`>`)break}return this.pos=t+2,this.column=r+2,this.makeToken(c,o+s,t,n,r)}if(i===`(`&&this.dparenDepth>0)return this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(U.LPAREN,`(`,t,n,r);if(i===`)`&&this.dparenDepth>1)return this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(U.RPAREN,`)`,t,n,r);let s=Lu.get(i);if(s!==void 0)return this.pos=t+1,this.column=r+1,this.makeToken(s,i,t,n,r);if(i===`{`){let e=this.scanFdVariable(t);return e===null?a===`}`?(this.pos=t+2,this.column=r+2,{type:U.WORD,value:`{}`,start:t,end:t+2,line:n,column:r,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(t)===null&&this.scanLiteralBraceWord(t)===null?a!==void 0&&a!==` `&&a!==` `&&a!==`
157
- `?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(U.LBRACE,`{`,t,n,r)):this.readWordWithBraceExpansion(t,n,r):(this.pos=e.end,this.column=r+(e.end-t),{type:U.FD_VARIABLE,value:e.varname,start:t,end:e.end,line:n,column:r})}return i===`}`?this.isWordCharFollowing(t+1)?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(U.RBRACE,`}`,t,n,r)):i===`!`?a===`=`?(this.pos=t+2,this.column=r+2,this.makeToken(U.WORD,`!=`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(U.BANG,`!`,t,n,r)):this.readWord(t,n,r)}looksLikeNestedSubshells(e){let t=this.input,n=t.length,r=e;for(;r<n&&(t[r]===` `||t[r]===` `);)r++;if(r>=n)return!1;let i=t[r];if(i===`(`)return this.looksLikeNestedSubshells(r+1);let a=/[a-zA-Z_]/.test(i),o=i===`!`||i===`[`;if(!a&&!o)return!1;let s=r;for(;s<n&&/[a-zA-Z0-9_\-.]/.test(t[s]);)s++;if(s===r)return o;let c=s;for(;c<n&&(t[c]===` `||t[c]===` `);)c++;if(c>=n)return!1;let l=t[c];if(l===`=`&&t[c+1]!==`=`||l===`
159
+ `)return this.pos=t+1,this.line++,this.column=1,{type:W.NEWLINE,value:`
160
+ `,start:t,end:t+1,line:n,column:r};if(i===`<`&&a===`<`&&o===`-`)return this.pos=t+3,this.column=r+3,this.registerHeredocFromLookahead(!0),this.makeToken(W.DLESSDASH,`<<-`,t,n,r);for(let[e,s,c,l]of Uu)if(i===e&&a===s&&o===c)return this.pos=t+3,this.column=r+3,this.makeToken(l,e+s+c,t,n,r);if(i===`<`&&a===`<`)return this.pos=t+2,this.column=r+2,this.registerHeredocFromLookahead(!1),this.makeToken(W.DLESS,`<<`,t,n,r);if(i===`(`&&a===`(`)return this.dparenDepth>0?(this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(W.LPAREN,`(`,t,n,r)):this.looksLikeNestedSubshells(t+2)||this.dparenClosesWithSpacedParens(t+2)?(this.pos=t+1,this.column=r+1,this.makeToken(W.LPAREN,`(`,t,n,r)):(this.pos=t+2,this.column=r+2,this.dparenDepth=1,this.makeToken(W.DPAREN_START,`((`,t,n,r));if(i===`)`&&a===`)`)return this.dparenDepth===1?(this.pos=t+2,this.column=r+2,this.dparenDepth=0,this.makeToken(W.DPAREN_END,`))`,t,n,r)):this.dparenDepth>1?(this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(W.RPAREN,`)`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(W.RPAREN,`)`,t,n,r));for(let[o,s,c]of Wu)if(!(o===`(`&&s===`(`||o===`)`&&s===`)`)&&!(this.dparenDepth>0&&o===`;`&&(c===W.DSEMI||c===W.SEMI_AND||c===W.SEMI_SEMI_AND))&&i===o&&a===s){if(c===W.DBRACK_START||c===W.DBRACK_END){let n=e[t+2];if(n!==void 0&&n!==` `&&n!==` `&&n!==`
161
+ `&&n!==`;`&&n!==`&`&&n!==`|`&&n!==`(`&&n!==`)`&&n!==`<`&&n!==`>`)break}return this.pos=t+2,this.column=r+2,this.makeToken(c,o+s,t,n,r)}if(i===`(`&&this.dparenDepth>0)return this.pos=t+1,this.column=r+1,this.dparenDepth++,this.makeToken(W.LPAREN,`(`,t,n,r);if(i===`)`&&this.dparenDepth>1)return this.pos=t+1,this.column=r+1,this.dparenDepth--,this.makeToken(W.RPAREN,`)`,t,n,r);let s=Gu.get(i);if(s!==void 0)return this.pos=t+1,this.column=r+1,this.makeToken(s,i,t,n,r);if(i===`{`){let e=this.scanFdVariable(t);return e===null?a===`}`?(this.pos=t+2,this.column=r+2,{type:W.WORD,value:`{}`,start:t,end:t+2,line:n,column:r,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(t)===null&&this.scanLiteralBraceWord(t)===null?a!==void 0&&a!==` `&&a!==` `&&a!==`
162
+ `?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(W.LBRACE,`{`,t,n,r)):this.readWordWithBraceExpansion(t,n,r):(this.pos=e.end,this.column=r+(e.end-t),{type:W.FD_VARIABLE,value:e.varname,start:t,end:e.end,line:n,column:r})}return i===`}`?this.isWordCharFollowing(t+1)?this.readWord(t,n,r):(this.pos=t+1,this.column=r+1,this.makeToken(W.RBRACE,`}`,t,n,r)):i===`!`?a===`=`?(this.pos=t+2,this.column=r+2,this.makeToken(W.WORD,`!=`,t,n,r)):(this.pos=t+1,this.column=r+1,this.makeToken(W.BANG,`!`,t,n,r)):this.readWord(t,n,r)}looksLikeNestedSubshells(e){let t=this.input,n=t.length,r=e;for(;r<n&&(t[r]===` `||t[r]===` `);)r++;if(r>=n)return!1;let i=t[r];if(i===`(`)return this.looksLikeNestedSubshells(r+1);let a=/[a-zA-Z_]/.test(i),o=i===`!`||i===`[`;if(!a&&!o)return!1;let s=r;for(;s<n&&/[a-zA-Z0-9_\-.]/.test(t[s]);)s++;if(s===r)return o;let c=s;for(;c<n&&(t[c]===` `||t[c]===` `);)c++;if(c>=n)return!1;let l=t[c];if(l===`=`&&t[c+1]!==`=`||l===`
158
163
  `||s===c&&/[+\-*/%<>&|^!~?:]/.test(l)&&l!==`-`||l===`)`&&t[c+1]===`)`)return!1;if(c>s&&(l===`-`||l===`"`||l===`'`||l===`$`||/[a-zA-Z_/.]/.test(l))){let e=c;for(;e<n&&t[e]!==`
159
164
  `;){if(t[e]===`)`)return!0;e++}return!1}if(l===`)`){let e=c+1;for(;e<n&&(t[e]===` `||t[e]===` `);)e++;if(t[e]===`|`&&t[e+1]===`|`||t[e]===`&`&&t[e+1]===`&`||t[e]===`;`||t[e]===`|`&&t[e+1]!==`|`)return!0}return!1}makeToken(e,t,n,r,i){return{type:e,value:t,start:n,end:this.pos,line:r,column:i}}readComment(e,t,n){let r=this.input,i=r.length,a=this.pos;for(;a<i&&r[a]!==`
160
- `;)a++;let o=r.slice(e,a);return this.pos=a,this.column=n+(a-e),{type:U.COMMENT,value:o,start:e,end:a,line:t,column:n}}readWord(e,t,n){let r=this.input,i=r.length,a=this.pos,o=a;for(;a<i;){let e=r[a];if(e===` `||e===` `||e===`
165
+ `;)a++;let o=r.slice(e,a);return this.pos=a,this.column=n+(a-e),{type:W.COMMENT,value:o,start:e,end:a,line:t,column:n}}readWord(e,t,n){let r=this.input,i=r.length,a=this.pos,o=a;for(;a<i;){let e=r[a];if(e===` `||e===` `||e===`
161
166
  `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`||e===`'`||e===`"`||e===`\\`||e===`$`||e==="`"||e===`{`||e===`}`||e===`~`||e===`*`||e===`?`||e===`[`)break;a++}if(a>o){let s=r[a];if(!(s===`(`&&a>o&&`@*+?!`.includes(r[a-1]))&&(a>=i||s===` `||s===` `||s===`
162
- `||s===`;`||s===`&`||s===`|`||s===`(`||s===`)`||s===`<`||s===`>`)){let i=r.slice(o,a);this.pos=a,this.column=n+(a-o);let s=Pu.get(i);if(s!==void 0)return{type:s,value:i,start:e,end:a,line:t,column:n};let c=Au(i);return c>0&&ku(i.slice(0,c))?{type:U.ASSIGNMENT_WORD,value:i,start:e,end:a,line:t,column:n}:/^[0-9]+$/.test(i)?{type:U.NUMBER,value:i,start:e,end:a,line:t,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?{type:U.NAME,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}:{type:U.WORD,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}}a=this.pos;let s=this.column,c=this.line,l=``,u=!1,d=!1,f=!1,p=!1,m=r[a]===`"`||r[a]===`'`,h=!1,ee=0;for(;a<i;){let e=r[a];if(!f&&!p){if(e===`(`&&l.length>0&&`@*+?!`.includes(l[l.length-1])){let e=this.scanExtglobPattern(a);if(e!==null){l+=e.content,a=e.end,s+=e.content.length;continue}}if(e===`[`&&ee===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){let t=a+1<i?r[a+1]:``;if(t===`^`||t===`!`){l+=e,a++,s++;continue}ee=1,l+=e,a++,s++;continue}}else if(e===`[`&&ee>0){l.length>0&&l[l.length-1]!==`\\`&&ee++,l+=e,a++,s++;continue}else if(e===`]`&&ee>0){l.length>0&&l[l.length-1]!==`\\`&&ee--,l+=e,a++,s++;continue}if(ee>0){if(e===`
167
+ `||s===`;`||s===`&`||s===`|`||s===`(`||s===`)`||s===`<`||s===`>`)){let i=r.slice(o,a);this.pos=a,this.column=n+(a-o);let s=Hu.get(i);if(s!==void 0)return{type:s,value:i,start:e,end:a,line:t,column:n};let c=Lu(i);return c>0&&Iu(i.slice(0,c))?{type:W.ASSIGNMENT_WORD,value:i,start:e,end:a,line:t,column:n}:/^[0-9]+$/.test(i)?{type:W.NUMBER,value:i,start:e,end:a,line:t,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)?{type:W.NAME,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}:{type:W.WORD,value:i,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}}a=this.pos;let s=this.column,c=this.line,l=``,u=!1,d=!1,f=!1,p=!1,m=r[a]===`"`||r[a]===`'`,h=!1,ee=0;for(;a<i;){let e=r[a];if(!f&&!p){if(e===`(`&&l.length>0&&`@*+?!`.includes(l[l.length-1])){let e=this.scanExtglobPattern(a);if(e!==null){l+=e.content,a=e.end,s+=e.content.length;continue}}if(e===`[`&&ee===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)){let t=a+1<i?r[a+1]:``;if(t===`^`||t===`!`){l+=e,a++,s++;continue}ee=1,l+=e,a++,s++;continue}}else if(e===`[`&&ee>0){l.length>0&&l[l.length-1]!==`\\`&&ee++,l+=e,a++,s++;continue}else if(e===`]`&&ee>0){l.length>0&&l[l.length-1]!==`\\`&&ee--,l+=e,a++,s++;continue}if(ee>0){if(e===`
163
168
  `)break;l+=e,a++,s++;continue}if(e===` `||e===` `||e===`
164
- `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+1<i&&r[a+1]===`'`&&!f&&!p){for(l+=`$'`,a+=2,s+=2;a<i&&r[a]!==`'`;)r[a]===`\\`&&a+1<i?(l+=r[a]+r[a+1],a+=2,s+=2):(l+=r[a],a++,s++);a<i&&(l+=`'`,a++,s++);continue}if(e===`$`&&a+1<i&&r[a+1]===`"`&&!f&&!p){a++,s++,p=!0,u=!0,l===``&&(m=!0),a++,s++;continue}if(e===`'`&&!p){if(f)if(f=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!Mu(t)&&t!==`'`&&(t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else f=!0,m&&!h?(d=!0,u=!0):l+=e;a++,s++;continue}if(e===`"`&&!f){if(p)if(p=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!Mu(t)&&t!==`"`&&(t===`'`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else p=!0,m&&!h?u=!0:l+=e;a++,s++;continue}if(e===`\\`&&!f&&a+1<i){let t=r[a+1];if(t===`
169
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break}if(e===`$`&&a+1<i&&r[a+1]===`'`&&!f&&!p){for(l+=`$'`,a+=2,s+=2;a<i&&r[a]!==`'`;)r[a]===`\\`&&a+1<i?(l+=r[a]+r[a+1],a+=2,s+=2):(l+=r[a],a++,s++);a<i&&(l+=`'`,a++,s++);continue}if(e===`$`&&a+1<i&&r[a+1]===`"`&&!f&&!p){a++,s++,p=!0,u=!0,l===``&&(m=!0),a++,s++;continue}if(e===`'`&&!p){if(f)if(f=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!zu(t)&&t!==`'`&&(t===`"`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else f=!0,m&&!h?(d=!0,u=!0):l+=e;a++,s++;continue}if(e===`"`&&!f){if(p)if(p=!1,!m||h)l+=e;else{let t=a+1<i?r[a+1]:``;t&&!zu(t)&&t!==`"`&&(t===`'`?(h=!0,l+=e,d=!1,u=!1):(h=!0,l+=e))}else p=!0,m&&!h?u=!0:l+=e;a++,s++;continue}if(e===`\\`&&!f&&a+1<i){let t=r[a+1];if(t===`
165
170
  `){a+=2,c++,s=1;continue}if(p){if(t===`"`||t===`\\`||t===`$`||t==="`"||t===`
166
171
  `){if(t===`
167
- `){a+=2,s=1,c++;continue}l+=e+t,a+=2,s+=2;continue}}else{t===`\\`||t===`"`||t===`'`||t==="`"||t===`*`||t===`?`||t===`[`||t===`]`||t===`(`||t===`)`||t===`$`||t===`-`||t===`.`||t===`^`||t===`+`||t===`{`||t===`}`?l+=e+t:l+=t,a+=2,s+=2;continue}}if(e===`$`&&a+1<i&&r[a+1]===`(`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1,n=!1,o=!1,u=0,d=!1,f=``,p=r[a]===`(`&&!this.dollarDparenIsSubshell(a);for(;t>0&&a<i;){let e=r[a];if(l+=e,n)e===`'`&&(n=!1);else if(o)e===`\\`&&a+1<i?(l+=r[a+1],a++,s++):e===`"`&&(o=!1);else if(e===`'`)n=!0,f=``;else if(e===`"`)o=!0,f=``;else if(e===`\\`&&a+1<i)l+=r[a+1],a++,s++,f=``;else if(e===`$`&&a+1<i&&r[a+1]===`{`){a++,s++,l+=r[a],a++,s++;let e=1,t=!1,n=!1;for(;e>0&&a<i;){let o=r[a];if(o===`\\`&&a+1<i&&!t){l+=o,a++,s++,l+=r[a],a++,s++;continue}l+=o,t?o===`'`&&(t=!1):n?o===`"`&&(n=!1):o===`'`?t=!0:o===`"`?n=!0:o===`{`?e++:o===`}`&&e--,o===`
168
- `?(c++,s=0):s++,a++}f=``;continue}else if(e===`#`&&!p&&(f===``||/\s/.test(r[a-1]||``))){for(;a+1<i&&r[a+1]!==`
169
- `;)a++,s++,l+=r[a];f=``}else /[a-zA-Z_]/.test(e)?f+=e:(f===`case`?(u++,d=!1):f===`in`&&u>0?d=!0:f===`esac`&&u>0&&(u--,d=!1),f=``,e===`(`?a>0&&r[a-1]===`$`?t++:d||t++:e===`)`?d?d=!1:t--:e===`;`&&u>0&&(a+1<i&&r[a+1]===`;`||a+1<i&&r[a+1]===`&`)&&(d=!0));e===`
172
+ `){a+=2,s=1,c++;continue}l+=e+t,a+=2,s+=2;continue}}else{t===`\\`||t===`"`||t===`'`||t==="`"||t===`*`||t===`?`||t===`[`||t===`]`||t===`(`||t===`)`||t===`$`||t===`-`||t===`.`||t===`^`||t===`+`||t===`{`||t===`}`?l+=e+t:l+=t,a+=2,s+=2;continue}}if(e===`$`&&a+1<i&&r[a+1]===`(`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1,n=!1,o=!1,u=0,d=!1,f=``,p=[],m=r[a]===`(`&&!this.dollarDparenIsSubshell(a),h=+!!m;for(;t>0&&a<i;){let e=r[a];if(l+=e,n)e===`'`&&(n=!1);else if(o)e===`\\`&&a+1<i?(l+=r[a+1],a++,s++):e===`"`&&(o=!1);else{if(e===`(`&&r[a+1]===`(`?h++:e===`)`&&r[a+1]===`)`&&h>0&&h--,h===0&&e===`<`&&r[a+1]===`<`&&r[a+2]!==`<`){let e=a+2,t=!1;for(r[e]===`-`&&(t=!0,e++);r[e]===` `||r[e]===` `;)e++;let{delim:n,endPos:i}=ju(r,e);if(n.length>0){l+=r.slice(a+1,i),s+=i-a,p.push({delim:n,stripTabs:t}),a=i;continue}}if(e===`
173
+ `&&p.length>0){c++,s=0;let e=a+1;for(let{delim:t,stripTabs:n}of p)for(;!(e>=i);){let a=r.indexOf(`
174
+ `,e);a===-1&&(a=i);let o=r.slice(e,a),s=n?o.replace(/^\t+/,``):o;l+=r.slice(e,Math.min(a+1,i)),a<i&&c++;let u=a>=i;if(e=a+1,s===t||u)break}p.length=0,s=0,a=Math.min(e,i);continue}if(e===`'`)n=!0,f=``;else if(e===`"`)o=!0,f=``;else if(e===`\\`&&a+1<i)l+=r[a+1],a++,s++,f=``;else if(e===`$`&&a+1<i&&r[a+1]===`{`){a++,s++,l+=r[a],a++,s++;let e=1,t=!1,n=!1;for(;e>0&&a<i;){let o=r[a];if(o===`\\`&&a+1<i&&!t){l+=o,a++,s++,l+=r[a],a++,s++;continue}l+=o,t?o===`'`&&(t=!1):n?o===`"`&&(n=!1):o===`'`?t=!0:o===`"`?n=!0:o===`{`?e++:o===`}`&&e--,o===`
175
+ `?(c++,s=0):s++,a++}f=``;continue}else if(e===`#`&&!m&&(f===``||/\s/.test(r[a-1]||``))){for(;a+1<i&&r[a+1]!==`
176
+ `;)a++,s++,l+=r[a];f=``}else /[a-zA-Z_]/.test(e)?f+=e:(f===`case`?(u++,d=!1):f===`in`&&u>0?d=!0:f===`esac`&&u>0&&(u--,d=!1),f=``,e===`(`?a>0&&r[a-1]===`$`?t++:d||t++:e===`)`?d?d=!1:t--:e===`;`&&u>0&&(a+1<i&&r[a+1]===`;`||a+1<i&&r[a+1]===`&`)&&(d=!0))}e===`
170
177
  `&&(c++,s=0,f=``),a++,s++}continue}if(e===`$`&&a+1<i&&r[a+1]===`[`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1;for(;t>0&&a<i;){let e=r[a];l+=e,e===`[`?t++:e===`]`?t--:e===`
171
178
  `&&(c++,s=0),a++,s++}continue}if(e===`$`&&a+1<i&&r[a+1]===`{`&&!f){l+=e,a++,s++,l+=r[a],a++,s++;let t=1,n=!1,o=!1,u=c,d=s,f=c,p=s;for(;t>0&&a<i;){let e=r[a];if(e===`\\`&&a+1<i&&r[a+1]===`
172
179
  `){a+=2,c++,s=1;continue}if(e===`\\`&&a+1<i&&!n){l+=e,a++,s++,l+=r[a],a++,s++;continue}l+=e,n?e===`'`&&(n=!1):o?e===`"`&&(o=!1):e===`'`?(n=!0,u=c,d=s):e===`"`?(o=!0,f=c,p=s):e===`{`?t++:e===`}`&&t--,e===`
173
- `&&(c++,s=0),a++,s++}if(n)throw new Nu("unexpected EOF while looking for matching `''",u,d);if(o)throw new Nu(`unexpected EOF while looking for matching \`"'`,f,p);continue}if(e===`$`&&a+1<i&&!f){let t=r[a+1];if(t===`#`||t===`?`||t===`$`||t===`!`||t===`@`||t===`*`||t===`-`||t>=`0`&&t<=`9`){l+=e+t,a+=2,s+=2;continue}}if(e==="`"&&!f){for(l+=e,a++,s++;a<i&&r[a]!=="`";){let e=r[a];l+=e,e===`\\`&&a+1<i&&(l+=r[a+1],a++,s++),e===`
180
+ `&&(c++,s=0),a++,s++}if(n)throw new Vu("unexpected EOF while looking for matching `''",u,d);if(o)throw new Vu(`unexpected EOF while looking for matching \`"'`,f,p);continue}if(e===`$`&&a+1<i&&!f){let t=r[a+1];if(t===`#`||t===`?`||t===`$`||t===`!`||t===`@`||t===`*`||t===`-`||t>=`0`&&t<=`9`){l+=e+t,a+=2,s+=2;continue}}if(e==="`"&&!f){for(l+=e,a++,s++;a<i&&r[a]!=="`";){let e=r[a];l+=e,e===`\\`&&a+1<i&&(l+=r[a+1],a++,s++),e===`
174
181
  `&&(c++,s=0),a++,s++}a<i&&(l+=r[a],a++,s++);continue}l+=e,a++,e===`
175
- `?(c++,s=1):s++}if(this.pos=a,this.column=s,this.line=c,h&&m&&(l=r[e]+l,u=!1,d=!1),f||p)throw new Nu(`unexpected EOF while looking for matching \`${f?`'`:`"`}'`,t,n);if(!m&&l.length>=2){if(l[0]===`'`&&l[l.length-1]===`'`){let e=l.slice(1,-1);!e.includes(`'`)&&!e.includes(`"`)&&(l=e,u=!0,d=!0)}else if(l[0]===`"`&&l[l.length-1]===`"`){let e=l.slice(1,-1),t=!1;for(let n=0;n<e.length;n++){if(e[n]===`"`){t=!0;break}e[n]===`\\`&&n+1<e.length&&n++}t||(l=e,u=!0,d=!1)}}if(l===``)return{type:U.WORD,value:``,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d};let te=Pu.get(l);if(!u&&te!==void 0)return{type:te,value:l,start:e,end:a,line:t,column:n};if(!m){let r=Au(l);if(r>0&&ku(l.slice(0,r)))return{type:U.ASSIGNMENT_WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}return/^[0-9]+$/.test(l)?{type:U.NUMBER,value:l,start:e,end:a,line:t,column:n}:ju(l)?{type:U.NAME,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}:{type:U.WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let t=this.pos,n=this.line,r=this.column,i=``;for(;this.pos<this.input.length;){let t=``;for(;this.pos<this.input.length&&this.input[this.pos]!==`
182
+ `?(c++,s=1):s++}if(this.pos=a,this.column=s,this.line=c,h&&m&&(l=r[e]+l,u=!1,d=!1),f||p)throw new Vu(`unexpected EOF while looking for matching \`${f?`'`:`"`}'`,t,n);if(!m&&l.length>=2){if(l[0]===`'`&&l[l.length-1]===`'`){let e=l.slice(1,-1);!e.includes(`'`)&&!e.includes(`"`)&&(l=e,u=!0,d=!0)}else if(l[0]===`"`&&l[l.length-1]===`"`){let e=l.slice(1,-1),t=!1;for(let n=0;n<e.length;n++){if(e[n]===`"`){t=!0;break}e[n]===`\\`&&n+1<e.length&&n++}t||(l=e,u=!0,d=!1)}}if(l===``)return{type:W.WORD,value:``,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d};let te=Hu.get(l);if(!u&&te!==void 0)return{type:te,value:l,start:e,end:a,line:t,column:n};if(!m){let r=Lu(l);if(r>0&&Iu(l.slice(0,r)))return{type:W.ASSIGNMENT_WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}return/^[0-9]+$/.test(l)?{type:W.NUMBER,value:l,start:e,end:a,line:t,column:n}:Ru(l)?{type:W.NAME,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}:{type:W.WORD,value:l,start:e,end:a,line:t,column:n,quoted:u,singleQuoted:d}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let t=this.pos,n=this.line,r=this.column,i=``;for(;this.pos<this.input.length;){let t=``;for(;this.pos<this.input.length&&this.input[this.pos]!==`
176
183
  `;)t+=this.input[this.pos],this.pos++,this.column++;if((e.stripTabs?t.replace(/^\t+/,``):t)===e.delimiter){this.pos<this.input.length&&this.input[this.pos]===`
177
- `&&(this.pos++,this.line++,this.column=1);break}if(i+=t,i.length>this.maxHeredocSize)throw new Nu(`Heredoc size limit exceeded (${this.maxHeredocSize} bytes)`,n,r);this.pos<this.input.length&&this.input[this.pos]===`
184
+ `&&(this.pos++,this.line++,this.column=1);break}if(i+=t,i.length>this.maxHeredocSize)throw new Vu(`Heredoc size limit exceeded (${this.maxHeredocSize} bytes)`,n,r);this.pos<this.input.length&&this.input[this.pos]===`
178
185
  `&&(i+=`
179
- `,this.pos++,this.line++,this.column=1)}this.tokens.push({type:U.HEREDOC_CONTENT,value:i,start:t,end:this.pos,line:n,column:r})}}addPendingHeredoc(e,t,n){this.pendingHeredocs.push({delimiter:e,stripTabs:t,quoted:n})}registerHeredocFromLookahead(e){let t=this.pos,n=this.column;for(;this.pos<this.input.length&&(this.input[this.pos]===` `||this.input[this.pos]===` `);)this.pos++,this.column++;let r=``,i=!1;for(;this.pos<this.input.length;){let e=this.input[this.pos];if(/[\s;<>&|()]/.test(e))break;if(e===`'`||e===`"`){i=!0;let t=e;for(this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]!==t;)r+=this.input[this.pos],this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]===t&&(this.pos++,this.column++)}else e===`\\`?(i=!0,this.pos++,this.column++,this.pos<this.input.length&&(r+=this.input[this.pos],this.pos++,this.column++)):(r+=e,this.pos++,this.column++)}this.pos=t,this.column=n,r&&this.pendingHeredocs.push({delimiter:r,stripTabs:e,quoted:i})}isWordCharFollowing(e){if(e>=this.input.length)return!1;let t=this.input[e];return!(t===` `||t===` `||t===`
186
+ `,this.pos++,this.line++,this.column=1)}this.tokens.push({type:W.HEREDOC_CONTENT,value:i,start:t,end:this.pos,line:n,column:r})}}addPendingHeredoc(e,t,n){this.pendingHeredocs.push({delimiter:e,stripTabs:t,quoted:n})}registerHeredocFromLookahead(e){let t=this.pos,n=this.column;for(;this.pos<this.input.length&&(this.input[this.pos]===` `||this.input[this.pos]===` `);)this.pos++,this.column++;let r=``,i=!1;for(;this.pos<this.input.length;){let e=this.input[this.pos];if(/[\s;<>&|()]/.test(e))break;if(e===`'`||e===`"`){i=!0;let t=e;for(this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]!==t;)r+=this.input[this.pos],this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]===t&&(this.pos++,this.column++)}else e===`\\`?(i=!0,this.pos++,this.column++,this.pos<this.input.length&&(r+=this.input[this.pos],this.pos++,this.column++)):(r+=e,this.pos++,this.column++)}this.pos=t,this.column=n,r&&this.pendingHeredocs.push({delimiter:r,stripTabs:e,quoted:i})}isWordCharFollowing(e){if(e>=this.input.length)return!1;let t=this.input[e];return!(t===` `||t===` `||t===`
180
187
  `||t===`;`||t===`&`||t===`|`||t===`(`||t===`)`||t===`<`||t===`>`)}readWordWithBraceExpansion(e,t,n){let r=this.input,i=r.length,a=e,o=n;for(;a<i;){let e=r[a];if(e===` `||e===` `||e===`
181
- `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break;if(e===`{`){if(this.scanBraceExpansion(a)!==null){let e=1;for(a++,o++;a<i&&e>0;)r[a]===`{`?e++:r[a]===`}`&&e--,a++,o++;continue}a++,o++;continue}if(e===`}`){a++,o++;continue}if(e===`$`&&a+1<i&&r[a+1]===`(`){a++,o++,a++,o++;let e=1;for(;e>0&&a<i;)r[a]===`(`?e++:r[a]===`)`&&e--,a++,o++;continue}if(e===`$`&&a+1<i&&r[a+1]===`{`){a++,o++,a++,o++;let e=1;for(;e>0&&a<i;)r[a]===`{`?e++:r[a]===`}`&&e--,a++,o++;continue}if(e==="`"){for(a++,o++;a<i&&r[a]!=="`";)r[a]===`\\`&&a+1<i?(a+=2,o+=2):(a++,o++);a<i&&(a++,o++);continue}a++,o++}let s=r.slice(e,a);return this.pos=a,this.column=o,{type:U.WORD,value:s,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}scanBraceExpansion(e){let t=this.input,n=t.length,r=e+1,i=1,a=!1,o=!1;for(;r<n&&i>0;){let e=t[r];if(e===`{`)i++,r++;else if(e===`}`)i--,r++;else if(e===`,`&&i===1)a=!0,r++;else if(e===`.`&&r+1<n&&t[r+1]===`.`)o=!0,r+=2;else{if(e===` `||e===` `||e===`
188
+ `||e===`;`||e===`&`||e===`|`||e===`(`||e===`)`||e===`<`||e===`>`)break;if(e===`{`){if(this.scanBraceExpansion(a)!==null){let e=1;for(a++,o++;a<i&&e>0;)r[a]===`{`?e++:r[a]===`}`&&e--,a++,o++;continue}a++,o++;continue}if(e===`}`){a++,o++;continue}if(e===`$`&&a+1<i&&r[a+1]===`(`){a++,o++,a++,o++;let e=1;for(;e>0&&a<i;)r[a]===`(`?e++:r[a]===`)`&&e--,a++,o++;continue}if(e===`$`&&a+1<i&&r[a+1]===`{`){a++,o++,a++,o++;let e=1;for(;e>0&&a<i;)r[a]===`{`?e++:r[a]===`}`&&e--,a++,o++;continue}if(e==="`"){for(a++,o++;a<i&&r[a]!=="`";)r[a]===`\\`&&a+1<i?(a+=2,o+=2):(a++,o++);a<i&&(a++,o++);continue}a++,o++}let s=r.slice(e,a);return this.pos=a,this.column=o,{type:W.WORD,value:s,start:e,end:a,line:t,column:n,quoted:!1,singleQuoted:!1}}scanBraceExpansion(e){let t=this.input,n=t.length,r=e+1,i=1,a=!1,o=!1;for(;r<n&&i>0;){let e=t[r];if(e===`{`)i++,r++;else if(e===`}`)i--,r++;else if(e===`,`&&i===1)a=!0,r++;else if(e===`.`&&r+1<n&&t[r+1]===`.`)o=!0,r+=2;else{if(e===` `||e===` `||e===`
182
189
  `||e===`;`||e===`&`||e===`|`)return null;r++}}return i===0&&(a||o)?t.slice(e,r):null}scanLiteralBraceWord(e){let t=this.input,n=t.length,r=e+1,i=1;for(;r<n&&i>0;){let n=t[r];if(n===`{`)i++,r++;else if(n===`}`){if(i--,i===0)return t.slice(e,r+1);r++}else{if(n===` `||n===` `||n===`
183
190
  `||n===`;`||n===`&`||n===`|`)return null;r++}}return null}scanExtglobPattern(e){let t=this.input,n=t.length,r=e+1,i=1;for(;r<n&&i>0;){let e=t[r];if(e===`\\`&&r+1<n){r+=2;continue}if(`@*+?!`.includes(e)&&r+1<n&&t[r+1]===`(`){r++,i++,r++;continue}if(e===`(`)i++,r++;else if(e===`)`)i--,r++;else{if(e===`
184
191
  `)return null;r++}}return i===0?{content:t.slice(e,r),end:r}:null}scanFdVariable(e){let t=this.input,n=t.length,r=e+1,i=r;for(;r<n;){let e=t[r];if(r===i){if(!(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e===`_`))return null}else if(!(e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`||e>=`0`&&e<=`9`||e===`_`))break;r++}if(r===i)return null;let a=t.slice(i,r);if(r>=n||t[r]!==`}`||(r++,r>=n))return null;let o=t[r],s=r+1<n?t[r+1]:``;return o===`>`||o===`<`||o===`&`&&(s===`>`||s===`<`)?{varname:a,end:r}:null}dollarDparenIsSubshell(e){let t=this.input,n=t.length,r=e+1,i=2,a=!1,o=!1,s=!1;for(;r<n&&i>0;){let e=t[r];if(a){e===`'`&&(a=!1),e===`
@@ -186,35 +193,33 @@ ${o.repeat(a)}}`}return String(e)}var Cl,wl;_({},{base64Command:()=>Tl,flagsForF
186
193
  `&&(s=!0),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`
187
194
  `&&(s=!0),e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e<n&&t[e]===`)`)return!1;let i=e,a=!1;for(;i<n&&(t[i]===` `||t[i]===` `||t[i]===`
188
195
  `);)a=!0,i++;if(a&&i<n&&t[i]===`)`||s)return!0}if(i===0)return!1;r++;continue}r++}return!1}dparenClosesWithSpacedParens(e){let t=this.input,n=t.length,r=e,i=2,a=!1,o=!1;for(;r<n&&i>0;){let e=t[r];if(a){e===`'`&&(a=!1),r++;continue}if(o){if(e===`\\`){r+=2;continue}e===`"`&&(o=!1),r++;continue}if(e===`'`){a=!0,r++;continue}if(e===`"`){o=!0,r++;continue}if(e===`\\`){r+=2;continue}if(e===`(`){i++,r++;continue}if(e===`)`){if(i--,i===1){let e=r+1;if(e<n&&t[e]===`)`)return!1;let i=e,a=!1;for(;i<n&&(t[i]===` `||t[i]===` `||t[i]===`
189
- `);)a=!0,i++;if(a&&i<n&&t[i]===`)`)return!0}if(i===0)return!1;r++;continue}if(i===1&&(e===`|`&&r+1<n&&t[r+1]===`|`||e===`&`&&r+1<n&&t[r+1]===`&`||e===`|`&&r+1<n&&t[r+1]!==`|`))return!0;r++}return!1}}}),Bu,Vu,Hu,Uu,Wu,Gu,Ku,qu,Ju=g(()=>{zu(),Bu=1e6,Vu=1e5,Hu=1e6,Uu=200,Wu=new Set([U.LESS,U.GREAT,U.DLESS,U.DGREAT,U.LESSAND,U.GREATAND,U.LESSGREAT,U.DLESSDASH,U.CLOBBER,U.TLESS,U.AND_GREAT,U.AND_DGREAT]),Gu=new Set([U.LESS,U.GREAT,U.DLESS,U.DGREAT,U.LESSAND,U.GREATAND,U.LESSGREAT,U.DLESSDASH,U.CLOBBER,U.TLESS]),Ku=new Set([U.LESS,U.GREAT,U.DLESS,U.DGREAT,U.LESSAND,U.GREATAND,U.LESSGREAT,U.DLESSDASH,U.CLOBBER,U.TLESS,U.AND_GREAT,U.AND_DGREAT]),qu=class extends Error{line;column;token;constructor(e,t,n,r=void 0){super(`Parse error at ${t}:${n}: ${e}`),this.line=t,this.column=n,this.token=r,this.name=`ParseException`}}}),W,Yu=g(()=>{W={script(e){return{type:`Script`,statements:e}},statement(e,t=[],n=!1,r,i){let a={type:`Statement`,pipelines:e,operators:t,background:n};return r&&(a.deferredError=r),i!==void 0&&(a.sourceText=i),a},pipeline(e,t=!1,n=!1,r=!1,i){return{type:`Pipeline`,commands:e,negated:t,timed:n,timePosix:r,pipeStderr:i}},simpleCommand(e,t=[],n=[],r=[]){return{type:`SimpleCommand`,name:e,args:t,assignments:n,redirections:r}},word(e){return{type:`Word`,parts:e}},literal(e){return{type:`Literal`,value:e}},singleQuoted(e){return{type:`SingleQuoted`,value:e}},doubleQuoted(e){return{type:`DoubleQuoted`,parts:e}},escaped(e){return{type:`Escaped`,value:e}},parameterExpansion(e,t=null){return{type:`ParameterExpansion`,parameter:e,operation:t}},commandSubstitution(e,t=!1){return{type:`CommandSubstitution`,body:e,legacy:t}},arithmeticExpansion(e){return{type:`ArithmeticExpansion`,expression:e}},assignment(e,t,n=!1,r=null){return{type:`Assignment`,name:e,value:t,append:n,array:r}},redirection(e,t,n=null,r){let i={type:`Redirection`,fd:n,operator:e,target:t};return r&&(i.fdVariable=r),i},hereDoc(e,t,n=!1,r=!1){return{type:`HereDoc`,delimiter:e,content:t,stripTabs:n,quoted:r}},ifNode(e,t=null,n=[]){return{type:`If`,clauses:e,elseBody:t,redirections:n}},forNode(e,t,n,r=[]){return{type:`For`,variable:e,words:t,body:n,redirections:r}},whileNode(e,t,n=[]){return{type:`While`,condition:e,body:t,redirections:n}},untilNode(e,t,n=[]){return{type:`Until`,condition:e,body:t,redirections:n}},caseNode(e,t,n=[]){return{type:`Case`,word:e,items:t,redirections:n}},caseItem(e,t,n=`;;`){return{type:`CaseItem`,patterns:e,body:t,terminator:n}},subshell(e,t=[]){return{type:`Subshell`,body:e,redirections:t}},group(e,t=[]){return{type:`Group`,body:e,redirections:t}},functionDef(e,t,n=[],r){return{type:`FunctionDef`,name:e,body:t,redirections:n,sourceFile:r}},conditionalCommand(e,t=[],n){return{type:`ConditionalCommand`,expression:e,redirections:t,line:n}},arithmeticCommand(e,t=[],n){return{type:`ArithmeticCommand`,expression:e,redirections:t,line:n}}}});function G(e,t){for(;t<e.length;){if(e[t]===`\\`&&e[t+1]===`
190
- `){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}function Xu(e){if(e.includes(`#`)){let[t,n]=e.split(`#`),r=Number.parseInt(t,10);if(r<2||r>64)return NaN;if(r<=36){let e=Number.parseInt(n,r);return e>2**53-1?2**53-1:e}let i=0;for(let e of n){let t;if(/[0-9]/.test(e))t=e.charCodeAt(0)-48;else if(/[a-z]/.test(e))t=e.charCodeAt(0)-97+10;else if(/[A-Z]/.test(e))t=e.charCodeAt(0)-65+36;else if(e===`@`)t=62;else if(e===`_`)t=63;else return NaN;if(t>=r)return NaN;if(i=i*r+t,i>2**53-1)return 2**53-1}return i}if(e.startsWith(`0x`)||e.startsWith(`0X`)){let t=Number.parseInt(e.slice(2),16);return t>2**53-1?2**53-1:t}if(e.startsWith(`0`)&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return NaN;let t=Number.parseInt(e,8);return t>2**53-1?2**53-1:t}let t=Number.parseInt(e,10);return t>2**53-1?2**53-1:t}function Zu(e,t,n,r){if(n.slice(r,r+3)!==`$((`)return null;let i=r+3,a=1,o=i;for(;i<n.length-1&&a>0;)n[i]===`(`&&n[i+1]===`(`?(a++,i+=2):n[i]===`)`&&n[i+1]===`)`?(a--,a>0&&(i+=2)):i++;let{expr:s}=e(t,n.slice(o,i),0);return i+=2,{expr:{type:`ArithNested`,expression:s},pos:i}}function Qu(e,t){if(e.slice(t,t+2)!==`$'`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`'`;)if(e[n]===`\\`&&n+1<e.length){let t=e[n+1];switch(t){case`n`:r+=`
191
- `;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`\\`:r+=`\\`;break;case`'`:r+=`'`;break;default:r+=t}n+=2}else r+=e[n],n++;e[n]===`'`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function $u(e,t){if(e.slice(t,t+2)!==`$"`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]===`"`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}var ed,td=g(()=>{ed=[`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`|=`,`^=`]});function nd(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function rd(e,t){let n=nd(t),{expr:r,pos:i}=od(e,n,0),a=G(n,i);if(a<n.length){let e=t.slice(a).trim();if(e)return{type:`ArithmeticExpression`,originalText:t,expression:{type:`ArithSyntaxError`,errorToken:e,message:`${e}: syntax error: invalid arithmetic operator (error token is "${e}")`}}}return{type:`ArithmeticExpression`,expression:r,originalText:t}}function id(e,t){return{expr:{type:`ArithSyntaxError`,errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function ad(e,t){return G(e,t)>=e.length}function od(e,t,n){return sd(e,t,n)}function sd(e,t,n){let{expr:r,pos:i}=cd(e,t,n);for(i=G(t,i);t[i]===`,`;){if(i++,ad(t,i))return id(`,`,i);let{expr:n,pos:a}=cd(e,t,i);r={type:`ArithBinary`,operator:`,`,left:r,right:n},i=G(t,a)}return{expr:r,pos:i}}function cd(e,t,n){let{expr:r,pos:i}=ld(e,t,n);if(i=G(t,i),t[i]===`?`){i++;let{expr:n,pos:a}=od(e,t,i);if(i=G(t,a),t[i]===`:`){i++;let{expr:a,pos:o}=od(e,t,i);return{expr:{type:`ArithTernary`,condition:r,consequent:n,alternate:a},pos:o}}}return{expr:r,pos:i}}function ld(e,t,n){let{expr:r,pos:i}=ud(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`||`;){if(i+=2,ad(t,i))return id(`||`,i);let{expr:n,pos:a}=ud(e,t,i);r={type:`ArithBinary`,operator:`||`,left:r,right:n},i=a}return{expr:r,pos:i}}function ud(e,t,n){let{expr:r,pos:i}=dd(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`&&`;){if(i+=2,ad(t,i))return id(`&&`,i);let{expr:n,pos:a}=dd(e,t,i);r={type:`ArithBinary`,operator:`&&`,left:r,right:n},i=a}return{expr:r,pos:i}}function dd(e,t,n){let{expr:r,pos:i}=fd(e,t,n);for(;i=G(t,i),t[i]===`|`&&t[i+1]!==`|`;){if(i++,ad(t,i))return id(`|`,i);let{expr:n,pos:a}=fd(e,t,i);r={type:`ArithBinary`,operator:`|`,left:r,right:n},i=a}return{expr:r,pos:i}}function fd(e,t,n){let{expr:r,pos:i}=pd(e,t,n);for(;i=G(t,i),t[i]===`^`;){if(i++,ad(t,i))return id(`^`,i);let{expr:n,pos:a}=pd(e,t,i);r={type:`ArithBinary`,operator:`^`,left:r,right:n},i=a}return{expr:r,pos:i}}function pd(e,t,n){let{expr:r,pos:i}=md(e,t,n);for(;i=G(t,i),t[i]===`&`&&t[i+1]!==`&`;){if(i++,ad(t,i))return id(`&`,i);let{expr:n,pos:a}=md(e,t,i);r={type:`ArithBinary`,operator:`&`,left:r,right:n},i=a}return{expr:r,pos:i}}function md(e,t,n){let{expr:r,pos:i}=hd(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`==`||t.slice(i,i+2)===`!=`;){let n=t.slice(i,i+2);if(i+=2,ad(t,i))return id(n,i);let{expr:a,pos:o}=hd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function hd(e,t,n){let{expr:r,pos:i}=gd(e,t,n);for(;;)if(i=G(t,i),t.slice(i,i+2)===`<=`||t.slice(i,i+2)===`>=`){let n=t.slice(i,i+2);if(i+=2,ad(t,i))return id(n,i);let{expr:a,pos:o}=gd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else if(t[i]===`<`||t[i]===`>`){let n=t[i];if(i++,ad(t,i))return id(n,i);let{expr:a,pos:o}=gd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function gd(e,t,n){let{expr:r,pos:i}=_d(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`<<`||t.slice(i,i+2)===`>>`;){let n=t.slice(i,i+2);if(i+=2,ad(t,i))return id(n,i);let{expr:a,pos:o}=_d(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function _d(e,t,n){let{expr:r,pos:i}=vd(e,t,n);for(;i=G(t,i),(t[i]===`+`||t[i]===`-`)&&t[i+1]!==t[i];){let n=t[i];if(i++,ad(t,i))return id(n,i);let{expr:a,pos:o}=vd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function vd(e,t,n){let{expr:r,pos:i}=yd(e,t,n);for(;;)if(i=G(t,i),t[i]===`*`&&t[i+1]!==`*`){if(i++,ad(t,i))return id(`*`,i);let{expr:n,pos:a}=yd(e,t,i);r={type:`ArithBinary`,operator:`*`,left:r,right:n},i=a}else if(t[i]===`/`||t[i]===`%`){let n=t[i];if(i++,ad(t,i))return id(n,i);let{expr:a,pos:o}=yd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function yd(e,t,n){let{expr:r,pos:i}=bd(e,t,n),a=G(t,i);if(t.slice(a,a+2)===`**`){if(a+=2,ad(t,a))return id(`**`,a);let{expr:n,pos:i}=yd(e,t,a);return{expr:{type:`ArithBinary`,operator:`**`,left:r,right:n},pos:i}}return{expr:r,pos:i}}function bd(e,t,n){let r=G(t,n);if(t.slice(r,r+2)===`++`||t.slice(r,r+2)===`--`){let n=t.slice(r,r+2);r+=2;let{expr:i,pos:a}=bd(e,t,r);return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}if(t[r]===`+`||t[r]===`-`||t[r]===`!`||t[r]===`~`){let n=t[r];r++;let{expr:i,pos:a}=bd(e,t,r);return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}return Sd(e,t,r)}function xd(e,t){let n=e[t];return n===`$`||n==="`"}function Sd(e,t,n){let{expr:r,pos:i}=Cd(e,t,n,!1),a=[r];for(;xd(t,i);){let{expr:n,pos:r}=Cd(e,t,i,!0);a.push(n),i=r}a.length>1&&(r={type:`ArithConcat`,parts:a});let o;if(t[i]===`[`&&r.type===`ArithConcat`){i++;let{expr:n,pos:r}=od(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(o&&r.type===`ArithConcat`&&(r={type:`ArithDynamicElement`,nameExpr:r,subscript:o},o=void 0),i=G(t,i),r.type===`ArithConcat`||r.type===`ArithVariable`||r.type===`ArithDynamicElement`){for(let n of ed)if(t.slice(i,i+n.length)===n&&t.slice(i,i+n.length+1)!==`==`){i+=n.length;let{expr:a,pos:o}=cd(e,t,i);return r.type===`ArithDynamicElement`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r.nameExpr,subscript:r.subscript,value:a},pos:o}:r.type===`ArithConcat`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r,value:a},pos:o}:{expr:{type:`ArithAssignment`,operator:n,variable:r.name,value:a},pos:o}}}if(t.slice(i,i+2)===`++`||t.slice(i,i+2)===`--`){let e=t.slice(i,i+2);return i+=2,{expr:{type:`ArithUnary`,operator:e,operand:r,prefix:!1},pos:i}}return{expr:r,pos:i}}function Cd(e,t,n,r=!1){let i=G(t,n),a=Zu(od,e,t,i);if(a)return a;let o=Qu(t,i);if(o)return o;let s=$u(t,i);if(s)return s;if(t.slice(i,i+2)===`$(`&&t[i+2]!==`(`){i+=2;let e=1,n=i;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,e>0&&i++;let r=t.slice(n,i);return i++,{expr:{type:`ArithCommandSubst`,command:r},pos:i}}if(t[i]==="`"){i++;let e=i;for(;i<t.length&&t[i]!=="`";)i++;let n=t.slice(e,i);return t[i]==="`"&&i++,{expr:{type:`ArithCommandSubst`,command:n},pos:i}}if(t[i]===`(`){i++;let{expr:n,pos:r}=od(e,t,i);return i=G(t,r),t[i]===`)`&&i++,{expr:{type:`ArithGroup`,expression:n},pos:i}}if(t[i]===`'`){i++;let e=``;for(;i<t.length&&t[i]!==`'`;)e+=t[i],i++;t[i]===`'`&&i++;let n=Number.parseInt(e,10);return{expr:{type:`ArithSingleQuote`,content:e,value:Number.isNaN(n)?0:n},pos:i}}if(t[i]===`"`){i++;let n=``;for(;i<t.length&&t[i]!==`"`;)t[i]===`\\`&&i+1<t.length?(n+=t[i+1],i+=2):(n+=t[i],i++);t[i]===`"`&&i++;let r=n.trim();if(!r)return{expr:{type:`ArithNumber`,value:0},pos:i};let{expr:a}=od(e,r,0);return{expr:a,pos:i}}if(/[0-9]/.test(t[i])){let e=``,n=!1,r=!1;for(;i<t.length;){let a=t[i];if(n)if(/[0-9a-zA-Z@_]/.test(a))e+=a,i++;else break;else if(a===`#`)n=!0,e+=a,i++;else if(e===`0`&&(a===`x`||a===`X`)&&i+1<t.length&&/[0-9a-fA-F]/.test(t[i+1]))r=!0,e+=a,i++;else if(r&&/[0-9a-fA-F]/.test(a))e+=a,i++;else if(!r&&/[0-9]/.test(a))e+=a,i++;else break}if(i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=e;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: value too great for base (error token is "${n}")`},pos:i}}if(t[i]===`.`&&/[0-9]/.test(t[i+1]))throw new sr(`${e}.${t[i+1]}...: syntax error: invalid arithmetic operator`);if(t[i]===`[`){let n=t.slice(i).trim();return{expr:{type:`ArithNumberSubscript`,number:e,errorToken:n},pos:t.length}}return{expr:{type:`ArithNumber`,value:Xu(e)},pos:i}}if(t[i]===`$`&&t[i+1]===`{`){let e=i+2,n=1,r=e;for(;r<t.length&&n>0;)t[r]===`{`?n++:t[r]===`}`&&n--,n>0&&r++;let a=t.slice(e,r),o=r+1;if(t[o]===`#`){let e=o+1;for(;e<t.length&&/[0-9a-zA-Z@_]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicBase`,baseExpr:a,value:t.slice(o+1,e)},pos:e}}if(/[0-9]/.test(t[o])||t[o]===`x`||t[o]===`X`){let e=o;if(t[o]===`x`||t[o]===`X`)for(e++;e<t.length&&/[0-9a-fA-F]/.test(t[e]);)e++;else for(;e<t.length&&/[0-9]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicNumber`,prefix:a,suffix:t.slice(o,e)},pos:e}}return i=o,{expr:{type:`ArithBracedExpansion`,content:a},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[0-9]/.test(t[i+1])){i++;let e=``;for(;i<t.length&&/[0-9]/.test(t[i]);)e+=t[i],i++;return{expr:{type:`ArithVariable`,name:e,hasDollarPrefix:!0},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[*@#?\-!$]/.test(t[i+1])){let e=t[i+1];return i+=2,{expr:{type:`ArithSpecialVar`,name:e},pos:i}}let c=!1;if(t[i]===`$`&&i+1<t.length&&/[a-zA-Z_]/.test(t[i+1])&&(c=!0,i++),i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=``;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;if(t[i]===`[`&&!r){i++;let a;if(t[i]===`'`||t[i]===`"`){let e=t[i];for(i++,a=``;i<t.length&&t[i]!==e;)a+=t[i],i++;t[i]===e&&i++,i=G(t,i),t[i]===`]`&&i++}let o;if(a===void 0){let{expr:n,pos:r}=od(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(i=G(t,i),t[i]===`[`&&o)return{expr:{type:`ArithDoubleSubscript`,array:n,index:o},pos:i};if(!r){for(let r of ed)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:s,pos:c}=cd(e,t,i);return{expr:{type:`ArithAssignment`,operator:r,variable:n,subscript:o,stringKey:a,value:s},pos:c}}}return{expr:{type:`ArithArrayElement`,array:n,index:o,stringKey:a},pos:i}}if(i=G(t,i),!r){for(let r of ed)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:a,pos:o}=cd(e,t,i);return{expr:{type:`ArithAssignment`,operator:r,variable:n,value:a},pos:o}}}return{expr:{type:`ArithVariable`,name:n,hasDollarPrefix:c},pos:i}}if(t[i]===`#`){let e=i+1;for(;e<t.length&&t[e]!==`
192
- `;)e++;let n=t.slice(i,e).trim()||`#`;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: syntax error: invalid arithmetic operator (error token is "${n}")`},pos:t.length}}return{expr:{type:`ArithNumber`,value:0},pos:i}}var wd=g(()=>{x(),td()});function Td(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function Ed(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function Dd(e,t,n,r,i){let a=1,o=n+1;for(;o<t.length&&a>0;)t[o]===r?a++:t[o]===i&&a--,a>0&&o++;return a===0?o:-1}function Od(e,t,n){let r=n,i=1;for(;r<t.length&&i>0;){let e=t[r];if(e===`\\`&&r+1<t.length){r+=2;continue}if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++;continue}e===`{`?i++:e===`}`&&i--,i>0&&r++}return r}function kd(e,t,n){let r=n,i=!1;for(;r<t.length;){let e=t[r];if(e===`/`&&i||e===`}`)break;if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1,i=!0;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++,i=!0;continue}e===`\\`?(r+=2,i=!0):(r++,i=!0)}return r}function Ad(e,t,n){let r=n,i=``;for(;r<t.length;){let e=t[r];if(e===`*`||e===`?`)i+=e,r++;else if(e===`[`){let n=jd(t,r);n===-1?(i+=e,r++):(i+=t.slice(r,n+1),r=n+1)}else break}return{pattern:i,endIndex:r}}function jd(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){let t=e[n];if(t===`\\`&&n+1<e.length){let t=e[n+1];if(t===`"`||t===`'`)return-1;n+=2;continue}if(t===`]`)return n;if(t===`"`||t===`$`||t==="`")return-1;if(t===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}if(t===`[`&&n+1<e.length&&(e[n+1]===`.`||e[n+1]===`=`)){let t=`${e[n+1]}]`,r=e.indexOf(t,n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function Md(e,t,n){let r=``,i=n;for(;i<t.length&&t[i]!==`'`;){let e=t[i];if(e===`\\`&&i+1<t.length)switch(t[i+1]){case`n`:r+=`
193
- `,i+=2;break;case`t`:r+=` `,i+=2;break;case`r`:r+=`\r`,i+=2;break;case`\\`:r+=`\\`,i+=2;break;case`'`:r+=`'`,i+=2;break;case`"`:r+=`"`,i+=2;break;case`a`:r+=`\x07`,i+=2;break;case`b`:r+=`\b`,i+=2;break;case`e`:case`E`:r+=`\x1B`,i+=2;break;case`f`:r+=`\f`,i+=2;break;case`v`:r+=`\v`,i+=2;break;case`x`:{let e=[],n=i;for(;n+1<t.length&&t[n]===`\\`&&t[n+1]===`x`;){let r=t.slice(n+2,n+4),i=parseInt(r,16);if(!Number.isNaN(i)&&r.length>0)e.push(i),n+=2+r.length;else break}e.length>0?(r+=Td(e),i=n):(r+=`\\x`,i+=2);break}case`u`:{let e=t.slice(i+2,i+6),n=parseInt(e,16);Number.isNaN(n)?(r+=`\\u`,i+=2):(r+=String.fromCharCode(n),i+=6);break}case`c`:if(i+2<t.length){let e=t[i+2].charCodeAt(0)&31;r+=String.fromCharCode(e),i+=3}else r+=`\\c`,i+=2;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let e=``,n=i+1;for(;n<t.length&&n<i+4&&/[0-7]/.test(t[n]);)e+=t[n],n++;let a=parseInt(e,8);r+=String.fromCharCode(a),i=n;break}default:r+=e,i++}else r+=e,i++}return i<t.length&&t[i]===`'`&&i++,{part:W.literal(r),endIndex:i}}function Nd(e,t){let n=t.trim();return n===``?{type:`ArithmeticExpression`,expression:{type:`ArithNumber`,value:0}}:rd(e,n)}function Pd(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`{`?(r++,n+=a):a===`}`?(r--,n+=a):a===`,`&&r===0?(t.push(n),n=``):n+=a}return t.push(n),t}function Fd(e,t,n,r){let i=Dd(e,t,n,`{`,`}`);if(i===-1)return null;let a=t.slice(n+1,i),o=a.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:`BraceExpansion`,items:[{type:`Range`,start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:i+1};let s=a.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return s?{part:{type:`BraceExpansion`,items:[{type:`Range`,start:s[1],end:s[2],step:s[3]?Number.parseInt(s[3],10):void 0}]},endIndex:i+1}:a.includes(`,`)&&r?{part:{type:`BraceExpansion`,items:Pd(a).map(t=>({type:`Word`,word:W.word(r(e,t,!1,!1,!1))}))},endIndex:i+1}:a.includes(`,`)?{part:{type:`BraceExpansion`,items:Pd(a).map(e=>({type:`Word`,word:W.word([W.literal(e)])}))},endIndex:i+1}:null}function Id(e,t){let n=``;for(let r of t.parts)switch(r.type){case`Literal`:n+=r.value;break;case`SingleQuoted`:n+=`'${r.value}'`;break;case`Escaped`:n+=r.value;break;case`DoubleQuoted`:n+=`"`;for(let e of r.parts)e.type===`Literal`||e.type===`Escaped`?n+=e.value:e.type===`ParameterExpansion`&&(n+=`\${${e.parameter}}`);n+=`"`;break;case`ParameterExpansion`:n+=`\${${r.parameter}}`;break;case`Glob`:n+=r.pattern;break;case`TildeExpansion`:n+=`~`,r.user&&(n+=r.user);break;case`BraceExpansion`:{n+=`{`;let t=[];for(let n of r.items)if(n.type===`Range`){let e=n.startStr??String(n.start),r=n.endStr??String(n.end);n.step===void 0?t.push(`${e}..${r}`):t.push(`${e}..${r}..${n.step}`)}else t.push(Id(e,n.word));t.length===1&&r.items[0].type===`Range`?n+=t[0]:n+=t.join(`,`),n+=`}`;break}default:n+=r.type}return n}function Ld(e,t){return{[U.LESS]:`<`,[U.GREAT]:`>`,[U.DGREAT]:`>>`,[U.LESSAND]:`<&`,[U.GREATAND]:`>&`,[U.LESSGREAT]:`<>`,[U.CLOBBER]:`>|`,[U.TLESS]:`<<<`,[U.AND_GREAT]:`&>`,[U.AND_DGREAT]:`&>>`,[U.DLESS]:`<`,[U.DLESSDASH]:`<`}[t]||`>`}var Rd=g(()=>{Yu(),wd(),zu()});function zd(e){let t=e.current(),n=t.type;if(n===U.NUMBER){let n=e.peek(1);return t.end===n.start?Gu.has(n.type):!1}if(n===U.FD_VARIABLE){let t=e.peek(1);return Ku.has(t.type)}return Wu.has(n)}function Bd(e){let t=null,n;e.check(U.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(U.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),i=Ld(e,r.type);if(r.type===U.DLESS||r.type===U.DLESSDASH)return Vd(e,i,t,r.type===U.DLESSDASH);e.isWord()||e.error(`Expected redirection target`);let a=e.parseWord();return W.redirection(i,a,t,n)}function Vd(e,t,n,r){e.isWord()||e.error(`Expected here-document delimiter`);let i=e.advance(),a=i.value,o=i.quoted||!1;(a.startsWith(`'`)&&a.endsWith(`'`)||a.startsWith(`"`)&&a.endsWith(`"`))&&(a=a.slice(1,-1));let s=W.redirection(r?`<<-`:`<<`,W.hereDoc(a,W.word([]),r,o),n);return e.addPendingHeredoc(s,a,r,o),s}function Hd(e){let t=e.current().line,n=[],r=null,i=[],a=[];for(;e.check(U.ASSIGNMENT_WORD)||zd(e);)e.checkIterationLimit(),e.check(U.ASSIGNMENT_WORD)?n.push(Ud(e)):a.push(Bd(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(U.DBRACK_START)||e.check(U.DPAREN_START))){let t=e.advance();r=W.word([W.literal(t.value)])}for(;(!e.isStatementEnd()||e.check(U.RBRACE))&&!e.check(U.PIPE,U.PIPE_AMP);)if(e.checkIterationLimit(),zd(e))a.push(Bd(e));else if(e.check(U.RBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(U.LBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(U.DBRACK_END)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.isWord())i.push(e.parseWord());else if(e.check(U.ASSIGNMENT_WORD)){let t=e.advance(),n=t.value,r=n.endsWith(`=`),a=n.endsWith(`=(`);if((r||a)&&(a||e.check(U.LPAREN))){let t=a?n.slice(0,-2):n.slice(0,-1);a||e.expect(U.LPAREN);let r=Wd(e);e.expect(U.RPAREN);let o=`${t}=(${r.map(t=>Id(e,t)).join(` `)})`;i.push(e.parseWordFromString(o,!1,!1))}else i.push(e.parseWordFromString(n,t.quoted,t.singleQuoted))}else if(e.check(U.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=W.simpleCommand(r,i,n,a);return o.line=t,o}function Ud(e){let t=e.expect(U.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let i=r[0],a,o=i.length;if(n[o]===`[`){let t=0,r=o+1;for(;o<n.length;o++)if(n[o]===`[`)t++;else if(n[o]===`]`&&(t--,t===0))break;t!==0&&e.error(`Invalid assignment: ${n}`),a=n.slice(r,o),o++}let s=n[o]===`+`;s&&o++,n[o]!==`=`&&e.error(`Invalid assignment: ${n}`),o++;let c=n.slice(o);if(c===`(`){let t=Wd(e);e.expect(U.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return W.assignment(n,null,s,t)}if(c===``&&e.check(U.LPAREN)){let n=e.current();if(t.end===n.start){e.advance();let t=Wd(e);e.expect(U.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return W.assignment(n,null,s,t)}}let l=c?e.parseWordFromString(c,t.quoted,t.singleQuoted,!0):null,u=a===void 0?i:`${i}[${a}]`;return W.assignment(u,l,s,null)}function Wd(e){let t=[];for(e.skipNewlines();!e.check(U.RPAREN,U.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):Gd.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var Gd,Kd=g(()=>{Yu(),zu(),Ju(),Rd(),Gd=new Set([U.AMP,U.PIPE,U.PIPE_AMP,U.SEMICOLON,U.AND_AND,U.OR_OR,U.DSEMI,U.SEMI_AND,U.SEMI_SEMI_AND])});function qd(e,t){e.expect(U.IF);let n=[],r=e.parseCompoundList();e.expect(U.THEN);let i=e.parseCompoundList();if(i.length===0){let t=e.check(U.FI)?`fi`:e.check(U.ELSE)?`else`:e.check(U.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}for(n.push({condition:r,body:i});e.check(U.ELIF);){e.advance();let t=e.parseCompoundList();e.expect(U.THEN);let r=e.parseCompoundList();if(r.length===0){let t=e.check(U.FI)?`fi`:e.check(U.ELSE)?`else`:e.check(U.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}n.push({condition:t,body:r})}let a=null;e.check(U.ELSE)&&(e.advance(),a=e.parseCompoundList(),a.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(U.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return W.ifNode(n,a,o)}function Jd(e,t){let n=e.expect(U.FOR);if(e.check(U.DPAREN_START))return Yd(e,t,n.line);e.isWord()||e.error(`Expected variable name in for loop`);let r=e.advance().value,i=null;if(e.skipNewlines(),e.check(U.IN))for(e.advance(),i=[];!e.check(U.SEMICOLON,U.NEWLINE,U.DO,U.EOF)&&e.isWord();)i.push(e.parseWord());e.check(U.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(U.DO);let a=e.parseCompoundList();e.expect(U.DONE);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return W.forNode(r,i,a,o)}function Yd(e,t,n){e.expect(U.DPAREN_START);let r=null,i=null,a=null,o=[``,``,``],s=0,c=0;for(;!e.check(U.DPAREN_END,U.EOF);){let t=e.advance();if(t.type===U.SEMICOLON&&c===0){if(s++,s>2)break}else t.value===`(`&&c++,t.value===`)`&&c--,o[s]+=t.value}e.expect(U.DPAREN_END),o[0].trim()&&(r=rd(e,o[0].trim())),o[1].trim()&&(i=rd(e,o[1].trim())),o[2].trim()&&(a=rd(e,o[2].trim())),e.skipNewlines(),e.check(U.SEMICOLON)&&e.advance(),e.skipNewlines();let l;e.check(U.LBRACE)?(e.advance(),l=e.parseCompoundList(),e.expect(U.RBRACE)):(e.expect(U.DO),l=e.parseCompoundList(),e.expect(U.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:`CStyleFor`,init:r,condition:i,update:a,body:l,redirections:u,line:n}}function Xd(e,t){e.expect(U.WHILE);let n=e.parseCompoundList();e.expect(U.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(U.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return W.whileNode(n,r,i)}function Zd(e,t){e.expect(U.UNTIL);let n=e.parseCompoundList();e.expect(U.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(U.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return W.untilNode(n,r,i)}function Qd(e,t){e.expect(U.CASE),e.isWord()||e.error(`Expected word after 'case'`);let n=e.parseWord();e.skipNewlines(),e.expect(U.IN),e.skipNewlines();let r=[];for(;!e.check(U.ESAC,U.EOF);){e.checkIterationLimit();let t=e.getPos(),n=$d(e);if(n&&r.push(n),e.skipNewlines(),e.getPos()===t&&!n)break}e.expect(U.ESAC);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return W.caseNode(n,r,i)}function $d(e){e.check(U.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(U.PIPE));)e.advance();if(t.length===0)return null;e.expect(U.RPAREN),e.skipNewlines();let n=[];for(;!e.check(U.DSEMI,U.SEMI_AND,U.SEMI_SEMI_AND,U.ESAC,U.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===U.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(U.LPAREN)&&e.peek(1).type===U.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let t=e.getPos(),r=e.parseStatement();if(r&&n.push(r),e.skipSeparators(!1),e.getPos()===t&&!r)break}let r=`;;`;return e.check(U.DSEMI)?(e.advance(),r=`;;`):e.check(U.SEMI_AND)?(e.advance(),r=`;&`):e.check(U.SEMI_SEMI_AND)&&(e.advance(),r=`;;&`),W.caseItem(t,n,r)}function ef(e,t){e.expect(U.LPAREN);let n=e.parseCompoundList();e.expect(U.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return W.subshell(n,r)}function tf(e,t){e.expect(U.LBRACE);let n=e.parseCompoundList();e.expect(U.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return W.group(n,r)}var nf=g(()=>{Yu(),wd(),zu()});function rf(e){return e.isWord()||e.check(U.LBRACE)||e.check(U.RBRACE)||e.check(U.ASSIGNMENT_WORD)}function af(e){if(e.check(U.BANG)&&e.peek(1).type===U.LPAREN){e.advance(),e.advance();let t=1,n=`!(`;for(;t>0&&!e.check(U.EOF);)if(e.check(U.LPAREN))t++,n+=`(`,e.advance();else if(e.check(U.RPAREN))t--,t>0&&(n+=`)`),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(U.PIPE))n+=`|`,e.advance();else break;return n+=`)`,e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function of(e){return e.skipNewlines(),sf(e)}function sf(e){let t=cf(e);for(e.skipNewlines();e.check(U.OR_OR);){e.advance(),e.skipNewlines();let n=cf(e);t={type:`CondOr`,left:t,right:n},e.skipNewlines()}return t}function cf(e){let t=lf(e);for(e.skipNewlines();e.check(U.AND_AND);){e.advance(),e.skipNewlines();let n=lf(e);t={type:`CondAnd`,left:t,right:n},e.skipNewlines()}return t}function lf(e){return e.skipNewlines(),e.check(U.BANG)?(e.advance(),e.skipNewlines(),{type:`CondNot`,operand:lf(e)}):uf(e)}function uf(e){if(e.check(U.LPAREN)){e.advance();let t=of(e);return e.expect(U.RPAREN),{type:`CondGroup`,expression:t}}if(rf(e)){let t=e.current(),n=t.value;if(ff.includes(n)&&!t.quoted){if(e.advance(),e.check(U.DBRACK_END)&&e.error(`Expected operand after ${n}`),rf(e))return{type:`CondUnary`,operator:n,operand:e.parseWordNoBraceExpansion()};let t=e.current();e.error(`unexpected argument \`${t.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&pf.includes(e.current().value)){let t=e.advance().value,n;return n=t===`=~`?df(e):t===`==`||t===`!=`?af(e):e.parseWordNoBraceExpansion(),{type:`CondBinary`,operator:t,left:r,right:n}}return e.check(U.LESS)?(e.advance(),{type:`CondBinary`,operator:`<`,left:r,right:e.parseWordNoBraceExpansion()}):e.check(U.GREAT)?(e.advance(),{type:`CondBinary`,operator:`>`,left:r,right:e.parseWordNoBraceExpansion()}):e.isWord()&&e.current().value===`=`?(e.advance(),{type:`CondBinary`,operator:`==`,left:r,right:af(e)}):{type:`CondWord`,word:r}}e.error(`Expected conditional expression`)}function df(e){let t=[],n=0,r=-1,i=e.getInput(),a=()=>e.check(U.DBRACK_END)||e.check(U.AND_AND)||e.check(U.OR_OR)||e.check(U.NEWLINE)||e.check(U.EOF);for(;!a();){let a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let e=i.slice(r,a.start);t.push({type:`Literal`,value:e})}if(e.isWord()||e.check(U.ASSIGNMENT_WORD)){let n=e.parseWordForRegex();t.push(...n.parts),r=e.peek(-1).end}else if(e.check(U.LPAREN)){let i=e.advance();t.push({type:`Literal`,value:`(`}),n++,r=i.end}else if(e.check(U.DPAREN_START)){let i=e.advance();t.push({type:`Literal`,value:`((`}),n+=2,r=i.end}else if(e.check(U.DPAREN_END))if(n>=2){let i=e.advance();t.push({type:`Literal`,value:`))`}),n-=2,r=i.end}else{if(n===1)break;break}else if(e.check(U.RPAREN))if(n>0){let i=e.advance();t.push({type:`Literal`,value:`)`}),n--,r=i.end}else break;else if(e.check(U.PIPE)){let n=e.advance();t.push({type:`Literal`,value:`|`}),r=n.end}else if(e.check(U.SEMICOLON))if(n>0){let n=e.advance();t.push({type:`Literal`,value:`;`}),r=n.end}else break;else if(n>0&&e.check(U.LESS)){let n=e.advance();t.push({type:`Literal`,value:`<`}),r=n.end}else if(n>0&&e.check(U.GREAT)){let n=e.advance();t.push({type:`Literal`,value:`>`}),r=n.end}else if(n>0&&e.check(U.DGREAT)){let n=e.advance();t.push({type:`Literal`,value:`>>`}),r=n.end}else if(n>0&&e.check(U.DLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<`}),r=n.end}else if(n>0&&e.check(U.LESSAND)){let n=e.advance();t.push({type:`Literal`,value:`<&`}),r=n.end}else if(n>0&&e.check(U.GREATAND)){let n=e.advance();t.push({type:`Literal`,value:`>&`}),r=n.end}else if(n>0&&e.check(U.LESSGREAT)){let n=e.advance();t.push({type:`Literal`,value:`<>`}),r=n.end}else if(n>0&&e.check(U.CLOBBER)){let n=e.advance();t.push({type:`Literal`,value:`>|`}),r=n.end}else if(n>0&&e.check(U.TLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<<`}),r=n.end}else if(n>0&&e.check(U.AMP)){let n=e.advance();t.push({type:`Literal`,value:`&`}),r=n.end}else if(n>0&&e.check(U.LBRACE)){let n=e.advance();t.push({type:`Literal`,value:`{`}),r=n.end}else if(n>0&&e.check(U.RBRACE)){let n=e.advance();t.push({type:`Literal`,value:`}`}),r=n.end}else break}return t.length===0&&e.error(`Expected regex pattern after =~`),{type:`Word`,parts:t}}var ff,pf,mf=g(()=>{zu(),ff=`-a.-b.-c.-d.-e.-f.-g.-h.-k.-p.-r.-s.-t.-u.-w.-x.-G.-L.-N.-O.-S.-z.-n.-o.-v.-R`.split(`.`),pf=[`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`]});function hf(e){return e.length>0?e:[W.literal(``)]}function gf(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(`@*+?!`.includes(t)&&r+1<e.length&&e[r+1]===`(`){r++,n++,r++;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function _f(e,t,n){let r=n+1,i=t[r];if(`@*#?$!-0123456789`.includes(i))return{part:W.parameterExpansion(i),endIndex:r+1};let a=``;for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)a+=t[r],r++;return{part:W.parameterExpansion(a),endIndex:r}}function vf(e,t,n,r=!1){let i=n+2,a=!1;t[i]===`!`&&(a=!0,i++);let o=!1;t[i]===`#`&&!/[}:#%/^,]/.test(t[i+1]||`}`)&&(o=!0,i++);let s=``,c=t[i];if(/[@*#?$!-]/.test(c)&&!/[a-zA-Z0-9_]/.test(t[i+1]||``))s=c,i++;else for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)s+=t[i],i++;if(t[i]===`[`){let r=Dd(e,t,i,`[`,`]`);if(s+=t.slice(i,r+1),i=r+1,t[i]===`[`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;let a=t.slice(n+2,r);return{part:W.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}}if(s===``&&!a&&!o&&t[i]!==`}`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;if(e>0)throw new qu(`unexpected EOF while looking for matching '}'`,0,0);let a=t.slice(n+2,r);return{part:W.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}let l=null;if(a){let n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n)if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let a=yf(e,t,i,s,r);a.operation?(l={type:`Indirection`,innerOp:a.operation},i=a.endIndex):(l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``)}else l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``;else if(t[i]===`*`||t[i]===`@`&&!/[QPaAEKkuUL]/.test(t[i+1]||``)){let e=t[i];i++,l={type:`VarNamePrefix`,prefix:s,star:e===`*`},s=``}else if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let n=yf(e,t,i,s,r);n.operation?(l={type:`Indirection`,innerOp:n.operation},i=n.endIndex):l={type:`Indirection`}}else l={type:`Indirection`}}else if(o)if(t[i]===`:`)for(l={type:`LengthSliceError`};i<t.length&&t[i]!==`}`;)i++;else t[i]!==`}`&&/[-+=?]/.test(t[i])||t[i]===`/`?e.error(`\${#${s}${t.slice(i,t.indexOf(`}`,i))}}: bad substitution`):l={type:`Length`};if(!l&&i<t.length&&t[i]!==`}`){let n=yf(e,t,i,s,r);l=n.operation,i=n.endIndex}if(i<t.length&&t[i]!==`}`){let r=t[i];if(!/[:\-+=?#%/^,@[]/.test(r)){let r=i;for(;r<t.length&&t[r]!==`}`;)r++;let a=t.slice(n,r+1);e.error(`\${${a.slice(2,-1)}}: bad substitution`)}}for(;i<t.length&&t[i]!==`}`;)i++;if(i>=t.length)throw new qu(`unexpected EOF while looking for matching '}'`,0,0);return{part:W.parameterExpansion(s,l),endIndex:i+1}}function yf(e,t,n,r,i=!1){let a=n,o=t[a],s=t[a+1]||``;if(o===`:`){let n=s;if(`-=?+`.includes(n)){a+=2;let r=Od(e,t,a),o=Cf(e,t.slice(a,r),!1,!1,!0,!1,i,!1,!1,!0),s=W.word(hf(o));if(n===`-`)return{operation:{type:`DefaultValue`,word:s,checkEmpty:!0},endIndex:r};if(n===`=`)return{operation:{type:`AssignDefault`,word:s,checkEmpty:!0},endIndex:r};if(n===`?`)return{operation:{type:`ErrorIfUnset`,word:s,checkEmpty:!0},endIndex:r};if(n===`+`)return{operation:{type:`UseAlternative`,word:s,checkEmpty:!0},endIndex:r}}a++;let r=Od(e,t,a),o=t.slice(a,r),c=-1,l=0,u=0;for(let e=0;e<o.length;e++){let t=o[e];if(t===`(`||t===`[`)l++;else if(t===`)`||t===`]`)l--;else if(t===`?`&&l===0)u++;else if(t===`:`&&l===0)if(u>0)u--;else{c=e;break}}let d=c>=0?o.slice(0,c):o,f=c>=0?o.slice(c+1):null;return{operation:{type:`Substring`,offset:Nd(e,d),length:f===null?null:Nd(e,f)},endIndex:r}}if(`-=?+`.includes(o)){a++;let n=Od(e,t,a),r=t.slice(a,n),s=Cf(e,r,!1,!1,!0,!1,i,!1,!1,!0),c=W.word(hf(s));if(o===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!1},endIndex:n};if(o===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!1},endIndex:n};if(o===`?`)return{operation:{type:`ErrorIfUnset`,word:r?c:null,checkEmpty:!1},endIndex:n};if(o===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!1},endIndex:n}}if(o===`#`||o===`%`){let n=s===o,r=o===`#`?`prefix`:`suffix`;a+=n?2:1;let i=Od(e,t,a),c=Cf(e,t.slice(a,i),!1,!1,!1);return{operation:{type:`PatternRemoval`,pattern:W.word(hf(c)),side:r,greedy:n},endIndex:i}}if(o===`/`){let n=s===`/`;a+=n?2:1;let r=null;t[a]===`#`?(r=`start`,a++):t[a]===`%`&&(r=`end`,a++);let i;i=r!==null&&(t[a]===`/`||t[a]===`}`)?a:kd(e,t,a);let o=Cf(e,t.slice(a,i),!1,!1,!1),c=W.word(hf(o)),l=null,u=i;if(t[i]===`/`){let n=i+1,r=Od(e,t,n),a=Cf(e,t.slice(n,r),!1,!1,!1);l=W.word(hf(a)),u=r}return{operation:{type:`PatternReplacement`,pattern:c,replacement:l,all:n,anchor:r},endIndex:u}}if(o===`^`||o===`,`){let n=s===o,r=o===`^`?`upper`:`lower`;a+=n?2:1;let i=Od(e,t,a),c=t.slice(a,i);return{operation:{type:`CaseModification`,direction:r,all:n,pattern:c?W.word([W.literal(c)]):null},endIndex:i}}return o===`@`&&/[QPaAEKkuUL]/.test(s)?{operation:{type:`Transform`,operator:s},endIndex:a+2}:{operation:null,endIndex:a}}function bf(e,t,n,r=!1){let i=n+1;if(i>=t.length)return{part:W.literal(`$`),endIndex:i};let a=t[i];if(a===`(`&&t[i+1]===`(`)return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(a===`[`){let n=1,r=i+1;for(;r<t.length&&n>0;)t[r]===`[`?n++:t[r]===`]`&&n--,n>0&&r++;if(n===0){let n=rd(e,t.slice(i+1,r));return{part:W.arithmeticExpansion(n),endIndex:r+1}}}return a===`(`?e.parseCommandSubstitution(t,n):a===`{`?vf(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(a)?_f(e,t,n):{part:W.literal(`$`),endIndex:i}}function xf(e,t){let n=[],r=0,i=``,a=()=>{i&&=(n.push(W.literal(i)),``)};for(;r<t.length;){let o=t[r];if(o===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`"`||e===`\\`){i+=e,r+=2;continue}i+=o,r++;continue}if(o===`$`){a();let{part:i,endIndex:o}=bf(e,t,r,!0);i&&n.push(i),r=o;continue}if(o==="`"){a();let{part:i,endIndex:o}=e.parseBacktickSubstitution(t,r,!0);n.push(i),r=o;continue}i+=o,r++}return a(),n}function Sf(e,t,n){let r=[],i=n,a=``,o=()=>{a&&=(r.push(W.literal(a)),``)};for(;i<t.length&&t[i]!==`"`;){let n=t[i];if(n===`\\`&&i+1<t.length){let e=t[i+1];if(`"\\$\`
194
- `.includes(e)){a+=e,i+=2;continue}a+=n,i++;continue}if(n===`$`){o();let{part:n,endIndex:a}=bf(e,t,i,!0);n&&r.push(n),i=a;continue}if(n==="`"){o();let{part:n,endIndex:a}=e.parseBacktickSubstitution(t,i,!0);r.push(n),i=a;continue}a+=n,i++}return o(),{part:W.doubleQuoted(r),endIndex:i}}function Cf(e,t,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1){if(r)return[W.singleQuoted(t)];if(n){let n=xf(e,t);return[W.doubleQuoted(n)]}if(t.length>=2&&t[0]===`"`&&t[t.length-1]===`"`){let n=t.slice(1,-1),r=!1;for(let e=0;e<n.length;e++){if(n[e]===`"`){r=!0;break}n[e]===`\\`&&e+1<n.length&&e++}if(!r){let t=xf(e,n);return[W.doubleQuoted(t)]}}let u=[],d=0,f=``,p=()=>{f&&=(u.push(W.literal(f)),``)};for(;d<t.length;){let n=t[d];if(n===`\\`&&d+1<t.length){let e=t[d+1];if(c){p(),u.push(W.escaped(e)),d+=2;continue}let n=a?e===`$`||e==="`"||e===`
196
+ `);)a=!0,i++;if(a&&i<n&&t[i]===`)`)return!0}if(i===0)return!1;r++;continue}if(i===1&&(e===`|`&&r+1<n&&t[r+1]===`|`||e===`&`&&r+1<n&&t[r+1]===`&`||e===`|`&&r+1<n&&t[r+1]!==`|`))return!0;r++}return!1}}}),Ju,Yu,Xu,Zu,Qu,$u,ed,td,nd=g(()=>{qu(),Ju=1e6,Yu=1e5,Xu=1e6,Zu=200,Qu=new Set([W.LESS,W.GREAT,W.DLESS,W.DGREAT,W.LESSAND,W.GREATAND,W.LESSGREAT,W.DLESSDASH,W.CLOBBER,W.TLESS,W.AND_GREAT,W.AND_DGREAT]),$u=new Set([W.LESS,W.GREAT,W.DLESS,W.DGREAT,W.LESSAND,W.GREATAND,W.LESSGREAT,W.DLESSDASH,W.CLOBBER,W.TLESS]),ed=new Set([W.LESS,W.GREAT,W.DLESS,W.DGREAT,W.LESSAND,W.GREATAND,W.LESSGREAT,W.DLESSDASH,W.CLOBBER,W.TLESS,W.AND_GREAT,W.AND_DGREAT]),td=class extends Error{line;column;token;constructor(e,t,n,r=void 0){super(`Parse error at ${t}:${n}: ${e}`),this.line=t,this.column=n,this.token=r,this.name=`ParseException`}}});function G(e,t){for(;t<e.length;){if(e[t]===`\\`&&e[t+1]===`
197
+ `){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}function rd(e){if(e.includes(`#`)){let[t,n]=e.split(`#`),r=Number.parseInt(t,10);if(r<2||r>64)return NaN;if(r<=36){let e=Number.parseInt(n,r);return e>2**53-1?2**53-1:e}let i=0;for(let e of n){let t;if(/[0-9]/.test(e))t=e.charCodeAt(0)-48;else if(/[a-z]/.test(e))t=e.charCodeAt(0)-97+10;else if(/[A-Z]/.test(e))t=e.charCodeAt(0)-65+36;else if(e===`@`)t=62;else if(e===`_`)t=63;else return NaN;if(t>=r)return NaN;if(i=i*r+t,i>2**53-1)return 2**53-1}return i}if(e.startsWith(`0x`)||e.startsWith(`0X`)){let t=Number.parseInt(e.slice(2),16);return t>2**53-1?2**53-1:t}if(e.startsWith(`0`)&&e.length>1&&/^[0-9]+$/.test(e)){if(/[89]/.test(e))return NaN;let t=Number.parseInt(e,8);return t>2**53-1?2**53-1:t}let t=Number.parseInt(e,10);return t>2**53-1?2**53-1:t}function id(e,t,n,r){if(n.slice(r,r+3)!==`$((`)return null;let i=r+3,a=1,o=i;for(;i<n.length-1&&a>0;)n[i]===`(`&&n[i+1]===`(`?(a++,i+=2):n[i]===`)`&&n[i+1]===`)`?(a--,a>0&&(i+=2)):i++;let{expr:s}=e(t,n.slice(o,i),0);return i+=2,{expr:{type:`ArithNested`,expression:s},pos:i}}function ad(e,t){if(e.slice(t,t+2)!==`$'`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`'`;)if(e[n]===`\\`&&n+1<e.length){let t=e[n+1];switch(t){case`n`:r+=`
198
+ `;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`\\`:r+=`\\`;break;case`'`:r+=`'`;break;default:r+=t}n+=2}else r+=e[n],n++;e[n]===`'`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}function od(e,t){if(e.slice(t,t+2)!==`$"`)return null;let n=t+2,r=``;for(;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]===`"`&&n++;let i=Number.parseInt(r,10);return{expr:{type:`ArithNumber`,value:Number.isNaN(i)?0:i},pos:n}}var sd,cd=g(()=>{sd=[`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`<<=`,`>>=`,`&=`,`|=`,`^=`]});function ld(e){let t=``,n=0;for(;n<e.length;)if(e[n]===`"`){for(n++;n<e.length&&e[n]!==`"`;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function ud(e,t){let n=ld(t),{expr:r,pos:i}=pd(e,n,0),a=G(n,i);if(a<n.length){let e=t.slice(a).trim();if(e)return{type:`ArithmeticExpression`,originalText:t,expression:{type:`ArithSyntaxError`,errorToken:e,message:`${e}: syntax error: invalid arithmetic operator (error token is "${e}")`}}}return{type:`ArithmeticExpression`,expression:r,originalText:t}}function dd(e,t){return{expr:{type:`ArithSyntaxError`,errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function fd(e,t){return G(e,t)>=e.length}function pd(e,t,n){return md(e,t,n)}function md(e,t,n){let{expr:r,pos:i}=hd(e,t,n);for(i=G(t,i);t[i]===`,`;){if(i++,fd(t,i))return dd(`,`,i);let{expr:n,pos:a}=hd(e,t,i);r={type:`ArithBinary`,operator:`,`,left:r,right:n},i=G(t,a)}return{expr:r,pos:i}}function hd(e,t,n){let{expr:r,pos:i}=gd(e,t,n);if(i=G(t,i),t[i]===`?`){i++;let{expr:n,pos:a}=pd(e,t,i);if(i=G(t,a),t[i]===`:`){i++;let{expr:a,pos:o}=pd(e,t,i);return{expr:{type:`ArithTernary`,condition:r,consequent:n,alternate:a},pos:o}}}return{expr:r,pos:i}}function gd(e,t,n){let{expr:r,pos:i}=_d(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`||`;){if(i+=2,fd(t,i))return dd(`||`,i);let{expr:n,pos:a}=_d(e,t,i);r={type:`ArithBinary`,operator:`||`,left:r,right:n},i=a}return{expr:r,pos:i}}function _d(e,t,n){let{expr:r,pos:i}=vd(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`&&`;){if(i+=2,fd(t,i))return dd(`&&`,i);let{expr:n,pos:a}=vd(e,t,i);r={type:`ArithBinary`,operator:`&&`,left:r,right:n},i=a}return{expr:r,pos:i}}function vd(e,t,n){let{expr:r,pos:i}=yd(e,t,n);for(;i=G(t,i),t[i]===`|`&&t[i+1]!==`|`;){if(i++,fd(t,i))return dd(`|`,i);let{expr:n,pos:a}=yd(e,t,i);r={type:`ArithBinary`,operator:`|`,left:r,right:n},i=a}return{expr:r,pos:i}}function yd(e,t,n){let{expr:r,pos:i}=bd(e,t,n);for(;i=G(t,i),t[i]===`^`;){if(i++,fd(t,i))return dd(`^`,i);let{expr:n,pos:a}=bd(e,t,i);r={type:`ArithBinary`,operator:`^`,left:r,right:n},i=a}return{expr:r,pos:i}}function bd(e,t,n){let{expr:r,pos:i}=xd(e,t,n);for(;i=G(t,i),t[i]===`&`&&t[i+1]!==`&`;){if(i++,fd(t,i))return dd(`&`,i);let{expr:n,pos:a}=xd(e,t,i);r={type:`ArithBinary`,operator:`&`,left:r,right:n},i=a}return{expr:r,pos:i}}function xd(e,t,n){let{expr:r,pos:i}=Sd(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`==`||t.slice(i,i+2)===`!=`;){let n=t.slice(i,i+2);if(i+=2,fd(t,i))return dd(n,i);let{expr:a,pos:o}=Sd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function Sd(e,t,n){let{expr:r,pos:i}=Cd(e,t,n);for(;;)if(i=G(t,i),t.slice(i,i+2)===`<=`||t.slice(i,i+2)===`>=`){let n=t.slice(i,i+2);if(i+=2,fd(t,i))return dd(n,i);let{expr:a,pos:o}=Cd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else if(t[i]===`<`||t[i]===`>`){let n=t[i];if(i++,fd(t,i))return dd(n,i);let{expr:a,pos:o}=Cd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function Cd(e,t,n){let{expr:r,pos:i}=wd(e,t,n);for(;i=G(t,i),t.slice(i,i+2)===`<<`||t.slice(i,i+2)===`>>`;){let n=t.slice(i,i+2);if(i+=2,fd(t,i))return dd(n,i);let{expr:a,pos:o}=wd(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function wd(e,t,n){let{expr:r,pos:i}=Td(e,t,n);for(;i=G(t,i),(t[i]===`+`||t[i]===`-`)&&t[i+1]!==t[i];){let n=t[i];if(i++,fd(t,i))return dd(n,i);let{expr:a,pos:o}=Td(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}return{expr:r,pos:i}}function Td(e,t,n){let{expr:r,pos:i}=Ed(e,t,n);for(;;)if(i=G(t,i),t[i]===`*`&&t[i+1]!==`*`){if(i++,fd(t,i))return dd(`*`,i);let{expr:n,pos:a}=Ed(e,t,i);r={type:`ArithBinary`,operator:`*`,left:r,right:n},i=a}else if(t[i]===`/`||t[i]===`%`){let n=t[i];if(i++,fd(t,i))return dd(n,i);let{expr:a,pos:o}=Ed(e,t,i);r={type:`ArithBinary`,operator:n,left:r,right:a},i=o}else break;return{expr:r,pos:i}}function Ed(e,t,n){let{expr:r,pos:i}=Dd(e,t,n),a=G(t,i);if(t.slice(a,a+2)===`**`){if(a+=2,fd(t,a))return dd(`**`,a);let{expr:n,pos:i}=Ed(e,t,a);return{expr:{type:`ArithBinary`,operator:`**`,left:r,right:n},pos:i}}return{expr:r,pos:i}}function Dd(e,t,n){let r=G(t,n);if(t.slice(r,r+2)===`++`||t.slice(r,r+2)===`--`){let n=t.slice(r,r+2);r+=2;let{expr:i,pos:a}=Dd(e,t,r);return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}if(t[r]===`+`||t[r]===`-`||t[r]===`!`||t[r]===`~`){let n=t[r];r++;let{expr:i,pos:a}=Dd(e,t,r);return{expr:{type:`ArithUnary`,operator:n,operand:i,prefix:!0},pos:a}}return kd(e,t,r)}function Od(e,t){let n=e[t];return n===`$`||n==="`"}function kd(e,t,n){let{expr:r,pos:i}=Ad(e,t,n,!1),a=[r];for(;Od(t,i);){let{expr:n,pos:r}=Ad(e,t,i,!0);a.push(n),i=r}a.length>1&&(r={type:`ArithConcat`,parts:a});let o;if(t[i]===`[`&&r.type===`ArithConcat`){i++;let{expr:n,pos:r}=pd(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(o&&r.type===`ArithConcat`&&(r={type:`ArithDynamicElement`,nameExpr:r,subscript:o},o=void 0),i=G(t,i),r.type===`ArithConcat`||r.type===`ArithVariable`||r.type===`ArithDynamicElement`){for(let n of sd)if(t.slice(i,i+n.length)===n&&t.slice(i,i+n.length+1)!==`==`){i+=n.length;let{expr:a,pos:o}=hd(e,t,i);return r.type===`ArithDynamicElement`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r.nameExpr,subscript:r.subscript,value:a},pos:o}:r.type===`ArithConcat`?{expr:{type:`ArithDynamicAssignment`,operator:n,target:r,value:a},pos:o}:{expr:{type:`ArithAssignment`,operator:n,variable:r.name,value:a},pos:o}}}if(t.slice(i,i+2)===`++`||t.slice(i,i+2)===`--`){let e=t.slice(i,i+2);return i+=2,{expr:{type:`ArithUnary`,operator:e,operand:r,prefix:!1},pos:i}}return{expr:r,pos:i}}function Ad(e,t,n,r=!1){let i=G(t,n),a=id(pd,e,t,i);if(a)return a;let o=ad(t,i);if(o)return o;let s=od(t,i);if(s)return s;if(t.slice(i,i+2)===`$(`&&t[i+2]!==`(`){i+=2;let e=1,n=i;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,e>0&&i++;let r=t.slice(n,i);return i++,{expr:{type:`ArithCommandSubst`,command:r},pos:i}}if(t[i]==="`"){i++;let e=i;for(;i<t.length&&t[i]!=="`";)i++;let n=t.slice(e,i);return t[i]==="`"&&i++,{expr:{type:`ArithCommandSubst`,command:n},pos:i}}if(t[i]===`(`){i++;let{expr:n,pos:r}=pd(e,t,i);return i=G(t,r),t[i]===`)`&&i++,{expr:{type:`ArithGroup`,expression:n},pos:i}}if(t[i]===`'`){i++;let e=``;for(;i<t.length&&t[i]!==`'`;)e+=t[i],i++;t[i]===`'`&&i++;let n=Number.parseInt(e,10);return{expr:{type:`ArithSingleQuote`,content:e,value:Number.isNaN(n)?0:n},pos:i}}if(t[i]===`"`){i++;let n=``;for(;i<t.length&&t[i]!==`"`;)t[i]===`\\`&&i+1<t.length?(n+=t[i+1],i+=2):(n+=t[i],i++);t[i]===`"`&&i++;let r=n.trim();if(!r)return{expr:{type:`ArithNumber`,value:0},pos:i};let{expr:a}=pd(e,r,0);return{expr:a,pos:i}}if(/[0-9]/.test(t[i])){let e=``,n=!1,r=!1;for(;i<t.length;){let a=t[i];if(n)if(/[0-9a-zA-Z@_]/.test(a))e+=a,i++;else break;else if(a===`#`)n=!0,e+=a,i++;else if(e===`0`&&(a===`x`||a===`X`)&&i+1<t.length&&/[0-9a-fA-F]/.test(t[i+1]))r=!0,e+=a,i++;else if(r&&/[0-9a-fA-F]/.test(a))e+=a,i++;else if(!r&&/[0-9]/.test(a))e+=a,i++;else break}if(i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=e;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: value too great for base (error token is "${n}")`},pos:i}}if(t[i]===`.`&&/[0-9]/.test(t[i+1]))throw new sr(`${e}.${t[i+1]}...: syntax error: invalid arithmetic operator`);if(t[i]===`[`){let n=t.slice(i).trim();return{expr:{type:`ArithNumberSubscript`,number:e,errorToken:n},pos:t.length}}return{expr:{type:`ArithNumber`,value:rd(e)},pos:i}}if(t[i]===`$`&&t[i+1]===`{`){let e=i+2,n=1,r=e;for(;r<t.length&&n>0;)t[r]===`{`?n++:t[r]===`}`&&n--,n>0&&r++;let a=t.slice(e,r),o=r+1;if(t[o]===`#`){let e=o+1;for(;e<t.length&&/[0-9a-zA-Z@_]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicBase`,baseExpr:a,value:t.slice(o+1,e)},pos:e}}if(/[0-9]/.test(t[o])||t[o]===`x`||t[o]===`X`){let e=o;if(t[o]===`x`||t[o]===`X`)for(e++;e<t.length&&/[0-9a-fA-F]/.test(t[e]);)e++;else for(;e<t.length&&/[0-9]/.test(t[e]);)e++;return{expr:{type:`ArithDynamicNumber`,prefix:a,suffix:t.slice(o,e)},pos:e}}return i=o,{expr:{type:`ArithBracedExpansion`,content:a},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[0-9]/.test(t[i+1])){i++;let e=``;for(;i<t.length&&/[0-9]/.test(t[i]);)e+=t[i],i++;return{expr:{type:`ArithVariable`,name:e,hasDollarPrefix:!0},pos:i}}if(t[i]===`$`&&i+1<t.length&&/[*@#?\-!$]/.test(t[i+1])){let e=t[i+1];return i+=2,{expr:{type:`ArithSpecialVar`,name:e},pos:i}}let c=!1;if(t[i]===`$`&&i+1<t.length&&/[a-zA-Z_]/.test(t[i+1])&&(c=!0,i++),i<t.length&&/[a-zA-Z_]/.test(t[i])){let n=``;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)n+=t[i],i++;if(t[i]===`[`&&!r){i++;let a;if(t[i]===`'`||t[i]===`"`){let e=t[i];for(i++,a=``;i<t.length&&t[i]!==e;)a+=t[i],i++;t[i]===e&&i++,i=G(t,i),t[i]===`]`&&i++}let o;if(a===void 0){let{expr:n,pos:r}=pd(e,t,i);o=n,i=r,t[i]===`]`&&i++}if(i=G(t,i),t[i]===`[`&&o)return{expr:{type:`ArithDoubleSubscript`,array:n,index:o},pos:i};if(!r){for(let r of sd)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:s,pos:c}=hd(e,t,i);return{expr:{type:`ArithAssignment`,operator:r,variable:n,subscript:o,stringKey:a,value:s},pos:c}}}return{expr:{type:`ArithArrayElement`,array:n,index:o,stringKey:a},pos:i}}if(i=G(t,i),!r){for(let r of sd)if(t.slice(i,i+r.length)===r&&t.slice(i,i+r.length+1)!==`==`){i+=r.length;let{expr:a,pos:o}=hd(e,t,i);return{expr:{type:`ArithAssignment`,operator:r,variable:n,value:a},pos:o}}}return{expr:{type:`ArithVariable`,name:n,hasDollarPrefix:c},pos:i}}if(t[i]===`#`){let e=i+1;for(;e<t.length&&t[e]!==`
199
+ `;)e++;let n=t.slice(i,e).trim()||`#`;return{expr:{type:`ArithSyntaxError`,errorToken:n,message:`${n}: syntax error: invalid arithmetic operator (error token is "${n}")`},pos:t.length}}return{expr:{type:`ArithNumber`,value:0},pos:i}}var jd=g(()=>{x(),cd()});function Md(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)==192){if(n+1<e.length&&(e[n+1]&192)==128&&r>=194){let i=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(i),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)==224){if(n+2<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let i=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(i>=55296&&i<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(i),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)==240&&r<=244){if(n+3<e.length&&(e[n+1]&192)==128&&(e[n+2]&192)==128&&(e[n+3]&192)==128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let i=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(i>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(i),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function Nd(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function Pd(e,t,n,r,i){let a=1,o=n+1;for(;o<t.length&&a>0;)t[o]===r?a++:t[o]===i&&a--,a>0&&o++;return a===0?o:-1}function Fd(e,t,n){let r=n,i=1;for(;r<t.length&&i>0;){let e=t[r];if(e===`\\`&&r+1<t.length){r+=2;continue}if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++;continue}e===`{`?i++:e===`}`&&i--,i>0&&r++}return r}function Id(e,t,n){let r=n,i=!1;for(;r<t.length;){let e=t[r];if(e===`/`&&i||e===`}`)break;if(e===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){r=e+1,i=!0;continue}}if(e===`"`){for(r++;r<t.length&&t[r]!==`"`;)t[r]===`\\`&&r+1<t.length?r+=2:r++;r<t.length&&r++,i=!0;continue}e===`\\`?(r+=2,i=!0):(r++,i=!0)}return r}function Ld(e,t,n){let r=n,i=``;for(;r<t.length;){let e=t[r];if(e===`*`||e===`?`)i+=e,r++;else if(e===`[`){let n=Rd(t,r);n===-1?(i+=e,r++):(i+=t.slice(r,n+1),r=n+1)}else break}return{pattern:i,endIndex:r}}function Rd(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){let t=e[n];if(t===`\\`&&n+1<e.length){let t=e[n+1];if(t===`"`||t===`'`)return-1;n+=2;continue}if(t===`]`)return n;if(t===`"`||t===`$`||t==="`")return-1;if(t===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(t===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}if(t===`[`&&n+1<e.length&&(e[n+1]===`.`||e[n+1]===`=`)){let t=`${e[n+1]}]`,r=e.indexOf(t,n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function zd(e,t,n){let r=``,i=n;for(;i<t.length&&t[i]!==`'`;){let e=t[i];if(e===`\\`&&i+1<t.length)switch(t[i+1]){case`n`:r+=`
200
+ `,i+=2;break;case`t`:r+=` `,i+=2;break;case`r`:r+=`\r`,i+=2;break;case`\\`:r+=`\\`,i+=2;break;case`'`:r+=`'`,i+=2;break;case`"`:r+=`"`,i+=2;break;case`a`:r+=`\x07`,i+=2;break;case`b`:r+=`\b`,i+=2;break;case`e`:case`E`:r+=`\x1B`,i+=2;break;case`f`:r+=`\f`,i+=2;break;case`v`:r+=`\v`,i+=2;break;case`x`:{let e=[],n=i;for(;n+1<t.length&&t[n]===`\\`&&t[n+1]===`x`;){let r=t.slice(n+2,n+4),i=parseInt(r,16);if(!Number.isNaN(i)&&r.length>0)e.push(i),n+=2+r.length;else break}e.length>0?(r+=Md(e),i=n):(r+=`\\x`,i+=2);break}case`u`:{let e=t.slice(i+2,i+6),n=parseInt(e,16);Number.isNaN(n)?(r+=`\\u`,i+=2):(r+=String.fromCharCode(n),i+=6);break}case`c`:if(i+2<t.length){let e=t[i+2].charCodeAt(0)&31;r+=String.fromCharCode(e),i+=3}else r+=`\\c`,i+=2;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:{let e=``,n=i+1;for(;n<t.length&&n<i+4&&/[0-7]/.test(t[n]);)e+=t[n],n++;let a=parseInt(e,8);r+=String.fromCharCode(a),i=n;break}default:r+=e,i++}else r+=e,i++}return i<t.length&&t[i]===`'`&&i++,{part:U.literal(r),endIndex:i}}function Bd(e,t){let n=t.trim();return n===``?{type:`ArithmeticExpression`,expression:{type:`ArithNumber`,value:0}}:ud(e,n)}function Vd(e){let t=[],n=``,r=0;for(let i=0;i<e.length;i++){let a=e[i];a===`{`?(r++,n+=a):a===`}`?(r--,n+=a):a===`,`&&r===0?(t.push(n),n=``):n+=a}return t.push(n),t}function Hd(e,t,n,r){let i=Pd(e,t,n,`{`,`}`);if(i===-1)return null;let a=t.slice(n+1,i),o=a.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(o)return{part:{type:`BraceExpansion`,items:[{type:`Range`,start:Number.parseInt(o[1],10),end:Number.parseInt(o[2],10),step:o[3]?Number.parseInt(o[3],10):void 0,startStr:o[1],endStr:o[2]}]},endIndex:i+1};let s=a.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return s?{part:{type:`BraceExpansion`,items:[{type:`Range`,start:s[1],end:s[2],step:s[3]?Number.parseInt(s[3],10):void 0}]},endIndex:i+1}:a.includes(`,`)&&r?{part:{type:`BraceExpansion`,items:Vd(a).map(t=>({type:`Word`,word:U.word(r(e,t,!1,!1,!1))}))},endIndex:i+1}:a.includes(`,`)?{part:{type:`BraceExpansion`,items:Vd(a).map(e=>({type:`Word`,word:U.word([U.literal(e)])}))},endIndex:i+1}:null}function Ud(e,t){let n=``;for(let r of t.parts)switch(r.type){case`Literal`:n+=r.value;break;case`SingleQuoted`:n+=`'${r.value}'`;break;case`Escaped`:n+=r.value;break;case`DoubleQuoted`:n+=`"`;for(let e of r.parts)e.type===`Literal`||e.type===`Escaped`?n+=e.value:e.type===`ParameterExpansion`&&(n+=`\${${e.parameter}}`);n+=`"`;break;case`ParameterExpansion`:n+=`\${${r.parameter}}`;break;case`Glob`:n+=r.pattern;break;case`TildeExpansion`:n+=`~`,r.user&&(n+=r.user);break;case`BraceExpansion`:{n+=`{`;let t=[];for(let n of r.items)if(n.type===`Range`){let e=n.startStr??String(n.start),r=n.endStr??String(n.end);n.step===void 0?t.push(`${e}..${r}`):t.push(`${e}..${r}..${n.step}`)}else t.push(Ud(e,n.word));t.length===1&&r.items[0].type===`Range`?n+=t[0]:n+=t.join(`,`),n+=`}`;break}default:n+=r.type}return n}function Wd(e,t){return{[W.LESS]:`<`,[W.GREAT]:`>`,[W.DGREAT]:`>>`,[W.LESSAND]:`<&`,[W.GREATAND]:`>&`,[W.LESSGREAT]:`<>`,[W.CLOBBER]:`>|`,[W.TLESS]:`<<<`,[W.AND_GREAT]:`&>`,[W.AND_DGREAT]:`&>>`,[W.DLESS]:`<`,[W.DLESSDASH]:`<`}[t]||`>`}var Gd=g(()=>{ku(),jd(),qu()});function Kd(e){let t=e.current(),n=t.type;if(n===W.NUMBER){let n=e.peek(1);return t.end===n.start?$u.has(n.type):!1}if(n===W.FD_VARIABLE){let t=e.peek(1);return ed.has(t.type)}return Qu.has(n)}function qd(e){let t=null,n;e.check(W.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(W.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),i=Wd(e,r.type);if(r.type===W.DLESS||r.type===W.DLESSDASH)return Jd(e,i,t,r.type===W.DLESSDASH);e.isWord()||e.error(`Expected redirection target`);let a=e.parseWord();return U.redirection(i,a,t,n)}function Jd(e,t,n,r){e.isWord()||e.error(`Expected here-document delimiter`);let i=e.advance(),a=i.value,o=i.quoted||!1;(a.startsWith(`'`)&&a.endsWith(`'`)||a.startsWith(`"`)&&a.endsWith(`"`))&&(a=a.slice(1,-1));let s=U.redirection(r?`<<-`:`<<`,U.hereDoc(a,U.word([]),r,o),n);return e.addPendingHeredoc(s,a,r,o),s}function Yd(e){let t=e.current().line,n=[],r=null,i=[],a=[];for(;e.check(W.ASSIGNMENT_WORD)||Kd(e);)e.checkIterationLimit(),e.check(W.ASSIGNMENT_WORD)?n.push(Xd(e)):a.push(qd(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(W.DBRACK_START)||e.check(W.DPAREN_START))){let t=e.advance();r=U.word([U.literal(t.value)])}for(;(!e.isStatementEnd()||e.check(W.RBRACE))&&!e.check(W.PIPE,W.PIPE_AMP);)if(e.checkIterationLimit(),Kd(e))a.push(qd(e));else if(e.check(W.RBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(W.LBRACE)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.check(W.DBRACK_END)){let t=e.advance();i.push(e.parseWordFromString(t.value,!1,!1))}else if(e.isWord())i.push(e.parseWord());else if(e.check(W.ASSIGNMENT_WORD)){let t=e.advance(),n=t.value,r=n.endsWith(`=`),a=n.endsWith(`=(`);if((r||a)&&(a||e.check(W.LPAREN))){let t=a?n.slice(0,-2):n.slice(0,-1);a||e.expect(W.LPAREN);let r=Zd(e);e.expect(W.RPAREN);let o=`${t}=(${r.map(t=>Ud(e,t)).join(` `)})`;i.push(e.parseWordFromString(o,!1,!1))}else i.push(e.parseWordFromString(n,t.quoted,t.singleQuoted))}else if(e.check(W.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=U.simpleCommand(r,i,n,a);return o.line=t,o}function Xd(e){let t=e.expect(W.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let i=r[0],a,o=i.length;if(n[o]===`[`){let t=0,r=o+1;for(;o<n.length;o++)if(n[o]===`[`)t++;else if(n[o]===`]`&&(t--,t===0))break;t!==0&&e.error(`Invalid assignment: ${n}`),a=n.slice(r,o),o++}let s=n[o]===`+`;s&&o++,n[o]!==`=`&&e.error(`Invalid assignment: ${n}`),o++;let c=n.slice(o);if(c===`(`){let t=Zd(e);e.expect(W.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return U.assignment(n,null,s,t)}if(c===``&&e.check(W.LPAREN)){let n=e.current();if(t.end===n.start){e.advance();let t=Zd(e);e.expect(W.RPAREN);let n=a===void 0?i:`${i}[${a}]`;return U.assignment(n,null,s,t)}}let l=c?e.parseWordFromString(c,t.quoted,t.singleQuoted,!0):null,u=a===void 0?i:`${i}[${a}]`;return U.assignment(u,l,s,null)}function Zd(e){let t=[];for(e.skipNewlines();!e.check(W.RPAREN,W.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):Qd.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var Qd,$d=g(()=>{ku(),qu(),nd(),Gd(),Qd=new Set([W.AMP,W.PIPE,W.PIPE_AMP,W.SEMICOLON,W.AND_AND,W.OR_OR,W.DSEMI,W.SEMI_AND,W.SEMI_SEMI_AND])});function ef(e,t){e.expect(W.IF);let n=[],r=e.parseCompoundList();e.expect(W.THEN);let i=e.parseCompoundList();if(i.length===0){let t=e.check(W.FI)?`fi`:e.check(W.ELSE)?`else`:e.check(W.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}for(n.push({condition:r,body:i});e.check(W.ELIF);){e.advance();let t=e.parseCompoundList();e.expect(W.THEN);let r=e.parseCompoundList();if(r.length===0){let t=e.check(W.FI)?`fi`:e.check(W.ELSE)?`else`:e.check(W.ELIF)?`elif`:`fi`;e.error(`syntax error near unexpected token \`${t}'`)}n.push({condition:t,body:r})}let a=null;e.check(W.ELSE)&&(e.advance(),a=e.parseCompoundList(),a.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(W.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return U.ifNode(n,a,o)}function tf(e,t){let n=e.expect(W.FOR);if(e.check(W.DPAREN_START))return nf(e,t,n.line);e.isWord()||e.error(`Expected variable name in for loop`);let r=e.advance().value,i=null;if(e.skipNewlines(),e.check(W.IN))for(e.advance(),i=[];!e.check(W.SEMICOLON,W.NEWLINE,W.DO,W.EOF)&&e.isWord();)i.push(e.parseWord());e.check(W.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(W.DO);let a=e.parseCompoundList();e.expect(W.DONE);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return U.forNode(r,i,a,o)}function nf(e,t,n){e.expect(W.DPAREN_START);let r=null,i=null,a=null,o=[``,``,``],s=0,c=0;for(;!e.check(W.DPAREN_END,W.EOF);){let t=e.advance();if(t.type===W.SEMICOLON&&c===0){if(s++,s>2)break}else t.value===`(`&&c++,t.value===`)`&&c--,o[s]+=t.value}e.expect(W.DPAREN_END),o[0].trim()&&(r=ud(e,o[0].trim())),o[1].trim()&&(i=ud(e,o[1].trim())),o[2].trim()&&(a=ud(e,o[2].trim())),e.skipNewlines(),e.check(W.SEMICOLON)&&e.advance(),e.skipNewlines();let l;e.check(W.LBRACE)?(e.advance(),l=e.parseCompoundList(),e.expect(W.RBRACE)):(e.expect(W.DO),l=e.parseCompoundList(),e.expect(W.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:`CStyleFor`,init:r,condition:i,update:a,body:l,redirections:u,line:n}}function rf(e,t){e.expect(W.WHILE);let n=e.parseCompoundList();e.expect(W.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(W.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return U.whileNode(n,r,i)}function af(e,t){e.expect(W.UNTIL);let n=e.parseCompoundList();e.expect(W.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(W.DONE);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return U.untilNode(n,r,i)}function of(e,t){e.expect(W.CASE),e.isWord()||e.error(`Expected word after 'case'`);let n=e.parseWord();e.skipNewlines(),e.expect(W.IN),e.skipNewlines();let r=[];for(;!e.check(W.ESAC,W.EOF);){e.checkIterationLimit();let t=e.getPos(),n=sf(e);if(n&&r.push(n),e.skipNewlines(),e.getPos()===t&&!n)break}e.expect(W.ESAC);let i=t?.skipRedirections?[]:e.parseOptionalRedirections();return U.caseNode(n,r,i)}function sf(e){e.check(W.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(W.PIPE));)e.advance();if(t.length===0)return null;e.expect(W.RPAREN),e.skipNewlines();let n=[];for(;!e.check(W.DSEMI,W.SEMI_AND,W.SEMI_SEMI_AND,W.ESAC,W.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===W.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(W.LPAREN)&&e.peek(1).type===W.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let t=e.getPos(),r=e.parseStatement();if(r&&n.push(r),e.skipSeparators(!1),e.getPos()===t&&!r)break}let r=`;;`;return e.check(W.DSEMI)?(e.advance(),r=`;;`):e.check(W.SEMI_AND)?(e.advance(),r=`;&`):e.check(W.SEMI_SEMI_AND)&&(e.advance(),r=`;;&`),U.caseItem(t,n,r)}function cf(e,t){e.expect(W.LPAREN);let n=e.parseCompoundList();e.expect(W.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return U.subshell(n,r)}function lf(e,t){e.expect(W.LBRACE);let n=e.parseCompoundList();e.expect(W.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return U.group(n,r)}var uf=g(()=>{ku(),jd(),qu()});function df(e){return e.isWord()||e.check(W.LBRACE)||e.check(W.RBRACE)||e.check(W.ASSIGNMENT_WORD)}function ff(e){if(e.check(W.BANG)&&e.peek(1).type===W.LPAREN){e.advance(),e.advance();let t=1,n=`!(`;for(;t>0&&!e.check(W.EOF);)if(e.check(W.LPAREN))t++,n+=`(`,e.advance();else if(e.check(W.RPAREN))t--,t>0&&(n+=`)`),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(W.PIPE))n+=`|`,e.advance();else break;return n+=`)`,e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function pf(e){return e.skipNewlines(),mf(e)}function mf(e){let t=hf(e);for(e.skipNewlines();e.check(W.OR_OR);){e.advance(),e.skipNewlines();let n=hf(e);t={type:`CondOr`,left:t,right:n},e.skipNewlines()}return t}function hf(e){let t=gf(e);for(e.skipNewlines();e.check(W.AND_AND);){e.advance(),e.skipNewlines();let n=gf(e);t={type:`CondAnd`,left:t,right:n},e.skipNewlines()}return t}function gf(e){return e.skipNewlines(),e.check(W.BANG)?(e.advance(),e.skipNewlines(),{type:`CondNot`,operand:gf(e)}):_f(e)}function _f(e){if(e.check(W.LPAREN)){e.advance();let t=pf(e);return e.expect(W.RPAREN),{type:`CondGroup`,expression:t}}if(df(e)){let t=e.current(),n=t.value;if(yf.includes(n)&&!t.quoted){if(e.advance(),e.check(W.DBRACK_END)&&e.error(`Expected operand after ${n}`),df(e))return{type:`CondUnary`,operator:n,operand:e.parseWordNoBraceExpansion()};let t=e.current();e.error(`unexpected argument \`${t.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&bf.includes(e.current().value)){let t=e.advance().value,n;return n=t===`=~`?vf(e):t===`==`||t===`!=`?ff(e):e.parseWordNoBraceExpansion(),{type:`CondBinary`,operator:t,left:r,right:n}}return e.check(W.LESS)?(e.advance(),{type:`CondBinary`,operator:`<`,left:r,right:e.parseWordNoBraceExpansion()}):e.check(W.GREAT)?(e.advance(),{type:`CondBinary`,operator:`>`,left:r,right:e.parseWordNoBraceExpansion()}):e.isWord()&&e.current().value===`=`?(e.advance(),{type:`CondBinary`,operator:`==`,left:r,right:ff(e)}):{type:`CondWord`,word:r}}e.error(`Expected conditional expression`)}function vf(e){let t=[],n=0,r=-1,i=e.getInput(),a=()=>e.check(W.DBRACK_END)||e.check(W.AND_AND)||e.check(W.OR_OR)||e.check(W.NEWLINE)||e.check(W.EOF);for(;!a();){let a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let e=i.slice(r,a.start);t.push({type:`Literal`,value:e})}if(e.isWord()||e.check(W.ASSIGNMENT_WORD)){let n=e.parseWordForRegex();t.push(...n.parts),r=e.peek(-1).end}else if(e.check(W.LPAREN)){let i=e.advance();t.push({type:`Literal`,value:`(`}),n++,r=i.end}else if(e.check(W.DPAREN_START)){let i=e.advance();t.push({type:`Literal`,value:`((`}),n+=2,r=i.end}else if(e.check(W.DPAREN_END))if(n>=2){let i=e.advance();t.push({type:`Literal`,value:`))`}),n-=2,r=i.end}else{if(n===1)break;break}else if(e.check(W.RPAREN))if(n>0){let i=e.advance();t.push({type:`Literal`,value:`)`}),n--,r=i.end}else break;else if(e.check(W.PIPE)){let n=e.advance();t.push({type:`Literal`,value:`|`}),r=n.end}else if(e.check(W.SEMICOLON))if(n>0){let n=e.advance();t.push({type:`Literal`,value:`;`}),r=n.end}else break;else if(n>0&&e.check(W.LESS)){let n=e.advance();t.push({type:`Literal`,value:`<`}),r=n.end}else if(n>0&&e.check(W.GREAT)){let n=e.advance();t.push({type:`Literal`,value:`>`}),r=n.end}else if(n>0&&e.check(W.DGREAT)){let n=e.advance();t.push({type:`Literal`,value:`>>`}),r=n.end}else if(n>0&&e.check(W.DLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<`}),r=n.end}else if(n>0&&e.check(W.LESSAND)){let n=e.advance();t.push({type:`Literal`,value:`<&`}),r=n.end}else if(n>0&&e.check(W.GREATAND)){let n=e.advance();t.push({type:`Literal`,value:`>&`}),r=n.end}else if(n>0&&e.check(W.LESSGREAT)){let n=e.advance();t.push({type:`Literal`,value:`<>`}),r=n.end}else if(n>0&&e.check(W.CLOBBER)){let n=e.advance();t.push({type:`Literal`,value:`>|`}),r=n.end}else if(n>0&&e.check(W.TLESS)){let n=e.advance();t.push({type:`Literal`,value:`<<<`}),r=n.end}else if(n>0&&e.check(W.AMP)){let n=e.advance();t.push({type:`Literal`,value:`&`}),r=n.end}else if(n>0&&e.check(W.LBRACE)){let n=e.advance();t.push({type:`Literal`,value:`{`}),r=n.end}else if(n>0&&e.check(W.RBRACE)){let n=e.advance();t.push({type:`Literal`,value:`}`}),r=n.end}else break}return t.length===0&&e.error(`Expected regex pattern after =~`),{type:`Word`,parts:t}}var yf,bf,xf=g(()=>{qu(),yf=`-a.-b.-c.-d.-e.-f.-g.-h.-k.-p.-r.-s.-t.-u.-w.-x.-G.-L.-N.-O.-S.-z.-n.-o.-v.-R`.split(`.`),bf=[`==`,`!=`,`=~`,`<`,`>`,`-eq`,`-ne`,`-lt`,`-le`,`-gt`,`-ge`,`-nt`,`-ot`,`-ef`]});function Sf(e){return e.length>0?e:[U.literal(``)]}function Cf(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(`@*+?!`.includes(t)&&r+1<e.length&&e[r+1]===`(`){r++,n++,r++;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function wf(e,t,n){let r=n+1,i=t[r];if(`@*#?$!-0123456789`.includes(i))return{part:U.parameterExpansion(i),endIndex:r+1};let a=``;for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)a+=t[r],r++;return{part:U.parameterExpansion(a),endIndex:r}}function Tf(e,t,n,r=!1){let i=n+2,a=!1;t[i]===`!`&&(a=!0,i++);let o=!1;t[i]===`#`&&!/[}:#%/^,]/.test(t[i+1]||`}`)&&(o=!0,i++);let s=``,c=t[i];if(/[@*#?$!-]/.test(c)&&!/[a-zA-Z0-9_]/.test(t[i+1]||``))s=c,i++;else for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)s+=t[i],i++;if(t[i]===`[`){let r=Pd(e,t,i,`[`,`]`);if(s+=t.slice(i,r+1),i=r+1,t[i]===`[`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;let a=t.slice(n+2,r);return{part:U.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}}if(s===``&&!a&&!o&&t[i]!==`}`){let e=1,r=i;for(;r<t.length&&e>0;)t[r]===`{`?e++:t[r]===`}`&&e--,e>0&&r++;if(e>0)throw new td(`unexpected EOF while looking for matching '}'`,0,0);let a=t.slice(n+2,r);return{part:U.parameterExpansion(``,{type:`BadSubstitution`,text:a}),endIndex:r+1}}let l=null;if(a){let n=s.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n)if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let a=Ef(e,t,i,s,r);a.operation?(l={type:`Indirection`,innerOp:a.operation},i=a.endIndex):(l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``)}else l={type:`ArrayKeys`,array:n[1],star:n[2]===`*`},s=``;else if(t[i]===`*`||t[i]===`@`&&!/[QPaAEKkuUL]/.test(t[i+1]||``)){let e=t[i];i++,l={type:`VarNamePrefix`,prefix:s,star:e===`*`},s=``}else if(i<t.length&&t[i]!==`}`&&/[:=\-+?#%/^,@]/.test(t[i])){let n=Ef(e,t,i,s,r);n.operation?(l={type:`Indirection`,innerOp:n.operation},i=n.endIndex):l={type:`Indirection`}}else l={type:`Indirection`}}else if(o)if(t[i]===`:`)for(l={type:`LengthSliceError`};i<t.length&&t[i]!==`}`;)i++;else t[i]!==`}`&&/[-+=?]/.test(t[i])||t[i]===`/`?e.error(`\${#${s}${t.slice(i,t.indexOf(`}`,i))}}: bad substitution`):l={type:`Length`};if(!l&&i<t.length&&t[i]!==`}`){let n=Ef(e,t,i,s,r);l=n.operation,i=n.endIndex}if(i<t.length&&t[i]!==`}`){let r=t[i];if(!/[:\-+=?#%/^,@[]/.test(r)){let r=i;for(;r<t.length&&t[r]!==`}`;)r++;let a=t.slice(n,r+1);e.error(`\${${a.slice(2,-1)}}: bad substitution`)}}for(;i<t.length&&t[i]!==`}`;)i++;if(i>=t.length)throw new td(`unexpected EOF while looking for matching '}'`,0,0);return{part:U.parameterExpansion(s,l),endIndex:i+1}}function Ef(e,t,n,r,i=!1){let a=n,o=t[a],s=t[a+1]||``;if(o===`:`){let n=s;if(`-=?+`.includes(n)){a+=2;let r=Fd(e,t,a),o=Af(e,t.slice(a,r),!1,!1,!0,!1,i,!1,!1,!0),s=U.word(Sf(o));if(n===`-`)return{operation:{type:`DefaultValue`,word:s,checkEmpty:!0},endIndex:r};if(n===`=`)return{operation:{type:`AssignDefault`,word:s,checkEmpty:!0},endIndex:r};if(n===`?`)return{operation:{type:`ErrorIfUnset`,word:s,checkEmpty:!0},endIndex:r};if(n===`+`)return{operation:{type:`UseAlternative`,word:s,checkEmpty:!0},endIndex:r}}a++;let r=Fd(e,t,a),o=t.slice(a,r),c=-1,l=0,u=0;for(let e=0;e<o.length;e++){let t=o[e];if(t===`(`||t===`[`)l++;else if(t===`)`||t===`]`)l--;else if(t===`?`&&l===0)u++;else if(t===`:`&&l===0)if(u>0)u--;else{c=e;break}}let d=c>=0?o.slice(0,c):o,f=c>=0?o.slice(c+1):null;return{operation:{type:`Substring`,offset:Bd(e,d),length:f===null?null:Bd(e,f)},endIndex:r}}if(`-=?+`.includes(o)){a++;let n=Fd(e,t,a),r=t.slice(a,n),s=Af(e,r,!1,!1,!0,!1,i,!1,!1,!0),c=U.word(Sf(s));if(o===`-`)return{operation:{type:`DefaultValue`,word:c,checkEmpty:!1},endIndex:n};if(o===`=`)return{operation:{type:`AssignDefault`,word:c,checkEmpty:!1},endIndex:n};if(o===`?`)return{operation:{type:`ErrorIfUnset`,word:r?c:null,checkEmpty:!1},endIndex:n};if(o===`+`)return{operation:{type:`UseAlternative`,word:c,checkEmpty:!1},endIndex:n}}if(o===`#`||o===`%`){let n=s===o,r=o===`#`?`prefix`:`suffix`;a+=n?2:1;let i=Fd(e,t,a),c=Af(e,t.slice(a,i),!1,!1,!1);return{operation:{type:`PatternRemoval`,pattern:U.word(Sf(c)),side:r,greedy:n},endIndex:i}}if(o===`/`){let n=s===`/`;a+=n?2:1;let r=null;t[a]===`#`?(r=`start`,a++):t[a]===`%`&&(r=`end`,a++);let i;i=r!==null&&(t[a]===`/`||t[a]===`}`)?a:Id(e,t,a);let o=Af(e,t.slice(a,i),!1,!1,!1),c=U.word(Sf(o)),l=null,u=i;if(t[i]===`/`){let n=i+1,r=Fd(e,t,n),a=Af(e,t.slice(n,r),!1,!1,!1);l=U.word(Sf(a)),u=r}return{operation:{type:`PatternReplacement`,pattern:c,replacement:l,all:n,anchor:r},endIndex:u}}if(o===`^`||o===`,`){let n=s===o,r=o===`^`?`upper`:`lower`;a+=n?2:1;let i=Fd(e,t,a),c=t.slice(a,i);return{operation:{type:`CaseModification`,direction:r,all:n,pattern:c?U.word([U.literal(c)]):null},endIndex:i}}return o===`@`&&/[QPaAEKkuUL]/.test(s)?{operation:{type:`Transform`,operator:s},endIndex:a+2}:{operation:null,endIndex:a}}function Df(e,t,n,r=!1){let i=n+1;if(i>=t.length)return{part:U.literal(`$`),endIndex:i};let a=t[i];if(a===`(`&&t[i+1]===`(`)return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(a===`[`){let n=1,r=i+1;for(;r<t.length&&n>0;)t[r]===`[`?n++:t[r]===`]`&&n--,n>0&&r++;if(n===0){let n=ud(e,t.slice(i+1,r));return{part:U.arithmeticExpansion(n),endIndex:r+1}}}return a===`(`?e.parseCommandSubstitution(t,n):a===`{`?Tf(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(a)?wf(e,t,n):{part:U.literal(`$`),endIndex:i}}function Of(e,t){let n=[],r=0,i=``,a=()=>{i&&=(n.push(U.literal(i)),``)};for(;r<t.length;){let o=t[r];if(o===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`"`||e===`\\`){i+=e,r+=2;continue}i+=o,r++;continue}if(o===`$`){a();let{part:i,endIndex:o}=Df(e,t,r,!0);i&&n.push(i),r=o;continue}if(o==="`"){a();let{part:i,endIndex:o}=e.parseBacktickSubstitution(t,r,!0);n.push(i),r=o;continue}i+=o,r++}return a(),n}function kf(e,t,n){let r=[],i=n,a=``,o=()=>{a&&=(r.push(U.literal(a)),``)};for(;i<t.length&&t[i]!==`"`;){let n=t[i];if(n===`\\`&&i+1<t.length){let e=t[i+1];if(`"\\$\`
201
+ `.includes(e)){a+=e,i+=2;continue}a+=n,i++;continue}if(n===`$`){o();let{part:n,endIndex:a}=Df(e,t,i,!0);n&&r.push(n),i=a;continue}if(n==="`"){o();let{part:n,endIndex:a}=e.parseBacktickSubstitution(t,i,!0);r.push(n),i=a;continue}a+=n,i++}return o(),{part:U.doubleQuoted(r),endIndex:i}}function Af(e,t,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1,c=!1,l=!1){if(r)return[U.singleQuoted(t)];if(n){let n=Of(e,t);return[U.doubleQuoted(n)]}if(t.length>=2&&t[0]===`"`&&t[t.length-1]===`"`){let n=t.slice(1,-1),r=!1;for(let e=0;e<n.length;e++){if(n[e]===`"`){r=!0;break}n[e]===`\\`&&e+1<n.length&&e++}if(!r){let t=Of(e,n);return[U.doubleQuoted(t)]}}let u=[],d=0,f=``,p=()=>{f&&=(u.push(U.literal(f)),``)};for(;d<t.length;){let n=t[d];if(n===`\\`&&d+1<t.length){let e=t[d+1];if(c){p(),u.push(U.escaped(e)),d+=2;continue}let n=a?e===`$`||e==="`"||e===`
195
202
  `:e===`$`||e==="`"||e===`"`||e===`'`||e===`
196
- `||l&&e===`}`,r=o?`*?[]\\`.includes(e):`*?[]\\(){}.^+`.includes(e);n?f+=e:r?(p(),u.push(W.escaped(e))):f+=`\\${e}`,d+=2;continue}if(n===`'`&&!o&&!a){p();let e=t.indexOf(`'`,d+1);if(e===-1){f+=t.slice(d);break}u.push(W.singleQuoted(t.slice(d+1,e))),d=e+1;continue}if(n===`"`&&!a){p();let{part:n,endIndex:r}=Sf(e,t,d+1);u.push(n),d=r+1;continue}if(n===`$`&&t[d+1]===`'`){p();let{part:n,endIndex:r}=Md(e,t,d+2);u.push(n),d=r;continue}if(n===`$`){p();let{part:n,endIndex:r}=bf(e,t,d);n&&u.push(n),d=r;continue}if(n==="`"){p();let{part:n,endIndex:r}=e.parseBacktickSubstitution(t,d);u.push(n),d=r;continue}if(n===`~`){let n=d>0?t[d-1]:``;if(d===0||n===`=`||i&&n===`:`){let n=Ed(e,t,d),r=t[n];if(r===void 0||r===`/`||r===`:`){p();let e=t.slice(d+1,n)||null;u.push({type:`TildeExpansion`,user:e}),d=n;continue}}}if(`@*+?!`.includes(n)&&d+1<t.length&&t[d+1]===`(`){let e=gf(t,d+1);if(e!==-1){p();let n=t.slice(d,e+1);u.push({type:`Glob`,pattern:n}),d=e+1;continue}}if(n===`*`||n===`?`||n===`[`){p();let{pattern:n,endIndex:r}=Ad(e,t,d);u.push({type:`Glob`,pattern:n}),d=r;continue}if(n===`{`&&!i&&!s&&!a){let n=Fd(e,t,d,Cf);if(n){p(),u.push(n.part),d=n.endIndex;continue}}f+=n,d++}return p(),u}var wf=g(()=>{Yu(),wd(),Ju(),Rd()});function Tf(e,t){let n=e.length,r=t+3,i=2,a=!1,o=!1;for(;r<n&&i>0;){let t=e[r];if(a){t===`'`&&(a=!1),r++;continue}if(o){if(t===`\\`){r+=2;continue}t===`"`&&(o=!1),r++;continue}if(t===`'`){a=!0,r++;continue}if(t===`"`){o=!0,r++;continue}if(t===`\\`){r+=2;continue}if(t===`(`){i++,r++;continue}if(t===`)`){if(i--,i===1){let t=r+1;return!(t<n&&e[t]===`)`)}if(i===0)return!1;r++;continue}if(i===1&&(t===`|`&&r+1<n&&e[r+1]===`|`||t===`&`&&r+1<n&&e[r+1]===`&`||t===`|`&&r+1<n&&e[r+1]!==`|`))return!0;r++}return!1}function Ef(e,t,n,r){let i=t+2,a=1,o=i,s=!1,c=!1,l=0,u=!1,d=``;for(;o<e.length&&a>0;){let t=e[o];s?t===`'`&&(s=!1):c?t===`\\`&&o+1<e.length?o++:t===`"`&&(c=!1):t===`'`?(s=!0,d=``):t===`"`?(c=!0,d=``):t===`\\`&&o+1<e.length?(o++,d=``):/[a-zA-Z_]/.test(t)?d+=t:(d===`case`?(l++,u=!1):d===`in`&&l>0?u=!0:d===`esac`&&l>0&&(l--,u=!1),d=``,t===`(`?o>0&&e[o-1]===`$`?a++:u||a++:t===`)`?u?u=!1:a--:t===`;`&&l>0&&o+1<e.length&&e[o+1]===`;`&&(u=!0)),a>0&&o++}a>0&&r("unexpected EOF while looking for matching `)'");let f=e.slice(i,o),p=n().parse(f);return{part:W.commandSubstitution(p,!1),endIndex:o+1}}function Df(e,t,n,r,i){let a=t+1,o=``;for(;a<e.length&&e[a]!=="`";)if(e[a]===`\\`){let t=e[a+1];t===`$`||t==="`"||t===`\\`||t===`
197
- `||n&&t===`"`?(t!==`
198
- `&&(o+=t),a+=2):(o+=e[a],a++)}else o+=e[a],a++;a>=e.length&&i("unexpected EOF while looking for matching ``'");let s=r().parse(o);return{part:W.commandSubstitution(s,!0),endIndex:a+1}}var Of=g(()=>{Yu()}),kf,K=g(()=>{Yu(),wd(),Kd(),nf(),mf(),wf(),zu(),Of(),Ju(),Ju(),kf=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input=``;getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Hu)throw new qu(`Maximum parse iterations exceeded (possible infinite loop)`,this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Uu)throw new qu(`Maximum parser nesting depth exceeded (${Uu})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(e,t){if(e.length>Bu)throw new qu(`Input too large: ${e.length} bytes exceeds limit of ${Bu}`,1,1);this._input=e;let n=new Ru(e,t);if(this.tokens=n.tokenize(),this.tokens.length>Vu)throw new qu(`Too many tokens: ${this.tokens.length} exceeds limit of ${Vu}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,t,n,r,...i){let a=this.tokens[this.pos]?.type;return a===e||t!==void 0&&a===t||n!==void 0&&a===n||r!==void 0&&a===r?!0:i.length>0?i.includes(a):!1}expect(e,t){if(this.check(e))return this.advance();let n=this.current();throw new qu(t||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let t=this.current();throw new qu(e,t.line,t.column,t)}skipNewlines(){for(;this.check(U.NEWLINE,U.COMMENT);)this.check(U.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(U.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(U.SEMICOLON,U.COMMENT)){this.advance();continue}if(e&&this.check(U.DSEMI,U.SEMI_AND,U.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,t,n,r){this.pendingHeredocs.push({redirect:e,delimiter:t,stripTabs:n,quoted:r})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(U.HEREDOC_CONTENT)){let t=this.advance(),n;n=e.quoted?W.word([W.literal(t.value)]):this.parseWordFromString(t.value,!1,!1,!1,!0),e.redirect.target=W.hereDoc(e.delimiter,n,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(U.EOF,U.NEWLINE,U.SEMICOLON,U.AMP,U.AND_AND,U.OR_OR,U.RPAREN,U.RBRACE,U.DSEMI,U.SEMI_AND,U.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===U.WORD||e===U.NAME||e===U.NUMBER||e===U.ASSIGNMENT_WORD||e===U.IF||e===U.FOR||e===U.WHILE||e===U.UNTIL||e===U.CASE||e===U.LPAREN||e===U.LBRACE||e===U.DPAREN_START||e===U.DBRACK_START||e===U.FUNCTION||e===U.BANG||e===U.TIME||e===U.IN||e===U.LESS||e===U.GREAT||e===U.DLESS||e===U.DGREAT||e===U.LESSAND||e===U.GREATAND||e===U.LESSGREAT||e===U.DLESSDASH||e===U.CLOBBER||e===U.TLESS||e===U.AND_GREAT||e===U.AND_DGREAT}parseScript(){let e=[],t=0;for(this.skipNewlines();!this.check(U.EOF);){t++,t>1e4&&this.error(`Parser stuck: too many iterations (>10000)`);let n=this.checkUnexpectedToken();if(n){e.push(n),this.skipSeparators(!1);continue}let r=this.pos,i=this.parseStatement();i&&e.push(i),this.skipSeparators(!1),this.check(U.DSEMI,U.SEMI_AND,U.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===r&&!this.check(U.EOF)&&this.advance()}return W.script(e)}checkUnexpectedToken(){let e=this.current().type,t=this.current().value;if((e===U.DO||e===U.DONE||e===U.THEN||e===U.ELSE||e===U.ELIF||e===U.FI||e===U.ESAC)&&this.error(`syntax error near unexpected token \`${t}'`),e===U.RBRACE||e===U.RPAREN){let e=`syntax error near unexpected token \`${t}'`;return this.advance(),W.statement([W.pipeline([W.simpleCommand(null,[],[],[])])],[],!1,{message:e,token:t})}return(e===U.DSEMI||e===U.SEMI_AND||e===U.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${t}'`),e===U.SEMICOLON&&this.error(`syntax error near unexpected token \`${t}'`),(e===U.PIPE||e===U.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${t}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,t=[],n=[],r=!1,i=this.parsePipeline();for(t.push(i);this.check(U.AND_AND,U.OR_OR);){let e=this.advance();n.push(e.type===U.AND_AND?`&&`:`||`),this.skipNewlines();let r=this.parsePipeline();t.push(r)}this.check(U.AMP)&&(this.advance(),r=!0);let a=this.pos>0?this.tokens[this.pos-1].end:e,o=this._input.slice(e,a);return W.statement(t,n,r,void 0,o)}parsePipeline(){let e=!1,t=!1;this.check(U.TIME)&&(this.advance(),e=!0,this.check(U.WORD,U.NAME)&&this.current().value===`-p`&&(this.advance(),t=!0));let n=0;for(;this.check(U.BANG);)this.advance(),n++;let r=n%2==1,i=[],a=[],o=this.parseCommand();for(i.push(o);this.check(U.PIPE,U.PIPE_AMP);){let e=this.advance();this.skipNewlines(),a.push(e.type===U.PIPE_AMP);let t=this.parseCommand();i.push(t)}return W.pipeline(i,r,e,t,a.length>0?a:void 0)}parseCommand(){return this.check(U.IF)?qd(this):this.check(U.FOR)?Jd(this):this.check(U.WHILE)?Xd(this):this.check(U.UNTIL)?Zd(this):this.check(U.CASE)?Qd(this):this.check(U.LPAREN)?ef(this):this.check(U.LBRACE)?tf(this):this.check(U.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(U.DBRACK_START)?this.parseConditionalCommand():this.check(U.FUNCTION)||this.check(U.NAME,U.WORD)&&this.peek(1).type===U.LPAREN&&this.peek(2).type===U.RPAREN?this.parseFunctionDef():Hd(this)}dparenClosesWithSpacedParens(){let e=1,t=1;for(;t<this.tokens.length-this.pos;){let n=this.peek(t);if(n.type===U.EOF)return!1;if(n.type===U.DPAREN_START||n.type===U.LPAREN)e++;else if(n.type===U.DPAREN_END){if(e-=2,e<=0)return!1}else if(n.type===U.RPAREN&&(e--,e===0&&this.peek(t+1).type===U.RPAREN))return!0;t++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(U.RPAREN),this.expect(U.RPAREN);let t=this.parseOptionalRedirections(),n=W.subshell(e,[]);return W.subshell([W.statement([W.pipeline([n],!1,!1,!1)])],t)}isWord(){let e=this.current().type;return e===U.WORD||e===U.NAME||e===U.NUMBER||e===U.IF||e===U.FOR||e===U.WHILE||e===U.UNTIL||e===U.CASE||e===U.FUNCTION||e===U.ELSE||e===U.ELIF||e===U.FI||e===U.THEN||e===U.DO||e===U.DONE||e===U.ESAC||e===U.IN||e===U.SELECT||e===U.TIME||e===U.COPROC||e===U.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordNoBraceExpansion(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0)}parseWordForRegex(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0,!0)}parseWordFromString(e,t=!1,n=!1,r=!1,i=!1,a=!1,o=!1){let s=Cf(this,e,t,n,r,i,!1,a,o);return W.word(s)}parseCommandSubstitution(t,n){return Ef(t,n,()=>new e,e=>this.error(e))}parseBacktickSubstitution(t,n,r=!1){return Df(t,n,r,()=>new e,e=>this.error(e))}isDollarDparenSubshell(e,t){return Tf(e,t)}parseArithmeticExpansion(e,t){let n=t+3,r=1,i=0,a=n;for(;a<e.length-1&&r>0;)e[a]===`$`&&e[a+1]===`(`?e[a+2]===`(`?(r++,a+=3):(i++,a+=2):e[a]===`(`&&e[a+1]===`(`?(r++,a+=2):e[a]===`)`&&e[a+1]===`)`?i>0?(i--,a++):(r--,r>0&&(a+=2)):e[a]===`(`?(i++,a++):(e[a]===`)`&&i>0&&i--,a++);let o=e.slice(n,a),s=this.parseArithmeticExpression(o);return{part:W.arithmeticExpansion(s),endIndex:a+2}}parseArithmeticCommand(){let e=this.expect(U.DPAREN_START),t=``,n=1,r=0,i=!1,a=!1;for(;n>0&&!this.check(U.EOF);){if(i){if(i=!1,r>0){r--,t+=`)`;continue}if(this.check(U.RPAREN)){n--,a=!0,this.advance();continue}if(this.check(U.DPAREN_END)){n--,a=!0;continue}t+=`)`;continue}if(this.check(U.DPAREN_START))n++,t+=`((`,this.advance();else if(this.check(U.DPAREN_END))r>=2?(r-=2,t+=`))`,this.advance()):r===1?(r--,t+=`)`,i=!0,this.advance()):(n--,a=!0,n>0&&(t+=`))`),this.advance());else if(this.check(U.LPAREN))r++,t+=`(`,this.advance();else if(this.check(U.RPAREN))r>0&&r--,t+=`)`,this.advance();else{let e=this.current().value,n=t.length>0?t[t.length-1]:``;t.length>0&&!t.endsWith(` `)&&!(e===`=`&&/[|&^+\-*/%<>]$/.test(t))&&!(e===`<`&&n===`<`)&&!(e===`>`&&n===`>`)&&(t+=` `),t+=e,this.advance()}}a||this.expect(U.DPAREN_END);let o=this.parseArithmeticExpression(t.trim()),s=this.parseOptionalRedirections();return W.arithmeticCommand(o,s,e.line)}parseConditionalCommand(){let e=this.expect(U.DBRACK_START),t=of(this);this.expect(U.DBRACK_END);let n=this.parseOptionalRedirections();return W.conditionalCommand(t,n,e.line)}parseFunctionDef(){let e;if(this.check(U.FUNCTION)){if(this.advance(),this.check(U.NAME)||this.check(U.WORD))e=this.advance().value;else{let e=this.current();throw new qu(`Expected function name`,e.line,e.column,e)}this.check(U.LPAREN)&&(this.advance(),this.expect(U.RPAREN))}else e=this.advance().value,e.includes(`$`)&&this.error(`\`${e}': not a valid identifier`),this.expect(U.LPAREN),this.expect(U.RPAREN);this.skipNewlines();let t=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return W.functionDef(e,t,n)}parseCompoundCommandBody(e){let t=e?.forFunctionBody;if(this.check(U.LBRACE))return tf(this,{skipRedirections:t});if(this.check(U.LPAREN))return ef(this,{skipRedirections:t});if(this.check(U.IF))return qd(this,{skipRedirections:t});if(this.check(U.FOR))return Jd(this,{skipRedirections:t});if(this.check(U.WHILE))return Xd(this,{skipRedirections:t});if(this.check(U.UNTIL))return Zd(this,{skipRedirections:t});if(this.check(U.CASE))return Qd(this,{skipRedirections:t});this.error(`Expected compound command for function body`)}parseCompoundList(){let e=this.enterDepth(),t=[];for(this.skipNewlines();!this.check(U.EOF,U.FI,U.ELSE,U.ELIF,U.THEN,U.DO,U.DONE,U.ESAC,U.RPAREN,U.RBRACE,U.DSEMI,U.SEMI_AND,U.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let e=this.pos,n=this.parseStatement();if(n&&t.push(n),this.skipSeparators(),this.pos===e&&!n)break}return e(),t}parseOptionalRedirections(){let e=[];for(;zd(this);){this.checkIterationLimit();let t=this.pos;if(e.push(Bd(this)),this.pos===t)break}return e}parseArithmeticExpression(e){return rd(this,e)}}});function Af(e){return Ff.get(e)??``}function jf(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`[`){for(n+=i,r++,r<e.length&&(e[r]===`!`||e[r]===`^`)&&(n+=e[r],r++),r<e.length&&e[r]===`]`&&(n+=e[r],r++);r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){n+=e.slice(r,t+2),r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]===`]`&&(n+=e[r],r++)}else i===`:`?(n!==``&&t.push(n),n=``,r++):i===`\\`&&r+1<e.length?(n+=i+e[r+1],r+=2):(n+=i,r++)}return n!==``&&t.push(n),t}function Mf(e){let t=`^`;for(let n=0;n<e.length;n++){let r=e[n];if(r===`*`)t+=`[^/]*`;else if(r===`?`)t+=`[^/]`;else if(r===`[`){let r=n+1,i=`[`;r<e.length&&(e[r]===`^`||e[r]===`!`)&&(i+=`^`,r++),r<e.length&&e[r]===`]`&&(i+=`\\]`,r++);let a=r;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=r;for(;r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){let n=Af(e.slice(r+2,t));i+=n,r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){i+=`\\${e[r+1]}`,r+=2;continue}if(e[r]===`-`){let e=r===o,t=r+1===a;e||t?i+=`\\-`:i+=`-`}else i+=e[r];r++}i+=`]`,t+=i,n=r}else if(r===`\\`&&n+1<e.length){let r=e[n+1];/[.+^${}()|\\*?[\]]/.test(r)?t+=`\\${r}`:t+=r,n++}else /[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+=`$`,M(t)}function Nf(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Pf(e){let t=[],n=``,r=0,i=!1,a=0;for(;a<e.length;){let o=e[a];if(o===`'`&&!i){i=!0,n+=`\0QUOTE_START\0`,a++;continue}if(o===`'`&&i){i=!1,n+=`\0QUOTE_END\0`,a++;continue}if(i){n+=o,a++;continue}if(o===`\\`){n+=o,a+1<e.length?(n+=e[a+1],a+=2):a++;continue}o===`(`?(r++,n+=o):o===`)`?(r--,n+=o):o===`|`&&r===0?(t.push(n),n=``):n+=o,a++}return t.push(n),t}var Ff,If=g(()=>{ta(),Ff=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9a-fA-F`]])}),Lf,Rf,zf=g(()=>{x(),ta(),tr(),If(),Lf=5,Rf=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(e,t,n,r){this.fs=e,this.cwd=t,typeof r==`boolean`?(this.globstar=r,this.maxOps=1e5):r?(this.globstar=r.globstar??!1,this.nullglob=r.nullglob??!1,this.failglob=r.failglob??!1,this.dotglob=r.dotglob??!1,this.extglob=r.extglob??!1,this.globskipdots=r.globskipdots??!0,this.maxOps=r.maxGlobOperations??1e5):this.maxOps=1e5;let i=n?.get(`GLOBIGNORE`);i!==void 0&&i!==``&&(this.hasGlobignore=!0,this.globignorePatterns=jf(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new b(`Glob operation limit exceeded (${this.maxOps})`,`glob_operations`)}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(e=>{let t=e.split(`/`).pop()||e;if((this.hasGlobignore||this.globskipdots)&&(t===`.`||t===`..`))return!1;if(this.hasGlobignore){for(let t of this.globignorePatterns)if(this.matchGlobignorePattern(e,t))return!1}return!0})}matchGlobignorePattern(e,t){return Mf(t).test(e)}isGlobPattern(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,t){let n=e.map((e,n)=>(t?.[n]??!1)||!this.isGlobPattern(e)?null:this.expand(e)),r=await Promise.all(n.map(e=>e||Promise.resolve(null))),i=[];for(let t=0;t<e.length;t++){let n=r[t];n===null?i.push(e[t]):n.length>0?i.push(...n):i.push(e[t])}return i}async expand(e){if(this.globstar){let t=e.split(`/`),n=0;for(let e of t)if(e===`**`&&(n++,n>Lf))throw new b(`Glob pattern has too many ** segments (max ${Lf})`,`glob_operations`)}let t;if(e.includes(`**`)&&this.globstar&&this.isGlobstarValid(e))t=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,`*`);t=await this.expandSimple(n)}return this.filterGlobignore(t)}isGlobstarValid(e){let t=e.split(`/`);for(let e of t)if(e.includes(`**`)&&e!==`**`)return!1;return!0}hasGlobChars(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e!==``),r=-1;for(let e=0;e<n.length;e++)if(this.hasGlobChars(n[e])){r=e;break}if(r===-1)return[e];let i,a;if(r===0)t?(i=`/`,a=`/`):(i=this.cwd,a=``);else{let e=n.slice(0,r);t?(i=`/${e.join(`/`)}`,a=`/${e.join(`/`)}`):(i=this.fs.resolvePath(this.cwd,e.join(`/`)),a=e.join(`/`))}let o=n.slice(r);return(await this.expandSegments(i,a,o)).sort()}async expandSegments(e,t,n){if(this.checkOpsLimit(),n.length===0)return[t];let[r,...i]=n,a=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let n=await this.fs.readdirWithFileTypes(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;if(r.startsWith(`.`)||this.dotglob){let e=n.some(e=>e.name===`.`),t=n.some(e=>e.name===`..`);e||s.push({name:`.`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}),t||s.push({name:`..`,isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let n of s)if(!(n.name.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n.name,r)){let r=e===`/`?`/${n.name}`:`${e}/${n.name}`,a;a=t===``?n.name:t===`/`?`/${n.name}`:`${t}/${n.name}`,i.length===0?o.push(Promise.resolve([a])):n.isDirectory&&o.push(this.expandSegments(r,a,i))}let l=await Promise.all(o);for(let e of l)a.push(...e)}else{this.checkOpsLimit();let n=await this.fs.readdir(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;(r.startsWith(`.`)||this.dotglob)&&(n.includes(`.`)||s.push(`.`),n.includes(`..`)||s.push(`..`));for(let n of s)if(!(n.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n,r)){let r=e===`/`?`/${n}`:`${e}/${n}`,a;a=t===``?n:t===`/`?`/${n}`:`${t}/${n}`,i.length===0?o.push(Promise.resolve([a])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory)return this.expandSegments(r,a,i)}catch(e){if(e instanceof b)throw e}return[]})())}let l=await Promise.all(o);for(let e of l)a.push(...e)}}catch(e){if(e instanceof b)throw e}return a}async expandRecursive(e){let t=[],n=e.indexOf(`**`),r=e.slice(0,n).replace(/\/$/,``)||`.`,i=e.slice(n+2).replace(/^\//,``);return i.includes(`**`)&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(r,i,t),[...new Set(t)].sort()):(await this.walkDirectory(r,i,t),t.sort())}async walkDirectoryMultiGlobstar(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(r):null;if(i){let r=[];for(let t of i){let n=e===`.`?t.name:`${e}/${t.name}`;t.isDirectory&&r.push(n)}let a=e===`.`?t:`${e}/${t}`,o=await this.expandRecursive(a);n.push(...o);for(let e=0;e<r.length;e+=100){let i=r.slice(e,e+100);await Promise.all(i.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t of i){let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory&&a.push(n)}catch(e){if(e instanceof b)throw e}}let o=e===`.`?t:`${e}/${t}`,s=await this.expandRecursive(o);n.push(...s);for(let e=0;e<a.length;e+=100){let r=a.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}}catch(e){if(e instanceof b)throw e}}async walkDirectory(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(r),a=[],o=[];for(let n of i){let r=e===`.`?n.name:`${e}/${n.name}`;n.isDirectory?o.push(r):t&&this.matchPattern(n.name,t)&&a.push(r)}n.push(...a);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t=0;t<i.length;t+=100){let n=i.slice(t,t+100),r=await Promise.all(n.map(async t=>{let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{return this.checkOpsLimit(),{name:t,path:n,isDirectory:(await this.fs.stat(r)).isDirectory}}catch(e){if(e instanceof b)throw e;return null}}));a.push(...r.filter(e=>e!==null))}for(let e of a)!e.isDirectory&&t&&this.matchPattern(e.name,t)&&n.push(e.path);let o=a.filter(e=>e.isDirectory);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e.path,t,n)))}}}catch(e){if(e instanceof b)throw e}}matchPattern(e,t){return this.patternToRegex(t).test(e)}patternToRegex(e){return M(`^${this.patternToRegexStr(e)}$`)}patternToRegexStr(e){let t=``,n=!1;for(let r=0;r<e.length;r++){if(e.slice(r,r+13)===`\0QUOTE_START\0`){n=!0,r+=12;continue}if(e.slice(r,r+11)===`\0QUOTE_END\0`){n=!1,r+=10;continue}let i=e[r];if(n){/[.+^${}()|\\*?[\]]/.test(i)?t+=`\\${i}`:t+=i;continue}if(this.extglob&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let n=Nf(e,r+1);if(n!==-1){let a=Pf(e.slice(r+2,n)),o=a.map(e=>this.patternToRegexStr(e)),s=o.length>0?o.join(`|`):`(?:)`;if(i===`@`)t+=`(?:${s})`;else if(i===`*`)t+=`(?:${s})*`;else if(i===`+`)t+=`(?:${s})+`;else if(i===`?`)t+=`(?:${s})?`;else if(i===`!`)if(n<e.length-1){let e=a.map(e=>this.computePatternLength(e));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let n=e[0];if(n===0)t+=`(?:.+)`;else{let e=[];n>0&&e.push(`.{0,${n-1}}`),e.push(`.{${n+1},}`),e.push(`(?!(?:${s})).{${n}}`),t+=`(?:${e.join(`|`)})`}}else t+=`(?:(?!(?:${s})).)*?`}else t+=`(?!(?:${s})$).*`;r=n;continue}}if(i===`*`)t+=`.*`;else if(i===`?`)t+=`.`;else if(i===`[`){let n=r+1,i=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(i+=`^`,n++),n<e.length&&e[n]===`]`&&(i+=`\\]`,n++);let a=n;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=n;for(;n<e.length&&e[n]!==`]`;){if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=Af(e.slice(n+2,t));i+=r,n=t+2;continue}}if(e[n]===`\\`&&n+1<e.length){i+=`\\${e[n+1]}`,n+=2;continue}if(e[n]===`-`){let e=n===o,t=n+1===a;e||t?i+=`\\-`:i+=`-`}else i+=e[n];n++}i+=`]`,t+=i,r=n}else if(i===`\\`&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\*?[\]]/.test(n)?t+=`\\${n}`:t+=n,r++}else /[.+^${}()|]/.test(i)?t+=`\\${i}`:t+=i}return t}computePatternLength(e){let t=0,n=0,r=!1;for(;n<e.length;){if(e.slice(n,n+13)===`\0QUOTE_START\0`){r=!0,n+=13;continue}if(e.slice(n,n+11)===`\0QUOTE_END\0`){r=!1,n+=11;continue}let i=e[n];if(r){t+=1,n++;continue}if((i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&n+1<e.length&&e[n+1]===`(`){let r=Nf(e,n+1);if(r!==-1){if(i===`@`){let i=Pf(e.slice(n+2,r)).map(e=>this.computePatternLength(e));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){t+=i[0],n=r+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){t+=1,n++;continue}if(i===`[`){let r=e.indexOf(`]`,n+1);if(r!==-1){t+=1,n=r+1;continue}t+=1,n++;continue}if(i===`\\`){t+=1,n+=2;continue}t+=1,n++}return t}}});function Bf(e){for(let t=0;t<e.length;t++){if(e[t]===`\\`){t++;continue}if(e[t]===`$`){let n=e[t+1];if(n===`{`||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function Vf(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n)return!1;for(let e of n)if(e.type===`DoubleQuoted`||e.type===`SingleQuoted`)return!0;return!1}function Hf(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n||n.length===0)return!1;for(let e of n)if(e.type!==`DoubleQuoted`&&e.type!==`SingleQuoted`)return!1;return!0}function Uf(e){let t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1;for(let c of e){if((c.type===`SingleQuoted`||c.type===`DoubleQuoted`)&&(t=!0,c.type===`DoubleQuoted`))for(let e of c.parts)e.type===`ParameterExpansion`&&(e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!e.operation||e.operation.type===`PatternRemoval`||e.operation.type===`PatternReplacement`)&&(i=!0),(e.operation?.type===`VarNamePrefix`||e.operation?.type===`ArrayKeys`)&&(o=!0),e.operation?.type===`Indirection`&&(s=!0));c.type===`CommandSubstitution`&&(n=!0),c.type===`ParameterExpansion`&&(a=!0,(c.parameter===`@`||c.parameter===`*`)&&(r=!0),Vf(c)&&(t=!0),(c.operation?.type===`VarNamePrefix`||c.operation?.type===`ArrayKeys`)&&(o=!0),c.operation?.type===`Indirection`&&(s=!0)),c.type===`Glob`&&Bf(c.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:i,hasParamExpansion:a,hasVarNamePrefixExpansion:o,hasIndirection:s}}var Wf=g(()=>{});function Gf(e,t){let n=`${t}_`,r=[];for(let t of e.state.env.keys())if(t.startsWith(n)){let e=t.slice(n.length),i=Number.parseInt(e,10);!Number.isNaN(i)&&String(i)===e&&r.push(i)}return r.sort((e,t)=>e-t)}function Kf(e,t){let n=`${t}_`,r=`${t}__length`,i=[];for(let t of e.state.env.keys())if(t!==r&&t.startsWith(n)){let e=t.slice(n.length);if(e.startsWith(`_length`))continue;i.push(e)}return i.sort()}function qf(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}var Jf=g(()=>{});function Yf(e){return e.get(`IFS`)??`
199
- `}function Xf(e){return e.get(`IFS`)===``}function Zf(e){let t=Yf(e);if(t===``)return!0;for(let e of t)if(e!==` `&&e!==` `&&e!==`
200
- `)return!1;return!0}function Qf(e){let t=!1,n=[];for(let r of e.split(``))r===`-`?t=!0:/[\\^$.*+?()[\]{}|]/.test(r)?n.push(`\\${r}`):r===` `?n.push(`\\t`):r===`
201
- `?n.push(`\\n`):n.push(r);return t&&n.push(`\\-`),n.join(``)}function q(e){let t=e.get(`IFS`);return t===void 0?` `:t[0]||``}function $f(e){return np.includes(e)}function ep(e){let t=new Set,n=new Set;for(let r of e)$f(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function tp(e,t){if(t===``)return{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e===``)return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:n,nonWhitespace:r}=ep(t),i=[],a=0,o=!1,s=!1,c=a;for(;a<e.length&&n.has(e[a]);)a++;if(a>c&&(o=!0),a>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(r.has(e[a]))for(i.push(``),a++;a<e.length&&n.has(e[a]);)a++;for(;a<e.length;){let t=a;for(;a<e.length;){let t=e[a];if(n.has(t)||r.has(t))break;a++}if(i.push(e.substring(t,a)),a>=e.length){s=!1;break}let o=a;for(;a<e.length&&n.has(e[a]);)a++;if(a<e.length&&r.has(e[a])){for(a++;a<e.length&&n.has(e[a]);)a++;for(;a<e.length&&r.has(e[a]);)for(i.push(``),a++;a<e.length&&n.has(e[a]);)a++}a>=e.length&&a>o&&(s=!0)}return{words:i,hadLeadingDelimiter:o,hadTrailingDelimiter:s}}function J(e,t){return tp(e,t).words}var np,rp=g(()=>{np=`
202
- `});function ip(e,t){return e.state.namerefs?.has(t)??!1}function ap(e,t){return e.state.invalidNamerefs?.has(t)??!1}function op(e,t,n=100){if(!ip(e,t)||ap(e,t))return t;let r=new Set,i=t;for(;n-- >0;){if(r.has(i))return;if(r.add(i),!ip(e,i))return i;let t=e.state.env.get(i);if(t===void 0||t===``||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return i;i=t}}function sp(e,t){if(ip(e,t))return e.state.env.get(t)}var cp=g(()=>{});function lp(e,t){let n=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(t,n)=>e.state.env.get(n)??``);return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(t,n)=>e.state.env.get(n)??``),n}function Y(e,t){return t===`FUNCNAME`?(e.state.funcNameStack??[]).map((e,t)=>[t,e]):t===`BASH_LINENO`?(e.state.callLineStack??[]).map((e,t)=>[t,String(e)]):t===`BASH_SOURCE`?(e.state.sourceStack??[]).map((e,t)=>[t,e]):e.state.associativeArrays?.has(t)?Kf(e,t).map(n=>[n,e.state.env.get(`${t}_${n}`)??``]):Gf(e,t).map(n=>[n,e.state.env.get(`${t}_${n}`)??``])}function up(e,t){return t===`FUNCNAME`?(e.state.funcNameStack?.length??0)>0:t===`BASH_LINENO`?(e.state.callLineStack?.length??0)>0:t===`BASH_SOURCE`?(e.state.sourceStack?.length??0)>0:e.state.associativeArrays?.has(t)?Kf(e,t).length>0:Gf(e,t).length>0}async function X(e,t,n=!0,r=!1){switch(t){case`?`:return String(e.state.lastExitCode);case`$`:return String(e.state.virtualPid);case`#`:return e.state.env.get(`#`)||`0`;case`@`:return e.state.env.get(`@`)||``;case`_`:return e.state.lastArg;case`-`:{let t=``;return t+=`h`,e.state.options.errexit&&(t+=`e`),e.state.options.noglob&&(t+=`f`),e.state.options.nounset&&(t+=`u`),e.state.options.verbose&&(t+=`v`),e.state.options.xtrace&&(t+=`x`),t+=`B`,e.state.options.noclobber&&(t+=`C`),t+=`s`,t}case`*`:{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t===0)return``;let n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return n.join(q(e.state.env))}case`0`:return e.state.env.get(`0`)||`bash`;case`PWD`:return e.state.env.get(`PWD`)??``;case`OLDPWD`:return e.state.env.get(`OLDPWD`)??``;case`PPID`:return String(e.state.virtualPpid);case`UID`:return String(e.state.virtualUid);case`EUID`:return String(e.state.virtualUid);case`RANDOM`:return String(Math.floor(Math.random()*32768));case`SECONDS`:return String(Math.floor((Date.now()-e.state.startTime)/1e3));case`BASH_VERSION`:return Du;case`!`:return String(e.state.lastBackgroundPid);case`BASHPID`:return String(e.state.bashPid);case`LINENO`:return String(e.state.currentLine);case`FUNCNAME`:{let t=e.state.funcNameStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new ar(`FUNCNAME`);return``}case`BASH_LINENO`:{let t=e.state.callLineStack?.[0];if(t!==void 0)return String(t);if(n&&e.state.options.nounset)throw new ar(`BASH_LINENO`);return``}case`BASH_SOURCE`:{let t=e.state.sourceStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new ar(`BASH_SOURCE`);return``}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new cr(`\${${t}}`);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let t=i[1],r=i[2];if(ip(e,t)){let n=op(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return``;t=n}}if(r===`@`||r===`*`){let n=Y(e,t);if(n.length>0)return n.map(([,e])=>e).join(` `);let r=e.state.env.get(t);return r===void 0?``:r}if(t===`FUNCNAME`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.funcNameStack?.[t]??``:``}if(t===`BASH_LINENO`){let t=Number.parseInt(r,10);if(!Number.isNaN(t)&&t>=0){let n=e.state.callLineStack?.[t];return n===void 0?``:String(n)}return``}if(t===`BASH_SOURCE`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.sourceStack?.[t]??``:``}if(e.state.associativeArrays?.has(t)){let i=qf(r);i=lp(e,i);let a=e.state.env.get(`${t}_${i}`);if(a===void 0&&n&&e.state.options.nounset)throw new ar(`${t}[${r}]`);return a||``}let a;if(/^-?\d+$/.test(r))a=Number.parseInt(r,10);else try{a=await $(e,rd(new kf,r).expression)}catch{let t=e.state.env.get(r);a=t?Number.parseInt(t,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let n=Y(e,t),r=e.state.currentLine;if(n.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
203
+ `||l&&e===`}`,r=o?`*?[]\\`.includes(e):`*?[]\\(){}.^+`.includes(e);n?f+=e:r?(p(),u.push(U.escaped(e))):f+=`\\${e}`,d+=2;continue}if(n===`'`&&!o&&!a){p();let e=t.indexOf(`'`,d+1);if(e===-1){f+=t.slice(d);break}u.push(U.singleQuoted(t.slice(d+1,e))),d=e+1;continue}if(n===`"`&&!a){p();let{part:n,endIndex:r}=kf(e,t,d+1);u.push(n),d=r+1;continue}if(n===`$`&&t[d+1]===`'`){p();let{part:n,endIndex:r}=zd(e,t,d+2);u.push(n),d=r;continue}if(n===`$`){p();let{part:n,endIndex:r}=Df(e,t,d);n&&u.push(n),d=r;continue}if(n==="`"){p();let{part:n,endIndex:r}=e.parseBacktickSubstitution(t,d);u.push(n),d=r;continue}if(n===`~`){let n=d>0?t[d-1]:``;if(d===0||n===`=`||i&&n===`:`){let n=Nd(e,t,d),r=t[n];if(r===void 0||r===`/`||r===`:`){p();let e=t.slice(d+1,n)||null;u.push({type:`TildeExpansion`,user:e}),d=n;continue}}}if(`@*+?!`.includes(n)&&d+1<t.length&&t[d+1]===`(`){let e=Cf(t,d+1);if(e!==-1){p();let n=t.slice(d,e+1);u.push({type:`Glob`,pattern:n}),d=e+1;continue}}if(n===`*`||n===`?`||n===`[`){p();let{pattern:n,endIndex:r}=Ld(e,t,d);u.push({type:`Glob`,pattern:n}),d=r;continue}if(n===`{`&&!i&&!s&&!a){let n=Hd(e,t,d,Af);if(n){p(),u.push(n.part),d=n.endIndex;continue}}f+=n,d++}return p(),u}var jf=g(()=>{ku(),jd(),nd(),Gd()}),Mf,K=g(()=>{ku(),jd(),$d(),uf(),xf(),jf(),qu(),Fu(),nd(),nd(),Mf=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input=``;getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Xu)throw new td(`Maximum parse iterations exceeded (possible infinite loop)`,this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Zu)throw new td(`Maximum parser nesting depth exceeded (${Zu})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(e,t){if(e.length>Ju)throw new td(`Input too large: ${e.length} bytes exceeds limit of ${Ju}`,1,1);this._input=e;let n=new Ku(e,t);if(this.tokens=n.tokenize(),this.tokens.length>Yu)throw new td(`Too many tokens: ${this.tokens.length} exceeds limit of ${Yu}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(e=0){return this.tokens[this.pos+e]||this.tokens[this.tokens.length-1]}advance(){let e=this.current();return this.pos<this.tokens.length-1&&this.pos++,e}getPos(){return this.pos}check(e,t,n,r,...i){let a=this.tokens[this.pos]?.type;return a===e||t!==void 0&&a===t||n!==void 0&&a===n||r!==void 0&&a===r?!0:i.length>0?i.includes(a):!1}expect(e,t){if(this.check(e))return this.advance();let n=this.current();throw new td(t||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let t=this.current();throw new td(e,t.line,t.column,t)}skipNewlines(){for(;this.check(W.NEWLINE,W.COMMENT);)this.check(W.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(W.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(W.SEMICOLON,W.COMMENT)){this.advance();continue}if(e&&this.check(W.DSEMI,W.SEMI_AND,W.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,t,n,r){this.pendingHeredocs.push({redirect:e,delimiter:t,stripTabs:n,quoted:r})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(W.HEREDOC_CONTENT)){let t=this.advance(),n;n=e.quoted?U.word([U.literal(t.value)]):this.parseWordFromString(t.value,!1,!1,!1,!0),e.redirect.target=U.hereDoc(e.delimiter,n,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(W.EOF,W.NEWLINE,W.SEMICOLON,W.AMP,W.AND_AND,W.OR_OR,W.RPAREN,W.RBRACE,W.DSEMI,W.SEMI_AND,W.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===W.WORD||e===W.NAME||e===W.NUMBER||e===W.ASSIGNMENT_WORD||e===W.IF||e===W.FOR||e===W.WHILE||e===W.UNTIL||e===W.CASE||e===W.LPAREN||e===W.LBRACE||e===W.DPAREN_START||e===W.DBRACK_START||e===W.FUNCTION||e===W.BANG||e===W.TIME||e===W.IN||e===W.LESS||e===W.GREAT||e===W.DLESS||e===W.DGREAT||e===W.LESSAND||e===W.GREATAND||e===W.LESSGREAT||e===W.DLESSDASH||e===W.CLOBBER||e===W.TLESS||e===W.AND_GREAT||e===W.AND_DGREAT}parseScript(){let e=[],t=0;for(this.skipNewlines();!this.check(W.EOF);){t++,t>1e4&&this.error(`Parser stuck: too many iterations (>10000)`);let n=this.checkUnexpectedToken();if(n){e.push(n),this.skipSeparators(!1);continue}let r=this.pos,i=this.parseStatement();i&&e.push(i),this.skipSeparators(!1),this.check(W.DSEMI,W.SEMI_AND,W.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===r&&!this.check(W.EOF)&&this.advance()}return U.script(e)}checkUnexpectedToken(){let e=this.current().type,t=this.current().value;if((e===W.DO||e===W.DONE||e===W.THEN||e===W.ELSE||e===W.ELIF||e===W.FI||e===W.ESAC)&&this.error(`syntax error near unexpected token \`${t}'`),e===W.RBRACE||e===W.RPAREN){let e=`syntax error near unexpected token \`${t}'`;return this.advance(),U.statement([U.pipeline([U.simpleCommand(null,[],[],[])])],[],!1,{message:e,token:t})}return(e===W.DSEMI||e===W.SEMI_AND||e===W.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${t}'`),e===W.SEMICOLON&&this.error(`syntax error near unexpected token \`${t}'`),(e===W.PIPE||e===W.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${t}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=this.current().start,t=[],n=[],r=!1,i=this.parsePipeline();for(t.push(i);this.check(W.AND_AND,W.OR_OR);){let e=this.advance();n.push(e.type===W.AND_AND?`&&`:`||`),this.skipNewlines();let r=this.parsePipeline();t.push(r)}this.check(W.AMP)&&(this.advance(),r=!0);let a=this.pos>0?this.tokens[this.pos-1].end:e,o=this._input.slice(e,a);return U.statement(t,n,r,void 0,o)}parsePipeline(){let e=!1,t=!1;this.check(W.TIME)&&(this.advance(),e=!0,this.check(W.WORD,W.NAME)&&this.current().value===`-p`&&(this.advance(),t=!0));let n=0;for(;this.check(W.BANG);)this.advance(),n++;let r=n%2==1,i=[],a=[],o=this.parseCommand();for(i.push(o);this.check(W.PIPE,W.PIPE_AMP);){let e=this.advance();this.skipNewlines(),a.push(e.type===W.PIPE_AMP);let t=this.parseCommand();i.push(t)}return U.pipeline(i,r,e,t,a.length>0?a:void 0)}parseCommand(){return this.check(W.IF)?ef(this):this.check(W.FOR)?tf(this):this.check(W.WHILE)?rf(this):this.check(W.UNTIL)?af(this):this.check(W.CASE)?of(this):this.check(W.LPAREN)?cf(this):this.check(W.LBRACE)?lf(this):this.check(W.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(W.DBRACK_START)?this.parseConditionalCommand():this.check(W.FUNCTION)||this.check(W.NAME,W.WORD)&&this.peek(1).type===W.LPAREN&&this.peek(2).type===W.RPAREN?this.parseFunctionDef():Yd(this)}dparenClosesWithSpacedParens(){let e=1,t=1;for(;t<this.tokens.length-this.pos;){let n=this.peek(t);if(n.type===W.EOF)return!1;if(n.type===W.DPAREN_START||n.type===W.LPAREN)e++;else if(n.type===W.DPAREN_END){if(e-=2,e<=0)return!1}else if(n.type===W.RPAREN&&(e--,e===0&&this.peek(t+1).type===W.RPAREN))return!0;t++}return!1}parseNestedSubshellsFromDparen(){this.advance();let e=this.parseCompoundList();this.expect(W.RPAREN),this.expect(W.RPAREN);let t=this.parseOptionalRedirections(),n=U.subshell(e,[]);return U.subshell([U.statement([U.pipeline([n],!1,!1,!1)])],t)}isWord(){let e=this.current().type;return e===W.WORD||e===W.NAME||e===W.NUMBER||e===W.IF||e===W.FOR||e===W.WHILE||e===W.UNTIL||e===W.CASE||e===W.FUNCTION||e===W.ELSE||e===W.ELIF||e===W.FI||e===W.THEN||e===W.DO||e===W.DONE||e===W.ESAC||e===W.IN||e===W.SELECT||e===W.TIME||e===W.COPROC||e===W.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordNoBraceExpansion(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0)}parseWordForRegex(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted,!1,!1,!0,!0)}parseWordFromString(e,t=!1,n=!1,r=!1,i=!1,a=!1,o=!1){let s=Af(this,e,t,n,r,i,!1,a,o);return U.word(s)}parseCommandSubstitution(t,n){return Nu(t,n,()=>new e,e=>this.error(e))}parseBacktickSubstitution(t,n,r=!1){return Pu(t,n,r,()=>new e,e=>this.error(e))}isDollarDparenSubshell(e,t){return Au(e,t)}parseArithmeticExpansion(e,t){let n=t+3,r=1,i=0,a=n;for(;a<e.length-1&&r>0;)e[a]===`$`&&e[a+1]===`(`?e[a+2]===`(`?(r++,a+=3):(i++,a+=2):e[a]===`(`&&e[a+1]===`(`?(r++,a+=2):e[a]===`)`&&e[a+1]===`)`?i>0?(i--,a++):(r--,r>0&&(a+=2)):e[a]===`(`?(i++,a++):(e[a]===`)`&&i>0&&i--,a++);let o=e.slice(n,a),s=this.parseArithmeticExpression(o);return{part:U.arithmeticExpansion(s),endIndex:a+2}}parseArithmeticCommand(){let e=this.expect(W.DPAREN_START),t=``,n=1,r=0,i=!1,a=!1;for(;n>0&&!this.check(W.EOF);){if(i){if(i=!1,r>0){r--,t+=`)`;continue}if(this.check(W.RPAREN)){n--,a=!0,this.advance();continue}if(this.check(W.DPAREN_END)){n--,a=!0;continue}t+=`)`;continue}if(this.check(W.DPAREN_START))n++,t+=`((`,this.advance();else if(this.check(W.DPAREN_END))r>=2?(r-=2,t+=`))`,this.advance()):r===1?(r--,t+=`)`,i=!0,this.advance()):(n--,a=!0,n>0&&(t+=`))`),this.advance());else if(this.check(W.LPAREN))r++,t+=`(`,this.advance();else if(this.check(W.RPAREN))r>0&&r--,t+=`)`,this.advance();else{let e=this.current().value,n=t.length>0?t[t.length-1]:``;t.length>0&&!t.endsWith(` `)&&!(e===`=`&&/[|&^+\-*/%<>]$/.test(t))&&!(e===`<`&&n===`<`)&&!(e===`>`&&n===`>`)&&(t+=` `),t+=e,this.advance()}}a||this.expect(W.DPAREN_END);let o=this.parseArithmeticExpression(t.trim()),s=this.parseOptionalRedirections();return U.arithmeticCommand(o,s,e.line)}parseConditionalCommand(){let e=this.expect(W.DBRACK_START),t=pf(this);this.expect(W.DBRACK_END);let n=this.parseOptionalRedirections();return U.conditionalCommand(t,n,e.line)}parseFunctionDef(){let e;if(this.check(W.FUNCTION)){if(this.advance(),this.check(W.NAME)||this.check(W.WORD))e=this.advance().value;else{let e=this.current();throw new td(`Expected function name`,e.line,e.column,e)}this.check(W.LPAREN)&&(this.advance(),this.expect(W.RPAREN))}else e=this.advance().value,e.includes(`$`)&&this.error(`\`${e}': not a valid identifier`),this.expect(W.LPAREN),this.expect(W.RPAREN);this.skipNewlines();let t=this.parseCompoundCommandBody({forFunctionBody:!0}),n=this.parseOptionalRedirections();return U.functionDef(e,t,n)}parseCompoundCommandBody(e){let t=e?.forFunctionBody;if(this.check(W.LBRACE))return lf(this,{skipRedirections:t});if(this.check(W.LPAREN))return cf(this,{skipRedirections:t});if(this.check(W.IF))return ef(this,{skipRedirections:t});if(this.check(W.FOR))return tf(this,{skipRedirections:t});if(this.check(W.WHILE))return rf(this,{skipRedirections:t});if(this.check(W.UNTIL))return af(this,{skipRedirections:t});if(this.check(W.CASE))return of(this,{skipRedirections:t});this.error(`Expected compound command for function body`)}parseCompoundList(){let e=this.enterDepth(),t=[];for(this.skipNewlines();!this.check(W.EOF,W.FI,W.ELSE,W.ELIF,W.THEN,W.DO,W.DONE,W.ESAC,W.RPAREN,W.RBRACE,W.DSEMI,W.SEMI_AND,W.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let e=this.pos,n=this.parseStatement();if(n&&t.push(n),this.skipSeparators(),this.pos===e&&!n)break}return e(),t}parseOptionalRedirections(){let e=[];for(;Kd(this);){this.checkIterationLimit();let t=this.pos;if(e.push(qd(this)),this.pos===t)break}return e}parseArithmeticExpression(e){return ud(this,e)}}});function Nf(e){return Rf.get(e)??``}function Pf(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`[`){for(n+=i,r++,r<e.length&&(e[r]===`!`||e[r]===`^`)&&(n+=e[r],r++),r<e.length&&e[r]===`]`&&(n+=e[r],r++);r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){n+=e.slice(r,t+2),r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]===`]`&&(n+=e[r],r++)}else i===`:`?(n!==``&&t.push(n),n=``,r++):i===`\\`&&r+1<e.length?(n+=i+e[r+1],r+=2):(n+=i,r++)}return n!==``&&t.push(n),t}function Ff(e){let t=`^`;for(let n=0;n<e.length;n++){let r=e[n];if(r===`*`)t+=`[^/]*`;else if(r===`?`)t+=`[^/]`;else if(r===`[`){let r=n+1,i=`[`;r<e.length&&(e[r]===`^`||e[r]===`!`)&&(i+=`^`,r++),r<e.length&&e[r]===`]`&&(i+=`\\]`,r++);let a=r;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=r;for(;r<e.length&&e[r]!==`]`;){if(e[r]===`[`&&r+1<e.length&&e[r+1]===`:`){let t=e.indexOf(`:]`,r+2);if(t!==-1){let n=Nf(e.slice(r+2,t));i+=n,r=t+2;continue}}if(e[r]===`\\`&&r+1<e.length){i+=`\\${e[r+1]}`,r+=2;continue}if(e[r]===`-`){let e=r===o,t=r+1===a;e||t?i+=`\\-`:i+=`-`}else i+=e[r];r++}i+=`]`,t+=i,n=r}else if(r===`\\`&&n+1<e.length){let r=e[n+1];/[.+^${}()|\\*?[\]]/.test(r)?t+=`\\${r}`:t+=r,n++}else /[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+=`$`,M(t)}function If(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Lf(e){let t=[],n=``,r=0,i=!1,a=0;for(;a<e.length;){let o=e[a];if(o===`'`&&!i){i=!0,n+=`\0QUOTE_START\0`,a++;continue}if(o===`'`&&i){i=!1,n+=`\0QUOTE_END\0`,a++;continue}if(i){n+=o,a++;continue}if(o===`\\`){n+=o,a+1<e.length?(n+=e[a+1],a+=2):a++;continue}o===`(`?(r++,n+=o):o===`)`?(r--,n+=o):o===`|`&&r===0?(t.push(n),n=``):n+=o,a++}return t.push(n),t}var Rf,zf=g(()=>{ta(),Rf=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9a-fA-F`]])}),Bf,Vf,Hf=g(()=>{x(),ta(),tr(),zf(),Bf=5,Vf=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(e,t,n,r){this.fs=e,this.cwd=t,typeof r==`boolean`?(this.globstar=r,this.maxOps=1e5):r?(this.globstar=r.globstar??!1,this.nullglob=r.nullglob??!1,this.failglob=r.failglob??!1,this.dotglob=r.dotglob??!1,this.extglob=r.extglob??!1,this.globskipdots=r.globskipdots??!0,this.maxOps=r.maxGlobOperations??1e5):this.maxOps=1e5;let i=n?.get(`GLOBIGNORE`);i!==void 0&&i!==``&&(this.hasGlobignore=!0,this.globignorePatterns=Pf(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new b(`Glob operation limit exceeded (${this.maxOps})`,`glob_operations`)}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(e){return!this.hasGlobignore&&!this.globskipdots?e:e.filter(e=>{let t=e.split(`/`).pop()||e;if((this.hasGlobignore||this.globskipdots)&&(t===`.`||t===`..`))return!1;if(this.hasGlobignore){for(let t of this.globignorePatterns)if(this.matchGlobignorePattern(e,t))return!1}return!0})}matchGlobignorePattern(e,t){return Ff(t).test(e)}isGlobPattern(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandArgs(e,t){let n=e.map((e,n)=>(t?.[n]??!1)||!this.isGlobPattern(e)?null:this.expand(e)),r=await Promise.all(n.map(e=>e||Promise.resolve(null))),i=[];for(let t=0;t<e.length;t++){let n=r[t];n===null?i.push(e[t]):n.length>0?i.push(...n):i.push(e[t])}return i}async expand(e){if(this.globstar){let t=e.split(`/`),n=0;for(let e of t)if(e===`**`&&(n++,n>Bf))throw new b(`Glob pattern has too many ** segments (max ${Bf})`,`glob_operations`)}let t;if(e.includes(`**`)&&this.globstar&&this.isGlobstarValid(e))t=await this.expandRecursive(e);else{let n=e.replace(/\*\*+/g,`*`);t=await this.expandSimple(n)}return this.filterGlobignore(t)}isGlobstarValid(e){let t=e.split(`/`);for(let e of t)if(e.includes(`**`)&&e!==`**`)return!1;return!0}hasGlobChars(e){return!!(e.includes(`*`)||e.includes(`?`)||/\[.*\]/.test(e)||this.extglob&&/[@*+?!]\(/.test(e))}async expandSimple(e){let t=e.startsWith(`/`),n=e.split(`/`).filter(e=>e!==``),r=-1;for(let e=0;e<n.length;e++)if(this.hasGlobChars(n[e])){r=e;break}if(r===-1)return[e];let i,a;if(r===0)t?(i=`/`,a=`/`):(i=this.cwd,a=``);else{let e=n.slice(0,r);t?(i=`/${e.join(`/`)}`,a=`/${e.join(`/`)}`):(i=this.fs.resolvePath(this.cwd,e.join(`/`)),a=e.join(`/`))}let o=n.slice(r);return(await this.expandSegments(i,a,o)).sort()}async expandSegments(e,t,n){if(this.checkOpsLimit(),n.length===0)return[t];let[r,...i]=n,a=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let n=await this.fs.readdirWithFileTypes(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;if(r.startsWith(`.`)||this.dotglob){let e=n.some(e=>e.name===`.`),t=n.some(e=>e.name===`..`);e||s.push({name:`.`,isFile:!1,isDirectory:!0,isSymbolicLink:!1}),t||s.push({name:`..`,isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let n of s)if(!(n.name.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n.name,r)){let r=e===`/`?`/${n.name}`:`${e}/${n.name}`,a;a=t===``?n.name:t===`/`?`/${n.name}`:`${t}/${n.name}`,i.length===0?o.push(Promise.resolve([a])):n.isDirectory&&o.push(this.expandSegments(r,a,i))}let l=await Promise.all(o);for(let e of l)a.push(...e)}else{this.checkOpsLimit();let n=await this.fs.readdir(e),o=[],s=[...n],c=this.dotglob||this.hasGlobignore;(r.startsWith(`.`)||this.dotglob)&&(n.includes(`.`)||s.push(`.`),n.includes(`..`)||s.push(`..`));for(let n of s)if(!(n.startsWith(`.`)&&!r.startsWith(`.`)&&!c)&&this.matchPattern(n,r)){let r=e===`/`?`/${n}`:`${e}/${n}`,a;a=t===``?n:t===`/`?`/${n}`:`${t}/${n}`,i.length===0?o.push(Promise.resolve([a])):o.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory)return this.expandSegments(r,a,i)}catch(e){if(e instanceof b)throw e}return[]})())}let l=await Promise.all(o);for(let e of l)a.push(...e)}}catch(e){if(e instanceof b)throw e}return a}async expandRecursive(e){let t=[],n=e.indexOf(`**`),r=e.slice(0,n).replace(/\/$/,``)||`.`,i=e.slice(n+2).replace(/^\//,``);return i.includes(`**`)&&this.isGlobstarValid(i)?(await this.walkDirectoryMultiGlobstar(r,i,t),[...new Set(t)].sort()):(await this.walkDirectory(r,i,t),t.sort())}async walkDirectoryMultiGlobstar(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(r):null;if(i){let r=[];for(let t of i){let n=e===`.`?t.name:`${e}/${t.name}`;t.isDirectory&&r.push(n)}let a=e===`.`?t:`${e}/${t}`,o=await this.expandRecursive(a);n.push(...o);for(let e=0;e<r.length;e+=100){let i=r.slice(e,e+100);await Promise.all(i.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t of i){let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{this.checkOpsLimit(),(await this.fs.stat(r)).isDirectory&&a.push(n)}catch(e){if(e instanceof b)throw e}}let o=e===`.`?t:`${e}/${t}`,s=await this.expandRecursive(o);n.push(...s);for(let e=0;e<a.length;e+=100){let r=a.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectoryMultiGlobstar(e,t,n)))}}}catch(e){if(e instanceof b)throw e}}async walkDirectory(e,t,n){this.checkOpsLimit();let r=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(r),a=[],o=[];for(let n of i){let r=e===`.`?n.name:`${e}/${n.name}`;n.isDirectory?o.push(r):t&&this.matchPattern(n.name,t)&&a.push(r)}n.push(...a);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e,t,n)))}}else{this.checkOpsLimit();let i=await this.fs.readdir(r),a=[];for(let t=0;t<i.length;t+=100){let n=i.slice(t,t+100),r=await Promise.all(n.map(async t=>{let n=e===`.`?t:`${e}/${t}`,r=this.fs.resolvePath(this.cwd,n);try{return this.checkOpsLimit(),{name:t,path:n,isDirectory:(await this.fs.stat(r)).isDirectory}}catch(e){if(e instanceof b)throw e;return null}}));a.push(...r.filter(e=>e!==null))}for(let e of a)!e.isDirectory&&t&&this.matchPattern(e.name,t)&&n.push(e.path);let o=a.filter(e=>e.isDirectory);for(let e=0;e<o.length;e+=100){let r=o.slice(e,e+100);await Promise.all(r.map(e=>this.walkDirectory(e.path,t,n)))}}}catch(e){if(e instanceof b)throw e}}matchPattern(e,t){return this.patternToRegex(t).test(e)}patternToRegex(e){return M(`^${this.patternToRegexStr(e)}$`)}patternToRegexStr(e){let t=``,n=!1;for(let r=0;r<e.length;r++){if(e.slice(r,r+13)===`\0QUOTE_START\0`){n=!0,r+=12;continue}if(e.slice(r,r+11)===`\0QUOTE_END\0`){n=!1,r+=10;continue}let i=e[r];if(n){/[.+^${}()|\\*?[\]]/.test(i)?t+=`\\${i}`:t+=i;continue}if(this.extglob&&(i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&r+1<e.length&&e[r+1]===`(`){let n=If(e,r+1);if(n!==-1){let a=Lf(e.slice(r+2,n)),o=a.map(e=>this.patternToRegexStr(e)),s=o.length>0?o.join(`|`):`(?:)`;if(i===`@`)t+=`(?:${s})`;else if(i===`*`)t+=`(?:${s})*`;else if(i===`+`)t+=`(?:${s})+`;else if(i===`?`)t+=`(?:${s})?`;else if(i===`!`)if(n<e.length-1){let e=a.map(e=>this.computePatternLength(e));if(e.every(e=>e!==null)&&e.every(t=>t===e[0])&&e[0]!==null){let n=e[0];if(n===0)t+=`(?:.+)`;else{let e=[];n>0&&e.push(`.{0,${n-1}}`),e.push(`.{${n+1},}`),e.push(`(?!(?:${s})).{${n}}`),t+=`(?:${e.join(`|`)})`}}else t+=`(?:(?!(?:${s})).)*?`}else t+=`(?!(?:${s})$).*`;r=n;continue}}if(i===`*`)t+=`.*`;else if(i===`?`)t+=`.`;else if(i===`[`){let n=r+1,i=`[`;n<e.length&&(e[n]===`^`||e[n]===`!`)&&(i+=`^`,n++),n<e.length&&e[n]===`]`&&(i+=`\\]`,n++);let a=n;for(;a<e.length;){if(e[a]===`\\`&&a+1<e.length){a+=2;continue}if(e[a]===`[`&&a+1<e.length&&e[a+1]===`:`){let t=e.indexOf(`:]`,a+2);if(t!==-1){a=t+2;continue}}if(e[a]===`]`)break;a++}let o=n;for(;n<e.length&&e[n]!==`]`;){if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){let r=Nf(e.slice(n+2,t));i+=r,n=t+2;continue}}if(e[n]===`\\`&&n+1<e.length){i+=`\\${e[n+1]}`,n+=2;continue}if(e[n]===`-`){let e=n===o,t=n+1===a;e||t?i+=`\\-`:i+=`-`}else i+=e[n];n++}i+=`]`,t+=i,r=n}else if(i===`\\`&&r+1<e.length){let n=e[r+1];/[.+^${}()|\\*?[\]]/.test(n)?t+=`\\${n}`:t+=n,r++}else /[.+^${}()|]/.test(i)?t+=`\\${i}`:t+=i}return t}computePatternLength(e){let t=0,n=0,r=!1;for(;n<e.length;){if(e.slice(n,n+13)===`\0QUOTE_START\0`){r=!0,n+=13;continue}if(e.slice(n,n+11)===`\0QUOTE_END\0`){r=!1,n+=11;continue}let i=e[n];if(r){t+=1,n++;continue}if((i===`@`||i===`*`||i===`+`||i===`?`||i===`!`)&&n+1<e.length&&e[n+1]===`(`){let r=If(e,n+1);if(r!==-1){if(i===`@`){let i=Lf(e.slice(n+2,r)).map(e=>this.computePatternLength(e));if(i.every(e=>e!==null)&&i.every(e=>e===i[0])){t+=i[0],n=r+1;continue}return null}return null}}if(i===`*`)return null;if(i===`?`){t+=1,n++;continue}if(i===`[`){let r=e.indexOf(`]`,n+1);if(r!==-1){t+=1,n=r+1;continue}t+=1,n++;continue}if(i===`\\`){t+=1,n+=2;continue}t+=1,n++}return t}}});function Uf(e){for(let t=0;t<e.length;t++){if(e[t]===`\\`){t++;continue}if(e[t]===`$`){let n=e[t+1];if(n===`{`||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function Wf(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n)return!1;for(let e of n)if(e.type===`DoubleQuoted`||e.type===`SingleQuoted`)return!0;return!1}function Gf(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type===`DefaultValue`||t.type===`AssignDefault`||t.type===`UseAlternative`||t.type===`ErrorIfUnset`)&&(n=t.word?.parts),!n||n.length===0)return!1;for(let e of n)if(e.type!==`DoubleQuoted`&&e.type!==`SingleQuoted`)return!1;return!0}function Kf(e){let t=!1,n=!1,r=!1,i=!1,a=!1,o=!1,s=!1;for(let c of e){if((c.type===`SingleQuoted`||c.type===`DoubleQuoted`)&&(t=!0,c.type===`DoubleQuoted`))for(let e of c.parts)e.type===`ParameterExpansion`&&(e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!e.operation||e.operation.type===`PatternRemoval`||e.operation.type===`PatternReplacement`)&&(i=!0),(e.operation?.type===`VarNamePrefix`||e.operation?.type===`ArrayKeys`)&&(o=!0),e.operation?.type===`Indirection`&&(s=!0));c.type===`CommandSubstitution`&&(n=!0),c.type===`ParameterExpansion`&&(a=!0,(c.parameter===`@`||c.parameter===`*`)&&(r=!0),Wf(c)&&(t=!0),(c.operation?.type===`VarNamePrefix`||c.operation?.type===`ArrayKeys`)&&(o=!0),c.operation?.type===`Indirection`&&(s=!0)),c.type===`Glob`&&Uf(c.pattern)&&(a=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:i,hasParamExpansion:a,hasVarNamePrefixExpansion:o,hasIndirection:s}}var qf=g(()=>{});function Jf(e,t){let n=`${t}_`,r=[];for(let t of e.state.env.keys())if(t.startsWith(n)){let e=t.slice(n.length),i=Number.parseInt(e,10);!Number.isNaN(i)&&String(i)===e&&r.push(i)}return r.sort((e,t)=>e-t)}function Yf(e,t){let n=`${t}_`,r=`${t}__length`,i=[];for(let t of e.state.env.keys())if(t!==r&&t.startsWith(n)){let e=t.slice(n.length);if(e.startsWith(`_length`))continue;i.push(e)}return i.sort()}function Xf(e){return e.startsWith(`'`)&&e.endsWith(`'`)||e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}var Zf=g(()=>{});function Qf(e){return e.get(`IFS`)??`
204
+ `}function $f(e){return e.get(`IFS`)===``}function ep(e){let t=Qf(e);if(t===``)return!0;for(let e of t)if(e!==` `&&e!==` `&&e!==`
205
+ `)return!1;return!0}function tp(e){let t=!1,n=[];for(let r of e.split(``))r===`-`?t=!0:/[\\^$.*+?()[\]{}|]/.test(r)?n.push(`\\${r}`):r===` `?n.push(`\\t`):r===`
206
+ `?n.push(`\\n`):n.push(r);return t&&n.push(`\\-`),n.join(``)}function q(e){let t=e.get(`IFS`);return t===void 0?` `:t[0]||``}function np(e){return ap.includes(e)}function rp(e){let t=new Set,n=new Set;for(let r of e)np(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function ip(e,t){if(t===``)return{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e===``)return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:n,nonWhitespace:r}=rp(t),i=[],a=0,o=!1,s=!1,c=a;for(;a<e.length&&n.has(e[a]);)a++;if(a>c&&(o=!0),a>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(r.has(e[a]))for(i.push(``),a++;a<e.length&&n.has(e[a]);)a++;for(;a<e.length;){let t=a;for(;a<e.length;){let t=e[a];if(n.has(t)||r.has(t))break;a++}if(i.push(e.substring(t,a)),a>=e.length){s=!1;break}let o=a;for(;a<e.length&&n.has(e[a]);)a++;if(a<e.length&&r.has(e[a])){for(a++;a<e.length&&n.has(e[a]);)a++;for(;a<e.length&&r.has(e[a]);)for(i.push(``),a++;a<e.length&&n.has(e[a]);)a++}a>=e.length&&a>o&&(s=!0)}return{words:i,hadLeadingDelimiter:o,hadTrailingDelimiter:s}}function J(e,t){return ip(e,t).words}var ap,op=g(()=>{ap=`
207
+ `});function sp(e,t){return e.state.namerefs?.has(t)??!1}function cp(e,t){return e.state.invalidNamerefs?.has(t)??!1}function lp(e,t,n=100){if(!sp(e,t)||cp(e,t))return t;let r=new Set,i=t;for(;n-- >0;){if(r.has(i))return;if(r.add(i),!sp(e,i))return i;let t=e.state.env.get(i);if(t===void 0||t===``||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(t))return i;i=t}}function up(e,t){if(sp(e,t))return e.state.env.get(t)}var dp=g(()=>{});function fp(e,t){let n=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(t,n)=>e.state.env.get(n)??``);return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(t,n)=>e.state.env.get(n)??``),n}function Y(e,t){return t===`FUNCNAME`?(e.state.funcNameStack??[]).map((e,t)=>[t,e]):t===`BASH_LINENO`?(e.state.callLineStack??[]).map((e,t)=>[t,String(e)]):t===`BASH_SOURCE`?(e.state.sourceStack??[]).map((e,t)=>[t,e]):e.state.associativeArrays?.has(t)?Yf(e,t).map(n=>[n,e.state.env.get(`${t}_${n}`)??``]):Jf(e,t).map(n=>[n,e.state.env.get(`${t}_${n}`)??``])}function pp(e,t){return t===`FUNCNAME`?(e.state.funcNameStack?.length??0)>0:t===`BASH_LINENO`?(e.state.callLineStack?.length??0)>0:t===`BASH_SOURCE`?(e.state.sourceStack?.length??0)>0:e.state.associativeArrays?.has(t)?Yf(e,t).length>0:Jf(e,t).length>0}async function X(e,t,n=!0,r=!1){switch(t){case`?`:return String(e.state.lastExitCode);case`$`:return String(e.state.virtualPid);case`#`:return e.state.env.get(`#`)||`0`;case`@`:return e.state.env.get(`@`)||``;case`_`:return e.state.lastArg;case`-`:{let t=``;return t+=`h`,e.state.options.errexit&&(t+=`e`),e.state.options.noglob&&(t+=`f`),e.state.options.nounset&&(t+=`u`),e.state.options.verbose&&(t+=`v`),e.state.options.xtrace&&(t+=`x`),t+=`B`,e.state.options.noclobber&&(t+=`C`),t+=`s`,t}case`*`:{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(t===0)return``;let n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return n.join(q(e.state.env))}case`0`:return e.state.env.get(`0`)||`bash`;case`PWD`:return e.state.env.get(`PWD`)??``;case`OLDPWD`:return e.state.env.get(`OLDPWD`)??``;case`PPID`:return String(e.state.virtualPpid);case`UID`:return String(e.state.virtualUid);case`EUID`:return String(e.state.virtualUid);case`RANDOM`:return String(Math.floor(Math.random()*32768));case`SECONDS`:return String(Math.floor((Date.now()-e.state.startTime)/1e3));case`BASH_VERSION`:return Du;case`!`:return String(e.state.lastBackgroundPid);case`BASHPID`:return String(e.state.bashPid);case`LINENO`:return String(e.state.currentLine);case`FUNCNAME`:{let t=e.state.funcNameStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new ar(`FUNCNAME`);return``}case`BASH_LINENO`:{let t=e.state.callLineStack?.[0];if(t!==void 0)return String(t);if(n&&e.state.options.nounset)throw new ar(`BASH_LINENO`);return``}case`BASH_SOURCE`:{let t=e.state.sourceStack?.[0];if(t!==void 0)return t;if(n&&e.state.options.nounset)throw new ar(`BASH_SOURCE`);return``}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new cr(`\${${t}}`);let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let t=i[1],r=i[2];if(sp(e,t)){let n=lp(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return``;t=n}}if(r===`@`||r===`*`){let n=Y(e,t);if(n.length>0)return n.map(([,e])=>e).join(` `);let r=e.state.env.get(t);return r===void 0?``:r}if(t===`FUNCNAME`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.funcNameStack?.[t]??``:``}if(t===`BASH_LINENO`){let t=Number.parseInt(r,10);if(!Number.isNaN(t)&&t>=0){let n=e.state.callLineStack?.[t];return n===void 0?``:String(n)}return``}if(t===`BASH_SOURCE`){let t=Number.parseInt(r,10);return!Number.isNaN(t)&&t>=0?e.state.sourceStack?.[t]??``:``}if(e.state.associativeArrays?.has(t)){let i=Xf(r);i=fp(e,i);let a=e.state.env.get(`${t}_${i}`);if(a===void 0&&n&&e.state.options.nounset)throw new ar(`${t}[${r}]`);return a||``}let a;if(/^-?\d+$/.test(r))a=Number.parseInt(r,10);else try{a=await $(e,ud(new Mf,r).expression)}catch{let t=e.state.env.get(r);a=t?Number.parseInt(t,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let n=Y(e,t),r=e.state.currentLine;if(n.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
203
208
  `,``;let i=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+a;return i<0?(e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${r}: ${t}: bad array subscript
204
- `,``):e.state.env.get(`${t}_${i}`)||``}let o=e.state.env.get(`${t}_${a}`);if(o!==void 0)return o;if(a===0){let n=e.state.env.get(t);if(n!==void 0)return n}if(n&&e.state.options.nounset)throw new ar(`${t}[${a}]`);return``}if(/^[1-9][0-9]*$/.test(t)){let r=e.state.env.get(t);if(r===void 0&&n&&e.state.options.nounset)throw new ar(t);return r||``}if(ip(e,t)){let i=op(e,t);if(i===void 0)return``;if(i!==t)return await X(e,i,n,r);let a=e.state.env.get(t);if((a===void 0||a===``)&&n&&e.state.options.nounset)throw new ar(t);return a||``}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(e=>e.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(up(e,t)){let n=e.state.env.get(`${t}_0`);return n===void 0?``:n}if(n&&e.state.options.nounset)throw new ar(t);return``}async function dp(e,t){if(new Set([`?`,`$`,`#`,`_`,`-`,`0`,`PPID`,`UID`,`EUID`,`RANDOM`,`SECONDS`,`BASH_VERSION`,`!`,`BASHPID`,`LINENO`]).has(t))return!0;if(t===`@`||t===`*`)return Number.parseInt(e.state.env.get(`#`)||`0`,10)>0;if(t===`PWD`||t===`OLDPWD`)return e.state.env.has(t);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(ip(e,t)){let n=op(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;t=n}}if(r===`@`||r===`*`)return Y(e,t).length>0?!0:e.state.env.has(t);if(e.state.associativeArrays?.has(t)){let n=qf(r);return e.state.env.has(`${t}_${n}`)}let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else try{i=await $(e,rd(new kf,r).expression)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0,Number.isNaN(i)&&(i=0)}if(i<0){let n=Y(e,t);if(n.length===0)return!1;let r=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+i;return r<0?!1:e.state.env.has(`${t}_${r}`)}return e.state.env.has(`${t}_${i}`)}if(ip(e,t)){let n=op(e,t);return n===void 0||n===t?e.state.env.has(t):dp(e,n)}return!!(e.state.env.has(t)||up(e,t))}var fp=g(()=>{wd(),K(),Ou(),ig(),x(),Jf(),rp(),cp()});async function pp(e,t){let n=``,r=0;for(;r<t.length;){if(t[r]===`$`){if(t[r+1]===`{`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`{`?e++:t[i]===`}`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]===`(`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await X(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[0-9]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[0-9]/.test(t[i]);)i++;let a=await X(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[*@#?\-!$]/.test(t[r+1]||``)){let i=t[r+1],a=await X(e,i);n+=a,r+=2;continue}}if(t[r]===`"`){for(n+=`"`,r++;r<t.length&&t[r]!==`"`;)if(t[r]===`$`&&/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await X(e,t.slice(r+1,i));n+=a,r=i}else t[r]===`\\`?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+=`"`,r++);continue}n+=t[r],r++}return n}async function mp(e,t){let n=t,r=t.startsWith(`"`)&&t.endsWith(`"`),i=t.startsWith(`'`)&&t.endsWith(`'`);if((r||i)&&(n=t.slice(1,-1)),i)return n;let a=``,o=0;for(;o<n.length;)if(n[o]===`$`)if(n[o+1]===`(`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`(`&&n[r-1]===`$`||n[r]===`(`?t++:n[r]===`)`&&t--,r++;let i=n.slice(o+2,r-1);if(e.execFn){let t=await e.execFn(i,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=r}else if(n[o+1]===`{`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`{`?t++:n[r]===`}`&&t--,r++;let i=await X(e,n.slice(o+2,r-1));a+=i,o=r}else if(/[a-zA-Z_]/.test(n[o+1]||``)){let t=o+1;for(;t<n.length&&/[a-zA-Z0-9_]/.test(n[t]);)t++;let r=await X(e,n.slice(o+1,t));a+=r,o=t}else a+=n[o],o++;else if(n[o]==="`"){let t=o+1;for(;t<n.length&&n[t]!=="`";)t++;let r=n.slice(o+1,t);if(e.execFn){let t=await e.execFn(r,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=t+1}else a+=n[o],o++;return a}var hp=g(()=>{fp()});function gp(e,t,n,r,i){let a=n??1;a===0&&(a=1);let o=Math.abs(a),s=[],c=0;r?.match(/^-?0\d/)&&(c=Math.max(c,r.replace(/^-/,``).length)),i?.match(/^-?0\d/)&&(c=Math.max(c,i.replace(/^-/,``).length));let l=e=>{if(c>0){let t=e<0,n=String(Math.abs(e)).padStart(c,`0`);return t?`-${n}`:n}return String(e)};if(e<=t)for(let n=e,r=0;n<=t&&r<yp;n+=o,r++)s.push(l(n));else for(let n=e,r=0;n>=t&&r<yp;n-=o,r++)s.push(l(n));return s}function _p(e,t,n){let r=n??1;r===0&&(r=1);let i=e.charCodeAt(0),a=t.charCodeAt(0),o=Math.abs(r);if(e>=`A`&&e<=`Z`&&t>=`a`&&t<=`z`||e>=`a`&&e<=`z`&&t>=`A`&&t<=`Z`){let r=n===void 0?``:`..${n}`;throw new ur(`{${e}..${t}${r}}: invalid sequence`)}let s=[];if(i<=a)for(let e=i,t=0;e<=a&&t<yp;e+=o,t++)s.push(String.fromCharCode(e));else for(let e=i,t=0;e>=a&&t<yp;e-=o,t++)s.push(String.fromCharCode(e));return s}function vp(e,t,n,r,i){let a=n===void 0?``:`..${n}`;return typeof e==`number`&&typeof t==`number`?{expanded:gp(e,t,n,r,i),literal:`{${e}..${t}${a}}`}:typeof e==`string`&&typeof t==`string`?{expanded:_p(e,t,n),literal:`{${e}..${t}${a}}`}:{expanded:null,literal:`{${e}..${t}${a}}`}}var yp,bp=g(()=>{x(),yp=1e4});function xp(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!==`SimpleCommand`)return null;let i=r;if(i.name!==null||i.args.length!==0||i.assignments.length!==0||i.redirections.length!==1)return null;let a=i.redirections[0];return a.operator!==`<`||a.target.type!==`Word`?null:{target:a.target}}var Sp=g(()=>{});function Cp(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function wp(e){let t=``,n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function Tp(e){return e.replace(/([*?[\]\\()|])/g,`\\$1`)}function Ep(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`)}var Dp=g(()=>{});function Z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var Op=g(()=>{});function Q(e,t,n=!1){let r=``,i=0;for(;i<e.length;){let a=e[i];if(n&&(a===`@`||a===`*`||a===`+`||a===`?`||a===`!`)&&i+1<e.length&&e[i+1]===`(`){let o=kp(e,i+1);if(o!==-1){let s=Ap(e.slice(i+2,o)).map(e=>Q(e,t,n)),c=s.length>0?s.join(`|`):`(?:)`;a===`@`?r+=`(?:${c})`:a===`*`?r+=`(?:${c})*`:a===`+`?r+=`(?:${c})+`:a===`?`?r+=`(?:${c})?`:a===`!`&&(r+=`(?!(?:${c})$).*`),i=o+1;continue}}if(a===`\\`)if(i+1<e.length){let t=e[i+1];/[\\^$.|+(){}[\]*?]/.test(t)?r+=`\\${t}`:r+=t,i+=2}else r+=`\\\\`,i++;else if(a===`*`)r+=t?`.*`:`.*?`,i++;else if(a===`?`)r+=`.`,i++;else if(a===`[`){let t=jp(e,i);if(t===-1)r+=`\\[`,i++;else{let n=e.slice(i+1,t);r+=Mp(n),i=t+1}}else /[\^$.|+(){}]/.test(a)?(r+=`\\${a}`,i++):(r+=a,i++)}return r}function kp(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Ap(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function jp(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){if(e[n]===`\\`&&n+1<e.length){n+=2;continue}if(e[n]===`]`)return n;if(e[n]===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}n++}return-1}function Mp(e){let t=`[`,n=0;for((e[0]===`^`||e[0]===`!`)&&(t+=`^`,n++);n<e.length;){if(e[n]===`'`){let r=e.indexOf(`'`,n+1);if(r!==-1){let i=e.slice(n+1,r);for(let e of i)e===`\\`?t+=`\\\\`:e===`]`?t+=`\\]`:e===`^`&&t===`[`?t+=`\\^`:t+=e;n=r+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r);t+=Np(i),n=r+2;continue}}let r=e[n];r===`\\`?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+=`\\\\`,n++):r===`-`&&n>0&&n<e.length-1?(t+=`-`,n++):r===`^`&&n===0?(t+=`^`,n++):(r===`]`&&n===0?t+=`\\]`:t+=r,n++)}return t+=`]`,t}function Np(e){return Pp.get(e)??``}var Pp,Fp=g(()=>{Pp=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9A-Fa-f`]])});function Ip(e,t,n,r){if(n===`prefix`)return M(`^${t}`,`s`).replace(e,``);let i=M(`${t}$`,`s`);if(r)return i.replace(e,``);for(let t=e.length;t>=0;t--){let n=e.slice(t);if(i.test(n))return e.slice(0,t)}return e}function Lp(e,t){let n=Array.from(e.state.env.keys()),r=new Set,i=e.state.associativeArrays??new Set,a=new Set;for(let e of n){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);t&&a.add(t[1]);let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);n&&a.add(n[1])}let o=e=>{for(let t of i){let n=`${t}_`;if(e.startsWith(n)&&e!==t)return!0}return!1};for(let e of n)if(e.startsWith(t))if(e.includes(`__`)){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);n?.[1].startsWith(t)&&r.add(n[1])}else if(/_\d+$/.test(e)){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);n?.[1].startsWith(t)&&r.add(n[1])}else o(e)||r.add(e);return[...r].sort()}var Rp=g(()=>{ta()});function zp(e,t){let n=(e,t=2)=>String(e).padStart(t,`0`);if(e===``)return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;let r=``,i=0;for(;i<e.length;)if(e[i]===`%`){if(i+1>=e.length){r+=`%`,i++;continue}let a=e[i+1];switch(a){case`H`:r+=n(t.getHours());break;case`M`:r+=n(t.getMinutes());break;case`S`:r+=n(t.getSeconds());break;case`d`:r+=n(t.getDate());break;case`m`:r+=n(t.getMonth()+1);break;case`Y`:r+=t.getFullYear();break;case`y`:r+=n(t.getFullYear()%100);break;case`I`:{let e=t.getHours()%12;e===0&&(e=12),r+=n(e);break}case`p`:r+=t.getHours()<12?`AM`:`PM`;break;case`P`:r+=t.getHours()<12?`am`:`pm`;break;case`%`:r+=`%`;break;case`a`:r+=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.getDay()];break;case`b`:r+=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()];break;default:r+=`%${a}`}i+=2}else r+=e[i],i++;return r}function Bp(e,t){let n=``,r=0,i=e.state.env.get(`USER`)||e.state.env.get(`LOGNAME`)||`user`,a=e.state.env.get(`HOSTNAME`)||`localhost`,o=a.split(`.`)[0],s=e.state.env.get(`PWD`)||`/`,c=e.state.env.get(`HOME`)||`/`,l=s.startsWith(c)?`~${s.slice(c.length)}`:s,u=s.split(`/`).pop()||s,d=new Date,f=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],p=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],m=e.state.env.get(`__COMMAND_NUMBER`)||`1`;for(;r<t.length;){let e=t[r];if(e===`\\`){if(r+1>=t.length){n+=`\\`,r++;continue}let e=t[r+1];if(e>=`0`&&e<=`7`){let e=``,i=r+1;for(;i<t.length&&i<r+4&&t[i]>=`0`&&t[i]<=`7`;)e+=t[i],i++;let a=Number.parseInt(e,8)%256;n+=String.fromCharCode(a),r=i;continue}switch(e){case`\\`:n+=`\\`,r+=2;break;case`a`:n+=`\x07`,r+=2;break;case`e`:n+=`\x1B`,r+=2;break;case`n`:n+=`
205
- `,r+=2;break;case`r`:n+=`\r`,r+=2;break;case`$`:n+=`$`,r+=2;break;case`[`:case`]`:r+=2;break;case`u`:n+=i,r+=2;break;case`h`:n+=o,r+=2;break;case`H`:n+=a,r+=2;break;case`w`:n+=l,r+=2;break;case`W`:n+=u,r+=2;break;case`d`:{let e=String(d.getDate()).padStart(2,` `);n+=`${f[d.getDay()]} ${p[d.getMonth()]} ${e}`,r+=2;break}case`t`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`),i=String(d.getSeconds()).padStart(2,`0`);n+=`${e}:${t}:${i}`,r+=2;break}case`T`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=String(d.getSeconds()).padStart(2,`0`);n+=`${t}:${i}:${a}`,r+=2;break}case`@`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=d.getHours()<12?`AM`:`PM`;n+=`${t}:${i} ${a}`,r+=2;break}case`A`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`);n+=`${e}:${t}`,r+=2;break}case`D`:if(r+2<t.length&&t[r+2]===`{`){let e=t.indexOf(`}`,r+3);if(e!==-1){let i=t.slice(r+3,e);n+=zp(i,d),r=e+1}else n+=`\\D`,r+=2}else n+=`\\D`,r+=2;break;case`s`:n+=`bash`,r+=2;break;case`v`:n+=`5.0`,r+=2;break;case`V`:n+=`5.0.0`,r+=2;break;case`j`:n+=`0`,r+=2;break;case`l`:n+=`tty`,r+=2;break;case`#`:n+=m,r+=2;break;case`!`:n+=m,r+=2;break;case`x`:n+=`\\x`,r+=2;break;default:n+=`\\${e}`,r+=2}}else n+=e,r++}return n}var Vp=g(()=>{});function Hp(e){if(e===``)return`''`;if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let t=`$'`;for(let n of e)switch(n){case`'`:t+=`\\'`;break;case`\\`:t+=`\\\\`;break;case`
206
- `:t+=`\\n`;break;case`\r`:t+=`\\r`;break;case` `:t+=`\\t`;break;default:{let e=n.charCodeAt(0);e<32||e===127?t+=`\\${e.toString(8).padStart(3,`0`)}`:t+=n}}return`${t}'`}return`'${e}'`}var Up=g(()=>{});function Wp(e,t){return e.state.readonlyVars?.has(t)??!1}var Gp=g(()=>{x()});function Kp(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return``;let n=``,r=e.state.env.has(`${t}__length`)||Array.from(e.state.env.keys()).some(e=>e.startsWith(`${t}_`)&&/^[0-9]+$/.test(e.slice(t.length+1))),i=e.state.associativeArrays?.has(t)??!1;return r&&!i&&(n+=`a`),i&&(n+=`A`),e.state.integerVars?.has(t)&&(n+=`i`),ip(e,t)&&(n+=`n`),Wp(e,t)&&(n+=`r`),e.state.exportedVars?.has(t)&&(n+=`x`),n}var qp=g(()=>{cp(),Gp()});async function Jp(e,t,n,r){return e.coverage?.hit(`bash:expansion:default_value`),(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function Yp(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:assign_default`),(r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let a=await i(e,n.word.parts,r.inDoubleQuotes),o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let[,t,n]=o,r;if(/^\d+$/.test(n))r=Number.parseInt(n,10);else{try{r=await $(e,rd(new kf,n).expression)}catch{let t=e.state.env.get(n);r=t?Number.parseInt(t,10):0}Number.isNaN(r)&&(r=0)}e.state.env.set(`${t}_${r}`,a);let i=Number.parseInt(e.state.env.get(`${t}__length`)||`0`,10);r>=i&&e.state.env.set(`${t}__length`,String(r+1))}else e.state.env.set(t,a);return a}return r.effectiveValue}async function Xp(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:error_if_unset`),r.isUnset||n.checkEmpty&&r.isEmpty){let a=n.word?await i(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new or(1,``,`bash: ${a}
207
- `)}return r.effectiveValue}async function Zp(e,t,n,r){return e.coverage?.hit(`bash:expansion:use_alternative`),!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):``}async function Qp(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_removal`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=Q(t.pattern,n.greedy,o);else if(t.type===`Literal`)a+=Q(t.value,n.greedy,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=Z(n)}else if(t.type===`ParameterExpansion`){let r=await i(e,t);a+=Q(r,n.greedy,o)}else{let n=await i(e,t);a+=Z(n)}if(n.side===`prefix`)return M(`^${a}`,`s`).replace(t,``);let s=M(`${a}$`,`s`);if(n.greedy)return s.replace(t,``);for(let e=t.length;e>=0;e--){let n=t.slice(e);if(s.test(n))return t.slice(0,e)}return t}async function $p(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_replacement`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=Q(t.pattern,!0,o);else if(t.type===`Literal`)a+=Q(t.value,!0,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=Z(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);a+=Q(n,!0,o)}else{let n=await i(e,t);a+=Z(n)}let s=n.replacement?await r(e,n.replacement.parts):``;if(n.anchor===`start`?a=`^${a}`:n.anchor===`end`&&(a=`${a}$`),a===``)return t;let c=n.all?`gs`:`s`;try{let r=M(a,c);if(n.all){let n=``,i=0,a=0,o=e.limits.maxStringLength,c=r.exec(t);for(;c!==null&&!(c[0].length===0&&c.index===t.length);){if(n+=t.slice(i,c.index)+s,i=c.index+c[0].length,c[0].length===0&&i++,a++,a%100==0&&n.length>o)throw new b(`pattern replacement: string length limit exceeded (${o} bytes)`,`string_length`);c=r.exec(t)}return n+=t.slice(i),n}return r.replace(t,s)}catch(e){if(e instanceof b)throw e;return t}}function em(e,t,n){e.coverage?.hit(`bash:expansion:length`);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=Y(e,t);return n.length>0?String(n.length):e.state.env.get(t)===void 0?`0`:`1`}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&up(e,t)){if(t===`FUNCNAME`){let t=e.state.funcNameStack?.[0]||``;return String([...t].length)}if(t===`BASH_LINENO`){let t=e.state.callLineStack?.[0];return String(t===void 0?0:[...String(t)].length)}let n=e.state.env.get(`${t}_0`)||``;return String([...n].length)}return String([...n].length)}async function tm(e,t,n,r){e.coverage?.hit(`bash:expansion:substring`);let i=await $(e,r.offset.expression),a=r.length?await $(e,r.length.expression):void 0;if(t===`@`||t===`*`){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);let r=e.state.env.get(`0`)||`bash`,o,s;if(i<=0)if(o=[r,...n],i<0){if(s=o.length+i,s<0)return``}else s=0;else o=n,s=i-1;if(s<0||s>=o.length)return``;if(a!==void 0){let e=a<0?o.length+a:s+a;return o.slice(s,Math.max(s,e)).join(` `)}return o.slice(s).join(` `)}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let t=o[1];if(e.state.associativeArrays?.has(t))throw new or(1,``,`bash: \${${t}[@]: 0: 3}: bad substitution
208
- `);let n=Y(e,t),r=0;if(i<0){if(n.length>0){let e=n[n.length-1][0],t=(typeof e==`number`?e:0)+1+i;if(t<0||(r=n.findIndex(([e])=>typeof e==`number`&&e>=t),r<0))return``}}else if(r=n.findIndex(([e])=>typeof e==`number`&&e>=i),r<0)return``;if(a!==void 0){if(a<0)throw new sr(`${o[1]}[@]: substring expression < 0`);return n.slice(r,r+a).map(([,e])=>e).join(` `)}return n.slice(r).map(([,e])=>e).join(` `)}let s=[...n],c=i;if(c<0&&(c=Math.max(0,s.length+c)),a!==void 0){if(a<0){let e=s.length+a;return s.slice(c,Math.max(c,e)).join(``)}return s.slice(c,c+a).join(``)}return s.slice(c).join(``)}async function nm(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:case_modification`),n.pattern){let a=e.state.shoptOptions.extglob,o=``;for(let t of n.pattern.parts)if(t.type===`Glob`)o+=Q(t.pattern,!0,a);else if(t.type===`Literal`)o+=Q(t.value,!0,a);else if(t.type===`SingleQuoted`||t.type===`Escaped`)o+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);o+=Z(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);o+=Q(n,!0,a)}let s=M(`^(?:${o})$`),c=n.direction===`upper`?e=>e.toUpperCase():e=>e.toLowerCase(),l=``,u=!1;for(let e of t)!n.all&&u?l+=e:s.test(e)?(l+=c(e),u=!0):l+=e;return l}return n.direction===`upper`?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function rm(e,t,n,r,i){e.coverage?.hit(`bash:expansion:transform`);let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(a&&i.operator===`Q`)return Y(e,a[1]).map(([,e])=>Hp(e)).join(` `);if(a&&i.operator===`a`)return Kp(e,a[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&i.operator===`a`)return Kp(e,o[1]);switch(i.operator){case`Q`:return r?``:Hp(n);case`P`:return Bp(e,n);case`a`:return Kp(e,t);case`A`:return r?``:`${t}=${Hp(n)}`;case`E`:return n.replace(/\\([\\abefnrtv'"?])/g,(e,t)=>{switch(t){case`\\`:return`\\`;case`a`:return`\x07`;case`b`:return`\b`;case`e`:return`\x1B`;case`f`:return`\f`;case`n`:return`
209
- `;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`'`:return`'`;case`"`:return`"`;case`?`:return`?`;default:return t}});case`K`:case`k`:return r?``:Hp(n);case`u`:return n.charAt(0).toUpperCase()+n.slice(1);case`U`:return n.toUpperCase();case`L`:return n.toLowerCase();default:return n}}async function im(e,t,n,r,i,a,o=!1){if(e.coverage?.hit(`bash:expansion:indirection`),ip(e,t))return sp(e,t)||``;let s=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(i.innerOp?.type===`UseAlternative`)return``;throw new cr(`\${!${t}}`)}let c=n;if(s&&(c===``||c.includes(` `)))throw new cr(`\${!${t}}`);let l=c.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(l&&l[1].includes(`~`))throw new cr(`\${!${t}}`);return i.innerOp?a(e,{type:`ParameterExpansion`,parameter:c,operation:i.innerOp},o):await X(e,c)}function am(e,t){e.coverage?.hit(`bash:expansion:array_keys`);let n=Y(e,t.array).map(([e])=>String(e));return t.star?n.join(q(e.state.env)):n.join(` `)}function om(e,t){e.coverage?.hit(`bash:expansion:var_name_prefix`);let n=Lp(e,t.prefix);return t.star?n.join(q(e.state.env)):n.join(` `)}function sm(e,t,n,r){let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t===`*`)return{isEmpty:i===0,effectiveValue:n};if(t===`@`)return{isEmpty:i===0||i===1&&e.state.env.get(`1`)===``,effectiveValue:n};if(a){let[,t,n]=a,i=Y(e,t);if(i.length===0)return{isEmpty:!0,effectiveValue:``};if(n===`*`){let t=q(e.state.env),n=i.map(([,e])=>e).join(t);return{isEmpty:r?n===``:!1,effectiveValue:n}}return{isEmpty:i.length===1&&i.every(([,e])=>e===``),effectiveValue:i.map(([,e])=>e).join(` `)}}return{isEmpty:n===``,effectiveValue:n}}var cm=g(()=>{wd(),K(),ta(),ig(),x(),rp(),cp(),Op(),Fp(),Rp(),Vp(),Up(),fp(),qp()});function lm(e){let t=0;for(;t<e.length;){let n=e[t];if(n===`\\`&&t+1<e.length){t+=2;continue}if(n===`'`){let n=e.indexOf(`'`,t+1);if(n!==-1){t=n+1;continue}}if(n===`$`&&t+1<e.length&&e[t+1]===`(`||n==="`")return!0;t++}return!1}function um(e,t){let n=1,r=t,i=!1,a=!1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`&&!i&&r+1<e.length){r+=2;continue}if(t===`'`&&!a){i=!i,r++;continue}if(t===`"`&&!i){a=!a,r++;continue}if(!i&&!a){if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}r++}return-1}async function dm(e,t){let n=new kf,r;try{r=n.parse(t)}catch{return``}let i=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let a=new Map(e.state.env),o=e.state.cwd,s=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let t=await e.executeScript(r),n=t.exitCode;return e.state.env=a,e.state.cwd=o,e.state.suppressVerbose=s,e.state.lastExitCode=n,e.state.env.set(`?`,String(n)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr),e.state.bashPid=i,t.stdout.replace(/\n+$/,``)}catch(t){if(e.state.env=a,e.state.cwd=o,e.state.bashPid=i,e.state.suppressVerbose=s,t instanceof b)throw t;return t instanceof or?(e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stdout?.replace(/\n+$/,``)??``):``}}function fm(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=Tp(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=pm(e,t.slice(r+1,i));n+=Tp(a),r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}function pm(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}async function mm(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=Tp(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=await hm(e,t.slice(r+1,i));n+=Tp(a),r=i+1;continue}}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=um(t,r+2);if(i!==-1){let a=await dm(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await dm(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}async function hm(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=um(t,r+2);if(i!==-1){let a=await dm(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await dm(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}var gm=g(()=>{K(),x(),Dp()});function _m(e,t){if(!t.startsWith(`~`))return t;e.coverage?.hit(`bash:expansion:tilde`);let n=e.state.env.get(`HOME`)===void 0?`/home/user`:e.state.env.get(`HOME`);if(t===`~`||t.startsWith(`~/`))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let i=t.slice(1,r),a=t.slice(r);return a!==``&&!a.startsWith(`/`)?t:i===`root`?`/root${a}`:t}var vm=g(()=>{});async function ym(e,t,n,r){let i=``;for(let a of t.parts)if(a.type===`Glob`)i+=Q(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)i+=Q(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)i+=Z(a.value);else if(a.type===`DoubleQuoted`){let t=await n(e,a.parts);i+=Z(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);i+=Q(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);i+=Z(t)}return i}async function bm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternReplacement`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=Y(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``;l.pattern&&(f=await ym(e,l.pattern,n,r));let p=l.replacement?await n(e,l.replacement.parts):``,m=f;l.anchor===`start`?m=`^${f}`:l.anchor===`end`&&(m=`${f}$`);let h=[];try{let e=M(m,l.all?`g`:``);for(let t of d)h.push(e.replace(t,p))}catch{h.push(...d)}if(c){let t=q(e.state.env);return{values:[h.join(t)],quoted:!0}}return{values:h,quoted:!0}}async function xm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternRemoval`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=Y(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``,p=e.state.shoptOptions.extglob;if(l.pattern)for(let t of l.pattern.parts)if(t.type===`Glob`)f+=Q(t.pattern,l.greedy,p);else if(t.type===`Literal`)f+=Q(t.value,l.greedy,p);else if(t.type===`SingleQuoted`||t.type===`Escaped`)f+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);f+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);f+=Q(n,l.greedy,p)}else{let n=await r(e,t);f+=Z(n)}let m=[];for(let e of d)m.push(Ip(e,f,l.side,l.greedy));if(c){let t=q(e.state.env);return{values:[m.join(t)],quoted:!0}}return{values:m,quoted:!0}}var Sm=g(()=>{ta(),rp(),Op(),Fp(),Rp(),fp()});async function Cm(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`DefaultValue`&&n.parts[0].operation?.type!==`UseAlternative`&&n.parts[0].operation?.type!==`AssignDefault`)return null;let r=n.parts[0],i=r.operation,a=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,s=!1;if(a){let t=a[1];s=a[2]===`*`;let n=Y(e,t),r=n.length>0||e.state.env.has(t),c=n.length===0||n.length===1&&n.every(([,e])=>e===``),l=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?r&&!(l&&c):!r||l&&c,!o){if(n.length>0){let t=n.map(([,e])=>e);if(s){let n=q(e.state.env);return{values:[t.join(n)],quoted:!0}}return{values:t,quoted:!0}}let r=e.state.env.get(t);return r===void 0?{values:[],quoted:!0}:{values:[r],quoted:!0}}}else{let t=r.parameter,n=await dp(e,t),a=await X(e,t),s=a===``,c=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?n&&!(c&&s):!n||c&&s,!o)return{values:[a],quoted:!0}}if(o&&i.word){let t=i.word.parts,n=null,r=!1;for(let e of t)if(e.type===`ParameterExpansion`&&!e.operation){let t=e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){n=t[1],r=t[2]===`*`;break}}if(n){let t=Y(e,n);if(t.length>0){let n=t.map(([,e])=>e);if(r||s){let t=q(e.state.env);return{values:[n.join(t)],quoted:!0}}return{values:n,quoted:!0}}let i=e.state.env.get(n);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}}return null}async function wm(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0],o=-1,s=``,c=!1,l=null;for(let e=0;e<a.parts.length;e++){let t=a.parts[e];if(t.type===`ParameterExpansion`&&(t.operation?.type===`PatternRemoval`||t.operation?.type===`PatternReplacement`)){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){o=e,s=n[1],c=n[2]===`*`,l=t.operation;break}}}if(o===-1||o===0&&o===a.parts.length-1)return null;let u=``;for(let t=0;t<o;t++)u+=await r(e,a.parts[t]);let d=``;for(let t=o+1;t<a.parts.length;t++)d+=await r(e,a.parts[t]);let f=Y(e,s),p=f.map(([,e])=>e);if(f.length===0){let t=e.state.env.get(s);if(t!==void 0)p=[t];else{if(c)return{values:[u+d],quoted:!0};let e=u+d;return{values:e?[e]:[],quoted:!0}}}if(l?.type===`PatternRemoval`){let t=l,n=``,a=e.state.shoptOptions.extglob;if(t.pattern)for(let o of t.pattern.parts)if(o.type===`Glob`)n+=Q(o.pattern,t.greedy,a);else if(o.type===`Literal`)n+=Q(o.value,t.greedy,a);else if(o.type===`SingleQuoted`||o.type===`Escaped`)n+=Z(o.value);else if(o.type===`DoubleQuoted`){let t=await i(e,o.parts);n+=Z(t)}else if(o.type===`ParameterExpansion`){let i=await r(e,o);n+=Q(i,t.greedy,a)}else{let t=await r(e,o);n+=Z(t)}p=p.map(e=>Ip(e,n,t.side,t.greedy))}else if(l?.type===`PatternReplacement`){let t=l,n=``;if(t.pattern)for(let a of t.pattern.parts)if(a.type===`Glob`)n+=Q(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)n+=Q(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)n+=Z(a.value);else if(a.type===`DoubleQuoted`){let t=await i(e,a.parts);n+=Z(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);n+=Q(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);n+=Z(t)}let a=t.replacement?await i(e,t.replacement.parts):``,o=n;t.anchor===`start`?o=`^${n}`:t.anchor===`end`&&(o=`${n}$`);try{let e=M(o,t.all?`g`:``);p=p.map(t=>e.replace(t,a))}catch{}}if(c){let t=q(e.state.env);return{values:[u+p.join(t)+d],quoted:!0}}return p.length===1?{values:[u+p[0]+d],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+d],quoted:!0}}async function Tm(e,t,n,r){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=``,s=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&!t.operation){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){a=e,o=n[1],s=n[2]===`*`;break}}}if(a===-1)return null;let c=``;for(let t=0;t<a;t++)c+=await r(e,i.parts[t]);let l=``;for(let t=a+1;t<i.parts.length;t++)l+=await r(e,i.parts[t]);let u=Y(e,o),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(o);if(t!==void 0)return{values:[c+t+l],quoted:!0};if(s)return{values:[c+l],quoted:!0};let n=c+l;return{values:n?[n]:[],quoted:!0}}if(s){let t=q(e.state.env);return{values:[c+d.join(t)+l],quoted:!0}}return d.length===1?{values:[c+d[0]+l],quoted:!0}:{values:[c+d[0],...d.slice(1,-1),d[d.length-1]+l],quoted:!0}}var Em=g(()=>{ta(),rp(),Op(),Fp(),Rp(),fp()});async function Dm(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==`ParameterExpansion`||r.parts[0].operation?.type!==`Substring`)return null;let i=r.parts[0],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],s=a[2]===`*`,c=i.operation;if(e.state.associativeArrays?.has(o))throw new or(1,``,`bash: \${${o}[@]: 0: 3}: bad substitution
210
- `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=Y(e,o),f=0;if(l<0){if(d.length>0){let e=d[d.length-1][0],t=(typeof e==`number`?e:0)+1+l;if(t<0)return{values:[],quoted:!0};f=d.findIndex(([e])=>typeof e==`number`&&e>=t),f<0&&(f=d.length)}}else f=d.findIndex(([e])=>typeof e==`number`&&e>=l),f<0&&(f=d.length);let p;if(u!==void 0){if(u<0)throw new sr(`${o}[@]: substring expression < 0`);p=d.slice(f,f+u).map(([,e])=>e)}else p=d.slice(f).map(([,e])=>e);if(p.length===0)return{values:[],quoted:!0};if(s){let t=q(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,quoted:!0}}function Om(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`Transform`)return null;let r=n.parts[0],i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let a=i[1],o=i[2]===`*`,s=r.operation,c=Y(e,a);if(c.length===0){let t=e.state.env.get(a);if(t!==void 0){let n;switch(s.operator){case`a`:n=``;break;case`P`:n=Bp(e,t);break;case`Q`:n=Hp(t);break;default:n=t}return{values:[n],quoted:!0}}return o?{values:[``],quoted:!0}:{values:[],quoted:!0}}let l=Kp(e,a),u;switch(s.operator){case`a`:u=c.map(()=>l);break;case`P`:u=c.map(([,t])=>Bp(e,t));break;case`Q`:u=c.map(([,e])=>Hp(e));break;case`u`:u=c.map(([,e])=>e.charAt(0).toUpperCase()+e.slice(1));break;case`U`:u=c.map(([,e])=>e.toUpperCase());break;case`L`:u=c.map(([,e])=>e.toLowerCase());break;default:u=c.map(([,e])=>e)}if(o){let t=q(e.state.env);return{values:[u.join(t)],quoted:!0}}return{values:u,quoted:!0}}var km=g(()=>{x(),rp(),Vp(),Up(),fp(),qp()});function Am(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`)return null;let r=n.parts[0];if(r.operation)return null;let i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!i)return null;let a=i[1];if(ip(e,a)){let t=sp(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=Y(e,a);if(o.length>0)return{values:o.map(([,e])=>e),quoted:!0};let s=e.state.env.get(a);return s===void 0?{values:[],quoted:!0}:{values:[s],quoted:!0}}function jm(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation)return null;let r=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)||!ip(e,r))return null;let i=sp(e,r);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],s=Y(e,o);if(s.length>0)return{values:s.map(([,e])=>e),quoted:!0};let c=e.state.env.get(o);return c===void 0?{values:[],quoted:!0}:{values:[c],quoted:!0}}var Mm=g(()=>{cp(),fp()});async function Nm(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=o.operation,c=await X(e,o.parameter),l=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l){if(!s.innerOp&&(c===`@`||c===`*`)){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return c===`*`?{values:[n.join(q(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=Y(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return Pm(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return Fm(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=Kp(e,u),n=f.map(()=>t);return d?{values:[n.join(q(e.state.env))],quoted:!0}:{values:n,quoted:!0}}let t=[];for(let[,n]of f){let i={type:`ParameterExpansion`,parameter:`_indirect_elem_`,operation:s.innerOp},a=e.state.env.get(`_indirect_elem_`);e.state.env.set(`_indirect_elem_`,n);try{let n=await r(e,i,!0);t.push(n)}finally{a===void 0?e.state.env.delete(`_indirect_elem_`):e.state.env.set(`_indirect_elem_`,a)}}return d?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let p=e.state.env.get(u);return p===void 0?{values:[],quoted:!0}:{values:[p],quoted:!0}}async function Pm(e,t,n,r,i){let a=i.offset?await $(e,i.offset.expression):0,o=i.length?await $(e,i.length.expression):void 0,s=0;if(a<0){if(t.length>0){let e=t[t.length-1][0],n=(typeof e==`number`?e:0)+1+a;if(n<0||(s=t.findIndex(([e])=>typeof e==`number`&&e>=n),s<0))return{values:[],quoted:!0}}}else if(s=t.findIndex(([e])=>typeof e==`number`&&e>=a),s<0)return{values:[],quoted:!0};let c;if(o!==void 0){if(o<0)throw new sr(`${n}[@]: substring expression < 0`);c=t.slice(s,s+o)}else c=t.slice(s);let l=c.map(([,e])=>e);return r?{values:[l.join(q(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function Fm(e,t,n,r,i,a){let o=i.checkEmpty??!1,s=t.map(([,e])=>e),c=t.length===0,l=t.length===0;if(i.type===`UseAlternative`)return!l&&!(o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(i.type===`DefaultValue`)return(l||o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:r?{values:[s.join(q(e.state.env))],quoted:!0}:{values:s,quoted:!0};if(i.type===`AssignDefault`){if((l||o&&c)&&i.word){let t=await a(e,i.word.parts,!0);return e.state.env.set(`${n}_0`,t),e.state.env.set(`${n}__length`,`1`),{values:[t],quoted:!0}}return r?{values:[s.join(q(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(q(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function Im(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`UseAlternative`&&t[0].operation?.type!==`DefaultValue`)return null;let n=t[0],r=n.operation,i=r?.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await X(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await dp(e,n.parameter),l=await X(e,n.parameter)===``,u=r.checkEmpty??!1,d;if(d=r.type===`UseAlternative`?c&&!(u&&l):!c||u&&l,d){let t=s[1],n=s[2]===`*`,r=Y(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}async function Lm(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`Indirection`)return null;let n=t[0],r=n.operation.innerOp;if(!r||r.type!==`UseAlternative`&&r.type!==`DefaultValue`)return null;let i=r.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await X(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await X(e,n.parameter),l=await dp(e,n.parameter),u=c===``,d=r.checkEmpty??!1,f;if(f=r.type===`UseAlternative`?l&&!(d&&u):!l||d&&u,f){let t=s[1],n=s[2]===`*`,r=Y(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}var Rm=g(()=>{ig(),x(),rp(),fp(),qp()});function zm(e){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return n}async function Bm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`Substring`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=s.offset?await n(e,s.offset.expression):0,l=s.length?await n(e,s.length.expression):void 0,u=Number.parseInt(e.state.env.get(`#`)||`0`,10),d=[];for(let t=1;t<=u;t++)d.push(e.state.env.get(String(t))||``);let f=e.state.env.get(`0`)||`bash`,p;if(c<=0){let e=[f,...d],t=e.length+c;if(t<0)p=[];else{let n=c<0?t:0;if(l!==void 0){let t=l<0?e.length+l:n+l;p=e.slice(n,Math.max(n,t))}else p=e.slice(n)}}else{let e=c-1;if(e>=d.length)p=[];else if(l!==void 0){let t=l<0?d.length+l:e+l;p=d.slice(e,Math.max(e,t))}else p=d.slice(e)}let m=``;for(let t=0;t<a;t++)m+=await r(e,i.parts[t]);let h=``;for(let t=a+1;t<i.parts.length;t++)h+=await r(e,i.parts[t]);if(p.length===0){let e=m+h;return{values:e?[e]:[],quoted:!0}}if(o){let t=q(e.state.env);return{values:[m+p.join(t)+h],quoted:!0}}return p.length===1?{values:[m+p[0]+h],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+h],quoted:!0}}async function Vm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternReplacement`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=zm(e),l=``;for(let t=0;t<a;t++)l+=await n(e,i.parts[t]);let u=``;for(let t=a+1;t<i.parts.length;t++)u+=await n(e,i.parts[t]);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=Q(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)d+=Q(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=Z(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Q(r,!0,e.state.shoptOptions.extglob)}else{let r=await n(e,t);d+=Z(r)}let f=s.replacement?await r(e,s.replacement.parts):``,p=d;s.anchor===`start`?p=`^${d}`:s.anchor===`end`&&(p=`${d}$`);let m=[];try{let e=M(p,s.all?`g`:``);for(let t of c)m.push(e.replace(t,f))}catch{m.push(...c)}if(o){let t=q(e.state.env);return{values:[l+m.join(t)+u],quoted:!0}}return m.length===1?{values:[l+m[0]+u],quoted:!0}:{values:[l+m[0],...m.slice(1,-1),m[m.length-1]+u],quoted:!0}}async function Hm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternRemoval`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=zm(e),l=``;for(let t=0;t<a;t++)l+=await n(e,i.parts[t]);let u=``;for(let t=a+1;t<i.parts.length;t++)u+=await n(e,i.parts[t]);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``,f=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=Q(t.pattern,s.greedy,f);else if(t.type===`Literal`)d+=Q(t.value,s.greedy,f);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=Z(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Q(r,s.greedy,f)}else{let r=await n(e,t);d+=Z(r)}let p=[];for(let e of c)p.push(Ip(e,d,s.side,s.greedy));if(o){let t=q(e.state.env);return{values:[l+p.join(t)+u],quoted:!0}}return p.length===1?{values:[l+p[0]+u],quoted:!0}:{values:[l+p[0],...p.slice(1,-1),p[p.length-1]+u],quoted:!0}}async function Um(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0],i=-1,a=!1;for(let e=0;e<r.parts.length;e++){let t=r.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)){i=e,a=t.parameter===`*`;break}}if(i===-1)return null;let o=r.parts[i];if(o.type===`ParameterExpansion`&&o.operation)return null;let s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=``;for(let t=0;t<i;t++)c+=await n(e,r.parts[t]);let l=``;for(let t=i+1;t<r.parts.length;t++)l+=await n(e,r.parts[t]);if(s===0){if(a)return{values:[c+l],quoted:!0};let e=c+l;return{values:e?[e]:[],quoted:!0}}let u=[];for(let t=1;t<=s;t++)u.push(e.state.env.get(String(t))||``);if(a){let t=q(e.state.env);return{values:[c+u.join(t)+l],quoted:!0}}return u.length===1?{values:[c+u[0]+l],quoted:!0}:{values:[c+u[0],...u.slice(1,-1),u[u.length-1]+l],quoted:!0}}var Wm=g(()=>{ta(),rp(),Op(),Fp(),Rp()});function Gm(e){return new Rf(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations})}async function Km(e,t){if(e.state.options.noglob)return t;let n=Gm(e),r=[];for(let i of t)if(Cp(i,e.state.shoptOptions.extglob)){let e=await n.expand(i);if(e.length>0)r.push(...e);else{if(n.hasFailglob())throw new lr(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function qm(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternReplacement`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=Y(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=Q(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=Q(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Q(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=Z(n)}let d=s.replacement?await n(e,s.replacement.parts):``,f=u;s.anchor===`start`?f=`^${u}`:s.anchor===`end`&&(f=`${u}$`);let p=[];try{let e=M(f,s.all?`g`:``);for(let t of l)p.push(e.replace(t,d))}catch{p.push(...l)}let m=Yf(e.state.env),h=Xf(e.state.env);if(o){let t=q(e.state.env),n=p.join(t);return h?{values:n?[n]:[],quoted:!1}:{values:J(n,m),quoted:!1}}if(h)return{values:p,quoted:!1};let ee=[];for(let e of p)e===``?ee.push(``):ee.push(...J(e,m));return{values:ee,quoted:!1}}async function Jm(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternRemoval`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=Y(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``,d=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=Q(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=Q(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Q(n,s.greedy,d)}else{let n=await r(e,t);u+=Z(n)}let f=[];for(let e of l)f.push(Ip(e,u,s.side,s.greedy));let p=Yf(e.state.env),m=Xf(e.state.env);if(o){let t=q(e.state.env),n=f.join(t);return m?{values:n?[n]:[],quoted:!1}:{values:J(n,p),quoted:!1}}if(m)return{values:f,quoted:!1};let h=[];for(let e of f)e===``?h.push(``):h.push(...J(e,p));return{values:h,quoted:!1}}async function Ym(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`PatternRemoval`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=[];for(let t=1;t<=s;t++)c.push(e.state.env.get(String(t))||``);if(c.length===0)return{values:[],quoted:!1};let l=``,u=e.state.shoptOptions.extglob;if(o.pattern)for(let t of o.pattern.parts)if(t.type===`Glob`)l+=Q(t.pattern,o.greedy,u);else if(t.type===`Literal`)l+=Q(t.value,o.greedy,u);else if(t.type===`SingleQuoted`||t.type===`Escaped`)l+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);l+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);l+=Q(n,o.greedy,u)}else{let n=await r(e,t);l+=Z(n)}let d=[];for(let e of c)d.push(Ip(e,l,o.side,o.greedy));let f=Yf(e.state.env),p=Xf(e.state.env);if(a){let t=q(e.state.env),n=d.join(t);return p?{values:n?[n]:[],quoted:!1}:{values:J(n,f),quoted:!1}}if(p)return{values:d,quoted:!1};let m=[];for(let e of d)e===``?m.push(``):m.push(...J(e,f));return{values:m,quoted:!1}}async function Xm(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`Substring`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=o.offset?await n(e,o.offset.expression):0,c=o.length?await n(e,o.length.expression):void 0,l=Number.parseInt(e.state.env.get(`#`)||`0`,10),u=[];for(let t=1;t<=l;t++)u.push(e.state.env.get(String(t))||``);let d=e.state.env.get(`0`)||`bash`,f;if(s<=0){let e=[d,...u],t=e.length+s;if(t<0)f=[];else{let n=s<0?t:0;if(c!==void 0){let t=c<0?e.length+c:n+c;f=e.slice(n,Math.max(n,t))}else f=e.slice(n)}}else{let e=s-1;if(e>=u.length)f=[];else if(c!==void 0){let t=c<0?u.length+c:e+c;f=u.slice(e,Math.max(e,t))}else f=u.slice(e)}let p=``;for(let n=0;n<i;n++)p+=await r(e,t[n]);let m=``;for(let n=i+1;n<t.length;n++)m+=await r(e,t[n]);let h=Yf(e.state.env),ee=Xf(e.state.env);if(f.length===0){let e=p+m;return e?ee?{values:[e],quoted:!1}:{values:J(e,h),quoted:!1}:{values:[],quoted:!1}}let te;if(a){let t=q(e.state.env),n=p+f.join(t)+m;te=ee?n?[n]:[]:J(n,h)}else if(ee)te=f.length===1?[p+f[0]+m]:[p+f[0],...f.slice(1,-1),f[f.length-1]+m];else{te=[];for(let e=0;e<f.length;e++){let t=f[e];if(e===0&&(t=p+t),e===f.length-1&&(t+=m),t===``)te.push(``);else{let e=J(t,h);te.push(...e)}}}return{values:await Km(e,te),quoted:!1}}async function Zm(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].parameter!==`@`&&t[0].parameter!==`*`||t[0].operation)return null;let n=t[0].parameter===`*`,r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(r===0)return{values:[],quoted:!1};let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=Yf(e.state.env),o=Xf(e.state.env),s=Zf(e.state.env),c;if(n)if(o)c=i.filter(e=>e!==``);else{let t=q(e.state.env);c=J(i.join(t),a)}else if(o)c=i.filter(e=>e!==``);else if(s){c=[];for(let e of i){if(e===``)continue;let t=J(e,a);c.push(...t)}}else{c=[];for(let e of i)if(e===``)c.push(``);else{let t=J(e,a);c.push(...t)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await Km(e,c),quoted:!1}}async function Qm(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],i=n[2]===`*`,a=Y(e,r),o;if(a.length===0){let t=e.state.env.get(r);if(t!==void 0)o=[t];else return{values:[],quoted:!1}}else o=a.map(([,e])=>e);let s=Yf(e.state.env),c=Xf(e.state.env),l=Zf(e.state.env),u;if(i)if(c)u=o.filter(e=>e!==``);else{let t=q(e.state.env);u=J(o.join(t),s)}else if(c)u=o.filter(e=>e!==``);else if(l){u=[];for(let e of o){if(e===``)continue;let t=J(e,s);u.push(...t)}}else{u=[];for(let e of o)if(e===``)u.push(``);else{let t=J(e,s);u.push(...t)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await Km(e,u),quoted:!1}}function $m(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=Lp(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=Yf(e.state.env),a=Xf(e.state.env),o;if(n.star)if(a)o=r;else{let t=q(e.state.env);o=J(r.join(t),i)}else if(a)o=r;else{o=[];for(let e of r){let t=J(e,i);o.push(...t)}}return{values:o,quoted:!1}}function eh(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=Y(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=Yf(e.state.env),a=Xf(e.state.env),o;if(n.star)if(a)o=r;else{let t=q(e.state.env);o=J(r.join(t),i)}else if(a)o=r;else{o=[];for(let e of r){let t=J(e,i);o.push(...t)}}return{values:o,quoted:!1}}async function th(e,t,n){let r=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&!n.operation){r=e;break}}if(r===-1||t.length<=1)return null;let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=[];for(let t=1;t<=i;t++)a.push(e.state.env.get(String(t))||``);let o=``;for(let i=0;i<r;i++)o+=await n(e,t[i]);let s=``;for(let i=r+1;i<t.length;i++)s+=await n(e,t[i]);let c=Yf(e.state.env),l=Xf(e.state.env),u=Zf(e.state.env);if(i===0){let e=o+s;return{values:e?[e]:[],quoted:!1}}let d;{let e=[];for(let t=0;t<a.length;t++){let n=a[t];t===0&&(n=o+n),t===a.length-1&&(n+=s),e.push(n)}if(l)d=e.filter(e=>e!==``);else if(u){d=[];for(let t of e){if(t===``)continue;let e=J(t,c);d.push(...e)}}else{d=[];for(let t of e)if(t===``)d.push(``);else{let e=J(t,c);d.push(...e)}for(;d.length>0&&d[d.length-1]===``;)d.pop()}}return d.length===0?{values:[],quoted:!1}:{values:await Km(e,d),quoted:!1}}var nh=g(()=>{ta(),zf(),x(),rp(),Op(),Dp(),Fp(),Rp(),fp()});async function rh(e,t,n){e.coverage?.hit(`bash:expansion:word_glob`);let r=t.parts,{hasQuoted:i,hasCommandSub:a,hasArrayVar:o,hasArrayAtExpansion:s,hasParamExpansion:c,hasVarNamePrefixExpansion:l,hasIndirection:u}=Uf(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return ih(e,d,i);let f=await ah(e,r,s,l,u,n);if(f!==null)return f;let p=await sh(e,r,n);if(p!==null)return p;let m=await ch(e,r,n);if(m!==null)return m;let h=await dh(e,r,n.expandPart);if(h!==null)return fh(e,h);if((a||o||c)&&!Xf(e.state.env)){let t=Yf(e.state.env),i=n.buildIfsCharClassPattern(t);return fh(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return mh(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function ih(e,t,n){let r=[];for(let i of t)if(!(!n&&i===``))if(!n&&!e.state.options.noglob&&Cp(i,e.state.shoptOptions.extglob)){let t=await ph(e,i);r.push(...t)}else r.push(i);return{values:r,quoted:!1}}async function ah(e,t,n,r,i,a){if(n){let n=Am(e,t);if(n!==null)return n}{let n=jm(e,t);if(n!==null)return n}{let n=await Cm(e,t);if(n!==null)return n}{let r=await wm(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await Tm(e,t,n,a.expandPart);if(r!==null)return r}{let n=await Dm(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=Om(e,t);if(n!==null)return n}{let n=await bm(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await xm(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=oh(e,t);if(n!==null)return n}{let n=await Nm(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await Im(e,t);if(n!==null)return n}{let n=await Lm(e,t);if(n!==null)return n}return null}function oh(e,t){let n=t[0];if(n.type!==`DoubleQuoted`)return null;if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`VarNamePrefix`){let t=n.parts[0].operation,r=Lp(e,t.prefix);return t.star?{values:[r.join(q(e.state.env))],quoted:!0}:{values:r,quoted:!0}}if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`ArrayKeys`){let t=n.parts[0].operation,r=Y(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(q(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function sh(e,t,n){{let r=await Bm(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await Vm(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await Hm(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await Um(e,t,n.expandPart);if(r!==null)return r}return null}async function ch(e,t,n){{let r=await qm(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Jm(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Ym(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Xm(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await Zm(e,t);if(n!==null)return n}{let n=await Qm(e,t);if(n!==null)return n}{let n=$m(e,t);if(n!==null)return n}{let n=eh(e,t);if(n!==null)return n}{let r=await th(e,t,n.expandPart);if(r!==null)return r}return null}function lh(e){if(e.type!==`DoubleQuoted`)return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!==`ParameterExpansion`||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:`array`,name:r[1],atIndex:t,isStar:r[2]===`*`};if(n.parameter===`@`||n.parameter===`*`)return{type:`positional`,atIndex:t,isStar:n.parameter===`*`}}return null}async function uh(e,t,n,r){let i=``;for(let a=0;a<n.atIndex;a++)i+=await r(e,t.parts[a]);let a=``;for(let i=n.atIndex+1;i<t.parts.length;i++)a+=await r(e,t.parts[i]);let o;if(n.type===`array`){if(o=Y(e,n.name).map(([,e])=>e),o.length===0){let t=e.state.env.get(n.name);t!==void 0&&(o=[t])}}else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);o=[];for(let n=1;n<=t;n++)o.push(e.state.env.get(String(n))||``)}if(n.isStar){let t=q(e.state.env),n=o.join(t);return[i+n+a]}if(o.length===0){let e=i+a;return e?[e]:[]}return o.length===1?[i+o[0]+a]:[i+o[0],...o.slice(1,-1),o[o.length-1]+a]}async function dh(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if(lh(e)){r=!0;break}if(!r)return null;let i=Yf(e.state.env),a=Xf(e.state.env),o=[];for(let r of t){let t=lh(r);if(t&&r.type===`DoubleQuoted`){let i=await uh(e,r,t,n);o.push(i)}else if(r.type===`DoubleQuoted`||r.type===`SingleQuoted`){let t=await n(e,r);o.push([t])}else if(r.type===`Literal`)o.push([r.value]);else if(r.type===`ParameterExpansion`){let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let e=J(t,i);o.push(e)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let e=J(t,i);o.push(e)}}}let s=[];for(let e of o)if(e.length!==0)if(s.length===0)s.push(...e);else{let t=s.length-1;s[t]=s[t]+e[0];for(let t=1;t<e.length;t++)s.push(e[t])}return s}async function fh(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(Cp(r,e.state.shoptOptions.extglob)){let t=await ph(e,r);n.push(...t)}else n.push(r);return{values:n,quoted:!1}}async function ph(e,t){let n=new Rf(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new lr(t);return n.hasNullglob()?[]:[t]}async function mh(e,t,n,r,i,a){let o=n.some(e=>e.type===`Glob`);if(!e.state.options.noglob&&o){let n=await a(e,t);if(Cp(n,e.state.shoptOptions.extglob)){let t=await ph(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=wp(r);return Xf(e.state.env)?{values:[i],quoted:!1}:{values:J(i,Yf(e.state.env)),quoted:!1}}if(!i&&!e.state.options.noglob&&Cp(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(Cp(n,e.state.shoptOptions.extglob)){let t=await ph(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1}}}if(r===``&&!i)return{values:[],quoted:!1};if(o&&!i){let t=wp(r);return Xf(e.state.env)?{values:[t],quoted:!1}:{values:J(t,Yf(e.state.env)),quoted:!1}}return{values:[r],quoted:i}}var hh=g(()=>{zf(),x(),rp(),Wf(),Sm(),Em(),km(),Mm(),Dp(),Rm(),Rp(),Wm(),nh(),fp()});async function gh(e,t){let n=t.operation;if(!n||n.type!==`DefaultValue`&&n.type!==`AssignDefault`&&n.type!==`UseAlternative`)return null;let r=n.word;if(!r||r.parts.length===0)return null;let i=await dp(e,t.parameter),a=await X(e,t.parameter,!1)===``,o=n.checkEmpty??!1,s;return s=n.type===`UseAlternative`?i&&!(o&&a):!i||o&&a,s?r.parts:null}function _h(e){return e.type===`SingleQuoted`?!0:e.type===`DoubleQuoted`?e.parts.every(e=>e.type===`Literal`):!1}async function vh(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await gh(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>_h(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function yh(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?Bf(e.pattern):!(!(e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`)||e.type===`ParameterExpansion`&&Hf(e))}async function bh(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await gh(e,a);if(o&&o.length>0&&o.length>1&&o.some(e=>e.type===`DoubleQuoted`||e.type===`SingleQuoted`)&&o.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`))return Sh(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=yh(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await vh(e,n):null,c=await i(e,n);a.push({value:c,isSplittable:t,isQuoted:r,mixedDefaultParts:s??void 0}),t&&(o=!0)}if(!o){let e=a.map(e=>e.value).join(``);return e?[e]:[]}let s=[],c=``,l=!1,u=!1,d=!1;for(let t of a)if(!t.isSplittable)u?t.isQuoted&&t.value===``?(c!==``&&s.push(c),s.push(``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&s.push(c),c=t.value,u=!1,d=!1):(c+=t.value,d=t.isQuoted&&t.value===``);else if(t.mixedDefaultParts){let a=await Sh(e,t.mixedDefaultParts,n,r,i);if(a.length!==0)if(a.length===1)c+=a[0],l=!0;else{c+=a[0],s.push(c),l=!0;for(let e=1;e<a.length-1;e++)s.push(a[e]);c=a[a.length-1]}u=!1,d=!1}else{let{words:e,hadLeadingDelimiter:r,hadTrailingDelimiter:i}=tp(t.value,n);if(d&&r&&c===``&&(s.push(``),l=!0),e.length===0)i&&(u=!0);else if(e.length===1)c+=e[0],l=!0,u=i;else{c+=e[0],s.push(c),l=!0;for(let t=1;t<e.length-1;t++)s.push(e[t]);c=e[e.length-1],u=i}d=!1}return c===``?s.length===0&&l&&s.push(``):s.push(c),s}function xh(e,t){return e.length>0&&t.includes(e[0])}async function Sh(e,t,n,r,i){let a=[];for(let n of t){let t=!(n.type===`DoubleQuoted`||n.type===`SingleQuoted`),r=await i(e,n);a.push({value:r,isSplittable:t})}let o=[],s=``,c=!1,l=!1;for(let e of a)if(!e.isSplittable)l&&e.value!==``?(s!==``&&o.push(s),s=e.value,l=!1):s+=e.value;else{xh(e.value,n)&&s!==``&&(o.push(s),s=``,c=!0);let{words:t,hadTrailingDelimiter:r}=tp(e.value,n);if(t.length===0)r&&(l=!0);else if(t.length===1)s+=t[0],c=!0,l=r;else{s+=t[0],o.push(s),c=!0;for(let e=1;e<t.length-1;e++)o.push(t[e]);s=t[t.length-1],l=r}}return s===``?o.length===0&&c&&o.push(``):o.push(s),o}var Ch=g(()=>{fp(),rp(),Wf()});function wh(e){switch(e.type){case`Literal`:return e.value;case`SingleQuoted`:return e.value;case`Escaped`:return e.value;default:return null}}function Th(e){switch(e.type){case`SingleQuoted`:case`Escaped`:case`DoubleQuoted`:return!0;case`Literal`:return e.value===``;default:return!1}}var Eh=g(()=>{});_({},{escapeGlobChars:()=>Tp,escapeRegexChars:()=>Ep,expandRedirectTarget:()=>Uh,expandWord:()=>Mh,expandWordForPattern:()=>Ph,expandWordForRegex:()=>Nh,expandWordWithGlob:()=>Bh,getArrayElements:()=>Y,getVariable:()=>X,hasQuotedMultiValueAt:()=>Hh,isArray:()=>up,isWordFullyQuoted:()=>Ah});function Dh(e,t,n){if(e.length>t)throw new b(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function Oh(e,t,n=!1){let r=[];for(let i of t)r.push(await Gh(e,i,n));return r.join(``)}function kh(e){return Th(e)}function Ah(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!kh(t))return!1;return!0}function jh(e,t,n=!1){let r=wh(t);if(r!==null)return r;switch(t.type){case`TildeExpansion`:return n?t.user===null?`~`:`~${t.user}`:(e.coverage?.hit(`bash:expansion:tilde`),t.user===null?e.state.env.get(`HOME`)??`/home/user`:t.user===`root`?`/root`:`~${t.user}`);case`Glob`:return fm(e,t.pattern);default:return null}}async function Mh(e,t){return Wh(e,t)}async function Nh(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(`\\${r.value}`);else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await Oh(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await Gh(e,r);n.push(Ep(t))}else n.push(await Gh(e,r));return n.join(``)}async function Ph(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`){let e=r.value;`()|*?[]`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`SingleQuoted`)n.push(Tp(r.value));else if(r.type===`DoubleQuoted`){let t=await Oh(e,r.parts);n.push(Tp(t))}else n.push(await Gh(e,r));return n.join(``)}async function Fh(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(Tp(r.value));else if(r.type===`Escaped`){let e=r.value;`*?[]\\()|`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`DoubleQuoted`){let t=await Oh(e,r.parts);n.push(Tp(t))}else r.type===`Glob`?lm(r.pattern)?n.push(await mm(e,r.pattern)):n.push(fm(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await Gh(e,r));return n.join(``)}function Ih(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&Ih(t.parts))return!0;return!1}async function Lh(e,t,n={count:0}){if(n.count>qh)return[[]];let r=[[]];for(let i of t)if(i.type===`BraceExpansion`){let t=[],a=!1,o=``;for(let r of i.items)if(r.type===`Range`){let e=vp(r.start,r.end,r.step,r.startStr,r.endStr);if(e.expanded)for(let r of e.expanded)n.count++,t.push(r);else{a=!0,o=e.literal;break}}else{let i=await Lh(e,r.word.parts,n);for(let r of i){n.count++;let i=[];for(let t of r)typeof t==`string`?i.push(t):i.push(await Gh(e,t));t.push(i.join(``))}}if(a){for(let e of r)n.count++,e.push(o);continue}if(r.length*t.length>e.limits.maxBraceExpansionResults||n.count>qh)return r;let s=[];for(let e of r)for(let i of t){if(n.count++,n.count>qh)return s.length>0?s:r;s.push([...e,i])}r=s}else for(let e of r)n.count++,e.push(i);return r}async function Rh(e,t){let n=t.parts;if(!Ih(n))return[await Mh(e,t)];let r=await Lh(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await Gh(e,r));i.push(_m(e,n.join(``)))}return i}function zh(){return{expandWordAsync:Wh,expandWordForGlobbing:Fh,expandWordWithBracesAsync:Rh,expandWordPartsAsync:Oh,expandPart:Gh,expandParameterAsync:Kh,hasBraceExpansion:Ih,evaluateArithmetic:$,buildIfsCharClassPattern:Qf,smartWordSplit:bh}}async function Bh(e,t){return rh(e,t,zh())}function Vh(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function Hh(e,t){if(Number.parseInt(e.state.env.get(`#`)||`0`,10)<2)return!1;function n(e){for(let t of e)if(t.type===`DoubleQuoted`){for(let e of t.parts)if(e.type===`ParameterExpansion`&&e.parameter===`@`&&!e.operation)return!0}return!1}return n(t.parts)}async function Uh(e,t){if(Hh(e,t))return{error:`bash: $@: ambiguous redirect
211
- `};let n=t.parts,{hasQuoted:r}=Uf(n);if(Ih(n)&&(await Rh(e,t)).length>1)return{error:`bash: ${n.map(e=>e.type===`Literal`?e.value:e.type===`BraceExpansion`?`{${e.items.map(e=>{if(e.type===`Range`){let t=e.step?`..${e.step}`:``;return`${e.startStr??e.start}..${e.endStr??e.end}${t}`}return e.word.parts.map(e=>e.type===`Literal`?e.value:``).join(``)}).join(`,`)}}`:``).join(``)}: ambiguous redirect
212
- `};let i=await Wh(e,t),{hasParamExpansion:a,hasCommandSub:o}=Uf(n);if((a||o)&&!r&&!Xf(e.state.env)&&J(i,Yf(e.state.env)).length>1)return{error:`bash: $${Vh(n)}: ambiguous redirect
213
- `};if(r||e.state.options.noglob)return{target:i};let s=await Fh(e,t);if(!Cp(s,e.state.shoptOptions.extglob))return{target:i};let c=new Rf(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),l=await c.expand(s);return l.length===0?c.hasFailglob()?{error:`bash: no match: ${i}
209
+ `,``):e.state.env.get(`${t}_${i}`)||``}let o=e.state.env.get(`${t}_${a}`);if(o!==void 0)return o;if(a===0){let n=e.state.env.get(t);if(n!==void 0)return n}if(n&&e.state.options.nounset)throw new ar(`${t}[${a}]`);return``}if(/^[1-9][0-9]*$/.test(t)){let r=e.state.env.get(t);if(r===void 0&&n&&e.state.options.nounset)throw new ar(t);return r||``}if(sp(e,t)){let i=lp(e,t);if(i===void 0)return``;if(i!==t)return await X(e,i,n,r);let a=e.state.env.get(t);if((a===void 0||a===``)&&n&&e.state.options.nounset)throw new ar(t);return a||``}let a=e.state.env.get(t);if(a!==void 0)return e.state.tempEnvBindings?.some(e=>e.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),a;if(pp(e,t)){let n=e.state.env.get(`${t}_0`);return n===void 0?``:n}if(n&&e.state.options.nounset)throw new ar(t);return``}async function mp(e,t){if(new Set([`?`,`$`,`#`,`_`,`-`,`0`,`PPID`,`UID`,`EUID`,`RANDOM`,`SECONDS`,`BASH_VERSION`,`!`,`BASHPID`,`LINENO`]).has(t))return!0;if(t===`@`||t===`*`)return Number.parseInt(e.state.env.get(`#`)||`0`,10)>0;if(t===`PWD`||t===`OLDPWD`)return e.state.env.has(t);let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let t=n[1],r=n[2];if(sp(e,t)){let n=lp(e,t);if(n&&n!==t){if(n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;t=n}}if(r===`@`||r===`*`)return Y(e,t).length>0?!0:e.state.env.has(t);if(e.state.associativeArrays?.has(t)){let n=Xf(r);return e.state.env.has(`${t}_${n}`)}let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else try{i=await $(e,ud(new Mf,r).expression)}catch{let t=e.state.env.get(r);i=t?Number.parseInt(t,10):0,Number.isNaN(i)&&(i=0)}if(i<0){let n=Y(e,t);if(n.length===0)return!1;let r=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+i;return r<0?!1:e.state.env.has(`${t}_${r}`)}return e.state.env.has(`${t}_${i}`)}if(sp(e,t)){let n=lp(e,t);return n===void 0||n===t?e.state.env.has(t):mp(e,n)}return!!(e.state.env.has(t)||pp(e,t))}var hp=g(()=>{jd(),K(),Ou(),sg(),x(),Zf(),op(),dp()});async function gp(e,t){let n=``,r=0;for(;r<t.length;){if(t[r]===`$`){if(t[r+1]===`{`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`{`?e++:t[i]===`}`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]===`(`){let e=1,i=r+2;for(;i<t.length&&e>0;)t[i]===`(`?e++:t[i]===`)`&&e--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await X(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[0-9]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[0-9]/.test(t[i]);)i++;let a=await X(e,t.slice(r+1,i));n+=a,r=i;continue}if(/[*@#?\-!$]/.test(t[r+1]||``)){let i=t[r+1],a=await X(e,i);n+=a,r+=2;continue}}if(t[r]===`"`){for(n+=`"`,r++;r<t.length&&t[r]!==`"`;)if(t[r]===`$`&&/[a-zA-Z_]/.test(t[r+1]||``)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=await X(e,t.slice(r+1,i));n+=a,r=i}else t[r]===`\\`?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+=`"`,r++);continue}n+=t[r],r++}return n}async function _p(e,t){let n=t,r=t.startsWith(`"`)&&t.endsWith(`"`),i=t.startsWith(`'`)&&t.endsWith(`'`);if((r||i)&&(n=t.slice(1,-1)),i)return n;let a=``,o=0;for(;o<n.length;)if(n[o]===`$`)if(n[o+1]===`(`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`(`&&n[r-1]===`$`||n[r]===`(`?t++:n[r]===`)`&&t--,r++;let i=n.slice(o+2,r-1);if(e.execFn){let t=await e.execFn(i,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=r}else if(n[o+1]===`{`){let t=1,r=o+2;for(;r<n.length&&t>0;)n[r]===`{`?t++:n[r]===`}`&&t--,r++;let i=await X(e,n.slice(o+2,r-1));a+=i,o=r}else if(/[a-zA-Z_]/.test(n[o+1]||``)){let t=o+1;for(;t<n.length&&/[a-zA-Z0-9_]/.test(n[t]);)t++;let r=await X(e,n.slice(o+1,t));a+=r,o=t}else a+=n[o],o++;else if(n[o]==="`"){let t=o+1;for(;t<n.length&&n[t]!=="`";)t++;let r=n.slice(o+1,t);if(e.execFn){let t=await e.execFn(r,{signal:e.state.signal});a+=t.stdout.replace(/\n+$/,``),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr)}o=t+1}else a+=n[o],o++;return a}var vp=g(()=>{hp()});function yp(e,t,n,r,i){let a=n??1;a===0&&(a=1);let o=Math.abs(a),s=[],c=0;r?.match(/^-?0\d/)&&(c=Math.max(c,r.replace(/^-/,``).length)),i?.match(/^-?0\d/)&&(c=Math.max(c,i.replace(/^-/,``).length));let l=e=>{if(c>0){let t=e<0,n=String(Math.abs(e)).padStart(c,`0`);return t?`-${n}`:n}return String(e)};if(e<=t)for(let n=e,r=0;n<=t&&r<Sp;n+=o,r++)s.push(l(n));else for(let n=e,r=0;n>=t&&r<Sp;n-=o,r++)s.push(l(n));return s}function bp(e,t,n){let r=n??1;r===0&&(r=1);let i=e.charCodeAt(0),a=t.charCodeAt(0),o=Math.abs(r);if(e>=`A`&&e<=`Z`&&t>=`a`&&t<=`z`||e>=`a`&&e<=`z`&&t>=`A`&&t<=`Z`){let r=n===void 0?``:`..${n}`;throw new ur(`{${e}..${t}${r}}: invalid sequence`)}let s=[];if(i<=a)for(let e=i,t=0;e<=a&&t<Sp;e+=o,t++)s.push(String.fromCharCode(e));else for(let e=i,t=0;e>=a&&t<Sp;e-=o,t++)s.push(String.fromCharCode(e));return s}function xp(e,t,n,r,i){let a=n===void 0?``:`..${n}`;return typeof e==`number`&&typeof t==`number`?{expanded:yp(e,t,n,r,i),literal:`{${e}..${t}${a}}`}:typeof e==`string`&&typeof t==`string`?{expanded:bp(e,t,n),literal:`{${e}..${t}${a}}`}:{expanded:null,literal:`{${e}..${t}${a}}`}}var Sp,Cp=g(()=>{x(),Sp=1e4});function wp(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!==`SimpleCommand`)return null;let i=r;if(i.name!==null||i.args.length!==0||i.assignments.length!==0||i.redirections.length!==1)return null;let a=i.redirections[0];return a.operator!==`<`||a.target.type!==`Word`?null:{target:a.target}}var Tp=g(()=>{});function Ep(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function Dp(e){let t=``,n=0;for(;n<e.length;)e[n]===`\\`&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function Op(e){return e.replace(/([*?[\]\\()|])/g,`\\$1`)}function kp(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`)}var Ap=g(()=>{});function Z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var jp=g(()=>{});function Q(e,t,n=!1){let r=``,i=0;for(;i<e.length;){let a=e[i];if(n&&(a===`@`||a===`*`||a===`+`||a===`?`||a===`!`)&&i+1<e.length&&e[i+1]===`(`){let o=Mp(e,i+1);if(o!==-1){let s=Np(e.slice(i+2,o)).map(e=>Q(e,t,n)),c=s.length>0?s.join(`|`):`(?:)`;a===`@`?r+=`(?:${c})`:a===`*`?r+=`(?:${c})*`:a===`+`?r+=`(?:${c})+`:a===`?`?r+=`(?:${c})?`:a===`!`&&(r+=`(?!(?:${c})$).*`),i=o+1;continue}}if(a===`\\`)if(i+1<e.length){let t=e[i+1];/[\\^$.|+(){}[\]*?]/.test(t)?r+=`\\${t}`:r+=t,i+=2}else r+=`\\\\`,i++;else if(a===`*`)r+=t?`.*`:`.*?`,i++;else if(a===`?`)r+=`.`,i++;else if(a===`[`){let t=Pp(e,i);if(t===-1)r+=`\\[`,i++;else{let n=e.slice(i+1,t);r+=Fp(n),i=t+1}}else /[\^$.|+(){}]/.test(a)?(r+=`\\${a}`,i++):(r+=a,i++)}return r}function Mp(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`){r+=2;continue}if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r;r++}return-1}function Np(e){let t=[],n=``,r=0,i=0;for(;i<e.length;){let a=e[i];if(a===`\\`){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a===`(`?(r++,n+=a):a===`)`?(r--,n+=a):a===`|`&&r===0?(t.push(n),n=``):n+=a,i++}return t.push(n),t}function Pp(e,t){let n=t+1;for(n<e.length&&e[n]===`^`&&n++,n<e.length&&e[n]===`]`&&n++;n<e.length;){if(e[n]===`\\`&&n+1<e.length){n+=2;continue}if(e[n]===`]`)return n;if(e[n]===`'`){let t=e.indexOf(`'`,n+1);if(t!==-1){n=t+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let t=e.indexOf(`:]`,n+2);if(t!==-1){n=t+2;continue}}n++}return-1}function Fp(e){let t=`[`,n=0;for((e[0]===`^`||e[0]===`!`)&&(t+=`^`,n++);n<e.length;){if(e[n]===`'`){let r=e.indexOf(`'`,n+1);if(r!==-1){let i=e.slice(n+1,r);for(let e of i)e===`\\`?t+=`\\\\`:e===`]`?t+=`\\]`:e===`^`&&t===`[`?t+=`\\^`:t+=e;n=r+1;continue}}if(e[n]===`[`&&n+1<e.length&&e[n+1]===`:`){let r=e.indexOf(`:]`,n+2);if(r!==-1){let i=e.slice(n+2,r);t+=Ip(i),n=r+2;continue}}let r=e[n];r===`\\`?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+=`\\\\`,n++):r===`-`&&n>0&&n<e.length-1?(t+=`-`,n++):r===`^`&&n===0?(t+=`^`,n++):(r===`]`&&n===0?t+=`\\]`:t+=r,n++)}return t+=`]`,t}function Ip(e){return Lp.get(e)??``}var Lp,Rp=g(()=>{Lp=new Map([[`alnum`,`a-zA-Z0-9`],[`alpha`,`a-zA-Z`],[`ascii`,`\\x00-\\x7F`],[`blank`,` \\t`],[`cntrl`,`\\x00-\\x1F\\x7F`],[`digit`,`0-9`],[`graph`,`!-~`],[`lower`,`a-z`],[`print`,` -~`],[`punct`,"!-/:-@\\[-`{-~"],[`space`,` \\t\\n\\r\\f\\v`],[`upper`,`A-Z`],[`word`,`a-zA-Z0-9_`],[`xdigit`,`0-9A-Fa-f`]])});function zp(e,t,n,r){if(n===`prefix`)return M(`^${t}`,`s`).replace(e,``);let i=M(`${t}$`,`s`);if(r)return i.replace(e,``);for(let t=e.length;t>=0;t--){let n=e.slice(t);if(i.test(n))return e.slice(0,t)}return e}function Bp(e,t){let n=Array.from(e.state.env.keys()),r=new Set,i=e.state.associativeArrays??new Set,a=new Set;for(let e of n){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);t&&a.add(t[1]);let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);n&&a.add(n[1])}let o=e=>{for(let t of i){let n=`${t}_`;if(e.startsWith(n)&&e!==t)return!0}return!1};for(let e of n)if(e.startsWith(t))if(e.includes(`__`)){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);n?.[1].startsWith(t)&&r.add(n[1])}else if(/_\d+$/.test(e)){let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);n?.[1].startsWith(t)&&r.add(n[1])}else o(e)||r.add(e);return[...r].sort()}var Vp=g(()=>{ta()});function Hp(e,t){let n=(e,t=2)=>String(e).padStart(t,`0`);if(e===``)return`${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`;let r=``,i=0;for(;i<e.length;)if(e[i]===`%`){if(i+1>=e.length){r+=`%`,i++;continue}let a=e[i+1];switch(a){case`H`:r+=n(t.getHours());break;case`M`:r+=n(t.getMinutes());break;case`S`:r+=n(t.getSeconds());break;case`d`:r+=n(t.getDate());break;case`m`:r+=n(t.getMonth()+1);break;case`Y`:r+=t.getFullYear();break;case`y`:r+=n(t.getFullYear()%100);break;case`I`:{let e=t.getHours()%12;e===0&&(e=12),r+=n(e);break}case`p`:r+=t.getHours()<12?`AM`:`PM`;break;case`P`:r+=t.getHours()<12?`am`:`pm`;break;case`%`:r+=`%`;break;case`a`:r+=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`][t.getDay()];break;case`b`:r+=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][t.getMonth()];break;default:r+=`%${a}`}i+=2}else r+=e[i],i++;return r}function Up(e,t){let n=``,r=0,i=e.state.env.get(`USER`)||e.state.env.get(`LOGNAME`)||`user`,a=e.state.env.get(`HOSTNAME`)||`localhost`,o=a.split(`.`)[0],s=e.state.env.get(`PWD`)||`/`,c=e.state.env.get(`HOME`)||`/`,l=s.startsWith(c)?`~${s.slice(c.length)}`:s,u=s.split(`/`).pop()||s,d=new Date,f=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],p=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],m=e.state.env.get(`__COMMAND_NUMBER`)||`1`;for(;r<t.length;){let e=t[r];if(e===`\\`){if(r+1>=t.length){n+=`\\`,r++;continue}let e=t[r+1];if(e>=`0`&&e<=`7`){let e=``,i=r+1;for(;i<t.length&&i<r+4&&t[i]>=`0`&&t[i]<=`7`;)e+=t[i],i++;let a=Number.parseInt(e,8)%256;n+=String.fromCharCode(a),r=i;continue}switch(e){case`\\`:n+=`\\`,r+=2;break;case`a`:n+=`\x07`,r+=2;break;case`e`:n+=`\x1B`,r+=2;break;case`n`:n+=`
210
+ `,r+=2;break;case`r`:n+=`\r`,r+=2;break;case`$`:n+=`$`,r+=2;break;case`[`:case`]`:r+=2;break;case`u`:n+=i,r+=2;break;case`h`:n+=o,r+=2;break;case`H`:n+=a,r+=2;break;case`w`:n+=l,r+=2;break;case`W`:n+=u,r+=2;break;case`d`:{let e=String(d.getDate()).padStart(2,` `);n+=`${f[d.getDay()]} ${p[d.getMonth()]} ${e}`,r+=2;break}case`t`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`),i=String(d.getSeconds()).padStart(2,`0`);n+=`${e}:${t}:${i}`,r+=2;break}case`T`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=String(d.getSeconds()).padStart(2,`0`);n+=`${t}:${i}:${a}`,r+=2;break}case`@`:{let e=d.getHours()%12;e===0&&(e=12);let t=String(e).padStart(2,`0`),i=String(d.getMinutes()).padStart(2,`0`),a=d.getHours()<12?`AM`:`PM`;n+=`${t}:${i} ${a}`,r+=2;break}case`A`:{let e=String(d.getHours()).padStart(2,`0`),t=String(d.getMinutes()).padStart(2,`0`);n+=`${e}:${t}`,r+=2;break}case`D`:if(r+2<t.length&&t[r+2]===`{`){let e=t.indexOf(`}`,r+3);if(e!==-1){let i=t.slice(r+3,e);n+=Hp(i,d),r=e+1}else n+=`\\D`,r+=2}else n+=`\\D`,r+=2;break;case`s`:n+=`bash`,r+=2;break;case`v`:n+=`5.0`,r+=2;break;case`V`:n+=`5.0.0`,r+=2;break;case`j`:n+=`0`,r+=2;break;case`l`:n+=`tty`,r+=2;break;case`#`:n+=m,r+=2;break;case`!`:n+=m,r+=2;break;case`x`:n+=`\\x`,r+=2;break;default:n+=`\\${e}`,r+=2}}else n+=e,r++}return n}var Wp=g(()=>{});function Gp(e){if(e===``)return`''`;if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let t=`$'`;for(let n of e)switch(n){case`'`:t+=`\\'`;break;case`\\`:t+=`\\\\`;break;case`
211
+ `:t+=`\\n`;break;case`\r`:t+=`\\r`;break;case` `:t+=`\\t`;break;default:{let e=n.charCodeAt(0);e<32||e===127?t+=`\\${e.toString(8).padStart(3,`0`)}`:t+=n}}return`${t}'`}return`'${e}'`}var Kp=g(()=>{});function qp(e,t){return e.state.readonlyVars?.has(t)??!1}var Jp=g(()=>{x()});function Yp(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return``;let n=``,r=e.state.env.has(`${t}__length`)||Array.from(e.state.env.keys()).some(e=>e.startsWith(`${t}_`)&&/^[0-9]+$/.test(e.slice(t.length+1))),i=e.state.associativeArrays?.has(t)??!1;return r&&!i&&(n+=`a`),i&&(n+=`A`),e.state.integerVars?.has(t)&&(n+=`i`),sp(e,t)&&(n+=`n`),qp(e,t)&&(n+=`r`),e.state.exportedVars?.has(t)&&(n+=`x`),n}var Xp=g(()=>{dp(),Jp()});async function Zp(e,t,n,r){return e.coverage?.hit(`bash:expansion:default_value`),(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function Qp(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:assign_default`),(r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let a=await i(e,n.word.parts,r.inDoubleQuotes),o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let[,t,n]=o,r;if(/^\d+$/.test(n))r=Number.parseInt(n,10);else{try{r=await $(e,ud(new Mf,n).expression)}catch{let t=e.state.env.get(n);r=t?Number.parseInt(t,10):0}Number.isNaN(r)&&(r=0)}e.state.env.set(`${t}_${r}`,a);let i=Number.parseInt(e.state.env.get(`${t}__length`)||`0`,10);r>=i&&e.state.env.set(`${t}__length`,String(r+1))}else e.state.env.set(t,a);return a}return r.effectiveValue}async function $p(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:error_if_unset`),r.isUnset||n.checkEmpty&&r.isEmpty){let a=n.word?await i(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new or(1,``,`bash: ${a}
212
+ `)}return r.effectiveValue}async function em(e,t,n,r){return e.coverage?.hit(`bash:expansion:use_alternative`),!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):``}async function tm(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_removal`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=Q(t.pattern,n.greedy,o);else if(t.type===`Literal`)a+=Q(t.value,n.greedy,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=Z(n)}else if(t.type===`ParameterExpansion`){let r=await i(e,t);a+=Q(r,n.greedy,o)}else{let n=await i(e,t);a+=Z(n)}if(n.side===`prefix`)return M(`^${a}`,`s`).replace(t,``);let s=M(`${a}$`,`s`);if(n.greedy)return s.replace(t,``);for(let e=t.length;e>=0;e--){let n=t.slice(e);if(s.test(n))return t.slice(0,e)}return t}async function nm(e,t,n,r,i){e.coverage?.hit(`bash:expansion:pattern_replacement`);let a=``,o=e.state.shoptOptions.extglob;if(n.pattern)for(let t of n.pattern.parts)if(t.type===`Glob`)a+=Q(t.pattern,!0,o);else if(t.type===`Literal`)a+=Q(t.value,!0,o);else if(t.type===`SingleQuoted`||t.type===`Escaped`)a+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);a+=Z(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);a+=Q(n,!0,o)}else{let n=await i(e,t);a+=Z(n)}let s=n.replacement?await r(e,n.replacement.parts):``;if(n.anchor===`start`?a=`^${a}`:n.anchor===`end`&&(a=`${a}$`),a===``)return t;let c=n.all?`gs`:`s`;try{let r=M(a,c);if(n.all){let n=``,i=0,a=0,o=e.limits.maxStringLength,c=r.exec(t);for(;c!==null&&!(c[0].length===0&&c.index===t.length);){if(n+=t.slice(i,c.index)+s,i=c.index+c[0].length,c[0].length===0&&i++,a++,a%100==0&&n.length>o)throw new b(`pattern replacement: string length limit exceeded (${o} bytes)`,`string_length`);c=r.exec(t)}return n+=t.slice(i),n}return r.replace(t,s)}catch(e){if(e instanceof b)throw e;return t}}function rm(e,t,n){e.coverage?.hit(`bash:expansion:length`);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=Y(e,t);return n.length>0?String(n.length):e.state.env.get(t)===void 0?`0`:`1`}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&pp(e,t)){if(t===`FUNCNAME`){let t=e.state.funcNameStack?.[0]||``;return String([...t].length)}if(t===`BASH_LINENO`){let t=e.state.callLineStack?.[0];return String(t===void 0?0:[...String(t)].length)}let n=e.state.env.get(`${t}_0`)||``;return String([...n].length)}return String([...n].length)}async function im(e,t,n,r){e.coverage?.hit(`bash:expansion:substring`);let i=await $(e,r.offset.expression),a=r.length?await $(e,r.length.expression):void 0;if(t===`@`||t===`*`){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);let r=e.state.env.get(`0`)||`bash`,o,s;if(i<=0)if(o=[r,...n],i<0){if(s=o.length+i,s<0)return``}else s=0;else o=n,s=i-1;if(s<0||s>=o.length)return``;if(a!==void 0){let e=a<0?o.length+a:s+a;return o.slice(s,Math.max(s,e)).join(` `)}return o.slice(s).join(` `)}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let t=o[1];if(e.state.associativeArrays?.has(t))throw new or(1,``,`bash: \${${t}[@]: 0: 3}: bad substitution
213
+ `);let n=Y(e,t),r=0;if(i<0){if(n.length>0){let e=n[n.length-1][0],t=(typeof e==`number`?e:0)+1+i;if(t<0||(r=n.findIndex(([e])=>typeof e==`number`&&e>=t),r<0))return``}}else if(r=n.findIndex(([e])=>typeof e==`number`&&e>=i),r<0)return``;if(a!==void 0){if(a<0)throw new sr(`${o[1]}[@]: substring expression < 0`);return n.slice(r,r+a).map(([,e])=>e).join(` `)}return n.slice(r).map(([,e])=>e).join(` `)}let s=[...n],c=i;if(c<0&&(c=Math.max(0,s.length+c)),a!==void 0){if(a<0){let e=s.length+a;return s.slice(c,Math.max(c,e)).join(``)}return s.slice(c,c+a).join(``)}return s.slice(c).join(``)}async function am(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:case_modification`),n.pattern){let a=e.state.shoptOptions.extglob,o=``;for(let t of n.pattern.parts)if(t.type===`Glob`)o+=Q(t.pattern,!0,a);else if(t.type===`Literal`)o+=Q(t.value,!0,a);else if(t.type===`SingleQuoted`||t.type===`Escaped`)o+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);o+=Z(n)}else if(t.type===`ParameterExpansion`){let n=await i(e,t);o+=Q(n,!0,a)}let s=M(`^(?:${o})$`),c=n.direction===`upper`?e=>e.toUpperCase():e=>e.toLowerCase(),l=``,u=!1;for(let e of t)!n.all&&u?l+=e:s.test(e)?(l+=c(e),u=!0):l+=e;return l}return n.direction===`upper`?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function om(e,t,n,r,i){e.coverage?.hit(`bash:expansion:transform`);let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(a&&i.operator===`Q`)return Y(e,a[1]).map(([,e])=>Gp(e)).join(` `);if(a&&i.operator===`a`)return Yp(e,a[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&i.operator===`a`)return Yp(e,o[1]);switch(i.operator){case`Q`:return r?``:Gp(n);case`P`:return Up(e,n);case`a`:return Yp(e,t);case`A`:return r?``:`${t}=${Gp(n)}`;case`E`:return n.replace(/\\([\\abefnrtv'"?])/g,(e,t)=>{switch(t){case`\\`:return`\\`;case`a`:return`\x07`;case`b`:return`\b`;case`e`:return`\x1B`;case`f`:return`\f`;case`n`:return`
214
+ `;case`r`:return`\r`;case`t`:return` `;case`v`:return`\v`;case`'`:return`'`;case`"`:return`"`;case`?`:return`?`;default:return t}});case`K`:case`k`:return r?``:Gp(n);case`u`:return n.charAt(0).toUpperCase()+n.slice(1);case`U`:return n.toUpperCase();case`L`:return n.toLowerCase();default:return n}}async function sm(e,t,n,r,i,a,o=!1){if(e.coverage?.hit(`bash:expansion:indirection`),sp(e,t))return up(e,t)||``;let s=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(i.innerOp?.type===`UseAlternative`)return``;throw new cr(`\${!${t}}`)}let c=n;if(s&&(c===``||c.includes(` `)))throw new cr(`\${!${t}}`);let l=c.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(l&&l[1].includes(`~`))throw new cr(`\${!${t}}`);return i.innerOp?a(e,{type:`ParameterExpansion`,parameter:c,operation:i.innerOp},o):await X(e,c)}function cm(e,t){e.coverage?.hit(`bash:expansion:array_keys`);let n=Y(e,t.array).map(([e])=>String(e));return t.star?n.join(q(e.state.env)):n.join(` `)}function lm(e,t){e.coverage?.hit(`bash:expansion:var_name_prefix`);let n=Bp(e,t.prefix);return t.star?n.join(q(e.state.env)):n.join(` `)}function um(e,t,n,r){let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t===`*`)return{isEmpty:i===0,effectiveValue:n};if(t===`@`)return{isEmpty:i===0||i===1&&e.state.env.get(`1`)===``,effectiveValue:n};if(a){let[,t,n]=a,i=Y(e,t);if(i.length===0)return{isEmpty:!0,effectiveValue:``};if(n===`*`){let t=q(e.state.env),n=i.map(([,e])=>e).join(t);return{isEmpty:r?n===``:!1,effectiveValue:n}}return{isEmpty:i.length===1&&i.every(([,e])=>e===``),effectiveValue:i.map(([,e])=>e).join(` `)}}return{isEmpty:n===``,effectiveValue:n}}var dm=g(()=>{jd(),K(),ta(),sg(),x(),op(),dp(),jp(),Rp(),Vp(),Wp(),Kp(),hp(),Xp()});function fm(e){let t=0;for(;t<e.length;){let n=e[t];if(n===`\\`&&t+1<e.length){t+=2;continue}if(n===`'`){let n=e.indexOf(`'`,t+1);if(n!==-1){t=n+1;continue}}if(n===`$`&&t+1<e.length&&e[t+1]===`(`||n==="`")return!0;t++}return!1}function pm(e,t){let n=1,r=t,i=!1,a=!1;for(;r<e.length&&n>0;){let t=e[r];if(t===`\\`&&!i&&r+1<e.length){r+=2;continue}if(t===`'`&&!a){i=!i,r++;continue}if(t===`"`&&!i){a=!a,r++;continue}if(!i&&!a){if(t===`(`)n++;else if(t===`)`&&(n--,n===0))return r}r++}return-1}async function mm(e,t){let n=new Mf,r;try{r=n.parse(t)}catch{return``}let i=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let a=new Map(e.state.env),o=e.state.cwd,s=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let t=await e.executeScript(r),n=t.exitCode;return e.state.env=a,e.state.cwd=o,e.state.suppressVerbose=s,e.state.lastExitCode=n,e.state.env.set(`?`,String(n)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr),e.state.bashPid=i,t.stdout.replace(/\n+$/,``)}catch(t){if(e.state.env=a,e.state.cwd=o,e.state.bashPid=i,e.state.suppressVerbose=s,t instanceof b)throw t;return t instanceof or?(e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stdout?.replace(/\n+$/,``)??``):``}}function hm(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=Op(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=gm(e,t.slice(r+1,i));n+=Op(a),r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}function gm(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}async function _m(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`'`){let e=t.indexOf(`'`,r+1);if(e!==-1){let i=t.slice(r+1,e);n+=Op(i),r=e+1;continue}}if(i===`"`){let i=-1,a=r+1;for(;a<t.length;){if(t[a]===`\\`){a+=2;continue}if(t[a]===`"`){i=a;break}a++}if(i!==-1){let a=await vm(e,t.slice(r+1,i));n+=Op(a),r=i+1;continue}}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=pm(t,r+2);if(i!==-1){let a=await mm(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await mm(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}if(i===`\\`&&r+1<t.length){n+=i+t[r+1],r+=2;continue}n+=i,r++}return n}async function vm(e,t){let n=``,r=0;for(;r<t.length;){let i=t[r];if(i===`\\`&&r+1<t.length){let e=t[r+1];if(e===`$`||e==="`"||e===`\\`||e===`"`){n+=e,r+=2;continue}n+=i,r++;continue}if(i===`$`&&r+1<t.length&&t[r+1]===`(`){let i=pm(t,r+2);if(i!==-1){let a=await mm(e,t.slice(r+2,i));n+=a,r=i+1;continue}}if(i==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=await mm(e,t.slice(r+1,i));n+=a,r=i+1;continue}}if(i===`$`&&r+1<t.length){let i=t[r+1];if(i===`{`){let i=t.indexOf(`}`,r+2);if(i!==-1){let a=t.slice(r+2,i);n+=e.state.env.get(a)??``,r=i+1;continue}}else if(/[a-zA-Z_]/.test(i)){let i=r+1;for(;i<t.length&&/[a-zA-Z0-9_]/.test(t[i]);)i++;let a=t.slice(r+1,i);n+=e.state.env.get(a)??``,r=i;continue}}n+=i,r++}return n}var ym=g(()=>{K(),x(),Ap()});function bm(e,t){if(!t.startsWith(`~`))return t;e.coverage?.hit(`bash:expansion:tilde`);let n=e.state.env.get(`HOME`)===void 0?`/home/user`:e.state.env.get(`HOME`);if(t===`~`||t.startsWith(`~/`))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let i=t.slice(1,r),a=t.slice(r);return a!==``&&!a.startsWith(`/`)?t:i===`root`?`/root${a}`:t}var xm=g(()=>{});async function Sm(e,t,n,r){let i=``;for(let a of t.parts)if(a.type===`Glob`)i+=Q(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)i+=Q(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)i+=Z(a.value);else if(a.type===`DoubleQuoted`){let t=await n(e,a.parts);i+=Z(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);i+=Q(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);i+=Z(t)}return i}async function Cm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternReplacement`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=Y(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``;l.pattern&&(f=await Sm(e,l.pattern,n,r));let p=l.replacement?await n(e,l.replacement.parts):``,m=f;l.anchor===`start`?m=`^${f}`:l.anchor===`end`&&(m=`${f}$`);let h=[];try{let e=M(m,l.all?`g`:``);for(let t of d)h.push(e.replace(t,p))}catch{h.push(...d)}if(c){let t=q(e.state.env);return{values:[h.join(t)],quoted:!0}}return{values:h,quoted:!0}}async function wm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!==`ParameterExpansion`||i.parts[0].operation?.type!==`PatternRemoval`)return null;let a=i.parts[0],o=a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let s=o[1],c=o[2]===`*`,l=a.operation,u=Y(e,s),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(s);t!==void 0&&d.push(t)}if(d.length===0)return{values:[],quoted:!0};let f=``,p=e.state.shoptOptions.extglob;if(l.pattern)for(let t of l.pattern.parts)if(t.type===`Glob`)f+=Q(t.pattern,l.greedy,p);else if(t.type===`Literal`)f+=Q(t.value,l.greedy,p);else if(t.type===`SingleQuoted`||t.type===`Escaped`)f+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);f+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);f+=Q(n,l.greedy,p)}else{let n=await r(e,t);f+=Z(n)}let m=[];for(let e of d)m.push(zp(e,f,l.side,l.greedy));if(c){let t=q(e.state.env);return{values:[m.join(t)],quoted:!0}}return{values:m,quoted:!0}}var Tm=g(()=>{ta(),op(),jp(),Rp(),Vp(),hp()});async function Em(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`DefaultValue`&&n.parts[0].operation?.type!==`UseAlternative`&&n.parts[0].operation?.type!==`AssignDefault`)return null;let r=n.parts[0],i=r.operation,a=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,s=!1;if(a){let t=a[1];s=a[2]===`*`;let n=Y(e,t),r=n.length>0||e.state.env.has(t),c=n.length===0||n.length===1&&n.every(([,e])=>e===``),l=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?r&&!(l&&c):!r||l&&c,!o){if(n.length>0){let t=n.map(([,e])=>e);if(s){let n=q(e.state.env);return{values:[t.join(n)],quoted:!0}}return{values:t,quoted:!0}}let r=e.state.env.get(t);return r===void 0?{values:[],quoted:!0}:{values:[r],quoted:!0}}}else{let t=r.parameter,n=await mp(e,t),a=await X(e,t),s=a===``,c=i.checkEmpty??!1;if(o=i.type===`UseAlternative`?n&&!(c&&s):!n||c&&s,!o)return{values:[a],quoted:!0}}if(o&&i.word){let t=i.word.parts,n=null,r=!1;for(let e of t)if(e.type===`ParameterExpansion`&&!e.operation){let t=e.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){n=t[1],r=t[2]===`*`;break}}if(n){let t=Y(e,n);if(t.length>0){let n=t.map(([,e])=>e);if(r||s){let t=q(e.state.env);return{values:[n.join(t)],quoted:!0}}return{values:n,quoted:!0}}let i=e.state.env.get(n);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}}return null}async function Dm(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0],o=-1,s=``,c=!1,l=null;for(let e=0;e<a.parts.length;e++){let t=a.parts[e];if(t.type===`ParameterExpansion`&&(t.operation?.type===`PatternRemoval`||t.operation?.type===`PatternReplacement`)){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){o=e,s=n[1],c=n[2]===`*`,l=t.operation;break}}}if(o===-1||o===0&&o===a.parts.length-1)return null;let u=``;for(let t=0;t<o;t++)u+=await r(e,a.parts[t]);let d=``;for(let t=o+1;t<a.parts.length;t++)d+=await r(e,a.parts[t]);let f=Y(e,s),p=f.map(([,e])=>e);if(f.length===0){let t=e.state.env.get(s);if(t!==void 0)p=[t];else{if(c)return{values:[u+d],quoted:!0};let e=u+d;return{values:e?[e]:[],quoted:!0}}}if(l?.type===`PatternRemoval`){let t=l,n=``,a=e.state.shoptOptions.extglob;if(t.pattern)for(let o of t.pattern.parts)if(o.type===`Glob`)n+=Q(o.pattern,t.greedy,a);else if(o.type===`Literal`)n+=Q(o.value,t.greedy,a);else if(o.type===`SingleQuoted`||o.type===`Escaped`)n+=Z(o.value);else if(o.type===`DoubleQuoted`){let t=await i(e,o.parts);n+=Z(t)}else if(o.type===`ParameterExpansion`){let i=await r(e,o);n+=Q(i,t.greedy,a)}else{let t=await r(e,o);n+=Z(t)}p=p.map(e=>zp(e,n,t.side,t.greedy))}else if(l?.type===`PatternReplacement`){let t=l,n=``;if(t.pattern)for(let a of t.pattern.parts)if(a.type===`Glob`)n+=Q(a.pattern,!0,e.state.shoptOptions.extglob);else if(a.type===`Literal`)n+=Q(a.value,!0,e.state.shoptOptions.extglob);else if(a.type===`SingleQuoted`||a.type===`Escaped`)n+=Z(a.value);else if(a.type===`DoubleQuoted`){let t=await i(e,a.parts);n+=Z(t)}else if(a.type===`ParameterExpansion`){let t=await r(e,a);n+=Q(t,!0,e.state.shoptOptions.extglob)}else{let t=await r(e,a);n+=Z(t)}let a=t.replacement?await i(e,t.replacement.parts):``,o=n;t.anchor===`start`?o=`^${n}`:t.anchor===`end`&&(o=`${n}$`);try{let e=M(o,t.all?`g`:``);p=p.map(t=>e.replace(t,a))}catch{}}if(c){let t=q(e.state.env);return{values:[u+p.join(t)+d],quoted:!0}}return p.length===1?{values:[u+p[0]+d],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+d],quoted:!0}}async function Om(e,t,n,r){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=``,s=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&!t.operation){let n=t.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(n){a=e,o=n[1],s=n[2]===`*`;break}}}if(a===-1)return null;let c=``;for(let t=0;t<a;t++)c+=await r(e,i.parts[t]);let l=``;for(let t=a+1;t<i.parts.length;t++)l+=await r(e,i.parts[t]);let u=Y(e,o),d=u.map(([,e])=>e);if(u.length===0){let t=e.state.env.get(o);if(t!==void 0)return{values:[c+t+l],quoted:!0};if(s)return{values:[c+l],quoted:!0};let n=c+l;return{values:n?[n]:[],quoted:!0}}if(s){let t=q(e.state.env);return{values:[c+d.join(t)+l],quoted:!0}}return d.length===1?{values:[c+d[0]+l],quoted:!0}:{values:[c+d[0],...d.slice(1,-1),d[d.length-1]+l],quoted:!0}}var km=g(()=>{ta(),op(),jp(),Rp(),Vp(),hp()});async function Am(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!==`ParameterExpansion`||r.parts[0].operation?.type!==`Substring`)return null;let i=r.parts[0],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],s=a[2]===`*`,c=i.operation;if(e.state.associativeArrays?.has(o))throw new or(1,``,`bash: \${${o}[@]: 0: 3}: bad substitution
215
+ `);let l=c.offset?await n(e,c.offset.expression):0,u=c.length?await n(e,c.length.expression):void 0,d=Y(e,o),f=0;if(l<0){if(d.length>0){let e=d[d.length-1][0],t=(typeof e==`number`?e:0)+1+l;if(t<0)return{values:[],quoted:!0};f=d.findIndex(([e])=>typeof e==`number`&&e>=t),f<0&&(f=d.length)}}else f=d.findIndex(([e])=>typeof e==`number`&&e>=l),f<0&&(f=d.length);let p;if(u!==void 0){if(u<0)throw new sr(`${o}[@]: substring expression < 0`);p=d.slice(f,f+u).map(([,e])=>e)}else p=d.slice(f).map(([,e])=>e);if(p.length===0)return{values:[],quoted:!0};if(s){let t=q(e.state.env);return{values:[p.join(t)],quoted:!0}}return{values:p,quoted:!0}}function jm(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation?.type!==`Transform`)return null;let r=n.parts[0],i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let a=i[1],o=i[2]===`*`,s=r.operation,c=Y(e,a);if(c.length===0){let t=e.state.env.get(a);if(t!==void 0){let n;switch(s.operator){case`a`:n=``;break;case`P`:n=Up(e,t);break;case`Q`:n=Gp(t);break;default:n=t}return{values:[n],quoted:!0}}return o?{values:[``],quoted:!0}:{values:[],quoted:!0}}let l=Yp(e,a),u;switch(s.operator){case`a`:u=c.map(()=>l);break;case`P`:u=c.map(([,t])=>Up(e,t));break;case`Q`:u=c.map(([,e])=>Gp(e));break;case`u`:u=c.map(([,e])=>e.charAt(0).toUpperCase()+e.slice(1));break;case`U`:u=c.map(([,e])=>e.toUpperCase());break;case`L`:u=c.map(([,e])=>e.toLowerCase());break;default:u=c.map(([,e])=>e)}if(o){let t=q(e.state.env);return{values:[u.join(t)],quoted:!0}}return{values:u,quoted:!0}}var Mm=g(()=>{x(),op(),Wp(),Kp(),hp(),Xp()});function Nm(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`)return null;let r=n.parts[0];if(r.operation)return null;let i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!i)return null;let a=i[1];if(sp(e,a)){let t=up(e,a);if(t?.endsWith(`[@]`)||t?.endsWith(`[*]`))return{values:[],quoted:!0}}let o=Y(e,a);if(o.length>0)return{values:o.map(([,e])=>e),quoted:!0};let s=e.state.env.get(a);return s===void 0?{values:[],quoted:!0}:{values:[s],quoted:!0}}function Pm(e,t){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!==`ParameterExpansion`||n.parts[0].operation)return null;let r=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)||!sp(e,r))return null;let i=up(e,r);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],s=Y(e,o);if(s.length>0)return{values:s.map(([,e])=>e),quoted:!0};let c=e.state.env.get(o);return c===void 0?{values:[],quoted:!0}:{values:[c],quoted:!0}}var Fm=g(()=>{dp(),hp()});async function Im(e,t,n,r,i){if(!n||t.length!==1||t[0].type!==`DoubleQuoted`)return null;let a=t[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=o.operation,c=await X(e,o.parameter),l=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l){if(!s.innerOp&&(c===`@`||c===`*`)){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return c===`*`?{values:[n.join(q(e.state.env))],quoted:!0}:{values:n,quoted:!0}}return null}let u=l[1],d=l[2]===`*`,f=Y(e,u);if(s.innerOp){if(s.innerOp.type===`Substring`)return Lm(e,f,u,d,s.innerOp);if(s.innerOp.type===`DefaultValue`||s.innerOp.type===`UseAlternative`||s.innerOp.type===`AssignDefault`||s.innerOp.type===`ErrorIfUnset`)return Rm(e,f,u,d,s.innerOp,i);if(s.innerOp.type===`Transform`&&s.innerOp.operator===`a`){let t=Yp(e,u),n=f.map(()=>t);return d?{values:[n.join(q(e.state.env))],quoted:!0}:{values:n,quoted:!0}}let t=[];for(let[,n]of f){let i={type:`ParameterExpansion`,parameter:`_indirect_elem_`,operation:s.innerOp},a=e.state.env.get(`_indirect_elem_`);e.state.env.set(`_indirect_elem_`,n);try{let n=await r(e,i,!0);t.push(n)}finally{a===void 0?e.state.env.delete(`_indirect_elem_`):e.state.env.set(`_indirect_elem_`,a)}}return d?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}if(f.length>0){let t=f.map(([,e])=>e);return d?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let p=e.state.env.get(u);return p===void 0?{values:[],quoted:!0}:{values:[p],quoted:!0}}async function Lm(e,t,n,r,i){let a=i.offset?await $(e,i.offset.expression):0,o=i.length?await $(e,i.length.expression):void 0,s=0;if(a<0){if(t.length>0){let e=t[t.length-1][0],n=(typeof e==`number`?e:0)+1+a;if(n<0||(s=t.findIndex(([e])=>typeof e==`number`&&e>=n),s<0))return{values:[],quoted:!0}}}else if(s=t.findIndex(([e])=>typeof e==`number`&&e>=a),s<0)return{values:[],quoted:!0};let c;if(o!==void 0){if(o<0)throw new sr(`${n}[@]: substring expression < 0`);c=t.slice(s,s+o)}else c=t.slice(s);let l=c.map(([,e])=>e);return r?{values:[l.join(q(e.state.env))],quoted:!0}:{values:l,quoted:!0}}async function Rm(e,t,n,r,i,a){let o=i.checkEmpty??!1,s=t.map(([,e])=>e),c=t.length===0,l=t.length===0;if(i.type===`UseAlternative`)return!l&&!(o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(i.type===`DefaultValue`)return(l||o&&c)&&i.word?{values:[await a(e,i.word.parts,!0)],quoted:!0}:r?{values:[s.join(q(e.state.env))],quoted:!0}:{values:s,quoted:!0};if(i.type===`AssignDefault`){if((l||o&&c)&&i.word){let t=await a(e,i.word.parts,!0);return e.state.env.set(`${n}_0`,t),e.state.env.set(`${n}__length`,`1`),{values:[t],quoted:!0}}return r?{values:[s.join(q(e.state.env))],quoted:!0}:{values:s,quoted:!0}}return r?{values:[s.join(q(e.state.env))],quoted:!0}:{values:s,quoted:!0}}async function zm(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`UseAlternative`&&t[0].operation?.type!==`DefaultValue`)return null;let n=t[0],r=n.operation,i=r?.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await X(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await mp(e,n.parameter),l=await X(e,n.parameter)===``,u=r.checkEmpty??!1,d;if(d=r.type===`UseAlternative`?c&&!(u&&l):!c||u&&l,d){let t=s[1],n=s[2]===`*`,r=Y(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}async function Bm(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`Indirection`)return null;let n=t[0],r=n.operation.innerOp;if(!r||r.type!==`UseAlternative`&&r.type!==`DefaultValue`)return null;let i=r.word;if(!i||i.parts.length!==1||i.parts[0].type!==`DoubleQuoted`)return null;let a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!==`ParameterExpansion`||a.parts[0].operation?.type!==`Indirection`)return null;let o=a.parts[0],s=(await X(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let c=await X(e,n.parameter),l=await mp(e,n.parameter),u=c===``,d=r.checkEmpty??!1,f;if(f=r.type===`UseAlternative`?l&&!(d&&u):!l||d&&u,f){let t=s[1],n=s[2]===`*`,r=Y(e,t);if(r.length>0){let t=r.map(([,e])=>e);return n?{values:[t.join(q(e.state.env))],quoted:!0}:{values:t,quoted:!0}}let i=e.state.env.get(t);return i===void 0?{values:[],quoted:!0}:{values:[i],quoted:!0}}return{values:[],quoted:!1}}var Vm=g(()=>{sg(),x(),op(),hp(),Xp()});function Hm(e){let t=Number.parseInt(e.state.env.get(`#`)||`0`,10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||``);return n}async function Um(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`Substring`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=s.offset?await n(e,s.offset.expression):0,l=s.length?await n(e,s.length.expression):void 0,u=Number.parseInt(e.state.env.get(`#`)||`0`,10),d=[];for(let t=1;t<=u;t++)d.push(e.state.env.get(String(t))||``);let f=e.state.env.get(`0`)||`bash`,p;if(c<=0){let e=[f,...d],t=e.length+c;if(t<0)p=[];else{let n=c<0?t:0;if(l!==void 0){let t=l<0?e.length+l:n+l;p=e.slice(n,Math.max(n,t))}else p=e.slice(n)}}else{let e=c-1;if(e>=d.length)p=[];else if(l!==void 0){let t=l<0?d.length+l:e+l;p=d.slice(e,Math.max(e,t))}else p=d.slice(e)}let m=``;for(let t=0;t<a;t++)m+=await r(e,i.parts[t]);let h=``;for(let t=a+1;t<i.parts.length;t++)h+=await r(e,i.parts[t]);if(p.length===0){let e=m+h;return{values:e?[e]:[],quoted:!0}}if(o){let t=q(e.state.env);return{values:[m+p.join(t)+h],quoted:!0}}return p.length===1?{values:[m+p[0]+h],quoted:!0}:{values:[m+p[0],...p.slice(1,-1),p[p.length-1]+h],quoted:!0}}async function Wm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternReplacement`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=Hm(e),l=``;for(let t=0;t<a;t++)l+=await n(e,i.parts[t]);let u=``;for(let t=a+1;t<i.parts.length;t++)u+=await n(e,i.parts[t]);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=Q(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)d+=Q(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=Z(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Q(r,!0,e.state.shoptOptions.extglob)}else{let r=await n(e,t);d+=Z(r)}let f=s.replacement?await r(e,s.replacement.parts):``,p=d;s.anchor===`start`?p=`^${d}`:s.anchor===`end`&&(p=`${d}$`);let m=[];try{let e=M(p,s.all?`g`:``);for(let t of c)m.push(e.replace(t,f))}catch{m.push(...c)}if(o){let t=q(e.state.env);return{values:[l+m.join(t)+u],quoted:!0}}return m.length===1?{values:[l+m[0]+u],quoted:!0}:{values:[l+m[0],...m.slice(1,-1),m[m.length-1]+u],quoted:!0}}async function Gm(e,t,n,r){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let i=t[0],a=-1,o=!1;for(let e=0;e<i.parts.length;e++){let t=i.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)&&t.operation?.type===`PatternRemoval`){a=e,o=t.parameter===`*`;break}}if(a===-1)return null;let s=i.parts[a].operation,c=Hm(e),l=``;for(let t=0;t<a;t++)l+=await n(e,i.parts[t]);let u=``;for(let t=a+1;t<i.parts.length;t++)u+=await n(e,i.parts[t]);if(c.length===0){let e=l+u;return{values:e?[e]:[],quoted:!0}}let d=``,f=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)d+=Q(t.pattern,s.greedy,f);else if(t.type===`Literal`)d+=Q(t.value,s.greedy,f);else if(t.type===`SingleQuoted`||t.type===`Escaped`)d+=Z(t.value);else if(t.type===`DoubleQuoted`){let n=await r(e,t.parts);d+=Z(n)}else if(t.type===`ParameterExpansion`){let r=await n(e,t);d+=Q(r,s.greedy,f)}else{let r=await n(e,t);d+=Z(r)}let p=[];for(let e of c)p.push(zp(e,d,s.side,s.greedy));if(o){let t=q(e.state.env);return{values:[l+p.join(t)+u],quoted:!0}}return p.length===1?{values:[l+p[0]+u],quoted:!0}:{values:[l+p[0],...p.slice(1,-1),p[p.length-1]+u],quoted:!0}}async function Km(e,t,n){if(t.length!==1||t[0].type!==`DoubleQuoted`)return null;let r=t[0],i=-1,a=!1;for(let e=0;e<r.parts.length;e++){let t=r.parts[e];if(t.type===`ParameterExpansion`&&(t.parameter===`@`||t.parameter===`*`)){i=e,a=t.parameter===`*`;break}}if(i===-1)return null;let o=r.parts[i];if(o.type===`ParameterExpansion`&&o.operation)return null;let s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=``;for(let t=0;t<i;t++)c+=await n(e,r.parts[t]);let l=``;for(let t=i+1;t<r.parts.length;t++)l+=await n(e,r.parts[t]);if(s===0){if(a)return{values:[c+l],quoted:!0};let e=c+l;return{values:e?[e]:[],quoted:!0}}let u=[];for(let t=1;t<=s;t++)u.push(e.state.env.get(String(t))||``);if(a){let t=q(e.state.env);return{values:[c+u.join(t)+l],quoted:!0}}return u.length===1?{values:[c+u[0]+l],quoted:!0}:{values:[c+u[0],...u.slice(1,-1),u[u.length-1]+l],quoted:!0}}var qm=g(()=>{ta(),op(),jp(),Rp(),Vp()});function Jm(e){return new Vf(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations})}async function Ym(e,t){if(e.state.options.noglob)return t;let n=Jm(e),r=[];for(let i of t)if(Ep(i,e.state.shoptOptions.extglob)){let e=await n.expand(i);if(e.length>0)r.push(...e);else{if(n.hasFailglob())throw new lr(i);n.hasNullglob()||r.push(i)}}else r.push(i);return r}async function Xm(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternReplacement`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=Y(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=Q(t.pattern,!0,e.state.shoptOptions.extglob);else if(t.type===`Literal`)u+=Q(t.value,!0,e.state.shoptOptions.extglob);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Q(n,!0,e.state.shoptOptions.extglob)}else{let n=await r(e,t);u+=Z(n)}let d=s.replacement?await n(e,s.replacement.parts):``,f=u;s.anchor===`start`?f=`^${u}`:s.anchor===`end`&&(f=`${u}$`);let p=[];try{let e=M(f,s.all?`g`:``);for(let t of l)p.push(e.replace(t,d))}catch{p.push(...l)}let m=Qf(e.state.env),h=$f(e.state.env);if(o){let t=q(e.state.env),n=p.join(t);return h?{values:n?[n]:[],quoted:!1}:{values:J(n,m),quoted:!1}}if(h)return{values:p,quoted:!1};let ee=[];for(let e of p)e===``?ee.push(``):ee.push(...J(e,m));return{values:ee,quoted:!1}}async function Zm(e,t,n,r){let i=-1,a=``,o=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&n.operation?.type===`PatternRemoval`){let t=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t){i=e,a=t[1],o=t[2]===`*`;break}}}if(i===-1)return null;let s=t[i].operation,c=Y(e,a),l=c.map(([,e])=>e);if(c.length===0){let t=e.state.env.get(a);t!==void 0&&(l=[t])}if(l.length===0)return{values:[],quoted:!1};let u=``,d=e.state.shoptOptions.extglob;if(s.pattern)for(let t of s.pattern.parts)if(t.type===`Glob`)u+=Q(t.pattern,s.greedy,d);else if(t.type===`Literal`)u+=Q(t.value,s.greedy,d);else if(t.type===`SingleQuoted`||t.type===`Escaped`)u+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);u+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);u+=Q(n,s.greedy,d)}else{let n=await r(e,t);u+=Z(n)}let f=[];for(let e of l)f.push(zp(e,u,s.side,s.greedy));let p=Qf(e.state.env),m=$f(e.state.env);if(o){let t=q(e.state.env),n=f.join(t);return m?{values:n?[n]:[],quoted:!1}:{values:J(n,p),quoted:!1}}if(m)return{values:f,quoted:!1};let h=[];for(let e of f)e===``?h.push(``):h.push(...J(e,p));return{values:h,quoted:!1}}async function Qm(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`PatternRemoval`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=Number.parseInt(e.state.env.get(`#`)||`0`,10),c=[];for(let t=1;t<=s;t++)c.push(e.state.env.get(String(t))||``);if(c.length===0)return{values:[],quoted:!1};let l=``,u=e.state.shoptOptions.extglob;if(o.pattern)for(let t of o.pattern.parts)if(t.type===`Glob`)l+=Q(t.pattern,o.greedy,u);else if(t.type===`Literal`)l+=Q(t.value,o.greedy,u);else if(t.type===`SingleQuoted`||t.type===`Escaped`)l+=Z(t.value);else if(t.type===`DoubleQuoted`){let r=await n(e,t.parts);l+=Z(r)}else if(t.type===`ParameterExpansion`){let n=await r(e,t);l+=Q(n,o.greedy,u)}else{let n=await r(e,t);l+=Z(n)}let d=[];for(let e of c)d.push(zp(e,l,o.side,o.greedy));let f=Qf(e.state.env),p=$f(e.state.env);if(a){let t=q(e.state.env),n=d.join(t);return p?{values:n?[n]:[],quoted:!1}:{values:J(n,f),quoted:!1}}if(p)return{values:d,quoted:!1};let m=[];for(let e of d)e===``?m.push(``):m.push(...J(e,f));return{values:m,quoted:!1}}async function $m(e,t,n,r){let i=-1,a=!1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&n.operation?.type===`Substring`){i=e,a=n.parameter===`*`;break}}if(i===-1)return null;let o=t[i].operation,s=o.offset?await n(e,o.offset.expression):0,c=o.length?await n(e,o.length.expression):void 0,l=Number.parseInt(e.state.env.get(`#`)||`0`,10),u=[];for(let t=1;t<=l;t++)u.push(e.state.env.get(String(t))||``);let d=e.state.env.get(`0`)||`bash`,f;if(s<=0){let e=[d,...u],t=e.length+s;if(t<0)f=[];else{let n=s<0?t:0;if(c!==void 0){let t=c<0?e.length+c:n+c;f=e.slice(n,Math.max(n,t))}else f=e.slice(n)}}else{let e=s-1;if(e>=u.length)f=[];else if(c!==void 0){let t=c<0?u.length+c:e+c;f=u.slice(e,Math.max(e,t))}else f=u.slice(e)}let p=``;for(let n=0;n<i;n++)p+=await r(e,t[n]);let m=``;for(let n=i+1;n<t.length;n++)m+=await r(e,t[n]);let h=Qf(e.state.env),ee=$f(e.state.env);if(f.length===0){let e=p+m;return e?ee?{values:[e],quoted:!1}:{values:J(e,h),quoted:!1}:{values:[],quoted:!1}}let te;if(a){let t=q(e.state.env),n=p+f.join(t)+m;te=ee?n?[n]:[]:J(n,h)}else if(ee)te=f.length===1?[p+f[0]+m]:[p+f[0],...f.slice(1,-1),f[f.length-1]+m];else{te=[];for(let e=0;e<f.length;e++){let t=f[e];if(e===0&&(t=p+t),e===f.length-1&&(t+=m),t===``)te.push(``);else{let e=J(t,h);te.push(...e)}}}return{values:await Ym(e,te),quoted:!1}}async function eh(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].parameter!==`@`&&t[0].parameter!==`*`||t[0].operation)return null;let n=t[0].parameter===`*`,r=Number.parseInt(e.state.env.get(`#`)||`0`,10);if(r===0)return{values:[],quoted:!1};let i=[];for(let t=1;t<=r;t++)i.push(e.state.env.get(String(t))||``);let a=Qf(e.state.env),o=$f(e.state.env),s=ep(e.state.env),c;if(n)if(o)c=i.filter(e=>e!==``);else{let t=q(e.state.env);c=J(i.join(t),a)}else if(o)c=i.filter(e=>e!==``);else if(s){c=[];for(let e of i){if(e===``)continue;let t=J(e,a);c.push(...t)}}else{c=[];for(let e of i)if(e===``)c.push(``);else{let t=J(e,a);c.push(...t)}for(;c.length>0&&c[c.length-1]===``;)c.pop()}return{values:await Ym(e,c),quoted:!1}}async function th(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],i=n[2]===`*`,a=Y(e,r),o;if(a.length===0){let t=e.state.env.get(r);if(t!==void 0)o=[t];else return{values:[],quoted:!1}}else o=a.map(([,e])=>e);let s=Qf(e.state.env),c=$f(e.state.env),l=ep(e.state.env),u;if(i)if(c)u=o.filter(e=>e!==``);else{let t=q(e.state.env);u=J(o.join(t),s)}else if(c)u=o.filter(e=>e!==``);else if(l){u=[];for(let e of o){if(e===``)continue;let t=J(e,s);u.push(...t)}}else{u=[];for(let e of o)if(e===``)u.push(``);else{let t=J(e,s);u.push(...t)}for(;u.length>0&&u[u.length-1]===``;)u.pop()}return{values:await Ym(e,u),quoted:!1}}function nh(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`VarNamePrefix`)return null;let n=t[0].operation,r=Bp(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let i=Qf(e.state.env),a=$f(e.state.env),o;if(n.star)if(a)o=r;else{let t=q(e.state.env);o=J(r.join(t),i)}else if(a)o=r;else{o=[];for(let e of r){let t=J(e,i);o.push(...t)}}return{values:o,quoted:!1}}function rh(e,t){if(t.length!==1||t[0].type!==`ParameterExpansion`||t[0].operation?.type!==`ArrayKeys`)return null;let n=t[0].operation,r=Y(e,n.array).map(([e])=>String(e));if(r.length===0)return{values:[],quoted:!1};let i=Qf(e.state.env),a=$f(e.state.env),o;if(n.star)if(a)o=r;else{let t=q(e.state.env);o=J(r.join(t),i)}else if(a)o=r;else{o=[];for(let e of r){let t=J(e,i);o.push(...t)}}return{values:o,quoted:!1}}async function ih(e,t,n){let r=-1;for(let e=0;e<t.length;e++){let n=t[e];if(n.type===`ParameterExpansion`&&(n.parameter===`@`||n.parameter===`*`)&&!n.operation){r=e;break}}if(r===-1||t.length<=1)return null;let i=Number.parseInt(e.state.env.get(`#`)||`0`,10),a=[];for(let t=1;t<=i;t++)a.push(e.state.env.get(String(t))||``);let o=``;for(let i=0;i<r;i++)o+=await n(e,t[i]);let s=``;for(let i=r+1;i<t.length;i++)s+=await n(e,t[i]);let c=Qf(e.state.env),l=$f(e.state.env),u=ep(e.state.env);if(i===0){let e=o+s;return{values:e?[e]:[],quoted:!1}}let d;{let e=[];for(let t=0;t<a.length;t++){let n=a[t];t===0&&(n=o+n),t===a.length-1&&(n+=s),e.push(n)}if(l)d=e.filter(e=>e!==``);else if(u){d=[];for(let t of e){if(t===``)continue;let e=J(t,c);d.push(...e)}}else{d=[];for(let t of e)if(t===``)d.push(``);else{let e=J(t,c);d.push(...e)}for(;d.length>0&&d[d.length-1]===``;)d.pop()}}return d.length===0?{values:[],quoted:!1}:{values:await Ym(e,d),quoted:!1}}var ah=g(()=>{ta(),Hf(),x(),op(),jp(),Ap(),Rp(),Vp(),hp()});async function oh(e,t,n){e.coverage?.hit(`bash:expansion:word_glob`);let r=t.parts,{hasQuoted:i,hasCommandSub:a,hasArrayVar:o,hasArrayAtExpansion:s,hasParamExpansion:c,hasVarNamePrefixExpansion:l,hasIndirection:u}=Kf(r),d=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(d&&d.length>1)return sh(e,d,i);let f=await ch(e,r,s,l,u,n);if(f!==null)return f;let p=await uh(e,r,n);if(p!==null)return p;let m=await dh(e,r,n);if(m!==null)return m;let h=await mh(e,r,n.expandPart);if(h!==null)return hh(e,h);if((a||o||c)&&!$f(e.state.env)){let t=Qf(e.state.env),i=n.buildIfsCharClassPattern(t);return hh(e,await n.smartWordSplit(e,r,t,i,n.expandPart))}return _h(e,t,r,await n.expandWordAsync(e,t),i,n.expandWordForGlobbing)}async function sh(e,t,n){let r=[];for(let i of t)if(!(!n&&i===``))if(!n&&!e.state.options.noglob&&Ep(i,e.state.shoptOptions.extglob)){let t=await gh(e,i);r.push(...t)}else r.push(i);return{values:r,quoted:!1}}async function ch(e,t,n,r,i,a){if(n){let n=Nm(e,t);if(n!==null)return n}{let n=Pm(e,t);if(n!==null)return n}{let n=await Em(e,t);if(n!==null)return n}{let r=await Dm(e,t,n,a.expandPart,a.expandWordPartsAsync);if(r!==null)return r}{let r=await Om(e,t,n,a.expandPart);if(r!==null)return r}{let n=await Am(e,t,a.evaluateArithmetic);if(n!==null)return n}{let n=jm(e,t);if(n!==null)return n}{let n=await Cm(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}{let n=await wm(e,t,a.expandWordPartsAsync,a.expandPart);if(n!==null)return n}if(r&&t.length===1&&t[0].type===`DoubleQuoted`){let n=lh(e,t);if(n!==null)return n}{let n=await Im(e,t,i,a.expandParameterAsync,a.expandWordPartsAsync);if(n!==null)return n}{let n=await zm(e,t);if(n!==null)return n}{let n=await Bm(e,t);if(n!==null)return n}return null}function lh(e,t){let n=t[0];if(n.type!==`DoubleQuoted`)return null;if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`VarNamePrefix`){let t=n.parts[0].operation,r=Bp(e,t.prefix);return t.star?{values:[r.join(q(e.state.env))],quoted:!0}:{values:r,quoted:!0}}if(n.parts.length===1&&n.parts[0].type===`ParameterExpansion`&&n.parts[0].operation?.type===`ArrayKeys`){let t=n.parts[0].operation,r=Y(e,t.array).map(([e])=>String(e));return t.star?{values:[r.join(q(e.state.env))],quoted:!0}:{values:r,quoted:!0}}return null}async function uh(e,t,n){{let r=await Um(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await Wm(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await Gm(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await Km(e,t,n.expandPart);if(r!==null)return r}return null}async function dh(e,t,n){{let r=await Xm(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Zm(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Qm(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await $m(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let n=await eh(e,t);if(n!==null)return n}{let n=await th(e,t);if(n!==null)return n}{let n=nh(e,t);if(n!==null)return n}{let n=rh(e,t);if(n!==null)return n}{let r=await ih(e,t,n.expandPart);if(r!==null)return r}return null}function fh(e){if(e.type!==`DoubleQuoted`)return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!==`ParameterExpansion`||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:`array`,name:r[1],atIndex:t,isStar:r[2]===`*`};if(n.parameter===`@`||n.parameter===`*`)return{type:`positional`,atIndex:t,isStar:n.parameter===`*`}}return null}async function ph(e,t,n,r){let i=``;for(let a=0;a<n.atIndex;a++)i+=await r(e,t.parts[a]);let a=``;for(let i=n.atIndex+1;i<t.parts.length;i++)a+=await r(e,t.parts[i]);let o;if(n.type===`array`){if(o=Y(e,n.name).map(([,e])=>e),o.length===0){let t=e.state.env.get(n.name);t!==void 0&&(o=[t])}}else{let t=Number.parseInt(e.state.env.get(`#`)||`0`,10);o=[];for(let n=1;n<=t;n++)o.push(e.state.env.get(String(n))||``)}if(n.isStar){let t=q(e.state.env),n=o.join(t);return[i+n+a]}if(o.length===0){let e=i+a;return e?[e]:[]}return o.length===1?[i+o[0]+a]:[i+o[0],...o.slice(1,-1),o[o.length-1]+a]}async function mh(e,t,n){if(t.length<2)return null;let r=!1;for(let e of t)if(fh(e)){r=!0;break}if(!r)return null;let i=Qf(e.state.env),a=$f(e.state.env),o=[];for(let r of t){let t=fh(r);if(t&&r.type===`DoubleQuoted`){let i=await ph(e,r,t,n);o.push(i)}else if(r.type===`DoubleQuoted`||r.type===`SingleQuoted`){let t=await n(e,r);o.push([t])}else if(r.type===`Literal`)o.push([r.value]);else if(r.type===`ParameterExpansion`){let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let e=J(t,i);o.push(e)}}else{let t=await n(e,r);if(a)o.push(t?[t]:[]);else{let e=J(t,i);o.push(e)}}}let s=[];for(let e of o)if(e.length!==0)if(s.length===0)s.push(...e);else{let t=s.length-1;s[t]=s[t]+e[0];for(let t=1;t<e.length;t++)s.push(e[t])}return s}async function hh(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(Ep(r,e.state.shoptOptions.extglob)){let t=await gh(e,r);n.push(...t)}else n.push(r);return{values:n,quoted:!1}}async function gh(e,t){let n=new Vf(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new lr(t);return n.hasNullglob()?[]:[t]}async function _h(e,t,n,r,i,a){let o=n.some(e=>e.type===`Glob`);if(!e.state.options.noglob&&o){let n=await a(e,t);if(Ep(n,e.state.shoptOptions.extglob)){let t=await gh(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1};if(t.length===0)return{values:[],quoted:!1}}let i=Dp(r);return $f(e.state.env)?{values:[i],quoted:!1}:{values:J(i,Qf(e.state.env)),quoted:!1}}if(!i&&!e.state.options.noglob&&Ep(r,e.state.shoptOptions.extglob)){let n=await a(e,t);if(Ep(n,e.state.shoptOptions.extglob)){let t=await gh(e,n);if(t.length>0&&t[0]!==n)return{values:t,quoted:!1}}}if(r===``&&!i)return{values:[],quoted:!1};if(o&&!i){let t=Dp(r);return $f(e.state.env)?{values:[t],quoted:!1}:{values:J(t,Qf(e.state.env)),quoted:!1}}return{values:[r],quoted:i}}var vh=g(()=>{Hf(),x(),op(),qf(),Tm(),km(),Mm(),Fm(),Ap(),Vm(),Vp(),qm(),ah(),hp()});async function yh(e,t){let n=t.operation;if(!n||n.type!==`DefaultValue`&&n.type!==`AssignDefault`&&n.type!==`UseAlternative`)return null;let r=n.word;if(!r||r.parts.length===0)return null;let i=await mp(e,t.parameter),a=await X(e,t.parameter,!1)===``,o=n.checkEmpty??!1,s;return s=n.type===`UseAlternative`?i&&!(o&&a):!i||o&&a,s?r.parts:null}function bh(e){return e.type===`SingleQuoted`?!0:e.type===`DoubleQuoted`?e.parts.every(e=>e.type===`Literal`):!1}async function xh(e,t){if(t.type!==`ParameterExpansion`)return null;let n=await yh(e,t);if(!n||n.length<=1)return null;let r=n.some(e=>bh(e)),i=n.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`);return r&&i?n:null}function Sh(e){return e.type===`DoubleQuoted`||e.type===`SingleQuoted`||e.type===`Literal`?!1:e.type===`Glob`?Uf(e.pattern):!(!(e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`)||e.type===`ParameterExpansion`&&Gf(e))}async function Ch(e,t,n,r,i){if(e.coverage?.hit(`bash:expansion:word_split`),t.length===1&&t[0].type===`ParameterExpansion`){let a=t[0],o=await yh(e,a);if(o&&o.length>0&&o.length>1&&o.some(e=>e.type===`DoubleQuoted`||e.type===`SingleQuoted`)&&o.some(e=>e.type===`Literal`||e.type===`ParameterExpansion`||e.type===`CommandSubstitution`||e.type===`ArithmeticExpansion`))return Th(e,o,n,r,i)}let a=[],o=!1;for(let n of t){let t=Sh(n),r=n.type===`DoubleQuoted`||n.type===`SingleQuoted`,s=t?await xh(e,n):null,c=await i(e,n);a.push({value:c,isSplittable:t,isQuoted:r,mixedDefaultParts:s??void 0}),t&&(o=!0)}if(!o){let e=a.map(e=>e.value).join(``);return e?[e]:[]}let s=[],c=``,l=!1,u=!1,d=!1;for(let t of a)if(!t.isSplittable)u?t.isQuoted&&t.value===``?(c!==``&&s.push(c),s.push(``),l=!0,c=``,u=!1,d=!0):t.value===``?(c+=t.value,d=!1):(c!==``&&s.push(c),c=t.value,u=!1,d=!1):(c+=t.value,d=t.isQuoted&&t.value===``);else if(t.mixedDefaultParts){let a=await Th(e,t.mixedDefaultParts,n,r,i);if(a.length!==0)if(a.length===1)c+=a[0],l=!0;else{c+=a[0],s.push(c),l=!0;for(let e=1;e<a.length-1;e++)s.push(a[e]);c=a[a.length-1]}u=!1,d=!1}else{let{words:e,hadLeadingDelimiter:r,hadTrailingDelimiter:i}=ip(t.value,n);if(d&&r&&c===``&&(s.push(``),l=!0),e.length===0)i&&(u=!0);else if(e.length===1)c+=e[0],l=!0,u=i;else{c+=e[0],s.push(c),l=!0;for(let t=1;t<e.length-1;t++)s.push(e[t]);c=e[e.length-1],u=i}d=!1}return c===``?s.length===0&&l&&s.push(``):s.push(c),s}function wh(e,t){return e.length>0&&t.includes(e[0])}async function Th(e,t,n,r,i){let a=[];for(let n of t){let t=!(n.type===`DoubleQuoted`||n.type===`SingleQuoted`),r=await i(e,n);a.push({value:r,isSplittable:t})}let o=[],s=``,c=!1,l=!1;for(let e of a)if(!e.isSplittable)l&&e.value!==``?(s!==``&&o.push(s),s=e.value,l=!1):s+=e.value;else{wh(e.value,n)&&s!==``&&(o.push(s),s=``,c=!0);let{words:t,hadTrailingDelimiter:r}=ip(e.value,n);if(t.length===0)r&&(l=!0);else if(t.length===1)s+=t[0],c=!0,l=r;else{s+=t[0],o.push(s),c=!0;for(let e=1;e<t.length-1;e++)o.push(t[e]);s=t[t.length-1],l=r}}return s===``?o.length===0&&c&&o.push(``):o.push(s),o}var Eh=g(()=>{hp(),op(),qf()});function Dh(e){switch(e.type){case`Literal`:return e.value;case`SingleQuoted`:return e.value;case`Escaped`:return e.value;default:return null}}function Oh(e){switch(e.type){case`SingleQuoted`:case`Escaped`:case`DoubleQuoted`:return!0;case`Literal`:return e.value===``;default:return!1}}var kh=g(()=>{});_({},{escapeGlobChars:()=>Op,escapeRegexChars:()=>kp,expandRedirectTarget:()=>Kh,expandWord:()=>Fh,expandWordForPattern:()=>Lh,expandWordForRegex:()=>Ih,expandWordWithGlob:()=>Uh,getArrayElements:()=>Y,getVariable:()=>X,hasQuotedMultiValueAt:()=>Gh,isArray:()=>pp,isWordFullyQuoted:()=>Nh});function Ah(e,t,n){if(e.length>t)throw new b(`${n}: string length limit exceeded (${t} bytes)`,`string_length`)}async function jh(e,t,n=!1){let r=[];for(let i of t)r.push(await Jh(e,i,n));return r.join(``)}function Mh(e){return Oh(e)}function Nh(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!Mh(t))return!1;return!0}function Ph(e,t,n=!1){let r=Dh(t);if(r!==null)return r;switch(t.type){case`TildeExpansion`:return n?t.user===null?`~`:`~${t.user}`:(e.coverage?.hit(`bash:expansion:tilde`),t.user===null?e.state.env.get(`HOME`)??`/home/user`:t.user===`root`?`/root`:`~${t.user}`);case`Glob`:return hm(e,t.pattern);default:return null}}async function Fh(e,t){return qh(e,t)}async function Ih(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`)n.push(`\\${r.value}`);else if(r.type===`SingleQuoted`)n.push(r.value);else if(r.type===`DoubleQuoted`){let t=await jh(e,r.parts);n.push(t)}else if(r.type===`TildeExpansion`){let t=await Jh(e,r);n.push(kp(t))}else n.push(await Jh(e,r));return n.join(``)}async function Lh(e,t){let n=[];for(let r of t.parts)if(r.type===`Escaped`){let e=r.value;`()|*?[]`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`SingleQuoted`)n.push(Op(r.value));else if(r.type===`DoubleQuoted`){let t=await jh(e,r.parts);n.push(Op(t))}else n.push(await Jh(e,r));return n.join(``)}async function Rh(e,t){let n=[];for(let r of t.parts)if(r.type===`SingleQuoted`)n.push(Op(r.value));else if(r.type===`Escaped`){let e=r.value;`*?[]\\()|`.includes(e)?n.push(`\\${e}`):n.push(e)}else if(r.type===`DoubleQuoted`){let t=await jh(e,r.parts);n.push(Op(t))}else r.type===`Glob`?fm(r.pattern)?n.push(await _m(e,r.pattern)):n.push(hm(e,r.pattern)):r.type===`Literal`?n.push(r.value):n.push(await Jh(e,r));return n.join(``)}function zh(e){for(let t of e)if(t.type===`BraceExpansion`||t.type===`DoubleQuoted`&&zh(t.parts))return!0;return!1}async function Bh(e,t,n={count:0}){if(n.count>Xh)return[[]];let r=[[]];for(let i of t)if(i.type===`BraceExpansion`){let t=[],a=!1,o=``;for(let r of i.items)if(r.type===`Range`){let e=xp(r.start,r.end,r.step,r.startStr,r.endStr);if(e.expanded)for(let r of e.expanded)n.count++,t.push(r);else{a=!0,o=e.literal;break}}else{let i=await Bh(e,r.word.parts,n);for(let r of i){n.count++;let i=[];for(let t of r)typeof t==`string`?i.push(t):i.push(await Jh(e,t));t.push(i.join(``))}}if(a){for(let e of r)n.count++,e.push(o);continue}if(r.length*t.length>e.limits.maxBraceExpansionResults||n.count>Xh)return r;let s=[];for(let e of r)for(let i of t){if(n.count++,n.count>Xh)return s.length>0?s:r;s.push([...e,i])}r=s}else for(let e of r)n.count++,e.push(i);return r}async function Vh(e,t){let n=t.parts;if(!zh(n))return[await Fh(e,t)];let r=await Bh(e,n),i=[];for(let t of r){let n=[];for(let r of t)typeof r==`string`?n.push(r):n.push(await Jh(e,r));i.push(bm(e,n.join(``)))}return i}function Hh(){return{expandWordAsync:qh,expandWordForGlobbing:Rh,expandWordWithBracesAsync:Vh,expandWordPartsAsync:jh,expandPart:Jh,expandParameterAsync:Yh,hasBraceExpansion:zh,evaluateArithmetic:$,buildIfsCharClassPattern:tp,smartWordSplit:Ch}}async function Uh(e,t){return oh(e,t,Hh())}function Wh(e){for(let t of e){if(t.type===`ParameterExpansion`)return t.parameter;if(t.type===`Literal`)return t.value}return``}function Gh(e,t){if(Number.parseInt(e.state.env.get(`#`)||`0`,10)<2)return!1;function n(e){for(let t of e)if(t.type===`DoubleQuoted`){for(let e of t.parts)if(e.type===`ParameterExpansion`&&e.parameter===`@`&&!e.operation)return!0}return!1}return n(t.parts)}async function Kh(e,t){if(Gh(e,t))return{error:`bash: $@: ambiguous redirect
216
+ `};let n=t.parts,{hasQuoted:r}=Kf(n);if(zh(n)&&(await Vh(e,t)).length>1)return{error:`bash: ${n.map(e=>e.type===`Literal`?e.value:e.type===`BraceExpansion`?`{${e.items.map(e=>{if(e.type===`Range`){let t=e.step?`..${e.step}`:``;return`${e.startStr??e.start}..${e.endStr??e.end}${t}`}return e.word.parts.map(e=>e.type===`Literal`?e.value:``).join(``)}).join(`,`)}}`:``).join(``)}: ambiguous redirect
217
+ `};let i=await qh(e,t),{hasParamExpansion:a,hasCommandSub:o}=Kf(n);if((a||o)&&!r&&!$f(e.state.env)&&J(i,Qf(e.state.env)).length>1)return{error:`bash: $${Wh(n)}: ambiguous redirect
218
+ `};if(r||e.state.options.noglob)return{target:i};let s=await Rh(e,t);if(!Ep(s,e.state.shoptOptions.extglob))return{target:i};let c=new Vf(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),l=await c.expand(s);return l.length===0?c.hasFailglob()?{error:`bash: no match: ${i}
214
219
  `}:{target:i}:l.length===1?{target:l[0]}:{error:`bash: ${i}: ambiguous redirect
215
- `}}async function Wh(e,t){let n=t.parts,r=n.length;if(r===1){let t=await Gh(e,n[0]);return Dh(t,e.limits.maxStringLength,`word expansion`),t}let i=[];for(let t=0;t<r;t++)i.push(await Gh(e,n[t]));let a=i.join(``);return Dh(a,e.limits.maxStringLength,`word expansion`),a}async function Gh(e,t,n=!1){if(t.type===`ParameterExpansion`)return Kh(e,t,n);let r=jh(e,t,n);if(r!==null)return r;switch(t.type){case`DoubleQuoted`:{let n=[];for(let r of t.parts)n.push(await Gh(e,r,!0));return n.join(``)}case`CommandSubstitution`:{let n=xp(t.body);if(n)try{let t=await Mh(e,n.target),r=t.startsWith(`/`)?t:`${e.state.cwd}/${t}`,i=await e.fs.readFile(r);e.state.lastExitCode=0,e.state.env.set(`?`,`0`);let a=i.replace(/\n+$/,``);return Dh(a,e.limits.maxStringLength,`command substitution`),a}catch(t){if(t instanceof b)throw t;return e.state.lastExitCode=1,e.state.env.set(`?`,`1`),``}let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new b(`Command substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth;e.substitutionDepth=r+1;let o=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let s=new Map(e.state.env),c=e.state.cwd,l=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let n=await e.executeScript(t.body),r=n.exitCode;e.state.env=s,e.state.cwd=c,e.state.suppressVerbose=l,e.state.lastExitCode=r,e.state.env.set(`?`,String(r)),n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),e.state.bashPid=o,e.substitutionDepth=a;let i=n.stdout.replace(/\n+$/,``);return Dh(i,e.limits.maxStringLength,`command substitution`),i}catch(t){if(e.state.env=s,e.state.cwd=c,e.state.bashPid=o,e.substitutionDepth=a,e.state.suppressVerbose=l,t instanceof b)throw t;if(t instanceof or){e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr);let n=t.stdout.replace(/\n+$/,``);return Dh(n,e.limits.maxStringLength,`command substitution`),n}throw t}}case`ArithmeticExpansion`:{let n=t.expression.originalText;if(n&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(n)){let t=await pp(e,n),r=rd(new kf,t);return String(await $(e,r.expression,!0))}return String(await $(e,t.expression.expression,!0))}case`BraceExpansion`:{let n=[];for(let r of t.items)if(r.type===`Range`){let e=vp(r.start,r.end,r.step,r.startStr,r.endStr);if(e.expanded)n.push(...e.expanded);else return e.literal}else n.push(await Mh(e,r.word));return n.join(` `)}default:return``}}async function Kh(e,t,n=!1){let{parameter:r}=t,{operation:i}=t,a=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,t,n]=a;(e.state.associativeArrays?.has(t)||n.includes(`$(`)||n.includes("`")||n.includes("${"))&&(r=`${t}[${await mp(e,n)}]`)}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&ip(e,r)){let t=op(e,r);if(t&&t!==r){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let[,t,i]=n;(e.state.associativeArrays?.has(t)||i.includes(`$(`)||i.includes("`")||i.includes("${"))&&(r=`${t}[${await mp(e,i)}]`)}}}let o=i&&(i.type===`DefaultValue`||i.type===`AssignDefault`||i.type===`UseAlternative`||i.type===`ErrorIfUnset`),s=await X(e,r,!o);if(!i)return s;let c=!await dp(e,r),{isEmpty:l,effectiveValue:u}=sm(e,r,s,n),d={value:s,isUnset:c,isEmpty:l,effectiveValue:u,inDoubleQuotes:n};switch(i.type){case`DefaultValue`:return Jp(e,i,d,Oh);case`AssignDefault`:return Yp(e,r,i,d,Oh);case`ErrorIfUnset`:return Xp(e,r,i,d,Oh);case`UseAlternative`:return Zp(e,i,d,Oh);case`PatternRemoval`:{let t=await Qp(e,s,i,Oh,Gh);return Dh(t,e.limits.maxStringLength,`pattern removal`),t}case`PatternReplacement`:{let t=await $p(e,s,i,Oh,Gh);return Dh(t,e.limits.maxStringLength,`pattern replacement`),t}case`Length`:return em(e,r,s);case`LengthSliceError`:throw new cr(r);case`BadSubstitution`:throw new cr(i.text);case`Substring`:return tm(e,r,s,i);case`CaseModification`:{let t=await nm(e,s,i,Oh,Kh);return Dh(t,e.limits.maxStringLength,`case modification`),t}case`Transform`:return rm(e,r,s,c,i);case`Indirection`:return im(e,r,s,c,i,Kh,n);case`ArrayKeys`:return am(e,i);case`VarNamePrefix`:return om(e,i);default:return s}}var qh,Jh=g(()=>{wd(),K(),zf(),ig(),x(),Wf(),hp(),bp(),Sp(),Dp(),cm(),gm(),vm(),fp(),hh(),Ch(),rp(),cp(),Eh(),Dp(),fp(),qh=1e5});function Yh(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:if(t===0)throw new sr(`division by 0`);return Math.trunc(e/t);case`%`:if(t===0)throw new sr(`division by 0`);return e%t;case`**`:if(t<0)throw new sr(`exponent less than 0`);return e**t;case`<<`:return e<<t;case`>>`:return e>>t;case`<`:return+(e<t);case`<=`:return+(e<=t);case`>`:return+(e>t);case`>=`:return+(e>=t);case`==`:return+(e===t);case`!=`:return e===t?0:1;case`&`:return e&t;case`|`:return e|t;case`^`:return e^t;case`,`:return t;default:return 0}}function Xh(e,t,n){switch(n){case`=`:return t;case`+=`:return e+t;case`-=`:return e-t;case`*=`:return e*t;case`/=`:return t===0?0:Math.trunc(e/t);case`%=`:return t===0?0:e%t;case`<<=`:return e<<t;case`>>=`:return e>>t;case`&=`:return e&t;case`|=`:return e|t;case`^=`:return e^t;default:return t}}function Zh(e,t){switch(t){case`-`:return-e;case`+`:return+e;case`!`:return+(e===0);case`~`:return~e;default:return e}}async function Qh(e,t){let n=e.state.env.get(t);if(n!==void 0)return n;let r=e.state.env.get(`${t}_0`);return r===void 0?await X(e,t):r}function $h(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\d+$/.test(e.trim()))return t;let n=e.trim();if(!n)return 0;try{let{expr:e,pos:r}=od(new kf,n,0);if(r<n.length){let e=n.slice(r).trim().split(/\s+/)[0];throw new sr(`${n}: syntax error in expression (error token is "${e}")`)}return e.type===`ArithNumber`?e.value:t||0}catch(e){if(e instanceof sr)throw e;let t=n.split(/\s+/).slice(1)[0]||n;throw new sr(`${n}: syntax error in expression (error token is "${t}")`)}}async function eg(e,t){if(!t)return 0;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(t.trim()))return n;let r=t.trim();if(!r)return 0;let{expr:i,pos:a}=od(new kf,r,0);if(a<r.length){let e=r.slice(a).trim(),t=e.split(/\s+/)[0]||e;throw new sr(`syntax error in expression (error token is "${t}")`,``,``)}return await $(e,i)}async function tg(e,t,n=new Set,r=0){if(r>100)throw new sr(`maximum variable indirection depth exceeded`);if(n.has(t))return 0;n.add(t);let i=await Qh(e,t);if(!i)return 0;let a=Number.parseInt(i,10);if(!Number.isNaN(a)&&/^-?\d+$/.test(i.trim()))return a;let o=i.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o))return await tg(e,o,n,r+1);let{expr:s,pos:c}=od(new kf,o,0);if(c<o.length){let e=o.slice(c).trim(),t=e.split(/\s+/)[0]||e;throw new sr(`${o}: syntax error in expression (error token is "${t}")`)}return await $(e,s)}async function ng(e,t){if(t.startsWith(`#`)){let n=t.slice(1),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=Y(e,t);return String(n.length)}let i=e.state.env.get(n)||``;return String(i.length)}if(t.startsWith(`!`)){let n=t.slice(1),r=e.state.env.get(n)||``;return e.state.env.get(r)||``}let n=[`:-`,`:=`,`:?`,`:+`,`-`,`=`,`?`,`+`],r=-1,i=``;for(let e of n){let n=t.indexOf(e);n>0&&(r===-1||n<r)&&(r=n,i=e)}if(r===-1)return await X(e,t);let a=t.slice(0,r),o=t.slice(r+i.length),s=e.state.env.get(a),c=s===void 0,l=s===``,u=i.startsWith(`:`);switch(i){case`:-`:case`-`:return c||u&&l?o:s||``;case`:=`:case`=`:return c||u&&l?(e.state.env.set(a,o),o):s||``;case`:+`:case`+`:return c||u&&l?``:o;case`:?`:case`?`:if(c||u&&l)throw Error(o||`${a}: parameter null or not set`);return s||``;default:return s||``}}async function $(e,t,n=!1){switch(t.type){case`ArithNumber`:if(Number.isNaN(t.value))throw new sr(`value too great for base`);return t.value;case`ArithVariable`:return await tg(e,t.name);case`ArithSpecialVar`:{let n=(await X(e,t.name)).trim();if(!n)return 0;let r=Number.parseInt(n,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(n))return r;let{expr:i}=od(new kf,n,0);return await $(e,i)}case`ArithNested`:return await $(e,t.expression);case`ArithCommandSubst`:if(e.execFn){let n=await e.execFn(t.command,{signal:e.state.signal});n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr);let r=n.stdout.trim();return Number.parseInt(r,10)||0}return 0;case`ArithBracedExpansion`:{let n=await ng(e,t.content);return Number.parseInt(n,10)||0}case`ArithDynamicBase`:{let n=await ng(e,t.baseExpr),r=Number.parseInt(n,10);return r<2||r>64?0:Xu(`${r}#${t.value}`)}case`ArithDynamicNumber`:return Xu(await ng(e,t.prefix)+t.suffix);case`ArithArrayElement`:{let r=e.state.associativeArrays?.has(t.array),i=async t=>{let n=e.state.env.get(t);return n===void 0?0:await eg(e,n)};if(t.stringKey!==void 0)return await i(`${t.array}_${t.stringKey}`);if(r&&t.index?.type===`ArithVariable`&&!t.index.hasDollarPrefix)return await i(`${t.array}_${t.index.name}`);if(r&&t.index?.type===`ArithVariable`&&t.index.hasDollarPrefix){let n=await X(e,t.index.name);return await i(`${t.array}_${n}`)}if(t.index){let r=await $(e,t.index,n);if(r<0){let n=Y(e,t.array),i=e.state.currentLine;if(n.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript
220
+ `}}async function qh(e,t){let n=t.parts,r=n.length;if(r===1){let t=await Jh(e,n[0]);return Ah(t,e.limits.maxStringLength,`word expansion`),t}let i=[];for(let t=0;t<r;t++)i.push(await Jh(e,n[t]));let a=i.join(``);return Ah(a,e.limits.maxStringLength,`word expansion`),a}async function Jh(e,t,n=!1){if(t.type===`ParameterExpansion`)return Yh(e,t,n);let r=Ph(e,t,n);if(r!==null)return r;switch(t.type){case`DoubleQuoted`:{let n=[];for(let r of t.parts)n.push(await Jh(e,r,!0));return n.join(``)}case`CommandSubstitution`:{let n=wp(t.body);if(n)try{let t=await Fh(e,n.target),r=t.startsWith(`/`)?t:`${e.state.cwd}/${t}`,i=await e.fs.readFile(r);e.state.lastExitCode=0,e.state.env.set(`?`,`0`);let a=i.replace(/\n+$/,``);return Ah(a,e.limits.maxStringLength,`command substitution`),a}catch(t){if(t instanceof b)throw t;return e.state.lastExitCode=1,e.state.env.set(`?`,`1`),``}let r=e.substitutionDepth??0,i=e.limits.maxSubstitutionDepth;if(r>=i)throw new b(`Command substitution nesting limit exceeded (${i})`,`substitution_depth`);let a=e.substitutionDepth;e.substitutionDepth=r+1;let o=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let s=new Map(e.state.env),c=e.state.cwd,l=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let n=await e.executeScript(t.body),r=n.exitCode;e.state.env=s,e.state.cwd=c,e.state.suppressVerbose=l,e.state.lastExitCode=r,e.state.env.set(`?`,String(r)),n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr),e.state.bashPid=o,e.substitutionDepth=a;let i=n.stdout.replace(/\n+$/,``);return Ah(i,e.limits.maxStringLength,`command substitution`),i}catch(t){if(e.state.env=s,e.state.cwd=c,e.state.bashPid=o,e.substitutionDepth=a,e.state.suppressVerbose=l,t instanceof b)throw t;if(t instanceof or){e.state.lastExitCode=t.exitCode,e.state.env.set(`?`,String(t.exitCode)),t.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+t.stderr);let n=t.stdout.replace(/\n+$/,``);return Ah(n,e.limits.maxStringLength,`command substitution`),n}throw t}}case`ArithmeticExpansion`:{let n=t.expression.originalText;if(n&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(n)){let t=await gp(e,n),r=ud(new Mf,t);return String(await $(e,r.expression,!0))}return String(await $(e,t.expression.expression,!0))}case`BraceExpansion`:{let n=[];for(let r of t.items)if(r.type===`Range`){let e=xp(r.start,r.end,r.step,r.startStr,r.endStr);if(e.expanded)n.push(...e.expanded);else return e.literal}else n.push(await Fh(e,r.word));return n.join(` `)}default:return``}}async function Yh(e,t,n=!1){let{parameter:r}=t,{operation:i}=t,a=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,t,n]=a;(e.state.associativeArrays?.has(t)||n.includes(`$(`)||n.includes("`")||n.includes("${"))&&(r=`${t}[${await _p(e,n)}]`)}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&sp(e,r)){let t=lp(e,r);if(t&&t!==r){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let[,t,i]=n;(e.state.associativeArrays?.has(t)||i.includes(`$(`)||i.includes("`")||i.includes("${"))&&(r=`${t}[${await _p(e,i)}]`)}}}let o=i&&(i.type===`DefaultValue`||i.type===`AssignDefault`||i.type===`UseAlternative`||i.type===`ErrorIfUnset`),s=await X(e,r,!o);if(!i)return s;let c=!await mp(e,r),{isEmpty:l,effectiveValue:u}=um(e,r,s,n),d={value:s,isUnset:c,isEmpty:l,effectiveValue:u,inDoubleQuotes:n};switch(i.type){case`DefaultValue`:return Zp(e,i,d,jh);case`AssignDefault`:return Qp(e,r,i,d,jh);case`ErrorIfUnset`:return $p(e,r,i,d,jh);case`UseAlternative`:return em(e,i,d,jh);case`PatternRemoval`:{let t=await tm(e,s,i,jh,Jh);return Ah(t,e.limits.maxStringLength,`pattern removal`),t}case`PatternReplacement`:{let t=await nm(e,s,i,jh,Jh);return Ah(t,e.limits.maxStringLength,`pattern replacement`),t}case`Length`:return rm(e,r,s);case`LengthSliceError`:throw new cr(r);case`BadSubstitution`:throw new cr(i.text);case`Substring`:return im(e,r,s,i);case`CaseModification`:{let t=await am(e,s,i,jh,Yh);return Ah(t,e.limits.maxStringLength,`case modification`),t}case`Transform`:return om(e,r,s,c,i);case`Indirection`:return sm(e,r,s,c,i,Yh,n);case`ArrayKeys`:return cm(e,i);case`VarNamePrefix`:return lm(e,i);default:return s}}var Xh,Zh=g(()=>{jd(),K(),Hf(),sg(),x(),qf(),vp(),Cp(),Tp(),Ap(),dm(),ym(),xm(),hp(),vh(),Eh(),op(),dp(),kh(),Ap(),hp(),Xh=1e5});function Qh(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:if(t===0)throw new sr(`division by 0`);return Math.trunc(e/t);case`%`:if(t===0)throw new sr(`division by 0`);return e%t;case`**`:if(t<0)throw new sr(`exponent less than 0`);return e**t;case`<<`:return e<<t;case`>>`:return e>>t;case`<`:return+(e<t);case`<=`:return+(e<=t);case`>`:return+(e>t);case`>=`:return+(e>=t);case`==`:return+(e===t);case`!=`:return e===t?0:1;case`&`:return e&t;case`|`:return e|t;case`^`:return e^t;case`,`:return t;default:return 0}}function $h(e,t,n){switch(n){case`=`:return t;case`+=`:return e+t;case`-=`:return e-t;case`*=`:return e*t;case`/=`:return t===0?0:Math.trunc(e/t);case`%=`:return t===0?0:e%t;case`<<=`:return e<<t;case`>>=`:return e>>t;case`&=`:return e&t;case`|=`:return e|t;case`^=`:return e^t;default:return t}}function eg(e,t){switch(t){case`-`:return-e;case`+`:return+e;case`!`:return+(e===0);case`~`:return~e;default:return e}}async function tg(e,t){let n=e.state.env.get(t);if(n!==void 0)return n;let r=e.state.env.get(`${t}_0`);return r===void 0?await X(e,t):r}function ng(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\d+$/.test(e.trim()))return t;let n=e.trim();if(!n)return 0;try{let{expr:e,pos:r}=pd(new Mf,n,0);if(r<n.length){let e=n.slice(r).trim().split(/\s+/)[0];throw new sr(`${n}: syntax error in expression (error token is "${e}")`)}return e.type===`ArithNumber`?e.value:t||0}catch(e){if(e instanceof sr)throw e;let t=n.split(/\s+/).slice(1)[0]||n;throw new sr(`${n}: syntax error in expression (error token is "${t}")`)}}async function rg(e,t){if(!t)return 0;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(t.trim()))return n;let r=t.trim();if(!r)return 0;let{expr:i,pos:a}=pd(new Mf,r,0);if(a<r.length){let e=r.slice(a).trim(),t=e.split(/\s+/)[0]||e;throw new sr(`syntax error in expression (error token is "${t}")`,``,``)}return await $(e,i)}async function ig(e,t,n=new Set,r=0){if(r>100)throw new sr(`maximum variable indirection depth exceeded`);if(n.has(t))return 0;n.add(t);let i=await tg(e,t);if(!i)return 0;let a=Number.parseInt(i,10);if(!Number.isNaN(a)&&/^-?\d+$/.test(i.trim()))return a;let o=i.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o))return await ig(e,o,n,r+1);let{expr:s,pos:c}=pd(new Mf,o,0);if(c<o.length){let e=o.slice(c).trim(),t=e.split(/\s+/)[0]||e;throw new sr(`${o}: syntax error in expression (error token is "${t}")`)}return await $(e,s)}async function ag(e,t){if(t.startsWith(`#`)){let n=t.slice(1),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let t=r[1],n=Y(e,t);return String(n.length)}let i=e.state.env.get(n)||``;return String(i.length)}if(t.startsWith(`!`)){let n=t.slice(1),r=e.state.env.get(n)||``;return e.state.env.get(r)||``}let n=[`:-`,`:=`,`:?`,`:+`,`-`,`=`,`?`,`+`],r=-1,i=``;for(let e of n){let n=t.indexOf(e);n>0&&(r===-1||n<r)&&(r=n,i=e)}if(r===-1)return await X(e,t);let a=t.slice(0,r),o=t.slice(r+i.length),s=e.state.env.get(a),c=s===void 0,l=s===``,u=i.startsWith(`:`);switch(i){case`:-`:case`-`:return c||u&&l?o:s||``;case`:=`:case`=`:return c||u&&l?(e.state.env.set(a,o),o):s||``;case`:+`:case`+`:return c||u&&l?``:o;case`:?`:case`?`:if(c||u&&l)throw Error(o||`${a}: parameter null or not set`);return s||``;default:return s||``}}async function $(e,t,n=!1){switch(t.type){case`ArithNumber`:if(Number.isNaN(t.value))throw new sr(`value too great for base`);return t.value;case`ArithVariable`:return await ig(e,t.name);case`ArithSpecialVar`:{let n=(await X(e,t.name)).trim();if(!n)return 0;let r=Number.parseInt(n,10);if(!Number.isNaN(r)&&/^-?\d+$/.test(n))return r;let{expr:i}=pd(new Mf,n,0);return await $(e,i)}case`ArithNested`:return await $(e,t.expression);case`ArithCommandSubst`:if(e.execFn){let n=await e.execFn(t.command,{signal:e.state.signal});n.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||``)+n.stderr);let r=n.stdout.trim();return Number.parseInt(r,10)||0}return 0;case`ArithBracedExpansion`:{let n=await ag(e,t.content);return Number.parseInt(n,10)||0}case`ArithDynamicBase`:{let n=await ag(e,t.baseExpr),r=Number.parseInt(n,10);return r<2||r>64?0:rd(`${r}#${t.value}`)}case`ArithDynamicNumber`:return rd(await ag(e,t.prefix)+t.suffix);case`ArithArrayElement`:{let r=e.state.associativeArrays?.has(t.array),i=async t=>{let n=e.state.env.get(t);return n===void 0?0:await rg(e,n)};if(t.stringKey!==void 0)return await i(`${t.array}_${t.stringKey}`);if(r&&t.index?.type===`ArithVariable`&&!t.index.hasDollarPrefix)return await i(`${t.array}_${t.index.name}`);if(r&&t.index?.type===`ArithVariable`&&t.index.hasDollarPrefix){let n=await X(e,t.index.name);return await i(`${t.array}_${n}`)}if(t.index){let r=await $(e,t.index,n);if(r<0){let n=Y(e,t.array),i=e.state.currentLine;if(n.length===0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript
216
221
  `,0;let a=Math.max(...n.map(([e])=>typeof e==`number`?e:0))+1+r;if(a<0)return e.state.expansionStderr=(e.state.expansionStderr||``)+`bash: line ${i}: ${t.array}: bad array subscript
217
- `,0;r=a}let i=`${t.array}_${r}`,a=e.state.env.get(i);if(a!==void 0)return eg(e,a);if(r===0){let n=e.state.env.get(t.array);if(n!==void 0)return eg(e,n)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(e=>e===t.array||e.startsWith(`${t.array}_`)))throw new ar(`${t.array}[${r}]`);return 0}return 0}case`ArithDoubleSubscript`:throw new sr(`double subscript`,``,``);case`ArithNumberSubscript`:throw new sr(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case`ArithSyntaxError`:throw new sr(t.message,``,``,!0);case`ArithSingleQuote`:if(n)throw new sr(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value;case`ArithBinary`:return t.operator===`||`?await $(e,t.left,n)||await $(e,t.right,n)?1:0:t.operator===`&&`?await $(e,t.left,n)&&await $(e,t.right,n)?1:0:Yh(await $(e,t.left,n),await $(e,t.right,n),t.operator);case`ArithUnary`:{let r=await $(e,t.operand,n);if(t.operator===`++`||t.operator===`--`){if(t.operand.type===`ArithVariable`){let n=t.operand.name,r=Number.parseInt(await X(e,n),10)||0,i=t.operator===`++`?r+1:r-1;return e.state.env.set(n,String(i)),t.prefix?i:r}if(t.operand.type===`ArithArrayElement`){let i=t.operand.array,a=e.state.associativeArrays?.has(i),o;if(t.operand.stringKey!==void 0)o=`${i}_${t.operand.stringKey}`;else if(a&&t.operand.index?.type===`ArithVariable`&&!t.operand.index.hasDollarPrefix)o=`${i}_${t.operand.index.name}`;else if(a&&t.operand.index?.type===`ArithVariable`&&t.operand.index.hasDollarPrefix)o=`${i}_${await X(e,t.operand.index.name)}`;else if(t.operand.index)o=`${i}_${await $(e,t.operand.index,n)}`;else return r;let s=Number.parseInt(e.state.env.get(o)||`0`,10)||0,c=t.operator===`++`?s+1:s-1;return e.state.env.set(o,String(c)),t.prefix?c:s}if(t.operand.type===`ArithConcat`){let r=``;for(let i of t.operand.parts)r+=await rg(e,i,n);if(r&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)){let n=Number.parseInt(e.state.env.get(r)||`0`,10)||0,i=t.operator===`++`?n+1:n-1;return e.state.env.set(r,String(i)),t.prefix?i:n}}if(t.operand.type===`ArithDynamicElement`){let r=``;if(t.operand.nameExpr.type===`ArithConcat`)for(let i of t.operand.nameExpr.parts)r+=await rg(e,i,n);else t.operand.nameExpr.type===`ArithVariable`&&(r=t.operand.nameExpr.hasDollarPrefix?await X(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(r&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)){let i=await $(e,t.operand.subscript,n),a=`${r}_${i}`,o=Number.parseInt(e.state.env.get(a)||`0`,10)||0,s=t.operator===`++`?o+1:o-1;return e.state.env.set(a,String(s)),t.prefix?s:o}}return r}return Zh(r,t.operator)}case`ArithTernary`:return await $(e,t.condition,n)?await $(e,t.consequent,n):await $(e,t.alternate,n);case`ArithAssignment`:{let r=t.variable,i=r;if(t.stringKey!==void 0)i=`${r}_${t.stringKey}`;else if(t.subscript){let a=e.state.associativeArrays?.has(r);if(a&&t.subscript.type===`ArithVariable`&&!t.subscript.hasDollarPrefix)i=`${r}_${t.subscript.name}`;else if(a&&t.subscript.type===`ArithVariable`&&t.subscript.hasDollarPrefix)i=`${r}_${await X(e,t.subscript.name)||`\\`}`;else if(a)i=`${r}_${await $(e,t.subscript,n)}`;else{let a=await $(e,t.subscript,n);if(a<0){let t=Y(e,r);t.length>0&&(a=Math.max(...t.map(([e])=>typeof e==`number`?e:0))+1+a)}i=`${r}_${a}`}}let a=Xh(Number.parseInt(e.state.env.get(i)||`0`,10)||0,await $(e,t.value,n),t.operator);return e.state.env.set(i,String(a)),a}case`ArithGroup`:return await $(e,t.expression,n);case`ArithConcat`:{let r=``;for(let i of t.parts)r+=await rg(e,i,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await tg(e,r):Number.parseInt(r,10)||0}case`ArithDynamicAssignment`:{let r=``;if(t.target.type===`ArithConcat`)for(let i of t.target.parts)r+=await rg(e,i,n);else t.target.type===`ArithVariable`&&(r=t.target.hasDollarPrefix?await X(e,t.target.name):t.target.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let i=r;if(t.subscript){let a=await $(e,t.subscript,n);i=`${r}_${a}`}let a=Xh(Number.parseInt(e.state.env.get(i)||`0`,10)||0,await $(e,t.value,n),t.operator);return e.state.env.set(i,String(a)),a}case`ArithDynamicElement`:{let r=``;if(t.nameExpr.type===`ArithConcat`)for(let i of t.nameExpr.parts)r+=await rg(e,i,n);else t.nameExpr.type===`ArithVariable`&&(r=t.nameExpr.hasDollarPrefix?await X(e,t.nameExpr.name):t.nameExpr.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let i=await $(e,t.subscript,n),a=`${r}_${i}`,o=e.state.env.get(a);return o===void 0?0:$h(o)}default:return 0}}async function rg(e,t,n=!1){switch(t.type){case`ArithNumber`:return String(t.value);case`ArithSingleQuote`:return String(await $(e,t,n));case`ArithVariable`:return t.hasDollarPrefix?await X(e,t.name):t.name;case`ArithSpecialVar`:return await X(e,t.name);case`ArithBracedExpansion`:return await ng(e,t.content);case`ArithCommandSubst`:return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():`0`;case`ArithConcat`:{let r=``;for(let i of t.parts)r+=await rg(e,i,n);return r}default:return String(await $(e,t,n))}}var ig=g(()=>{wd(),K(),x(),Jh()}),ag=g(()=>{});Yn(),Jn(),er(),er(),Tu(),new TextEncoder,Ou(),br(),$a(),x(),er(),$a(),Ju(),Jn(),K(),Ju(),ig(),Jh(),Jf(),er(),br(),ka(),Jn(),x(),x(),Object.freeze({stdout:``,stderr:``,exitCode:0}),K(),wd(),K(),ta(),ig(),Jh(),Jf(),wd(),K(),ig(),Jf(),Jh(),wd(),K(),ig(),Gp(),x(),Jh(),Jh(),x(),wd(),K(),ig(),Jf(),cp(),Gp(),Jf(),cp(),K(),x(),x(),Gp(),ta(),[...new Map([[`:`,[`: [arguments]`,`Null command.
222
+ `,0;r=a}let i=`${t.array}_${r}`,a=e.state.env.get(i);if(a!==void 0)return rg(e,a);if(r===0){let n=e.state.env.get(t.array);if(n!==void 0)return rg(e,n)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(e=>e===t.array||e.startsWith(`${t.array}_`)))throw new ar(`${t.array}[${r}]`);return 0}return 0}case`ArithDoubleSubscript`:throw new sr(`double subscript`,``,``);case`ArithNumberSubscript`:throw new sr(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case`ArithSyntaxError`:throw new sr(t.message,``,``,!0);case`ArithSingleQuote`:if(n)throw new sr(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value;case`ArithBinary`:return t.operator===`||`?await $(e,t.left,n)||await $(e,t.right,n)?1:0:t.operator===`&&`?await $(e,t.left,n)&&await $(e,t.right,n)?1:0:Qh(await $(e,t.left,n),await $(e,t.right,n),t.operator);case`ArithUnary`:{let r=await $(e,t.operand,n);if(t.operator===`++`||t.operator===`--`){if(t.operand.type===`ArithVariable`){let n=t.operand.name,r=Number.parseInt(await X(e,n),10)||0,i=t.operator===`++`?r+1:r-1;return e.state.env.set(n,String(i)),t.prefix?i:r}if(t.operand.type===`ArithArrayElement`){let i=t.operand.array,a=e.state.associativeArrays?.has(i),o;if(t.operand.stringKey!==void 0)o=`${i}_${t.operand.stringKey}`;else if(a&&t.operand.index?.type===`ArithVariable`&&!t.operand.index.hasDollarPrefix)o=`${i}_${t.operand.index.name}`;else if(a&&t.operand.index?.type===`ArithVariable`&&t.operand.index.hasDollarPrefix)o=`${i}_${await X(e,t.operand.index.name)}`;else if(t.operand.index)o=`${i}_${await $(e,t.operand.index,n)}`;else return r;let s=Number.parseInt(e.state.env.get(o)||`0`,10)||0,c=t.operator===`++`?s+1:s-1;return e.state.env.set(o,String(c)),t.prefix?c:s}if(t.operand.type===`ArithConcat`){let r=``;for(let i of t.operand.parts)r+=await og(e,i,n);if(r&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)){let n=Number.parseInt(e.state.env.get(r)||`0`,10)||0,i=t.operator===`++`?n+1:n-1;return e.state.env.set(r,String(i)),t.prefix?i:n}}if(t.operand.type===`ArithDynamicElement`){let r=``;if(t.operand.nameExpr.type===`ArithConcat`)for(let i of t.operand.nameExpr.parts)r+=await og(e,i,n);else t.operand.nameExpr.type===`ArithVariable`&&(r=t.operand.nameExpr.hasDollarPrefix?await X(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(r&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)){let i=await $(e,t.operand.subscript,n),a=`${r}_${i}`,o=Number.parseInt(e.state.env.get(a)||`0`,10)||0,s=t.operator===`++`?o+1:o-1;return e.state.env.set(a,String(s)),t.prefix?s:o}}return r}return eg(r,t.operator)}case`ArithTernary`:return await $(e,t.condition,n)?await $(e,t.consequent,n):await $(e,t.alternate,n);case`ArithAssignment`:{let r=t.variable,i=r;if(t.stringKey!==void 0)i=`${r}_${t.stringKey}`;else if(t.subscript){let a=e.state.associativeArrays?.has(r);if(a&&t.subscript.type===`ArithVariable`&&!t.subscript.hasDollarPrefix)i=`${r}_${t.subscript.name}`;else if(a&&t.subscript.type===`ArithVariable`&&t.subscript.hasDollarPrefix)i=`${r}_${await X(e,t.subscript.name)||`\\`}`;else if(a)i=`${r}_${await $(e,t.subscript,n)}`;else{let a=await $(e,t.subscript,n);if(a<0){let t=Y(e,r);t.length>0&&(a=Math.max(...t.map(([e])=>typeof e==`number`?e:0))+1+a)}i=`${r}_${a}`}}let a=$h(Number.parseInt(e.state.env.get(i)||`0`,10)||0,await $(e,t.value,n),t.operator);return e.state.env.set(i,String(a)),a}case`ArithGroup`:return await $(e,t.expression,n);case`ArithConcat`:{let r=``;for(let i of t.parts)r+=await og(e,i,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await ig(e,r):Number.parseInt(r,10)||0}case`ArithDynamicAssignment`:{let r=``;if(t.target.type===`ArithConcat`)for(let i of t.target.parts)r+=await og(e,i,n);else t.target.type===`ArithVariable`&&(r=t.target.hasDollarPrefix?await X(e,t.target.name):t.target.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let i=r;if(t.subscript){let a=await $(e,t.subscript,n);i=`${r}_${a}`}let a=$h(Number.parseInt(e.state.env.get(i)||`0`,10)||0,await $(e,t.value,n),t.operator);return e.state.env.set(i,String(a)),a}case`ArithDynamicElement`:{let r=``;if(t.nameExpr.type===`ArithConcat`)for(let i of t.nameExpr.parts)r+=await og(e,i,n);else t.nameExpr.type===`ArithVariable`&&(r=t.nameExpr.hasDollarPrefix?await X(e,t.nameExpr.name):t.nameExpr.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let i=await $(e,t.subscript,n),a=`${r}_${i}`,o=e.state.env.get(a);return o===void 0?0:ng(o)}default:return 0}}async function og(e,t,n=!1){switch(t.type){case`ArithNumber`:return String(t.value);case`ArithSingleQuote`:return String(await $(e,t,n));case`ArithVariable`:return t.hasDollarPrefix?await X(e,t.name):t.name;case`ArithSpecialVar`:return await X(e,t.name);case`ArithBracedExpansion`:return await ag(e,t.content);case`ArithCommandSubst`:return e.execFn?(await e.execFn(t.command,{signal:e.state.signal})).stdout.trim():`0`;case`ArithConcat`:{let r=``;for(let i of t.parts)r+=await og(e,i,n);return r}default:return String(await $(e,t,n))}}var sg=g(()=>{jd(),K(),x(),Zh()}),cg=g(()=>{});Yn(),Jn(),er(),er(),Tu(),new TextEncoder,Ou(),br(),$a(),x(),er(),$a(),nd(),Jn(),K(),nd(),sg(),Zh(),Zf(),er(),br(),ka(),Jn(),x(),x(),Object.freeze({stdout:``,stderr:``,exitCode:0}),K(),jd(),K(),ta(),sg(),Zh(),Zf(),jd(),K(),sg(),Zf(),Zh(),jd(),K(),sg(),Jp(),x(),Zh(),Zh(),x(),jd(),K(),sg(),Zf(),dp(),Jp(),Zf(),dp(),K(),x(),x(),Jp(),ta(),[...new Map([[`:`,[`: [arguments]`,`Null command.
218
223
  No effect; the command does nothing.
219
224
  Exit Status:
220
225
  Always succeeds.`]],[`.`,[`. filename [arguments]`,`Execute commands from a file in the current shell.
@@ -561,4 +566,4 @@ ${o.repeat(a)}}`}return String(e)}var Cl,wl;_({},{base64Command:()=>Tl,flagsForF
561
566
  job specification, and reports its termination status.
562
567
  Exit Status:
563
568
  Returns the status of the last ID; fails if ID is invalid or an invalid
564
- option is given.`]]]).keys()].sort(),K(),ig(),wd(),K(),ig(),Jf(),cp(),Gp(),Jf(),Jf(),rp(),x(),x(),Jf(),x(),K(),x(),wd(),K(),ig(),fp(),Jh(),cp(),Gp(),ka(),x(),dr(),ig(),x(),Jh(),x(),dr(),x(),dr(),x(),Jh(),K(),Jh(),er(),Fl(),x(),wd(),K(),ig(),x(),Jh(),Jf(),cp(),Gp(),K(),x(),Jh(),dr(),ag(),Jn(),Yn(),zu(),K(),Jn(),new TextDecoder(`utf-8`,{fatal:!0}),er();
569
+ option is given.`]]]).keys()].sort(),K(),sg(),jd(),K(),sg(),Zf(),dp(),Jp(),Zf(),Zf(),op(),x(),x(),Zf(),x(),K(),x(),jd(),K(),sg(),hp(),Zh(),dp(),Jp(),ka(),x(),dr(),sg(),x(),Zh(),x(),dr(),x(),dr(),x(),Zh(),K(),Zh(),er(),Fl(),x(),jd(),K(),sg(),x(),Zh(),Zf(),dp(),Jp(),K(),x(),Zh(),dr(),cg(),Jn(),Yn(),qu(),K(),Jn(),new TextDecoder(`utf-8`,{fatal:!0}),er();