just-bash 2.3.3 → 2.4.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 (99) hide show
  1. package/dist/bin/chunks/cat-ZEMMQGY5.js +6 -0
  2. package/dist/bin/chunks/chunk-45SNFRCY.js +3 -0
  3. package/dist/bin/chunks/chunk-OBH7XN5N.js +1 -0
  4. package/dist/bin/{shell/chunks/chunk-OQRRF62X.js → chunks/chunk-UUQYHLBO.js} +3 -3
  5. package/dist/bin/chunks/cut-WWPJ2PYT.js +6 -0
  6. package/dist/bin/chunks/du-XQPYLN3H.js +8 -0
  7. package/dist/bin/chunks/find-4D6S5MQR.js +11 -0
  8. package/dist/bin/chunks/grep-U2RCKOEG.js +15 -0
  9. package/dist/bin/chunks/jq-63OXR3LZ.js +15 -0
  10. package/dist/bin/chunks/ls-BEHQBUMC.js +26 -0
  11. package/dist/bin/chunks/sort-C3F6LCNY.js +16 -0
  12. package/dist/bin/chunks/tree-DQBEJH47.js +12 -0
  13. package/dist/bin/chunks/uniq-DKS7RIAE.js +5 -0
  14. package/dist/bin/chunks/wc-4LMTC3QD.js +6 -0
  15. package/dist/bin/chunks/{xan-ASGSTJP4.js → xan-WNN2ZOAX.js} +48 -48
  16. package/dist/bin/chunks/{xan-view-YGORUYA2.js → xan-view-6Z6TWXMY.js} +1 -1
  17. package/dist/bin/chunks/xargs-IWT2HHEA.js +5 -0
  18. package/dist/bin/just-bash.js +83 -83
  19. package/dist/bin/shell/chunks/cat-ZEMMQGY5.js +6 -0
  20. package/dist/bin/shell/chunks/chunk-45SNFRCY.js +3 -0
  21. package/dist/bin/shell/chunks/chunk-OBH7XN5N.js +1 -0
  22. package/dist/bin/{chunks/chunk-OQRRF62X.js → shell/chunks/chunk-UUQYHLBO.js} +3 -3
  23. package/dist/bin/shell/chunks/cut-WWPJ2PYT.js +6 -0
  24. package/dist/bin/shell/chunks/du-XQPYLN3H.js +8 -0
  25. package/dist/bin/shell/chunks/find-4D6S5MQR.js +11 -0
  26. package/dist/bin/shell/chunks/grep-U2RCKOEG.js +15 -0
  27. package/dist/bin/shell/chunks/jq-63OXR3LZ.js +15 -0
  28. package/dist/bin/shell/chunks/ls-BEHQBUMC.js +26 -0
  29. package/dist/bin/shell/chunks/sort-C3F6LCNY.js +16 -0
  30. package/dist/bin/shell/chunks/tree-DQBEJH47.js +12 -0
  31. package/dist/bin/shell/chunks/uniq-DKS7RIAE.js +5 -0
  32. package/dist/bin/shell/chunks/wc-4LMTC3QD.js +6 -0
  33. package/dist/bin/shell/chunks/{xan-ASGSTJP4.js → xan-WNN2ZOAX.js} +48 -48
  34. package/dist/bin/shell/chunks/{xan-view-YGORUYA2.js → xan-view-6Z6TWXMY.js} +1 -1
  35. package/dist/bin/shell/chunks/xargs-IWT2HHEA.js +5 -0
  36. package/dist/bin/shell/shell.js +72 -72
  37. package/dist/bundle/browser.js +432 -432
  38. package/dist/bundle/chunks/cat-W5XITXDC.js +5 -0
  39. package/dist/bundle/chunks/chunk-4ACWXGKW.js +2 -0
  40. package/dist/bundle/chunks/{chunk-U4UYWYTO.js → chunk-A263W2RD.js} +3 -3
  41. package/dist/bundle/chunks/chunk-NUFRM6SI.js +0 -0
  42. package/dist/bundle/chunks/cut-KKAAQJVD.js +5 -0
  43. package/dist/bundle/chunks/du-NQXEC3EF.js +7 -0
  44. package/dist/bundle/chunks/find-GPKJFOPK.js +10 -0
  45. package/dist/bundle/chunks/grep-CTJRP2G3.js +14 -0
  46. package/dist/bundle/chunks/jq-WOKA22RE.js +14 -0
  47. package/dist/bundle/chunks/ls-5W3NU5OJ.js +23 -0
  48. package/dist/bundle/chunks/sort-JHO22QVO.js +15 -0
  49. package/dist/bundle/chunks/tree-MEM64BW3.js +11 -0
  50. package/dist/bundle/chunks/uniq-SEKCFR7B.js +4 -0
  51. package/dist/bundle/chunks/wc-52FZ4QGS.js +5 -0
  52. package/dist/bundle/chunks/{xan-B3RI2BDO.js → xan-ZHXYF6B4.js} +48 -48
  53. package/dist/bundle/chunks/{xan-view-33AU6NPN.js → xan-view-DMFUMZG7.js} +1 -1
  54. package/dist/bundle/chunks/xargs-4FRA6OJ7.js +4 -0
  55. package/dist/bundle/index.js +65 -65
  56. package/dist/commands/find/matcher.d.ts +5 -0
  57. package/dist/commands/xan/csv.d.ts +5 -0
  58. package/dist/utils/constants.d.ts +15 -0
  59. package/dist/utils/file-reader.d.ts +4 -1
  60. package/package.json +1 -1
  61. package/dist/bin/chunks/cat-7TVSOZLU.js +0 -6
  62. package/dist/bin/chunks/chunk-J7MJV6WO.js +0 -3
  63. package/dist/bin/chunks/cut-VCKWLT2T.js +0 -6
  64. package/dist/bin/chunks/du-ZONJJZUK.js +0 -8
  65. package/dist/bin/chunks/find-P6UQXFKX.js +0 -11
  66. package/dist/bin/chunks/grep-L5HBHEEQ.js +0 -15
  67. package/dist/bin/chunks/jq-MTQKMJJI.js +0 -16
  68. package/dist/bin/chunks/ls-FSSC77F4.js +0 -26
  69. package/dist/bin/chunks/sort-J5ARYV56.js +0 -16
  70. package/dist/bin/chunks/tree-ESVATRDW.js +0 -12
  71. package/dist/bin/chunks/uniq-7JNZWE5D.js +0 -5
  72. package/dist/bin/chunks/wc-OFU3HUEZ.js +0 -6
  73. package/dist/bin/chunks/xargs-WIJC4RTG.js +0 -4
  74. package/dist/bin/shell/chunks/cat-7TVSOZLU.js +0 -6
  75. package/dist/bin/shell/chunks/chunk-J7MJV6WO.js +0 -3
  76. package/dist/bin/shell/chunks/cut-VCKWLT2T.js +0 -6
  77. package/dist/bin/shell/chunks/du-ZONJJZUK.js +0 -8
  78. package/dist/bin/shell/chunks/find-P6UQXFKX.js +0 -11
  79. package/dist/bin/shell/chunks/grep-L5HBHEEQ.js +0 -15
  80. package/dist/bin/shell/chunks/jq-MTQKMJJI.js +0 -16
  81. package/dist/bin/shell/chunks/ls-FSSC77F4.js +0 -26
  82. package/dist/bin/shell/chunks/sort-J5ARYV56.js +0 -16
  83. package/dist/bin/shell/chunks/tree-ESVATRDW.js +0 -12
  84. package/dist/bin/shell/chunks/uniq-7JNZWE5D.js +0 -5
  85. package/dist/bin/shell/chunks/wc-OFU3HUEZ.js +0 -6
  86. package/dist/bin/shell/chunks/xargs-WIJC4RTG.js +0 -4
  87. package/dist/bundle/chunks/cat-CE7XIAD2.js +0 -5
  88. package/dist/bundle/chunks/chunk-3YNHMZ5M.js +0 -2
  89. package/dist/bundle/chunks/cut-MCCSW2TZ.js +0 -5
  90. package/dist/bundle/chunks/du-3NURMGXT.js +0 -7
  91. package/dist/bundle/chunks/find-QJDJJ5KW.js +0 -10
  92. package/dist/bundle/chunks/grep-4K5T3MYL.js +0 -14
  93. package/dist/bundle/chunks/jq-QAA4WF2O.js +0 -15
  94. package/dist/bundle/chunks/ls-CS3TIKWR.js +0 -23
  95. package/dist/bundle/chunks/sort-PMLMEZ4E.js +0 -15
  96. package/dist/bundle/chunks/tree-5TYW7S7K.js +0 -11
  97. package/dist/bundle/chunks/uniq-ONGDGSEB.js +0 -4
  98. package/dist/bundle/chunks/wc-Y5MNUNQQ.js +0 -5
  99. package/dist/bundle/chunks/xargs-2IMBHM4N.js +0 -3
@@ -1,6 +1,6 @@
1
- var jf=Object.create;var In=Object.defineProperty;var zf=Object.getOwnPropertyDescriptor;var Hf=Object.getOwnPropertyNames;var Gf=Object.getPrototypeOf,qf=Object.prototype.hasOwnProperty;var C=(t,e)=>()=>(t&&(e=t(t=0)),e);var mr=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),v=(t,e)=>{for(var r in e)In(t,r,{get:e[r],enumerable:!0})},Vf=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Hf(e))!qf.call(t,s)&&s!==r&&In(t,s,{get:()=>e[s],enumerable:!(n=zf(e,s))||n.enumerable});return t};var Ai=(t,e,r)=>(r=t!=null?jf(Gf(t)):{},Vf(e||!t||!t.__esModule?In(r,"default",{value:t,enumerable:!0}):r,t));var ki={};v(ki,{echoCommand:()=>Zf});function Kf(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"){if(r+1>=t.length){e+="\\";break}let n=t[r+1];switch(n){case"\\":e+="\\",r+=2;break;case"n":e+=`
2
- `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"e":case"E":e+="\x1B",r+=2;break;case"c":return{output:e,stop:!0};case"0":{let s="",i=r+2;for(;i<t.length&&i<r+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\0";else{let o=parseInt(s,8)%256;e+=String.fromCharCode(o)}r=i;break}case"x":{let s="",i=r+2;for(;i<t.length&&i<r+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\x",r+=2;else{let o=parseInt(s,16);e+=String.fromCharCode(o),r=i}break}case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\u",r+=2;else{let o=parseInt(s,16);e+=String.fromCodePoint(o),r=i}break}case"U":{let s="",i=r+2;for(;i<t.length&&i<r+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\U",r+=2;else{let o=parseInt(s,16);try{e+=String.fromCodePoint(o)}catch{e+=`\\U${s}`}r=i}break}default:e+=`\\${n}`,r+=2}}else e+=t[r],r++;return{output:e,stop:!1}}var Zf,Ni=C(()=>{"use strict";Zf={name:"echo",async execute(t,e){let r=!1,n=!1,s=0;for(;s<t.length;){let o=t[s];if(o==="-n")r=!0,s++;else if(o==="-e")n=!0,s++;else if(o==="-E")n=!1,s++;else if(o==="-ne"||o==="-en")r=!0,n=!0,s++;else break}let i=t.slice(s).join(" ");if(n){let o=Kf(i);if(i=o.output,o.stop)return{stdout:i,stderr:"",exitCode:0}}return r||(i+=`
3
- `),{stdout:i,stderr:"",exitCode:0}}}});function N(t){let e=`${t.name} - ${t.summary}
1
+ var Qf=Object.create;var Ln=Object.defineProperty;var Xf=Object.getOwnPropertyDescriptor;var Jf=Object.getOwnPropertyNames;var Yf=Object.getPrototypeOf,ep=Object.prototype.hasOwnProperty;var C=(t,e)=>()=>(t&&(e=t(t=0)),e);var Ar=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),R=(t,e)=>{for(var r in e)Ln(t,r,{get:e[r],enumerable:!0})},tp=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Jf(e))!ep.call(t,s)&&s!==r&&Ln(t,s,{get:()=>e[s],enumerable:!(n=Xf(e,s))||n.enumerable});return t};var Fi=(t,e,r)=>(r=t!=null?Qf(Yf(t)):{},tp(e||!t||!t.__esModule?Ln(r,"default",{value:t,enumerable:!0}):r,t));var Oi={};R(Oi,{echoCommand:()=>np});function rp(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"){if(r+1>=t.length){e+="\\";break}let n=t[r+1];switch(n){case"\\":e+="\\",r+=2;break;case"n":e+=`
2
+ `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"e":case"E":e+="\x1B",r+=2;break;case"c":return{output:e,stop:!0};case"0":{let s="",i=r+2;for(;i<t.length&&i<r+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\0";else{let o=parseInt(s,8)%256;e+=String.fromCharCode(o)}r=i;break}case"x":{let s="",i=r+2;for(;i<t.length&&i<r+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\x",r+=2;else{let o=parseInt(s,16);e+=String.fromCharCode(o),r=i}break}case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\u",r+=2;else{let o=parseInt(s,16);e+=String.fromCodePoint(o),r=i}break}case"U":{let s="",i=r+2;for(;i<t.length&&i<r+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;if(s.length===0)e+="\\U",r+=2;else{let o=parseInt(s,16);try{e+=String.fromCodePoint(o)}catch{e+=`\\U${s}`}r=i}break}default:e+=`\\${n}`,r+=2}}else e+=t[r],r++;return{output:e,stop:!1}}var np,Ti=C(()=>{"use strict";np={name:"echo",async execute(t,e){let r=!1,n=!1,s=0;for(;s<t.length;){let o=t[s];if(o==="-n")r=!0,s++;else if(o==="-e")n=!0,s++;else if(o==="-E")n=!1,s++;else if(o==="-ne"||o==="-en")r=!0,n=!0,s++;else break}let i=t.slice(s).join(" ");if(n){let o=rp(i);if(i=o.output,o.stop)return{stdout:i,stderr:"",exitCode:0}}return r||(i+=`
3
+ `),{stdout:i,stderr:"",exitCode:0}}}});function k(t){let e=`${t.name} - ${t.summary}
4
4
 
5
5
  `;if(e+=`Usage: ${t.usage}
6
6
  `,t.description){if(e+=`
@@ -19,176 +19,176 @@ Examples:
19
19
  `}if(t.notes&&t.notes.length>0){e+=`
20
20
  Notes:
21
21
  `;for(let r of t.notes)e+=` ${r}
22
- `}return{stdout:e,stderr:"",exitCode:0}}function I(t){return t.includes("--help")}function $(t,e){return{stdout:"",stderr:e.startsWith("--")?`${t}: unrecognized option '${e}'
22
+ `}return{stdout:e,stderr:"",exitCode:0}}function N(t){return t.includes("--help")}function P(t,e){return{stdout:"",stderr:e.startsWith("--")?`${t}: unrecognized option '${e}'
23
23
  `:`${t}: invalid option -- '${e.replace(/^-/,"")}'
24
- `,exitCode:1}}var O=C(()=>{"use strict"});function j(t,e,r){let n=new Map,s=new Map;for(let[l,c]of Object.entries(r)){let u={name:l,type:c.type};c.short&&n.set(c.short,u),c.long&&s.set(c.long,u)}let i={};for(let[l,c]of Object.entries(r))c.default!==void 0?i[l]=c.default:c.type==="boolean"&&(i[l]=!1);let o=[],a=!1;for(let l=0;l<e.length;l++){let c=e[l];if(a||!c.startsWith("-")||c==="-"){o.push(c);continue}if(c==="--"){a=!0;continue}if(c.startsWith("--")){let u=c.indexOf("="),f,d;u!==-1?(f=c.slice(2,u),d=c.slice(u+1)):f=c.slice(2);let p=s.get(f);if(!p)return{ok:!1,error:$(t,c)};let{name:h,type:y}=p;if(y==="boolean")i[h]=!0;else{if(d===void 0){if(l+1>=e.length)return{ok:!1,error:{stdout:"",stderr:`${t}: option '--${f}' requires an argument
25
- `,exitCode:1}};d=e[++l]}i[h]=y==="number"?parseInt(d,10):d}}else{let u=c.slice(1);for(let f=0;f<u.length;f++){let d=u[f],p=n.get(d);if(!p)return{ok:!1,error:$(t,`-${d}`)};let{name:h,type:y}=p;if(y==="boolean")i[h]=!0;else{let m;if(f+1<u.length)m=u.slice(f+1);else if(l+1<e.length)m=e[++l];else return{ok:!1,error:{stdout:"",stderr:`${t}: option requires an argument -- '${d}'
26
- `,exitCode:1}};i[h]=y==="number"?parseInt(m,10):m;break}}}}return{ok:!0,result:{flags:i,positional:o}}}var ae=C(()=>{"use strict";O()});async function Kt(t,e,r){let{cmdName:n,allowStdinMarker:s=!0,stopOnError:i=!1}=r;if(e.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let o=[],a="",l=0;for(let c of e){if(s&&c==="-"){o.push({filename:"-",content:t.stdin});continue}try{let u=t.fs.resolvePath(t.cwd,c),f=await t.fs.readFile(u);o.push({filename:c,content:f})}catch{if(a+=`${n}: ${c}: No such file or directory
27
- `,l=1,i)return{files:o,stderr:a,exitCode:l}}}return{files:o,stderr:a,exitCode:l}}async function St(t,e,r){let n=await Kt(t,e,{...r,stopOnError:!0});return n.exitCode!==0?{ok:!1,error:{stdout:"",stderr:n.stderr,exitCode:n.exitCode}}:{ok:!0,content:n.files.map(i=>i.content).join("")}}var Ct=C(()=>{"use strict"});var Ii={};v(Ii,{catCommand:()=>Jf});function Yf(t,e){let r=t.split(`
24
+ `,exitCode:1}}var L=C(()=>{"use strict"});function z(t,e,r){let n=new Map,s=new Map;for(let[l,c]of Object.entries(r)){let u={name:l,type:c.type};c.short&&n.set(c.short,u),c.long&&s.set(c.long,u)}let i={};for(let[l,c]of Object.entries(r))c.default!==void 0?i[l]=c.default:c.type==="boolean"&&(i[l]=!1);let o=[],a=!1;for(let l=0;l<e.length;l++){let c=e[l];if(a||!c.startsWith("-")||c==="-"){o.push(c);continue}if(c==="--"){a=!0;continue}if(c.startsWith("--")){let u=c.indexOf("="),f,p;u!==-1?(f=c.slice(2,u),p=c.slice(u+1)):f=c.slice(2);let d=s.get(f);if(!d)return{ok:!1,error:P(t,c)};let{name:h,type:m}=d;if(m==="boolean")i[h]=!0;else{if(p===void 0){if(l+1>=e.length)return{ok:!1,error:{stdout:"",stderr:`${t}: option '--${f}' requires an argument
25
+ `,exitCode:1}};p=e[++l]}i[h]=m==="number"?parseInt(p,10):p}}else{let u=c.slice(1);for(let f=0;f<u.length;f++){let p=u[f],d=n.get(p);if(!d)return{ok:!1,error:P(t,`-${p}`)};let{name:h,type:m}=d;if(m==="boolean")i[h]=!0;else{let g;if(f+1<u.length)g=u.slice(f+1);else if(l+1<e.length)g=e[++l];else return{ok:!1,error:{stdout:"",stderr:`${t}: option requires an argument -- '${p}'
26
+ `,exitCode:1}};i[h]=m==="number"?parseInt(g,10):g;break}}}}return{ok:!0,result:{flags:i,positional:o}}}var ye=C(()=>{"use strict";L()});var ht=C(()=>{"use strict"});async function mt(t,e,r){let{cmdName:n,allowStdinMarker:s=!0,stopOnError:i=!1,batchSize:o=100}=r;if(e.length===0)return{files:[{filename:"",content:t.stdin}],stderr:"",exitCode:0};let a=[],l="",c=0;for(let u=0;u<e.length;u+=o){let f=e.slice(u,u+o),p=await Promise.all(f.map(async d=>{if(s&&d==="-")return{filename:"-",content:t.stdin,error:null};try{let h=t.fs.resolvePath(t.cwd,d),m=await t.fs.readFile(h);return{filename:d,content:m,error:null}}catch{return{filename:d,content:"",error:`${n}: ${d}: No such file or directory
27
+ `}}}));for(let d of p)if(d.error){if(l+=d.error,c=1,i)return{files:a,stderr:l,exitCode:c}}else a.push({filename:d.filename,content:d.content})}return{files:a,stderr:l,exitCode:c}}async function Ot(t,e,r){let n=await mt(t,e,{...r,stopOnError:!0});return n.exitCode!==0?{ok:!1,error:{stdout:"",stderr:n.stderr,exitCode:n.exitCode}}:{ok:!0,content:n.files.map(i=>i.content).join("")}}var gt=C(()=>{"use strict";ht()});var Di={};R(Di,{catCommand:()=>op});function ap(t,e){let r=t.split(`
28
28
  `),n=t.endsWith(`
29
29
  `),s=n?r.slice(0,-1):r;return{content:s.map((o,a)=>`${String(e+a).padStart(6," ")} ${o}`).join(`
30
30
  `)+(n?`
31
- `:""),nextLineNumber:e+s.length}}var Qf,Xf,Jf,vi=C(()=>{"use strict";ae();Ct();O();Qf={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},Xf={number:{short:"n",long:"number",type:"boolean"}},Jf={name:"cat",async execute(t,e){if(I(t))return N(Qf);let r=j("cat",t,Xf);if(!r.ok)return r.error;let n=r.result.flags.number,s=r.result.positional,i=await Kt(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files)if(n){let c=Yf(l,a);o+=c.content,a=c.nextLineNumber}else o+=l;return{stdout:o,stderr:i.stderr,exitCode:i.exitCode}}}});function re(t){return t instanceof Error?t.message:String(t)}var Be=C(()=>{"use strict"});function gr(t,e,r){let n=t;r>=0&&n.length>r&&(n=n.slice(0,r));let s=Math.abs(e);return s>n.length&&(e<0?n=n.padEnd(s," "):n=n.padStart(s," ")),n}function $i(t,e){let r=e,n=0,s=-1,i=!1;for(r<t.length&&t[r]==="-"&&(i=!0,r++);r<t.length&&/\d/.test(t[r]);)n=n*10+parseInt(t[r],10),r++;if(r<t.length&&t[r]===".")for(r++,s=0;r<t.length&&/\d/.test(t[r]);)s=s*10+parseInt(t[r],10),r++;return i&&n>0&&(n=-n),[n,s,r-e]}function yr(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length)switch(t[r+1]){case"n":e+=`
32
- `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"\\":e+="\\",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"e":case"E":e+="\x1B",r+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=r+1;for(;i<t.length&&i<r+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),r=i;break}case"x":r+3<t.length&&/[0-9a-fA-F]{2}/.test(t.slice(r+2,r+4))?(e+=String.fromCharCode(parseInt(t.slice(r+2,r+4),16)),r+=4):(e+=t[r],r++);break;case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\u",r+=2);break}case"U":{let s="",i=r+2;for(;i<t.length&&i<r+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\U",r+=2);break}default:e+=t[r],r++}else e+=t[r],r++;return e}var vn=C(()=>{"use strict"});var Pi={};v(Pi,{printfCommand:()=>td});import{sprintf as At}from"sprintf-js";function rd(t,e,r){let n="",s=0,i=0,o=!1,a="";for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let l=s;if(s++,t[s]==="%"){n+="%",s++;continue}for(;s<t.length&&"+-0 #'".includes(t[s]);)s++;let c=!1;if(t[s]==="*")c=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;let u=!1;if(t[s]===".")if(s++,t[s]==="*")u=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;s<t.length&&"hlL".includes(t[s])&&s++;let f=t[s]||"";s++;let p=t.slice(l,s);if(c){let E=parseInt(e[r+i]||"0",10);i++,p=p.replace("*",String(E))}if(u){let E=parseInt(e[r+i]||"0",10);i++,p=p.replace(".*",`.${E}`)}let h=e[r+i]||"";i++;let{value:y,parseError:m,parseErrMsg:w,stopped:b}=nd(p,f,h);if(n+=y,m&&(o=!0,w&&(a=w)),b)return{result:n,argsConsumed:i,error:o,errMsg:a,stopped:!0}}else n+=t[s],s++;return{result:n,argsConsumed:i,error:o,errMsg:a,stopped:!1}}function nd(t,e,r){let n=!1,s="";switch(e){case"d":case"i":{let i=xr(r);return n=We,n&&(s=`printf: ${r}: invalid number
33
- `),{value:Ri(t,i),parseError:n,parseErrMsg:s}}case"o":{let i=xr(r);return n=We,n&&(s=`printf: ${r}: invalid number
34
- `),{value:sd(t,i),parseError:n,parseErrMsg:s}}case"u":{let i=xr(r);n=We,n&&(s=`printf: ${r}: invalid number
35
- `);let o=i<0?i>>>0:i;return{value:Ri(t.replace("u","d"),o),parseError:n,parseErrMsg:s}}case"x":case"X":{let i=xr(r);return n=We,n&&(s=`printf: ${r}: invalid number
36
- `),{value:id(t,i),parseError:n,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let i=parseFloat(r)||0;return{value:cd(t,e,i),parseError:!1,parseErrMsg:""}}case"c":return{value:r.charAt(0)||"",parseError:!1,parseErrMsg:""};case"s":return{value:ad(t,r),parseError:!1,parseErrMsg:""};case"q":return{value:ld(t,r),parseError:!1,parseErrMsg:""};case"b":{let i=ud(r);return{value:i.value,parseError:!1,parseErrMsg:"",stopped:i.stopped}}default:try{return{value:At(t,r),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
37
- `}}}}function xr(t){We=!1;let e=t.trimStart(),r=e!==e.trimEnd();if(t=e.trimEnd(),t.startsWith("'")&&t.length>=2||t.startsWith('"')&&t.length>=2)return t.charCodeAt(1);if(t.startsWith("\\'")&&t.length>=3||t.startsWith('\\"')&&t.length>=3)return t.charCodeAt(2);if(t.startsWith("+")&&(t=t.slice(1)),t.startsWith("0x")||t.startsWith("0X")){let n=parseInt(t,16);return Number.isNaN(n)?(We=!0,0):(r&&(We=!0),n)}if(t.startsWith("0")&&t.length>1&&/^-?0[0-7]+$/.test(t))return r&&(We=!0),parseInt(t,8)||0;if(/^\d+#/.test(t)){We=!0;let n=t.match(/^(\d+)#/);return n?parseInt(n[1],10):0}if(t!==""&&!/^-?\d+$/.test(t)){We=!0;let n=parseInt(t,10);return Number.isNaN(n)?0:n}return r&&(We=!0),parseInt(t,10)||0}function Ri(t,e){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!r)return At(t.replace(/\.\d*/,""),e);let n=r[1]||"",s=r[2]?parseInt(r[2],10):0,i=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=e<0,a=Math.abs(e),l=String(a);i>=0&&(l=l.padStart(i,"0"));let c="";o?c="-":n.includes("+")?c="+":n.includes(" ")&&(c=" ");let u=c+l;return s>u.length&&(n.includes("-")?u=u.padEnd(s," "):n.includes("0")&&i<0?u=c+l.padStart(s-c.length,"0"):u=u.padStart(s," ")),u}function sd(t,e){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!r)return At(t,e);let n=r[1]||"",s=r[2]?parseInt(r[2],10):0,i=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=Math.abs(e).toString(8);i>=0&&(o=o.padStart(i,"0")),n.includes("#")&&!o.startsWith("0")&&(o=`0${o}`);let a=o;return s>a.length&&(n.includes("-")?a=a.padEnd(s," "):n.includes("0")&&i<0?a=a.padStart(s,"0"):a=a.padStart(s," ")),a}function id(t,e){let r=t.includes("X"),n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!n)return At(t,e);let s=n[1]||"",i=n[2]?parseInt(n[2],10):0,o=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,a=Math.abs(e).toString(16);r&&(a=a.toUpperCase()),o>=0&&(a=a.padStart(o,"0"));let l="";s.includes("#")&&e!==0&&(l=r?"0X":"0x");let c=l+a;return i>c.length&&(s.includes("-")?c=c.padEnd(i," "):s.includes("0")&&o<0?c=l+a.padStart(i-l.length,"0"):c=c.padStart(i," ")),c}function od(t){if(t==="")return"''";if(/^[a-zA-Z0-9_./-]+$/.test(t))return t;if(/[\x00-\x1f\x7f]/.test(t)){let n="$'";for(let s of t){let i=s.charCodeAt(0);s==="'"?n+="\\'":s==="\\"?n+="\\\\":s===`
38
- `?n+="\\n":s===" "?n+="\\t":s==="\r"?n+="\\r":s==="\x07"?n+="\\a":s==="\b"?n+="\\b":s==="\f"?n+="\\f":s==="\v"?n+="\\v":s==="\x1B"?n+="\\E":i<32||i>126?n+=`\\x${i.toString(16).padStart(2,"0")}`:s==='"'?n+='\\"':n+=s}return n+="'",n}let r="";for(let n of t)" |&;<>()$`\\\"'*?[#~=%!{}".includes(n)?r+=`\\${n}`:r+=n;return r}function ad(t,e){let r=t.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!r)return At(t.replace(/0+(?=\d)/,""),e);let n=r[1]==="-",s=r[2]?parseInt(r[2],10):0,i=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=n?-s:s;return gr(e,o,i)}function ld(t,e){let r=od(e),n=t.match(/^%(-?)(\d*)q$/);if(!n)return r;let s=n[1]==="-",i=n[2]?parseInt(n[2],10):0,o=r;return i>o.length&&(s?o=o.padEnd(i," "):o=o.padStart(i," ")),o}function cd(t,e,r){let n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!n)return At(t,r);let s=n[1]||"",i=n[2]?parseInt(n[2],10):0,o=n[3]!==void 0?n[4]?parseInt(n[4],10):0:6,a,l=e.toLowerCase();if(l==="e"?(a=r.toExponential(o),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="E"&&(a=a.toUpperCase())):l==="f"?(a=r.toFixed(o),s.includes("#")&&o===0&&!a.includes(".")&&(a+=".")):l==="g"?(a=r.toPrecision(o||1),s.includes("#")||(a=a.replace(/\.?0+$/,""),a=a.replace(/\.?0+e/,"e")),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="G"&&(a=a.toUpperCase())):a=r.toString(),r>=0&&(s.includes("+")?a=`+${a}`:s.includes(" ")&&(a=` ${a}`)),i>a.length)if(s.includes("-"))a=a.padEnd(i," ");else if(s.includes("0")){let c=a.match(/^[+ -]/)?.[0]||"",u=c?a.slice(1):a;a=c+u.padStart(i-c.length,"0")}else a=a.padStart(i," ");return a}function ud(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length)switch(t[r+1]){case"n":e+=`
39
- `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"\\":e+="\\",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"c":return{value:e,stopped:!0};case"x":{let s="",i=r+2;for(;i<t.length&&i<r+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCharCode(parseInt(s,16)),r=i):(e+="\\x",r+=2);break}case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\u",r+=2);break}case"0":{let s="",i=r+2;for(;i<t.length&&i<r+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;s?e+=String.fromCharCode(parseInt(s,8)):e+="\0",r=i;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=r+1;for(;i<t.length&&i<r+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),r=i;break}default:e+=t[r],r++}else e+=t[r],r++;return{value:e,stopped:!1}}var ed,td,We,Oi=C(()=>{"use strict";Be();O();vn();ed={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},td={name:"printf",async execute(t,e){if(I(t))return N(ed);if(t.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
31
+ `:""),nextLineNumber:e+s.length}}var sp,ip,op,Li=C(()=>{"use strict";ye();gt();L();sp={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},ip={number:{short:"n",long:"number",type:"boolean"}},op={name:"cat",async execute(t,e){if(N(t))return k(sp);let r=z("cat",t,ip);if(!r.ok)return r.error;let n=r.result.flags.number,s=r.result.positional,i=await mt(e,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files)if(n){let c=ap(l,a);o+=c.content,a=c.nextLineNumber}else o+=l;return{stdout:o,stderr:i.stderr,exitCode:i.exitCode}}}});function de(t){return t instanceof Error?t.message:String(t)}var qe=C(()=>{"use strict"});function kr(t,e,r){let n=t;r>=0&&n.length>r&&(n=n.slice(0,r));let s=Math.abs(e);return s>n.length&&(e<0?n=n.padEnd(s," "):n=n.padStart(s," ")),n}function Mi(t,e){let r=e,n=0,s=-1,i=!1;for(r<t.length&&t[r]==="-"&&(i=!0,r++);r<t.length&&/\d/.test(t[r]);)n=n*10+parseInt(t[r],10),r++;if(r<t.length&&t[r]===".")for(r++,s=0;r<t.length&&/\d/.test(t[r]);)s=s*10+parseInt(t[r],10),r++;return i&&n>0&&(n=-n),[n,s,r-e]}function Nr(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length)switch(t[r+1]){case"n":e+=`
32
+ `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"\\":e+="\\",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"e":case"E":e+="\x1B",r+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=r+1;for(;i<t.length&&i<r+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),r=i;break}case"x":r+3<t.length&&/[0-9a-fA-F]{2}/.test(t.slice(r+2,r+4))?(e+=String.fromCharCode(parseInt(t.slice(r+2,r+4),16)),r+=4):(e+=t[r],r++);break;case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\u",r+=2);break}case"U":{let s="",i=r+2;for(;i<t.length&&i<r+10&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\U",r+=2);break}default:e+=t[r],r++}else e+=t[r],r++;return e}var Mn=C(()=>{"use strict"});var Bi={};R(Bi,{printfCommand:()=>cp});import{sprintf as Tt}from"sprintf-js";function up(t,e,r){let n="",s=0,i=0,o=!1,a="";for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let l=s;if(s++,t[s]==="%"){n+="%",s++;continue}for(;s<t.length&&"+-0 #'".includes(t[s]);)s++;let c=!1;if(t[s]==="*")c=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;let u=!1;if(t[s]===".")if(s++,t[s]==="*")u=!0,s++;else for(;s<t.length&&/\d/.test(t[s]);)s++;s<t.length&&"hlL".includes(t[s])&&s++;let f=t[s]||"";s++;let d=t.slice(l,s);if(c){let E=parseInt(e[r+i]||"0",10);i++,d=d.replace("*",String(E))}if(u){let E=parseInt(e[r+i]||"0",10);i++,d=d.replace(".*",`.${E}`)}let h=e[r+i]||"";i++;let{value:m,parseError:g,parseErrMsg:w,stopped:b}=fp(d,f,h);if(n+=m,g&&(o=!0,w&&(a=w)),b)return{result:n,argsConsumed:i,error:o,errMsg:a,stopped:!0}}else n+=t[s],s++;return{result:n,argsConsumed:i,error:o,errMsg:a,stopped:!1}}function fp(t,e,r){let n=!1,s="";switch(e){case"d":case"i":{let i=Ir(r);return n=Ve,n&&(s=`printf: ${r}: invalid number
33
+ `),{value:_i(t,i),parseError:n,parseErrMsg:s}}case"o":{let i=Ir(r);return n=Ve,n&&(s=`printf: ${r}: invalid number
34
+ `),{value:pp(t,i),parseError:n,parseErrMsg:s}}case"u":{let i=Ir(r);n=Ve,n&&(s=`printf: ${r}: invalid number
35
+ `);let o=i<0?i>>>0:i;return{value:_i(t.replace("u","d"),o),parseError:n,parseErrMsg:s}}case"x":case"X":{let i=Ir(r);return n=Ve,n&&(s=`printf: ${r}: invalid number
36
+ `),{value:dp(t,i),parseError:n,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let i=parseFloat(r)||0;return{value:yp(t,e,i),parseError:!1,parseErrMsg:""}}case"c":return{value:r.charAt(0)||"",parseError:!1,parseErrMsg:""};case"s":return{value:mp(t,r),parseError:!1,parseErrMsg:""};case"q":return{value:gp(t,r),parseError:!1,parseErrMsg:""};case"b":{let i=xp(r);return{value:i.value,parseError:!1,parseErrMsg:"",stopped:i.stopped}}default:try{return{value:Tt(t,r),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
37
+ `}}}}function Ir(t){Ve=!1;let e=t.trimStart(),r=e!==e.trimEnd();if(t=e.trimEnd(),t.startsWith("'")&&t.length>=2||t.startsWith('"')&&t.length>=2)return t.charCodeAt(1);if(t.startsWith("\\'")&&t.length>=3||t.startsWith('\\"')&&t.length>=3)return t.charCodeAt(2);if(t.startsWith("+")&&(t=t.slice(1)),t.startsWith("0x")||t.startsWith("0X")){let n=parseInt(t,16);return Number.isNaN(n)?(Ve=!0,0):(r&&(Ve=!0),n)}if(t.startsWith("0")&&t.length>1&&/^-?0[0-7]+$/.test(t))return r&&(Ve=!0),parseInt(t,8)||0;if(/^\d+#/.test(t)){Ve=!0;let n=t.match(/^(\d+)#/);return n?parseInt(n[1],10):0}if(t!==""&&!/^-?\d+$/.test(t)){Ve=!0;let n=parseInt(t,10);return Number.isNaN(n)?0:n}return r&&(Ve=!0),parseInt(t,10)||0}function _i(t,e){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!r)return Tt(t.replace(/\.\d*/,""),e);let n=r[1]||"",s=r[2]?parseInt(r[2],10):0,i=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=e<0,a=Math.abs(e),l=String(a);i>=0&&(l=l.padStart(i,"0"));let c="";o?c="-":n.includes("+")?c="+":n.includes(" ")&&(c=" ");let u=c+l;return s>u.length&&(n.includes("-")?u=u.padEnd(s," "):n.includes("0")&&i<0?u=c+l.padStart(s-c.length,"0"):u=u.padStart(s," ")),u}function pp(t,e){let r=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!r)return Tt(t,e);let n=r[1]||"",s=r[2]?parseInt(r[2],10):0,i=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=Math.abs(e).toString(8);i>=0&&(o=o.padStart(i,"0")),n.includes("#")&&!o.startsWith("0")&&(o=`0${o}`);let a=o;return s>a.length&&(n.includes("-")?a=a.padEnd(s," "):n.includes("0")&&i<0?a=a.padStart(s,"0"):a=a.padStart(s," ")),a}function dp(t,e){let r=t.includes("X"),n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!n)return Tt(t,e);let s=n[1]||"",i=n[2]?parseInt(n[2],10):0,o=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,a=Math.abs(e).toString(16);r&&(a=a.toUpperCase()),o>=0&&(a=a.padStart(o,"0"));let l="";s.includes("#")&&e!==0&&(l=r?"0X":"0x");let c=l+a;return i>c.length&&(s.includes("-")?c=c.padEnd(i," "):s.includes("0")&&o<0?c=l+a.padStart(i-l.length,"0"):c=c.padStart(i," ")),c}function hp(t){if(t==="")return"''";if(/^[a-zA-Z0-9_./-]+$/.test(t))return t;if(/[\x00-\x1f\x7f]/.test(t)){let n="$'";for(let s of t){let i=s.charCodeAt(0);s==="'"?n+="\\'":s==="\\"?n+="\\\\":s===`
38
+ `?n+="\\n":s===" "?n+="\\t":s==="\r"?n+="\\r":s==="\x07"?n+="\\a":s==="\b"?n+="\\b":s==="\f"?n+="\\f":s==="\v"?n+="\\v":s==="\x1B"?n+="\\E":i<32||i>126?n+=`\\x${i.toString(16).padStart(2,"0")}`:s==='"'?n+='\\"':n+=s}return n+="'",n}let r="";for(let n of t)" |&;<>()$`\\\"'*?[#~=%!{}".includes(n)?r+=`\\${n}`:r+=n;return r}function mp(t,e){let r=t.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!r)return Tt(t.replace(/0+(?=\d)/,""),e);let n=r[1]==="-",s=r[2]?parseInt(r[2],10):0,i=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,o=n?-s:s;return kr(e,o,i)}function gp(t,e){let r=hp(e),n=t.match(/^%(-?)(\d*)q$/);if(!n)return r;let s=n[1]==="-",i=n[2]?parseInt(n[2],10):0,o=r;return i>o.length&&(s?o=o.padEnd(i," "):o=o.padStart(i," ")),o}function yp(t,e,r){let n=t.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!n)return Tt(t,r);let s=n[1]||"",i=n[2]?parseInt(n[2],10):0,o=n[3]!==void 0?n[4]?parseInt(n[4],10):0:6,a,l=e.toLowerCase();if(l==="e"?(a=r.toExponential(o),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="E"&&(a=a.toUpperCase())):l==="f"?(a=r.toFixed(o),s.includes("#")&&o===0&&!a.includes(".")&&(a+=".")):l==="g"?(a=r.toPrecision(o||1),s.includes("#")||(a=a.replace(/\.?0+$/,""),a=a.replace(/\.?0+e/,"e")),a=a.replace(/e([+-])(\d)$/,"e$10$2"),e==="G"&&(a=a.toUpperCase())):a=r.toString(),r>=0&&(s.includes("+")?a=`+${a}`:s.includes(" ")&&(a=` ${a}`)),i>a.length)if(s.includes("-"))a=a.padEnd(i," ");else if(s.includes("0")){let c=a.match(/^[+ -]/)?.[0]||"",u=c?a.slice(1):a;a=c+u.padStart(i-c.length,"0")}else a=a.padStart(i," ");return a}function xp(t){let e="",r=0;for(;r<t.length;)if(t[r]==="\\"&&r+1<t.length)switch(t[r+1]){case"n":e+=`
39
+ `,r+=2;break;case"t":e+=" ",r+=2;break;case"r":e+="\r",r+=2;break;case"\\":e+="\\",r+=2;break;case"a":e+="\x07",r+=2;break;case"b":e+="\b",r+=2;break;case"f":e+="\f",r+=2;break;case"v":e+="\v",r+=2;break;case"c":return{value:e,stopped:!0};case"x":{let s="",i=r+2;for(;i<t.length&&i<r+4&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCharCode(parseInt(s,16)),r=i):(e+="\\x",r+=2);break}case"u":{let s="",i=r+2;for(;i<t.length&&i<r+6&&/[0-9a-fA-F]/.test(t[i]);)s+=t[i],i++;s?(e+=String.fromCodePoint(parseInt(s,16)),r=i):(e+="\\u",r+=2);break}case"0":{let s="",i=r+2;for(;i<t.length&&i<r+5&&/[0-7]/.test(t[i]);)s+=t[i],i++;s?e+=String.fromCharCode(parseInt(s,8)):e+="\0",r=i;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=r+1;for(;i<t.length&&i<r+4&&/[0-7]/.test(t[i]);)s+=t[i],i++;e+=String.fromCharCode(parseInt(s,8)),r=i;break}default:e+=t[r],r++}else e+=t[r],r++;return{value:e,stopped:!1}}var lp,cp,Ve,Wi=C(()=>{"use strict";qe();L();Mn();lp={name:"printf",summary:"format and print data",usage:"printf [-v var] FORMAT [ARGUMENT...]",options:[" -v var assign the output to shell variable VAR rather than display it"," --help display this help and exit"],notes:["FORMAT controls the output like in C printf.","Escape sequences: \\n (newline), \\t (tab), \\\\ (backslash)","Format specifiers: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %% (literal %)","Width and precision: %10s (width 10), %.2f (2 decimal places), %010d (zero-padded)","Flags: %- (left-justify), %+ (show sign), %0 (zero-pad)"]},cp={name:"printf",async execute(t,e){if(N(t))return k(lp);if(t.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
40
40
  `,exitCode:2};let r=null,n=0;for(;n<t.length;){let o=t[n];if(o==="--"){n++;break}if(o==="-v"){if(n+1>=t.length)return{stdout:"",stderr:`printf: -v: option requires an argument
41
41
  `,exitCode:1};if(r=t[n+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(\[[^\]]+\])?$/.test(r))return{stdout:"",stderr:`printf: \`${r}': not a valid identifier
42
42
  `,exitCode:2};n+=2}else{if(o.startsWith("-")&&o!=="-")break;break}}if(n>=t.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
43
- `,exitCode:1};let s=t[n],i=t.slice(n+1);try{let o=yr(s),a="",l=0,c=!1,u="";do{let{result:f,argsConsumed:d,error:p,errMsg:h,stopped:y}=rd(o,i,l);if(a+=f,l+=d,p&&(c=!0,h&&(u=h)),y)break}while(l<i.length&&l>0);return l===0&&i.length>0,r?(e.env[r]=a,{stdout:"",stderr:u,exitCode:c?1:0}):{stdout:a,stderr:u,exitCode:c?1:0}}catch(o){return{stdout:"",stderr:`printf: ${re(o)}
44
- `,exitCode:1}}}};We=!1});var Li={};v(Li,{lsCommand:()=>pd});import{minimatch as Fi}from"minimatch";function wr(t){if(t<1024)return String(t);if(t<1024*1024){let r=t/1024;return r<10?`${r.toFixed(1)}K`:`${Math.round(r)}K`}if(t<1024*1024*1024){let r=t/1048576;return r<10?`${r.toFixed(1)}M`:`${Math.round(r)}M`}let e=t/(1024*1024*1024);return e<10?`${e.toFixed(1)}G`:`${Math.round(e)}G`}function br(t){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=String(t.getDate()).padStart(2," "),s=new Date,i=new Date(s.getTime()-4320*60*60*1e3);if(t>i){let a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${r} ${n} ${a}:${l}`}let o=t.getFullYear();return`${r} ${n} ${o}`}async function hd(t,e,r,n,s,i=!1,o=!1,a=!1){let l=r||n,c=e.fs.getAllPaths(),u=e.fs.resolvePath(e.cwd,"."),f=[];for(let d of c){let p=d.startsWith(u)&&d.slice(u.length+1)||d;if(Fi(p,t)||Fi(d,t)){let h=p.split("/").pop()||p;if(!l&&h.startsWith("."))continue;f.push(p||d)}}if(f.length===0)return{stdout:"",stderr:`ls: ${t}: No such file or directory
45
- `,exitCode:2};if(a){let d=[];for(let p of f){let h=e.fs.resolvePath(e.cwd,p);try{let y=await e.fs.stat(h);d.push({path:p,size:y.size??0})}catch{d.push({path:p,size:0})}}d.sort((p,h)=>h.size-p.size),f.length=0,f.push(...d.map(p=>p.path))}else f.sort();if(i&&f.reverse(),s){let d=[];for(let p of f){let h=e.fs.resolvePath(e.cwd,p);try{let y=await e.fs.stat(h),m=y.isDirectory?"drwxr-xr-x":"-rw-r--r--",w=y.isDirectory?"/":"",b=y.size??0,E=o?wr(b).padStart(5):String(b).padStart(5),S=y.mtime??new Date(0),A=br(S);d.push(`${m} 1 user user ${E} ${A} ${p}${w}`)}catch{d.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${p}`)}}return{stdout:`${d.join(`
43
+ `,exitCode:1};let s=t[n],i=t.slice(n+1);try{let o=Nr(s),a="",l=0,c=!1,u="";do{let{result:f,argsConsumed:p,error:d,errMsg:h,stopped:m}=up(o,i,l);if(a+=f,l+=p,d&&(c=!0,h&&(u=h)),m)break}while(l<i.length&&l>0);return l===0&&i.length>0,r?(e.env[r]=a,{stdout:"",stderr:u,exitCode:c?1:0}):{stdout:a,stderr:u,exitCode:c?1:0}}catch(o){return{stdout:"",stderr:`printf: ${de(o)}
44
+ `,exitCode:1}}}};Ve=!1});var zi={};R(zi,{lsCommand:()=>Ep});import{minimatch as Ui}from"minimatch";function vr(t){if(t<1024)return String(t);if(t<1024*1024){let r=t/1024;return r<10?`${r.toFixed(1)}K`:`${Math.round(r)}K`}if(t<1024*1024*1024){let r=t/1048576;return r<10?`${r.toFixed(1)}M`:`${Math.round(r)}M`}let e=t/(1024*1024*1024);return e<10?`${e.toFixed(1)}G`:`${Math.round(e)}G`}function $r(t){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=String(t.getDate()).padStart(2," "),s=new Date,i=new Date(s.getTime()-4320*60*60*1e3);if(t>i){let a=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0");return`${r} ${n} ${a}:${l}`}let o=t.getFullYear();return`${r} ${n} ${o}`}async function Sp(t,e,r,n,s,i=!1,o=!1,a=!1){let l=r||n,c=e.fs.getAllPaths(),u=e.fs.resolvePath(e.cwd,"."),f=[];for(let p of c){let d=p.startsWith(u)&&p.slice(u.length+1)||p;if(Ui(d,t)||Ui(p,t)){let h=d.split("/").pop()||d;if(!l&&h.startsWith("."))continue;f.push(d||p)}}if(f.length===0)return{stdout:"",stderr:`ls: ${t}: No such file or directory
45
+ `,exitCode:2};if(a){let p=[];for(let d of f){let h=e.fs.resolvePath(e.cwd,d);try{let m=await e.fs.stat(h);p.push({path:d,size:m.size??0})}catch{p.push({path:d,size:0})}}p.sort((d,h)=>h.size-d.size),f.length=0,f.push(...p.map(d=>d.path))}else f.sort();if(i&&f.reverse(),s){let p=[];for(let d of f){let h=e.fs.resolvePath(e.cwd,d);try{let m=await e.fs.stat(h),g=m.isDirectory?"drwxr-xr-x":"-rw-r--r--",w=m.isDirectory?"/":"",b=m.size??0,E=o?vr(b).padStart(5):String(b).padStart(5),S=m.mtime??new Date(0),v=$r(S);p.push(`${g} 1 user user ${E} ${v} ${d}${w}`)}catch{p.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${d}`)}}return{stdout:`${p.join(`
46
46
  `)}
47
47
  `,stderr:"",exitCode:0}}return{stdout:`${f.join(`
48
48
  `)}
49
- `,stderr:"",exitCode:0}}async function Ti(t,e,r,n,s,i,o,a=!1,l=!1,c=!1,u=!1){let f=r||n,d=e.fs.resolvePath(e.cwd,t);try{let p=await e.fs.stat(d);if(!p.isDirectory){if(s){let m=p.size??0,w=l?wr(m).padStart(5):String(m).padStart(5),b=p.mtime??new Date(0),E=br(b);return{stdout:`-rw-r--r-- 1 user user ${w} ${E} ${t}
49
+ `,stderr:"",exitCode:0}}async function ji(t,e,r,n,s,i,o,a=!1,l=!1,c=!1,u=!1){let f=r||n,p=e.fs.resolvePath(e.cwd,t);try{let d=await e.fs.stat(p);if(!d.isDirectory){if(s){let g=d.size??0,w=l?vr(g).padStart(5):String(g).padStart(5),b=d.mtime??new Date(0),E=$r(b);return{stdout:`-rw-r--r-- 1 user user ${w} ${E} ${t}
50
50
  `,stderr:"",exitCode:0}}return{stdout:`${t}
51
- `,stderr:"",exitCode:0}}let h=await e.fs.readdir(d);if(f||(h=h.filter(m=>!m.startsWith("."))),c){let m=[];for(let w of h){let b=d==="/"?`/${w}`:`${d}/${w}`;try{let E=await e.fs.stat(b);m.push({name:w,size:E.size??0})}catch{m.push({name:w,size:0})}}m.sort((w,b)=>b.size-w.size),h=m.map(w=>w.name)}else h.sort();r&&(h=[".","..",...h]),a&&h.reverse();let y="";if((i||o)&&(y+=`${t}:
52
- `),s){y+=`total ${h.length}
53
- `;for(let m of h){if(m==="."||m===".."){y+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${m}
54
- `;continue}let w=d==="/"?`/${m}`:`${d}/${m}`;try{let b=await e.fs.stat(w),E=b.isDirectory?"drwxr-xr-x":"-rw-r--r--",S=b.isDirectory?"/":"",A=b.size??0,F=l?wr(A).padStart(5):String(A).padStart(5),M=b.mtime??new Date(0),D=br(M);y+=`${E} 1 user user ${F} ${D} ${m}${S}
55
- `}catch{y+=`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${m}
56
- `}}}else y+=h.join(`
51
+ `,stderr:"",exitCode:0}}let h=await e.fs.readdir(p);if(f||(h=h.filter(g=>!g.startsWith("."))),c){let g=[];for(let w of h){let b=p==="/"?`/${w}`:`${p}/${w}`;try{let E=await e.fs.stat(b);g.push({name:w,size:E.size??0})}catch{g.push({name:w,size:0})}}g.sort((w,b)=>b.size-w.size),h=g.map(w=>w.name)}else h.sort();r&&(h=[".","..",...h]),a&&h.reverse();let m="";if((i||o)&&(m+=`${t}:
52
+ `),s){m+=`total ${h.length}
53
+ `;let g=h.filter(S=>S==="."||S===".."),w=h.filter(S=>S!=="."&&S!=="..");for(let S of g)m+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${S}
54
+ `;let b=[];for(let S=0;S<w.length;S+=100){let v=w.slice(S,S+100),D=await Promise.all(v.map(async I=>{let $=p==="/"?`/${I}`:`${p}/${I}`;try{let V=await e.fs.stat($),K=V.isDirectory?"drwxr-xr-x":"-rw-r--r--",Y=V.isDirectory?"/":"",re=V.size??0,H=l?vr(re).padStart(5):String(re).padStart(5),ce=V.mtime??new Date(0),X=$r(ce);return{name:I,line:`${K} 1 user user ${H} ${X} ${I}${Y}
55
+ `}}catch{return{name:I,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${I}
56
+ `}}}));b.push(...D)}let E=new Map(w.map((S,v)=>[S,v]));b.sort((S,v)=>(E.get(S.name)??0)-(E.get(v.name)??0));for(let{line:S}of b)m+=S}else m+=h.join(`
57
57
  `)+(h.length?`
58
- `:"");if(i)for(let m of h){if(m==="."||m==="..")continue;let w=d==="/"?`/${m}`:`${d}/${m}`;try{if((await e.fs.stat(w)).isDirectory){y+=`
59
- `;let E=t==="."?`./${m}`:`${t}/${m}`,S=await Ti(E,e,r,n,s,i,!1,a,l,c,!0);y+=S.stdout}}catch{}}return{stdout:y,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`ls: ${t}: No such file or directory
60
- `,exitCode:2}}}var fd,dd,pd,Di=C(()=>{"use strict";ae();O();fd={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},dd={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},pd={name:"ls",async execute(t,e){if(I(t))return N(fd);let r=j("ls",t,dd);if(!r.ok)return r.error;let n=r.result.flags.showAll,s=r.result.flags.showAlmostAll,i=r.result.flags.longFormat,o=r.result.flags.humanReadable,a=r.result.flags.recursive,l=r.result.flags.reverse,c=r.result.flags.sortBySize,u=r.result.flags.directoryOnly,f=r.result.flags.sortByTime;r.result.flags.onePerLine;let d=r.result.positional;d.length===0&&d.push(".");let p="",h="",y=0;for(let m=0;m<d.length;m++){let w=d[m];if(m>0&&p&&!p.endsWith(`
58
+ `:"");if(i){let g=h.filter(E=>E!=="."&&E!==".."),w=[];if(e.fs.readdirWithFileTypes)w=(await e.fs.readdirWithFileTypes(p)).filter(S=>S.isDirectory&&g.includes(S.name)).map(S=>({name:S.name,isDirectory:!0}));else for(let E=0;E<g.length;E+=100){let S=g.slice(E,E+100),v=await Promise.all(S.map(async D=>{let I=p==="/"?`/${D}`:`${p}/${D}`;try{let $=await e.fs.stat(I);return{name:D,isDirectory:$.isDirectory}}catch{return{name:D,isDirectory:!1}}}));w.push(...v.filter(D=>D.isDirectory))}w.sort((E,S)=>E.name.localeCompare(S.name)),a&&w.reverse();let b=[];for(let E=0;E<w.length;E+=100){let S=w.slice(E,E+100),v=await Promise.all(S.map(async D=>{let I=t==="."?`./${D.name}`:`${t}/${D.name}`,$=await ji(I,e,r,n,s,i,!1,a,l,c,!0);return{name:D.name,result:$}}));b.push(...v)}b.sort((E,S)=>E.name.localeCompare(S.name)),a&&b.reverse();for(let{result:E}of b)m+=`
59
+ `,m+=E.stdout}return{stdout:m,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`ls: ${t}: No such file or directory
60
+ `,exitCode:2}}}var wp,bp,Ep,Hi=C(()=>{"use strict";ye();ht();L();wp={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},bp={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},Ep={name:"ls",async execute(t,e){if(N(t))return k(wp);let r=z("ls",t,bp);if(!r.ok)return r.error;let n=r.result.flags.showAll,s=r.result.flags.showAlmostAll,i=r.result.flags.longFormat,o=r.result.flags.humanReadable,a=r.result.flags.recursive,l=r.result.flags.reverse,c=r.result.flags.sortBySize,u=r.result.flags.directoryOnly,f=r.result.flags.sortByTime;r.result.flags.onePerLine;let p=r.result.positional;p.length===0&&p.push(".");let d="",h="",m=0;for(let g=0;g<p.length;g++){let w=p[g];if(g>0&&d&&!d.endsWith(`
61
61
 
62
- `)&&(p+=`
63
- `),u){let b=e.fs.resolvePath(e.cwd,w);try{let E=await e.fs.stat(b);if(i){let S=E.isDirectory?"drwxr-xr-x":"-rw-r--r--",A=E.isDirectory?"/":"",F=E.size??0,M=o?wr(F).padStart(5):String(F).padStart(5),D=E.mtime??new Date(0),U=br(D);p+=`${S} 1 user user ${M} ${U} ${w}${A}
64
- `}else p+=`${w}
62
+ `)&&(d+=`
63
+ `),u){let b=e.fs.resolvePath(e.cwd,w);try{let E=await e.fs.stat(b);if(i){let S=E.isDirectory?"drwxr-xr-x":"-rw-r--r--",v=E.isDirectory?"/":"",D=E.size??0,I=o?vr(D).padStart(5):String(D).padStart(5),$=E.mtime??new Date(0),V=$r($);d+=`${S} 1 user user ${I} ${V} ${w}${v}
64
+ `}else d+=`${w}
65
65
  `}catch{h+=`ls: cannot access '${w}': No such file or directory
66
- `,y=2}continue}if(w.includes("*")||w.includes("?")||w.includes("[")){let b=await hd(w,e,n,s,i,l,o,c);p+=b.stdout,h+=b.stderr,b.exitCode!==0&&(y=b.exitCode)}else{let b=await Ti(w,e,n,s,i,a,d.length>1,l,o,c);p+=b.stdout,h+=b.stderr,b.exitCode!==0&&(y=b.exitCode)}}return{stdout:p,stderr:h,exitCode:y}}}});var Mi={};v(Mi,{mkdirCommand:()=>gd});var md,gd,_i=C(()=>{"use strict";Be();ae();md={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},gd={name:"mkdir",async execute(t,e){let r=j("mkdir",t,md);if(!r.ok)return r.error;let n=r.result.flags.recursive,s=r.result.flags.verbose,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:`mkdir: missing operand
66
+ `,m=2}continue}if(w.includes("*")||w.includes("?")||w.includes("[")){let b=await Sp(w,e,n,s,i,l,o,c);d+=b.stdout,h+=b.stderr,b.exitCode!==0&&(m=b.exitCode)}else{let b=await ji(w,e,n,s,i,a,p.length>1,l,o,c);d+=b.stdout,h+=b.stderr,b.exitCode!==0&&(m=b.exitCode)}}return{stdout:d,stderr:h,exitCode:m}}}});var Gi={};R(Gi,{mkdirCommand:()=>Ap});var Cp,Ap,qi=C(()=>{"use strict";qe();ye();Cp={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Ap={name:"mkdir",async execute(t,e){let r=z("mkdir",t,Cp);if(!r.ok)return r.error;let n=r.result.flags.recursive,s=r.result.flags.verbose,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:`mkdir: missing operand
67
67
  `,exitCode:1};let o="",a="",l=0;for(let c of i)try{let u=e.fs.resolvePath(e.cwd,c);await e.fs.mkdir(u,{recursive:n}),s&&(o+=`mkdir: created directory '${c}'
68
- `)}catch(u){let f=re(u);f.includes("ENOENT")||f.includes("no such file")?a+=`mkdir: cannot create directory '${c}': No such file or directory
68
+ `)}catch(u){let f=de(u);f.includes("ENOENT")||f.includes("no such file")?a+=`mkdir: cannot create directory '${c}': No such file or directory
69
69
  `:f.includes("EEXIST")||f.includes("already exists")?a+=`mkdir: cannot create directory '${c}': File exists
70
70
  `:a+=`mkdir: cannot create directory '${c}': ${f}
71
- `,l=1}return{stdout:o,stderr:a,exitCode:l}}}});var Bi={};v(Bi,{touchCommand:()=>yd});var yd,Wi=C(()=>{"use strict";Be();O();yd={name:"touch",async execute(t,e){let r=[];for(let i of t){if(i.startsWith("--"))return $("touch",i);if(i.startsWith("-")&&i.length>1)return $("touch",i);r.push(i)}if(r.length===0)return{stdout:"",stderr:`touch: missing file operand
72
- `,exitCode:1};let n="",s=0;for(let i of r)try{let o=e.fs.resolvePath(e.cwd,i);await e.fs.exists(o)||await e.fs.writeFile(o,"")}catch(o){n+=`touch: cannot touch '${i}': ${re(o)}
73
- `,s=1}return{stdout:"",stderr:n,exitCode:s}}}});var Ui={};v(Ui,{rmCommand:()=>wd});var xd,wd,ji=C(()=>{"use strict";Be();ae();xd={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},wd={name:"rm",async execute(t,e){let r=j("rm",t,xd);if(!r.ok)return r.error;let n=r.result.flags.recursive||r.result.flags.recursiveUpper,s=r.result.flags.force,i=r.result.flags.verbose,o=r.result.positional;if(o.length===0)return s?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand
71
+ `,l=1}return{stdout:o,stderr:a,exitCode:l}}}});var Vi={};R(Vi,{touchCommand:()=>kp});var kp,Ki=C(()=>{"use strict";qe();L();kp={name:"touch",async execute(t,e){let r=[];for(let i of t){if(i.startsWith("--"))return P("touch",i);if(i.startsWith("-")&&i.length>1)return P("touch",i);r.push(i)}if(r.length===0)return{stdout:"",stderr:`touch: missing file operand
72
+ `,exitCode:1};let n="",s=0;for(let i of r)try{let o=e.fs.resolvePath(e.cwd,i);await e.fs.exists(o)||await e.fs.writeFile(o,"")}catch(o){n+=`touch: cannot touch '${i}': ${de(o)}
73
+ `,s=1}return{stdout:"",stderr:n,exitCode:s}}}});var Zi={};R(Zi,{rmCommand:()=>Ip});var Np,Ip,Qi=C(()=>{"use strict";qe();ye();Np={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Ip={name:"rm",async execute(t,e){let r=z("rm",t,Np);if(!r.ok)return r.error;let n=r.result.flags.recursive||r.result.flags.recursiveUpper,s=r.result.flags.force,i=r.result.flags.verbose,o=r.result.positional;if(o.length===0)return s?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:`rm: missing operand
74
74
  `,exitCode:1};let a="",l="",c=0;for(let u of o)try{let f=e.fs.resolvePath(e.cwd,u);if((await e.fs.stat(f)).isDirectory&&!n){l+=`rm: cannot remove '${u}': Is a directory
75
75
  `,c=1;continue}await e.fs.rm(f,{recursive:n,force:s}),i&&(a+=`removed '${u}'
76
- `)}catch(f){if(!s){let d=re(f);d.includes("ENOENT")||d.includes("no such file")?l+=`rm: cannot remove '${u}': No such file or directory
77
- `:d.includes("ENOTEMPTY")||d.includes("not empty")?l+=`rm: cannot remove '${u}': Directory not empty
78
- `:l+=`rm: cannot remove '${u}': ${d}
79
- `,c=1}}return{stdout:a,stderr:l,exitCode:c}}}});var zi={};v(zi,{cpCommand:()=>Sd});var bd,Ed,Sd,Hi=C(()=>{"use strict";Be();ae();O();bd={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},Ed={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Sd={name:"cp",async execute(t,e){if(I(t))return N(bd);let r=j("cp",t,Ed);if(!r.ok)return r.error;let n=r.result.flags.recursive||r.result.flags.recursiveUpper,s=r.result.flags.noClobber,i=r.result.flags.preserve,o=r.result.flags.verbose,a=r.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
80
- `,exitCode:1};let l=a.pop()??"",c=a,u=e.fs.resolvePath(e.cwd,l),f="",d="",p=0,h=!1;try{h=(await e.fs.stat(u)).isDirectory}catch{}if(c.length>1&&!h)return{stdout:"",stderr:`cp: target '${l}' is not a directory
81
- `,exitCode:1};for(let y of c)try{let m=e.fs.resolvePath(e.cwd,y),w=await e.fs.stat(m),b=u;if(h){let E=y.split("/").pop()||y;b=u==="/"?`/${E}`:`${u}/${E}`}if(w.isDirectory&&!n){d+=`cp: -r not specified; omitting directory '${y}'
82
- `,p=1;continue}if(s)try{await e.fs.stat(b);continue}catch{}await e.fs.cp(m,b,{recursive:n}),o&&(f+=`'${y}' -> '${b}'
83
- `)}catch(m){let w=re(m);w.includes("ENOENT")||w.includes("no such file")?d+=`cp: cannot stat '${y}': No such file or directory
84
- `:d+=`cp: cannot copy '${y}': ${w}
85
- `,p=1}return{stdout:f,stderr:d,exitCode:p}}}});var Gi={};v(Gi,{mvCommand:()=>kd});var Cd,Ad,kd,qi=C(()=>{"use strict";Be();ae();O();Cd={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},Ad={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},kd={name:"mv",async execute(t,e){if(I(t))return N(Cd);let r=j("mv",t,Ad);if(!r.ok)return r.error;let n=r.result.flags.force,s=r.result.flags.noClobber,i=r.result.flags.verbose,o=r.result.positional;if(s&&(n=!1),o.length<2)return{stdout:"",stderr:`mv: missing destination file operand
86
- `,exitCode:1};let a=o.pop()??"",l=o,c=e.fs.resolvePath(e.cwd,a),u="",f="",d=0,p=!1;try{p=(await e.fs.stat(c)).isDirectory}catch{}if(l.length>1&&!p)return{stdout:"",stderr:`mv: target '${a}' is not a directory
87
- `,exitCode:1};for(let h of l)try{let y=e.fs.resolvePath(e.cwd,h),m=c;if(p){let w=h.split("/").pop()||h;m=c==="/"?`/${w}`:`${c}/${w}`}if(s)try{await e.fs.stat(m);continue}catch{}if(await e.fs.mv(y,m),i){let w=p?`${a}/${h.split("/").pop()||h}`:a;u+=`renamed '${h}' -> '${w}'
88
- `}}catch(y){let m=re(y);m.includes("ENOENT")||m.includes("no such file")?f+=`mv: cannot stat '${h}': No such file or directory
89
- `:f+=`mv: cannot move '${h}': ${m}
90
- `,d=1}return{stdout:u,stderr:f,exitCode:d}}}});var Vi={};v(Vi,{lnCommand:()=>Id});var Nd,Id,Ki=C(()=>{"use strict";O();Nd={name:"ln",summary:"make links between files",usage:"ln [OPTIONS] TARGET LINK_NAME",options:["-s create a symbolic link instead of a hard link","-f remove existing destination files","-n treat LINK_NAME as a normal file if it is a symbolic link to a directory","-v print name of each linked file"," --help display this help and exit"]},Id={name:"ln",async execute(t,e){if(I(t))return N(Nd);let r=!1,n=!1,s=!1,i=0;for(;i<t.length&&t[i].startsWith("-");){let f=t[i];if(f==="-s"||f==="--symbolic")r=!0,i++;else if(f==="-f"||f==="--force")n=!0,i++;else if(f==="-v"||f==="--verbose")s=!0,i++;else if(f==="-n"||f==="--no-dereference")i++;else if(/^-[sfvn]+$/.test(f))f.includes("s")&&(r=!0),f.includes("f")&&(n=!0),f.includes("v")&&(s=!0),i++;else if(f==="--"){i++;break}else return{stdout:"",stderr:`ln: invalid option -- '${f.slice(1)}'
76
+ `)}catch(f){if(!s){let p=de(f);p.includes("ENOENT")||p.includes("no such file")?l+=`rm: cannot remove '${u}': No such file or directory
77
+ `:p.includes("ENOTEMPTY")||p.includes("not empty")?l+=`rm: cannot remove '${u}': Directory not empty
78
+ `:l+=`rm: cannot remove '${u}': ${p}
79
+ `,c=1}}return{stdout:a,stderr:l,exitCode:c}}}});var Xi={};R(Xi,{cpCommand:()=>Rp});var vp,$p,Rp,Ji=C(()=>{"use strict";qe();ye();L();vp={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},$p={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Rp={name:"cp",async execute(t,e){if(N(t))return k(vp);let r=z("cp",t,$p);if(!r.ok)return r.error;let n=r.result.flags.recursive||r.result.flags.recursiveUpper,s=r.result.flags.noClobber,i=r.result.flags.preserve,o=r.result.flags.verbose,a=r.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
80
+ `,exitCode:1};let l=a.pop()??"",c=a,u=e.fs.resolvePath(e.cwd,l),f="",p="",d=0,h=!1;try{h=(await e.fs.stat(u)).isDirectory}catch{}if(c.length>1&&!h)return{stdout:"",stderr:`cp: target '${l}' is not a directory
81
+ `,exitCode:1};for(let m of c)try{let g=e.fs.resolvePath(e.cwd,m),w=await e.fs.stat(g),b=u;if(h){let E=m.split("/").pop()||m;b=u==="/"?`/${E}`:`${u}/${E}`}if(w.isDirectory&&!n){p+=`cp: -r not specified; omitting directory '${m}'
82
+ `,d=1;continue}if(s)try{await e.fs.stat(b);continue}catch{}await e.fs.cp(g,b,{recursive:n}),o&&(f+=`'${m}' -> '${b}'
83
+ `)}catch(g){let w=de(g);w.includes("ENOENT")||w.includes("no such file")?p+=`cp: cannot stat '${m}': No such file or directory
84
+ `:p+=`cp: cannot copy '${m}': ${w}
85
+ `,d=1}return{stdout:f,stderr:p,exitCode:d}}}});var Yi={};R(Yi,{mvCommand:()=>Op});var Pp,Fp,Op,eo=C(()=>{"use strict";qe();ye();L();Pp={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},Fp={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},Op={name:"mv",async execute(t,e){if(N(t))return k(Pp);let r=z("mv",t,Fp);if(!r.ok)return r.error;let n=r.result.flags.force,s=r.result.flags.noClobber,i=r.result.flags.verbose,o=r.result.positional;if(s&&(n=!1),o.length<2)return{stdout:"",stderr:`mv: missing destination file operand
86
+ `,exitCode:1};let a=o.pop()??"",l=o,c=e.fs.resolvePath(e.cwd,a),u="",f="",p=0,d=!1;try{d=(await e.fs.stat(c)).isDirectory}catch{}if(l.length>1&&!d)return{stdout:"",stderr:`mv: target '${a}' is not a directory
87
+ `,exitCode:1};for(let h of l)try{let m=e.fs.resolvePath(e.cwd,h),g=c;if(d){let w=h.split("/").pop()||h;g=c==="/"?`/${w}`:`${c}/${w}`}if(s)try{await e.fs.stat(g);continue}catch{}if(await e.fs.mv(m,g),i){let w=d?`${a}/${h.split("/").pop()||h}`:a;u+=`renamed '${h}' -> '${w}'
88
+ `}}catch(m){let g=de(m);g.includes("ENOENT")||g.includes("no such file")?f+=`mv: cannot stat '${h}': No such file or directory
89
+ `:f+=`mv: cannot move '${h}': ${g}
90
+ `,p=1}return{stdout:u,stderr:f,exitCode:p}}}});var to={};R(to,{lnCommand:()=>Dp});var Tp,Dp,ro=C(()=>{"use strict";L();Tp={name:"ln",summary:"make links between files",usage:"ln [OPTIONS] TARGET LINK_NAME",options:["-s create a symbolic link instead of a hard link","-f remove existing destination files","-n treat LINK_NAME as a normal file if it is a symbolic link to a directory","-v print name of each linked file"," --help display this help and exit"]},Dp={name:"ln",async execute(t,e){if(N(t))return k(Tp);let r=!1,n=!1,s=!1,i=0;for(;i<t.length&&t[i].startsWith("-");){let f=t[i];if(f==="-s"||f==="--symbolic")r=!0,i++;else if(f==="-f"||f==="--force")n=!0,i++;else if(f==="-v"||f==="--verbose")s=!0,i++;else if(f==="-n"||f==="--no-dereference")i++;else if(/^-[sfvn]+$/.test(f))f.includes("s")&&(r=!0),f.includes("f")&&(n=!0),f.includes("v")&&(s=!0),i++;else if(f==="--"){i++;break}else return{stdout:"",stderr:`ln: invalid option -- '${f.slice(1)}'
91
91
  `,exitCode:1}}let o=t.slice(i);if(o.length<2)return{stdout:"",stderr:`ln: missing file operand
92
92
  `,exitCode:1};let a=o[0],l=o[1],c=e.fs.resolvePath(e.cwd,l);if(await e.fs.exists(c))if(n)try{await e.fs.rm(c,{force:!0})}catch{return{stdout:"",stderr:`ln: cannot remove '${l}': Permission denied
93
93
  `,exitCode:1}}else return{stdout:"",stderr:`ln: failed to create ${r?"symbolic ":""}link '${l}': File exists
94
94
  `,exitCode:1};try{if(r)await e.fs.symlink(a,c);else{let f=e.fs.resolvePath(e.cwd,a);if(!await e.fs.exists(f))return{stdout:"",stderr:`ln: failed to access '${a}': No such file or directory
95
- `,exitCode:1};await e.fs.link(f,c)}}catch(f){let d=f;return d.message.includes("EPERM")?{stdout:"",stderr:`ln: '${a}': hard link not allowed for directory
96
- `,exitCode:1}:{stdout:"",stderr:`ln: ${d.message}
95
+ `,exitCode:1};await e.fs.link(f,c)}}catch(f){let p=f;return p.message.includes("EPERM")?{stdout:"",stderr:`ln: '${a}': hard link not allowed for directory
96
+ `,exitCode:1}:{stdout:"",stderr:`ln: ${p.message}
97
97
  `,exitCode:1}}let u="";return s&&(u=`'${l}' -> '${a}'
98
- `),{stdout:u,stderr:"",exitCode:0}}}});var Qi={};v(Qi,{chmodCommand:()=>$d});async function Zi(t,e,r,n){let s="",i=await t.fs.readdir(e);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;await t.fs.chmod(a,r),n&&(s+=`mode of '${a}' changed to ${r.toString(8).padStart(4,"0")}
99
- `),(await t.fs.stat(a)).isDirectory&&(s+=await Zi(t,a,r,n))}return s}function Rd(t){if(/^[0-7]+$/.test(t))return parseInt(t,8);let e=420,r=t.split(",");for(let n of r){let s=n.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!s)throw new Error(`Invalid mode: ${t}`);let i=s[1]||"a",o=s[2],a=s[3];(i==="a"||i==="")&&(i="ugo");let l=0;a.includes("r")&&(l|=4),a.includes("w")&&(l|=2),(a.includes("x")||a.includes("X"))&&(l|=1);for(let c of i){let u=0;c==="u"?u=6:c==="g"?u=3:c==="o"&&(u=0);let f=l<<u;o==="+"?e|=f:o==="-"?e&=~f:o==="="&&(e&=~(7<<u),e|=f)}}return e}var vd,$d,Xi=C(()=>{"use strict";O();vd={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},$d={name:"chmod",async execute(t,e){if(I(t))return N(vd);if(t.length<2)return{stdout:"",stderr:`chmod: missing operand
98
+ `),{stdout:u,stderr:"",exitCode:0}}}});var so={};R(so,{chmodCommand:()=>Mp});async function no(t,e,r,n){let s="",i=await t.fs.readdir(e);for(let o of i){let a=e==="/"?`/${o}`:`${e}/${o}`;await t.fs.chmod(a,r),n&&(s+=`mode of '${a}' changed to ${r.toString(8).padStart(4,"0")}
99
+ `),(await t.fs.stat(a)).isDirectory&&(s+=await no(t,a,r,n))}return s}function _p(t){if(/^[0-7]+$/.test(t))return parseInt(t,8);let e=420,r=t.split(",");for(let n of r){let s=n.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!s)throw new Error(`Invalid mode: ${t}`);let i=s[1]||"a",o=s[2],a=s[3];(i==="a"||i==="")&&(i="ugo");let l=0;a.includes("r")&&(l|=4),a.includes("w")&&(l|=2),(a.includes("x")||a.includes("X"))&&(l|=1);for(let c of i){let u=0;c==="u"?u=6:c==="g"?u=3:c==="o"&&(u=0);let f=l<<u;o==="+"?e|=f:o==="-"?e&=~f:o==="="&&(e&=~(7<<u),e|=f)}}return e}var Lp,Mp,io=C(()=>{"use strict";L();Lp={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},Mp={name:"chmod",async execute(t,e){if(N(t))return k(Lp);if(t.length<2)return{stdout:"",stderr:`chmod: missing operand
100
100
  `,exitCode:1};let r=!1,n=!1,s=0;for(;s<t.length&&t[s].startsWith("-");){let f=t[s];if(f==="-R"||f==="--recursive")r=!0,s++;else if(f==="-v"||f==="--verbose")n=!0,s++;else if(f==="--"){s++;break}else{if(/^[+-]?[rwxugo]+/.test(f)||/^\d+$/.test(f))break;if(/^-[Rv]+$/.test(f)){f.includes("R")&&(r=!0),f.includes("v")&&(n=!0),s++;continue}return{stdout:"",stderr:`chmod: invalid option -- '${f.slice(1)}'
101
101
  `,exitCode:1}}}if(t.length-s<2)return{stdout:"",stderr:`chmod: missing operand
102
- `,exitCode:1};let i=t[s],o=t.slice(s+1),a;try{a=Rd(i)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${i}'
103
- `,exitCode:1}}let l="",c="",u=!1;for(let f of o){let d=e.fs.resolvePath(e.cwd,f);try{if(await e.fs.chmod(d,a),n&&(l+=`mode of '${f}' changed to ${a.toString(8).padStart(4,"0")}
104
- `),r&&(await e.fs.stat(d)).isDirectory){let h=await Zi(e,d,a,n);l+=h}}catch{c+=`chmod: cannot access '${f}': No such file or directory
105
- `,u=!0}}return{stdout:l,stderr:c,exitCode:u?1:0}}}});var Ji={};v(Ji,{pwdCommand:()=>Pd});var Pd,Yi=C(()=>{"use strict";Pd={name:"pwd",async execute(t,e){return{stdout:`${e.cwd}
106
- `,stderr:"",exitCode:0}}}});var eo={};v(eo,{readlinkCommand:()=>Fd});var Od,Fd,to=C(()=>{"use strict";O();Od={name:"readlink",summary:"print resolved symbolic links or canonical file names",usage:"readlink [OPTIONS] FILE...",options:["-f canonicalize by following every symlink in every component of the given name recursively"," --help display this help and exit"]},Fd={name:"readlink",async execute(t,e){if(I(t))return N(Od);let r=!1,n=0;for(;n<t.length&&t[n].startsWith("-");){let a=t[n];if(a==="-f"||a==="--canonicalize")r=!0,n++;else if(a==="--"){n++;break}else return{stdout:"",stderr:`readlink: invalid option -- '${a.slice(1)}'
102
+ `,exitCode:1};let i=t[s],o=t.slice(s+1),a;try{a=_p(i)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${i}'
103
+ `,exitCode:1}}let l="",c="",u=!1;for(let f of o){let p=e.fs.resolvePath(e.cwd,f);try{if(await e.fs.chmod(p,a),n&&(l+=`mode of '${f}' changed to ${a.toString(8).padStart(4,"0")}
104
+ `),r&&(await e.fs.stat(p)).isDirectory){let h=await no(e,p,a,n);l+=h}}catch{c+=`chmod: cannot access '${f}': No such file or directory
105
+ `,u=!0}}return{stdout:l,stderr:c,exitCode:u?1:0}}}});var oo={};R(oo,{pwdCommand:()=>Bp});var Bp,ao=C(()=>{"use strict";Bp={name:"pwd",async execute(t,e){return{stdout:`${e.cwd}
106
+ `,stderr:"",exitCode:0}}}});var lo={};R(lo,{readlinkCommand:()=>Up});var Wp,Up,co=C(()=>{"use strict";L();Wp={name:"readlink",summary:"print resolved symbolic links or canonical file names",usage:"readlink [OPTIONS] FILE...",options:["-f canonicalize by following every symlink in every component of the given name recursively"," --help display this help and exit"]},Up={name:"readlink",async execute(t,e){if(N(t))return k(Wp);let r=!1,n=0;for(;n<t.length&&t[n].startsWith("-");){let a=t[n];if(a==="-f"||a==="--canonicalize")r=!0,n++;else if(a==="--"){n++;break}else return{stdout:"",stderr:`readlink: invalid option -- '${a.slice(1)}'
107
107
  `,exitCode:1}}let s=t.slice(n);if(s.length===0)return{stdout:"",stderr:`readlink: missing operand
108
- `,exitCode:1};let i="",o=!1;for(let a of s){let l=e.fs.resolvePath(e.cwd,a);try{if(r){let c=l,u=new Set;for(;!u.has(c);){u.add(c);try{let f=await e.fs.readlink(c);if(f.startsWith("/"))c=f;else{let d=c.substring(0,c.lastIndexOf("/"))||"/";c=e.fs.resolvePath(d,f)}}catch{break}}i+=`${c}
108
+ `,exitCode:1};let i="",o=!1;for(let a of s){let l=e.fs.resolvePath(e.cwd,a);try{if(r){let c=l,u=new Set;for(;!u.has(c);){u.add(c);try{let f=await e.fs.readlink(c);if(f.startsWith("/"))c=f;else{let p=c.substring(0,c.lastIndexOf("/"))||"/";c=e.fs.resolvePath(p,f)}}catch{break}}i+=`${c}
109
109
  `}else{let c=await e.fs.readlink(l);i+=`${c}
110
110
  `}}catch{r?i+=`${l}
111
- `:o=!0}}return{stdout:i,stderr:"",exitCode:o?1:0}}}});function Er(t,e){let r=10,n=null,s=!1,i=!1,o=!1,a=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-n"&&l+1<t.length){let u=t[++l];e==="tail"&&u.startsWith("+")?(o=!0,r=parseInt(u.slice(1),10)):r=parseInt(u,10)}else if(e==="tail"&&c.startsWith("-n+"))o=!0,r=parseInt(c.slice(3),10);else if(c.startsWith("-n"))r=parseInt(c.slice(2),10);else if(c==="-c"&&l+1<t.length)n=parseInt(t[++l],10);else if(c.startsWith("-c"))n=parseInt(c.slice(2),10);else if(c.startsWith("--bytes="))n=parseInt(c.slice(8),10);else if(c.startsWith("--lines="))r=parseInt(c.slice(8),10);else if(c==="-q"||c==="--quiet"||c==="--silent")s=!0;else if(c==="-v"||c==="--verbose")i=!0;else if(c.match(/^-\d+$/))r=parseInt(c.slice(1),10);else{if(c.startsWith("--"))return{ok:!1,error:$(e,c)};if(c.startsWith("-")&&c!=="-")return{ok:!1,error:$(e,c)};a.push(c)}}return n!==null&&(Number.isNaN(n)||n<0)?{ok:!1,error:{stdout:"",stderr:`${e}: invalid number of bytes
111
+ `:o=!0}}return{stdout:i,stderr:"",exitCode:o?1:0}}}});function Rr(t,e){let r=10,n=null,s=!1,i=!1,o=!1,a=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-n"&&l+1<t.length){let u=t[++l];e==="tail"&&u.startsWith("+")?(o=!0,r=parseInt(u.slice(1),10)):r=parseInt(u,10)}else if(e==="tail"&&c.startsWith("-n+"))o=!0,r=parseInt(c.slice(3),10);else if(c.startsWith("-n"))r=parseInt(c.slice(2),10);else if(c==="-c"&&l+1<t.length)n=parseInt(t[++l],10);else if(c.startsWith("-c"))n=parseInt(c.slice(2),10);else if(c.startsWith("--bytes="))n=parseInt(c.slice(8),10);else if(c.startsWith("--lines="))r=parseInt(c.slice(8),10);else if(c==="-q"||c==="--quiet"||c==="--silent")s=!0;else if(c==="-v"||c==="--verbose")i=!0;else if(c.match(/^-\d+$/))r=parseInt(c.slice(1),10);else{if(c.startsWith("--"))return{ok:!1,error:P(e,c)};if(c.startsWith("-")&&c!=="-")return{ok:!1,error:P(e,c)};a.push(c)}}return n!==null&&(Number.isNaN(n)||n<0)?{ok:!1,error:{stdout:"",stderr:`${e}: invalid number of bytes
112
112
  `,exitCode:1}}:Number.isNaN(r)||r<0?{ok:!1,error:{stdout:"",stderr:`${e}: invalid number of lines
113
- `,exitCode:1}}:{ok:!0,options:{lines:r,bytes:n,quiet:s,verbose:i,files:a,fromLine:o}}}async function Sr(t,e,r,n){let{quiet:s,verbose:i,files:o}=e;if(o.length===0)return{stdout:n(t.stdin),stderr:"",exitCode:0};let a="",l="",c=0,u=i||!s&&o.length>1;for(let f=0;f<o.length;f++){let d=o[f];u&&(f>0&&(a+=`
114
- `),a+=`==> ${d} <==
115
- `);try{let p=t.fs.resolvePath(t.cwd,d),h=await t.fs.readFile(p);a+=n(h)}catch{l+=`${r}: ${d}: No such file or directory
116
- `,c=1}}return{stdout:a,stderr:l,exitCode:c}}function ro(t,e,r){if(r!==null)return t.slice(0,r);if(e===0)return"";let n=0,s=0,i=t.length;for(;n<i&&s<e;){let o=t.indexOf(`
113
+ `,exitCode:1}}:{ok:!0,options:{lines:r,bytes:n,quiet:s,verbose:i,files:a,fromLine:o}}}async function Pr(t,e,r,n){let{quiet:s,verbose:i,files:o}=e;if(o.length===0)return{stdout:n(t.stdin),stderr:"",exitCode:0};let a="",l="",c=0,u=i||!s&&o.length>1;for(let f=0;f<o.length;f++){let p=o[f];u&&(f>0&&(a+=`
114
+ `),a+=`==> ${p} <==
115
+ `);try{let d=t.fs.resolvePath(t.cwd,p),h=await t.fs.readFile(d);a+=n(h)}catch{l+=`${r}: ${p}: No such file or directory
116
+ `,c=1}}return{stdout:a,stderr:l,exitCode:c}}function uo(t,e,r){if(r!==null)return t.slice(0,r);if(e===0)return"";let n=0,s=0,i=t.length;for(;n<i&&s<e;){let o=t.indexOf(`
117
117
  `,n);if(o===-1)return`${t}
118
- `;s++,n=o+1}return n>0?t.slice(0,n):""}function no(t,e,r,n){if(r!==null)return t.slice(-r);let s=t.length;if(s===0)return"";if(n){let l=0,c=1;for(;l<s&&c<e;){let f=t.indexOf(`
118
+ `;s++,n=o+1}return n>0?t.slice(0,n):""}function fo(t,e,r,n){if(r!==null)return t.slice(-r);let s=t.length;if(s===0)return"";if(n){let l=0,c=1;for(;l<s&&c<e;){let f=t.indexOf(`
119
119
  `,l);if(f===-1)break;c++,l=f+1}let u=t.slice(l);return u.endsWith(`
120
120
  `)?u:`${u}
121
121
  `}if(e===0)return"";let i=s-1;t[i]===`
122
122
  `&&i--;let o=0;for(;i>=0&&o<e;){if(t[i]===`
123
123
  `&&(o++,o===e)){i++;break}i--}i<0&&(i=0);let a=t.slice(i);return t[s-1]===`
124
124
  `?a:`${a}
125
- `}var $n=C(()=>{"use strict";O()});var so={};v(so,{headCommand:()=>Ld});var Td,Ld,io=C(()=>{"use strict";O();$n();Td={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},Ld={name:"head",async execute(t,e){if(I(t))return N(Td);let r=Er(t,"head");if(!r.ok)return r.error;let{lines:n,bytes:s}=r.options;return Sr(e,r.options,"head",i=>ro(i,n,s))}}});var oo={};v(oo,{tailCommand:()=>Md});var Dd,Md,ao=C(()=>{"use strict";$n();O();Dd={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},Md={name:"tail",async execute(t,e){if(I(t))return N(Dd);let r=Er(t,"tail");if(!r.ok)return r.error;let{lines:n,bytes:s,fromLine:i}=r.options;return Sr(e,r.options,"tail",o=>no(o,n,s,i??!1))}}});var co={};v(co,{wcCommand:()=>Wd});function lo(t){let e=t.length,r=0,n=0,s=!1;for(let i=0;i<e;i++){let o=t[i];o===`
126
- `?(r++,s&&(n++,s=!1)):o===" "||o===" "||o==="\r"?s&&(n++,s=!1):s=!0}return s&&n++,{lines:r,words:n,chars:e}}function Rn(t,e,r,n,s){let i=[];e&&i.push(String(t.lines)),r&&i.push(String(t.words)),n&&i.push(String(t.chars));let o=i.join(" ");return s&&(o+=` ${s}`),o}var _d,Bd,Wd,uo=C(()=>{"use strict";ae();Ct();O();_d={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},Bd={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},Wd={name:"wc",async execute(t,e){if(I(t))return N(_d);let r=j("wc",t,Bd);if(!r.ok)return r.error;let{lines:n,words:s}=r.result.flags,i=r.result.flags.bytes||r.result.flags.chars,o=r.result.positional;!n&&!s&&!i&&(n=s=i=!0);let a=await Kt(e,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let d=lo(a.files[0].content);return{stdout:`${Rn(d,n,s,i,"")}
127
- `,stderr:"",exitCode:0}}let l="",c=0,u=0,f=0;for(let{filename:d,content:p}of a.files){let h=lo(p);c+=h.lines,u+=h.words,f+=h.chars,l+=`${Rn(h,n,s,i,d)}
128
- `}return o.length>1&&(l+=`${Rn({lines:c,words:u,chars:f},n,s,i,"total")}
129
- `),{stdout:l,stderr:a.stderr,exitCode:a.exitCode}}}});var po={};v(po,{statCommand:()=>zd});function fo(t,e){let r=e?"d":"-",n=[t&256?"r":"-",t&128?"w":"-",t&64?"x":"-",t&32?"r":"-",t&16?"w":"-",t&8?"x":"-",t&4?"r":"-",t&2?"w":"-",t&1?"x":"-"];return r+n.join("")}var Ud,jd,zd,ho=C(()=>{"use strict";ae();O();Ud={name:"stat",summary:"display file or file system status",usage:"stat [OPTION]... FILE...",options:["-c FORMAT use the specified FORMAT instead of the default"," --help display this help and exit"]},jd={format:{short:"c",type:"string"}},zd={name:"stat",async execute(t,e){if(I(t))return N(Ud);let r=j("stat",t,jd);if(!r.ok)return r.error;let n=r.result.flags.format??null,s=r.result.positional;if(s.length===0)return{stdout:"",stderr:`stat: missing operand
130
- `,exitCode:1};let i="",o="",a=!1;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{let u=await e.fs.stat(c);if(n){let f=n,d=u.mode.toString(8),p=fo(u.mode,u.isDirectory);f=f.replace(/%n/g,l),f=f.replace(/%N/g,`'${l}'`),f=f.replace(/%s/g,String(u.size)),f=f.replace(/%F/g,u.isDirectory?"directory":"regular file"),f=f.replace(/%a/g,d),f=f.replace(/%A/g,p),f=f.replace(/%u/g,"1000"),f=f.replace(/%U/g,"user"),f=f.replace(/%g/g,"1000"),f=f.replace(/%G/g,"group"),i+=`${f}
131
- `}else{let f=u.mode.toString(8).padStart(4,"0"),d=fo(u.mode,u.isDirectory);i+=` File: ${l}
125
+ `}var _n=C(()=>{"use strict";L()});var po={};R(po,{headCommand:()=>zp});var jp,zp,ho=C(()=>{"use strict";L();_n();jp={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},zp={name:"head",async execute(t,e){if(N(t))return k(jp);let r=Rr(t,"head");if(!r.ok)return r.error;let{lines:n,bytes:s}=r.options;return Pr(e,r.options,"head",i=>uo(i,n,s))}}});var mo={};R(mo,{tailCommand:()=>Gp});var Hp,Gp,go=C(()=>{"use strict";_n();L();Hp={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},Gp={name:"tail",async execute(t,e){if(N(t))return k(Hp);let r=Rr(t,"tail");if(!r.ok)return r.error;let{lines:n,bytes:s,fromLine:i}=r.options;return Pr(e,r.options,"tail",o=>fo(o,n,s,i??!1))}}});var xo={};R(xo,{wcCommand:()=>Kp});function yo(t){let e=t.length,r=0,n=0,s=!1;for(let i=0;i<e;i++){let o=t[i];o===`
126
+ `?(r++,s&&(n++,s=!1)):o===" "||o===" "||o==="\r"?s&&(n++,s=!1):s=!0}return s&&n++,{lines:r,words:n,chars:e}}function Bn(t,e,r,n,s){let i=[];e&&i.push(String(t.lines)),r&&i.push(String(t.words)),n&&i.push(String(t.chars));let o=i.join(" ");return s&&(o+=` ${s}`),o}var qp,Vp,Kp,wo=C(()=>{"use strict";ye();gt();L();qp={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},Vp={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},Kp={name:"wc",async execute(t,e){if(N(t))return k(qp);let r=z("wc",t,Vp);if(!r.ok)return r.error;let{lines:n,words:s}=r.result.flags,i=r.result.flags.bytes||r.result.flags.chars,o=r.result.positional;!n&&!s&&!i&&(n=s=i=!0);let a=await mt(e,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let p=yo(a.files[0].content);return{stdout:`${Bn(p,n,s,i,"")}
127
+ `,stderr:"",exitCode:0}}let l="",c=0,u=0,f=0;for(let{filename:p,content:d}of a.files){let h=yo(d);c+=h.lines,u+=h.words,f+=h.chars,l+=`${Bn(h,n,s,i,p)}
128
+ `}return o.length>1&&(l+=`${Bn({lines:c,words:u,chars:f},n,s,i,"total")}
129
+ `),{stdout:l,stderr:a.stderr,exitCode:a.exitCode}}}});var Eo={};R(Eo,{statCommand:()=>Xp});function bo(t,e){let r=e?"d":"-",n=[t&256?"r":"-",t&128?"w":"-",t&64?"x":"-",t&32?"r":"-",t&16?"w":"-",t&8?"x":"-",t&4?"r":"-",t&2?"w":"-",t&1?"x":"-"];return r+n.join("")}var Zp,Qp,Xp,So=C(()=>{"use strict";ye();L();Zp={name:"stat",summary:"display file or file system status",usage:"stat [OPTION]... FILE...",options:["-c FORMAT use the specified FORMAT instead of the default"," --help display this help and exit"]},Qp={format:{short:"c",type:"string"}},Xp={name:"stat",async execute(t,e){if(N(t))return k(Zp);let r=z("stat",t,Qp);if(!r.ok)return r.error;let n=r.result.flags.format??null,s=r.result.positional;if(s.length===0)return{stdout:"",stderr:`stat: missing operand
130
+ `,exitCode:1};let i="",o="",a=!1;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{let u=await e.fs.stat(c);if(n){let f=n,p=u.mode.toString(8),d=bo(u.mode,u.isDirectory);f=f.replace(/%n/g,l),f=f.replace(/%N/g,`'${l}'`),f=f.replace(/%s/g,String(u.size)),f=f.replace(/%F/g,u.isDirectory?"directory":"regular file"),f=f.replace(/%a/g,p),f=f.replace(/%A/g,d),f=f.replace(/%u/g,"1000"),f=f.replace(/%U/g,"user"),f=f.replace(/%g/g,"1000"),f=f.replace(/%G/g,"group"),i+=`${f}
131
+ `}else{let f=u.mode.toString(8).padStart(4,"0"),p=bo(u.mode,u.isDirectory);i+=` File: ${l}
132
132
  `,i+=` Size: ${u.size} Blocks: ${Math.ceil(u.size/512)}
133
- `,i+=`Access: (${f}/${d})
133
+ `,i+=`Access: (${f}/${p})
134
134
  `,i+=`Modify: ${u.mtime.toISOString()}
135
135
  `}}catch{o+=`stat: cannot stat '${l}': No such file or directory
136
- `,a=!0}}return{stdout:i,stderr:o,exitCode:a?1:0}}}});function $e(t,e,r){let n=typeof r=="boolean"?{ignoreCase:r}:r??{},s=e;n.stripQuotes&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1));let i=n.ignoreCase?`i:${s}`:s,o=mo.get(i);return o||(o=Hd(s,n.ignoreCase),mo.set(i,o)),o.test(t)}function Hd(t,e){let r="^";for(let n=0;n<t.length;n++){let s=t[n];if(s==="*")r+=".*";else if(s==="?")r+=".";else if(s==="["){let i=n+1;for(;i<t.length&&t[i]!=="]";)i++;r+=t.slice(n,i+1),n=i}else s==="."||s==="+"||s==="^"||s==="$"||s==="{"||s==="}"||s==="("||s===")"||s==="|"||s==="\\"?r+=`\\${s}`:r+=s}return r+="$",new RegExp(r,e?"i":"")}var mo,Pn=C(()=>{"use strict";mo=new Map});var Cr={};v(Cr,{egrepCommand:()=>Zd,fgrepCommand:()=>Kd,grepCommand:()=>Fn});function qd(t){let e="",r=0;for(;r<t.length;){let n=t[r];if(n==="\\"&&r+1<t.length){let s=t[r+1];if(s==="|"||s==="("||s===")"){e+=s,r+=2;continue}else if(s==="{"||s==="}"){e+=`\\${s}`,r+=2;continue}}n==="+"||n==="?"||n==="|"||n==="("||n===")"||n==="{"||n==="}"?e+=`\\${n}`:e+=n,r++}return e}function go(t,e,r,n,s,i,o=!1,a=0,l=0,c=0){let u=t.split(`
137
- `),f=u.length,d=f>0&&u[f-1]===""?f-1:f;if(s){let w=0;for(let E=0;E<d;E++)e.lastIndex=0,e.test(u[E])!==r&&w++;return{output:`${i?`${i}:${w}`:String(w)}
138
- `,matched:w>0}}if(a===0&&l===0){let w=[],b=!1,E=0;for(let S=0;S<d&&!(c>0&&E>=c);S++){let A=u[S];if(e.lastIndex=0,e.test(A)!==r)if(b=!0,E++,o){e.lastIndex=0;for(let M=e.exec(A);M!==null;M=e.exec(A))w.push(i?`${i}:${M[0]}`:M[0]),M[0].length===0&&e.lastIndex++}else n?w.push(i?`${i}:${S+1}:${A}`:`${S+1}:${A}`):w.push(i?`${i}:${A}`:A)}return{output:w.length>0?`${w.join(`
136
+ `,a=!0}}return{stdout:i,stderr:o,exitCode:a?1:0}}}});function De(t,e,r){let n=typeof r=="boolean"?{ignoreCase:r}:r??{},s=e;n.stripQuotes&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1));let i=n.ignoreCase?`i:${s}`:s,o=Co.get(i);return o||(o=Jp(s,n.ignoreCase),Co.set(i,o)),o.test(t)}function Jp(t,e){let r="^";for(let n=0;n<t.length;n++){let s=t[n];if(s==="*")r+=".*";else if(s==="?")r+=".";else if(s==="["){let i=n+1;for(;i<t.length&&t[i]!=="]";)i++;r+=t.slice(n,i+1),n=i}else s==="."||s==="+"||s==="^"||s==="$"||s==="{"||s==="}"||s==="("||s===")"||s==="|"||s==="\\"?r+=`\\${s}`:r+=s}return r+="$",new RegExp(r,e?"i":"")}var Co,Wn=C(()=>{"use strict";Co=new Map});var Or={};R(Or,{egrepCommand:()=>nd,fgrepCommand:()=>rd,grepCommand:()=>Un});function ed(t){let e="",r=0;for(;r<t.length;){let n=t[r];if(n==="\\"&&r+1<t.length){let s=t[r+1];if(s==="|"||s==="("||s===")"){e+=s,r+=2;continue}else if(s==="{"||s==="}"){e+=`\\${s}`,r+=2;continue}}n==="+"||n==="?"||n==="|"||n==="("||n===")"||n==="{"||n==="}"?e+=`\\${n}`:e+=n,r++}return e}function Ao(t,e,r,n,s,i,o=!1,a=0,l=0,c=0){let u=t.split(`
137
+ `),f=u.length,p=f>0&&u[f-1]===""?f-1:f;if(s){let w=0;for(let E=0;E<p;E++)e.lastIndex=0,e.test(u[E])!==r&&w++;return{output:`${i?`${i}:${w}`:String(w)}
138
+ `,matched:w>0}}if(a===0&&l===0){let w=[],b=!1,E=0;for(let S=0;S<p&&!(c>0&&E>=c);S++){let v=u[S];if(e.lastIndex=0,e.test(v)!==r)if(b=!0,E++,o){e.lastIndex=0;for(let I=e.exec(v);I!==null;I=e.exec(v))w.push(i?`${i}:${I[0]}`:I[0]),I[0].length===0&&e.lastIndex++}else n?w.push(i?`${i}:${S+1}:${v}`:`${S+1}:${v}`):w.push(i?`${i}:${v}`:v)}return{output:w.length>0?`${w.join(`
139
139
  `)}
140
- `:"",matched:b}}let p=[],h=0,y=new Set,m=[];for(let w=0;w<d&&!(c>0&&h>=c);w++)e.lastIndex=0,e.test(u[w])!==r&&(m.push(w),h++);for(let w of m){for(let E=Math.max(0,w-a);E<w;E++)if(!y.has(E)){y.add(E);let S=u[E];n&&(S=`${E+1}-${S}`),i&&(S=`${i}-${S}`),p.push(S)}if(!y.has(w)){y.add(w);let E=u[w];if(o){e.lastIndex=0;for(let S=e.exec(E);S!==null;S=e.exec(E))p.push(i?`${i}:${S[0]}`:S[0]),S[0].length===0&&e.lastIndex++}else{let S=E;n&&(S=`${w+1}:${S}`),i&&(S=`${i}:${S}`),p.push(S)}}let b=Math.min(d-1,w+l);for(let E=w+1;E<=b;E++)if(!y.has(E)){y.add(E);let S=u[E];n&&(S=`${E+1}-${S}`),i&&(S=`${i}-${S}`),p.push(S)}}return{output:p.length>0?`${p.join(`
140
+ `:"",matched:b}}let d=[],h=0,m=new Set,g=[];for(let w=0;w<p&&!(c>0&&h>=c);w++)e.lastIndex=0,e.test(u[w])!==r&&(g.push(w),h++);for(let w of g){for(let E=Math.max(0,w-a);E<w;E++)if(!m.has(E)){m.add(E);let S=u[E];n&&(S=`${E+1}-${S}`),i&&(S=`${i}-${S}`),d.push(S)}if(!m.has(w)){m.add(w);let E=u[w];if(o){e.lastIndex=0;for(let S=e.exec(E);S!==null;S=e.exec(E))d.push(i?`${i}:${S[0]}`:S[0]),S[0].length===0&&e.lastIndex++}else{let S=E;n&&(S=`${w+1}:${S}`),i&&(S=`${i}:${S}`),d.push(S)}}let b=Math.min(p-1,w+l);for(let E=w+1;E<=b;E++)if(!m.has(E)){m.add(E);let S=u[E];n&&(S=`${E+1}-${S}`),i&&(S=`${i}-${S}`),d.push(S)}}return{output:d.length>0?`${d.join(`
141
141
  `)}
142
- `:"",matched:h>0}}async function On(t,e,r=[],n=[],s=[]){let i=e.fs.resolvePath(e.cwd,t),o=[];try{if(!(await e.fs.stat(i)).isDirectory){let u=t.split("/").pop()||t;return n.length>0&&n.some(f=>$e(u,f,{stripQuotes:!0}))?[]:r.length>0&&!r.some(f=>$e(u,f,{stripQuotes:!0}))?[]:[t]}let l=t.split("/").pop()||t;if(s.length>0&&s.some(u=>$e(l,u,{stripQuotes:!0})))return[];let c=await e.fs.readdir(i);for(let u of c){if(u.startsWith("."))continue;let f=t==="."?u:`${t}/${u}`,d=await On(f,e,r,n,s);o.push(...d)}}catch{}return o}async function Vd(t,e){let r=[],n=t.lastIndexOf("/"),s,i;if(n===-1?(s=e.cwd,i=t):(s=t.slice(0,n)||"/",i=t.slice(n+1)),t.includes("**")){let a=t.split("**"),l=a[0].replace(/\/$/,"")||".",c=a[1]||"";return await yo(l,c,e,r),r}let o=e.fs.resolvePath(e.cwd,s);try{let a=await e.fs.readdir(o);for(let l of a)if($e(l,i,{stripQuotes:!0})){let c=n===-1?l:`${s}/${l}`;r.push(c)}}catch{}return r.sort()}async function yo(t,e,r,n){let s=r.fs.resolvePath(r.cwd,t);try{if(!(await r.fs.stat(s)).isDirectory){let a=t.split("/").pop()||"";if(e){let l=e.replace(/^\//,"");$e(a,l,{stripQuotes:!0})&&n.push(t)}return}let o=await r.fs.readdir(s);for(let a of o){let l=t==="."?a:`${t}/${a}`,c=r.fs.resolvePath(r.cwd,l);if((await r.fs.stat(c)).isDirectory)await yo(l,e,r,n);else if(e){let f=e.replace(/^\//,"");$e(a,f,{stripQuotes:!0})&&n.push(l)}}}catch{}}var Gd,Fn,Kd,Zd,Ar=C(()=>{"use strict";Pn();O();Gd={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},Fn={name:"grep",async execute(t,e){if(I(t))return N(Gd);let r=!1,n=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,d=!1,p=!1,h=!1,y=!1,m=!1,w=0,b=0,E=0,S=[],A=[],F=[],M=null,D=[];for(let z=0;z<t.length;z++){let H=t[z];if(H.startsWith("-")&&H!=="-"){if(H==="-e"&&z+1<t.length){M=t[++z];continue}if(H.startsWith("--include=")){S.push(H.slice(10));continue}if(H.startsWith("--exclude=")){A.push(H.slice(10));continue}if(H.startsWith("--exclude-dir=")){F.push(H.slice(14));continue}if(H.startsWith("--max-count=")){w=parseInt(H.slice(12),10);continue}let Ae=H.match(/^-m(\d+)$/);if(Ae){w=parseInt(Ae[1],10);continue}if(H==="-m"&&z+1<t.length){w=parseInt(t[++z],10);continue}let _e=H.match(/^-([ABC])(\d+)$/);if(_e){let _=parseInt(_e[2],10);_e[1]==="A"?E=_:_e[1]==="B"?b=_:_e[1]==="C"&&(b=_,E=_);continue}if((H==="-A"||H==="-B"||H==="-C")&&z+1<t.length){let _=parseInt(t[++z],10);H==="-A"?E=_:H==="-B"?b=_:(b=_,E=_);continue}let Nn=H.startsWith("--")?[H]:H.slice(1).split("");for(let _ of Nn)if(_==="i"||_==="--ignore-case")r=!0;else if(_==="n"||_==="--line-number")n=!0;else if(_==="v"||_==="--invert-match")s=!0;else if(_==="c"||_==="--count")i=!0;else if(_==="l"||_==="--files-with-matches")o=!0;else if(_==="L"||_==="--files-without-match")a=!0;else if(_==="r"||_==="R"||_==="--recursive")l=!0;else if(_==="w"||_==="--word-regexp")c=!0;else if(_==="x"||_==="--line-regexp")u=!0;else if(_==="E"||_==="--extended-regexp")f=!0;else if(_==="P"||_==="--perl-regexp")d=!0;else if(_==="F"||_==="--fixed-strings")p=!0;else if(_==="o"||_==="--only-matching")h=!0;else if(_==="h"||_==="--no-filename")y=!0;else if(_==="q"||_==="--quiet"||_==="--silent")m=!0;else{if(_.startsWith("--"))return $("grep",_);if(_.length===1)return $("grep",`-${_}`)}}else M===null?M=H:D.push(H)}if(M===null)return{stdout:"",stderr:`grep: missing pattern
143
- `,exitCode:2};let U;p?U=M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):f||d?U=M:U=qd(M),c&&(U=`\\b${U}\\b`),u&&(U=`^${U}$`);let te;try{te=new RegExp(U,r?"gi":"g")}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${M}
144
- `,exitCode:2}}if(D.length===0&&e.stdin){let z=go(e.stdin,te,s,n,i,"",h,b,E,w);return m?{stdout:"",stderr:"",exitCode:z.matched?0:1}:{stdout:z.output,stderr:"",exitCode:z.matched?0:1}}if(D.length===0)return{stdout:"",stderr:`grep: no input files
145
- `,exitCode:2};let de="",se="",Ce=!1,je=!1,De=[];for(let z of D)if(z.includes("*")||z.includes("?")||z.includes("[")){let H=await Vd(z,e);if(l)for(let Ae of H){let _e=await On(Ae,e,S,A,F);De.push(..._e)}else De.push(...H)}else if(l){let H=await On(z,e,S,A,F);De.push(...H)}else De.push(z);let hr=(De.length>1||l)&&!y;for(let z of De){let H=z.split("/").pop()||z;if(!(A.length>0&&!l&&A.some(Ae=>$e(H,Ae,{stripQuotes:!0})))&&!(S.length>0&&!l&&!S.some(Ae=>$e(H,Ae,{stripQuotes:!0}))))try{let Ae=e.fs.resolvePath(e.cwd,z);if((await e.fs.stat(Ae)).isDirectory){l||(se+=`grep: ${z}: Is a directory
146
- `);continue}let Nn=await e.fs.readFile(Ae),_=go(Nn,te,s,n,i,hr?z:"",h,b,E,w);if(_.matched){if(Ce=!0,m)return{stdout:"",stderr:"",exitCode:0};o?de+=`${z}
147
- `:a||(de+=_.output)}else a?de+=`${z}
148
- `:i&&!o&&(de+=_.output)}catch{se+=`grep: ${z}: No such file or directory
149
- `,je=!0}}let Me;return je?Me=2:a?Me=de.length>0?0:1:Me=Ce?0:1,m?{stdout:"",stderr:"",exitCode:Me}:{stdout:de,stderr:se,exitCode:Me}}};Kd={name:"fgrep",async execute(t,e){return Fn.execute(["-F",...t],e)}},Zd={name:"egrep",async execute(t,e){return Fn.execute(["-E",...t],e)}}});function kr(t){return t instanceof he||t instanceof we||t instanceof me}var Re,he,we,me,Ue,Pe,Q,le,qe,W,ze,X=C(()=>{"use strict";Re=class extends Error{stdout;stderr;constructor(e,r="",n=""){super(e),this.stdout=r,this.stderr=n}prependOutput(e,r){this.stdout=e+this.stdout,this.stderr=r+this.stderr}},he=class extends Re{levels;name="BreakError";constructor(e=1,r="",n=""){super("break",r,n),this.levels=e}},we=class extends Re{levels;name="ContinueError";constructor(e=1,r="",n=""){super("continue",r,n),this.levels=e}},me=class extends Re{exitCode;name="ReturnError";constructor(e=0,r="",n=""){super("return",r,n),this.exitCode=e}},Ue=class extends Re{exitCode;name="ErrexitError";constructor(e,r="",n=""){super(`errexit: command exited with status ${e}`,r,n),this.exitCode=e}},Pe=class extends Re{varName;name="NounsetError";constructor(e,r=""){super(`${e}: unbound variable`,r,`bash: ${e}: unbound variable
150
- `),this.varName=e}},Q=class extends Re{exitCode;name="ExitError";constructor(e,r="",n=""){super("exit",r,n),this.exitCode=e}},le=class extends Re{name="ArithmeticError";constructor(e,r="",n=""){super(e,r,n),this.stderr=n||`bash: ${e}
151
- `}},qe=class extends Re{name="BadSubstitutionError";constructor(e,r="",n=""){super(e,r,n),this.stderr=n||`bash: ${e}: bad substitution
152
- `}},W=class extends Re{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,r,n="",s=""){super(e,n,s),this.limitType=r,this.stderr=s||`bash: ${e}
153
- `}},ze=class extends Re{name="SubshellExitError";constructor(e="",r=""){super("subshell exit",e,r)}}});function wo(t,e,r){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:t,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],restartCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],pendingExecute:void 0,rangeStates:r||new Map}}function Xd(t){return typeof t=="object"&&"first"in t&&"step"in t}function Zt(t,e,r,n){if(t==="$")return e===r;if(typeof t=="number")return e===t;if(Xd(t)){let{first:s,step:i}=t;return i===0?e===s:(e-s)%i===0&&e>=s}if(typeof t=="object"&&"pattern"in t)try{return new RegExp(t.pattern).test(n)}catch{return!1}return!1}function Jd(t){let e=r=>r===void 0?"undefined":r==="$"?"$":typeof r=="number"?String(r):"pattern"in r?`/${r.pattern}/`:"first"in r?`${r.first}~${r.step}`:"unknown";return`${e(t.start)},${e(t.end)}`}function kt(t,e,r,n,s){if(!t||!t.start&&!t.end)return!0;let i=t.start,o=t.end;if(i!==void 0&&o===void 0)return Zt(i,e,r,n);if(i!==void 0&&o!==void 0){let a=typeof i=="object"&&"pattern"in i,l=typeof o=="object"&&"pattern"in o;if(!a&&!l){let u=typeof i=="number"?i:i==="$"?r:1,f=typeof o=="number"?o:r;return e>=u&&e<=f}if(s){let u=Jd(t),f=s.get(u);return f||(f={active:!1},s.set(u,f)),f.active?(Zt(o,e,r,n)&&(f.active=!1,s.set(u,f)),!0):Zt(i,e,r,n)?(f.active=!0,f.startLine=e,s.set(u,f),Zt(o,e,r,n)&&(f.active=!1,s.set(u,f)),!0):!1}return Zt(i,e,r,n)}return!0}function Yd(t){let e="",r=0;for(;r<t.length;){if(t[r]==="\\"&&r+1<t.length){let n=t[r+1];if(n==="+"||n==="?"||n==="|"){e+=n,r+=2;continue}if(n==="("||n===")"){e+=n,r+=2;continue}if(n==="{"||n==="}"){e+=n,r+=2;continue}e+=t[r]+n,r+=2;continue}if(t[r]==="+"||t[r]==="?"||t[r]==="|"||t[r]==="("||t[r]===")"){e+=`\\${t[r]}`,r++;continue}e+=t[r],r++}return e}function ep(t){let e="";for(let r=0;r<t.length;r++){let n=t[r],s=n.charCodeAt(0);n==="\\"?e+="\\\\":n===" "?e+="\\t":n===`
142
+ `:"",matched:h>0}}async function ko(t,e,r,n){let s=r.fs.resolvePath(r.cwd,t);try{if(!(await r.fs.stat(s)).isDirectory){let a=t.split("/").pop()||"";if(e){let l=e.replace(/^\//,"");De(a,l,{stripQuotes:!0})&&n.push(t)}return}let o=await r.fs.readdir(s);for(let a of o){let l=t==="."?a:`${t}/${a}`,c=r.fs.resolvePath(r.cwd,l);if((await r.fs.stat(c)).isDirectory)await ko(l,e,r,n);else if(e){let f=e.replace(/^\//,"");De(a,f,{stripQuotes:!0})&&n.push(l)}}}catch{}}async function td(t,e){let r=[],n=t.lastIndexOf("/"),s,i;if(n===-1?(s=e.cwd,i=t):(s=t.slice(0,n)||"/",i=t.slice(n+1)),t.includes("**")){let a=[],l=t.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await ko(c,u,e,a),a.map(f=>({path:f}))}let o=e.fs.resolvePath(e.cwd,s);try{if(e.fs.readdirWithFileTypes){let a=await e.fs.readdirWithFileTypes(o);for(let l of a)if(De(l.name,i,{stripQuotes:!0})){let c=n===-1?l.name:`${s}/${l.name}`;r.push({path:c,isFile:l.isFile})}}else{let a=await e.fs.readdir(o);for(let l of a)if(De(l,i,{stripQuotes:!0})){let c=n===-1?l:`${s}/${l}`;r.push({path:c})}}}catch{}return r.sort((a,l)=>a.path.localeCompare(l.path))}async function Fr(t,e,r=[],n=[],s=[],i){let o=e.fs.resolvePath(e.cwd,t),a=[];try{let l,c;if(i!==void 0)l=i,c=!i;else{let f=await e.fs.stat(o);l=f.isFile,c=f.isDirectory}if(l){let f=t.split("/").pop()||t;return n.length>0&&n.some(p=>De(f,p,{stripQuotes:!0}))?[]:r.length>0&&!r.some(p=>De(f,p,{stripQuotes:!0}))?[]:[{path:t,isFile:!0}]}if(!c)return[];let u=t.split("/").pop()||t;if(s.length>0&&s.some(f=>De(u,f,{stripQuotes:!0})))return[];if(e.fs.readdirWithFileTypes){let f=await e.fs.readdirWithFileTypes(o);for(let p of f){if(p.name.startsWith("."))continue;let d=t==="."?p.name:`${t}/${p.name}`,h=await Fr(d,e,r,n,s,p.isFile);a.push(...h)}}else{let f=await e.fs.readdir(o);for(let p of f){if(p.startsWith("."))continue;let d=t==="."?p:`${t}/${p}`,h=await Fr(d,e,r,n,s);a.push(...h)}}}catch{}return a}var Yp,Un,rd,nd,Tr=C(()=>{"use strict";Wn();L();Yp={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-P, --perl-regexp PATTERN is a Perl regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-x, --line-regexp match only whole lines","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-m NUM, --max-count=NUM stop after NUM matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},Un={name:"grep",async execute(t,e){if(N(t))return k(Yp);let r=!1,n=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,p=!1,d=!1,h=!1,m=!1,g=!1,w=0,b=0,E=0,S=[],v=[],D=[],I=null,$=[];for(let M=0;M<t.length;M++){let W=t[M];if(W.startsWith("-")&&W!=="-"){if(W==="-e"&&M+1<t.length){I=t[++M];continue}if(W.startsWith("--include=")){S.push(W.slice(10));continue}if(W.startsWith("--exclude=")){v.push(W.slice(10));continue}if(W.startsWith("--exclude-dir=")){D.push(W.slice(14));continue}if(W.startsWith("--max-count=")){w=parseInt(W.slice(12),10);continue}let se=W.match(/^-m(\d+)$/);if(se){w=parseInt(se[1],10);continue}if(W==="-m"&&M+1<t.length){w=parseInt(t[++M],10);continue}let G=W.match(/^-([ABC])(\d+)$/);if(G){let F=parseInt(G[2],10);G[1]==="A"?E=F:G[1]==="B"?b=F:G[1]==="C"&&(b=F,E=F);continue}if((W==="-A"||W==="-B"||W==="-C")&&M+1<t.length){let F=parseInt(t[++M],10);W==="-A"?E=F:W==="-B"?b=F:(b=F,E=F);continue}let ne=W.startsWith("--")?[W]:W.slice(1).split("");for(let F of ne)if(F==="i"||F==="--ignore-case")r=!0;else if(F==="n"||F==="--line-number")n=!0;else if(F==="v"||F==="--invert-match")s=!0;else if(F==="c"||F==="--count")i=!0;else if(F==="l"||F==="--files-with-matches")o=!0;else if(F==="L"||F==="--files-without-match")a=!0;else if(F==="r"||F==="R"||F==="--recursive")l=!0;else if(F==="w"||F==="--word-regexp")c=!0;else if(F==="x"||F==="--line-regexp")u=!0;else if(F==="E"||F==="--extended-regexp")f=!0;else if(F==="P"||F==="--perl-regexp")p=!0;else if(F==="F"||F==="--fixed-strings")d=!0;else if(F==="o"||F==="--only-matching")h=!0;else if(F==="h"||F==="--no-filename")m=!0;else if(F==="q"||F==="--quiet"||F==="--silent")g=!0;else{if(F.startsWith("--"))return P("grep",F);if(F.length===1)return P("grep",`-${F}`)}}else I===null?I=W:$.push(W)}if(I===null)return{stdout:"",stderr:`grep: missing pattern
143
+ `,exitCode:2};let V;d?V=I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):f||p?V=I:V=ed(I),c&&(V=`\\b${V}\\b`),u&&(V=`^${V}$`);let K;try{K=new RegExp(V,r?"gi":"g")}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${I}
144
+ `,exitCode:2}}if($.length===0&&e.stdin){let M=Ao(e.stdin,K,s,n,i,"",h,b,E,w);return g?{stdout:"",stderr:"",exitCode:M.matched?0:1}:{stdout:M.output,stderr:"",exitCode:M.matched?0:1}}if($.length===0)return{stdout:"",stderr:`grep: no input files
145
+ `,exitCode:2};let Y="",re="",H=!1,ce=!1,X=[];for(let M of $)if(M.includes("*")||M.includes("?")||M.includes("[")){let W=await td(M,e);if(l)for(let se of W){let G=await Fr(se.path,e,S,v,D,se.isFile);X.push(...G)}else X.push(...W)}else if(l){let W=await Fr(M,e,S,v,D);X.push(...W)}else X.push({path:M});let Ce=(X.length>1||l)&&!m,ve=50;for(let M=0;M<X.length;M+=ve){let W=X.slice(M,M+ve),se=await Promise.all(W.map(async G=>{let ne=G.path,F=ne.split("/").pop()||ne;if(v.length>0&&!l&&v.some(fe=>De(F,fe,{stripQuotes:!0}))||S.length>0&&!l&&!S.some(fe=>De(F,fe,{stripQuotes:!0})))return null;try{let fe=e.fs.resolvePath(e.cwd,ne),dt=!1;if(G.isFile===void 0?dt=(await e.fs.stat(fe)).isDirectory:dt=!G.isFile,dt)return l?null:{error:`grep: ${ne}: Is a directory
146
+ `};let Te=await e.fs.readFile(fe),Ft=Ao(Te,K,s,n,i,Ce?ne:"",h,b,E,w);return{file:ne,result:Ft}}catch{return{error:`grep: ${ne}: No such file or directory
147
+ `}}}));for(let G of se){if(G===null)continue;if("error"in G&&G.error){re+=G.error,G.error.includes("Is a directory")||(ce=!0);continue}if(!("file"in G)||!G.result)continue;let{file:ne,result:F}=G;if(F.matched){if(H=!0,g)return{stdout:"",stderr:"",exitCode:0};o?Y+=`${ne}
148
+ `:a||(Y+=F.output)}else a?Y+=`${ne}
149
+ `:i&&!o&&(Y+=F.output)}}let ue;return ce?ue=2:a?ue=Y.length>0?0:1:ue=H?0:1,g?{stdout:"",stderr:"",exitCode:ue}:{stdout:Y,stderr:re,exitCode:ue}}};rd={name:"fgrep",async execute(t,e){return Un.execute(["-F",...t],e)}},nd={name:"egrep",async execute(t,e){return Un.execute(["-E",...t],e)}}});function Dr(t){return t instanceof Ae||t instanceof Re||t instanceof ke}var We,Ae,Re,ke,Ke,Ue,ie,xe,Je,j,Ze,oe=C(()=>{"use strict";We=class extends Error{stdout;stderr;constructor(e,r="",n=""){super(e),this.stdout=r,this.stderr=n}prependOutput(e,r){this.stdout=e+this.stdout,this.stderr=r+this.stderr}},Ae=class extends We{levels;name="BreakError";constructor(e=1,r="",n=""){super("break",r,n),this.levels=e}},Re=class extends We{levels;name="ContinueError";constructor(e=1,r="",n=""){super("continue",r,n),this.levels=e}},ke=class extends We{exitCode;name="ReturnError";constructor(e=0,r="",n=""){super("return",r,n),this.exitCode=e}},Ke=class extends We{exitCode;name="ErrexitError";constructor(e,r="",n=""){super(`errexit: command exited with status ${e}`,r,n),this.exitCode=e}},Ue=class extends We{varName;name="NounsetError";constructor(e,r=""){super(`${e}: unbound variable`,r,`bash: ${e}: unbound variable
150
+ `),this.varName=e}},ie=class extends We{exitCode;name="ExitError";constructor(e,r="",n=""){super("exit",r,n),this.exitCode=e}},xe=class extends We{name="ArithmeticError";constructor(e,r="",n=""){super(e,r,n),this.stderr=n||`bash: ${e}
151
+ `}},Je=class extends We{name="BadSubstitutionError";constructor(e,r="",n=""){super(e,r,n),this.stderr=n||`bash: ${e}: bad substitution
152
+ `}},j=class extends We{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(e,r,n="",s=""){super(e,n,s),this.limitType=r,this.stderr=s||`bash: ${e}
153
+ `}},Ze=class extends We{name="SubshellExitError";constructor(e="",r=""){super("subshell exit",e,r)}}});function Io(t,e,r){return{patternSpace:"",holdSpace:"",lineNumber:0,totalLines:t,deleted:!1,printed:!1,quit:!1,quitSilent:!1,exitCode:void 0,appendBuffer:[],substitutionMade:!1,lineNumberOutput:[],restartCycle:!1,currentFilename:e,pendingFileReads:[],pendingFileWrites:[],pendingExecute:void 0,rangeStates:r||new Map}}function id(t){return typeof t=="object"&&"first"in t&&"step"in t}function sr(t,e,r,n){if(t==="$")return e===r;if(typeof t=="number")return e===t;if(id(t)){let{first:s,step:i}=t;return i===0?e===s:(e-s)%i===0&&e>=s}if(typeof t=="object"&&"pattern"in t)try{return new RegExp(t.pattern).test(n)}catch{return!1}return!1}function od(t){let e=r=>r===void 0?"undefined":r==="$"?"$":typeof r=="number"?String(r):"pattern"in r?`/${r.pattern}/`:"first"in r?`${r.first}~${r.step}`:"unknown";return`${e(t.start)},${e(t.end)}`}function Dt(t,e,r,n,s){if(!t||!t.start&&!t.end)return!0;let i=t.start,o=t.end;if(i!==void 0&&o===void 0)return sr(i,e,r,n);if(i!==void 0&&o!==void 0){let a=typeof i=="object"&&"pattern"in i,l=typeof o=="object"&&"pattern"in o;if(!a&&!l){let u=typeof i=="number"?i:i==="$"?r:1,f=typeof o=="number"?o:r;return e>=u&&e<=f}if(s){let u=od(t),f=s.get(u);return f||(f={active:!1},s.set(u,f)),f.active?(sr(o,e,r,n)&&(f.active=!1,s.set(u,f)),!0):sr(i,e,r,n)?(f.active=!0,f.startLine=e,s.set(u,f),sr(o,e,r,n)&&(f.active=!1,s.set(u,f)),!0):!1}return sr(i,e,r,n)}return!0}function ad(t){let e="",r=0;for(;r<t.length;){if(t[r]==="\\"&&r+1<t.length){let n=t[r+1];if(n==="+"||n==="?"||n==="|"){e+=n,r+=2;continue}if(n==="("||n===")"){e+=n,r+=2;continue}if(n==="{"||n==="}"){e+=n,r+=2;continue}e+=t[r]+n,r+=2;continue}if(t[r]==="+"||t[r]==="?"||t[r]==="|"||t[r]==="("||t[r]===")"){e+=`\\${t[r]}`,r++;continue}e+=t[r],r++}return e}function ld(t){let e="";for(let r=0;r<t.length;r++){let n=t[r],s=n.charCodeAt(0);n==="\\"?e+="\\\\":n===" "?e+="\\t":n===`
154
154
  `?e+=`$
155
- `:n==="\r"?e+="\\r":n==="\x07"?e+="\\a":n==="\b"?e+="\\b":n==="\f"?e+="\\f":n==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=n}return`${e}$`}function xo(t,e,r){let n="",s=0;for(;s<t.length;){if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&"){n+="&",s+=2;continue}if(i==="n"){n+=`
156
- `,s+=2;continue}if(i==="t"){n+=" ",s+=2;continue}let o=parseInt(i,10);if(o>=1&&o<=9){n+=r[o-1]||"",s+=2;continue}n+=i,s+=2;continue}if(t[s]==="&"){n+=e,s++;continue}n+=t[s],s++}return n}function tp(t,e){let{lineNumber:r,totalLines:n,patternSpace:s}=e;if(t.type!=="label"&&kt(t.address,r,n,s,e.rangeStates))switch(t.type){case"substitute":{let i=t,o="";i.global&&(o+="g"),i.ignoreCase&&(o+="i");let a=i.extendedRegex?i.pattern:Yd(i.pattern);try{let l=new RegExp(a,o),c=l.test(e.patternSpace);if(l.lastIndex=0,c){if(e.substitutionMade=!0,i.nthOccurrence&&i.nthOccurrence>0&&!i.global){let u=0,f=i.nthOccurrence;e.patternSpace=e.patternSpace.replace(new RegExp(a,`g${i.ignoreCase?"i":""}`),(d,...p)=>{if(u++,u===f){let h=p.slice(0,-2);return xo(i.replacement,d,h)}return d})}else e.patternSpace=e.patternSpace.replace(l,(u,...f)=>{let d=f.slice(0,-2);return xo(i.replacement,u,d)});i.printOnMatch&&(e.printed=!0)}}catch{}break}case"print":e.printed=!0;break;case"printFirstLine":{let i=e.patternSpace.indexOf(`
155
+ `:n==="\r"?e+="\\r":n==="\x07"?e+="\\a":n==="\b"?e+="\\b":n==="\f"?e+="\\f":n==="\v"?e+="\\v":s<32||s>=127?e+=`\\${s.toString(8).padStart(3,"0")}`:e+=n}return`${e}$`}function No(t,e,r){let n="",s=0;for(;s<t.length;){if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&"){n+="&",s+=2;continue}if(i==="n"){n+=`
156
+ `,s+=2;continue}if(i==="t"){n+=" ",s+=2;continue}let o=parseInt(i,10);if(o>=1&&o<=9){n+=r[o-1]||"",s+=2;continue}n+=i,s+=2;continue}if(t[s]==="&"){n+=e,s++;continue}n+=t[s],s++}return n}function cd(t,e){let{lineNumber:r,totalLines:n,patternSpace:s}=e;if(t.type!=="label"&&Dt(t.address,r,n,s,e.rangeStates))switch(t.type){case"substitute":{let i=t,o="";i.global&&(o+="g"),i.ignoreCase&&(o+="i");let a=i.extendedRegex?i.pattern:ad(i.pattern);try{let l=new RegExp(a,o),c=l.test(e.patternSpace);if(l.lastIndex=0,c){if(e.substitutionMade=!0,i.nthOccurrence&&i.nthOccurrence>0&&!i.global){let u=0,f=i.nthOccurrence;e.patternSpace=e.patternSpace.replace(new RegExp(a,`g${i.ignoreCase?"i":""}`),(p,...d)=>{if(u++,u===f){let h=d.slice(0,-2);return No(i.replacement,p,h)}return p})}else e.patternSpace=e.patternSpace.replace(l,(u,...f)=>{let p=f.slice(0,-2);return No(i.replacement,u,p)});i.printOnMatch&&(e.printed=!0)}}catch{}break}case"print":e.printed=!0;break;case"printFirstLine":{let i=e.patternSpace.indexOf(`
157
157
  `);i!==-1?e.lineNumberOutput.push(e.patternSpace.slice(0,i)):e.lineNumberOutput.push(e.patternSpace);break}case"delete":e.deleted=!0;break;case"deleteFirstLine":{let i=e.patternSpace.indexOf(`
158
158
  `);i!==-1?(e.patternSpace=e.patternSpace.slice(i+1),e.restartCycle=!0):e.deleted=!0;break}case"zap":e.patternSpace="";break;case"append":e.appendBuffer.push(t.text);break;case"insert":e.appendBuffer.unshift(`__INSERT__${t.text}`);break;case"change":e.patternSpace=t.text,e.deleted=!0,e.appendBuffer.push(t.text);break;case"hold":e.holdSpace=e.patternSpace;break;case"holdAppend":e.holdSpace?e.holdSpace+=`
159
159
  ${e.patternSpace}`:e.holdSpace=e.patternSpace;break;case"get":e.patternSpace=e.holdSpace;break;case"getAppend":e.patternSpace+=`
160
- ${e.holdSpace}`;break;case"exchange":{let i=e.patternSpace;e.patternSpace=e.holdSpace,e.holdSpace=i;break}case"next":e.printed=!0;break;case"quit":e.quit=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"quitSilent":e.quit=!0,e.quitSilent=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"list":{let i=ep(e.patternSpace);e.lineNumberOutput.push(i);break}case"printFilename":e.currentFilename&&e.lineNumberOutput.push(e.currentFilename);break;case"version":break;case"readFile":e.pendingFileReads.push({filename:t.filename,wholeFile:!0});break;case"readFileLine":e.pendingFileReads.push({filename:t.filename,wholeFile:!1});break;case"writeFile":e.pendingFileWrites.push({filename:t.filename,content:`${e.patternSpace}
160
+ ${e.holdSpace}`;break;case"exchange":{let i=e.patternSpace;e.patternSpace=e.holdSpace,e.holdSpace=i;break}case"next":e.printed=!0;break;case"quit":e.quit=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"quitSilent":e.quit=!0,e.quitSilent=!0,t.exitCode!==void 0&&(e.exitCode=t.exitCode);break;case"list":{let i=ld(e.patternSpace);e.lineNumberOutput.push(i);break}case"printFilename":e.currentFilename&&e.lineNumberOutput.push(e.currentFilename);break;case"version":break;case"readFile":e.pendingFileReads.push({filename:t.filename,wholeFile:!0});break;case"readFileLine":e.pendingFileReads.push({filename:t.filename,wholeFile:!1});break;case"writeFile":e.pendingFileWrites.push({filename:t.filename,content:`${e.patternSpace}
161
161
  `});break;case"writeFirstLine":{let i=e.patternSpace.indexOf(`
162
162
  `),o=i!==-1?e.patternSpace.slice(0,i):e.patternSpace;e.pendingFileWrites.push({filename:t.filename,content:`${o}
163
- `});break}case"execute":t.command?e.pendingExecute={command:t.command,replacePattern:!1}:e.pendingExecute={command:e.patternSpace,replacePattern:!0};break;case"transliterate":e.patternSpace=rp(e.patternSpace,t);break;case"lineNumber":e.lineNumberOutput.push(String(e.lineNumber));break;case"branch":break;case"branchOnSubst":break;case"branchOnNoSubst":break;case"group":break}}function rp(t,e){let r="";for(let n of t){let s=e.source.indexOf(n);s!==-1?r+=e.dest[s]:r+=n}return r}function Tn(t,e,r,n){let s=new Map;for(let c=0;c<t.length;c++){let u=t[c];u.type==="label"&&s.set(u.name,c)}let i=n?.maxIterations??Qd,o=0,a=0,l=0;for(;l<t.length;){if(o++,o>i)throw new W(`sed: command execution exceeded maximum iterations (${i})`,"iterations");if(e.deleted||e.quit||e.quitSilent||e.restartCycle)break;let c=t[l];if(c.type==="nextAppend"){if(kt(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates))if(r&&r.currentLineIndex+a+1<r.lines.length){a++;let u=r.lines[r.currentLineIndex+a];e.patternSpace+=`
164
- ${u}`,e.lineNumber=r.currentLineIndex+a+1}else{e.quit=!0,e.deleted=!0;break}l++;continue}if(c.type==="branch"){let u=c;if(kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnSubst"){let u=c;if(kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&e.substitutionMade){if(e.substitutionMade=!1,u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnNoSubst"){let u=c;if(kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&!e.substitutionMade){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="group"){let u=c;kt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&Tn(u.commands,e,r,n),l++;continue}tp(c,e),l++}return a}var Qd,bo=C(()=>{"use strict";X();Qd=1e4});var P,Nr,Eo=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.DOLLAR="DOLLAR",t.PATTERN="PATTERN",t.STEP="STEP",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.COMMA="COMMA",t.COMMAND="COMMAND",t.SUBSTITUTE="SUBSTITUTE",t.TRANSLITERATE="TRANSLITERATE",t.LABEL_DEF="LABEL_DEF",t.BRANCH="BRANCH",t.BRANCH_ON_SUBST="BRANCH_ON_SUBST",t.BRANCH_ON_NO_SUBST="BRANCH_ON_NO_SUBST",t.TEXT_CMD="TEXT_CMD",t.FILE_READ="FILE_READ",t.FILE_READ_LINE="FILE_READ_LINE",t.FILE_WRITE="FILE_WRITE",t.FILE_WRITE_LINE="FILE_WRITE_LINE",t.EXECUTE="EXECUTE",t.EOF="EOF",t.ERROR="ERROR"})(P||(P={}));Nr=class{input;pos=0;line=1;column=1;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&e.push(r)}return e.push(this.makeToken(P.EOF,"")),e}makeToken(e,r,n){return{type:e,value:r,line:this.line,column:this.column,...n}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
163
+ `});break}case"execute":t.command?e.pendingExecute={command:t.command,replacePattern:!1}:e.pendingExecute={command:e.patternSpace,replacePattern:!0};break;case"transliterate":e.patternSpace=ud(e.patternSpace,t);break;case"lineNumber":e.lineNumberOutput.push(String(e.lineNumber));break;case"branch":break;case"branchOnSubst":break;case"branchOnNoSubst":break;case"group":break}}function ud(t,e){let r="";for(let n of t){let s=e.source.indexOf(n);s!==-1?r+=e.dest[s]:r+=n}return r}function jn(t,e,r,n){let s=new Map;for(let c=0;c<t.length;c++){let u=t[c];u.type==="label"&&s.set(u.name,c)}let i=n?.maxIterations??sd,o=0,a=0,l=0;for(;l<t.length;){if(o++,o>i)throw new j(`sed: command execution exceeded maximum iterations (${i})`,"iterations");if(e.deleted||e.quit||e.quitSilent||e.restartCycle)break;let c=t[l];if(c.type==="nextAppend"){if(Dt(c.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates))if(r&&r.currentLineIndex+a+1<r.lines.length){a++;let u=r.lines[r.currentLineIndex+a];e.patternSpace+=`
164
+ ${u}`,e.lineNumber=r.currentLineIndex+a+1}else{e.quit=!0,e.deleted=!0;break}l++;continue}if(c.type==="branch"){let u=c;if(Dt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnSubst"){let u=c;if(Dt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&e.substitutionMade){if(e.substitutionMade=!1,u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="branchOnNoSubst"){let u=c;if(Dt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&!e.substitutionMade){if(u.label){let f=s.get(u.label);if(f!==void 0){l=f;continue}}break}l++;continue}if(c.type==="group"){let u=c;Dt(u.address,e.lineNumber,e.totalLines,e.patternSpace,e.rangeStates)&&jn(u.commands,e,r,n),l++;continue}cd(c,e),l++}return a}var sd,vo=C(()=>{"use strict";oe();sd=1e4});var T,Lr,$o=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.DOLLAR="DOLLAR",t.PATTERN="PATTERN",t.STEP="STEP",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.COMMA="COMMA",t.COMMAND="COMMAND",t.SUBSTITUTE="SUBSTITUTE",t.TRANSLITERATE="TRANSLITERATE",t.LABEL_DEF="LABEL_DEF",t.BRANCH="BRANCH",t.BRANCH_ON_SUBST="BRANCH_ON_SUBST",t.BRANCH_ON_NO_SUBST="BRANCH_ON_NO_SUBST",t.TEXT_CMD="TEXT_CMD",t.FILE_READ="FILE_READ",t.FILE_READ_LINE="FILE_READ_LINE",t.FILE_WRITE="FILE_WRITE",t.FILE_WRITE_LINE="FILE_WRITE_LINE",t.EXECUTE="EXECUTE",t.EOF="EOF",t.ERROR="ERROR"})(T||(T={}));Lr=class{input;pos=0;line=1;column=1;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&e.push(r)}return e.push(this.makeToken(T.EOF,"")),e}makeToken(e,r,n){return{type:e,value:r,line:this.line,column:this.column,...n}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
165
165
  `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===" "||e===" "||e==="\r")this.advance();else if(e==="#")for(;this.pos<this.input.length&&this.peek()!==`
166
166
  `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,r=this.column,n=this.peek();return n===`
167
- `?(this.advance(),{type:P.NEWLINE,value:`
168
- `,line:e,column:r}):n===";"?(this.advance(),{type:P.SEMICOLON,value:";",line:e,column:r}):n==="{"?(this.advance(),{type:P.LBRACE,value:"{",line:e,column:r}):n==="}"?(this.advance(),{type:P.RBRACE,value:"}",line:e,column:r}):n===","?(this.advance(),{type:P.COMMA,value:",",line:e,column:r}):n==="$"?(this.advance(),{type:P.DOLLAR,value:"$",line:e,column:r}):this.isDigit(n)?this.readNumber():n==="/"?this.readPattern():n===":"?this.readLabelDef():this.readCommand()}readNumber(){let e=this.line,r=this.column,n="";for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="~"){this.advance();let s="";for(;this.isDigit(this.peek());)s+=this.advance();let i=parseInt(n,10),o=parseInt(s,10)||0;return{type:P.STEP,value:`${i}~${o}`,first:i,step:o,line:e,column:r}}return{type:P.NUMBER,value:parseInt(n,10),line:e,column:r}}readPattern(){let e=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")n+=this.advance(),this.pos<this.input.length&&(n+=this.advance());else{if(this.peek()===`
169
- `)break;n+=this.advance()}return this.peek()==="/"&&this.advance(),{type:P.PATTERN,value:n,pattern:n,line:e,column:r}}readLabelDef(){let e=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length;){let s=this.peek();if(s===" "||s===" "||s===`
170
- `||s===";"||s==="}"||s==="{")break;n+=this.advance()}return{type:P.LABEL_DEF,value:n,label:n,line:e,column:r}}readCommand(){let e=this.line,r=this.column,n=this.advance();switch(n){case"s":return this.readSubstitute(e,r);case"y":return this.readTransliterate(e,r);case"a":case"i":case"c":return this.readTextCommand(n,e,r);case"b":return this.readBranch(P.BRANCH,"b",e,r);case"t":return this.readBranch(P.BRANCH_ON_SUBST,"t",e,r);case"T":return this.readBranch(P.BRANCH_ON_NO_SUBST,"T",e,r);case"r":return this.readFileCommand(P.FILE_READ,"r",e,r);case"R":return this.readFileCommand(P.FILE_READ_LINE,"R",e,r);case"w":return this.readFileCommand(P.FILE_WRITE,"w",e,r);case"W":return this.readFileCommand(P.FILE_WRITE_LINE,"W",e,r);case"e":return this.readExecute(e,r);case"p":case"P":case"d":case"D":case"h":case"H":case"g":case"G":case"x":case"n":case"N":case"q":case"Q":case"z":case"=":case"l":case"F":case"v":return{type:P.COMMAND,value:n,line:e,column:r};default:return{type:P.ERROR,value:n,line:e,column:r}}}readSubstitute(e,r){let n=this.advance();if(!n||n===`
171
- `)return{type:P.ERROR,value:"s",line:e,column:r};let s="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\")s+=this.advance(),this.pos<this.input.length&&this.peek()!==`
167
+ `?(this.advance(),{type:T.NEWLINE,value:`
168
+ `,line:e,column:r}):n===";"?(this.advance(),{type:T.SEMICOLON,value:";",line:e,column:r}):n==="{"?(this.advance(),{type:T.LBRACE,value:"{",line:e,column:r}):n==="}"?(this.advance(),{type:T.RBRACE,value:"}",line:e,column:r}):n===","?(this.advance(),{type:T.COMMA,value:",",line:e,column:r}):n==="$"?(this.advance(),{type:T.DOLLAR,value:"$",line:e,column:r}):this.isDigit(n)?this.readNumber():n==="/"?this.readPattern():n===":"?this.readLabelDef():this.readCommand()}readNumber(){let e=this.line,r=this.column,n="";for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="~"){this.advance();let s="";for(;this.isDigit(this.peek());)s+=this.advance();let i=parseInt(n,10),o=parseInt(s,10)||0;return{type:T.STEP,value:`${i}~${o}`,first:i,step:o,line:e,column:r}}return{type:T.NUMBER,value:parseInt(n,10),line:e,column:r}}readPattern(){let e=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")n+=this.advance(),this.pos<this.input.length&&(n+=this.advance());else{if(this.peek()===`
169
+ `)break;n+=this.advance()}return this.peek()==="/"&&this.advance(),{type:T.PATTERN,value:n,pattern:n,line:e,column:r}}readLabelDef(){let e=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length;){let s=this.peek();if(s===" "||s===" "||s===`
170
+ `||s===";"||s==="}"||s==="{")break;n+=this.advance()}return{type:T.LABEL_DEF,value:n,label:n,line:e,column:r}}readCommand(){let e=this.line,r=this.column,n=this.advance();switch(n){case"s":return this.readSubstitute(e,r);case"y":return this.readTransliterate(e,r);case"a":case"i":case"c":return this.readTextCommand(n,e,r);case"b":return this.readBranch(T.BRANCH,"b",e,r);case"t":return this.readBranch(T.BRANCH_ON_SUBST,"t",e,r);case"T":return this.readBranch(T.BRANCH_ON_NO_SUBST,"T",e,r);case"r":return this.readFileCommand(T.FILE_READ,"r",e,r);case"R":return this.readFileCommand(T.FILE_READ_LINE,"R",e,r);case"w":return this.readFileCommand(T.FILE_WRITE,"w",e,r);case"W":return this.readFileCommand(T.FILE_WRITE_LINE,"W",e,r);case"e":return this.readExecute(e,r);case"p":case"P":case"d":case"D":case"h":case"H":case"g":case"G":case"x":case"n":case"N":case"q":case"Q":case"z":case"=":case"l":case"F":case"v":return{type:T.COMMAND,value:n,line:e,column:r};default:return{type:T.ERROR,value:n,line:e,column:r}}}readSubstitute(e,r){let n=this.advance();if(!n||n===`
171
+ `)return{type:T.ERROR,value:"s",line:e,column:r};let s="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\")s+=this.advance(),this.pos<this.input.length&&this.peek()!==`
172
172
  `&&(s+=this.advance());else{if(this.peek()===`
173
- `)break;s+=this.advance()}if(this.peek()!==n)return{type:P.ERROR,value:"unterminated substitution pattern",line:e,column:r};this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\")i+=this.advance(),this.pos<this.input.length&&this.peek()!==`
173
+ `)break;s+=this.advance()}if(this.peek()!==n)return{type:T.ERROR,value:"unterminated substitution pattern",line:e,column:r};this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\")i+=this.advance(),this.pos<this.input.length&&this.peek()!==`
174
174
  `&&(i+=this.advance());else{if(this.peek()===`
175
- `)break;i+=this.advance()}this.peek()===n&&this.advance();let o="";for(;this.pos<this.input.length;){let a=this.peek();if(a==="g"||a==="i"||a==="p"||a==="I"||this.isDigit(a))o+=this.advance();else break}return{type:P.SUBSTITUTE,value:`s${n}${s}${n}${i}${n}${o}`,pattern:s,replacement:i,flags:o,line:e,column:r}}readTransliterate(e,r){let n=this.advance();if(!n||n===`
176
- `)return{type:P.ERROR,value:"y",line:e,column:r};let s="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\"){this.advance();let o=this.advance();o==="n"?s+=`
175
+ `)break;i+=this.advance()}this.peek()===n&&this.advance();let o="";for(;this.pos<this.input.length;){let a=this.peek();if(a==="g"||a==="i"||a==="p"||a==="I"||this.isDigit(a))o+=this.advance();else break}return{type:T.SUBSTITUTE,value:`s${n}${s}${n}${i}${n}${o}`,pattern:s,replacement:i,flags:o,line:e,column:r}}readTransliterate(e,r){let n=this.advance();if(!n||n===`
176
+ `)return{type:T.ERROR,value:"y",line:e,column:r};let s="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\"){this.advance();let o=this.advance();o==="n"?s+=`
177
177
  `:o==="t"?s+=" ":s+=o}else{if(this.peek()===`
178
- `)break;s+=this.advance()}if(this.peek()!==n)return{type:P.ERROR,value:"unterminated transliteration source",line:e,column:r};this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\"){this.advance();let o=this.advance();o==="n"?i+=`
178
+ `)break;s+=this.advance()}if(this.peek()!==n)return{type:T.ERROR,value:"unterminated transliteration source",line:e,column:r};this.advance();let i="";for(;this.pos<this.input.length&&this.peek()!==n;)if(this.peek()==="\\"){this.advance();let o=this.advance();o==="n"?i+=`
179
179
  `:o==="t"?i+=" ":i+=o}else{if(this.peek()===`
180
- `)break;i+=this.advance()}return this.peek()===n&&this.advance(),{type:P.TRANSLITERATE,value:`y${n}${s}${n}${i}${n}`,source:s,dest:i,line:e,column:r}}readTextCommand(e,r,n){this.peek()==="\\"&&this.advance(),this.peek()===" "&&this.advance();let s="";for(;this.pos<this.input.length&&this.peek()!==`
181
- `;)s+=this.advance();return{type:P.TEXT_CMD,value:e,text:s.trim(),line:r,column:n}}readBranch(e,r,n,s){for(;this.peek()===" "||this.peek()===" ";)this.advance();let i="";for(;this.pos<this.input.length;){let o=this.peek();if(o===" "||o===" "||o===`
180
+ `)break;i+=this.advance()}return this.peek()===n&&this.advance(),{type:T.TRANSLITERATE,value:`y${n}${s}${n}${i}${n}`,source:s,dest:i,line:e,column:r}}readTextCommand(e,r,n){this.peek()==="\\"&&this.advance(),this.peek()===" "&&this.advance();let s="";for(;this.pos<this.input.length&&this.peek()!==`
181
+ `;)s+=this.advance();return{type:T.TEXT_CMD,value:e,text:s.trim(),line:r,column:n}}readBranch(e,r,n,s){for(;this.peek()===" "||this.peek()===" ";)this.advance();let i="";for(;this.pos<this.input.length;){let o=this.peek();if(o===" "||o===" "||o===`
182
182
  `||o===";"||o==="}"||o==="{")break;i+=this.advance()}return{type:e,value:r,label:i||void 0,line:n,column:s}}readFileCommand(e,r,n,s){for(;this.peek()===" "||this.peek()===" ";)this.advance();let i="";for(;this.pos<this.input.length;){let o=this.peek();if(o===`
183
183
  `||o===";")break;i+=this.advance()}return{type:e,value:r,filename:i.trim(),line:n,column:s}}readExecute(e,r){for(;this.peek()===" "||this.peek()===" ";)this.advance();let n="";for(;this.pos<this.input.length;){let s=this.peek();if(s===`
184
- `||s===";")break;n+=this.advance()}return{type:P.EXECUTE,value:"e",command:n.trim()||void 0,line:e,column:r}}isDigit(e){return e>="0"&&e<="9"}}});function So(t,e=!1){return new Ln(t,e).parse()}var Ln,Co=C(()=>{"use strict";Eo();Ln=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(e,r=!1){this.scripts=e,this.extendedRegex=r}parse(){let e=[];for(let r of this.scripts){let n=new Nr(r);for(this.tokens=n.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(P.NEWLINE)||this.check(P.SEMICOLON)){this.advance();continue}let s=this.parseCommand();if(s.error)return{commands:[],error:s.error};s.command&&e.push(s.command)}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();for(;this.check(P.NEWLINE)||this.check(P.SEMICOLON);)this.advance();if(this.isAtEnd())return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null};let r=this.peek();switch(r.type){case P.COMMAND:return this.parseSimpleCommand(r,e);case P.SUBSTITUTE:return this.parseSubstituteFromToken(r,e);case P.TRANSLITERATE:return this.parseTransliterateFromToken(r,e);case P.LABEL_DEF:return this.advance(),{command:{type:"label",name:r.label||""}};case P.BRANCH:return this.advance(),{command:{type:"branch",address:e,label:r.label}};case P.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:e,label:r.label}};case P.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:e,label:r.label}};case P.TEXT_CMD:return this.advance(),this.parseTextCommand(r,e);case P.FILE_READ:return this.advance(),{command:{type:"readFile",address:e,filename:r.filename||""}};case P.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:e,filename:r.filename||""}};case P.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:e,filename:r.filename||""}};case P.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:e,filename:r.filename||""}};case P.EXECUTE:return this.advance(),{command:{type:"execute",address:e,command:r.command}};case P.LBRACE:return this.parseGroup(e);case P.RBRACE:return{command:null};case P.ERROR:return{command:null,error:`invalid command: ${r.value}`};default:return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null}}}parseSimpleCommand(e,r){this.advance();let n=e.value;switch(n){case"p":return{command:{type:"print",address:r}};case"P":return{command:{type:"printFirstLine",address:r}};case"d":return{command:{type:"delete",address:r}};case"D":return{command:{type:"deleteFirstLine",address:r}};case"h":return{command:{type:"hold",address:r}};case"H":return{command:{type:"holdAppend",address:r}};case"g":return{command:{type:"get",address:r}};case"G":return{command:{type:"getAppend",address:r}};case"x":return{command:{type:"exchange",address:r}};case"n":return{command:{type:"next",address:r}};case"N":return{command:{type:"nextAppend",address:r}};case"q":return{command:{type:"quit",address:r}};case"Q":return{command:{type:"quitSilent",address:r}};case"z":return{command:{type:"zap",address:r}};case"=":return{command:{type:"lineNumber",address:r}};case"l":return{command:{type:"list",address:r}};case"F":return{command:{type:"printFilename",address:r}};case"v":return{command:{type:"version",address:r}};default:return{command:null,error:`unknown command: ${n}`}}}parseSubstituteFromToken(e,r){this.advance();let n=e.flags||"",s,i=n.match(/(\d+)/);return i&&(s=parseInt(i[1],10)),{command:{type:"substitute",address:r,pattern:e.pattern||"",replacement:e.replacement||"",global:n.includes("g"),ignoreCase:n.includes("i")||n.includes("I"),printOnMatch:n.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,r){this.advance();let n=e.source||"",s=e.dest||"";return n.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:r,source:n,dest:s}}}parseTextCommand(e,r){let n=e.value,s=e.text||"";switch(n){case"a":return{command:{type:"append",address:r,text:s}};case"i":return{command:{type:"insert",address:r,text:s}};case"c":return{command:{type:"change",address:r,text:s}};default:return{command:null,error:`unknown text command: ${n}`}}}parseGroup(e){this.advance();let r=[];for(;!this.isAtEnd()&&!this.check(P.RBRACE);){if(this.check(P.NEWLINE)||this.check(P.SEMICOLON)){this.advance();continue}let n=this.parseCommand();if(n.error)return{command:null,error:n.error};n.command&&r.push(n.command)}return this.check(P.RBRACE)?(this.advance(),{command:{type:"group",address:e,commands:r}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){let e=this.parseAddress();if(e===void 0)return;let r;return this.check(P.COMMA)&&(this.advance(),r=this.parseAddress()),{start:e,end:r}}parseAddress(){let e=this.peek();switch(e.type){case P.NUMBER:return this.advance(),e.value;case P.DOLLAR:return this.advance(),"$";case P.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case P.STEP:return this.advance(),{first:e.first||0,step:e.step||0};default:return}}peek(){return this.tokens[this.pos]||{type:P.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===P.EOF}}});var Ao={};v(Ao,{sedCommand:()=>sp});async function Dn(t,e,r,n={}){let{limits:s,filename:i,fs:o,cwd:a}=n,l=t.split(`
185
- `);l.length>0&&l[l.length-1]===""&&l.pop();let c=l.length,u="",f,d="",p=new Map,h=new Map,y=new Map,m=new Map,w=s?{maxIterations:s.maxSedIterations}:void 0;for(let b=0;b<l.length;b++){let E={...wo(c,i,p),patternSpace:l[b],holdSpace:d,lineNumber:b+1,totalLines:c,substitutionMade:!1},S={lines:l,currentLineIndex:b},A=0,F=1e4,M=0;do{if(A++,A>F)break;E.restartCycle=!1,E.pendingFileReads=[],E.pendingFileWrites=[];let te=Tn(e,E,S,w);if(M+=te,o&&a){for(let de of E.pendingFileReads){let se=o.resolvePath(a,de.filename);try{if(de.wholeFile){let Ce=await o.readFile(se);E.appendBuffer.push(Ce.replace(/\n$/,""))}else{if(!h.has(se)){let De=await o.readFile(se);h.set(se,De.split(`
186
- `)),y.set(se,0)}let Ce=h.get(se),je=y.get(se);Ce&&je!==void 0&&je<Ce.length&&(E.appendBuffer.push(Ce[je]),y.set(se,je+1))}}catch{}}for(let de of E.pendingFileWrites){let se=o.resolvePath(a,de.filename),Ce=m.get(se)||"";m.set(se,Ce+de.content)}}S.currentLineIndex+=te}while(E.restartCycle&&!E.deleted&&!E.quit&&!E.quitSilent);b+=M,d=E.holdSpace;for(let te of E.lineNumberOutput)u+=`${te}
187
- `;let D=[],U=[];for(let te of E.appendBuffer)te.startsWith("__INSERT__")?D.push(te.slice(10)):U.push(te);for(let te of D)u+=`${te}
184
+ `||s===";")break;n+=this.advance()}return{type:T.EXECUTE,value:"e",command:n.trim()||void 0,line:e,column:r}}isDigit(e){return e>="0"&&e<="9"}}});function Ro(t,e=!1){return new zn(t,e).parse()}var zn,Po=C(()=>{"use strict";$o();zn=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(e,r=!1){this.scripts=e,this.extendedRegex=r}parse(){let e=[];for(let r of this.scripts){let n=new Lr(r);for(this.tokens=n.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(T.NEWLINE)||this.check(T.SEMICOLON)){this.advance();continue}let s=this.parseCommand();if(s.error)return{commands:[],error:s.error};s.command&&e.push(s.command)}}return{commands:e}}parseCommand(){let e=this.parseAddressRange();for(;this.check(T.NEWLINE)||this.check(T.SEMICOLON);)this.advance();if(this.isAtEnd())return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null};let r=this.peek();switch(r.type){case T.COMMAND:return this.parseSimpleCommand(r,e);case T.SUBSTITUTE:return this.parseSubstituteFromToken(r,e);case T.TRANSLITERATE:return this.parseTransliterateFromToken(r,e);case T.LABEL_DEF:return this.advance(),{command:{type:"label",name:r.label||""}};case T.BRANCH:return this.advance(),{command:{type:"branch",address:e,label:r.label}};case T.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:e,label:r.label}};case T.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:e,label:r.label}};case T.TEXT_CMD:return this.advance(),this.parseTextCommand(r,e);case T.FILE_READ:return this.advance(),{command:{type:"readFile",address:e,filename:r.filename||""}};case T.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:e,filename:r.filename||""}};case T.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:e,filename:r.filename||""}};case T.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:e,filename:r.filename||""}};case T.EXECUTE:return this.advance(),{command:{type:"execute",address:e,command:r.command}};case T.LBRACE:return this.parseGroup(e);case T.RBRACE:return{command:null};case T.ERROR:return{command:null,error:`invalid command: ${r.value}`};default:return e&&(e.start!==void 0||e.end!==void 0)?{command:{type:"print",address:e}}:{command:null}}}parseSimpleCommand(e,r){this.advance();let n=e.value;switch(n){case"p":return{command:{type:"print",address:r}};case"P":return{command:{type:"printFirstLine",address:r}};case"d":return{command:{type:"delete",address:r}};case"D":return{command:{type:"deleteFirstLine",address:r}};case"h":return{command:{type:"hold",address:r}};case"H":return{command:{type:"holdAppend",address:r}};case"g":return{command:{type:"get",address:r}};case"G":return{command:{type:"getAppend",address:r}};case"x":return{command:{type:"exchange",address:r}};case"n":return{command:{type:"next",address:r}};case"N":return{command:{type:"nextAppend",address:r}};case"q":return{command:{type:"quit",address:r}};case"Q":return{command:{type:"quitSilent",address:r}};case"z":return{command:{type:"zap",address:r}};case"=":return{command:{type:"lineNumber",address:r}};case"l":return{command:{type:"list",address:r}};case"F":return{command:{type:"printFilename",address:r}};case"v":return{command:{type:"version",address:r}};default:return{command:null,error:`unknown command: ${n}`}}}parseSubstituteFromToken(e,r){this.advance();let n=e.flags||"",s,i=n.match(/(\d+)/);return i&&(s=parseInt(i[1],10)),{command:{type:"substitute",address:r,pattern:e.pattern||"",replacement:e.replacement||"",global:n.includes("g"),ignoreCase:n.includes("i")||n.includes("I"),printOnMatch:n.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(e,r){this.advance();let n=e.source||"",s=e.dest||"";return n.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:r,source:n,dest:s}}}parseTextCommand(e,r){let n=e.value,s=e.text||"";switch(n){case"a":return{command:{type:"append",address:r,text:s}};case"i":return{command:{type:"insert",address:r,text:s}};case"c":return{command:{type:"change",address:r,text:s}};default:return{command:null,error:`unknown text command: ${n}`}}}parseGroup(e){this.advance();let r=[];for(;!this.isAtEnd()&&!this.check(T.RBRACE);){if(this.check(T.NEWLINE)||this.check(T.SEMICOLON)){this.advance();continue}let n=this.parseCommand();if(n.error)return{command:null,error:n.error};n.command&&r.push(n.command)}return this.check(T.RBRACE)?(this.advance(),{command:{type:"group",address:e,commands:r}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){let e=this.parseAddress();if(e===void 0)return;let r;return this.check(T.COMMA)&&(this.advance(),r=this.parseAddress()),{start:e,end:r}}parseAddress(){let e=this.peek();switch(e.type){case T.NUMBER:return this.advance(),e.value;case T.DOLLAR:return this.advance(),"$";case T.PATTERN:return this.advance(),{pattern:e.pattern||e.value};case T.STEP:return this.advance(),{first:e.first||0,step:e.step||0};default:return}}peek(){return this.tokens[this.pos]||{type:T.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(e){return this.peek().type===e}isAtEnd(){return this.peek().type===T.EOF}}});var Fo={};R(Fo,{sedCommand:()=>pd});async function Hn(t,e,r,n={}){let{limits:s,filename:i,fs:o,cwd:a}=n,l=t.split(`
185
+ `);l.length>0&&l[l.length-1]===""&&l.pop();let c=l.length,u="",f,p="",d=new Map,h=new Map,m=new Map,g=new Map,w=s?{maxIterations:s.maxSedIterations}:void 0;for(let b=0;b<l.length;b++){let E={...Io(c,i,d),patternSpace:l[b],holdSpace:p,lineNumber:b+1,totalLines:c,substitutionMade:!1},S={lines:l,currentLineIndex:b},v=0,D=1e4,I=0;do{if(v++,v>D)break;E.restartCycle=!1,E.pendingFileReads=[],E.pendingFileWrites=[];let K=jn(e,E,S,w);if(I+=K,o&&a){for(let Y of E.pendingFileReads){let re=o.resolvePath(a,Y.filename);try{if(Y.wholeFile){let H=await o.readFile(re);E.appendBuffer.push(H.replace(/\n$/,""))}else{if(!h.has(re)){let X=await o.readFile(re);h.set(re,X.split(`
186
+ `)),m.set(re,0)}let H=h.get(re),ce=m.get(re);H&&ce!==void 0&&ce<H.length&&(E.appendBuffer.push(H[ce]),m.set(re,ce+1))}}catch{}}for(let Y of E.pendingFileWrites){let re=o.resolvePath(a,Y.filename),H=g.get(re)||"";g.set(re,H+Y.content)}}S.currentLineIndex+=K}while(E.restartCycle&&!E.deleted&&!E.quit&&!E.quitSilent);b+=I,p=E.holdSpace;for(let K of E.lineNumberOutput)u+=`${K}
187
+ `;let $=[],V=[];for(let K of E.appendBuffer)K.startsWith("__INSERT__")?$.push(K.slice(10)):V.push(K);for(let K of $)u+=`${K}
188
188
  `;!E.deleted&&!E.quitSilent&&(r?E.printed&&(u+=`${E.patternSpace}
189
189
  `):u+=`${E.patternSpace}
190
- `);for(let te of U)u+=`${te}
191
- `;if(E.quit||E.quitSilent){E.exitCode!==void 0&&(f=E.exitCode);break}}if(o&&a)for(let[b,E]of m)try{await o.writeFile(b,E)}catch{}return{output:u,exitCode:f}}var np,sp,ko=C(()=>{"use strict";X();O();bo();Co();np={name:"sed",summary:"stream editor for filtering and transforming text",usage:"sed [OPTION]... {script} [input-file]...",options:["-n, --quiet, --silent suppress automatic printing of pattern space","-e script add the script to commands to be executed","-f script-file read script from file","-i, --in-place edit files in place","-E, -r, --regexp-extended use extended regular expressions"," --help display this help and exit"],description:`Commands:
190
+ `);for(let K of V)u+=`${K}
191
+ `;if(E.quit||E.quitSilent){E.exitCode!==void 0&&(f=E.exitCode);break}}if(o&&a)for(let[b,E]of g)try{await o.writeFile(b,E)}catch{}return{output:u,exitCode:f}}var fd,pd,Oo=C(()=>{"use strict";oe();L();vo();Po();fd={name:"sed",summary:"stream editor for filtering and transforming text",usage:"sed [OPTION]... {script} [input-file]...",options:["-n, --quiet, --silent suppress automatic printing of pattern space","-e script add the script to commands to be executed","-f script-file read script from file","-i, --in-place edit files in place","-E, -r, --regexp-extended use extended regular expressions"," --help display this help and exit"],description:`Commands:
192
192
  s/regexp/replacement/[flags] substitute
193
193
  d delete pattern space
194
194
  p print pattern space
@@ -217,36 +217,36 @@ Addresses:
217
217
  $ last line
218
218
  /regexp/ lines matching regexp
219
219
  N,M range from line N to M
220
- first~step every step-th line starting at first`};sp={name:"sed",async execute(t,e){if(I(t))return N(np);let r=[],n=[],s=!1,i=!1,o=!1,a=[];for(let f=0;f<t.length;f++){let d=t[f];if(d==="-n"||d==="--quiet"||d==="--silent")s=!0;else if(d==="-i"||d==="--in-place")i=!0;else if(d.startsWith("-i"))i=!0;else if(d==="-E"||d==="-r"||d==="--regexp-extended")o=!0;else if(d==="-e")f+1<t.length&&r.push(t[++f]);else if(d==="-f")f+1<t.length&&n.push(t[++f]);else{if(d.startsWith("--"))return $("sed",d);if(d.startsWith("-")&&d.length>1){for(let p of d.slice(1))if(p!=="n"&&p!=="e"&&p!=="f"&&p!=="i"&&p!=="E"&&p!=="r")return $("sed",`-${p}`);d.includes("n")&&(s=!0),d.includes("i")&&(i=!0),(d.includes("E")||d.includes("r"))&&(o=!0),d.includes("e")&&!d.includes("n")&&!d.includes("i")&&f+1<t.length&&r.push(t[++f]),d.includes("f")&&!d.includes("e")&&f+1<t.length&&n.push(t[++f])}else!d.startsWith("-")&&r.length===0&&n.length===0?r.push(d):d.startsWith("-")||a.push(d)}}for(let f of n){let d=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readFile(d);for(let h of p.split(`
221
- `)){let y=h.trim();y&&!y.startsWith("#")&&r.push(y)}}catch{return{stdout:"",stderr:`sed: couldn't open file ${f}: No such file or directory
220
+ first~step every step-th line starting at first`};pd={name:"sed",async execute(t,e){if(N(t))return k(fd);let r=[],n=[],s=!1,i=!1,o=!1,a=[];for(let f=0;f<t.length;f++){let p=t[f];if(p==="-n"||p==="--quiet"||p==="--silent")s=!0;else if(p==="-i"||p==="--in-place")i=!0;else if(p.startsWith("-i"))i=!0;else if(p==="-E"||p==="-r"||p==="--regexp-extended")o=!0;else if(p==="-e")f+1<t.length&&r.push(t[++f]);else if(p==="-f")f+1<t.length&&n.push(t[++f]);else{if(p.startsWith("--"))return P("sed",p);if(p.startsWith("-")&&p.length>1){for(let d of p.slice(1))if(d!=="n"&&d!=="e"&&d!=="f"&&d!=="i"&&d!=="E"&&d!=="r")return P("sed",`-${d}`);p.includes("n")&&(s=!0),p.includes("i")&&(i=!0),(p.includes("E")||p.includes("r"))&&(o=!0),p.includes("e")&&!p.includes("n")&&!p.includes("i")&&f+1<t.length&&r.push(t[++f]),p.includes("f")&&!p.includes("e")&&f+1<t.length&&n.push(t[++f])}else!p.startsWith("-")&&r.length===0&&n.length===0?r.push(p):p.startsWith("-")||a.push(p)}}for(let f of n){let p=e.fs.resolvePath(e.cwd,f);try{let d=await e.fs.readFile(p);for(let h of d.split(`
221
+ `)){let m=h.trim();m&&!m.startsWith("#")&&r.push(m)}}catch{return{stdout:"",stderr:`sed: couldn't open file ${f}: No such file or directory
222
222
  `,exitCode:1}}}if(r.length===0)return{stdout:"",stderr:`sed: no script specified
223
- `,exitCode:1};let{commands:l,error:c}=So(r,o);if(c)return{stdout:"",stderr:`sed: ${c}
223
+ `,exitCode:1};let{commands:l,error:c}=Ro(r,o);if(c)return{stdout:"",stderr:`sed: ${c}
224
224
  `,exitCode:1};if(l.length===0)return{stdout:"",stderr:`sed: no valid commands
225
- `,exitCode:1};let u="";if(a.length===0){u=e.stdin;try{let f=await Dn(u,l,s,{limits:e.limits,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof W)return{stdout:"",stderr:`sed: ${f.message}
226
- `,exitCode:W.EXIT_CODE};throw f}}if(i){for(let f of a){let d=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readFile(d),h=await Dn(p,l,s,{limits:e.limits,filename:f,fs:e.fs,cwd:e.cwd});await e.fs.writeFile(d,h.output)}catch(p){return p instanceof W?{stdout:"",stderr:`sed: ${p.message}
227
- `,exitCode:W.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
228
- `,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}for(let f of a){let d=e.fs.resolvePath(e.cwd,f);try{u+=await e.fs.readFile(d)}catch(p){return p instanceof W?{stdout:"",stderr:`sed: ${p.message}
229
- `,exitCode:W.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
230
- `,exitCode:1}}}try{let f=await Dn(u,l,s,{limits:e.limits,filename:a.length===1?a[0]:void 0,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof W)return{stdout:"",stderr:`sed: ${f.message}
231
- `,exitCode:W.EXIT_CODE};throw f}}}});function Mn(t={}){let{fieldSep:e=/\s+/,maxIterations:r=1e4,maxRecursionDepth:n=100,fs:s,cwd:i}=t;return{FS:" ",OFS:" ",ORS:`
232
- `,NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:{},arrays:{},ARGC:0,ARGV:{},functions:new Map,fieldSep:e,maxIterations:r,maxRecursionDepth:n,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,output:"",openedFiles:new Set,fs:s,cwd:i}}var No=C(()=>{"use strict"});function Io(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?t/e:0;case"%":return e!==0?t%e:0;case"^":case"**":return t**e;default:return 0}}var vo=C(()=>{"use strict"});function ke(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function ie(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}async function ip(t,e,r){return t.length===0?e.line.length:ie(await r.evalExpr(t[0])).length}async function op(t,e,r){if(t.length<2)return"";let n=ie(await r.evalExpr(t[0])),s=Math.floor(ke(await r.evalExpr(t[1])))-1;if(t.length>=3){let i=Math.floor(ke(await r.evalExpr(t[2])));return n.substr(Math.max(0,s),i)}return n.substr(Math.max(0,s))}async function ap(t,e,r){if(t.length<2)return 0;let n=ie(await r.evalExpr(t[0])),s=ie(await r.evalExpr(t[1])),i=n.indexOf(s);return i===-1?0:i+1}async function lp(t,e,r){if(t.length<2)return 0;let n=ie(await r.evalExpr(t[0])),s=t[1];if(s.type!=="variable")return 0;let i=s.name,o=e.FS;if(t.length>=3){let l=ie(await r.evalExpr(t[2]));o=l===" "?/\s+/:l}else e.FS===" "&&(o=/\s+/);let a=n.split(o);e.arrays[i]={};for(let l=0;l<a.length;l++)e.arrays[i][String(l+1)]=a[l];return a.length}async function cp(t,e,r){if(t.length<2)return 0;let n;t[0].type==="regex"?n=t[0].pattern:(n=ie(await r.evalExpr(t[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let s=ie(await r.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(ke(await r.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=ie(e.vars[i]??"");try{let a=new RegExp(n),l=o.replace(a,Ro(s)),c=l!==o?1:0;if(i==="$0")e.line=l,e.fields=e.FS===" "?l.trim().split(/\s+/).filter(Boolean):l.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let u=parseInt(i.slice(1),10)-1;for(;e.fields.length<=u;)e.fields.push("");e.fields[u]=l,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=l;return c}catch{return 0}}async function up(t,e,r){if(t.length<2)return 0;let n;t[0].type==="regex"?n=t[0].pattern:(n=ie(await r.evalExpr(t[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let s=ie(await r.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(ke(await r.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=ie(e.vars[i]??"");try{let a=new RegExp(n,"g"),l=o.match(a),c=l?l.length:0,u=o.replace(a,Ro(s));if(i==="$0")e.line=u,e.fields=e.FS===" "?u.trim().split(/\s+/).filter(Boolean):u.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let f=parseInt(i.slice(1),10)-1;for(;e.fields.length<=f;)e.fields.push("");e.fields[f]=u,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=u;return c}catch{return 0}}function Ro(t){return e=>{let r="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length){let s=t[n+1];s==="&"?(r+="&",n+=2):s==="\\"?(r+="\\",n+=2):(r+=t[n+1],n+=2)}else t[n]==="&"?(r+=e,n++):(r+=t[n],n++);return r}}async function fp(t,e,r){if(t.length<2)return e.RSTART=0,e.RLENGTH=-1,0;let n=ie(await r.evalExpr(t[0])),s;t[1].type==="regex"?s=t[1].pattern:(s=ie(await r.evalExpr(t[1])),s.startsWith("/")&&s.endsWith("/")&&(s=s.slice(1,-1)));try{let o=new RegExp(s).exec(n);if(o)return e.RSTART=o.index+1,e.RLENGTH=o[0].length,e.RSTART}catch{}return e.RSTART=0,e.RLENGTH=-1,0}async function dp(t,e,r){if(t.length<3)return"";let n;t[0].type==="regex"?n=t[0].pattern:(n=ie(await r.evalExpr(t[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let s=ie(await r.evalExpr(t[1])),i=ie(await r.evalExpr(t[2])),o=t.length>=4?ie(await r.evalExpr(t[3])):e.line;try{let a=i.toLowerCase()==="g",l=a?0:parseInt(i,10)||1;if(a){let c=new RegExp(n,"g");return o.replace(c,(u,...f)=>$o(s,u,f.slice(0,-2)))}else{let c=0,u=new RegExp(n,"g");return o.replace(u,(f,...d)=>(c++,c===l?$o(s,f,d.slice(0,-2)):f))}}catch{return o}}function $o(t,e,r){let n="",s=0;for(;s<t.length;)if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&")n+="&",s+=2;else if(i==="0")n+=e,s+=2;else if(i>="1"&&i<="9"){let o=parseInt(i,10)-1;n+=r[o]||"",s+=2}else i==="n"?(n+=`
233
- `,s+=2):i==="t"?(n+=" ",s+=2):(n+=i,s+=2)}else t[s]==="&"?(n+=e,s++):(n+=t[s],s++);return n}async function pp(t,e,r){return t.length===0?"":ie(await r.evalExpr(t[0])).toLowerCase()}async function hp(t,e,r){return t.length===0?"":ie(await r.evalExpr(t[0])).toUpperCase()}async function mp(t,e,r){if(t.length===0)return"";let n=ie(await r.evalExpr(t[0])),s=[];for(let i=1;i<t.length;i++)s.push(await r.evalExpr(t[i]));return Wn(n,s)}async function gp(t,e,r){return t.length===0?0:Math.floor(ke(await r.evalExpr(t[0])))}async function yp(t,e,r){return t.length===0?0:Math.sqrt(ke(await r.evalExpr(t[0])))}async function xp(t,e,r){return t.length===0?0:Math.sin(ke(await r.evalExpr(t[0])))}async function wp(t,e,r){return t.length===0?0:Math.cos(ke(await r.evalExpr(t[0])))}async function bp(t,e,r){let n=t.length>0?ke(await r.evalExpr(t[0])):0,s=t.length>1?ke(await r.evalExpr(t[1])):0;return Math.atan2(n,s)}async function Ep(t,e,r){return t.length===0?0:Math.log(ke(await r.evalExpr(t[0])))}async function Sp(t,e,r){return t.length===0?1:Math.exp(ke(await r.evalExpr(t[0])))}function Cp(t,e,r){return e.random?e.random():Math.random()}async function Ap(t,e,r){let n=t.length>0?ke(await r.evalExpr(t[0])):Date.now();return e.vars._srand_seed=n,n}function _n(t,e){return()=>{throw new Error(`${t}() is not supported - ${e}`)}}function Bn(t){return()=>{throw new Error(`function '${t}()' is not implemented`)}}function Wn(t,e){let r=0,n="",s=0;for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let i=s+1,o="",a="",l="";for(;i<t.length&&/[-+ #0]/.test(t[i]);)o+=t[i++];for(;i<t.length&&/\d/.test(t[i]);)a+=t[i++];if(t[i]===".")for(i++;i<t.length&&/\d/.test(t[i]);)l+=t[i++];let c=t[i],u=e[r];switch(c){case"s":{let f=u!==void 0?String(u):"";if(l&&(f=f.substring(0,parseInt(l,10))),a){let d=parseInt(a,10);o.includes("-")?f=f.padEnd(d):f=f.padStart(d)}n+=f,r++;break}case"d":case"i":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=String(f);if(a){let p=parseInt(a,10);if(o.includes("-"))d=d.padEnd(p);else if(o.includes("0")&&!o.includes("-")){let h=f<0?"-":"";d=h+Math.abs(f).toString().padStart(p-h.length,"0")}else d=d.padStart(p)}n+=d,r++;break}case"f":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f.toFixed(d);if(a){let h=parseInt(a,10);o.includes("-")?p=p.padEnd(h):p=p.padStart(h)}n+=p,r++;break}case"e":case"E":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f.toExponential(d);if(c==="E"&&(p=p.toUpperCase()),a){let h=parseInt(a,10);o.includes("-")?p=p.padEnd(h):p=p.padStart(h)}n+=p,r++;break}case"g":case"G":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let d=l?parseInt(l,10):6,p=f!==0?Math.floor(Math.log10(Math.abs(f))):0,h;if(f===0?h="0":p<-4||p>=d?(h=f.toExponential(d-1),c==="G"&&(h=h.toUpperCase())):h=f.toPrecision(d),h=h.replace(/\.?0+$/,"").replace(/\.?0+e/,"e"),a){let y=parseInt(a,10);o.includes("-")?h=h.padEnd(y):h=h.padStart(y)}n+=h,r++;break}case"x":case"X":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=Math.abs(f).toString(16);if(c==="X"&&(d=d.toUpperCase()),a){let p=parseInt(a,10);o.includes("0")?d=d.padStart(p,"0"):o.includes("-")?d=d.padEnd(p):d=d.padStart(p)}n+=f<0?`-${d}`:d,r++;break}case"o":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let d=Math.abs(f).toString(8);if(a){let p=parseInt(a,10);o.includes("0")?d=d.padStart(p,"0"):o.includes("-")?d=d.padEnd(p):d=d.padStart(p)}n+=f<0?`-${d}`:d,r++;break}case"c":{typeof u=="number"?n+=String.fromCharCode(u):n+=String(u??"").charAt(0)||"",r++;break}case"%":n+="%";break;default:n+=t.substring(s,i+1)}s=i+1}else if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];switch(i){case"n":n+=`
234
- `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;default:n+=i}s+=2}else n+=t[s++];return n}var Po,Un=C(()=>{"use strict";Po={length:ip,substr:op,index:ap,split:lp,sub:cp,gsub:up,match:fp,gensub:dp,tolower:pp,toupper:hp,sprintf:mp,int:gp,sqrt:yp,sin:xp,cos:wp,atan2:bp,log:Ep,exp:Sp,rand:Cp,srand:Ap,system:_n("system","shell execution not allowed in sandboxed environment"),close:_n("close","file operations not allowed"),fflush:_n("fflush","file operations not allowed"),systime:Bn("systime"),mktime:Bn("mktime"),strftime:Bn("strftime")}});function xe(t){return typeof t=="number"?t!==0:t!==""}function G(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function q(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}function jn(t){if(typeof t=="number")return!0;let e=String(t).trim();return e===""?!1:!Number.isNaN(Number(e))}function Qt(t,e){try{return new RegExp(t).test(e)}catch{return!1}}var Nt=C(()=>{"use strict"});function Oo(t,e){return t.FS===" "?e.trim().split(/\s+/).filter(Boolean):e.split(t.fieldSep)}function at(t,e){return e===0?t.line:e<0||e>t.fields.length?"":t.fields[e-1]??""}function It(t,e,r){if(e===0)t.line=q(r),t.fields=Oo(t,t.line),t.NF=t.fields.length;else if(e>0){for(;t.fields.length<e;)t.fields.push("");t.fields[e-1]=q(r),t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}}function Xt(t,e){t.line=e,t.fields=Oo(t,e),t.NF=t.fields.length}function Fo(t,e){if(t.FS=e,e===" ")t.fieldSep=/\s+/;else try{t.fieldSep=new RegExp(e)}catch{t.fieldSep=new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var Ir=C(()=>{"use strict";Nt()});function lt(t,e){switch(e){case"FS":return t.FS;case"OFS":return t.OFS;case"ORS":return t.ORS;case"NR":return t.NR;case"NF":return t.NF;case"FNR":return t.FNR;case"FILENAME":return t.FILENAME;case"RSTART":return t.RSTART;case"RLENGTH":return t.RLENGTH;case"SUBSEP":return t.SUBSEP;case"ARGC":return t.ARGC}return t.vars[e]??""}function Ye(t,e,r){switch(e){case"FS":Fo(t,q(r));return;case"OFS":t.OFS=q(r);return;case"ORS":t.ORS=q(r);return;case"NR":t.NR=Math.floor(G(r));return;case"NF":{let n=Math.floor(G(r));if(n<t.NF)t.fields=t.fields.slice(0,n),t.line=t.fields.join(t.OFS);else if(n>t.NF){for(;t.fields.length<n;)t.fields.push("");t.line=t.fields.join(t.OFS)}t.NF=n;return}case"FNR":t.FNR=Math.floor(G(r));return;case"FILENAME":t.FILENAME=q(r);return;case"RSTART":t.RSTART=Math.floor(G(r));return;case"RLENGTH":t.RLENGTH=Math.floor(G(r));return;case"SUBSEP":t.SUBSEP=q(r);return}t.vars[e]=r}function ct(t,e,r){return e==="ARGV"?t.ARGV[r]??"":t.arrays[e]?.[r]??""}function vt(t,e,r,n){t.arrays[e]||(t.arrays[e]={}),t.arrays[e][r]=n}function To(t,e,r){return e==="ARGV"?t.ARGV[r]!==void 0:t.arrays[e]?.[r]!==void 0}function Lo(t,e,r){t.arrays[e]&&delete t.arrays[e][r]}function Do(t,e){delete t.arrays[e]}var zn=C(()=>{"use strict";Ir();Nt()});function Mo(t){Hn=t}async function L(t,e){switch(e.type){case"number":return e.value;case"string":return e.value;case"regex":return Qt(e.pattern,t.line)?1:0;case"field":return kp(t,e);case"variable":return lt(t,e.name);case"array_access":return Np(t,e);case"binary":return Ip(t,e);case"unary":return Rp(t,e);case"ternary":return xe(await L(t,e.condition))?L(t,e.consequent):L(t,e.alternate);case"call":return Pp(t,e.name,e.args);case"assignment":return Fp(t,e);case"pre_increment":return Tp(t,e.operand);case"pre_decrement":return Lp(t,e.operand);case"post_increment":return Dp(t,e.operand);case"post_decrement":return Mp(t,e.operand);case"in":return _p(t,e.key,e.array);case"getline":return Bp(t,e.variable,e.file);case"tuple":return Up(t,e.elements);default:return""}}async function kp(t,e){let r=Math.floor(G(await L(t,e.index)));return at(t,r)}async function Np(t,e){let r=q(await L(t,e.key));return ct(t,e.array,r)}async function Ip(t,e){let r=e.operator;if(r==="||")return xe(await L(t,e.left))||xe(await L(t,e.right))?1:0;if(r==="&&")return xe(await L(t,e.left))&&xe(await L(t,e.right))?1:0;if(r==="~"){let a=await L(t,e.left),l=e.right.type==="regex"?e.right.pattern:q(await L(t,e.right));try{return new RegExp(l).test(q(a))?1:0}catch{return 0}}if(r==="!~"){let a=await L(t,e.left),l=e.right.type==="regex"?e.right.pattern:q(await L(t,e.right));try{return new RegExp(l).test(q(a))?0:1}catch{return 1}}let n=await L(t,e.left),s=await L(t,e.right);if(r===" ")return q(n)+q(s);if(vp(r))return $p(n,s,r);let i=G(n),o=G(s);return Io(i,o,r)}function vp(t){return["<","<=",">",">=","==","!="].includes(t)}function $p(t,e,r){let n=jn(t),s=jn(e);if(n&&s){let a=G(t),l=G(e);switch(r){case"<":return a<l?1:0;case"<=":return a<=l?1:0;case">":return a>l?1:0;case">=":return a>=l?1:0;case"==":return a===l?1:0;case"!=":return a!==l?1:0}}let i=q(t),o=q(e);switch(r){case"<":return i<o?1:0;case"<=":return i<=o?1:0;case">":return i>o?1:0;case">=":return i>=o?1:0;case"==":return i===o?1:0;case"!=":return i!==o?1:0}return 0}async function Rp(t,e){let r=await L(t,e.operand);switch(e.operator){case"!":return xe(r)?0:1;case"-":return-G(r);case"+":return+G(r);default:return r}}async function Pp(t,e,r){let n=Po[e];if(n)return n(r,t,{evalExpr:i=>L(t,i)});let s=t.functions.get(e);return s?Op(t,s,r):""}async function Op(t,e,r){if(t.currentRecursionDepth++,t.currentRecursionDepth>t.maxRecursionDepth)throw t.currentRecursionDepth--,new W(`awk: recursion depth exceeded maximum (${t.maxRecursionDepth})`,"recursion",t.output);let n={};for(let i of e.params)n[i]=t.vars[i];for(let i=0;i<e.params.length;i++){let o=e.params[i],a=i<r.length?await L(t,r[i]):"";t.vars[o]=a}t.hasReturn=!1,t.returnValue=void 0,Hn&&await Hn(t,e.body.statements);let s=t.returnValue??"";for(let i of e.params)n[i]!==void 0?t.vars[i]=n[i]:delete t.vars[i];return t.hasReturn=!1,t.returnValue=void 0,t.currentRecursionDepth--,s}async function Fp(t,e){let r=await L(t,e.value),n=e.target,s=e.operator,i;if(s==="=")i=r;else{let o;if(n.type==="field"){let c=Math.floor(G(await L(t,n.index)));o=at(t,c)}else if(n.type==="variable")o=lt(t,n.name);else{let c=q(await L(t,n.key));o=ct(t,n.array,c)}let a=G(o),l=G(r);switch(s){case"+=":i=a+l;break;case"-=":i=a-l;break;case"*=":i=a*l;break;case"/=":i=l!==0?a/l:0;break;case"%=":i=l!==0?a%l:0;break;case"^=":i=a**l;break;default:i=r}}if(n.type==="field"){let o=Math.floor(G(await L(t,n.index)));It(t,o,i)}else if(n.type==="variable")Ye(t,n.name,i);else{let o=q(await L(t,n.key));vt(t,n.array,o,i)}return i}async function Tp(t,e){let r;if(e.type==="field"){let n=Math.floor(G(await L(t,e.index)));r=G(at(t,n))+1,It(t,n,r)}else if(e.type==="variable")r=G(lt(t,e.name))+1,Ye(t,e.name,r);else{let n=q(await L(t,e.key));r=G(ct(t,e.array,n))+1,vt(t,e.array,n,r)}return r}async function Lp(t,e){let r;if(e.type==="field"){let n=Math.floor(G(await L(t,e.index)));r=G(at(t,n))-1,It(t,n,r)}else if(e.type==="variable")r=G(lt(t,e.name))-1,Ye(t,e.name,r);else{let n=q(await L(t,e.key));r=G(ct(t,e.array,n))-1,vt(t,e.array,n,r)}return r}async function Dp(t,e){let r;if(e.type==="field"){let n=Math.floor(G(await L(t,e.index)));r=G(at(t,n)),It(t,n,r+1)}else if(e.type==="variable")r=G(lt(t,e.name)),Ye(t,e.name,r+1);else{let n=q(await L(t,e.key));r=G(ct(t,e.array,n)),vt(t,e.array,n,r+1)}return r}async function Mp(t,e){let r;if(e.type==="field"){let n=Math.floor(G(await L(t,e.index)));r=G(at(t,n)),It(t,n,r-1)}else if(e.type==="variable")r=G(lt(t,e.name)),Ye(t,e.name,r-1);else{let n=q(await L(t,e.key));r=G(ct(t,e.array,n)),vt(t,e.array,n,r-1)}return r}async function _p(t,e,r){let n;if(e.type==="tuple"){let s=[];for(let i of e.elements)s.push(q(await L(t,i)));n=s.join(t.SUBSEP)}else n=q(await L(t,e));return To(t,r,n)?1:0}async function Bp(t,e,r){if(r)return Wp(t,e,r);if(!t.lines||t.lineIndex===void 0)return-1;let n=t.lineIndex+1;if(n>=t.lines.length)return 0;let s=t.lines[n];return e?Ye(t,e,s):Xt(t,s),t.NR++,t.lineIndex=n,1}async function Wp(t,e,r){if(!t.fs||!t.cwd)return-1;let n=q(await L(t,r)),s=t.fs.resolvePath(t.cwd,n),i=`__fc_${s}`,o=`__fi_${s}`,a,l;if(t.vars[i]===void 0)try{a=(await t.fs.readFile(s)).split(`
235
- `),a.length>0&&a[a.length-1]===""&&a.pop(),t.vars[i]=JSON.stringify(a),t.vars[o]=-1,l=-1}catch{return-1}else a=JSON.parse(t.vars[i]),l=t.vars[o];let c=l+1;if(c>=a.length)return 0;let u=a[c];return t.vars[o]=c,e?Ye(t,e,u):Xt(t,u),1}async function Up(t,e){if(e.length===0)return"";for(let r=0;r<e.length-1;r++)await L(t,e[r]);return L(t,e[e.length-1])}var Hn,Gn=C(()=>{"use strict";X();vo();Un();Ir();Nt();zn();Hn=null});async function $t(t,e){for(let r of e)if(await ut(t,r),jp(t))break}function jp(t){return t.shouldExit||t.shouldNext||t.shouldNextFile||t.loopBreak||t.loopContinue||t.hasReturn}async function ut(t,e){switch(e.type){case"block":await $t(t,e.statements);break;case"expr_stmt":await L(t,e.expression);break;case"print":await zp(t,e.args,e.output);break;case"printf":await Hp(t,e.format,e.args,e.output);break;case"if":await Gp(t,e);break;case"while":await qp(t,e);break;case"do_while":await Vp(t,e);break;case"for":await Kp(t,e);break;case"for_in":await Zp(t,e);break;case"break":t.loopBreak=!0;break;case"continue":t.loopContinue=!0;break;case"next":t.shouldNext=!0;break;case"nextfile":t.shouldNextFile=!0;break;case"exit":t.shouldExit=!0,t.exitCode=e.code?Math.floor(G(await L(t,e.code))):0;break;case"return":t.hasReturn=!0,t.returnValue=e.value?await L(t,e.value):"";break;case"delete":await Qp(t,e.target);break}}async function zp(t,e,r){let n=[];for(let i of e)n.push(q(await L(t,i)));let s=n.join(t.OFS)+t.ORS;r?await _o(t,r.redirect,r.file,s):t.output+=s}async function Hp(t,e,r,n){let s=q(await L(t,e)),i=[];for(let a of r)i.push(await L(t,a));let o=Wn(s,i);n?await _o(t,n.redirect,n.file,o):t.output+=o}async function _o(t,e,r,n){if(!t.fs||!t.cwd){t.output+=n;return}let s=q(await L(t,r)),i=t.fs.resolvePath(t.cwd,s);e===">"?t.openedFiles.has(i)?await t.fs.appendFile(i,n):(await t.fs.writeFile(i,n),t.openedFiles.add(i)):(t.openedFiles.has(i)||t.openedFiles.add(i),await t.fs.appendFile(i,n))}async function Gp(t,e){xe(await L(t,e.condition))?await ut(t,e.consequent):e.alternate&&await ut(t,e.alternate)}async function qp(t,e){let r=0;for(;xe(await L(t,e.condition));){if(r++,r>t.maxIterations)throw new W(`awk: while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await ut(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function Vp(t,e){let r=0;do{if(r++,r>t.maxIterations)throw new W(`awk: do-while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await ut(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}while(xe(await L(t,e.condition)))}async function Kp(t,e){e.init&&await L(t,e.init);let r=0;for(;!e.condition||xe(await L(t,e.condition));){if(r++,r>t.maxIterations)throw new W(`awk: for loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await ut(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break;e.update&&await L(t,e.update)}}async function Zp(t,e){let r=t.arrays[e.array];if(r)for(let n of Object.keys(r)){if(t.vars[e.variable]=n,t.loopContinue=!1,await ut(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function Qp(t,e){if(e.type==="array_access"){let r=q(await L(t,e.key));Lo(t,e.array,r)}else e.type==="variable"&&Do(t,e.name)}var Bo=C(()=>{"use strict";X();Un();Gn();Nt();zn();Mo($t)});var Jt,Wo=C(()=>{"use strict";Gn();Ir();Nt();Bo();Jt=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}execute(e){this.program=e,this.ctx.output="";for(let r of e.functions)this.ctx.functions.set(r.name,r);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let e of this.program.rules)if(e.pattern?.type==="begin"&&(await $t(this.ctx,e.action.statements),this.ctx.shouldExit))break}}async executeLine(e){if(!(!this.program||this.ctx.shouldExit)){Xt(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let r=0;r<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);r++){let n=this.program.rules[r];n.pattern?.type==="begin"||n.pattern?.type==="end"||await this.matchesRule(n,r)&&await $t(this.ctx,n.action.statements)}}}async executeEnd(){if(!(!this.program||this.ctx.shouldExit)){for(let e of this.program.rules)if(e.pattern?.type==="end"&&(await $t(this.ctx,e.action.statements),this.ctx.shouldExit))break}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,r){let n=e.pattern;if(!n)return!0;switch(n.type){case"begin":case"end":return!1;case"regex_pattern":return Qt(n.pattern,this.ctx.line);case"expr_pattern":return xe(await L(this.ctx,n.expression));case"range":{let s=await this.matchPattern(n.start),i=await this.matchPattern(n.end);return this.rangeStates[r]?(i&&(this.rangeStates[r]=!1),!0):s?(this.rangeStates[r]=!0,i&&(this.rangeStates[r]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(e.type){case"regex_pattern":return Qt(e.pattern,this.ctx.line);case"expr_pattern":return xe(await L(this.ctx,e.expression));default:return!1}}}});var Uo=C(()=>{"use strict";No();Wo()});function Jp(t){return t.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var x,Xp,vr,jo=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.STRING="STRING",t.REGEX="REGEX",t.IDENT="IDENT",t.BEGIN="BEGIN",t.END="END",t.IF="IF",t.ELSE="ELSE",t.WHILE="WHILE",t.DO="DO",t.FOR="FOR",t.IN="IN",t.BREAK="BREAK",t.CONTINUE="CONTINUE",t.NEXT="NEXT",t.NEXTFILE="NEXTFILE",t.EXIT="EXIT",t.RETURN="RETURN",t.DELETE="DELETE",t.FUNCTION="FUNCTION",t.PRINT="PRINT",t.PRINTF="PRINTF",t.GETLINE="GETLINE",t.PLUS="PLUS",t.MINUS="MINUS",t.STAR="STAR",t.SLASH="SLASH",t.PERCENT="PERCENT",t.CARET="CARET",t.EQ="EQ",t.NE="NE",t.LT="LT",t.GT="GT",t.LE="LE",t.GE="GE",t.MATCH="MATCH",t.NOT_MATCH="NOT_MATCH",t.AND="AND",t.OR="OR",t.NOT="NOT",t.ASSIGN="ASSIGN",t.PLUS_ASSIGN="PLUS_ASSIGN",t.MINUS_ASSIGN="MINUS_ASSIGN",t.STAR_ASSIGN="STAR_ASSIGN",t.SLASH_ASSIGN="SLASH_ASSIGN",t.PERCENT_ASSIGN="PERCENT_ASSIGN",t.CARET_ASSIGN="CARET_ASSIGN",t.INCREMENT="INCREMENT",t.DECREMENT="DECREMENT",t.QUESTION="QUESTION",t.COLON="COLON",t.COMMA="COMMA",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.LBRACKET="LBRACKET",t.RBRACKET="RBRACKET",t.DOLLAR="DOLLAR",t.APPEND="APPEND",t.PIPE="PIPE",t.EOF="EOF"})(x||(x={}));Xp={BEGIN:x.BEGIN,END:x.END,if:x.IF,else:x.ELSE,while:x.WHILE,do:x.DO,for:x.FOR,in:x.IN,break:x.BREAK,continue:x.CONTINUE,next:x.NEXT,nextfile:x.NEXTFILE,exit:x.EXIT,return:x.RETURN,delete:x.DELETE,function:x.FUNCTION,print:x.PRINT,printf:x.PRINTF,getline:x.GETLINE};vr=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&(e.push(r),this.lastTokenType=r.type)}return e.push(this.makeToken(x.EOF,"")),e}makeToken(e,r){return{type:e,value:r,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
225
+ `,exitCode:1};let u="";if(a.length===0){u=e.stdin;try{let f=await Hn(u,l,s,{limits:e.limits,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof j)return{stdout:"",stderr:`sed: ${f.message}
226
+ `,exitCode:j.EXIT_CODE};throw f}}if(i){for(let f of a){let p=e.fs.resolvePath(e.cwd,f);try{let d=await e.fs.readFile(p),h=await Hn(d,l,s,{limits:e.limits,filename:f,fs:e.fs,cwd:e.cwd});await e.fs.writeFile(p,h.output)}catch(d){return d instanceof j?{stdout:"",stderr:`sed: ${d.message}
227
+ `,exitCode:j.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
228
+ `,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}for(let f of a){let p=e.fs.resolvePath(e.cwd,f);try{u+=await e.fs.readFile(p)}catch(d){return d instanceof j?{stdout:"",stderr:`sed: ${d.message}
229
+ `,exitCode:j.EXIT_CODE}:{stdout:"",stderr:`sed: ${f}: No such file or directory
230
+ `,exitCode:1}}}try{let f=await Hn(u,l,s,{limits:e.limits,filename:a.length===1?a[0]:void 0,fs:e.fs,cwd:e.cwd});return{stdout:f.output,stderr:"",exitCode:f.exitCode??0}}catch(f){if(f instanceof j)return{stdout:"",stderr:`sed: ${f.message}
231
+ `,exitCode:j.EXIT_CODE};throw f}}}});function Gn(t={}){let{fieldSep:e=/\s+/,maxIterations:r=1e4,maxRecursionDepth:n=100,fs:s,cwd:i}=t;return{FS:" ",OFS:" ",ORS:`
232
+ `,NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:{},arrays:{},ARGC:0,ARGV:{},functions:new Map,fieldSep:e,maxIterations:r,maxRecursionDepth:n,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,output:"",openedFiles:new Set,fs:s,cwd:i}}var To=C(()=>{"use strict"});function Do(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?t/e:0;case"%":return e!==0?t%e:0;case"^":case"**":return t**e;default:return 0}}var Lo=C(()=>{"use strict"});function Le(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function me(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}async function dd(t,e,r){return t.length===0?e.line.length:me(await r.evalExpr(t[0])).length}async function hd(t,e,r){if(t.length<2)return"";let n=me(await r.evalExpr(t[0])),s=Math.floor(Le(await r.evalExpr(t[1])))-1;if(t.length>=3){let i=Math.floor(Le(await r.evalExpr(t[2])));return n.substr(Math.max(0,s),i)}return n.substr(Math.max(0,s))}async function md(t,e,r){if(t.length<2)return 0;let n=me(await r.evalExpr(t[0])),s=me(await r.evalExpr(t[1])),i=n.indexOf(s);return i===-1?0:i+1}async function gd(t,e,r){if(t.length<2)return 0;let n=me(await r.evalExpr(t[0])),s=t[1];if(s.type!=="variable")return 0;let i=s.name,o=e.FS;if(t.length>=3){let l=me(await r.evalExpr(t[2]));o=l===" "?/\s+/:l}else e.FS===" "&&(o=/\s+/);let a=n.split(o);e.arrays[i]={};for(let l=0;l<a.length;l++)e.arrays[i][String(l+1)]=a[l];return a.length}async function yd(t,e,r){if(t.length<2)return 0;let n;t[0].type==="regex"?n=t[0].pattern:(n=me(await r.evalExpr(t[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let s=me(await r.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(Le(await r.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=me(e.vars[i]??"");try{let a=new RegExp(n),l=o.replace(a,_o(s)),c=l!==o?1:0;if(i==="$0")e.line=l,e.fields=e.FS===" "?l.trim().split(/\s+/).filter(Boolean):l.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let u=parseInt(i.slice(1),10)-1;for(;e.fields.length<=u;)e.fields.push("");e.fields[u]=l,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=l;return c}catch{return 0}}async function xd(t,e,r){if(t.length<2)return 0;let n;t[0].type==="regex"?n=t[0].pattern:(n=me(await r.evalExpr(t[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let s=me(await r.evalExpr(t[1])),i="$0";if(t.length>=3){let a=t[2];a.type==="variable"?i=a.name:a.type==="field"&&(i=`$${Math.floor(Le(await r.evalExpr(a.index)))}`)}let o;if(i==="$0")o=e.line;else if(i.startsWith("$")){let a=parseInt(i.slice(1),10)-1;o=e.fields[a]||""}else o=me(e.vars[i]??"");try{let a=new RegExp(n,"g"),l=o.match(a),c=l?l.length:0,u=o.replace(a,_o(s));if(i==="$0")e.line=u,e.fields=e.FS===" "?u.trim().split(/\s+/).filter(Boolean):u.split(e.fieldSep),e.NF=e.fields.length;else if(i.startsWith("$")){let f=parseInt(i.slice(1),10)-1;for(;e.fields.length<=f;)e.fields.push("");e.fields[f]=u,e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}else e.vars[i]=u;return c}catch{return 0}}function _o(t){return e=>{let r="",n=0;for(;n<t.length;)if(t[n]==="\\"&&n+1<t.length){let s=t[n+1];s==="&"?(r+="&",n+=2):s==="\\"?(r+="\\",n+=2):(r+=t[n+1],n+=2)}else t[n]==="&"?(r+=e,n++):(r+=t[n],n++);return r}}async function wd(t,e,r){if(t.length<2)return e.RSTART=0,e.RLENGTH=-1,0;let n=me(await r.evalExpr(t[0])),s;t[1].type==="regex"?s=t[1].pattern:(s=me(await r.evalExpr(t[1])),s.startsWith("/")&&s.endsWith("/")&&(s=s.slice(1,-1)));try{let o=new RegExp(s).exec(n);if(o)return e.RSTART=o.index+1,e.RLENGTH=o[0].length,e.RSTART}catch{}return e.RSTART=0,e.RLENGTH=-1,0}async function bd(t,e,r){if(t.length<3)return"";let n;t[0].type==="regex"?n=t[0].pattern:(n=me(await r.evalExpr(t[0])),n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)));let s=me(await r.evalExpr(t[1])),i=me(await r.evalExpr(t[2])),o=t.length>=4?me(await r.evalExpr(t[3])):e.line;try{let a=i.toLowerCase()==="g",l=a?0:parseInt(i,10)||1;if(a){let c=new RegExp(n,"g");return o.replace(c,(u,...f)=>Mo(s,u,f.slice(0,-2)))}else{let c=0,u=new RegExp(n,"g");return o.replace(u,(f,...p)=>(c++,c===l?Mo(s,f,p.slice(0,-2)):f))}}catch{return o}}function Mo(t,e,r){let n="",s=0;for(;s<t.length;)if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];if(i==="&")n+="&",s+=2;else if(i==="0")n+=e,s+=2;else if(i>="1"&&i<="9"){let o=parseInt(i,10)-1;n+=r[o]||"",s+=2}else i==="n"?(n+=`
233
+ `,s+=2):i==="t"?(n+=" ",s+=2):(n+=i,s+=2)}else t[s]==="&"?(n+=e,s++):(n+=t[s],s++);return n}async function Ed(t,e,r){return t.length===0?"":me(await r.evalExpr(t[0])).toLowerCase()}async function Sd(t,e,r){return t.length===0?"":me(await r.evalExpr(t[0])).toUpperCase()}async function Cd(t,e,r){if(t.length===0)return"";let n=me(await r.evalExpr(t[0])),s=[];for(let i=1;i<t.length;i++)s.push(await r.evalExpr(t[i]));return Kn(n,s)}async function Ad(t,e,r){return t.length===0?0:Math.floor(Le(await r.evalExpr(t[0])))}async function kd(t,e,r){return t.length===0?0:Math.sqrt(Le(await r.evalExpr(t[0])))}async function Nd(t,e,r){return t.length===0?0:Math.sin(Le(await r.evalExpr(t[0])))}async function Id(t,e,r){return t.length===0?0:Math.cos(Le(await r.evalExpr(t[0])))}async function vd(t,e,r){let n=t.length>0?Le(await r.evalExpr(t[0])):0,s=t.length>1?Le(await r.evalExpr(t[1])):0;return Math.atan2(n,s)}async function $d(t,e,r){return t.length===0?0:Math.log(Le(await r.evalExpr(t[0])))}async function Rd(t,e,r){return t.length===0?1:Math.exp(Le(await r.evalExpr(t[0])))}function Pd(t,e,r){return e.random?e.random():Math.random()}async function Fd(t,e,r){let n=t.length>0?Le(await r.evalExpr(t[0])):Date.now();return e.vars._srand_seed=n,n}function qn(t,e){return()=>{throw new Error(`${t}() is not supported - ${e}`)}}function Vn(t){return()=>{throw new Error(`function '${t}()' is not implemented`)}}function Kn(t,e){let r=0,n="",s=0;for(;s<t.length;)if(t[s]==="%"&&s+1<t.length){let i=s+1,o="",a="",l="";for(;i<t.length&&/[-+ #0]/.test(t[i]);)o+=t[i++];for(;i<t.length&&/\d/.test(t[i]);)a+=t[i++];if(t[i]===".")for(i++;i<t.length&&/\d/.test(t[i]);)l+=t[i++];let c=t[i],u=e[r];switch(c){case"s":{let f=u!==void 0?String(u):"";if(l&&(f=f.substring(0,parseInt(l,10))),a){let p=parseInt(a,10);o.includes("-")?f=f.padEnd(p):f=f.padStart(p)}n+=f,r++;break}case"d":case"i":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let p=String(f);if(a){let d=parseInt(a,10);if(o.includes("-"))p=p.padEnd(d);else if(o.includes("0")&&!o.includes("-")){let h=f<0?"-":"";p=h+Math.abs(f).toString().padStart(d-h.length,"0")}else p=p.padStart(d)}n+=p,r++;break}case"f":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let p=l?parseInt(l,10):6,d=f.toFixed(p);if(a){let h=parseInt(a,10);o.includes("-")?d=d.padEnd(h):d=d.padStart(h)}n+=d,r++;break}case"e":case"E":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let p=l?parseInt(l,10):6,d=f.toExponential(p);if(c==="E"&&(d=d.toUpperCase()),a){let h=parseInt(a,10);o.includes("-")?d=d.padEnd(h):d=d.padStart(h)}n+=d,r++;break}case"g":case"G":{let f=u!==void 0?Number(u):0;Number.isNaN(f)&&(f=0);let p=l?parseInt(l,10):6,d=f!==0?Math.floor(Math.log10(Math.abs(f))):0,h;if(f===0?h="0":d<-4||d>=p?(h=f.toExponential(p-1),c==="G"&&(h=h.toUpperCase())):h=f.toPrecision(p),h=h.replace(/\.?0+$/,"").replace(/\.?0+e/,"e"),a){let m=parseInt(a,10);o.includes("-")?h=h.padEnd(m):h=h.padStart(m)}n+=h,r++;break}case"x":case"X":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let p=Math.abs(f).toString(16);if(c==="X"&&(p=p.toUpperCase()),a){let d=parseInt(a,10);o.includes("0")?p=p.padStart(d,"0"):o.includes("-")?p=p.padEnd(d):p=p.padStart(d)}n+=f<0?`-${p}`:p,r++;break}case"o":{let f=u!==void 0?Math.floor(Number(u)):0;Number.isNaN(f)&&(f=0);let p=Math.abs(f).toString(8);if(a){let d=parseInt(a,10);o.includes("0")?p=p.padStart(d,"0"):o.includes("-")?p=p.padEnd(d):p=p.padStart(d)}n+=f<0?`-${p}`:p,r++;break}case"c":{typeof u=="number"?n+=String.fromCharCode(u):n+=String(u??"").charAt(0)||"",r++;break}case"%":n+="%";break;default:n+=t.substring(s,i+1)}s=i+1}else if(t[s]==="\\"&&s+1<t.length){let i=t[s+1];switch(i){case"n":n+=`
234
+ `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;default:n+=i}s+=2}else n+=t[s++];return n}var Bo,Zn=C(()=>{"use strict";Bo={length:dd,substr:hd,index:md,split:gd,sub:yd,gsub:xd,match:wd,gensub:bd,tolower:Ed,toupper:Sd,sprintf:Cd,int:Ad,sqrt:kd,sin:Nd,cos:Id,atan2:vd,log:$d,exp:Rd,rand:Pd,srand:Fd,system:qn("system","shell execution not allowed in sandboxed environment"),close:qn("close","file operations not allowed"),fflush:qn("fflush","file operations not allowed"),systime:Vn("systime"),mktime:Vn("mktime"),strftime:Vn("strftime")}});function $e(t){return typeof t=="number"?t!==0:t!==""}function q(t){if(typeof t=="number")return t;let e=parseFloat(t);return Number.isNaN(e)?0:e}function Z(t){return typeof t=="string"?t:(Number.isInteger(t),String(t))}function Qn(t){if(typeof t=="number")return!0;let e=String(t).trim();return e===""?!1:!Number.isNaN(Number(e))}function ir(t,e){try{return new RegExp(t).test(e)}catch{return!1}}var Lt=C(()=>{"use strict"});function Wo(t,e){return t.FS===" "?e.trim().split(/\s+/).filter(Boolean):e.split(t.fieldSep)}function yt(t,e){return e===0?t.line:e<0||e>t.fields.length?"":t.fields[e-1]??""}function Mt(t,e,r){if(e===0)t.line=Z(r),t.fields=Wo(t,t.line),t.NF=t.fields.length;else if(e>0){for(;t.fields.length<e;)t.fields.push("");t.fields[e-1]=Z(r),t.NF=t.fields.length,t.line=t.fields.join(t.OFS)}}function or(t,e){t.line=e,t.fields=Wo(t,e),t.NF=t.fields.length}function Uo(t,e){if(t.FS=e,e===" ")t.fieldSep=/\s+/;else try{t.fieldSep=new RegExp(e)}catch{t.fieldSep=new RegExp(e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var Mr=C(()=>{"use strict";Lt()});function xt(t,e){switch(e){case"FS":return t.FS;case"OFS":return t.OFS;case"ORS":return t.ORS;case"NR":return t.NR;case"NF":return t.NF;case"FNR":return t.FNR;case"FILENAME":return t.FILENAME;case"RSTART":return t.RSTART;case"RLENGTH":return t.RLENGTH;case"SUBSEP":return t.SUBSEP;case"ARGC":return t.ARGC}return t.vars[e]??""}function it(t,e,r){switch(e){case"FS":Uo(t,Z(r));return;case"OFS":t.OFS=Z(r);return;case"ORS":t.ORS=Z(r);return;case"NR":t.NR=Math.floor(q(r));return;case"NF":{let n=Math.floor(q(r));if(n<t.NF)t.fields=t.fields.slice(0,n),t.line=t.fields.join(t.OFS);else if(n>t.NF){for(;t.fields.length<n;)t.fields.push("");t.line=t.fields.join(t.OFS)}t.NF=n;return}case"FNR":t.FNR=Math.floor(q(r));return;case"FILENAME":t.FILENAME=Z(r);return;case"RSTART":t.RSTART=Math.floor(q(r));return;case"RLENGTH":t.RLENGTH=Math.floor(q(r));return;case"SUBSEP":t.SUBSEP=Z(r);return}t.vars[e]=r}function wt(t,e,r){return e==="ARGV"?t.ARGV[r]??"":t.arrays[e]?.[r]??""}function _t(t,e,r,n){t.arrays[e]||(t.arrays[e]={}),t.arrays[e][r]=n}function jo(t,e,r){return e==="ARGV"?t.ARGV[r]!==void 0:t.arrays[e]?.[r]!==void 0}function zo(t,e,r){t.arrays[e]&&delete t.arrays[e][r]}function Ho(t,e){delete t.arrays[e]}var Xn=C(()=>{"use strict";Mr();Lt()});function Go(t){Jn=t}async function B(t,e){switch(e.type){case"number":return e.value;case"string":return e.value;case"regex":return ir(e.pattern,t.line)?1:0;case"field":return Od(t,e);case"variable":return xt(t,e.name);case"array_access":return Td(t,e);case"binary":return Dd(t,e);case"unary":return _d(t,e);case"ternary":return $e(await B(t,e.condition))?B(t,e.consequent):B(t,e.alternate);case"call":return Bd(t,e.name,e.args);case"assignment":return Ud(t,e);case"pre_increment":return jd(t,e.operand);case"pre_decrement":return zd(t,e.operand);case"post_increment":return Hd(t,e.operand);case"post_decrement":return Gd(t,e.operand);case"in":return qd(t,e.key,e.array);case"getline":return Vd(t,e.variable,e.file);case"tuple":return Zd(t,e.elements);default:return""}}async function Od(t,e){let r=Math.floor(q(await B(t,e.index)));return yt(t,r)}async function Td(t,e){let r=Z(await B(t,e.key));return wt(t,e.array,r)}async function Dd(t,e){let r=e.operator;if(r==="||")return $e(await B(t,e.left))||$e(await B(t,e.right))?1:0;if(r==="&&")return $e(await B(t,e.left))&&$e(await B(t,e.right))?1:0;if(r==="~"){let a=await B(t,e.left),l=e.right.type==="regex"?e.right.pattern:Z(await B(t,e.right));try{return new RegExp(l).test(Z(a))?1:0}catch{return 0}}if(r==="!~"){let a=await B(t,e.left),l=e.right.type==="regex"?e.right.pattern:Z(await B(t,e.right));try{return new RegExp(l).test(Z(a))?0:1}catch{return 1}}let n=await B(t,e.left),s=await B(t,e.right);if(r===" ")return Z(n)+Z(s);if(Ld(r))return Md(n,s,r);let i=q(n),o=q(s);return Do(i,o,r)}function Ld(t){return["<","<=",">",">=","==","!="].includes(t)}function Md(t,e,r){let n=Qn(t),s=Qn(e);if(n&&s){let a=q(t),l=q(e);switch(r){case"<":return a<l?1:0;case"<=":return a<=l?1:0;case">":return a>l?1:0;case">=":return a>=l?1:0;case"==":return a===l?1:0;case"!=":return a!==l?1:0}}let i=Z(t),o=Z(e);switch(r){case"<":return i<o?1:0;case"<=":return i<=o?1:0;case">":return i>o?1:0;case">=":return i>=o?1:0;case"==":return i===o?1:0;case"!=":return i!==o?1:0}return 0}async function _d(t,e){let r=await B(t,e.operand);switch(e.operator){case"!":return $e(r)?0:1;case"-":return-q(r);case"+":return+q(r);default:return r}}async function Bd(t,e,r){let n=Bo[e];if(n)return n(r,t,{evalExpr:i=>B(t,i)});let s=t.functions.get(e);return s?Wd(t,s,r):""}async function Wd(t,e,r){if(t.currentRecursionDepth++,t.currentRecursionDepth>t.maxRecursionDepth)throw t.currentRecursionDepth--,new j(`awk: recursion depth exceeded maximum (${t.maxRecursionDepth})`,"recursion",t.output);let n={};for(let i of e.params)n[i]=t.vars[i];for(let i=0;i<e.params.length;i++){let o=e.params[i],a=i<r.length?await B(t,r[i]):"";t.vars[o]=a}t.hasReturn=!1,t.returnValue=void 0,Jn&&await Jn(t,e.body.statements);let s=t.returnValue??"";for(let i of e.params)n[i]!==void 0?t.vars[i]=n[i]:delete t.vars[i];return t.hasReturn=!1,t.returnValue=void 0,t.currentRecursionDepth--,s}async function Ud(t,e){let r=await B(t,e.value),n=e.target,s=e.operator,i;if(s==="=")i=r;else{let o;if(n.type==="field"){let c=Math.floor(q(await B(t,n.index)));o=yt(t,c)}else if(n.type==="variable")o=xt(t,n.name);else{let c=Z(await B(t,n.key));o=wt(t,n.array,c)}let a=q(o),l=q(r);switch(s){case"+=":i=a+l;break;case"-=":i=a-l;break;case"*=":i=a*l;break;case"/=":i=l!==0?a/l:0;break;case"%=":i=l!==0?a%l:0;break;case"^=":i=a**l;break;default:i=r}}if(n.type==="field"){let o=Math.floor(q(await B(t,n.index)));Mt(t,o,i)}else if(n.type==="variable")it(t,n.name,i);else{let o=Z(await B(t,n.key));_t(t,n.array,o,i)}return i}async function jd(t,e){let r;if(e.type==="field"){let n=Math.floor(q(await B(t,e.index)));r=q(yt(t,n))+1,Mt(t,n,r)}else if(e.type==="variable")r=q(xt(t,e.name))+1,it(t,e.name,r);else{let n=Z(await B(t,e.key));r=q(wt(t,e.array,n))+1,_t(t,e.array,n,r)}return r}async function zd(t,e){let r;if(e.type==="field"){let n=Math.floor(q(await B(t,e.index)));r=q(yt(t,n))-1,Mt(t,n,r)}else if(e.type==="variable")r=q(xt(t,e.name))-1,it(t,e.name,r);else{let n=Z(await B(t,e.key));r=q(wt(t,e.array,n))-1,_t(t,e.array,n,r)}return r}async function Hd(t,e){let r;if(e.type==="field"){let n=Math.floor(q(await B(t,e.index)));r=q(yt(t,n)),Mt(t,n,r+1)}else if(e.type==="variable")r=q(xt(t,e.name)),it(t,e.name,r+1);else{let n=Z(await B(t,e.key));r=q(wt(t,e.array,n)),_t(t,e.array,n,r+1)}return r}async function Gd(t,e){let r;if(e.type==="field"){let n=Math.floor(q(await B(t,e.index)));r=q(yt(t,n)),Mt(t,n,r-1)}else if(e.type==="variable")r=q(xt(t,e.name)),it(t,e.name,r-1);else{let n=Z(await B(t,e.key));r=q(wt(t,e.array,n)),_t(t,e.array,n,r-1)}return r}async function qd(t,e,r){let n;if(e.type==="tuple"){let s=[];for(let i of e.elements)s.push(Z(await B(t,i)));n=s.join(t.SUBSEP)}else n=Z(await B(t,e));return jo(t,r,n)?1:0}async function Vd(t,e,r){if(r)return Kd(t,e,r);if(!t.lines||t.lineIndex===void 0)return-1;let n=t.lineIndex+1;if(n>=t.lines.length)return 0;let s=t.lines[n];return e?it(t,e,s):or(t,s),t.NR++,t.lineIndex=n,1}async function Kd(t,e,r){if(!t.fs||!t.cwd)return-1;let n=Z(await B(t,r)),s=t.fs.resolvePath(t.cwd,n),i=`__fc_${s}`,o=`__fi_${s}`,a,l;if(t.vars[i]===void 0)try{a=(await t.fs.readFile(s)).split(`
235
+ `),a.length>0&&a[a.length-1]===""&&a.pop(),t.vars[i]=JSON.stringify(a),t.vars[o]=-1,l=-1}catch{return-1}else a=JSON.parse(t.vars[i]),l=t.vars[o];let c=l+1;if(c>=a.length)return 0;let u=a[c];return t.vars[o]=c,e?it(t,e,u):or(t,u),1}async function Zd(t,e){if(e.length===0)return"";for(let r=0;r<e.length-1;r++)await B(t,e[r]);return B(t,e[e.length-1])}var Jn,Yn=C(()=>{"use strict";oe();Lo();Zn();Mr();Lt();Xn();Jn=null});async function Bt(t,e){for(let r of e)if(await bt(t,r),Qd(t))break}function Qd(t){return t.shouldExit||t.shouldNext||t.shouldNextFile||t.loopBreak||t.loopContinue||t.hasReturn}async function bt(t,e){switch(e.type){case"block":await Bt(t,e.statements);break;case"expr_stmt":await B(t,e.expression);break;case"print":await Xd(t,e.args,e.output);break;case"printf":await Jd(t,e.format,e.args,e.output);break;case"if":await Yd(t,e);break;case"while":await eh(t,e);break;case"do_while":await th(t,e);break;case"for":await rh(t,e);break;case"for_in":await nh(t,e);break;case"break":t.loopBreak=!0;break;case"continue":t.loopContinue=!0;break;case"next":t.shouldNext=!0;break;case"nextfile":t.shouldNextFile=!0;break;case"exit":t.shouldExit=!0,t.exitCode=e.code?Math.floor(q(await B(t,e.code))):0;break;case"return":t.hasReturn=!0,t.returnValue=e.value?await B(t,e.value):"";break;case"delete":await sh(t,e.target);break}}async function Xd(t,e,r){let n=[];for(let i of e)n.push(Z(await B(t,i)));let s=n.join(t.OFS)+t.ORS;r?await qo(t,r.redirect,r.file,s):t.output+=s}async function Jd(t,e,r,n){let s=Z(await B(t,e)),i=[];for(let a of r)i.push(await B(t,a));let o=Kn(s,i);n?await qo(t,n.redirect,n.file,o):t.output+=o}async function qo(t,e,r,n){if(!t.fs||!t.cwd){t.output+=n;return}let s=Z(await B(t,r)),i=t.fs.resolvePath(t.cwd,s);e===">"?t.openedFiles.has(i)?await t.fs.appendFile(i,n):(await t.fs.writeFile(i,n),t.openedFiles.add(i)):(t.openedFiles.has(i)||t.openedFiles.add(i),await t.fs.appendFile(i,n))}async function Yd(t,e){$e(await B(t,e.condition))?await bt(t,e.consequent):e.alternate&&await bt(t,e.alternate)}async function eh(t,e){let r=0;for(;$e(await B(t,e.condition));){if(r++,r>t.maxIterations)throw new j(`awk: while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function th(t,e){let r=0;do{if(r++,r>t.maxIterations)throw new j(`awk: do-while loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}while($e(await B(t,e.condition)))}async function rh(t,e){e.init&&await B(t,e.init);let r=0;for(;!e.condition||$e(await B(t,e.condition));){if(r++,r>t.maxIterations)throw new j(`awk: for loop exceeded maximum iterations (${t.maxIterations})`,"iterations",t.output);if(t.loopContinue=!1,await bt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break;e.update&&await B(t,e.update)}}async function nh(t,e){let r=t.arrays[e.array];if(r)for(let n of Object.keys(r)){if(t.vars[e.variable]=n,t.loopContinue=!1,await bt(t,e.body),t.loopBreak){t.loopBreak=!1;break}if(t.shouldExit||t.shouldNext||t.hasReturn)break}}async function sh(t,e){if(e.type==="array_access"){let r=Z(await B(t,e.key));zo(t,e.array,r)}else e.type==="variable"&&Ho(t,e.name)}var Vo=C(()=>{"use strict";oe();Zn();Yn();Lt();Xn();Go(Bt)});var ar,Ko=C(()=>{"use strict";Yn();Mr();Lt();Vo();ar=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}execute(e){this.program=e,this.ctx.output="";for(let r of e.functions)this.ctx.functions.set(r.name,r);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let e of this.program.rules)if(e.pattern?.type==="begin"&&(await Bt(this.ctx,e.action.statements),this.ctx.shouldExit))break}}async executeLine(e){if(!(!this.program||this.ctx.shouldExit)){or(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let r=0;r<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);r++){let n=this.program.rules[r];n.pattern?.type==="begin"||n.pattern?.type==="end"||await this.matchesRule(n,r)&&await Bt(this.ctx,n.action.statements)}}}async executeEnd(){if(!(!this.program||this.ctx.shouldExit)){for(let e of this.program.rules)if(e.pattern?.type==="end"&&(await Bt(this.ctx,e.action.statements),this.ctx.shouldExit))break}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,r){let n=e.pattern;if(!n)return!0;switch(n.type){case"begin":case"end":return!1;case"regex_pattern":return ir(n.pattern,this.ctx.line);case"expr_pattern":return $e(await B(this.ctx,n.expression));case"range":{let s=await this.matchPattern(n.start),i=await this.matchPattern(n.end);return this.rangeStates[r]?(i&&(this.rangeStates[r]=!1),!0):s?(this.rangeStates[r]=!0,i&&(this.rangeStates[r]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(e.type){case"regex_pattern":return ir(e.pattern,this.ctx.line);case"expr_pattern":return $e(await B(this.ctx,e.expression));default:return!1}}}});var Zo=C(()=>{"use strict";To();Ko()});function oh(t){return t.replace(/\[\[:space:\]\]/g,"[ \\t\\n\\r\\f\\v]").replace(/\[\[:blank:\]\]/g,"[ \\t]").replace(/\[\[:alpha:\]\]/g,"[a-zA-Z]").replace(/\[\[:digit:\]\]/g,"[0-9]").replace(/\[\[:alnum:\]\]/g,"[a-zA-Z0-9]").replace(/\[\[:upper:\]\]/g,"[A-Z]").replace(/\[\[:lower:\]\]/g,"[a-z]").replace(/\[\[:punct:\]\]/g,"[!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_`{|}~]").replace(/\[\[:xdigit:\]\]/g,"[0-9A-Fa-f]").replace(/\[\[:graph:\]\]/g,"[!-~]").replace(/\[\[:print:\]\]/g,"[ -~]").replace(/\[\[:cntrl:\]\]/g,"[\\x00-\\x1f\\x7f]")}var x,ih,_r,Qo=C(()=>{"use strict";(function(t){t.NUMBER="NUMBER",t.STRING="STRING",t.REGEX="REGEX",t.IDENT="IDENT",t.BEGIN="BEGIN",t.END="END",t.IF="IF",t.ELSE="ELSE",t.WHILE="WHILE",t.DO="DO",t.FOR="FOR",t.IN="IN",t.BREAK="BREAK",t.CONTINUE="CONTINUE",t.NEXT="NEXT",t.NEXTFILE="NEXTFILE",t.EXIT="EXIT",t.RETURN="RETURN",t.DELETE="DELETE",t.FUNCTION="FUNCTION",t.PRINT="PRINT",t.PRINTF="PRINTF",t.GETLINE="GETLINE",t.PLUS="PLUS",t.MINUS="MINUS",t.STAR="STAR",t.SLASH="SLASH",t.PERCENT="PERCENT",t.CARET="CARET",t.EQ="EQ",t.NE="NE",t.LT="LT",t.GT="GT",t.LE="LE",t.GE="GE",t.MATCH="MATCH",t.NOT_MATCH="NOT_MATCH",t.AND="AND",t.OR="OR",t.NOT="NOT",t.ASSIGN="ASSIGN",t.PLUS_ASSIGN="PLUS_ASSIGN",t.MINUS_ASSIGN="MINUS_ASSIGN",t.STAR_ASSIGN="STAR_ASSIGN",t.SLASH_ASSIGN="SLASH_ASSIGN",t.PERCENT_ASSIGN="PERCENT_ASSIGN",t.CARET_ASSIGN="CARET_ASSIGN",t.INCREMENT="INCREMENT",t.DECREMENT="DECREMENT",t.QUESTION="QUESTION",t.COLON="COLON",t.COMMA="COMMA",t.SEMICOLON="SEMICOLON",t.NEWLINE="NEWLINE",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.LBRACKET="LBRACKET",t.RBRACKET="RBRACKET",t.DOLLAR="DOLLAR",t.APPEND="APPEND",t.PIPE="PIPE",t.EOF="EOF"})(x||(x={}));ih={BEGIN:x.BEGIN,END:x.END,if:x.IF,else:x.ELSE,while:x.WHILE,do:x.DO,for:x.FOR,in:x.IN,break:x.BREAK,continue:x.CONTINUE,next:x.NEXT,nextfile:x.NEXTFILE,exit:x.EXIT,return:x.RETURN,delete:x.DELETE,function:x.FUNCTION,print:x.PRINT,printf:x.PRINTF,getline:x.GETLINE};_r=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let r=this.nextToken();r&&(e.push(r),this.lastTokenType=r.type)}return e.push(this.makeToken(x.EOF,"")),e}makeToken(e,r){return{type:e,value:r,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||""}advance(){let e=this.input[this.pos++]||"";return e===`
236
236
  `?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===" "||e===" "||e==="\r")this.advance();else if(e==="\\")if(this.peek(1)===`
237
237
  `)this.advance(),this.advance();else break;else if(e==="#")for(;this.pos<this.input.length&&this.peek()!==`
238
238
  `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,r=this.column,n=this.peek();return n===`
239
239
  `?(this.advance(),{type:x.NEWLINE,value:`
240
240
  `,line:e,column:r}):n==='"'?this.readString():n==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(n)||n==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(n)||n==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,x.NEWLINE,x.SEMICOLON,x.LBRACE,x.RBRACE,x.LPAREN,x.LBRACKET,x.COMMA,x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN,x.AND,x.OR,x.NOT,x.MATCH,x.NOT_MATCH,x.QUESTION,x.COLON,x.LT,x.GT,x.LE,x.GE,x.EQ,x.NE,x.PLUS,x.MINUS,x.STAR,x.PERCENT,x.CARET,x.PRINT,x.PRINTF,x.IF,x.WHILE,x.DO,x.FOR,x.RETURN]).has(this.lastTokenType)}readString(){let e=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let s=this.advance();switch(s){case"n":n+=`
241
241
  `;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;case'"':n+='"';break;case"/":n+="/";break;default:n+=s}}else n+=this.advance();return this.peek()==='"'&&this.advance(),{type:x.STRING,value:n,line:e,column:r}}readRegex(){let e=this.line,r=this.column;this.advance();let n="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")n+=this.advance(),this.pos<this.input.length&&(n+=this.advance());else{if(this.peek()===`
242
- `)break;n+=this.advance()}return this.peek()==="/"&&this.advance(),n=Jp(n),{type:x.REGEX,value:n,line:e,column:r}}readNumber(){let e=this.line,r=this.column,n="";for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(n+=this.advance();this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(n+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(n+=this.advance());this.isDigit(this.peek());)n+=this.advance();return{type:x.NUMBER,value:parseFloat(n),line:e,column:r}}readIdentifier(){let e=this.line,r=this.column,n="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)n+=this.advance();let s=Xp[n];return s?{type:s,value:n,line:e,column:r}:{type:x.IDENT,value:n,line:e,column:r}}readOperator(){let e=this.line,r=this.column,n=this.advance(),s=this.peek();switch(n){case"+":return s==="+"?(this.advance(),{type:x.INCREMENT,value:"++",line:e,column:r}):s==="="?(this.advance(),{type:x.PLUS_ASSIGN,value:"+=",line:e,column:r}):{type:x.PLUS,value:"+",line:e,column:r};case"-":return s==="-"?(this.advance(),{type:x.DECREMENT,value:"--",line:e,column:r}):s==="="?(this.advance(),{type:x.MINUS_ASSIGN,value:"-=",line:e,column:r}):{type:x.MINUS,value:"-",line:e,column:r};case"*":return s==="*"?(this.advance(),{type:x.CARET,value:"**",line:e,column:r}):s==="="?(this.advance(),{type:x.STAR_ASSIGN,value:"*=",line:e,column:r}):{type:x.STAR,value:"*",line:e,column:r};case"/":return s==="="?(this.advance(),{type:x.SLASH_ASSIGN,value:"/=",line:e,column:r}):{type:x.SLASH,value:"/",line:e,column:r};case"%":return s==="="?(this.advance(),{type:x.PERCENT_ASSIGN,value:"%=",line:e,column:r}):{type:x.PERCENT,value:"%",line:e,column:r};case"^":return s==="="?(this.advance(),{type:x.CARET_ASSIGN,value:"^=",line:e,column:r}):{type:x.CARET,value:"^",line:e,column:r};case"=":return s==="="?(this.advance(),{type:x.EQ,value:"==",line:e,column:r}):{type:x.ASSIGN,value:"=",line:e,column:r};case"!":return s==="="?(this.advance(),{type:x.NE,value:"!=",line:e,column:r}):s==="~"?(this.advance(),{type:x.NOT_MATCH,value:"!~",line:e,column:r}):{type:x.NOT,value:"!",line:e,column:r};case"<":return s==="="?(this.advance(),{type:x.LE,value:"<=",line:e,column:r}):{type:x.LT,value:"<",line:e,column:r};case">":return s==="="?(this.advance(),{type:x.GE,value:">=",line:e,column:r}):s===">"?(this.advance(),{type:x.APPEND,value:">>",line:e,column:r}):{type:x.GT,value:">",line:e,column:r};case"&":return s==="&"?(this.advance(),{type:x.AND,value:"&&",line:e,column:r}):{type:x.IDENT,value:"&",line:e,column:r};case"|":return s==="|"?(this.advance(),{type:x.OR,value:"||",line:e,column:r}):{type:x.PIPE,value:"|",line:e,column:r};case"~":return{type:x.MATCH,value:"~",line:e,column:r};case"?":return{type:x.QUESTION,value:"?",line:e,column:r};case":":return{type:x.COLON,value:":",line:e,column:r};case",":return{type:x.COMMA,value:",",line:e,column:r};case";":return{type:x.SEMICOLON,value:";",line:e,column:r};case"(":return{type:x.LPAREN,value:"(",line:e,column:r};case")":return{type:x.RPAREN,value:")",line:e,column:r};case"{":return{type:x.LBRACE,value:"{",line:e,column:r};case"}":return{type:x.RBRACE,value:"}",line:e,column:r};case"[":return{type:x.LBRACKET,value:"[",line:e,column:r};case"]":return{type:x.RBRACKET,value:"]",line:e,column:r};case"$":return{type:x.DOLLAR,value:"$",line:e,column:r};default:return{type:x.IDENT,value:n,line:e,column:r}}}isDigit(e){return e>="0"&&e<="9"}isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}}});var $r,zo=C(()=>{"use strict";jo();$r=class{tokens=[];pos=0;parse(e){let r=new vr(e);return this.tokens=r.tokenize(),this.pos=0,this.parseProgram()}current(){return this.tokens[this.pos]||{type:x.EOF,value:"",line:0,column:0}}advance(){let e=this.current();return this.pos<this.tokens.length&&this.pos++,e}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,r){if(!this.check(e)){let n=this.current();throw new Error(r||`Expected ${e}, got ${n.type} at line ${n.line}:${n.column}`)}return this.advance()}skipNewlines(){for(;this.check(x.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(x.NEWLINE)||this.check(x.SEMICOLON);)this.advance()}parseProgram(){let e=[],r=[];for(this.skipNewlines();!this.check(x.EOF)&&(this.skipNewlines(),!this.check(x.EOF));)this.check(x.FUNCTION)?e.push(this.parseFunction()):r.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:r}}parseFunction(){this.expect(x.FUNCTION);let e=this.expect(x.IDENT).value;this.expect(x.LPAREN);let r=[];if(!this.check(x.RPAREN))for(r.push(this.expect(x.IDENT).value);this.check(x.COMMA);)this.advance(),r.push(this.expect(x.IDENT).value);this.expect(x.RPAREN),this.skipNewlines();let n=this.parseBlock();return{name:e,params:r,body:n}}parseRule(){let e;if(this.check(x.BEGIN))this.advance(),e={type:"begin"};else if(this.check(x.END))this.advance(),e={type:"end"};else if(this.check(x.LBRACE))e=void 0;else if(this.check(x.REGEX)){let n=this.advance();if(this.check(x.AND)||this.check(x.OR)){let s={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:n.value}};e={type:"expr_pattern",expression:this.parseLogicalOrRest(s)}}else{let s={type:"regex_pattern",pattern:n.value};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}}else{let s={type:"expr_pattern",expression:this.parseExpression()};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}this.skipNewlines();let r;return this.check(x.LBRACE)?r=this.parseBlock():r={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:e,action:r}}parseBlock(){this.expect(x.LBRACE),this.skipNewlines();let e=[];for(;!this.check(x.RBRACE)&&!this.check(x.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(x.RBRACE),{type:"block",statements:e}}parseStatement(){if(this.check(x.LBRACE))return this.parseBlock();if(this.check(x.IF))return this.parseIf();if(this.check(x.WHILE))return this.parseWhile();if(this.check(x.DO))return this.parseDoWhile();if(this.check(x.FOR))return this.parseFor();if(this.check(x.BREAK))return this.advance(),{type:"break"};if(this.check(x.CONTINUE))return this.advance(),{type:"continue"};if(this.check(x.NEXT))return this.advance(),{type:"next"};if(this.check(x.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(x.EXIT)){this.advance();let r;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(r=this.parseExpression()),{type:"exit",code:r}}if(this.check(x.RETURN)){this.advance();let r;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(r=this.parseExpression()),{type:"return",value:r}}if(this.check(x.DELETE)){this.advance();let r=this.parsePrimary();if(r.type!=="array_access"&&r.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:r}}return this.check(x.PRINT)?this.parsePrint():this.check(x.PRINTF)?this.parsePrintf():{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(x.IF),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let r=this.parseStatement();this.skipTerminators();let n;return this.check(x.ELSE)&&(this.advance(),this.skipNewlines(),n=this.parseStatement()),{type:"if",condition:e,consequent:r,alternate:n}}parseWhile(){this.expect(x.WHILE),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let r=this.parseStatement();return{type:"while",condition:e,body:r}}parseDoWhile(){this.expect(x.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(x.WHILE),this.expect(x.LPAREN);let r=this.parseExpression();return this.expect(x.RPAREN),{type:"do_while",body:e,condition:r}}parseFor(){if(this.expect(x.FOR),this.expect(x.LPAREN),this.check(x.IDENT)){let i=this.advance();if(this.check(x.IN)){this.advance();let o=this.expect(x.IDENT).value;this.expect(x.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for_in",variable:i.value,array:o,body:a}}this.pos--}let e;this.check(x.SEMICOLON)||(e=this.parseExpression()),this.expect(x.SEMICOLON);let r;this.check(x.SEMICOLON)||(r=this.parseExpression()),this.expect(x.SEMICOLON);let n;this.check(x.RPAREN)||(n=this.parseExpression()),this.expect(x.RPAREN),this.skipNewlines();let s=this.parseStatement();return{type:"for",init:e,condition:r,update:n,body:s}}parsePrint(){this.expect(x.PRINT);let e=[];if(this.check(x.NEWLINE)||this.check(x.SEMICOLON)||this.check(x.RBRACE)||this.check(x.PIPE)||this.check(x.GT)||this.check(x.APPEND))e.push({type:"field",index:{type:"number",value:0}});else for(e.push(this.parsePrintArg());this.check(x.COMMA);)this.advance(),e.push(this.parsePrintArg());let r;return this.check(x.GT)?(this.advance(),r={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),r={redirect:">>",file:this.parsePrimary()}),{type:"print",args:e,output:r}}parsePrintArg(){return this.lookAheadForTernary()?this.parseTernary():this.parsePrintOr()}lookAheadForTernary(){let e=0,r=this.pos;for(;r<this.tokens.length;){let n=this.tokens[r];if(n.type===x.LPAREN&&e++,n.type===x.RPAREN&&e--,n.type===x.QUESTION&&e===0)return!0;if(n.type===x.NEWLINE||n.type===x.SEMICOLON||n.type===x.RBRACE||n.type===x.COMMA||n.type===x.PIPE)return!1;r++}return!1}parsePrintOr(){let e=this.parsePrintAnd();for(;this.check(x.OR);){this.advance();let r=this.parsePrintAnd();e={type:"binary",operator:"||",left:e,right:r}}return e}parsePrintAnd(){let e=this.parsePrintIn();for(;this.check(x.AND);){this.advance();let r=this.parsePrintIn();e={type:"binary",operator:"&&",left:e,right:r}}return e}parsePrintIn(){let e=this.parsePrintMatch();if(this.check(x.IN)){this.advance();let r=String(this.expect(x.IDENT).value);return{type:"in",key:e,array:r}}return e}parsePrintMatch(){let e=this.parsePrintComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let r=this.advance().type===x.MATCH?"~":"!~",n=this.parsePrintComparison();e={type:"binary",operator:r,left:e,right:n}}return e}parsePrintComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GE,x.EQ,x.NE);){let r=this.advance(),n=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">=":">=","==":"==","!=":"!="}[r.value],left:e,right:n}}return e}parsePrintf(){this.expect(x.PRINTF);let e=this.parsePrintArg(),r=[];for(;this.check(x.COMMA);)this.advance(),r.push(this.parsePrintArg());let n;return this.check(x.GT)?(this.advance(),n={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),n={redirect:">>",file:this.parsePrimary()}),{type:"printf",format:e,args:r,output:n}}parseExpression(){return this.parseAssignment()}parseAssignment(){let e=this.parseTernary();if(this.match(x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN)){let r=this.advance(),n=this.parseAssignment();if(e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[r.value],target:e,value:n}}return e}parseTernary(){let e=this.parseOr();if(this.check(x.QUESTION)){this.advance();let r=this.parseExpression();this.expect(x.COLON);let n=this.parseExpression();e={type:"ternary",condition:e,consequent:r,alternate:n}}return e}parseOr(){let e=this.parseAnd();for(;this.check(x.OR);){this.advance();let r=this.parseAnd();e={type:"binary",operator:"||",left:e,right:r}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(x.OR);){this.advance();let r=this.parseAnd();e={type:"binary",operator:"||",left:e,right:r}}return e}parseLogicalAndRest(e){for(;this.check(x.AND);){this.advance();let r=this.parseIn();e={type:"binary",operator:"&&",left:e,right:r}}return e}parseAnd(){let e=this.parseIn();for(;this.check(x.AND);){this.advance();let r=this.parseIn();e={type:"binary",operator:"&&",left:e,right:r}}return e}parseIn(){let e=this.parseMatch();if(this.check(x.IN)){this.advance();let r=this.expect(x.IDENT).value;return{type:"in",key:e,array:r}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let r=this.advance().type===x.MATCH?"~":"!~",n=this.parseComparison();e={type:"binary",operator:r,left:e,right:n}}return e}parseComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE);){let r=this.advance(),n=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">":">",">=":">=","==":"==","!=":"!="}[r.value],left:e,right:n}}return e}parseConcatenation(){let e=this.parseAddSub();for(;this.canStartExpression()&&!this.isComparisonOrHigherOp();){let r=this.parseAddSub();e={type:"binary",operator:" ",left:e,right:r}}return e}canStartExpression(){return this.match(x.NUMBER,x.STRING,x.IDENT,x.DOLLAR,x.LPAREN,x.NOT,x.MINUS,x.PLUS,x.INCREMENT,x.DECREMENT)}isComparisonOrHigherOp(){return this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE,x.AND,x.OR,x.QUESTION,x.MATCH,x.NOT_MATCH,x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN,x.COMMA,x.SEMICOLON,x.NEWLINE,x.RBRACE,x.RPAREN,x.RBRACKET,x.COLON,x.PIPE,x.APPEND,x.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(x.PLUS,x.MINUS);){let r=this.advance().value,n=this.parseMulDiv();e={type:"binary",operator:r,left:e,right:n}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(x.STAR,x.SLASH,x.PERCENT);){let r=this.advance(),n=this.parseUnary();e={type:"binary",operator:{"*":"*","/":"/","%":"%"}[r.value],left:e,right:n}}return e}parseUnary(){if(this.check(x.INCREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:e}}:{type:"pre_increment",operand:e}}if(this.check(x.DECREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:e}}:{type:"pre_decrement",operand:e}}if(this.match(x.NOT,x.MINUS,x.PLUS)){let e=this.advance().value,r=this.parseUnary();return{type:"unary",operator:e,operand:r}}return this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(x.CARET)){this.advance();let r=this.parsePower();e={type:"binary",operator:"^",left:e,right:r}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(x.INCREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:e}}if(this.check(x.DECREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:e}}return e}parsePrimary(){if(this.check(x.NUMBER))return{type:"number",value:this.advance().value};if(this.check(x.STRING))return{type:"string",value:this.advance().value};if(this.check(x.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(x.DOLLAR))return this.advance(),{type:"field",index:this.parsePrimary()};if(this.check(x.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(x.COMMA)){let r=[e];for(;this.check(x.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(x.RPAREN),{type:"tuple",elements:r}}return this.expect(x.RPAREN),e}if(this.check(x.GETLINE)){this.advance();let e,r;return this.check(x.IDENT)&&(e=this.advance().value),this.check(x.LT)&&(this.advance(),r=this.parsePrimary()),{type:"getline",variable:e,file:r}}if(this.check(x.IDENT)){let e=this.advance().value;if(this.check(x.LPAREN)){this.advance();let r=[];if(!this.check(x.RPAREN))for(r.push(this.parseExpression());this.check(x.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(x.RPAREN),{type:"call",name:e,args:r}}if(this.check(x.LBRACKET)){this.advance();let r=[this.parseExpression()];for(;this.check(x.COMMA);)this.advance(),r.push(this.parseExpression());this.expect(x.RBRACKET);let n;if(r.length===1)n=r[0];else{n=r[0];for(let s=1;s<r.length;s++)n={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:n,right:{type:"variable",name:"SUBSEP"}},right:r[s]}}return{type:"array_access",array:e,key:n}}return{type:"variable",name:e}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}}});var Vo={};v(Vo,{awkCommand2:()=>eh});function Ho(t){return t.replace(/\\t/g," ").replace(/\\n/g,`
243
- `).replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function Go(t){if(t===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(t))try{return new RegExp(t)}catch{return new RegExp(qo(t))}return new RegExp(qo(t))}function qo(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Yp,eh,Ko=C(()=>{"use strict";X();O();Uo();zo();Yp={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},eh={name:"awk",async execute(t,e){if(I(t))return N(Yp);let r=/\s+/,n=" ",s={},i=0;for(let p=0;p<t.length;p++){let h=t[p];if(h==="-F"&&p+1<t.length)n=Ho(t[++p]),r=Go(n),i=p+1;else if(h.startsWith("-F"))n=Ho(h.slice(2)),r=Go(n),i=p+1;else if(h==="-v"&&p+1<t.length){let y=t[++p],m=y.indexOf("=");if(m>0){let w=y.slice(0,m),b=y.slice(m+1);s[w]=b}i=p+1}else{if(h.startsWith("--"))return $("awk",h);if(h.startsWith("-")&&h.length>1){let y=h[1];if(y!=="F"&&y!=="v")return $("awk",`-${y}`);i=p+1}else if(!h.startsWith("-")){i=p;break}}}if(i>=t.length)return{stdout:"",stderr:`awk: missing program
244
- `,exitCode:1};let o=t[i],a=t.slice(i+1),l=new $r,c;try{c=l.parse(o)}catch(p){return{stdout:"",stderr:`awk: ${p instanceof Error?p.message:String(p)}
245
- `,exitCode:1}}let u={readFile:e.fs.readFile.bind(e.fs),writeFile:e.fs.writeFile.bind(e.fs),appendFile:async(p,h)=>{try{let y=await e.fs.readFile(p);await e.fs.writeFile(p,y+h)}catch{await e.fs.writeFile(p,h)}},resolvePath:e.fs.resolvePath.bind(e.fs)},f=Mn({fieldSep:r,maxIterations:e.limits?.maxAwkIterations,fs:u,cwd:e.cwd});f.FS=n,f.vars={...s},f.ARGC=a.length+1,f.ARGV={0:"awk"};for(let p=0;p<a.length;p++)f.ARGV[String(p+1)]=a[p];let d=new Jt(f);d.execute(c);try{if(await d.executeBegin(),f.shouldExit)return{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()};let p=[];if(a.length>0)for(let h of a)try{let y=e.fs.resolvePath(e.cwd,h),w=(await e.fs.readFile(y)).split(`
246
- `);w.length>0&&w[w.length-1]===""&&w.pop(),p.push({filename:h,lines:w})}catch{return{stdout:"",stderr:`awk: ${h}: No such file or directory
242
+ `)break;n+=this.advance()}return this.peek()==="/"&&this.advance(),n=oh(n),{type:x.REGEX,value:n,line:e,column:r}}readNumber(){let e=this.line,r=this.column,n="";for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(n+=this.advance();this.isDigit(this.peek());)n+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(n+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(n+=this.advance());this.isDigit(this.peek());)n+=this.advance();return{type:x.NUMBER,value:parseFloat(n),line:e,column:r}}readIdentifier(){let e=this.line,r=this.column,n="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)n+=this.advance();let s=ih[n];return s?{type:s,value:n,line:e,column:r}:{type:x.IDENT,value:n,line:e,column:r}}readOperator(){let e=this.line,r=this.column,n=this.advance(),s=this.peek();switch(n){case"+":return s==="+"?(this.advance(),{type:x.INCREMENT,value:"++",line:e,column:r}):s==="="?(this.advance(),{type:x.PLUS_ASSIGN,value:"+=",line:e,column:r}):{type:x.PLUS,value:"+",line:e,column:r};case"-":return s==="-"?(this.advance(),{type:x.DECREMENT,value:"--",line:e,column:r}):s==="="?(this.advance(),{type:x.MINUS_ASSIGN,value:"-=",line:e,column:r}):{type:x.MINUS,value:"-",line:e,column:r};case"*":return s==="*"?(this.advance(),{type:x.CARET,value:"**",line:e,column:r}):s==="="?(this.advance(),{type:x.STAR_ASSIGN,value:"*=",line:e,column:r}):{type:x.STAR,value:"*",line:e,column:r};case"/":return s==="="?(this.advance(),{type:x.SLASH_ASSIGN,value:"/=",line:e,column:r}):{type:x.SLASH,value:"/",line:e,column:r};case"%":return s==="="?(this.advance(),{type:x.PERCENT_ASSIGN,value:"%=",line:e,column:r}):{type:x.PERCENT,value:"%",line:e,column:r};case"^":return s==="="?(this.advance(),{type:x.CARET_ASSIGN,value:"^=",line:e,column:r}):{type:x.CARET,value:"^",line:e,column:r};case"=":return s==="="?(this.advance(),{type:x.EQ,value:"==",line:e,column:r}):{type:x.ASSIGN,value:"=",line:e,column:r};case"!":return s==="="?(this.advance(),{type:x.NE,value:"!=",line:e,column:r}):s==="~"?(this.advance(),{type:x.NOT_MATCH,value:"!~",line:e,column:r}):{type:x.NOT,value:"!",line:e,column:r};case"<":return s==="="?(this.advance(),{type:x.LE,value:"<=",line:e,column:r}):{type:x.LT,value:"<",line:e,column:r};case">":return s==="="?(this.advance(),{type:x.GE,value:">=",line:e,column:r}):s===">"?(this.advance(),{type:x.APPEND,value:">>",line:e,column:r}):{type:x.GT,value:">",line:e,column:r};case"&":return s==="&"?(this.advance(),{type:x.AND,value:"&&",line:e,column:r}):{type:x.IDENT,value:"&",line:e,column:r};case"|":return s==="|"?(this.advance(),{type:x.OR,value:"||",line:e,column:r}):{type:x.PIPE,value:"|",line:e,column:r};case"~":return{type:x.MATCH,value:"~",line:e,column:r};case"?":return{type:x.QUESTION,value:"?",line:e,column:r};case":":return{type:x.COLON,value:":",line:e,column:r};case",":return{type:x.COMMA,value:",",line:e,column:r};case";":return{type:x.SEMICOLON,value:";",line:e,column:r};case"(":return{type:x.LPAREN,value:"(",line:e,column:r};case")":return{type:x.RPAREN,value:")",line:e,column:r};case"{":return{type:x.LBRACE,value:"{",line:e,column:r};case"}":return{type:x.RBRACE,value:"}",line:e,column:r};case"[":return{type:x.LBRACKET,value:"[",line:e,column:r};case"]":return{type:x.RBRACKET,value:"]",line:e,column:r};case"$":return{type:x.DOLLAR,value:"$",line:e,column:r};default:return{type:x.IDENT,value:n,line:e,column:r}}}isDigit(e){return e>="0"&&e<="9"}isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}}});var Br,Xo=C(()=>{"use strict";Qo();Br=class{tokens=[];pos=0;parse(e){let r=new _r(e);return this.tokens=r.tokenize(),this.pos=0,this.parseProgram()}current(){return this.tokens[this.pos]||{type:x.EOF,value:"",line:0,column:0}}advance(){let e=this.current();return this.pos<this.tokens.length&&this.pos++,e}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,r){if(!this.check(e)){let n=this.current();throw new Error(r||`Expected ${e}, got ${n.type} at line ${n.line}:${n.column}`)}return this.advance()}skipNewlines(){for(;this.check(x.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(x.NEWLINE)||this.check(x.SEMICOLON);)this.advance()}parseProgram(){let e=[],r=[];for(this.skipNewlines();!this.check(x.EOF)&&(this.skipNewlines(),!this.check(x.EOF));)this.check(x.FUNCTION)?e.push(this.parseFunction()):r.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:r}}parseFunction(){this.expect(x.FUNCTION);let e=this.expect(x.IDENT).value;this.expect(x.LPAREN);let r=[];if(!this.check(x.RPAREN))for(r.push(this.expect(x.IDENT).value);this.check(x.COMMA);)this.advance(),r.push(this.expect(x.IDENT).value);this.expect(x.RPAREN),this.skipNewlines();let n=this.parseBlock();return{name:e,params:r,body:n}}parseRule(){let e;if(this.check(x.BEGIN))this.advance(),e={type:"begin"};else if(this.check(x.END))this.advance(),e={type:"end"};else if(this.check(x.LBRACE))e=void 0;else if(this.check(x.REGEX)){let n=this.advance();if(this.check(x.AND)||this.check(x.OR)){let s={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:n.value}};e={type:"expr_pattern",expression:this.parseLogicalOrRest(s)}}else{let s={type:"regex_pattern",pattern:n.value};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}}else{let s={type:"expr_pattern",expression:this.parseExpression()};if(this.check(x.COMMA)){this.advance();let i;this.check(x.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},e={type:"range",start:s,end:i}}else e=s}this.skipNewlines();let r;return this.check(x.LBRACE)?r=this.parseBlock():r={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:e,action:r}}parseBlock(){this.expect(x.LBRACE),this.skipNewlines();let e=[];for(;!this.check(x.RBRACE)&&!this.check(x.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(x.RBRACE),{type:"block",statements:e}}parseStatement(){if(this.check(x.LBRACE))return this.parseBlock();if(this.check(x.IF))return this.parseIf();if(this.check(x.WHILE))return this.parseWhile();if(this.check(x.DO))return this.parseDoWhile();if(this.check(x.FOR))return this.parseFor();if(this.check(x.BREAK))return this.advance(),{type:"break"};if(this.check(x.CONTINUE))return this.advance(),{type:"continue"};if(this.check(x.NEXT))return this.advance(),{type:"next"};if(this.check(x.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(x.EXIT)){this.advance();let r;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(r=this.parseExpression()),{type:"exit",code:r}}if(this.check(x.RETURN)){this.advance();let r;return!this.check(x.NEWLINE)&&!this.check(x.SEMICOLON)&&!this.check(x.RBRACE)&&!this.check(x.EOF)&&(r=this.parseExpression()),{type:"return",value:r}}if(this.check(x.DELETE)){this.advance();let r=this.parsePrimary();if(r.type!=="array_access"&&r.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:r}}return this.check(x.PRINT)?this.parsePrint():this.check(x.PRINTF)?this.parsePrintf():{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(x.IF),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let r=this.parseStatement();this.skipTerminators();let n;return this.check(x.ELSE)&&(this.advance(),this.skipNewlines(),n=this.parseStatement()),{type:"if",condition:e,consequent:r,alternate:n}}parseWhile(){this.expect(x.WHILE),this.expect(x.LPAREN);let e=this.parseExpression();this.expect(x.RPAREN),this.skipNewlines();let r=this.parseStatement();return{type:"while",condition:e,body:r}}parseDoWhile(){this.expect(x.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(x.WHILE),this.expect(x.LPAREN);let r=this.parseExpression();return this.expect(x.RPAREN),{type:"do_while",body:e,condition:r}}parseFor(){if(this.expect(x.FOR),this.expect(x.LPAREN),this.check(x.IDENT)){let i=this.advance();if(this.check(x.IN)){this.advance();let o=this.expect(x.IDENT).value;this.expect(x.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for_in",variable:i.value,array:o,body:a}}this.pos--}let e;this.check(x.SEMICOLON)||(e=this.parseExpression()),this.expect(x.SEMICOLON);let r;this.check(x.SEMICOLON)||(r=this.parseExpression()),this.expect(x.SEMICOLON);let n;this.check(x.RPAREN)||(n=this.parseExpression()),this.expect(x.RPAREN),this.skipNewlines();let s=this.parseStatement();return{type:"for",init:e,condition:r,update:n,body:s}}parsePrint(){this.expect(x.PRINT);let e=[];if(this.check(x.NEWLINE)||this.check(x.SEMICOLON)||this.check(x.RBRACE)||this.check(x.PIPE)||this.check(x.GT)||this.check(x.APPEND))e.push({type:"field",index:{type:"number",value:0}});else for(e.push(this.parsePrintArg());this.check(x.COMMA);)this.advance(),e.push(this.parsePrintArg());let r;return this.check(x.GT)?(this.advance(),r={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),r={redirect:">>",file:this.parsePrimary()}),{type:"print",args:e,output:r}}parsePrintArg(){return this.lookAheadForTernary()?this.parseTernary():this.parsePrintOr()}lookAheadForTernary(){let e=0,r=this.pos;for(;r<this.tokens.length;){let n=this.tokens[r];if(n.type===x.LPAREN&&e++,n.type===x.RPAREN&&e--,n.type===x.QUESTION&&e===0)return!0;if(n.type===x.NEWLINE||n.type===x.SEMICOLON||n.type===x.RBRACE||n.type===x.COMMA||n.type===x.PIPE)return!1;r++}return!1}parsePrintOr(){let e=this.parsePrintAnd();for(;this.check(x.OR);){this.advance();let r=this.parsePrintAnd();e={type:"binary",operator:"||",left:e,right:r}}return e}parsePrintAnd(){let e=this.parsePrintIn();for(;this.check(x.AND);){this.advance();let r=this.parsePrintIn();e={type:"binary",operator:"&&",left:e,right:r}}return e}parsePrintIn(){let e=this.parsePrintMatch();if(this.check(x.IN)){this.advance();let r=String(this.expect(x.IDENT).value);return{type:"in",key:e,array:r}}return e}parsePrintMatch(){let e=this.parsePrintComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let r=this.advance().type===x.MATCH?"~":"!~",n=this.parsePrintComparison();e={type:"binary",operator:r,left:e,right:n}}return e}parsePrintComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GE,x.EQ,x.NE);){let r=this.advance(),n=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">=":">=","==":"==","!=":"!="}[r.value],left:e,right:n}}return e}parsePrintf(){this.expect(x.PRINTF);let e=this.parsePrintArg(),r=[];for(;this.check(x.COMMA);)this.advance(),r.push(this.parsePrintArg());let n;return this.check(x.GT)?(this.advance(),n={redirect:">",file:this.parsePrimary()}):this.check(x.APPEND)&&(this.advance(),n={redirect:">>",file:this.parsePrimary()}),{type:"printf",format:e,args:r,output:n}}parseExpression(){return this.parseAssignment()}parseAssignment(){let e=this.parseTernary();if(this.match(x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN)){let r=this.advance(),n=this.parseAssignment();if(e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[r.value],target:e,value:n}}return e}parseTernary(){let e=this.parseOr();if(this.check(x.QUESTION)){this.advance();let r=this.parseExpression();this.expect(x.COLON);let n=this.parseExpression();e={type:"ternary",condition:e,consequent:r,alternate:n}}return e}parseOr(){let e=this.parseAnd();for(;this.check(x.OR);){this.advance();let r=this.parseAnd();e={type:"binary",operator:"||",left:e,right:r}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(x.OR);){this.advance();let r=this.parseAnd();e={type:"binary",operator:"||",left:e,right:r}}return e}parseLogicalAndRest(e){for(;this.check(x.AND);){this.advance();let r=this.parseIn();e={type:"binary",operator:"&&",left:e,right:r}}return e}parseAnd(){let e=this.parseIn();for(;this.check(x.AND);){this.advance();let r=this.parseIn();e={type:"binary",operator:"&&",left:e,right:r}}return e}parseIn(){let e=this.parseMatch();if(this.check(x.IN)){this.advance();let r=this.expect(x.IDENT).value;return{type:"in",key:e,array:r}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(x.MATCH,x.NOT_MATCH);){let r=this.advance().type===x.MATCH?"~":"!~",n=this.parseComparison();e={type:"binary",operator:r,left:e,right:n}}return e}parseComparison(){let e=this.parseConcatenation();for(;this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE);){let r=this.advance(),n=this.parseConcatenation();e={type:"binary",operator:{"<":"<","<=":"<=",">":">",">=":">=","==":"==","!=":"!="}[r.value],left:e,right:n}}return e}parseConcatenation(){let e=this.parseAddSub();for(;this.canStartExpression()&&!this.isComparisonOrHigherOp();){let r=this.parseAddSub();e={type:"binary",operator:" ",left:e,right:r}}return e}canStartExpression(){return this.match(x.NUMBER,x.STRING,x.IDENT,x.DOLLAR,x.LPAREN,x.NOT,x.MINUS,x.PLUS,x.INCREMENT,x.DECREMENT)}isComparisonOrHigherOp(){return this.match(x.LT,x.LE,x.GT,x.GE,x.EQ,x.NE,x.AND,x.OR,x.QUESTION,x.MATCH,x.NOT_MATCH,x.ASSIGN,x.PLUS_ASSIGN,x.MINUS_ASSIGN,x.STAR_ASSIGN,x.SLASH_ASSIGN,x.PERCENT_ASSIGN,x.CARET_ASSIGN,x.COMMA,x.SEMICOLON,x.NEWLINE,x.RBRACE,x.RPAREN,x.RBRACKET,x.COLON,x.PIPE,x.APPEND,x.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(x.PLUS,x.MINUS);){let r=this.advance().value,n=this.parseMulDiv();e={type:"binary",operator:r,left:e,right:n}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(x.STAR,x.SLASH,x.PERCENT);){let r=this.advance(),n=this.parseUnary();e={type:"binary",operator:{"*":"*","/":"/","%":"%"}[r.value],left:e,right:n}}return e}parseUnary(){if(this.check(x.INCREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:e}}:{type:"pre_increment",operand:e}}if(this.check(x.DECREMENT)){this.advance();let e=this.parseUnary();return e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:e}}:{type:"pre_decrement",operand:e}}if(this.match(x.NOT,x.MINUS,x.PLUS)){let e=this.advance().value,r=this.parseUnary();return{type:"unary",operator:e,operand:r}}return this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(x.CARET)){this.advance();let r=this.parsePower();e={type:"binary",operator:"^",left:e,right:r}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(x.INCREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:e}}if(this.check(x.DECREMENT)){if(this.advance(),e.type!=="variable"&&e.type!=="field"&&e.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:e}}return e}parsePrimary(){if(this.check(x.NUMBER))return{type:"number",value:this.advance().value};if(this.check(x.STRING))return{type:"string",value:this.advance().value};if(this.check(x.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(x.DOLLAR))return this.advance(),{type:"field",index:this.parsePrimary()};if(this.check(x.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(x.COMMA)){let r=[e];for(;this.check(x.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(x.RPAREN),{type:"tuple",elements:r}}return this.expect(x.RPAREN),e}if(this.check(x.GETLINE)){this.advance();let e,r;return this.check(x.IDENT)&&(e=this.advance().value),this.check(x.LT)&&(this.advance(),r=this.parsePrimary()),{type:"getline",variable:e,file:r}}if(this.check(x.IDENT)){let e=this.advance().value;if(this.check(x.LPAREN)){this.advance();let r=[];if(!this.check(x.RPAREN))for(r.push(this.parseExpression());this.check(x.COMMA);)this.advance(),r.push(this.parseExpression());return this.expect(x.RPAREN),{type:"call",name:e,args:r}}if(this.check(x.LBRACKET)){this.advance();let r=[this.parseExpression()];for(;this.check(x.COMMA);)this.advance(),r.push(this.parseExpression());this.expect(x.RBRACKET);let n;if(r.length===1)n=r[0];else{n=r[0];for(let s=1;s<r.length;s++)n={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:n,right:{type:"variable",name:"SUBSEP"}},right:r[s]}}return{type:"array_access",array:e,key:n}}return{type:"variable",name:e}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}}});var ta={};R(ta,{awkCommand2:()=>lh});function Jo(t){return t.replace(/\\t/g," ").replace(/\\n/g,`
243
+ `).replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function Yo(t){if(t===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(t))try{return new RegExp(t)}catch{return new RegExp(ea(t))}return new RegExp(ea(t))}function ea(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var ah,lh,ra=C(()=>{"use strict";oe();L();Zo();Xo();ah={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},lh={name:"awk",async execute(t,e){if(N(t))return k(ah);let r=/\s+/,n=" ",s={},i=0;for(let d=0;d<t.length;d++){let h=t[d];if(h==="-F"&&d+1<t.length)n=Jo(t[++d]),r=Yo(n),i=d+1;else if(h.startsWith("-F"))n=Jo(h.slice(2)),r=Yo(n),i=d+1;else if(h==="-v"&&d+1<t.length){let m=t[++d],g=m.indexOf("=");if(g>0){let w=m.slice(0,g),b=m.slice(g+1);s[w]=b}i=d+1}else{if(h.startsWith("--"))return P("awk",h);if(h.startsWith("-")&&h.length>1){let m=h[1];if(m!=="F"&&m!=="v")return P("awk",`-${m}`);i=d+1}else if(!h.startsWith("-")){i=d;break}}}if(i>=t.length)return{stdout:"",stderr:`awk: missing program
244
+ `,exitCode:1};let o=t[i],a=t.slice(i+1),l=new Br,c;try{c=l.parse(o)}catch(d){return{stdout:"",stderr:`awk: ${d instanceof Error?d.message:String(d)}
245
+ `,exitCode:1}}let u={readFile:e.fs.readFile.bind(e.fs),writeFile:e.fs.writeFile.bind(e.fs),appendFile:async(d,h)=>{try{let m=await e.fs.readFile(d);await e.fs.writeFile(d,m+h)}catch{await e.fs.writeFile(d,h)}},resolvePath:e.fs.resolvePath.bind(e.fs)},f=Gn({fieldSep:r,maxIterations:e.limits?.maxAwkIterations,fs:u,cwd:e.cwd});f.FS=n,f.vars={...s},f.ARGC=a.length+1,f.ARGV={0:"awk"};for(let d=0;d<a.length;d++)f.ARGV[String(d+1)]=a[d];let p=new ar(f);p.execute(c);try{if(await p.executeBegin(),f.shouldExit)return{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()};let d=[];if(a.length>0)for(let h of a)try{let m=e.fs.resolvePath(e.cwd,h),w=(await e.fs.readFile(m)).split(`
246
+ `);w.length>0&&w[w.length-1]===""&&w.pop(),d.push({filename:h,lines:w})}catch{return{stdout:"",stderr:`awk: ${h}: No such file or directory
247
247
  `,exitCode:1}}else{let h=e.stdin.split(`
248
- `);h.length>0&&h[h.length-1]===""&&h.pop(),p.push({filename:"",lines:h})}for(let h of p){for(f.FILENAME=h.filename,f.FNR=0,f.lines=h.lines,f.lineIndex=-1,f.shouldNextFile=!1;f.lineIndex<h.lines.length-1&&(f.lineIndex++,await d.executeLine(h.lines[f.lineIndex]),!(f.shouldExit||f.shouldNextFile)););if(f.shouldExit)break}return f.shouldExit||await d.executeEnd(),{stdout:d.getOutput(),stderr:"",exitCode:d.getExitCode()}}catch(p){let h=p instanceof Error?p.message:String(p),y=p instanceof W?W.EXIT_CODE:2;return{stdout:d.getOutput(),stderr:`awk: ${h}
249
- `,exitCode:y}}}}});function Zo(t){let e=t.trim(),r=e.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!r){let o=parseFloat(e);return Number.isNaN(o)?0:o}let n=parseFloat(r[1]),s=(r[2]||"").toLowerCase(),i=th[s]||1;return n*i}function Qo(t){let e=t.trim().toLowerCase().slice(0,3);return rh[e]||0}function nh(t,e){let r=t.split(/(\d+)/),n=e.split(/(\d+)/),s=Math.max(r.length,n.length);for(let i=0;i<s;i++){let o=r[i]||"",a=n[i]||"",l=/^\d+$/.test(o)?parseInt(o,10):null,c=/^\d+$/.test(a)?parseInt(a,10):null;if(l!==null&&c!==null){if(l!==c)return l-c}else if(o!==a)return o.localeCompare(a)}return 0}function Xo(t){return t.replace(/[^a-zA-Z0-9\s]/g,"")}function qn(t,e,r){let n=r!==null?r:/\s+/,s=t.split(n),i=e.startField-1;if(i>=s.length)return"";if(e.endField===void 0){let l=s[i]||"";return e.startChar!==void 0&&(l=l.slice(e.startChar-1)),e.ignoreLeading&&(l=l.trimStart()),l}let o=Math.min(e.endField-1,s.length-1),a="";for(let l=i;l<=o&&l<s.length;l++){let c=s[l]||"";if(l===i&&e.startChar!==void 0&&(c=c.slice(e.startChar-1)),l===o&&e.endChar!==void 0){let u=l===i&&e.startChar!==void 0?e.endChar-e.startChar+1:e.endChar;c=c.slice(0,u)}l>i&&(a+=r||" "),a+=c}return e.ignoreLeading&&(a=a.trimStart()),a}function Jo(t,e,r){let n=t,s=e;if(r.dictionaryOrder&&(n=Xo(n),s=Xo(s)),r.ignoreCase&&(n=n.toLowerCase(),s=s.toLowerCase()),r.monthSort){let i=Qo(n),o=Qo(s);return i-o}if(r.humanNumeric){let i=Zo(n),o=Zo(s);return i-o}if(r.versionSort)return nh(n,s);if(r.numeric){let i=parseFloat(n)||0,o=parseFloat(s)||0;return i-o}return n.localeCompare(s)}function Yo(t){let{keys:e,fieldDelimiter:r,numeric:n,ignoreCase:s,reverse:i,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c,ignoreLeadingBlanks:u,stable:f}=t;return(d,p)=>{let h=d,y=p;if(u&&(h=h.trimStart(),y=y.trimStart()),e.length===0){let w=Jo(h,y,{numeric:n,ignoreCase:s,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c});if(w!==0)return i?-w:w;if(!f){let b=d.localeCompare(p);return i?-b:b}return 0}for(let m of e){let w=qn(h,m,r),b=qn(y,m,r);m.ignoreLeading&&(w=w.trimStart(),b=b.trimStart());let E={numeric:m.numeric??n,ignoreCase:m.ignoreCase??s,humanNumeric:m.humanNumeric??o,versionSort:m.versionSort??a,dictionaryOrder:m.dictionaryOrder??l,monthSort:m.monthSort??c},S=m.reverse??i,A=Jo(w,b,E);if(A!==0)return S?-A:A}if(!f){let m=d.localeCompare(p);return i?-m:m}return 0}}function ea(t,e){if(e.keys.length===0){if(e.ignoreCase){let s=new Set;return t.filter(i=>{let o=i.toLowerCase();return s.has(o)?!1:(s.add(o),!0)})}return[...new Set(t)]}let r=e.keys[0],n=new Set;return t.filter(s=>{let i=qn(s,r,e.fieldDelimiter);return(r.ignoreCase??e.ignoreCase)&&(i=i.toLowerCase()),n.has(i)?!1:(n.add(i),!0)})}var th,rh,ta=C(()=>{"use strict";th={"":1,k:1024,m:1048576,g:1073741824,t:1099511627776,p:0x4000000000000,e:1152921504606847e3},rh={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}});function Rr(t){let e={startField:1},r="",n=t,s=n.match(/([bdfhMnrV]+)$/);s&&(r=s[1],n=n.slice(0,-r.length)),r.includes("n")&&(e.numeric=!0),r.includes("r")&&(e.reverse=!0),r.includes("f")&&(e.ignoreCase=!0),r.includes("b")&&(e.ignoreLeading=!0),r.includes("h")&&(e.humanNumeric=!0),r.includes("V")&&(e.versionSort=!0),r.includes("d")&&(e.dictionaryOrder=!0),r.includes("M")&&(e.monthSort=!0);let i=n.split(",");if(i.length===0||i[0]==="")return null;let o=i[0].split("."),a=parseInt(o[0],10);if(Number.isNaN(a)||a<1)return null;if(e.startField=a,o.length>1&&o[1]){let l=parseInt(o[1],10);!Number.isNaN(l)&&l>=1&&(e.startChar=l)}if(i.length>1&&i[1]){let l=i[1],c=l.match(/([bdfhMnrV]+)$/);if(c){let f=c[1];f.includes("n")&&(e.numeric=!0),f.includes("r")&&(e.reverse=!0),f.includes("f")&&(e.ignoreCase=!0),f.includes("b")&&(e.ignoreLeading=!0),f.includes("h")&&(e.humanNumeric=!0),f.includes("V")&&(e.versionSort=!0),f.includes("d")&&(e.dictionaryOrder=!0),f.includes("M")&&(e.monthSort=!0),l=l.slice(0,-f.length)}let u=l.split(".");if(u[0]){let f=parseInt(u[0],10);if(!Number.isNaN(f)&&f>=1&&(e.endField=f),u.length>1&&u[1]){let d=parseInt(u[1],10);!Number.isNaN(d)&&d>=1&&(e.endChar=d)}}}return e}var ra=C(()=>{"use strict"});var na={};v(na,{sortCommand:()=>ih});var sh,ih,sa=C(()=>{"use strict";Ct();O();ta();ra();sh={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
248
+ `);h.length>0&&h[h.length-1]===""&&h.pop(),d.push({filename:"",lines:h})}for(let h of d){for(f.FILENAME=h.filename,f.FNR=0,f.lines=h.lines,f.lineIndex=-1,f.shouldNextFile=!1;f.lineIndex<h.lines.length-1&&(f.lineIndex++,await p.executeLine(h.lines[f.lineIndex]),!(f.shouldExit||f.shouldNextFile)););if(f.shouldExit)break}return f.shouldExit||await p.executeEnd(),{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()}}catch(d){let h=d instanceof Error?d.message:String(d),m=d instanceof j?j.EXIT_CODE:2;return{stdout:p.getOutput(),stderr:`awk: ${h}
249
+ `,exitCode:m}}}}});function na(t){let e=t.trim(),r=e.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!r){let o=parseFloat(e);return Number.isNaN(o)?0:o}let n=parseFloat(r[1]),s=(r[2]||"").toLowerCase(),i=ch[s]||1;return n*i}function sa(t){let e=t.trim().toLowerCase().slice(0,3);return uh[e]||0}function fh(t,e){let r=t.split(/(\d+)/),n=e.split(/(\d+)/),s=Math.max(r.length,n.length);for(let i=0;i<s;i++){let o=r[i]||"",a=n[i]||"",l=/^\d+$/.test(o)?parseInt(o,10):null,c=/^\d+$/.test(a)?parseInt(a,10):null;if(l!==null&&c!==null){if(l!==c)return l-c}else if(o!==a)return o.localeCompare(a)}return 0}function ia(t){return t.replace(/[^a-zA-Z0-9\s]/g,"")}function es(t,e,r){let n=r!==null?r:/\s+/,s=t.split(n),i=e.startField-1;if(i>=s.length)return"";if(e.endField===void 0){let l=s[i]||"";return e.startChar!==void 0&&(l=l.slice(e.startChar-1)),e.ignoreLeading&&(l=l.trimStart()),l}let o=Math.min(e.endField-1,s.length-1),a="";for(let l=i;l<=o&&l<s.length;l++){let c=s[l]||"";if(l===i&&e.startChar!==void 0&&(c=c.slice(e.startChar-1)),l===o&&e.endChar!==void 0){let u=l===i&&e.startChar!==void 0?e.endChar-e.startChar+1:e.endChar;c=c.slice(0,u)}l>i&&(a+=r||" "),a+=c}return e.ignoreLeading&&(a=a.trimStart()),a}function oa(t,e,r){let n=t,s=e;if(r.dictionaryOrder&&(n=ia(n),s=ia(s)),r.ignoreCase&&(n=n.toLowerCase(),s=s.toLowerCase()),r.monthSort){let i=sa(n),o=sa(s);return i-o}if(r.humanNumeric){let i=na(n),o=na(s);return i-o}if(r.versionSort)return fh(n,s);if(r.numeric){let i=parseFloat(n)||0,o=parseFloat(s)||0;return i-o}return n.localeCompare(s)}function aa(t){let{keys:e,fieldDelimiter:r,numeric:n,ignoreCase:s,reverse:i,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c,ignoreLeadingBlanks:u,stable:f}=t;return(p,d)=>{let h=p,m=d;if(u&&(h=h.trimStart(),m=m.trimStart()),e.length===0){let w=oa(h,m,{numeric:n,ignoreCase:s,humanNumeric:o,versionSort:a,dictionaryOrder:l,monthSort:c});if(w!==0)return i?-w:w;if(!f){let b=p.localeCompare(d);return i?-b:b}return 0}for(let g of e){let w=es(h,g,r),b=es(m,g,r);g.ignoreLeading&&(w=w.trimStart(),b=b.trimStart());let E={numeric:g.numeric??n,ignoreCase:g.ignoreCase??s,humanNumeric:g.humanNumeric??o,versionSort:g.versionSort??a,dictionaryOrder:g.dictionaryOrder??l,monthSort:g.monthSort??c},S=g.reverse??i,v=oa(w,b,E);if(v!==0)return S?-v:v}if(!f){let g=p.localeCompare(d);return i?-g:g}return 0}}function la(t,e){if(e.keys.length===0){if(e.ignoreCase){let s=new Set;return t.filter(i=>{let o=i.toLowerCase();return s.has(o)?!1:(s.add(o),!0)})}return[...new Set(t)]}let r=e.keys[0],n=new Set;return t.filter(s=>{let i=es(s,r,e.fieldDelimiter);return(r.ignoreCase??e.ignoreCase)&&(i=i.toLowerCase()),n.has(i)?!1:(n.add(i),!0)})}var ch,uh,ca=C(()=>{"use strict";ch={"":1,k:1024,m:1048576,g:1073741824,t:1099511627776,p:0x4000000000000,e:1152921504606847e3},uh={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12}});function Wr(t){let e={startField:1},r="",n=t,s=n.match(/([bdfhMnrV]+)$/);s&&(r=s[1],n=n.slice(0,-r.length)),r.includes("n")&&(e.numeric=!0),r.includes("r")&&(e.reverse=!0),r.includes("f")&&(e.ignoreCase=!0),r.includes("b")&&(e.ignoreLeading=!0),r.includes("h")&&(e.humanNumeric=!0),r.includes("V")&&(e.versionSort=!0),r.includes("d")&&(e.dictionaryOrder=!0),r.includes("M")&&(e.monthSort=!0);let i=n.split(",");if(i.length===0||i[0]==="")return null;let o=i[0].split("."),a=parseInt(o[0],10);if(Number.isNaN(a)||a<1)return null;if(e.startField=a,o.length>1&&o[1]){let l=parseInt(o[1],10);!Number.isNaN(l)&&l>=1&&(e.startChar=l)}if(i.length>1&&i[1]){let l=i[1],c=l.match(/([bdfhMnrV]+)$/);if(c){let f=c[1];f.includes("n")&&(e.numeric=!0),f.includes("r")&&(e.reverse=!0),f.includes("f")&&(e.ignoreCase=!0),f.includes("b")&&(e.ignoreLeading=!0),f.includes("h")&&(e.humanNumeric=!0),f.includes("V")&&(e.versionSort=!0),f.includes("d")&&(e.dictionaryOrder=!0),f.includes("M")&&(e.monthSort=!0),l=l.slice(0,-f.length)}let u=l.split(".");if(u[0]){let f=parseInt(u[0],10);if(!Number.isNaN(f)&&f>=1&&(e.endField=f),u.length>1&&u[1]){let p=parseInt(u[1],10);!Number.isNaN(p)&&p>=1&&(e.endChar=p)}}}return e}var ua=C(()=>{"use strict"});var fa={};R(fa,{sortCommand:()=>dh});var ph,dh,pa=C(()=>{"use strict";gt();L();ca();ua();ph={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
250
250
  F is a field number (1-indexed)
251
251
  C is a character position within the field (1-indexed)
252
252
  OPTS can be: b d f h M n r V (per-key modifiers)
@@ -256,36 +256,36 @@ Examples:
256
256
  -k2,2 sort by second field only
257
257
  -k1.3 sort by first field starting at 3rd character
258
258
  -k1,2n sort by fields 1-2 numerically
259
- -k2 -k1 sort by field 2, then by field 1`},ih={name:"sort",async execute(t,e){if(I(t))return N(sh);let r={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},n=[];for(let c=0;c<t.length;c++){let u=t[c];if(u==="-r"||u==="--reverse")r.reverse=!0;else if(u==="-n"||u==="--numeric-sort")r.numeric=!0;else if(u==="-u"||u==="--unique")r.unique=!0;else if(u==="-f"||u==="--ignore-case")r.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")r.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")r.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")r.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")r.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")r.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")r.stable=!0;else if(u==="-c"||u==="--check")r.checkOnly=!0;else if(u==="-o"||u==="--output")r.outputFile=t[++c]||null;else if(u.startsWith("-o"))r.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))r.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")r.fieldDelimiter=t[++c]||null;else if(u.startsWith("-t"))r.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))r.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=t[++c];if(f){let d=Rr(f);d&&r.keys.push(d)}}else if(u.startsWith("-k")){let f=Rr(u.slice(2));f&&r.keys.push(f)}else if(u.startsWith("--key=")){let f=Rr(u.slice(6));f&&r.keys.push(f)}else{if(u.startsWith("--"))return $("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let d of u.slice(1))if(d==="r")r.reverse=!0;else if(d==="n")r.numeric=!0;else if(d==="u")r.unique=!0;else if(d==="f")r.ignoreCase=!0;else if(d==="h")r.humanNumeric=!0;else if(d==="V")r.versionSort=!0;else if(d==="d")r.dictionaryOrder=!0;else if(d==="M")r.monthSort=!0;else if(d==="b")r.ignoreLeadingBlanks=!0;else if(d==="s")r.stable=!0;else if(d==="c")r.checkOnly=!0;else{f=!0;break}if(f)return $("sort",u)}else n.push(u)}}let s=await St(e,n,{cmdName:"sort"});if(!s.ok)return s.error;let o=s.content.split(`
260
- `);o.length>0&&o[o.length-1]===""&&o.pop();let a=Yo(r);if(r.checkOnly){let c=n.length>0?n[0]:"-";for(let u=1;u<o.length;u++)if(a(o[u-1],o[u])>0)return{stdout:"",stderr:`sort: ${c}:${u+1}: disorder: ${o[u]}
261
- `,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}o.sort(a),r.unique&&(o=ea(o,r));let l=o.length>0?`${o.join(`
259
+ -k2 -k1 sort by field 2, then by field 1`},dh={name:"sort",async execute(t,e){if(N(t))return k(ph);let r={reverse:!1,numeric:!1,unique:!1,ignoreCase:!1,humanNumeric:!1,versionSort:!1,dictionaryOrder:!1,monthSort:!1,ignoreLeadingBlanks:!1,stable:!1,checkOnly:!1,outputFile:null,keys:[],fieldDelimiter:null},n=[];for(let c=0;c<t.length;c++){let u=t[c];if(u==="-r"||u==="--reverse")r.reverse=!0;else if(u==="-n"||u==="--numeric-sort")r.numeric=!0;else if(u==="-u"||u==="--unique")r.unique=!0;else if(u==="-f"||u==="--ignore-case")r.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")r.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")r.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")r.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")r.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")r.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")r.stable=!0;else if(u==="-c"||u==="--check")r.checkOnly=!0;else if(u==="-o"||u==="--output")r.outputFile=t[++c]||null;else if(u.startsWith("-o"))r.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))r.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")r.fieldDelimiter=t[++c]||null;else if(u.startsWith("-t"))r.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))r.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=t[++c];if(f){let p=Wr(f);p&&r.keys.push(p)}}else if(u.startsWith("-k")){let f=Wr(u.slice(2));f&&r.keys.push(f)}else if(u.startsWith("--key=")){let f=Wr(u.slice(6));f&&r.keys.push(f)}else{if(u.startsWith("--"))return P("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let p of u.slice(1))if(p==="r")r.reverse=!0;else if(p==="n")r.numeric=!0;else if(p==="u")r.unique=!0;else if(p==="f")r.ignoreCase=!0;else if(p==="h")r.humanNumeric=!0;else if(p==="V")r.versionSort=!0;else if(p==="d")r.dictionaryOrder=!0;else if(p==="M")r.monthSort=!0;else if(p==="b")r.ignoreLeadingBlanks=!0;else if(p==="s")r.stable=!0;else if(p==="c")r.checkOnly=!0;else{f=!0;break}if(f)return P("sort",u)}else n.push(u)}}let s=await Ot(e,n,{cmdName:"sort"});if(!s.ok)return s.error;let o=s.content.split(`
260
+ `);o.length>0&&o[o.length-1]===""&&o.pop();let a=aa(r);if(r.checkOnly){let c=n.length>0?n[0]:"-";for(let u=1;u<o.length;u++)if(a(o[u-1],o[u])>0)return{stdout:"",stderr:`sort: ${c}:${u+1}: disorder: ${o[u]}
261
+ `,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}o.sort(a),r.unique&&(o=la(o,r));let l=o.length>0?`${o.join(`
262
262
  `)}
263
- `:"";if(r.outputFile){let c=e.fs.resolvePath(e.cwd,r.outputFile);return await e.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}}});var ia={};v(ia,{uniqCommand:()=>lh});var oh,ah,lh,oa=C(()=>{"use strict";ae();Ct();O();oh={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},ah={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},lh={name:"uniq",async execute(t,e){if(I(t))return N(oh);let r=j("uniq",t,ah);if(!r.ok)return r.error;let{count:n,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=r.result.flags,a=r.result.positional,l=await St(e,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=l.content.split(`
264
- `);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],d=u[0],p=1,h=(w,b)=>o?w.toLowerCase()===b.toLowerCase():w===b;for(let w=1;w<u.length;w++)h(u[w],d)?p++:(f.push({line:d,count:p}),d=u[w],p=1);f.push({line:d,count:p});let y=f;s?y=f.filter(w=>w.count>1):i&&(y=f.filter(w=>w.count===1));let m="";for(let{line:w,count:b}of y)n?m+=`${String(b).padStart(4)} ${w}
265
- `:m+=`${w}
266
- `;return{stdout:m,stderr:"",exitCode:0}}}});var aa={};v(aa,{commCommand:()=>uh});var ch,uh,la=C(()=>{"use strict";O();ch={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},uh={name:"comm",async execute(t,e){if(I(t))return N(ch);let r=!1,n=!1,s=!1,i=[];for(let m of t)if(m==="-1")r=!0;else if(m==="-2")n=!0;else if(m==="-3")s=!0;else if(m==="-12"||m==="-21")r=!0,n=!0;else if(m==="-13"||m==="-31")r=!0,s=!0;else if(m==="-23"||m==="-32")n=!0,s=!0;else if(m==="-123"||m==="-132"||m==="-213"||m==="-231"||m==="-312"||m==="-321")r=!0,n=!0,s=!0;else{if(m.startsWith("-")&&m!=="-")return $("comm",m);i.push(m)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
263
+ `:"";if(r.outputFile){let c=e.fs.resolvePath(e.cwd,r.outputFile);return await e.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}}});var da={};R(da,{uniqCommand:()=>gh});var hh,mh,gh,ha=C(()=>{"use strict";ye();gt();L();hh={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},mh={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},gh={name:"uniq",async execute(t,e){if(N(t))return k(hh);let r=z("uniq",t,mh);if(!r.ok)return r.error;let{count:n,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=r.result.flags,a=r.result.positional,l=await Ot(e,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=l.content.split(`
264
+ `);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],p=u[0],d=1,h=(w,b)=>o?w.toLowerCase()===b.toLowerCase():w===b;for(let w=1;w<u.length;w++)h(u[w],p)?d++:(f.push({line:p,count:d}),p=u[w],d=1);f.push({line:p,count:d});let m=f;s?m=f.filter(w=>w.count>1):i&&(m=f.filter(w=>w.count===1));let g="";for(let{line:w,count:b}of m)n?g+=`${String(b).padStart(4)} ${w}
265
+ `:g+=`${w}
266
+ `;return{stdout:g,stderr:"",exitCode:0}}}});var ma={};R(ma,{commCommand:()=>xh});var yh,xh,ga=C(()=>{"use strict";L();yh={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},xh={name:"comm",async execute(t,e){if(N(t))return k(yh);let r=!1,n=!1,s=!1,i=[];for(let g of t)if(g==="-1")r=!0;else if(g==="-2")n=!0;else if(g==="-3")s=!0;else if(g==="-12"||g==="-21")r=!0,n=!0;else if(g==="-13"||g==="-31")r=!0,s=!0;else if(g==="-23"||g==="-32")n=!0,s=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")r=!0,n=!0,s=!0;else{if(g.startsWith("-")&&g!=="-")return P("comm",g);i.push(g)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
267
267
  Try 'comm --help' for more information.
268
- `,exitCode:1};let o=async m=>{if(m==="-")return e.stdin;try{let w=e.fs.resolvePath(e.cwd,m);return await e.fs.readFile(w)}catch{return null}},a=await o(i[0]);if(a===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
268
+ `,exitCode:1};let o=async g=>{if(g==="-")return e.stdin;try{let w=e.fs.resolvePath(e.cwd,g);return await e.fs.readFile(w)}catch{return null}},a=await o(i[0]);if(a===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
269
269
  `,exitCode:1};let l=await o(i[1]);if(l===null)return{stdout:"",stderr:`comm: ${i[1]}: No such file or directory
270
270
  `,exitCode:1};let c=a.split(`
271
271
  `),u=l.split(`
272
- `);c.length>0&&c[c.length-1]===""&&c.pop(),u.length>0&&u[u.length-1]===""&&u.pop();let f=0,d=0,p="",h=r?"":" ",y=(r?"":" ")+(n?"":" ");for(;f<c.length||d<u.length;)f>=c.length?(n||(p+=`${h}${u[d]}
273
- `),d++):d>=u.length?(r||(p+=`${c[f]}
274
- `),f++):c[f]<u[d]?(r||(p+=`${c[f]}
275
- `),f++):c[f]>u[d]?(n||(p+=`${h}${u[d]}
276
- `),d++):(s||(p+=`${y}${c[f]}
277
- `),f++,d++);return{stdout:p,stderr:"",exitCode:0}}}});var ca={};v(ca,{cutCommand:()=>hh});function dh(t){let e=[],r=t.split(",");for(let n of r)if(n.includes("-")){let[s,i]=n.split("-");e.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(n,10);e.push({start:s,end:s})}return e}function ph(t,e){let r=[];for(let n of e){let s=n.start-1,i=n.end===null?t.length:n.end;for(let o=s;o<i&&o<t.length;o++)o>=0&&!r.includes(t[o])&&r.push(t[o])}return r}var fh,hh,ua=C(()=>{"use strict";Ct();O();fh={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};hh={name:"cut",async execute(t,e){if(I(t))return N(fh);let r=" ",n=null,s=null,i=!1,o=[];for(let d=0;d<t.length;d++){let p=t[d];if(p==="-d")r=t[++d]||" ";else if(p.startsWith("-d"))r=p.slice(2);else if(p==="-f")n=t[++d];else if(p.startsWith("-f"))n=p.slice(2);else if(p==="-c")s=t[++d];else if(p.startsWith("-c"))s=p.slice(2);else if(p==="-s"||p==="--only-delimited")i=!0;else{if(p.startsWith("--"))return $("cut",p);if(p.startsWith("-")){let h=!1;for(let y of p.slice(1))if(y==="s")i=!0;else if(!"dfc".includes(y)){h=!0;break}if(h)return $("cut",p)}else o.push(p)}}if(!n&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
278
- `,exitCode:1};let a=await St(e,o,{cmdName:"cut"});if(!a.ok)return a.error;let c=a.content.split(`
279
- `);c.length>0&&c[c.length-1]===""&&c.pop();let u=dh(n||s||"1"),f="";for(let d of c)if(s){let p=d.split(""),h=[];for(let y of u){let m=y.start-1,w=y.end===null?p.length:y.end;for(let b=m;b<w&&b<p.length;b++)b>=0&&h.push(p[b])}f+=`${h.join("")}
280
- `}else{if(i&&!d.includes(r))continue;let p=d.split(r),h=ph(p,u);f+=`${h.join(r)}
281
- `}return{stdout:f,stderr:"",exitCode:0}}}});var da={};v(da,{pasteCommand:()=>yh});function fa(t,e){if(t.length===0)return"";if(t.length===1)return t[0];let r=t[0];for(let n=1;n<t.length;n++){let s=(n-1)%e.length;r+=e[s]+t[n]}return r}var mh,gh,yh,pa=C(()=>{"use strict";ae();O();mh={name:"paste",summary:"merge lines of files",usage:"paste [OPTION]... [FILE]...",description:["Write lines consisting of the sequentially corresponding lines from","each FILE, separated by TABs, to standard output.","","With no FILE, or when FILE is -, read standard input."],options:["-d, --delimiters=LIST reuse characters from LIST instead of TABs","-s, --serial paste one file at a time instead of in parallel"," --help display this help and exit"],examples:["paste file1 file2 Merge file1 and file2 side by side","paste -d, file1 file2 Use comma as delimiter","paste -s file1 Paste all lines of file1 on one line","paste - - < file Paste pairs of lines from file"]},gh={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},yh={name:"paste",async execute(t,e){if(I(t))return N(mh);let r=j("paste",t,gh);if(!r.ok)return r.error;let n=r.result.flags.delimiter,s=r.result.flags.serial,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
272
+ `);c.length>0&&c[c.length-1]===""&&c.pop(),u.length>0&&u[u.length-1]===""&&u.pop();let f=0,p=0,d="",h=r?"":" ",m=(r?"":" ")+(n?"":" ");for(;f<c.length||p<u.length;)f>=c.length?(n||(d+=`${h}${u[p]}
273
+ `),p++):p>=u.length?(r||(d+=`${c[f]}
274
+ `),f++):c[f]<u[p]?(r||(d+=`${c[f]}
275
+ `),f++):c[f]>u[p]?(n||(d+=`${h}${u[p]}
276
+ `),p++):(s||(d+=`${m}${c[f]}
277
+ `),f++,p++);return{stdout:d,stderr:"",exitCode:0}}}});var ya={};R(ya,{cutCommand:()=>Sh});function bh(t){let e=[],r=t.split(",");for(let n of r)if(n.includes("-")){let[s,i]=n.split("-");e.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(n,10);e.push({start:s,end:s})}return e}function Eh(t,e){let r=[];for(let n of e){let s=n.start-1,i=n.end===null?t.length:n.end;for(let o=s;o<i&&o<t.length;o++)o>=0&&!r.includes(t[o])&&r.push(t[o])}return r}var wh,Sh,xa=C(()=>{"use strict";gt();L();wh={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};Sh={name:"cut",async execute(t,e){if(N(t))return k(wh);let r=" ",n=null,s=null,i=!1,o=[];for(let p=0;p<t.length;p++){let d=t[p];if(d==="-d")r=t[++p]||" ";else if(d.startsWith("-d"))r=d.slice(2);else if(d==="-f")n=t[++p];else if(d.startsWith("-f"))n=d.slice(2);else if(d==="-c")s=t[++p];else if(d.startsWith("-c"))s=d.slice(2);else if(d==="-s"||d==="--only-delimited")i=!0;else{if(d.startsWith("--"))return P("cut",d);if(d.startsWith("-")){let h=!1;for(let m of d.slice(1))if(m==="s")i=!0;else if(!"dfc".includes(m)){h=!0;break}if(h)return P("cut",d)}else o.push(d)}}if(!n&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
278
+ `,exitCode:1};let a=await Ot(e,o,{cmdName:"cut"});if(!a.ok)return a.error;let c=a.content.split(`
279
+ `);c.length>0&&c[c.length-1]===""&&c.pop();let u=bh(n||s||"1"),f="";for(let p of c)if(s){let d=p.split(""),h=[];for(let m of u){let g=m.start-1,w=m.end===null?d.length:m.end;for(let b=g;b<w&&b<d.length;b++)b>=0&&h.push(d[b])}f+=`${h.join("")}
280
+ `}else{if(i&&!p.includes(r))continue;let d=p.split(r),h=Eh(d,u);f+=`${h.join(r)}
281
+ `}return{stdout:f,stderr:"",exitCode:0}}}});var ba={};R(ba,{pasteCommand:()=>kh});function wa(t,e){if(t.length===0)return"";if(t.length===1)return t[0];let r=t[0];for(let n=1;n<t.length;n++){let s=(n-1)%e.length;r+=e[s]+t[n]}return r}var Ch,Ah,kh,Ea=C(()=>{"use strict";ye();L();Ch={name:"paste",summary:"merge lines of files",usage:"paste [OPTION]... [FILE]...",description:["Write lines consisting of the sequentially corresponding lines from","each FILE, separated by TABs, to standard output.","","With no FILE, or when FILE is -, read standard input."],options:["-d, --delimiters=LIST reuse characters from LIST instead of TABs","-s, --serial paste one file at a time instead of in parallel"," --help display this help and exit"],examples:["paste file1 file2 Merge file1 and file2 side by side","paste -d, file1 file2 Use comma as delimiter","paste -s file1 Paste all lines of file1 on one line","paste - - < file Paste pairs of lines from file"]},Ah={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},kh={name:"paste",async execute(t,e){if(N(t))return k(Ch);let r=z("paste",t,Ah);if(!r.ok)return r.error;let n=r.result.flags.delimiter,s=r.result.flags.serial,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
282
282
  `,exitCode:1};let o=e.stdin?e.stdin.split(`
283
- `):[""];o.length>0&&o[o.length-1]===""&&o.pop();let a=i.filter(f=>f==="-").length,l=[],c=0;for(let f of i)if(f==="-"){let d=[];for(let p=c;p<o.length;p+=a)d.push(o[p]);l.push(d),c++}else{let d=e.fs.resolvePath(e.cwd,f);try{let h=(await e.fs.readFile(d)).split(`
283
+ `):[""];o.length>0&&o[o.length-1]===""&&o.pop();let a=i.filter(f=>f==="-").length,l=[],c=0;for(let f of i)if(f==="-"){let p=[];for(let d=c;d<o.length;d+=a)p.push(o[d]);l.push(p),c++}else{let p=e.fs.resolvePath(e.cwd,f);try{let h=(await e.fs.readFile(p)).split(`
284
284
  `);h.length>0&&h[h.length-1]===""&&h.pop(),l.push(h)}catch{return{stdout:"",stderr:`paste: ${f}: No such file or directory
285
- `,exitCode:1}}}let u="";if(s)for(let f of l)f&&(u+=`${fa(f,n)}
286
- `);else{let f=Math.max(...l.map(d=>d?.length??0));for(let d=0;d<f;d++){let p=[];for(let h of l)p.push(h?.[d]??"");u+=`${fa(p,n)}
287
- `}}return{stdout:u,stderr:"",exitCode:0}}}});var ma={};v(ma,{trCommand:()=>Eh});function ha(t){let e="",r=0;for(;r<t.length;){if(t[r]==="["&&t[r+1]===":"){let n=!1;for(let[s,i]of Object.entries(wh))if(t.slice(r).startsWith(s)){e+=i,r+=s.length,n=!0;break}if(n)continue}if(t[r]==="\\"&&r+1<t.length){let n=t[r+1];n==="n"?e+=`
288
- `:n==="t"?e+=" ":n==="r"?e+="\r":e+=n,r+=2;continue}if(r+2<t.length&&t[r+1]==="-"){let n=t.charCodeAt(r),s=t.charCodeAt(r+2);for(let i=n;i<=s;i++)e+=String.fromCharCode(i);r+=3;continue}e+=t[r],r++}return e}var xh,wh,bh,Eh,ga=C(()=>{"use strict";ae();O();xh={name:"tr",summary:"translate or delete characters",usage:"tr [OPTION]... SET1 [SET2]",options:["-c, -C, --complement use the complement of SET1","-d, --delete delete characters in SET1","-s, --squeeze-repeats squeeze repeated characters"," --help display this help and exit"],description:`SET syntax:
285
+ `,exitCode:1}}}let u="";if(s)for(let f of l)f&&(u+=`${wa(f,n)}
286
+ `);else{let f=Math.max(...l.map(p=>p?.length??0));for(let p=0;p<f;p++){let d=[];for(let h of l)d.push(h?.[p]??"");u+=`${wa(d,n)}
287
+ `}}return{stdout:u,stderr:"",exitCode:0}}}});var Ca={};R(Ca,{trCommand:()=>$h});function Sa(t){let e="",r=0;for(;r<t.length;){if(t[r]==="["&&t[r+1]===":"){let n=!1;for(let[s,i]of Object.entries(Ih))if(t.slice(r).startsWith(s)){e+=i,r+=s.length,n=!0;break}if(n)continue}if(t[r]==="\\"&&r+1<t.length){let n=t[r+1];n==="n"?e+=`
288
+ `:n==="t"?e+=" ":n==="r"?e+="\r":e+=n,r+=2;continue}if(r+2<t.length&&t[r+1]==="-"){let n=t.charCodeAt(r),s=t.charCodeAt(r+2);for(let i=n;i<=s;i++)e+=String.fromCharCode(i);r+=3;continue}e+=t[r],r++}return e}var Nh,Ih,vh,$h,Aa=C(()=>{"use strict";ye();L();Nh={name:"tr",summary:"translate or delete characters",usage:"tr [OPTION]... SET1 [SET2]",options:["-c, -C, --complement use the complement of SET1","-d, --delete delete characters in SET1","-s, --squeeze-repeats squeeze repeated characters"," --help display this help and exit"],description:`SET syntax:
289
289
  a-z character range
290
290
  [:alnum:] all letters and digits
291
291
  [:alpha:] all letters
@@ -299,19 +299,19 @@ Try 'comm --help' for more information.
299
299
  [:graph:] all printable characters except space
300
300
  [:cntrl:] all control characters
301
301
  [:xdigit:] all hexadecimal digits
302
- \\n, \\t, \\r escape sequences`},wh={"[:alnum:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789","[:alpha:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","[:blank:]":" ","[:cntrl:]":Array.from({length:32},(t,e)=>String.fromCharCode(e)).join("").concat("\x7F"),"[:digit:]":"0123456789","[:graph:]":Array.from({length:94},(t,e)=>String.fromCharCode(33+e)).join(""),"[:lower:]":"abcdefghijklmnopqrstuvwxyz","[:print:]":Array.from({length:95},(t,e)=>String.fromCharCode(32+e)).join(""),"[:punct:]":"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~","[:space:]":`
303
- \r\f\v`,"[:upper:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZ","[:xdigit:]":"0123456789ABCDEFabcdef"};bh={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},Eh={name:"tr",async execute(t,e){if(I(t))return N(xh);let r=j("tr",t,bh);if(!r.ok)return r.error;let n=r.result.flags.complement||r.result.flags.complementUpper,s=r.result.flags.delete,i=r.result.flags.squeeze,o=r.result.positional;if(o.length<1)return{stdout:"",stderr:`tr: missing operand
302
+ \\n, \\t, \\r escape sequences`},Ih={"[:alnum:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789","[:alpha:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz","[:blank:]":" ","[:cntrl:]":Array.from({length:32},(t,e)=>String.fromCharCode(e)).join("").concat("\x7F"),"[:digit:]":"0123456789","[:graph:]":Array.from({length:94},(t,e)=>String.fromCharCode(33+e)).join(""),"[:lower:]":"abcdefghijklmnopqrstuvwxyz","[:print:]":Array.from({length:95},(t,e)=>String.fromCharCode(32+e)).join(""),"[:punct:]":"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~","[:space:]":`
303
+ \r\f\v`,"[:upper:]":"ABCDEFGHIJKLMNOPQRSTUVWXYZ","[:xdigit:]":"0123456789ABCDEFabcdef"};vh={complement:{short:"c",long:"complement",type:"boolean"},complementUpper:{short:"C",type:"boolean"},delete:{short:"d",long:"delete",type:"boolean"},squeeze:{short:"s",long:"squeeze-repeats",type:"boolean"}},$h={name:"tr",async execute(t,e){if(N(t))return k(Nh);let r=z("tr",t,vh);if(!r.ok)return r.error;let n=r.result.flags.complement||r.result.flags.complementUpper,s=r.result.flags.delete,i=r.result.flags.squeeze,o=r.result.positional;if(o.length<1)return{stdout:"",stderr:`tr: missing operand
304
304
  `,exitCode:1};if(!s&&!i&&o.length<2)return{stdout:"",stderr:`tr: missing operand after SET1
305
- `,exitCode:1};let a=ha(o[0]),l=o.length>1?ha(o[1]):"",c=e.stdin,u=d=>{let p=a.includes(d);return n?!p:p},f="";if(s)for(let d of c)u(d)||(f+=d);else if(i&&o.length===1){let d="";for(let p of c)u(p)&&p===d||(f+=p,d=p)}else{if(n){let d=l.length>0?l[l.length-1]:"";for(let p of c)a.includes(p)?f+=p:f+=d}else{let d=new Map;for(let p=0;p<a.length;p++){let h=p<l.length?l[p]:l[l.length-1];d.set(a[p],h)}for(let p of c)f+=d.get(p)??p}if(i){let d="",p="";for(let h of f)l.includes(h)&&h===p||(d+=h,p=h);f=d}}return{stdout:f,stderr:"",exitCode:0}}}});var ya={};v(ya,{rev:()=>Ah});function Ch(t){return Array.from(t).reverse().join("")}var Sh,Ah,xa=C(()=>{"use strict";O();Sh={name:"rev",summary:"reverse lines characterwise",usage:"rev [file ...]",description:"Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.",examples:["echo 'hello' | rev # Output: olleh","rev file.txt # Reverse each line in file"]};Ah={name:"rev",execute:async(t,e)=>{if(I(t))return N(Sh);let r=[];for(let i of t)if(i==="--"){let o=t.indexOf(i);r.push(...t.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return $("rev",i);r.push(i)}let n="",s=i=>{let o=i.split(`
305
+ `,exitCode:1};let a=Sa(o[0]),l=o.length>1?Sa(o[1]):"",c=e.stdin,u=p=>{let d=a.includes(p);return n?!d:d},f="";if(s)for(let p of c)u(p)||(f+=p);else if(i&&o.length===1){let p="";for(let d of c)u(d)&&d===p||(f+=d,p=d)}else{if(n){let p=l.length>0?l[l.length-1]:"";for(let d of c)a.includes(d)?f+=d:f+=p}else{let p=new Map;for(let d=0;d<a.length;d++){let h=d<l.length?l[d]:l[l.length-1];p.set(a[d],h)}for(let d of c)f+=p.get(d)??d}if(i){let p="",d="";for(let h of f)l.includes(h)&&h===d||(p+=h,d=h);f=p}}return{stdout:f,stderr:"",exitCode:0}}}});var ka={};R(ka,{rev:()=>Fh});function Ph(t){return Array.from(t).reverse().join("")}var Rh,Fh,Na=C(()=>{"use strict";L();Rh={name:"rev",summary:"reverse lines characterwise",usage:"rev [file ...]",description:"Copies the specified files to standard output, reversing the order of characters in every line. If no files are specified, standard input is read.",examples:["echo 'hello' | rev # Output: olleh","rev file.txt # Reverse each line in file"]};Fh={name:"rev",execute:async(t,e)=>{if(N(t))return k(Rh);let r=[];for(let i of t)if(i==="--"){let o=t.indexOf(i);r.push(...t.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return P("rev",i);r.push(i)}let n="",s=i=>{let o=i.split(`
306
306
  `),a=i.endsWith(`
307
- `)&&o[o.length-1]==="";return a&&o.pop(),o.map(Ch).join(`
307
+ `)&&o[o.length-1]==="";return a&&o.pop(),o.map(Ph).join(`
308
308
  `)+(a?`
309
309
  `:"")};if(r.length===0){let i=e.stdin??"";n=s(i)}else for(let i of r)if(i==="-"){let o=e.stdin??"";n+=s(o)}else{let o=e.fs.resolvePath(e.cwd,i),a=await e.fs.readFile(o);if(a===null)return{exitCode:1,stdout:n,stderr:`rev: ${i}: No such file or directory
310
- `};n+=s(a)}return{exitCode:0,stdout:n,stderr:""}}}});var ba={};v(ba,{nl:()=>vh});function Nh(t,e,r){let n=String(t);switch(e){case"ln":return n.padEnd(r);case"rn":return n.padStart(r);case"rz":return n.padStart(r,"0");default:return e}}function Ih(t,e){switch(e){case"a":return!0;case"t":return t.trim().length>0;case"n":return!1;default:return e}}function wa(t,e,r){if(t==="")return{output:"",nextNumber:r};let n=t.split(`
310
+ `};n+=s(a)}return{exitCode:0,stdout:n,stderr:""}}}});var va={};R(va,{nl:()=>Lh});function Th(t,e,r){let n=String(t);switch(e){case"ln":return n.padEnd(r);case"rn":return n.padStart(r);case"rz":return n.padStart(r,"0");default:return e}}function Dh(t,e){switch(e){case"a":return!0;case"t":return t.trim().length>0;case"n":return!1;default:return e}}function Ia(t,e,r){if(t==="")return{output:"",nextNumber:r};let n=t.split(`
311
311
  `),s=[],i=r,o=t.endsWith(`
312
- `)&&n[n.length-1]==="";o&&n.pop();for(let a of n)if(Ih(a,e.bodyStyle)){let l=Nh(i,e.numberFormat,e.width);s.push(`${l}${e.separator}${a}`),i+=e.increment}else{let l=" ".repeat(e.width);s.push(`${l}${e.separator}${a}`)}return{output:s.join(`
312
+ `)&&n[n.length-1]==="";o&&n.pop();for(let a of n)if(Dh(a,e.bodyStyle)){let l=Th(i,e.numberFormat,e.width);s.push(`${l}${e.separator}${a}`),i+=e.increment}else{let l=" ".repeat(e.width);s.push(`${l}${e.separator}${a}`)}return{output:s.join(`
313
313
  `)+(o?`
314
- `:""),nextNumber:i}}var kh,vh,Ea=C(()=>{"use strict";O();kh={name:"nl",summary:"number lines of files",usage:"nl [OPTION]... [FILE]...",description:"Write each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.",options:["-b STYLE Body numbering style: a (all), t (non-empty), n (none)","-n FORMAT Number format: ln (left), rn (right), rz (right zeros)","-w WIDTH Number width (default: 6)","-s SEP Separator after number (default: TAB)","-v START Starting line number (default: 1)","-i INCR Line number increment (default: 1)"],examples:["nl file.txt # Number non-empty lines","nl -ba file.txt # Number all lines","nl -n rz -w 3 file.txt # Right-justified with zeros","nl -s ': ' file.txt # Use ': ' as separator"]};vh={name:"nl",execute:async(t,e)=>{if(I(t))return N(kh);let r={bodyStyle:"t",numberFormat:"rn",width:6,separator:" ",startNumber:1,increment:1},n=[],s=0;for(;s<t.length;){let a=t[s];if(a==="-b"&&s+1<t.length){let l=t[s+1];if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
314
+ `:""),nextNumber:i}}var Oh,Lh,$a=C(()=>{"use strict";L();Oh={name:"nl",summary:"number lines of files",usage:"nl [OPTION]... [FILE]...",description:"Write each FILE to standard output, with line numbers added. If no FILE is specified, standard input is read.",options:["-b STYLE Body numbering style: a (all), t (non-empty), n (none)","-n FORMAT Number format: ln (left), rn (right), rz (right zeros)","-w WIDTH Number width (default: 6)","-s SEP Separator after number (default: TAB)","-v START Starting line number (default: 1)","-i INCR Line number increment (default: 1)"],examples:["nl file.txt # Number non-empty lines","nl -ba file.txt # Number all lines","nl -n rz -w 3 file.txt # Right-justified with zeros","nl -s ': ' file.txt # Use ': ' as separator"]};Lh={name:"nl",execute:async(t,e)=>{if(N(t))return k(Oh);let r={bodyStyle:"t",numberFormat:"rn",width:6,separator:" ",startNumber:1,increment:1},n=[],s=0;for(;s<t.length;){let a=t[s];if(a==="-b"&&s+1<t.length){let l=t[s+1];if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
315
315
  `};r.bodyStyle=l,s+=2}else if(a.startsWith("-b")){let l=a.slice(2);if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
316
316
  `};r.bodyStyle=l,s++}else if(a==="-n"&&s+1<t.length){let l=t[s+1];if(l!=="ln"&&l!=="rn"&&l!=="rz")return{exitCode:1,stdout:"",stderr:`nl: invalid line numbering format: '${l}'
317
317
  `};r.numberFormat=l,s+=2}else if(a.startsWith("-n")){let l=a.slice(2);if(l!=="ln"&&l!=="rn"&&l!=="rz")return{exitCode:1,stdout:"",stderr:`nl: invalid line numbering format: '${l}'
@@ -321,216 +321,216 @@ Try 'comm --help' for more information.
321
321
  `};r.startNumber=l,s+=2}else if(a.startsWith("-v")){let l=parseInt(a.slice(2),10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid starting line number: '${a.slice(2)}'
322
322
  `};r.startNumber=l,s++}else if(a==="-i"&&s+1<t.length){let l=parseInt(t[s+1],10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid line number increment: '${t[s+1]}'
323
323
  `};r.increment=l,s+=2}else if(a.startsWith("-i")){let l=parseInt(a.slice(2),10);if(Number.isNaN(l))return{exitCode:1,stdout:"",stderr:`nl: invalid line number increment: '${a.slice(2)}'
324
- `};r.increment=l,s++}else if(a==="--"){n.push(...t.slice(s+1));break}else{if(a.startsWith("-")&&a!=="-")return $("nl",a);n.push(a),s++}}let i="",o=r.startNumber;if(n.length===0){let a=e.stdin??"";i=wa(a,r,o).output}else for(let a of n){let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFile(l);if(c===null)return{exitCode:1,stdout:i,stderr:`nl: ${a}: No such file or directory
325
- `};let u=wa(c,r,o);i+=u.output,o=u.nextNumber}return{exitCode:0,stdout:i,stderr:""}}}});var Ca={};v(Ca,{fold:()=>Oh});function Rh(t,e,r){return r?new TextEncoder().encode(t).length:t===" "?8-e%8:t==="\b"?-1:1}function Ph(t,e){if(t.length===0)return t;let{width:r,breakAtSpaces:n,countBytes:s}=e,i=[],o="",a=0,l=-1,c=0;for(let u=0;u<t.length;u++){let f=t[u],d=Rh(f,a,s);a+d>r&&o.length>0?n&&l>=0?(i.push(o.slice(0,l+1)),o=o.slice(l+1)+f,a=a-c-1+d,l=-1,c=0):(i.push(o),o=f,a=d,l=-1,c=0):(o+=f,a+=d,(f===" "||f===" ")&&(l=o.length-1,c=a-d))}return o.length>0&&i.push(o),i.join(`
326
- `)}function Sa(t,e){if(t==="")return"";let r=t.split(`
324
+ `};r.increment=l,s++}else if(a==="--"){n.push(...t.slice(s+1));break}else{if(a.startsWith("-")&&a!=="-")return P("nl",a);n.push(a),s++}}let i="",o=r.startNumber;if(n.length===0){let a=e.stdin??"";i=Ia(a,r,o).output}else for(let a of n){let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFile(l);if(c===null)return{exitCode:1,stdout:i,stderr:`nl: ${a}: No such file or directory
325
+ `};let u=Ia(c,r,o);i+=u.output,o=u.nextNumber}return{exitCode:0,stdout:i,stderr:""}}}});var Pa={};R(Pa,{fold:()=>Wh});function _h(t,e,r){return r?new TextEncoder().encode(t).length:t===" "?8-e%8:t==="\b"?-1:1}function Bh(t,e){if(t.length===0)return t;let{width:r,breakAtSpaces:n,countBytes:s}=e,i=[],o="",a=0,l=-1,c=0;for(let u=0;u<t.length;u++){let f=t[u],p=_h(f,a,s);a+p>r&&o.length>0?n&&l>=0?(i.push(o.slice(0,l+1)),o=o.slice(l+1)+f,a=a-c-1+p,l=-1,c=0):(i.push(o),o=f,a=p,l=-1,c=0):(o+=f,a+=p,(f===" "||f===" ")&&(l=o.length-1,c=a-p))}return o.length>0&&i.push(o),i.join(`
326
+ `)}function Ra(t,e){if(t==="")return"";let r=t.split(`
327
327
  `),n=t.endsWith(`
328
- `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>Ph(i,e)).join(`
328
+ `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>Bh(i,e)).join(`
329
329
  `)+(n?`
330
- `:"")}var $h,Oh,Aa=C(()=>{"use strict";O();$h={name:"fold",summary:"wrap each input line to fit in specified width",usage:"fold [OPTION]... [FILE]...",description:"Wrap input lines in each FILE, writing to standard output. If no FILE is specified, standard input is read.",options:["-w WIDTH Use WIDTH columns instead of 80","-s Break at spaces","-b Count bytes rather than columns"],examples:["fold -w 40 file.txt # Wrap at 40 columns","fold -sw 40 file.txt # Word wrap at 40 columns","echo 'long line' | fold -w 5 # Force wrap at 5"]};Oh={name:"fold",execute:async(t,e)=>{if(I(t))return N($h);let r={width:80,breakAtSpaces:!1,countBytes:!1},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-w"&&s+1<t.length){let a=parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${t[s+1]}'
330
+ `:"")}var Mh,Wh,Fa=C(()=>{"use strict";L();Mh={name:"fold",summary:"wrap each input line to fit in specified width",usage:"fold [OPTION]... [FILE]...",description:"Wrap input lines in each FILE, writing to standard output. If no FILE is specified, standard input is read.",options:["-w WIDTH Use WIDTH columns instead of 80","-s Break at spaces","-b Count bytes rather than columns"],examples:["fold -w 40 file.txt # Wrap at 40 columns","fold -sw 40 file.txt # Word wrap at 40 columns","echo 'long line' | fold -w 5 # Force wrap at 5"]};Wh={name:"fold",execute:async(t,e)=>{if(N(t))return k(Mh);let r={width:80,breakAtSpaces:!1,countBytes:!1},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-w"&&s+1<t.length){let a=parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${t[s+1]}'
331
331
  `};r.width=a,s+=2}else if(o.startsWith("-w")&&o.length>2){let a=parseInt(o.slice(2),10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${o.slice(2)}'
332
332
  `};r.width=a,s++}else if(o==="-s")r.breakAtSpaces=!0,s++;else if(o==="-b")r.countBytes=!0,s++;else if(o==="-bs"||o==="-sb")r.breakAtSpaces=!0,r.countBytes=!0,s++;else if(o.match(/^-[sb]+w\d+$/)){o.includes("s")&&(r.breakAtSpaces=!0),o.includes("b")&&(r.countBytes=!0);let a=o.replace(/^-[sb]+w/,""),l=parseInt(a,10);if(Number.isNaN(l)||l<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${a}'
333
333
  `};r.width=l,s++}else if(o.match(/^-[sb]+w$/)&&s+1<t.length){o.includes("s")&&(r.breakAtSpaces=!0),o.includes("b")&&(r.countBytes=!0);let a=parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${t[s+1]}'
334
- `};r.width=a,s+=2}else if(o==="--"){n.push(...t.slice(s+1));break}else if(o.startsWith("-")&&o!=="-"){let a=o.slice(1),l=!1;for(let c of a)if(c==="s")r.breakAtSpaces=!0;else if(c==="b")r.countBytes=!0;else{l=!0;break}if(l)return $("fold",o);s++}else n.push(o),s++}let i="";if(n.length===0){let o=e.stdin??"";i=Sa(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`fold: ${o}: No such file or directory
335
- `};i+=Sa(l,r)}return{exitCode:0,stdout:i,stderr:""}}}});var Na={};v(Na,{expand:()=>Dh});function Pr(t){let e=t.split(",").map(n=>n.trim()),r=[];for(let n of e){let s=parseInt(n,10);if(Number.isNaN(s)||s<1)return null;r.push(s)}for(let n=1;n<r.length;n++)if(r[n]<=r[n-1])return null;return r}function Th(t,e){if(e.length===1){let r=e[0];return r-t%r}for(let r of e)if(r>t)return r-t;if(e.length>=2){let r=e[e.length-1]-e[e.length-2],n=e[e.length-1],s=Math.floor((t-n)/r)+1;return n+s*r-t}return 1}function Lh(t,e){let{tabStops:r,leadingOnly:n}=e,s="",i=0,o=!0;for(let a of t)if(a===" ")if(n&&!o)s+=a,i++;else{let l=Th(i,r);s+=" ".repeat(l),i+=l}else a!==" "&&a!==" "&&(o=!1),s+=a,i++;return s}function ka(t,e){if(t==="")return"";let r=t.split(`
334
+ `};r.width=a,s+=2}else if(o==="--"){n.push(...t.slice(s+1));break}else if(o.startsWith("-")&&o!=="-"){let a=o.slice(1),l=!1;for(let c of a)if(c==="s")r.breakAtSpaces=!0;else if(c==="b")r.countBytes=!0;else{l=!0;break}if(l)return P("fold",o);s++}else n.push(o),s++}let i="";if(n.length===0){let o=e.stdin??"";i=Ra(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`fold: ${o}: No such file or directory
335
+ `};i+=Ra(l,r)}return{exitCode:0,stdout:i,stderr:""}}}});var Ta={};R(Ta,{expand:()=>Hh});function Ur(t){let e=t.split(",").map(n=>n.trim()),r=[];for(let n of e){let s=parseInt(n,10);if(Number.isNaN(s)||s<1)return null;r.push(s)}for(let n=1;n<r.length;n++)if(r[n]<=r[n-1])return null;return r}function jh(t,e){if(e.length===1){let r=e[0];return r-t%r}for(let r of e)if(r>t)return r-t;if(e.length>=2){let r=e[e.length-1]-e[e.length-2],n=e[e.length-1],s=Math.floor((t-n)/r)+1;return n+s*r-t}return 1}function zh(t,e){let{tabStops:r,leadingOnly:n}=e,s="",i=0,o=!0;for(let a of t)if(a===" ")if(n&&!o)s+=a,i++;else{let l=jh(i,r);s+=" ".repeat(l),i+=l}else a!==" "&&a!==" "&&(o=!1),s+=a,i++;return s}function Oa(t,e){if(t==="")return"";let r=t.split(`
336
336
  `),n=t.endsWith(`
337
- `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>Lh(i,e)).join(`
337
+ `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>zh(i,e)).join(`
338
338
  `)+(n?`
339
- `:"")}var Fh,Dh,Ia=C(()=>{"use strict";O();Fh={name:"expand",summary:"convert tabs to spaces",usage:"expand [OPTION]... [FILE]...",description:"Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-i Only convert leading tabs on each line"],examples:["expand file.txt # Convert all tabs to 8 spaces","expand -t 4 file.txt # Use 4-space tabs","expand -t 4,8,12 file.txt # Custom tab stops"]};Dh={name:"expand",execute:async(t,e)=>{if(I(t))return N(Fh);let r={tabStops:[8],leadingOnly:!1},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=Pr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
340
- `};r.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=Pr(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(2)}'
341
- `};r.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=Pr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
342
- `};r.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=Pr(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(7)}'
343
- `};r.tabStops=a,s++}else if(o==="-i"||o==="--initial")r.leadingOnly=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return $("expand",o);n.push(o),s++}}let i="";if(n.length===0){let o=e.stdin??"";i=ka(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`expand: ${o}: No such file or directory
344
- `};i+=ka(l,r)}return{exitCode:0,stdout:i,stderr:""}}}});var Ra={};v(Ra,{unexpand:()=>Bh});function Or(t){let e=t.split(",").map(n=>n.trim()),r=[];for(let n of e){let s=parseInt(n,10);if(Number.isNaN(s)||s<1)return null;r.push(s)}for(let n=1;n<r.length;n++)if(r[n]<=r[n-1])return null;return r}function va(t,e){if(e.length===1){let r=e[0];return t+(r-t%r)}for(let r of e)if(r>t)return r;if(e.length>=2){let r=e[e.length-1]-e[e.length-2],n=e[e.length-1],s=Math.floor((t-n)/r)+1;return n+s*r}return-1}function _h(t,e){let{tabStops:r,allBlanks:n}=e,s="",i=0,o="",a=0,l=!0,c=()=>{if(o.length===0)return;let u=a+o.length;if(!n&&!l){s+=o,o="";return}let f=a,d="";for(;f<u;){let h=va(f,r);if(h<=u&&h>f)d+=" ",f=h;else break}let p=u-f;p>0&&(d+=" ".repeat(p)),s+=d,o=""};for(let u of t)u===" "?(o.length===0&&(a=i),o+=u,i++):u===" "?(c(),s+=u,i=va(i,r)):(c(),s+=u,i++,l=!1);return c(),s}function $a(t,e){if(t==="")return"";let r=t.split(`
339
+ `:"")}var Uh,Hh,Da=C(()=>{"use strict";L();Uh={name:"expand",summary:"convert tabs to spaces",usage:"expand [OPTION]... [FILE]...",description:"Convert TABs in each FILE to spaces, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-i Only convert leading tabs on each line"],examples:["expand file.txt # Convert all tabs to 8 spaces","expand -t 4 file.txt # Use 4-space tabs","expand -t 4,8,12 file.txt # Custom tab stops"]};Hh={name:"expand",execute:async(t,e)=>{if(N(t))return k(Uh);let r={tabStops:[8],leadingOnly:!1},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=Ur(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
340
+ `};r.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=Ur(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(2)}'
341
+ `};r.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=Ur(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${t[s+1]}'
342
+ `};r.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=Ur(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(7)}'
343
+ `};r.tabStops=a,s++}else if(o==="-i"||o==="--initial")r.leadingOnly=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return P("expand",o);n.push(o),s++}}let i="";if(n.length===0){let o=e.stdin??"";i=Oa(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`expand: ${o}: No such file or directory
344
+ `};i+=Oa(l,r)}return{exitCode:0,stdout:i,stderr:""}}}});var _a={};R(_a,{unexpand:()=>Vh});function jr(t){let e=t.split(",").map(n=>n.trim()),r=[];for(let n of e){let s=parseInt(n,10);if(Number.isNaN(s)||s<1)return null;r.push(s)}for(let n=1;n<r.length;n++)if(r[n]<=r[n-1])return null;return r}function La(t,e){if(e.length===1){let r=e[0];return t+(r-t%r)}for(let r of e)if(r>t)return r;if(e.length>=2){let r=e[e.length-1]-e[e.length-2],n=e[e.length-1],s=Math.floor((t-n)/r)+1;return n+s*r}return-1}function qh(t,e){let{tabStops:r,allBlanks:n}=e,s="",i=0,o="",a=0,l=!0,c=()=>{if(o.length===0)return;let u=a+o.length;if(!n&&!l){s+=o,o="";return}let f=a,p="";for(;f<u;){let h=La(f,r);if(h<=u&&h>f)p+=" ",f=h;else break}let d=u-f;d>0&&(p+=" ".repeat(d)),s+=p,o=""};for(let u of t)u===" "?(o.length===0&&(a=i),o+=u,i++):u===" "?(c(),s+=u,i=La(i,r)):(c(),s+=u,i++,l=!1);return c(),s}function Ma(t,e){if(t==="")return"";let r=t.split(`
345
345
  `),n=t.endsWith(`
346
- `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>_h(i,e)).join(`
346
+ `)&&r[r.length-1]==="";return n&&r.pop(),r.map(i=>qh(i,e)).join(`
347
347
  `)+(n?`
348
- `:"")}var Mh,Bh,Pa=C(()=>{"use strict";O();Mh={name:"unexpand",summary:"convert spaces to tabs",usage:"unexpand [OPTION]... [FILE]...",description:"Convert blanks in each FILE to TABs, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-a Convert all sequences of blanks (not just leading)"],examples:["unexpand file.txt # Convert leading spaces to tabs","unexpand -a file.txt # Convert all space sequences","unexpand -t 4 file.txt # Use 4-space tabs"]};Bh={name:"unexpand",execute:async(t,e)=>{if(I(t))return N(Mh);let r={tabStops:[8],allBlanks:!1},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=Or(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
349
- `};r.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=Or(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(2)}'
350
- `};r.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=Or(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
351
- `};r.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=Or(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(7)}'
352
- `};r.tabStops=a,s++}else if(o==="-a"||o==="--all")r.allBlanks=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return $("unexpand",o);n.push(o),s++}}let i="";if(n.length===0){let o=e.stdin??"";i=$a(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`unexpand: ${o}: No such file or directory
353
- `};i+=$a(l,r)}return{exitCode:0,stdout:i,stderr:""}}}});var Ta={};v(Ta,{strings:()=>jh});function Uh(t){return t>=32&&t<=126||t===9}function Oa(t,e){if(e===null)return"";switch(e){case"o":return`${t.toString(8).padStart(7," ")} `;case"x":return`${t.toString(16).padStart(7," ")} `;case"d":return`${t.toString(10).padStart(7," ")} `;default:return e}}function Fa(t,e){let r=[],n="",s=0,i=typeof t=="string"?new TextEncoder().encode(t):t;for(let o=0;o<i.length;o++){let a=i[o];if(Uh(a))n.length===0&&(s=o),n+=String.fromCharCode(a);else{if(n.length>=e.minLength){let l=Oa(s,e.offsetFormat);r.push(`${l}${n}`)}n=""}}if(n.length>=e.minLength){let o=Oa(s,e.offsetFormat);r.push(`${o}${n}`)}return r}var Wh,jh,La=C(()=>{"use strict";O();Wh={name:"strings",summary:"print the sequences of printable characters in files",usage:"strings [OPTION]... [FILE]...",description:"For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.",options:["-n MIN Print sequences of at least MIN characters (default: 4)","-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)","-a Scan the entire file (default behavior)","-e ENCODING Select character encoding (s=7-bit, S=8-bit)"],examples:["strings file.bin # Extract strings (min 4 chars)","strings -n 8 file.bin # Extract strings (min 8 chars)","strings -t x file.bin # Show hex offset","echo 'hello' | strings # Read from stdin"]};jh={name:"strings",execute:async(t,e)=>{if(I(t))return N(Wh);let r={minLength:4,offsetFormat:null},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-n"&&s+1<t.length){let a=Number.parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${t[s+1]}'
348
+ `:"")}var Gh,Vh,Ba=C(()=>{"use strict";L();Gh={name:"unexpand",summary:"convert spaces to tabs",usage:"unexpand [OPTION]... [FILE]...",description:"Convert blanks in each FILE to TABs, writing to standard output. If no FILE is specified, standard input is read.",options:["-t N Use N spaces per tab (default: 8)","-t LIST Use comma-separated list of tab stops","-a Convert all sequences of blanks (not just leading)"],examples:["unexpand file.txt # Convert leading spaces to tabs","unexpand -a file.txt # Convert all space sequences","unexpand -t 4 file.txt # Use 4-space tabs"]};Vh={name:"unexpand",execute:async(t,e)=>{if(N(t))return k(Gh);let r={tabStops:[8],allBlanks:!1},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-t"&&s+1<t.length){let a=jr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
349
+ `};r.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=jr(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(2)}'
350
+ `};r.tabStops=a,s++}else if(o==="--tabs"&&s+1<t.length){let a=jr(t[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${t[s+1]}'
351
+ `};r.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=jr(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(7)}'
352
+ `};r.tabStops=a,s++}else if(o==="-a"||o==="--all")r.allBlanks=!0,s++;else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return P("unexpand",o);n.push(o),s++}}let i="";if(n.length===0){let o=e.stdin??"";i=Ma(o,r)}else for(let o of n){let a=e.fs.resolvePath(e.cwd,o),l=await e.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`unexpand: ${o}: No such file or directory
353
+ `};i+=Ma(l,r)}return{exitCode:0,stdout:i,stderr:""}}}});var ja={};R(ja,{strings:()=>Qh});function Zh(t){return t>=32&&t<=126||t===9}function Wa(t,e){if(e===null)return"";switch(e){case"o":return`${t.toString(8).padStart(7," ")} `;case"x":return`${t.toString(16).padStart(7," ")} `;case"d":return`${t.toString(10).padStart(7," ")} `;default:return e}}function Ua(t,e){let r=[],n="",s=0,i=typeof t=="string"?new TextEncoder().encode(t):t;for(let o=0;o<i.length;o++){let a=i[o];if(Zh(a))n.length===0&&(s=o),n+=String.fromCharCode(a);else{if(n.length>=e.minLength){let l=Wa(s,e.offsetFormat);r.push(`${l}${n}`)}n=""}}if(n.length>=e.minLength){let o=Wa(s,e.offsetFormat);r.push(`${o}${n}`)}return r}var Kh,Qh,za=C(()=>{"use strict";L();Kh={name:"strings",summary:"print the sequences of printable characters in files",usage:"strings [OPTION]... [FILE]...",description:"For each FILE, print the printable character sequences that are at least MIN characters long. If no FILE is specified, standard input is read.",options:["-n MIN Print sequences of at least MIN characters (default: 4)","-t FORMAT Print offset before each string (o=octal, x=hex, d=decimal)","-a Scan the entire file (default behavior)","-e ENCODING Select character encoding (s=7-bit, S=8-bit)"],examples:["strings file.bin # Extract strings (min 4 chars)","strings -n 8 file.bin # Extract strings (min 8 chars)","strings -t x file.bin # Show hex offset","echo 'hello' | strings # Read from stdin"]};Qh={name:"strings",execute:async(t,e)=>{if(N(t))return k(Kh);let r={minLength:4,offsetFormat:null},n=[],s=0;for(;s<t.length;){let o=t[s];if(o==="-n"&&s+1<t.length){let a=Number.parseInt(t[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${t[s+1]}'
354
354
  `};r.minLength=a,s+=2}else if(o.match(/^-n\d+$/)){let a=Number.parseInt(o.slice(2),10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${o.slice(2)}'
355
355
  `};r.minLength=a,s++}else if(o.match(/^-\d+$/)){let a=Number.parseInt(o.slice(1),10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${o.slice(1)}'
356
356
  `};r.minLength=a,s++}else if(o==="-t"&&s+1<t.length){let a=t[s+1];if(a!=="o"&&a!=="x"&&a!=="d")return{exitCode:1,stdout:"",stderr:`strings: invalid radix: '${a}'
357
357
  `};r.offsetFormat=a,s+=2}else if(o.startsWith("-t")&&o.length===3){let a=o[2];if(a!=="o"&&a!=="x"&&a!=="d")return{exitCode:1,stdout:"",stderr:`strings: invalid radix: '${a}'
358
358
  `};r.offsetFormat=a,s++}else if(o==="-a"||o==="--all"||o==="-")o==="-"&&n.push(o),s++;else if(o==="-e"&&s+1<t.length){let a=t[s+1];if(a!=="s"&&a!=="S")return{exitCode:1,stdout:"",stderr:`strings: invalid encoding: '${a}'
359
359
  `};s+=2}else if(o.startsWith("-e")&&o.length===3){let a=o[2];if(a!=="s"&&a!=="S")return{exitCode:1,stdout:"",stderr:`strings: invalid encoding: '${a}'
360
- `};s++}else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return $("strings",o);n.push(o),s++}}let i="";if(n.length===0){let o=e.stdin??"",a=Fa(o,r);i=a.length>0?`${a.join(`
360
+ `};s++}else if(o==="--"){n.push(...t.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return P("strings",o);n.push(o),s++}}let i="";if(n.length===0){let o=e.stdin??"",a=Ua(o,r);i=a.length>0?`${a.join(`
361
361
  `)}
362
362
  `:""}else for(let o of n){let a;if(o==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,o);if(a=await e.fs.readFile(c),a===null)return{exitCode:1,stdout:i,stderr:`strings: ${o}: No such file or directory
363
- `}}let l=Fa(a,r);l.length>0&&(i+=`${l.join(`
363
+ `}}let l=Ua(a,r);l.length>0&&(i+=`${l.join(`
364
364
  `)}
365
- `)}return{exitCode:0,stdout:i,stderr:""}}}});var Ma={};v(Ma,{split:()=>Kh});function Da(t){let e=t.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!e)return null;let r=Number.parseInt(e[1],10);if(Number.isNaN(r)||r<1)return null;let n=(e[2]||"").toUpperCase(),i={"":1,K:1024,M:1024*1024,G:1024*1024*1024,T:1024*1024*1024*1024,P:1024*1024*1024*1024*1024}[n];return i===void 0?null:r*i}function Hh(t,e,r){if(e)return t.toString().padStart(r,"0");let n="abcdefghijklmnopqrstuvwxyz",s="",i=t;for(let o=0;o<r;o++)s=n[i%26]+s,i=Math.floor(i/26);return s}function Gh(t,e){let r=t.split(`
365
+ `)}return{exitCode:0,stdout:i,stderr:""}}}});var Ga={};R(Ga,{split:()=>rm});function Ha(t){let e=t.match(/^(\d+)([KMGTPEZY]?)([B]?)$/i);if(!e)return null;let r=Number.parseInt(e[1],10);if(Number.isNaN(r)||r<1)return null;let n=(e[2]||"").toUpperCase(),i={"":1,K:1024,M:1024*1024,G:1024*1024*1024,T:1024*1024*1024*1024,P:1024*1024*1024*1024*1024}[n];return i===void 0?null:r*i}function Jh(t,e,r){if(e)return t.toString().padStart(r,"0");let n="abcdefghijklmnopqrstuvwxyz",s="",i=t;for(let o=0;o<r;o++)s=n[i%26]+s,i=Math.floor(i/26);return s}function Yh(t,e){let r=t.split(`
366
366
  `),n=t.endsWith(`
367
367
  `)&&r[r.length-1]==="";n&&r.pop();let s=[];for(let i=0;i<r.length;i+=e){let o=r.slice(i,i+e),l=i+e>=r.length&&!n?o.join(`
368
368
  `):`${o.join(`
369
369
  `)}
370
- `;s.push({content:l,hasContent:!0})}return s}function qh(t,e){let n=new TextEncoder().encode(t),s=new TextDecoder,i=[];for(let o=0;o<n.length;o+=e){let a=n.slice(o,o+e);i.push({content:s.decode(a),hasContent:a.length>0})}return i}function Vh(t,e){let n=new TextEncoder().encode(t),s=new TextDecoder,i=[],o=Math.ceil(n.length/e);for(let a=0;a<e;a++){let l=a*o,c=Math.min(l+o,n.length),u=n.slice(l,c);i.push({content:s.decode(u),hasContent:u.length>0})}return i}var zh,Kh,_a=C(()=>{"use strict";O();zh={name:"split",summary:"split a file into pieces",usage:"split [OPTION]... [FILE [PREFIX]]",description:"Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.",options:["-l N Put N lines per output file","-b SIZE Put SIZE bytes per output file (K, M, G suffixes)","-n CHUNKS Split into CHUNKS equal-sized files","-d Use numeric suffixes (00, 01, ...) instead of alphabetic","-a LENGTH Use suffixes of length LENGTH (default: 2)","--additional-suffix=SUFFIX Append SUFFIX to file names"],examples:["split -l 100 file.txt # Split into 100-line chunks","split -b 1M file.bin # Split into 1MB chunks","split -n 5 file.txt # Split into 5 equal parts","split -d file.txt part_ # part_00, part_01, ...","split -a 3 -d file.txt x # x000, x001, ..."]};Kh={name:"split",execute:async(t,e)=>{if(I(t))return N(zh);let r={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},n=[],s=0;for(;s<t.length;){let c=t[s];if(c==="-l"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${t[s+1]}'
370
+ `;s.push({content:l,hasContent:!0})}return s}function em(t,e){let n=new TextEncoder().encode(t),s=new TextDecoder,i=[];for(let o=0;o<n.length;o+=e){let a=n.slice(o,o+e);i.push({content:s.decode(a),hasContent:a.length>0})}return i}function tm(t,e){let n=new TextEncoder().encode(t),s=new TextDecoder,i=[],o=Math.ceil(n.length/e);for(let a=0;a<e;a++){let l=a*o,c=Math.min(l+o,n.length),u=n.slice(l,c);i.push({content:s.decode(u),hasContent:u.length>0})}return i}var Xh,rm,qa=C(()=>{"use strict";L();Xh={name:"split",summary:"split a file into pieces",usage:"split [OPTION]... [FILE [PREFIX]]",description:"Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'.",options:["-l N Put N lines per output file","-b SIZE Put SIZE bytes per output file (K, M, G suffixes)","-n CHUNKS Split into CHUNKS equal-sized files","-d Use numeric suffixes (00, 01, ...) instead of alphabetic","-a LENGTH Use suffixes of length LENGTH (default: 2)","--additional-suffix=SUFFIX Append SUFFIX to file names"],examples:["split -l 100 file.txt # Split into 100-line chunks","split -b 1M file.bin # Split into 1MB chunks","split -n 5 file.txt # Split into 5 equal parts","split -d file.txt part_ # part_00, part_01, ...","split -a 3 -d file.txt x # x000, x001, ..."]};rm={name:"split",execute:async(t,e)=>{if(N(t))return k(Xh);let r={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},n=[],s=0;for(;s<t.length;){let c=t[s];if(c==="-l"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${t[s+1]}'
371
371
  `};r.mode="lines",r.lines=u,s+=2}else if(c.match(/^-l\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${c.slice(2)}'
372
- `};r.mode="lines",r.lines=u,s++}else if(c==="-b"&&s+1<t.length){let u=Da(t[s+1]);if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${t[s+1]}'
373
- `};r.mode="bytes",r.bytes=u,s+=2}else if(c.match(/^-b.+$/)){let u=Da(c.slice(2));if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${c.slice(2)}'
372
+ `};r.mode="lines",r.lines=u,s++}else if(c==="-b"&&s+1<t.length){let u=Ha(t[s+1]);if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${t[s+1]}'
373
+ `};r.mode="bytes",r.bytes=u,s+=2}else if(c.match(/^-b.+$/)){let u=Ha(c.slice(2));if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${c.slice(2)}'
374
374
  `};r.mode="bytes",r.bytes=u,s++}else if(c==="-n"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of chunks: '${t[s+1]}'
375
375
  `};r.mode="chunks",r.chunks=u,s+=2}else if(c.match(/^-n\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of chunks: '${c.slice(2)}'
376
376
  `};r.mode="chunks",r.chunks=u,s++}else if(c==="-a"&&s+1<t.length){let u=Number.parseInt(t[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${t[s+1]}'
377
377
  `};r.suffixLength=u,s+=2}else if(c.match(/^-a\d+$/)){let u=Number.parseInt(c.slice(2),10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${c.slice(2)}'
378
- `};r.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")r.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))r.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<t.length)r.additionalSuffix=t[s+1],s+=2;else if(c==="--"){n.push(...t.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return $("split",c);n.push(c),s++}}let i="-",o="x";n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]);let a;if(i==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,i),u=await e.fs.readFile(c);if(u===null)return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
379
- `};a=u}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(r.mode){case"lines":l=Gh(a,r.lines);break;case"bytes":l=qh(a,r.bytes);break;case"chunks":l=Vh(a,r.chunks);break;default:return r.mode}for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=Hh(c,r.useNumericSuffix,r.suffixLength),d=`${o}${f}${r.additionalSuffix}`,p=e.fs.resolvePath(e.cwd,d);await e.fs.writeFile(p,u.content)}return{exitCode:0,stdout:"",stderr:""}}}});var Wa={};v(Wa,{column:()=>em});function Ba(t,e,r){return e?r?t.split(e):t.split(e).filter(n=>n.length>0):r?t.split(/[ \t]/):t.split(/[ \t]+/).filter(n=>n.length>0)}function Xh(t){let e=[];for(let r of t)for(let n=0;n<r.length;n++){let s=r[n].length;(e[n]===void 0||s>e[n])&&(e[n]=s)}return e}function Jh(t,e){if(t.length===0)return"";let r=Xh(t),n=[];for(let s of t){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(r[o]));n.push(i.join(e))}return n.join(`
380
- `)}function Yh(t,e,r){if(t.length===0)return"";let n=Math.max(...t.map(c=>c.length)),s=r.length,i=n+s,o=Math.max(1,Math.floor((e+s)/i)),a=Math.ceil(t.length/o),l=[];for(let c=0;c<a;c++){let u=[];for(let f=0;f<o;f++){let d=f*a+c;d<t.length&&(f===o-1||(f+1)*a+c>=t.length?u.push(t[d]):u.push(t[d].padEnd(n)))}l.push(u.join(r))}return l.join(`
381
- `)}var Zh,Qh,em,Ua=C(()=>{"use strict";ae();O();Zh={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},Qh={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};em={name:"column",execute:async(t,e)=>{if(I(t))return N(Zh);let r=j("column",t,Qh);if(!r.ok)return r.error;let{table:n,separator:s,outputSep:i,width:o,noMerge:a}=r.result.flags,l=r.result.positional,c=i??" ",u;if(l.length===0)u=e.stdin??"";else{let y=[];for(let m of l)if(m==="-")y.push(e.stdin??"");else{let w=e.fs.resolvePath(e.cwd,m),b=await e.fs.readFile(w);if(b===null)return{exitCode:1,stdout:"",stderr:`column: ${m}: No such file or directory
382
- `};y.push(b)}u=y.join("")}if(u===""||u.trim()==="")return{exitCode:0,stdout:"",stderr:""};let f=u.split(`
378
+ `};r.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")r.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))r.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<t.length)r.additionalSuffix=t[s+1],s+=2;else if(c==="--"){n.push(...t.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return P("split",c);n.push(c),s++}}let i="-",o="x";n.length>=1&&(i=n[0]),n.length>=2&&(o=n[1]);let a;if(i==="-")a=e.stdin??"";else{let c=e.fs.resolvePath(e.cwd,i),u=await e.fs.readFile(c);if(u===null)return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
379
+ `};a=u}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(r.mode){case"lines":l=Yh(a,r.lines);break;case"bytes":l=em(a,r.bytes);break;case"chunks":l=tm(a,r.chunks);break;default:return r.mode}for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=Jh(c,r.useNumericSuffix,r.suffixLength),p=`${o}${f}${r.additionalSuffix}`,d=e.fs.resolvePath(e.cwd,p);await e.fs.writeFile(d,u.content)}return{exitCode:0,stdout:"",stderr:""}}}});var Ka={};R(Ka,{column:()=>lm});function Va(t,e,r){return e?r?t.split(e):t.split(e).filter(n=>n.length>0):r?t.split(/[ \t]/):t.split(/[ \t]+/).filter(n=>n.length>0)}function im(t){let e=[];for(let r of t)for(let n=0;n<r.length;n++){let s=r[n].length;(e[n]===void 0||s>e[n])&&(e[n]=s)}return e}function om(t,e){if(t.length===0)return"";let r=im(t),n=[];for(let s of t){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(r[o]));n.push(i.join(e))}return n.join(`
380
+ `)}function am(t,e,r){if(t.length===0)return"";let n=Math.max(...t.map(c=>c.length)),s=r.length,i=n+s,o=Math.max(1,Math.floor((e+s)/i)),a=Math.ceil(t.length/o),l=[];for(let c=0;c<a;c++){let u=[];for(let f=0;f<o;f++){let p=f*a+c;p<t.length&&(f===o-1||(f+1)*a+c>=t.length?u.push(t[p]):u.push(t[p].padEnd(n)))}l.push(u.join(r))}return l.join(`
381
+ `)}var nm,sm,lm,Za=C(()=>{"use strict";ye();L();nm={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},sm={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};lm={name:"column",execute:async(t,e)=>{if(N(t))return k(nm);let r=z("column",t,sm);if(!r.ok)return r.error;let{table:n,separator:s,outputSep:i,width:o,noMerge:a}=r.result.flags,l=r.result.positional,c=i??" ",u;if(l.length===0)u=e.stdin??"";else{let m=[];for(let g of l)if(g==="-")m.push(e.stdin??"");else{let w=e.fs.resolvePath(e.cwd,g),b=await e.fs.readFile(w);if(b===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
382
+ `};m.push(b)}u=m.join("")}if(u===""||u.trim()==="")return{exitCode:0,stdout:"",stderr:""};let f=u.split(`
383
383
  `);u.endsWith(`
384
- `)&&f[f.length-1]===""&&f.pop();let p=f.filter(y=>y.trim().length>0),h;if(n){let y=p.map(m=>Ba(m,s,a));h=Jh(y,c)}else{let y=[];for(let m of p){let w=Ba(m,s,a);y.push(...w)}h=Yh(y,o,c)}return h.length>0&&(h+=`
385
- `),{exitCode:0,stdout:h,stderr:""}}}});var ja={};v(ja,{join:()=>im});function rm(t,e){return e?t.split(e):t.split(/[ \t]+/).filter(r=>r.length>0)}function nm(t,e,r,n){let s=rm(t,e),i=s[r-1]??"";return n&&(i=i.toLowerCase()),{fields:s,joinKey:i,original:t}}function Vn(t,e,r){let n=r.separator??" ";if(r.outputFormat){let o=[];for(let{file:a,field:l}of r.outputFormat){let c=a===1?t:e;c&&l===0?o.push(c.joinKey):c&&c.fields[l-1]!==void 0?o.push(c.fields[l-1]):o.push(r.emptyString)}return o.join(n)}let s=[],i=t?.joinKey??e?.joinKey??"";if(s.push(i),t)for(let o=0;o<t.fields.length;o++)o!==r.field1-1&&s.push(t.fields[o]);if(e)for(let o=0;o<e.fields.length;o++)o!==r.field2-1&&s.push(e.fields[o]);return s.join(n)}function sm(t){let e=t.split(","),r=[];for(let n of e){let s=n.trim().match(/^(\d+)\.(\d+)$/);if(!s)return null;let i=Number.parseInt(s[1],10),o=Number.parseInt(s[2],10);if(i!==1&&i!==2)return null;r.push({file:i,field:o})}return r}var tm,im,za=C(()=>{"use strict";O();tm={name:"join",summary:"join lines of two files on a common field",usage:"join [OPTION]... FILE1 FILE2",description:"For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.",options:["-1 FIELD Join on this FIELD of file 1 (default: 1)","-2 FIELD Join on this FIELD of file 2 (default: 1)","-t CHAR Use CHAR as input and output field separator","-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)","-v FILENUM Like -a but only output unpairable lines","-e STRING Replace missing fields with STRING","-o FORMAT Output format (comma-separated list of FILENUM.FIELD)","-i Ignore case when comparing fields"],examples:["join file1 file2 # Join on first field","join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1","join -t ',' file1.csv file2.csv # Join CSV files","join -a 1 file1 file2 # Left outer join"]};im={name:"join",execute:async(t,e)=>{if(I(t))return N(tm);let r={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},n=[],s=0;for(;s<t.length;){let d=t[s];if(d==="-1"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${t[s+1]}'
386
- `};r.field1=p,s+=2}else if(d==="-2"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${t[s+1]}'
387
- `};r.field2=p,s+=2}else if((d==="-t"||d==="--field-separator")&&s+1<t.length)r.separator=t[s+1],s+=2;else if(d.startsWith("-t")&&d.length>2)r.separator=d.slice(2),s++;else if(d==="-a"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(p!==1&&p!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${t[s+1]}'
388
- `};r.printUnpairable.add(p),s+=2}else if(d.match(/^-a[12]$/))r.printUnpairable.add(Number.parseInt(d[2],10)),s++;else if(d==="-v"&&s+1<t.length){let p=Number.parseInt(t[s+1],10);if(p!==1&&p!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${t[s+1]}'
389
- `};r.onlyUnpairable.add(p),s+=2}else if(d.match(/^-v[12]$/))r.onlyUnpairable.add(Number.parseInt(d[2],10)),s++;else if(d==="-e"&&s+1<t.length)r.emptyString=t[s+1],s+=2;else if(d==="-o"&&s+1<t.length){let p=sm(t[s+1]);if(!p)return{exitCode:1,stdout:"",stderr:`join: invalid field spec: '${t[s+1]}'
390
- `};r.outputFormat=p,s+=2}else if(d==="-i"||d==="--ignore-case")r.ignoreCase=!0,s++;else if(d==="--"){n.push(...t.slice(s+1));break}else{if(d.startsWith("-")&&d!=="-")return $("join",d);n.push(d),s++}}if(n.length!==2)return{exitCode:1,stdout:"",stderr:n.length<2?`join: missing file operand
384
+ `)&&f[f.length-1]===""&&f.pop();let d=f.filter(m=>m.trim().length>0),h;if(n){let m=d.map(g=>Va(g,s,a));h=om(m,c)}else{let m=[];for(let g of d){let w=Va(g,s,a);m.push(...w)}h=am(m,o,c)}return h.length>0&&(h+=`
385
+ `),{exitCode:0,stdout:h,stderr:""}}}});var Qa={};R(Qa,{join:()=>dm});function um(t,e){return e?t.split(e):t.split(/[ \t]+/).filter(r=>r.length>0)}function fm(t,e,r,n){let s=um(t,e),i=s[r-1]??"";return n&&(i=i.toLowerCase()),{fields:s,joinKey:i,original:t}}function ts(t,e,r){let n=r.separator??" ";if(r.outputFormat){let o=[];for(let{file:a,field:l}of r.outputFormat){let c=a===1?t:e;c&&l===0?o.push(c.joinKey):c&&c.fields[l-1]!==void 0?o.push(c.fields[l-1]):o.push(r.emptyString)}return o.join(n)}let s=[],i=t?.joinKey??e?.joinKey??"";if(s.push(i),t)for(let o=0;o<t.fields.length;o++)o!==r.field1-1&&s.push(t.fields[o]);if(e)for(let o=0;o<e.fields.length;o++)o!==r.field2-1&&s.push(e.fields[o]);return s.join(n)}function pm(t){let e=t.split(","),r=[];for(let n of e){let s=n.trim().match(/^(\d+)\.(\d+)$/);if(!s)return null;let i=Number.parseInt(s[1],10),o=Number.parseInt(s[2],10);if(i!==1&&i!==2)return null;r.push({file:i,field:o})}return r}var cm,dm,Xa=C(()=>{"use strict";L();cm={name:"join",summary:"join lines of two files on a common field",usage:"join [OPTION]... FILE1 FILE2",description:"For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.",options:["-1 FIELD Join on this FIELD of file 1 (default: 1)","-2 FIELD Join on this FIELD of file 2 (default: 1)","-t CHAR Use CHAR as input and output field separator","-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)","-v FILENUM Like -a but only output unpairable lines","-e STRING Replace missing fields with STRING","-o FORMAT Output format (comma-separated list of FILENUM.FIELD)","-i Ignore case when comparing fields"],examples:["join file1 file2 # Join on first field","join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1","join -t ',' file1.csv file2.csv # Join CSV files","join -a 1 file1 file2 # Left outer join"]};dm={name:"join",execute:async(t,e)=>{if(N(t))return k(cm);let r={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},n=[],s=0;for(;s<t.length;){let p=t[s];if(p==="-1"&&s+1<t.length){let d=Number.parseInt(t[s+1],10);if(Number.isNaN(d)||d<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${t[s+1]}'
386
+ `};r.field1=d,s+=2}else if(p==="-2"&&s+1<t.length){let d=Number.parseInt(t[s+1],10);if(Number.isNaN(d)||d<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${t[s+1]}'
387
+ `};r.field2=d,s+=2}else if((p==="-t"||p==="--field-separator")&&s+1<t.length)r.separator=t[s+1],s+=2;else if(p.startsWith("-t")&&p.length>2)r.separator=p.slice(2),s++;else if(p==="-a"&&s+1<t.length){let d=Number.parseInt(t[s+1],10);if(d!==1&&d!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${t[s+1]}'
388
+ `};r.printUnpairable.add(d),s+=2}else if(p.match(/^-a[12]$/))r.printUnpairable.add(Number.parseInt(p[2],10)),s++;else if(p==="-v"&&s+1<t.length){let d=Number.parseInt(t[s+1],10);if(d!==1&&d!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${t[s+1]}'
389
+ `};r.onlyUnpairable.add(d),s+=2}else if(p.match(/^-v[12]$/))r.onlyUnpairable.add(Number.parseInt(p[2],10)),s++;else if(p==="-e"&&s+1<t.length)r.emptyString=t[s+1],s+=2;else if(p==="-o"&&s+1<t.length){let d=pm(t[s+1]);if(!d)return{exitCode:1,stdout:"",stderr:`join: invalid field spec: '${t[s+1]}'
390
+ `};r.outputFormat=d,s+=2}else if(p==="-i"||p==="--ignore-case")r.ignoreCase=!0,s++;else if(p==="--"){n.push(...t.slice(s+1));break}else{if(p.startsWith("-")&&p!=="-")return P("join",p);n.push(p),s++}}if(n.length!==2)return{exitCode:1,stdout:"",stderr:n.length<2?`join: missing file operand
391
391
  `:`join: extra operand
392
- `};let i=[];for(let d of n)if(d==="-")i.push(e.stdin??"");else{let p=e.fs.resolvePath(e.cwd,d),h=await e.fs.readFile(p);if(h===null)return{exitCode:1,stdout:"",stderr:`join: ${d}: No such file or directory
393
- `};i.push(h)}let o=(d,p)=>{let h=d.split(`
394
- `);return d.endsWith(`
395
- `)&&h[h.length-1]===""&&h.pop(),h.filter(y=>y.length>0).map(y=>nm(y,r.separator,p,r.ignoreCase))},a=o(i[0],r.field1),l=o(i[1],r.field2),c=new Map;for(let d of l){let p=c.get(d.joinKey);p?p.push(d):c.set(d.joinKey,[d])}let u=[],f=new Set;for(let d of a){let p=c.get(d.joinKey);if(p&&p.length>0){if(f.add(d.joinKey),r.onlyUnpairable.size===0)for(let h of p)u.push(Vn(d,h,r))}else(r.printUnpairable.has(1)||r.onlyUnpairable.has(1))&&u.push(Vn(d,null,r))}if(r.printUnpairable.has(2)||r.onlyUnpairable.has(2))for(let d of l)f.has(d.joinKey)||u.push(Vn(null,d,r));return{exitCode:0,stdout:u.length>0?`${u.join(`
392
+ `};let i=[];for(let p of n)if(p==="-")i.push(e.stdin??"");else{let d=e.fs.resolvePath(e.cwd,p),h=await e.fs.readFile(d);if(h===null)return{exitCode:1,stdout:"",stderr:`join: ${p}: No such file or directory
393
+ `};i.push(h)}let o=(p,d)=>{let h=p.split(`
394
+ `);return p.endsWith(`
395
+ `)&&h[h.length-1]===""&&h.pop(),h.filter(m=>m.length>0).map(m=>fm(m,r.separator,d,r.ignoreCase))},a=o(i[0],r.field1),l=o(i[1],r.field2),c=new Map;for(let p of l){let d=c.get(p.joinKey);d?d.push(p):c.set(p.joinKey,[p])}let u=[],f=new Set;for(let p of a){let d=c.get(p.joinKey);if(d&&d.length>0){if(f.add(p.joinKey),r.onlyUnpairable.size===0)for(let h of d)u.push(ts(p,h,r))}else(r.printUnpairable.has(1)||r.onlyUnpairable.has(1))&&u.push(ts(p,null,r))}if(r.printUnpairable.has(2)||r.onlyUnpairable.has(2))for(let p of l)f.has(p.joinKey)||u.push(ts(null,p,r));return{exitCode:0,stdout:u.length>0?`${u.join(`
396
396
  `)}
397
- `:"",stderr:""}}}});var Ha={};v(Ha,{teeCommand:()=>lm});var om,am,lm,Ga=C(()=>{"use strict";ae();O();om={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append append to the given FILEs, do not overwrite"," --help display this help and exit"]},am={append:{short:"a",long:"append",type:"boolean"}},lm={name:"tee",async execute(t,e){if(I(t))return N(om);let r=j("tee",t,am);if(!r.ok)return r.error;let{append:n}=r.result.flags,s=r.result.positional,i=e.stdin,o="",a=0;for(let l of s)try{let c=e.fs.resolvePath(e.cwd,l);n?await e.fs.appendFile(c,i):await e.fs.writeFile(c,i)}catch{o+=`tee: ${l}: No such file or directory
398
- `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function et(t,e){switch(t.type){case"name":return{matches:$e(e.name,t.pattern,t.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:$e(e.relativePath,t.pattern,t.ignoreCase),pruned:!1,printed:!1};case"regex":try{let r=t.ignoreCase?"i":"";return{matches:new RegExp(t.pattern,r).test(e.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return t.fileType==="f"?{matches:e.isFile,pruned:!1,printed:!1}:t.fileType==="d"?{matches:e.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:e.isEmpty,pruned:!1,printed:!1};case"mtime":{let n=(Date.now()-e.mtime)/(1e3*60*60*24),s;return t.comparison==="more"?s=n>t.days:t.comparison==="less"?s=n<t.days:s=Math.floor(n)===t.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let r=e.newerRefTimes.get(t.refPath);return r===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:e.mtime>r,pruned:!1,printed:!1}}case"size":{let r=t.value;switch(t.unit){case"c":r=t.value;break;case"k":r=t.value*1024;break;case"M":r=t.value*1024*1024;break;case"G":r=t.value*1024*1024*1024;break;case"b":r=t.value*512;break}let n;return t.comparison==="more"?n=e.size>r:t.comparison==="less"?n=e.size<r:t.unit==="b"?n=Math.ceil(e.size/512)===t.value:n=e.size===r,{matches:n,pruned:!1,printed:!1}}case"perm":{let r=e.mode&511,n=t.mode&511,s;return t.matchType==="exact"?s=r===n:t.matchType==="all"?s=(r&n)===n:s=(r&n)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let r=et(t.expr,e);return{matches:!r.matches,pruned:r.pruned,printed:!1}}case"and":{let r=et(t.left,e);if(!r.matches)return{matches:!1,pruned:r.pruned,printed:!1};let n=et(t.right,e);return{matches:n.matches,pruned:r.pruned||n.pruned,printed:r.printed||n.printed}}case"or":{let r=et(t.left,e);if(r.matches)return r;let n=et(t.right,e);return{matches:n.matches,pruned:r.pruned||n.pruned,printed:n.printed}}}}function qa(t){let e=[],r=n=>{n&&(n.type==="newer"?e.push(n.refPath):n.type==="not"?r(n.expr):(n.type==="and"||n.type==="or")&&(r(n.left),r(n.right)))};return r(t),e}var Va=C(()=>{"use strict";Pn()});function Ka(t,e){let r=[],n=[],s=e;for(;s<t.length;){let o=t[s];if(o==="("||o==="\\("){r.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){r.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<t.length)r.push({type:"expr",expr:{type:"name",pattern:t[++s]}});else if(o==="-iname"&&s+1<t.length)r.push({type:"expr",expr:{type:"name",pattern:t[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<t.length)r.push({type:"expr",expr:{type:"path",pattern:t[++s]}});else if(o==="-ipath"&&s+1<t.length)r.push({type:"expr",expr:{type:"path",pattern:t[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<t.length)r.push({type:"expr",expr:{type:"regex",pattern:t[++s]}});else if(o==="-iregex"&&s+1<t.length)r.push({type:"expr",expr:{type:"regex",pattern:t[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<t.length){let a=t[++s];if(a==="f"||a==="d")r.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
399
- `,actions:[]}}else if(o==="-empty")r.push({type:"expr",expr:{type:"empty"}});else if(o==="-mtime"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=parseInt(c,10);Number.isNaN(u)||r.push({type:"expr",expr:{type:"mtime",days:u,comparison:l}})}else if(o==="-newer"&&s+1<t.length){let a=t[++s];r.push({type:"expr",expr:{type:"newer",refPath:a}})}else if(o==="-size"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=c.match(/^(\d+)([ckMGb])?$/);if(u){let f=parseInt(u[1],10),d=u[2]||"b";r.push({type:"expr",expr:{type:"size",value:f,unit:d,comparison:l}})}}else if(o==="-perm"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("-")?(l="all",c=a.slice(1)):a.startsWith("/")&&(l="any",c=a.slice(1));let u=parseInt(c,8);Number.isNaN(u)||r.push({type:"expr",expr:{type:"perm",mode:u,matchType:l}})}else if(o==="-prune")r.push({type:"expr",expr:{type:"prune"}});else if(o==="-not"||o==="!")r.push({type:"not"});else if(o==="-o"||o==="-or")r.push({type:"op",op:"or"});else if(o==="-a"||o==="-and")r.push({type:"op",op:"and"});else if(o==="-maxdepth"||o==="-mindepth")s++;else if(o!=="-depth")if(o==="-exec"){let a=[];for(s++;s<t.length&&t[s]!==";"&&t[s]!=="+";)a.push(t[s]),s++;if(s>=t.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let l=t[s]==="+";n.push({type:"exec",command:a,batchMode:l})}else if(o==="-print")r.push({type:"expr",expr:{type:"print"}}),n.push({type:"print"});else if(o==="-print0")n.push({type:"print0"});else if(o==="-printf"&&s+1<t.length){let a=t[++s];n.push({type:"printf",format:a})}else if(o==="-delete")n.push({type:"delete"});else{if(o.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${o}'
400
- `,actions:[]};if(r.length===0){s++;continue}break}s++}if(r.length===0)return{expr:null,pathIndex:s,actions:n};let i=cm(r);return i.error?{expr:null,pathIndex:s,error:i.error,actions:n}:{expr:i.expr,pathIndex:s,actions:n}}function cm(t){let e=0;function r(){let a=n();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="or"){e++;let c=n();if(!c)return a;a={type:"or",left:a,right:c}}else break}return a}function n(){let a=s();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="and"){e++;let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else if(l.type==="expr"||l.type==="not"||l.type==="lparen"){let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else break}return a}function s(){if(e<t.length&&t[e].type==="not"){e++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(e>=t.length)return null;let a=t[e];if(a.type==="lparen"){e++;let l=r();return e<t.length&&t[e].type==="rparen"&&e++,l}return a.type==="expr"?(e++,a.expr):(a.type==="rparen",null)}return{expr:r()}}var Za=C(()=>{"use strict"});var Qa={};v(Qa,{findCommand:()=>dm});function pm(t,e){let r=yr(t),n="",s=0;for(;s<r.length;)if(r[s]==="%"&&s+1<r.length){if(s++,r[s]==="%"){n+="%",s++;continue}let[i,o,a]=$i(r,s);if(s+=a,s>=r.length){n+="%";break}let l=r[s],c;switch(l){case"f":c=e.name,s++;break;case"h":{let u=e.path.lastIndexOf("/");c=u>0?e.path.slice(0,u):".",s++;break}case"p":c=e.path,s++;break;case"P":{let u=e.startingPoint;e.path===u?c="":e.path.startsWith(`${u}/`)?c=e.path.slice(u.length+1):u==="."&&e.path.startsWith("./")?c=e.path.slice(2):c=e.path,s++;break}case"s":c=String(e.size),s++;break;case"d":c=String(e.depth),s++;break;case"m":c=(e.mode&511).toString(8),s++;break;case"M":c=hm(e.mode,e.isDirectory),s++;break;case"t":{let u=new Date(e.mtime);c=mm(u),s++;break}case"T":{if(s+1<r.length){let u=r[s+1],f=new Date(e.mtime);c=gm(f,u),s+=2}else c="%T",s++;break}default:n+=`%${i!==0||o!==-1?`${i}.${o}`:""}${l}`,s++;continue}n+=gr(c,i,o)}else n+=r[s],s++;return n}function hm(t,e){let r=t&511,n=e?"d":"-";return n+=r&256?"r":"-",n+=r&128?"w":"-",n+=r&64?"x":"-",n+=r&32?"r":"-",n+=r&16?"w":"-",n+=r&8?"x":"-",n+=r&4?"r":"-",n+=r&2?"w":"-",n+=r&1?"x":"-",n}function mm(t){let e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=e[t.getDay()],s=r[t.getMonth()],i=String(t.getDate()).padStart(2," "),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=String(t.getSeconds()).padStart(2,"0"),c=t.getFullYear();return`${n} ${s} ${i} ${o}:${a}:${l} ${c}`}function gm(t,e){switch(e){case"@":return String(t.getTime()/1e3);case"Y":return String(t.getFullYear());case"m":return String(t.getMonth()+1).padStart(2,"0");case"d":return String(t.getDate()).padStart(2,"0");case"H":return String(t.getHours()).padStart(2,"0");case"M":return String(t.getMinutes()).padStart(2,"0");case"S":return String(t.getSeconds()).padStart(2,"0");case"T":return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`;case"F":return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;default:return`%T${e}`}}var um,fm,dm,Xa=C(()=>{"use strict";O();vn();Va();Za();um={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},fm=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),dm={name:"find",async execute(t,e){if(I(t))return N(um);let r=[],n=null,s=null,i=!1,o=!1;for(let S=0;S<t.length;S++){let A=t[S];if(A==="-maxdepth"&&S+1<t.length)o=!0,n=parseInt(t[++S],10);else if(A==="-mindepth"&&S+1<t.length)o=!0,s=parseInt(t[++S],10);else if(A==="-depth")o=!0,i=!0;else if(A==="-exec")for(o=!0,S++;S<t.length&&t[S]!==";"&&t[S]!=="+";)S++;else!A.startsWith("-")&&A!==";"&&A!=="+"&&A!=="("&&A!==")"&&A!=="\\("&&A!=="\\)"&&A!=="!"?o||r.push(A):fm.has(A)?(o=!0,S++):(A.startsWith("-")||A==="("||A==="\\("||A==="!")&&(o=!0)}r.length===0&&r.push(".");let{expr:a,error:l,actions:c}=Ka(t,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some(S=>S.type==="print"),f=c.length===0,d=[],p=c.some(S=>S.type==="printf"),h=[],y="",m=0,w=qa(a),b=new Map;for(let S of w){let A=e.fs.resolvePath(e.cwd,S);try{let F=await e.fs.stat(A);b.set(S,F.mtime?.getTime()??Date.now())}catch{}}for(let S of r){S.length>1&&S.endsWith("/")&&(S=S.slice(0,-1));let A=e.fs.resolvePath(e.cwd,S);try{await e.fs.stat(A)}catch{y+=`find: ${S}: No such file or directory
401
- `,m=1;continue}async function F(M,D){if(n!==null&&D>n)return;let U;try{U=await e.fs.stat(M)}catch{return}if(!U)return;let te;M===A?te=S.split("/").pop()||S:te=M.split("/").pop()||"";let de=M===A?S:S==="."?`./${M.slice(A==="/"?A.length:A.length+1)}`:S+M.slice(A.length),se=null;U.isDirectory&&(se=await e.fs.readdir(M));let Ce=U.isFile?U.size===0:se!==null&&se.length===0,je=()=>{let z=s===null||D>=s,H=!1;if(z&&a!==null){let Ae={name:te,relativePath:de,isFile:U.isFile,isDirectory:U.isDirectory,isEmpty:Ce,mtime:U.mtime?.getTime()??Date.now(),size:U.size??0,mode:U.mode??420,newerRefTimes:b},_e=et(a,Ae);z=_e.matches,u?H=_e.printed:H=z}else z&&(H=!0);H&&(d.push(de),p&&h.push({path:de,name:te,size:U.size??0,mtime:U.mtime?.getTime()??Date.now(),mode:U.mode??420,isDirectory:U.isDirectory,depth:D,startingPoint:S}))},De=async()=>{if(se!==null)for(let Me of se){let z=M==="/"?`/${Me}`:`${M}/${Me}`;await F(z,D+1)}},hr=!1;if(!i&&a!==null){let Me={name:te,relativePath:de,isFile:U.isFile,isDirectory:U.isDirectory,isEmpty:Ce,mtime:U.mtime?.getTime()??Date.now(),size:U.size??0,mode:U.mode??420,newerRefTimes:b};hr=et(a,Me).pruned}i?(await De(),je()):(je(),hr||await De())}await F(A,0)}let E="";if(c.length>0)for(let S of c)switch(S.type){case"print":E+=d.length>0?`${d.join(`
397
+ `:"",stderr:""}}}});var Ja={};R(Ja,{teeCommand:()=>gm});var hm,mm,gm,Ya=C(()=>{"use strict";ye();L();hm={name:"tee",summary:"read from stdin and write to stdout and files",usage:"tee [OPTION]... [FILE]...",options:["-a, --append append to the given FILEs, do not overwrite"," --help display this help and exit"]},mm={append:{short:"a",long:"append",type:"boolean"}},gm={name:"tee",async execute(t,e){if(N(t))return k(hm);let r=z("tee",t,mm);if(!r.ok)return r.error;let{append:n}=r.result.flags,s=r.result.positional,i=e.stdin,o="",a=0;for(let l of s)try{let c=e.fs.resolvePath(e.cwd,l);n?await e.fs.appendFile(c,i):await e.fs.writeFile(c,i)}catch{o+=`tee: ${l}: No such file or directory
398
+ `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function ot(t,e){switch(t.type){case"name":return{matches:De(e.name,t.pattern,t.ignoreCase),pruned:!1,printed:!1};case"path":return{matches:De(e.relativePath,t.pattern,t.ignoreCase),pruned:!1,printed:!1};case"regex":try{let r=t.ignoreCase?"i":"";return{matches:new RegExp(t.pattern,r).test(e.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return t.fileType==="f"?{matches:e.isFile,pruned:!1,printed:!1}:t.fileType==="d"?{matches:e.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:e.isEmpty,pruned:!1,printed:!1};case"mtime":{let n=(Date.now()-e.mtime)/(1e3*60*60*24),s;return t.comparison==="more"?s=n>t.days:t.comparison==="less"?s=n<t.days:s=Math.floor(n)===t.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let r=e.newerRefTimes.get(t.refPath);return r===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:e.mtime>r,pruned:!1,printed:!1}}case"size":{let r=t.value;switch(t.unit){case"c":r=t.value;break;case"k":r=t.value*1024;break;case"M":r=t.value*1024*1024;break;case"G":r=t.value*1024*1024*1024;break;case"b":r=t.value*512;break}let n;return t.comparison==="more"?n=e.size>r:t.comparison==="less"?n=e.size<r:t.unit==="b"?n=Math.ceil(e.size/512)===t.value:n=e.size===r,{matches:n,pruned:!1,printed:!1}}case"perm":{let r=e.mode&511,n=t.mode&511,s;return t.matchType==="exact"?s=r===n:t.matchType==="all"?s=(r&n)===n:s=(r&n)!==0,{matches:s,pruned:!1,printed:!1}}case"prune":return{matches:!0,pruned:!0,printed:!1};case"print":return{matches:!0,pruned:!1,printed:!0};case"not":{let r=ot(t.expr,e);return{matches:!r.matches,pruned:r.pruned,printed:!1}}case"and":{let r=ot(t.left,e);if(!r.matches)return{matches:!1,pruned:r.pruned,printed:!1};let n=ot(t.right,e);return{matches:n.matches,pruned:r.pruned||n.pruned,printed:r.printed||n.printed}}case"or":{let r=ot(t.left,e);if(r.matches)return r;let n=ot(t.right,e);return{matches:n.matches,pruned:r.pruned||n.pruned,printed:n.printed}}}}function lr(t){if(!t)return!1;switch(t.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!1;case"empty":case"mtime":case"newer":case"size":case"perm":return!0;case"not":return lr(t.expr);case"and":case"or":return lr(t.left)||lr(t.right)}}function el(t){let e=[],r=n=>{n&&(n.type==="newer"?e.push(n.refPath):n.type==="not"?r(n.expr):(n.type==="and"||n.type==="or")&&(r(n.left),r(n.right)))};return r(t),e}var tl=C(()=>{"use strict";Wn()});function rl(t,e){let r=[],n=[],s=e;for(;s<t.length;){let o=t[s];if(o==="("||o==="\\("){r.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){r.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<t.length)r.push({type:"expr",expr:{type:"name",pattern:t[++s]}});else if(o==="-iname"&&s+1<t.length)r.push({type:"expr",expr:{type:"name",pattern:t[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<t.length)r.push({type:"expr",expr:{type:"path",pattern:t[++s]}});else if(o==="-ipath"&&s+1<t.length)r.push({type:"expr",expr:{type:"path",pattern:t[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<t.length)r.push({type:"expr",expr:{type:"regex",pattern:t[++s]}});else if(o==="-iregex"&&s+1<t.length)r.push({type:"expr",expr:{type:"regex",pattern:t[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<t.length){let a=t[++s];if(a==="f"||a==="d")r.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
399
+ `,actions:[]}}else if(o==="-empty")r.push({type:"expr",expr:{type:"empty"}});else if(o==="-mtime"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=parseInt(c,10);Number.isNaN(u)||r.push({type:"expr",expr:{type:"mtime",days:u,comparison:l}})}else if(o==="-newer"&&s+1<t.length){let a=t[++s];r.push({type:"expr",expr:{type:"newer",refPath:a}})}else if(o==="-size"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("+")?(l="more",c=a.slice(1)):a.startsWith("-")&&(l="less",c=a.slice(1));let u=c.match(/^(\d+)([ckMGb])?$/);if(u){let f=parseInt(u[1],10),p=u[2]||"b";r.push({type:"expr",expr:{type:"size",value:f,unit:p,comparison:l}})}}else if(o==="-perm"&&s+1<t.length){let a=t[++s],l="exact",c=a;a.startsWith("-")?(l="all",c=a.slice(1)):a.startsWith("/")&&(l="any",c=a.slice(1));let u=parseInt(c,8);Number.isNaN(u)||r.push({type:"expr",expr:{type:"perm",mode:u,matchType:l}})}else if(o==="-prune")r.push({type:"expr",expr:{type:"prune"}});else if(o==="-not"||o==="!")r.push({type:"not"});else if(o==="-o"||o==="-or")r.push({type:"op",op:"or"});else if(o==="-a"||o==="-and")r.push({type:"op",op:"and"});else if(o==="-maxdepth"||o==="-mindepth")s++;else if(o!=="-depth")if(o==="-exec"){let a=[];for(s++;s<t.length&&t[s]!==";"&&t[s]!=="+";)a.push(t[s]),s++;if(s>=t.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let l=t[s]==="+";n.push({type:"exec",command:a,batchMode:l})}else if(o==="-print")r.push({type:"expr",expr:{type:"print"}}),n.push({type:"print"});else if(o==="-print0")n.push({type:"print0"});else if(o==="-printf"&&s+1<t.length){let a=t[++s];n.push({type:"printf",format:a})}else if(o==="-delete")n.push({type:"delete"});else{if(o.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${o}'
400
+ `,actions:[]};if(r.length===0){s++;continue}break}s++}if(r.length===0)return{expr:null,pathIndex:s,actions:n};let i=ym(r);return i.error?{expr:null,pathIndex:s,error:i.error,actions:n}:{expr:i.expr,pathIndex:s,actions:n}}function ym(t){let e=0;function r(){let a=n();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="or"){e++;let c=n();if(!c)return a;a={type:"or",left:a,right:c}}else break}return a}function n(){let a=s();if(!a)return null;for(;e<t.length;){let l=t[e];if(l.type==="op"&&l.op==="and"){e++;let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else if(l.type==="expr"||l.type==="not"||l.type==="lparen"){let c=s();if(!c)return a;a={type:"and",left:a,right:c}}else break}return a}function s(){if(e<t.length&&t[e].type==="not"){e++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(e>=t.length)return null;let a=t[e];if(a.type==="lparen"){e++;let l=r();return e<t.length&&t[e].type==="rparen"&&e++,l}return a.type==="expr"?(e++,a.expr):(a.type==="rparen",null)}return{expr:r()}}var nl=C(()=>{"use strict"});var sl={};R(sl,{findCommand:()=>bm});function Em(t,e){let r=Nr(t),n="",s=0;for(;s<r.length;)if(r[s]==="%"&&s+1<r.length){if(s++,r[s]==="%"){n+="%",s++;continue}let[i,o,a]=Mi(r,s);if(s+=a,s>=r.length){n+="%";break}let l=r[s],c;switch(l){case"f":c=e.name,s++;break;case"h":{let u=e.path.lastIndexOf("/");c=u>0?e.path.slice(0,u):".",s++;break}case"p":c=e.path,s++;break;case"P":{let u=e.startingPoint;e.path===u?c="":e.path.startsWith(`${u}/`)?c=e.path.slice(u.length+1):u==="."&&e.path.startsWith("./")?c=e.path.slice(2):c=e.path,s++;break}case"s":c=String(e.size),s++;break;case"d":c=String(e.depth),s++;break;case"m":c=(e.mode&511).toString(8),s++;break;case"M":c=Sm(e.mode,e.isDirectory),s++;break;case"t":{let u=new Date(e.mtime);c=Cm(u),s++;break}case"T":{if(s+1<r.length){let u=r[s+1],f=new Date(e.mtime);c=Am(f,u),s+=2}else c="%T",s++;break}default:n+=`%${i!==0||o!==-1?`${i}.${o}`:""}${l}`,s++;continue}n+=kr(c,i,o)}else n+=r[s],s++;return n}function Sm(t,e){let r=t&511,n=e?"d":"-";return n+=r&256?"r":"-",n+=r&128?"w":"-",n+=r&64?"x":"-",n+=r&32?"r":"-",n+=r&16?"w":"-",n+=r&8?"x":"-",n+=r&4?"r":"-",n+=r&2?"w":"-",n+=r&1?"x":"-",n}function Cm(t){let e=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],n=e[t.getDay()],s=r[t.getMonth()],i=String(t.getDate()).padStart(2," "),o=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0"),l=String(t.getSeconds()).padStart(2,"0"),c=t.getFullYear();return`${n} ${s} ${i} ${o}:${a}:${l} ${c}`}function Am(t,e){switch(e){case"@":return String(t.getTime()/1e3);case"Y":return String(t.getFullYear());case"m":return String(t.getMonth()+1).padStart(2,"0");case"d":return String(t.getDate()).padStart(2,"0");case"H":return String(t.getHours()).padStart(2,"0");case"M":return String(t.getMinutes()).padStart(2,"0");case"S":return String(t.getSeconds()).padStart(2,"0");case"T":return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:${String(t.getSeconds()).padStart(2,"0")}`;case"F":return`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;default:return`%T${e}`}}var xm,wm,bm,il=C(()=>{"use strict";ht();L();Mn();tl();nl();xm={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-regex PATTERN file path matches regular expression PATTERN","-iregex PATTERN like -regex but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-depth process directory contents before directory itself","-prune do not descend into this directory","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-printf FORMAT print FORMAT with directives: %f %h %p %P %s %d %m %M %t","-delete delete found files/directories"," --help display this help and exit"]},wm=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),bm={name:"find",async execute(t,e){if(N(t))return k(xm);let r=[],n=null,s=null,i=!1,o=!1;for(let I=0;I<t.length;I++){let $=t[I];if($==="-maxdepth"&&I+1<t.length)o=!0,n=parseInt(t[++I],10);else if($==="-mindepth"&&I+1<t.length)o=!0,s=parseInt(t[++I],10);else if($==="-depth")o=!0,i=!0;else if($==="-exec")for(o=!0,I++;I<t.length&&t[I]!==";"&&t[I]!=="+";)I++;else!$.startsWith("-")&&$!==";"&&$!=="+"&&$!=="("&&$!==")"&&$!=="\\("&&$!=="\\)"&&$!=="!"?o||r.push($):wm.has($)?(o=!0,I++):($.startsWith("-")||$==="("||$==="\\("||$==="!")&&(o=!0)}r.length===0&&r.push(".");let{expr:a,error:l,actions:c}=rl(t,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some(I=>I.type==="print"),f=c.length===0,p=[],d=c.some(I=>I.type==="printf"),h=[],m="",g=0,w=el(a),b=new Map;for(let I of w){let $=e.fs.resolvePath(e.cwd,I);try{let V=await e.fs.stat($);b.set(I,V.mtime?.getTime()??Date.now())}catch{}}let E=lr(a)||d,S=typeof e.fs.readdirWithFileTypes=="function";for(let I of r){let K=function(H){let X=s===null||H.depth>=s,Ce=!1;if(X&&a!==null){let ue={name:H.name,relativePath:H.relativePath,isFile:H.isFile,isDirectory:H.isDirectory,isEmpty:H.isEmpty,mtime:H.stat?.mtime?.getTime()??Date.now(),size:H.stat?.size??0,mode:H.stat?.mode??420,newerRefTimes:b},M=ot(a,ue);X=M.matches,Ce=u?M.printed:X}else X&&(Ce=!0);return Ce?{print:!0,printfData:d?{path:H.relativePath,name:H.name,size:H.stat?.size??0,mtime:H.stat?.mtime?.getTime()??Date.now(),mode:H.stat?.mode??420,isDirectory:H.isDirectory,depth:H.depth,startingPoint:I}:null}:{print:!1,printfData:null}};var D=K;I.length>1&&I.endsWith("/")&&(I=I.slice(0,-1));let $=e.fs.resolvePath(e.cwd,I);try{await e.fs.stat($)}catch{m+=`find: ${I}: No such file or directory
401
+ `,g=1;continue}async function V(H){let{path:ce,depth:X,typeInfo:Ce}=H;if(n!==null&&X>n)return null;let ve,ue,M;if(Ce&&!E)ve=Ce.isFile,ue=Ce.isDirectory;else{try{M=await e.fs.stat(ce)}catch{return null}if(!M)return null;ve=M.isFile,ue=M.isDirectory}let W;ce===$?W=I.split("/").pop()||I:W=ce.split("/").pop()||"";let se=ce===$?I:I==="."?`./${ce.slice($==="/"?$.length:$.length+1)}`:I+ce.slice($.length),G=[],ne=null,F=null;ue&&(S&&e.fs.readdirWithFileTypes?(ne=await e.fs.readdirWithFileTypes(ce),G=ne.map((Te,Ft)=>({path:ce==="/"?`/${Te.name}`:`${ce}/${Te.name}`,depth:X+1,typeInfo:{isFile:Te.isFile,isDirectory:Te.isDirectory},resultIndex:Ft})),F=ne.map(Te=>Te.name)):(F=await e.fs.readdir(ce),G=F.map((Te,Ft)=>({path:ce==="/"?`/${Te}`:`${ce}/${Te}`,depth:X+1,resultIndex:Ft}))));let fe=ve?(M?.size??0)===0:F!==null&&F.length===0,dt=!1;if(!i&&a!==null){let Te={name:W,relativePath:se,isFile:ve,isDirectory:ue,isEmpty:fe,mtime:M?.mtime?.getTime()??Date.now(),size:M?.size??0,mode:M?.mode??420,newerRefTimes:b};dt=ot(a,Te).pruned}return{relativePath:se,name:W,isFile:ve,isDirectory:ue,isEmpty:fe,stat:M,depth:X,children:dt?[]:G,pruned:dt}}async function Y(){let H={paths:[],printfData:[]};if(i){let ue=function(M){let W={paths:[],printfData:[]},se=X[M];if(!se)return W;for(let F of se.childIndices){let fe=ue(F);W.paths.push(...fe.paths),W.printfData.push(...fe.printfData)}let{print:G,printfData:ne}=K(se.node);return G&&(W.paths.push(se.node.relativePath),ne&&W.printfData.push(ne)),W};var ce=ue;let X=[],Ce=[{item:{path:$,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],ve=new Map;for(;Ce.length>0;){let M=Ce.splice(0,100),W=await Promise.all(M.map(se=>V(se.item)));for(let se=0;se<M.length;se++){let G=W[se],ne=M[se];if(!G)continue;let F=X.length;if(ne.parentIndex>=0){let fe=ve.get(ne.parentIndex)||[];fe.push(F),ve.set(ne.parentIndex,fe)}X.push({node:G,parentIndex:ne.parentIndex,childIndices:[]});for(let fe=0;fe<G.children.length;fe++)Ce.push({item:G.children[fe],parentIndex:F,childOrderInParent:fe})}}for(let[M,W]of ve)M>=0&&M<X.length&&(X[M].childIndices=W);if(X.length>0){let M=ue(0);H.paths.push(...M.paths),H.printfData.push(...M.printfData)}}else{async function X(ve){let ue={paths:[],printfData:[]},M=await V(ve);if(!M)return ue;let{print:W,printfData:se}=K(M);W&&(ue.paths.push(M.relativePath),se&&ue.printfData.push(se));for(let G=0;G<M.children.length;G+=100){let ne=M.children.slice(G,G+100),F=await Promise.all(ne.map(X));for(let fe of F)ue.paths.push(...fe.paths),ue.printfData.push(...fe.printfData)}return ue}let Ce=await X({path:$,depth:0,resultIndex:0});H.paths.push(...Ce.paths),H.printfData.push(...Ce.printfData)}return H}let re=await Y();p.push(...re.paths),h.push(...re.printfData)}let v="";if(c.length>0)for(let I of c)switch(I.type){case"print":v+=p.length>0?`${p.join(`
402
402
  `)}
403
- `:"";break;case"print0":E+=d.length>0?`${d.join("\0")}\0`:"";break;case"delete":{let A=[...d].sort((F,M)=>M.length-F.length);for(let F of A){let M=e.fs.resolvePath(e.cwd,F);try{await e.fs.rm(M,{recursive:!1})}catch(D){let U=D instanceof Error?D.message:String(D);y+=`find: cannot delete '${F}': ${U}
404
- `,m=1}}break}case"printf":for(let A of h)E+=pm(S.format,A);break;case"exec":if(!e.exec)return{stdout:"",stderr:`find: -exec not supported in this context
405
- `,exitCode:1};if(S.batchMode){let A=[];for(let D of S.command)D==="{}"?A.push(...d):A.push(D);let F=A.map(D=>`"${D}"`).join(" "),M=await e.exec(F,{cwd:e.cwd});E+=M.stdout,y+=M.stderr,M.exitCode!==0&&(m=M.exitCode)}else for(let A of d){let M=S.command.map(U=>U==="{}"?A:U).map(U=>`"${U}"`).join(" "),D=await e.exec(M,{cwd:e.cwd});E+=D.stdout,y+=D.stderr,D.exitCode!==0&&(m=D.exitCode)}break}else f&&(E=d.length>0?`${d.join(`
403
+ `:"";break;case"print0":v+=p.length>0?`${p.join("\0")}\0`:"";break;case"delete":{let $=[...p].sort((V,K)=>K.length-V.length);for(let V of $){let K=e.fs.resolvePath(e.cwd,V);try{await e.fs.rm(K,{recursive:!1})}catch(Y){let re=Y instanceof Error?Y.message:String(Y);m+=`find: cannot delete '${V}': ${re}
404
+ `,g=1}}break}case"printf":for(let $ of h)v+=Em(I.format,$);break;case"exec":if(!e.exec)return{stdout:"",stderr:`find: -exec not supported in this context
405
+ `,exitCode:1};if(I.batchMode){let $=[];for(let Y of I.command)Y==="{}"?$.push(...p):$.push(Y);let V=$.map(Y=>`"${Y}"`).join(" "),K=await e.exec(V,{cwd:e.cwd});v+=K.stdout,m+=K.stderr,K.exitCode!==0&&(g=K.exitCode)}else for(let $ of p){let K=I.command.map(re=>re==="{}"?$:re).map(re=>`"${re}"`).join(" "),Y=await e.exec(K,{cwd:e.cwd});v+=Y.stdout,m+=Y.stderr,Y.exitCode!==0&&(g=Y.exitCode)}break}else f&&(v=p.length>0?`${p.join(`
406
406
  `)}
407
- `:"");return{stdout:E,stderr:y,exitCode:m}}}});var Ja={};v(Ja,{basenameCommand:()=>xm});var ym,xm,Ya=C(()=>{"use strict";O();ym={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX]
408
- basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},xm={name:"basename",async execute(t,e){if(I(t))return N(ym);let r=!1,n="",s=[];for(let o=0;o<t.length;o++){let a=t[o];a==="-a"||a==="--multiple"?r=!0:a==="-s"&&o+1<t.length?(n=t[++o],r=!0):a.startsWith("--suffix=")?(n=a.slice(9),r=!0):a.startsWith("-")||s.push(a)}if(s.length===0)return{stdout:"",stderr:`basename: missing operand
407
+ `:"");return{stdout:v,stderr:m,exitCode:g}}}});var ol={};R(ol,{basenameCommand:()=>Nm});var km,Nm,al=C(()=>{"use strict";L();km={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX]
408
+ basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},Nm={name:"basename",async execute(t,e){if(N(t))return k(km);let r=!1,n="",s=[];for(let o=0;o<t.length;o++){let a=t[o];a==="-a"||a==="--multiple"?r=!0:a==="-s"&&o+1<t.length?(n=t[++o],r=!0):a.startsWith("--suffix=")?(n=a.slice(9),r=!0):a.startsWith("-")||s.push(a)}if(s.length===0)return{stdout:"",stderr:`basename: missing operand
409
409
  `,exitCode:1};!r&&s.length>=2&&(n=s.pop()??"");let i=[];for(let o of s){let a=o.replace(/\/+$/,""),l=a.split("/").pop()||a;n&&l.endsWith(n)&&(l=l.slice(0,-n.length)),i.push(l)}return{stdout:`${i.join(`
410
410
  `)}
411
- `,stderr:"",exitCode:0}}}});var el={};v(el,{dirnameCommand:()=>bm});var wm,bm,tl=C(()=>{"use strict";O();wm={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},bm={name:"dirname",async execute(t,e){if(I(t))return N(wm);let r=t.filter(s=>!s.startsWith("-"));if(r.length===0)return{stdout:"",stderr:`dirname: missing operand
411
+ `,stderr:"",exitCode:0}}}});var ll={};R(ll,{dirnameCommand:()=>vm});var Im,vm,cl=C(()=>{"use strict";L();Im={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},vm={name:"dirname",async execute(t,e){if(N(t))return k(Im);let r=t.filter(s=>!s.startsWith("-"));if(r.length===0)return{stdout:"",stderr:`dirname: missing operand
412
412
  `,exitCode:1};let n=[];for(let s of r){let i=s.replace(/\/+$/,""),o=i.lastIndexOf("/");o===-1?n.push("."):o===0?n.push("/"):n.push(i.slice(0,o))}return{stdout:`${n.join(`
413
413
  `)}
414
- `,stderr:"",exitCode:0}}}});var nl={};v(nl,{treeCommand:()=>Cm});async function Am(t,e,r,n,s){let i={output:"",stderr:"",dirCount:0,fileCount:0},o=t.fs.resolvePath(t.cwd,e);try{if(!(await t.fs.stat(o)).isDirectory)return i.output=`${e}
414
+ `,stderr:"",exitCode:0}}}});var fl={};R(fl,{treeCommand:()=>Pm});async function Fm(t,e,r,n,s){let i={output:"",stderr:"",dirCount:0,fileCount:0},o=t.fs.resolvePath(t.cwd,e);try{if(!(await t.fs.stat(o)).isDirectory)return i.output=`${e}
415
415
  `,i.fileCount=1,i}catch{return i.stderr=`tree: ${e}: No such file or directory
416
416
  `,i}if(i.output=`${e}
417
- `,r.maxDepth!==null&&s>=r.maxDepth)return i;try{let l=(await t.fs.readdir(o)).filter(c=>!(!r.showHidden&&c.startsWith(".")));l.sort();for(let c=0;c<l.length;c++){let u=l[c],f=o==="/"?`/${u}`:`${o}/${u}`,d=c===l.length-1,p=d?"`-- ":"|-- ",h=n+(d?" ":"| ");try{if((await t.fs.stat(f)).isDirectory){i.dirCount++;let m=r.fullPath?f:u;if(i.output+=`${n+p+m}
418
- `,r.maxDepth===null||s+1<r.maxDepth){let w=await rl(t,f,r,h,s+1);i.output+=w.output,i.dirCount+=w.dirCount,i.fileCount+=w.fileCount}}else if(!r.directoriesOnly){i.fileCount++;let m=r.fullPath?f:u;i.output+=`${n+p+m}
419
- `}}catch{}}}catch{i.stderr=`tree: ${e}: Permission denied
420
- `}return i}async function rl(t,e,r,n,s){let i={output:"",stderr:"",dirCount:0,fileCount:0};if(r.maxDepth!==null&&s>=r.maxDepth)return i;try{let a=(await t.fs.readdir(e)).filter(l=>!(!r.showHidden&&l.startsWith(".")));a.sort();for(let l=0;l<a.length;l++){let c=a[l],u=e==="/"?`/${c}`:`${e}/${c}`,f=l===a.length-1,d=f?"`-- ":"|-- ",p=n+(f?" ":"| ");try{if((await t.fs.stat(u)).isDirectory){i.dirCount++;let y=r.fullPath?u:c;i.output+=`${n+d+y}
421
- `;let m=await rl(t,u,r,p,s+1);i.output+=m.output,i.dirCount+=m.dirCount,i.fileCount+=m.fileCount}else if(!r.directoriesOnly){i.fileCount++;let y=r.fullPath?u:c;i.output+=`${n+d+y}
422
- `}}catch{}}}catch{}return i}var Em,Sm,Cm,sl=C(()=>{"use strict";ae();O();Em={name:"tree",summary:"list contents of directories in a tree-like format",usage:"tree [OPTION]... [DIRECTORY]...",options:["-a include hidden files","-d list directories only","-L LEVEL limit depth of directory tree","-f print full path prefix for each file"," --help display this help and exit"]},Sm={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},Cm={name:"tree",async execute(t,e){if(I(t))return N(Em);let r=j("tree",t,Sm);if(!r.ok)return r.error;let n={showHidden:r.result.flags.showHidden,directoriesOnly:r.result.flags.directoriesOnly,maxDepth:r.result.flags.maxDepth??null,fullPath:r.result.flags.fullPath},s=r.result.positional;s.length===0&&s.push(".");let i="",o="",a=0,l=0;for(let c of s){let u=await Am(e,c,n,"",0);i+=u.output,o+=u.stderr,a+=u.dirCount,l+=u.fileCount}return i+=`
417
+ `,r.maxDepth!==null&&s>=r.maxDepth)return i;try{let a=[];if(t.fs.readdirWithFileTypes)a=(await t.fs.readdirWithFileTypes(o)).map(u=>({name:u.name,isDirectory:u.isDirectory}));else{let c=await t.fs.readdir(o);for(let u=0;u<c.length;u+=100){let f=c.slice(u,u+100),p=await Promise.all(f.map(async d=>{let h=o==="/"?`/${d}`:`${o}/${d}`;try{let m=await t.fs.stat(h);return{name:d,isDirectory:m.isDirectory}}catch{return null}}));a.push(...p.filter(d=>d!==null))}}let l=a.filter(c=>!(!r.showHidden&&c.name.startsWith(".")||r.directoriesOnly&&!c.isDirectory));l.sort((c,u)=>c.name.localeCompare(u.name));for(let c=0;c<l.length;c++){let u=l[c],f=o==="/"?`/${u.name}`:`${o}/${u.name}`,p=c===l.length-1,d=p?"`-- ":"|-- ",h=n+(p?" ":"| ");if(u.isDirectory){i.dirCount++;let m=r.fullPath?f:u.name;if(i.output+=`${n+d+m}
418
+ `,r.maxDepth===null||s+1<r.maxDepth){let g=await ul(t,f,r,h,s+1);i.output+=g.output,i.dirCount+=g.dirCount,i.fileCount+=g.fileCount}}else{i.fileCount++;let m=r.fullPath?f:u.name;i.output+=`${n+d+m}
419
+ `}}}catch{i.stderr=`tree: ${e}: Permission denied
420
+ `}return i}async function ul(t,e,r,n,s){let i={output:"",stderr:"",dirCount:0,fileCount:0};if(r.maxDepth!==null&&s>=r.maxDepth)return i;try{let o=[];if(t.fs.readdirWithFileTypes)o=(await t.fs.readdirWithFileTypes(e)).map(c=>({name:c.name,isDirectory:c.isDirectory}));else{let l=await t.fs.readdir(e);for(let c=0;c<l.length;c+=100){let u=l.slice(c,c+100),f=await Promise.all(u.map(async p=>{let d=e==="/"?`/${p}`:`${e}/${p}`;try{let h=await t.fs.stat(d);return{name:p,isDirectory:h.isDirectory}}catch{return null}}));o.push(...f.filter(p=>p!==null))}}let a=o.filter(l=>!(!r.showHidden&&l.name.startsWith(".")||r.directoriesOnly&&!l.isDirectory));a.sort((l,c)=>l.name.localeCompare(c.name));for(let l=0;l<a.length;l++){let c=a[l],u=e==="/"?`/${c.name}`:`${e}/${c.name}`,f=l===a.length-1,p=f?"`-- ":"|-- ",d=n+(f?" ":"| ");if(c.isDirectory){i.dirCount++;let h=r.fullPath?u:c.name;i.output+=`${n+p+h}
421
+ `;let m=await ul(t,u,r,d,s+1);i.output+=m.output,i.dirCount+=m.dirCount,i.fileCount+=m.fileCount}else{i.fileCount++;let h=r.fullPath?u:c.name;i.output+=`${n+p+h}
422
+ `}}}catch{}return i}var $m,Rm,Pm,pl=C(()=>{"use strict";ye();ht();L();$m={name:"tree",summary:"list contents of directories in a tree-like format",usage:"tree [OPTION]... [DIRECTORY]...",options:["-a include hidden files","-d list directories only","-L LEVEL limit depth of directory tree","-f print full path prefix for each file"," --help display this help and exit"]},Rm={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},Pm={name:"tree",async execute(t,e){if(N(t))return k($m);let r=z("tree",t,Rm);if(!r.ok)return r.error;let n={showHidden:r.result.flags.showHidden,directoriesOnly:r.result.flags.directoriesOnly,maxDepth:r.result.flags.maxDepth??null,fullPath:r.result.flags.fullPath},s=r.result.positional;s.length===0&&s.push(".");let i="",o="",a=0,l=0;for(let c of s){let u=await Fm(e,c,n,"",0);i+=u.output,o+=u.stderr,a+=u.dirCount,l+=u.fileCount}return i+=`
423
423
  ${a} director${a===1?"y":"ies"}`,n.directoriesOnly||(i+=`, ${l} file${l===1?"":"s"}`),i+=`
424
- `,{stdout:i,stderr:o,exitCode:o?1:0}}}});var ol={};v(ol,{duCommand:()=>Im});async function il(t,e,r,n,s){let i={output:"",totalSize:0,stderr:""};try{let o=await t.fs.stat(e);if(!o.isDirectory)return i.totalSize=o.size,(n.allFiles||s===0)&&(i.output=Fr(o.size,n.humanReadable)+" "+r+`
425
- `),i;let a=await t.fs.readdir(e),l=0;for(let c of a){let u=e==="/"?`/${c}`:`${e}/${c}`,f=r==="."?c:`${r}/${c}`;try{let d=await t.fs.stat(u);if(d.isDirectory){let p=await il(t,u,f,n,s+1);l+=p.totalSize,n.summarize||(n.maxDepth===null||s+1<=n.maxDepth?i.output+=p.output:l+=0)}else l+=d.size,n.allFiles&&!n.summarize&&(i.output+=Fr(d.size,n.humanReadable)+" "+f+`
426
- `)}catch{}}i.totalSize=l,(n.summarize||n.maxDepth===null||s<=n.maxDepth)&&(i.output+=`${Fr(l,n.humanReadable)} ${r}
424
+ `,{stdout:i,stderr:o,exitCode:o?1:0}}}});var hl={};R(hl,{duCommand:()=>Dm});async function dl(t,e,r,n,s){let i={output:"",totalSize:0,stderr:""};try{let o=await t.fs.stat(e);if(!o.isDirectory)return i.totalSize=o.size,(n.allFiles||s===0)&&(i.output=zr(o.size,n.humanReadable)+" "+r+`
425
+ `),i;let a=0,l=[];if(t.fs.readdirWithFileTypes){let f=await t.fs.readdirWithFileTypes(e),p=f.filter(h=>h.isFile),d=f.filter(h=>h.isDirectory);for(let h=0;h<p.length;h+=100){let m=p.slice(h,h+100),g=await Promise.all(m.map(async w=>{let b=e==="/"?`/${w.name}`:`${e}/${w.name}`;try{let E=await t.fs.stat(b);return{name:w.name,isDirectory:!1,size:E.size}}catch{return{name:w.name,isDirectory:!1,size:0}}}));l.push(...g)}l.push(...d.map(h=>({name:h.name,isDirectory:!0})))}else{let f=await t.fs.readdir(e);for(let p=0;p<f.length;p+=100){let d=f.slice(p,p+100),h=await Promise.all(d.map(async m=>{let g=e==="/"?`/${m}`:`${e}/${m}`;try{let w=await t.fs.stat(g);return{name:m,isDirectory:w.isDirectory,size:w.isDirectory?void 0:w.size}}catch{return{name:m,isDirectory:!1,size:0}}}));l.push(...h)}}l.sort((f,p)=>f.name.localeCompare(p.name));let c=l.filter(f=>!f.isDirectory);for(let f of c){let p=f.size??0;if(a+=p,n.allFiles&&!n.summarize){let d=r==="."?f.name:`${r}/${f.name}`;i.output+=zr(p,n.humanReadable)+" "+d+`
426
+ `}}let u=l.filter(f=>f.isDirectory);for(let f=0;f<u.length;f+=100){let p=u.slice(f,f+100),d=await Promise.all(p.map(async h=>{let m=e==="/"?`/${h.name}`:`${e}/${h.name}`,g=r==="."?h.name:`${r}/${h.name}`;return{name:h.name,result:await dl(t,m,g,n,s+1)}}));d.sort((h,m)=>h.name.localeCompare(m.name));for(let{result:h}of d)a+=h.totalSize,n.summarize||(n.maxDepth===null||s+1<=n.maxDepth)&&(i.output+=h.output)}i.totalSize=a,(n.summarize||n.maxDepth===null||s<=n.maxDepth)&&(i.output+=`${zr(a,n.humanReadable)} ${r}
427
427
  `)}catch{i.stderr=`du: cannot read directory '${r}': Permission denied
428
- `}return i}function Fr(t,e){return e?t<1024?`${t}`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)}M`:`${(t/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(t/1024)||1)}var km,Nm,Im,al=C(()=>{"use strict";ae();O();km={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},Nm={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},Im={name:"du",async execute(t,e){if(I(t))return N(km);let r=j("du",t,Nm);if(!r.ok)return r.error;let n={allFiles:r.result.flags.allFiles,humanReadable:r.result.flags.humanReadable,summarize:r.result.flags.summarize,grandTotal:r.result.flags.grandTotal,maxDepth:r.result.flags.maxDepth??null},s=r.result.positional;s.length===0&&s.push(".");let i="",o="",a=0;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{await e.fs.stat(c);let u=await il(e,c,l,n,0);i+=u.output,a+=u.totalSize,o+=u.stderr}catch{o+=`du: cannot access '${l}': No such file or directory
429
- `}}return n.grandTotal&&s.length>0&&(i+=`${Fr(a,n.humanReadable)} total
430
- `),{stdout:i,stderr:o,exitCode:o?1:0}}}});var Kn={};v(Kn,{envCommand:()=>$m,printenvCommand:()=>Pm});var vm,$m,Rm,Pm,Zn=C(()=>{"use strict";O();vm={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},$m={name:"env",async execute(t,e){if(I(t))return N(vm);let r=!1,n=[],s={},i=-1;for(let u=0;u<t.length;u++){let f=t[u];if(f==="-i"||f==="--ignore-environment")r=!0;else if(f==="-u"&&u+1<t.length)n.push(t[++u]);else if(f.startsWith("-u"))n.push(f.slice(2));else if(f.startsWith("--unset="))n.push(f.slice(8));else{if(f.startsWith("--")&&f!=="--")return $("env",f);if(f.startsWith("-")&&f!=="-"){for(let d of f.slice(1))if(d!=="i"&&d!=="u")return $("env",`-${d}`);f.includes("i")&&(r=!0)}else if(f.includes("=")&&i===-1){let d=f.indexOf("="),p=f.slice(0,d),h=f.slice(d+1);s[p]=h}else{i=u;break}}}let o;if(r)o={...s};else{o={...e.env};for(let u of n)delete o[u];Object.assign(o,s)}if(i===-1){let u=[];for(let[f,d]of Object.entries(o))u.push(`${f}=${d}`);return{stdout:u.join(`
428
+ `}return i}function zr(t,e){return e?t<1024?`${t}`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)}M`:`${(t/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(t/1024)||1)}var Om,Tm,Dm,ml=C(()=>{"use strict";ye();ht();L();Om={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},Tm={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},Dm={name:"du",async execute(t,e){if(N(t))return k(Om);let r=z("du",t,Tm);if(!r.ok)return r.error;let n={allFiles:r.result.flags.allFiles,humanReadable:r.result.flags.humanReadable,summarize:r.result.flags.summarize,grandTotal:r.result.flags.grandTotal,maxDepth:r.result.flags.maxDepth??null},s=r.result.positional;s.length===0&&s.push(".");let i="",o="",a=0;for(let l of s){let c=e.fs.resolvePath(e.cwd,l);try{await e.fs.stat(c);let u=await dl(e,c,l,n,0);i+=u.output,a+=u.totalSize,o+=u.stderr}catch{o+=`du: cannot access '${l}': No such file or directory
429
+ `}}return n.grandTotal&&s.length>0&&(i+=`${zr(a,n.humanReadable)} total
430
+ `),{stdout:i,stderr:o,exitCode:o?1:0}}}});var rs={};R(rs,{envCommand:()=>Mm,printenvCommand:()=>Bm});var Lm,Mm,_m,Bm,ns=C(()=>{"use strict";L();Lm={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},Mm={name:"env",async execute(t,e){if(N(t))return k(Lm);let r=!1,n=[],s={},i=-1;for(let u=0;u<t.length;u++){let f=t[u];if(f==="-i"||f==="--ignore-environment")r=!0;else if(f==="-u"&&u+1<t.length)n.push(t[++u]);else if(f.startsWith("-u"))n.push(f.slice(2));else if(f.startsWith("--unset="))n.push(f.slice(8));else{if(f.startsWith("--")&&f!=="--")return P("env",f);if(f.startsWith("-")&&f!=="-"){for(let p of f.slice(1))if(p!=="i"&&p!=="u")return P("env",`-${p}`);f.includes("i")&&(r=!0)}else if(f.includes("=")&&i===-1){let p=f.indexOf("="),d=f.slice(0,p),h=f.slice(p+1);s[d]=h}else{i=u;break}}}let o;if(r)o={...s};else{o={...e.env};for(let u of n)delete o[u];Object.assign(o,s)}if(i===-1){let u=[];for(let[f,p]of Object.entries(o))u.push(`${f}=${p}`);return{stdout:u.join(`
431
431
  `)+(u.length>0?`
432
432
  `:""),stderr:"",exitCode:0}}if(!e.exec)return{stdout:"",stderr:`env: command execution not supported in this context
433
- `,exitCode:1};let a=t.slice(i).join(" "),l=Object.entries(s).map(([u,f])=>`${u}="${f}"`).join(" "),c=l?`${l} ${a}`:a;return e.exec(c,{cwd:e.cwd})}},Rm={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},Pm={name:"printenv",async execute(t,e){if(I(t))return N(Rm);let r=t.filter(i=>!i.startsWith("-"));if(r.length===0){let i=[];for(let[o,a]of Object.entries(e.env))i.push(`${o}=${a}`);return{stdout:i.join(`
433
+ `,exitCode:1};let a=t.slice(i).join(" "),l=Object.entries(s).map(([u,f])=>`${u}="${f}"`).join(" "),c=l?`${l} ${a}`:a;return e.exec(c,{cwd:e.cwd})}},_m={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},Bm={name:"printenv",async execute(t,e){if(N(t))return k(_m);let r=t.filter(i=>!i.startsWith("-"));if(r.length===0){let i=[];for(let[o,a]of Object.entries(e.env))i.push(`${o}=${a}`);return{stdout:i.join(`
434
434
  `)+(i.length>0?`
435
435
  `:""),stderr:"",exitCode:0}}let n=[],s=0;for(let i of r)i in e.env?n.push(e.env[i]):s=1;return{stdout:n.join(`
436
436
  `)+(n.length>0?`
437
- `:""),stderr:"",exitCode:s}}}});var Qn={};v(Qn,{aliasCommand:()=>Fm,unaliasCommand:()=>Tm});var Om,Rt,Fm,Tm,Xn=C(()=>{"use strict";O();Om={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},Rt="BASH_ALIAS_",Fm={name:"alias",async execute(t,e){if(I(t))return N(Om);if(t.length===0){let r="";for(let[n,s]of Object.entries(e.env))if(n.startsWith(Rt)){let i=n.slice(Rt.length);r+=`alias ${i}='${s}'
438
- `}return{stdout:r,stderr:"",exitCode:0}}for(let r of t){let n=r.indexOf("=");if(n===-1){let s=Rt+r;return e.env[s]?{stdout:`alias ${r}='${e.env[s]}'
437
+ `:""),stderr:"",exitCode:s}}}});var ss={};R(ss,{aliasCommand:()=>Um,unaliasCommand:()=>jm});var Wm,Wt,Um,jm,is=C(()=>{"use strict";L();Wm={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},Wt="BASH_ALIAS_",Um={name:"alias",async execute(t,e){if(N(t))return k(Wm);if(t.length===0){let r="";for(let[n,s]of Object.entries(e.env))if(n.startsWith(Wt)){let i=n.slice(Wt.length);r+=`alias ${i}='${s}'
438
+ `}return{stdout:r,stderr:"",exitCode:0}}for(let r of t){let n=r.indexOf("=");if(n===-1){let s=Wt+r;return e.env[s]?{stdout:`alias ${r}='${e.env[s]}'
439
439
  `,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${r}: not found
440
- `,exitCode:1}}else{let s=r.slice(0,n),i=r.slice(n+1);(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1)),e.env[Rt+s]=i}}return{stdout:"",stderr:"",exitCode:0}}},Tm={name:"unalias",async execute(t,e){if(I(t))return N({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(t.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
441
- `,exitCode:1};if(t[0]==="-a"){for(let s of Object.keys(e.env))s.startsWith(Rt)&&delete e.env[s];return{stdout:"",stderr:"",exitCode:0}}let r=!1,n="";for(let s of t){let i=Rt+s;e.env[i]?delete e.env[i]:(n+=`unalias: ${s}: not found
442
- `,r=!0)}return{stdout:"",stderr:n,exitCode:r?1:0}}}});var cl={};v(cl,{historyCommand:()=>Dm});var Lm,ll,Dm,ul=C(()=>{"use strict";O();Lm={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},ll="BASH_HISTORY",Dm={name:"history",async execute(t,e){if(I(t))return N(Lm);let r=e.env[ll]||"[]",n;try{n=JSON.parse(r)}catch{n=[]}if(t[0]==="-c")return e.env[ll]="[]",{stdout:"",stderr:"",exitCode:0};let s=n.length;t[0]&&/^\d+$/.test(t[0])&&(s=Math.min(parseInt(t[0],10),n.length));let i=n.length-s,o="";for(let a=i;a<n.length;a++){let l=(a+1).toString().padStart(5," ");o+=`${l} ${n[a]}
443
- `}return{stdout:o,stderr:"",exitCode:0}}}});var fl={};v(fl,{xargsCommand:()=>_m});var Mm,_m,dl=C(()=>{"use strict";O();Mm={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},_m={name:"xargs",async execute(t,e){if(I(t))return N(Mm);let r=null,n=null,s=null,i=!1,o=!1,a=!1,l=0;for(let w=0;w<t.length;w++){let b=t[w];if(b==="-I"&&w+1<t.length)r=t[++w],l=w+1;else if(b==="-n"&&w+1<t.length)n=parseInt(t[++w],10),l=w+1;else if(b==="-P"&&w+1<t.length)s=parseInt(t[++w],10),l=w+1;else if(b==="-0"||b==="--null")i=!0,l=w+1;else if(b==="-t"||b==="--verbose")o=!0,l=w+1;else if(b==="-r"||b==="--no-run-if-empty")a=!0,l=w+1;else{if(b.startsWith("--"))return $("xargs",b);if(b.startsWith("-")&&b.length>1){for(let E of b.slice(1))if(!"0tr".includes(E))return $("xargs",`-${E}`);b.includes("0")&&(i=!0),b.includes("t")&&(o=!0),b.includes("r")&&(a=!0),l=w+1}else if(!b.startsWith("-")){l=w;break}}}let c=t.slice(l);c.length===0&&c.push("echo");let u=i?"\0":/\s+/,f=e.stdin.split(u).map(w=>w.trim()).filter(w=>w.length>0);if(f.length===0)return a?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let d="",p="",h=0,y=async w=>{let b=w.join(" ");return o&&(p+=`${b}
444
- `),e.exec?e.exec(b,{cwd:e.cwd}):{stdout:`${b}
445
- `,stderr:"",exitCode:0}},m=async w=>{if(s!==null&&s>1)for(let b=0;b<w.length;b+=s){let E=w.slice(b,b+s),S=await Promise.all(E.map(y));for(let A of S)d+=A.stdout,p+=A.stderr,A.exitCode!==0&&(h=A.exitCode)}else for(let b of w){let E=await y(b);d+=E.stdout,p+=E.stderr,E.exitCode!==0&&(h=E.exitCode)}};if(r!==null){let w=f.map(b=>c.map(E=>E.replaceAll(r,b)));await m(w)}else if(n!==null){let w=[];for(let b=0;b<f.length;b+=n){let E=f.slice(b,b+n);w.push([...c,...E])}await m(w)}else{let w=[...c,...f],b=await y(w);d+=b.stdout,p+=b.stderr,h=b.exitCode}return{stdout:d,stderr:p,exitCode:h}}}});var Jn={};v(Jn,{falseCommand:()=>Wm,trueCommand:()=>Bm});var Bm,Wm,Yn=C(()=>{"use strict";Bm={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},Wm={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}}});var pl={};v(pl,{clearCommand:()=>jm});var Um,jm,hl=C(()=>{"use strict";O();Um={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},jm={name:"clear",async execute(t,e){return I(t)?N(Um):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}}});var es={};v(es,{bashCommand:()=>zm,shCommand:()=>Hm});async function Tr(t,e,r,n){if(!n.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
440
+ `,exitCode:1}}else{let s=r.slice(0,n),i=r.slice(n+1);(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1)),e.env[Wt+s]=i}}return{stdout:"",stderr:"",exitCode:0}}},jm={name:"unalias",async execute(t,e){if(N(t))return k({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(t.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
441
+ `,exitCode:1};if(t[0]==="-a"){for(let s of Object.keys(e.env))s.startsWith(Wt)&&delete e.env[s];return{stdout:"",stderr:"",exitCode:0}}let r=!1,n="";for(let s of t){let i=Wt+s;e.env[i]?delete e.env[i]:(n+=`unalias: ${s}: not found
442
+ `,r=!0)}return{stdout:"",stderr:n,exitCode:r?1:0}}}});var yl={};R(yl,{historyCommand:()=>Hm});var zm,gl,Hm,xl=C(()=>{"use strict";L();zm={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},gl="BASH_HISTORY",Hm={name:"history",async execute(t,e){if(N(t))return k(zm);let r=e.env[gl]||"[]",n;try{n=JSON.parse(r)}catch{n=[]}if(t[0]==="-c")return e.env[gl]="[]",{stdout:"",stderr:"",exitCode:0};let s=n.length;t[0]&&/^\d+$/.test(t[0])&&(s=Math.min(parseInt(t[0],10),n.length));let i=n.length-s,o="";for(let a=i;a<n.length;a++){let l=(a+1).toString().padStart(5," ");o+=`${l} ${n[a]}
443
+ `}return{stdout:o,stderr:"",exitCode:0}}}});var wl={};R(wl,{xargsCommand:()=>qm});var Gm,qm,bl=C(()=>{"use strict";L();Gm={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},qm={name:"xargs",async execute(t,e){if(N(t))return k(Gm);let r=null,n=null,s=null,i=null,o=!1,a=!1,l=!1,c=0;for(let b=0;b<t.length;b++){let E=t[b];if(E==="-I"&&b+1<t.length)r=t[++b],c=b+1;else if(E==="-d"&&b+1<t.length)n=t[++b].replace(/\\n/g,`
444
+ `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=b+1;else if(E==="-n"&&b+1<t.length)s=parseInt(t[++b],10),c=b+1;else if(E==="-P"&&b+1<t.length)i=parseInt(t[++b],10),c=b+1;else if(E==="-0"||E==="--null")o=!0,c=b+1;else if(E==="-t"||E==="--verbose")a=!0,c=b+1;else if(E==="-r"||E==="--no-run-if-empty")l=!0,c=b+1;else{if(E.startsWith("--"))return P("xargs",E);if(E.startsWith("-")&&E.length>1){for(let S of E.slice(1))if(!"0tr".includes(S))return P("xargs",`-${S}`);E.includes("0")&&(o=!0),E.includes("t")&&(a=!0),E.includes("r")&&(l=!0),c=b+1}else if(!E.startsWith("-")){c=b;break}}}let u=t.slice(c);u.length===0&&u.push("echo");let f;if(o?f=e.stdin.split("\0").filter(b=>b.length>0):n!==null?f=e.stdin.replace(/\n$/,"").split(n).filter(E=>E.length>0):f=e.stdin.split(/\s+/).map(b=>b.trim()).filter(b=>b.length>0),f.length===0)return l?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let p="",d="",h=0,m=b=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(b)?`"${b.replace(/([\\"`$])/g,"\\$1")}"`:b,g=async b=>{let E=b.map(m).join(" ");return a&&(d+=`${E}
445
+ `),e.exec?e.exec(E,{cwd:e.cwd}):{stdout:`${E}
446
+ `,stderr:"",exitCode:0}},w=async b=>{if(i!==null&&i>1)for(let E=0;E<b.length;E+=i){let S=b.slice(E,E+i),v=await Promise.all(S.map(g));for(let D of v)p+=D.stdout,d+=D.stderr,D.exitCode!==0&&(h=D.exitCode)}else for(let E of b){let S=await g(E);p+=S.stdout,d+=S.stderr,S.exitCode!==0&&(h=S.exitCode)}};if(r!==null){let b=f.map(E=>u.map(S=>S.replaceAll(r,E)));await w(b)}else if(s!==null){let b=[];for(let E=0;E<f.length;E+=s){let S=f.slice(E,E+s);b.push([...u,...S])}await w(b)}else{let b=[...u,...f],E=await g(b);p+=E.stdout,d+=E.stderr,h=E.exitCode}return{stdout:p,stderr:d,exitCode:h}}}});var os={};R(os,{falseCommand:()=>Km,trueCommand:()=>Vm});var Vm,Km,as=C(()=>{"use strict";Vm={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},Km={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}}});var El={};R(El,{clearCommand:()=>Qm});var Zm,Qm,Sl=C(()=>{"use strict";L();Zm={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},Qm={name:"clear",async execute(t,e){return N(t)?k(Zm):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}}});var ls={};R(ls,{bashCommand:()=>Xm,shCommand:()=>Jm});async function Hr(t,e,r,n){if(!n.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
446
447
  `,exitCode:1};let s={0:e,"#":String(r.length),"@":r.join(" "),"*":r.join(" ")};r.forEach((u,f)=>{s[String(f+1)]=u});let i=t;if(i.startsWith("#!")){let u=i.indexOf(`
447
448
  `);u!==-1&&(i=i.slice(u+1))}let o=i.split(`
448
- `),a=[];for(let u of o){let f=u.trim();f&&!f.startsWith("#")&&a.push(f)}let l=a.join("; ");return await n.exec(l,{env:s,cwd:n.cwd})}var ml,zm,Hm,ts=C(()=>{"use strict";O();ml={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},zm={name:"bash",async execute(t,e){if(I(t))return N(ml);if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"bash",o=t.slice(3);return Tr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Tr(i,r,n,e)}catch{return{stdout:"",stderr:`bash: ${r}: No such file or directory
449
- `,exitCode:127}}}},Hm={name:"sh",async execute(t,e){if(I(t))return N({...ml,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"sh",o=t.slice(3);return Tr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Tr(i,r,n,e)}catch{return{stdout:"",stderr:`sh: ${r}: No such file or directory
450
- `,exitCode:127}}}}});function qm(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??Gm},env:t?.env}}function rs(t,e,r){let n=new Map(t.vars);return n.set(e,r),{vars:n,limits:t.limits,env:t.env,root:t.root,currentPath:t.currentPath}}function ns(t,e){let r=t;for(let n of e)if(r&&typeof r=="object")r=r[n];else return;return r}function Pt(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?Pt(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?Pt(t.base):[];if(e===null)return null;let r=t.index.value;return typeof r=="number"||typeof r=="string"?[...e,r]:null}if(t.type==="Pipe"){let e=Pt(t.left);return e===null?null:ss(e,t.right)}return t.type==="Call"&&(t.name==="parent"||t.name==="root"),null}function ss(t,e){if(e.type==="Call"){if(e.name==="parent"){let r=1;if(e.args.length>0&&e.args[0].type==="Literal"){let n=e.args[0].value;typeof n=="number"&&(r=n)}if(r>=0)return t.slice(0,Math.max(0,t.length-r));{let n=-r-1;return t.slice(0,Math.min(n,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let r=Pt(e);if(r!==null)return[...t,...r]}if(e.type==="Index"&&e.index.type==="Literal"){let r=Pt(e);if(r!==null)return[...t,...r]}if(e.type==="Pipe"){let r=ss(t,e.left);return r===null?null:ss(r,e.right)}return e.type==="Identity"?t:null}function k(t,e,r){let n=r&&"vars"in r?r:qm(r);switch(n.root===void 0&&(n={...n,root:t,currentPath:[]}),e.type){case"Identity":return[t];case"Field":return(e.base?k(t,e.base,n):[t]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let o=i[e.name];return[o===void 0?null:o]}return[null]});case"Index":return(e.base?k(t,e.base,n):[t]).flatMap(i=>k(i,e.index,n).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){let l=a<0?i.length+a:a;return l>=0&&l<i.length?[i[l]]:[null]}return typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[a]]:[null]}));case"Slice":return(e.base?k(t,e.base,n):[t]).flatMap(i=>{if(!Array.isArray(i)&&typeof i!="string")return[null];let o=i.length,a=e.start?k(t,e.start,n):[0],l=e.end?k(t,e.end,n):[o];return a.flatMap(c=>l.map(u=>{let f=gl(c,o),d=gl(u,o);return Array.isArray(i),i.slice(f,d)}))});case"Iterate":return(e.base?k(t,e.base,n):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=k(t,e.left,n),i=Pt(e.left);return s.flatMap(o=>{if(i!==null){let a={...n,currentPath:[...n.currentPath??[],...i]};return k(o,e.right,a)}return k(o,e.right,n)})}case"Comma":{let s=k(t,e.left,n),i=k(t,e.right,n);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[k(t,e.elements,n)]:[[]];case"Object":{let s=[{}];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:k(t,i.key,n),a=k(t,i.value,n),l=[];for(let c of s)for(let u of o)for(let f of a)l.push({...c,[String(u)]:f});s.length=0,s.push(...l)}return s}case"Paren":return k(t,e.expr,n);case"BinaryOp":return Zm(t,e.op,e.left,e.right,n);case"UnaryOp":return k(t,e.operand,n).map(i=>e.op==="-"?typeof i=="number"?-i:null:e.op==="not"?!ge(i):null);case"Cond":return k(t,e.cond,n).flatMap(i=>{if(ge(i))return k(t,e.then,n);for(let o of e.elifs)if(k(t,o.cond,n).some(ge))return k(t,o.then,n);return e.else?k(t,e.else,n):[null]});case"Try":try{return k(t,e.body,n)}catch{return e.catch?k(t,e.catch,n):[]}case"Call":return xl(t,e.name,e.args,n);case"VarBind":return k(t,e.value,n).flatMap(i=>{let o=rs(n,e.name,i);return k(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[n.env??{}];let s=n.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return k(t,e.expr,n)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:k(t,i,n).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[Vm(t,e.path,e.op,e.value,n)];case"Reduce":{let s=k(t,e.expr,n),i=k(t,e.init,n)[0];for(let o of s){let a=rs(n,e.varName,o);i=k(i,e.update,a)[0]}return[i]}case"Foreach":{let s=k(t,e.expr,n),i=k(t,e.init,n)[0],o=[];for(let a of s){let l=rs(n,e.varName,a);if(i=k(i,e.update,l)[0],e.extract){let c=k(i,e.extract,l);o.push(...c)}else o.push(i)}return o}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function gl(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function Vm(t,e,r,n,s){function i(l,c){switch(r){case"=":return c;case"|=":return k(l,n,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?{...l,...c}:c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let d={...f};return d[c.name]=u(d[c.name]),d}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l};return f[c.name]=u(f[c.name]),f}return l}case"Index":{let d=k(t,c.index,s)[0];if(c.base)return o(l,c.base,p=>{if(typeof d=="number"&&Array.isArray(p)){let h=[...p],y=d<0?h.length+d:d;return y>=0&&y<h.length&&(h[y]=u(h[y])),h}if(typeof d=="string"&&p&&typeof p=="object"&&!Array.isArray(p)){let h={...p};return h[d]=u(h[d]),h}return p});if(typeof d=="number"&&Array.isArray(l)){let p=[...l],h=d<0?p.length+d:d;return h>=0&&h<p.length&&(p[h]=u(p[h])),p}if(typeof d=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){let p={...l};return p[d]=u(p[d]),p}return l}case"Iterate":{let f=d=>{if(Array.isArray(d))return d.map(p=>u(p));if(d&&typeof d=="object"){let p={};for(let[h,y]of Object.entries(d))p[h]=u(y);return p}return d};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,d=>d);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(r==="|=")return i(l,l);let c=k(t,n,s);return i(l,c[0]??null)})}function Km(t,e,r){function n(s,i){switch(i.type){case"Identity":return null;case"Field":{if(s&&typeof s=="object"&&!Array.isArray(s)){let o={...s};return delete o[i.name],o}return s}case"Index":{let a=k(t,i.index,r)[0];if(typeof a=="number"&&Array.isArray(s)){let l=[...s],c=a<0?l.length+a:a;return c>=0&&c<l.length&&l.splice(c,1),l}if(typeof a=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){let l={...s};return delete l[a],l}return s}case"Iterate":return Array.isArray(s)?[]:s&&typeof s=="object"?{}:s;default:return s}}return n(t,e)}function ge(t){return t!==null&&t!==!1}function Zm(t,e,r,n,s){if(e==="and")return k(t,r,s).flatMap(l=>ge(l)?k(t,n,s).map(u=>ge(u)):[!1]);if(e==="or")return k(t,r,s).flatMap(l=>ge(l)?[!0]:k(t,n,s).map(u=>ge(u)));if(e==="//"){let l=k(t,r,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:k(t,n,s)}let i=k(t,r,s),o=k(t,n,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?{...a,...l}:null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}return null;case"*":return typeof a=="number"&&typeof l=="number"?a*l:typeof a=="string"&&typeof l=="number"?a.repeat(l):a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?yl(a,l):null;case"/":return typeof a=="number"&&typeof l=="number"?a/l:typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":return typeof a=="number"&&typeof l=="number"?a%l:null;case"==":return Ot(a,l);case"!=":return!Ot(a,l);case"<":return Lr(a,l)<0;case"<=":return Lr(a,l)<=0;case">":return Lr(a,l)>0;case">=":return Lr(a,l)>=0;default:return null}}))}function Ot(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Lr(t,e){return typeof t=="number"&&typeof e=="number"?t-e:typeof t=="string"&&typeof e=="string"?t.localeCompare(e):0}function yl(t,e){let r={...t};for(let n of Object.keys(e))n in r&&r[n]&&typeof r[n]=="object"&&!Array.isArray(r[n])&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])?r[n]=yl(r[n],e[n]):r[n]=e[n];return r}function xl(t,e,r,n){switch(e){case"keys":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"values":return Array.isArray(t)?[t]:t&&typeof t=="object"?[Object.values(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:[null];case"utf8bytelength":return typeof t=="string"?[new TextEncoder().encode(t).length]:[null];case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"empty":return[];case"error":{let s=r.length>0?k(t,r[0],n)[0]:t;throw new Error(String(s))}case"not":return[!ge(t)];case"null":return[null];case"true":return[!0];case"false":return[!1];case"first":if(r.length>0){let s=k(t,r[0],n);return s.length>0?[s[0]]:[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(r.length>0){let s=k(t,r[0],n);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(r.length<1)return[null];let i=k(t,r[0],n)[0];if(r.length>1){let o=k(t,r[1],n);return i>=0&&i<o.length?[o[i]]:[]}return Array.isArray(t)?i>=0&&i<t.length?[t[i]]:[null]:[null]}case"range":{if(r.length===0)return[];let s=k(t,r[0],n);if(r.length===1){let c=s[0];return Array.from({length:c},(u,f)=>f)}let i=k(t,r[1],n),o=s[0],a=i[0],l=[];for(let c=o;c<a;c++)l.push(c);return l}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"sort":return Array.isArray(t)?[[...t].sort(ft)]:[null];case"sort_by":return!Array.isArray(t)||r.length===0?[null]:[[...t].sort((i,o)=>{let a=k(i,r[0],n)[0],l=k(o,r[0],n)[0];return ft(a,l)})];case"unique":if(Array.isArray(t)){let s=new Set,i=[];for(let o of t){let a=JSON.stringify(o);s.has(a)||(s.add(a),i.push(o))}return[i]}return[null];case"unique_by":{if(!Array.isArray(t)||r.length===0)return[null];let s=new Set,i=[];for(let o of t){let a=JSON.stringify(k(o,r[0],n)[0]);s.has(a)||(s.add(a),i.push(o))}return[i]}case"group_by":{if(!Array.isArray(t)||r.length===0)return[null];let s=new Map;for(let i of t){let o=JSON.stringify(k(i,r[0],n)[0]);s.has(o)||s.set(o,[]),s.get(o)?.push(i)}return[[...s.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>ft(s,i)>0?s:i)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||r.length===0?[null]:[t.reduce((s,i)=>{let o=k(s,r[0],n)[0],a=k(i,r[0],n)[0];return ft(o,a)>0?s:i})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>ft(s,i)<0?s:i)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||r.length===0?[null]:[t.reduce((s,i)=>{let o=k(s,r[0],n)[0],a=k(i,r[0],n)[0];return ft(o,a)<0?s:i})];case"flatten":{if(!Array.isArray(t))return[null];let s=r.length>0?k(t,r[0],n)[0]:Number.POSITIVE_INFINITY;return[t.flat(s)]}case"add":if(Array.isArray(t)){if(t.length===0)return[null];if(t.every(s=>typeof s=="number"))return[t.reduce((s,i)=>s+i,0)];if(t.every(s=>typeof s=="string"))return[t.join("")];if(t.every(s=>Array.isArray(s)))return[t.flat()];if(t.every(s=>s&&typeof s=="object"&&!Array.isArray(s)))return[Object.assign({},...t)]}return[null];case"any":return r.length>0?Array.isArray(t)?[t.some(s=>ge(k(s,r[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(ge)]:[!1];case"all":return r.length>0?Array.isArray(t)?[t.every(s=>ge(k(s,r[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(ge)]:[!0];case"select":return r.length===0?[t]:k(t,r[0],n).some(ge)?[t]:[];case"map":return r.length===0||!Array.isArray(t)?[null]:[t.flatMap(i=>k(i,r[0],n))];case"map_values":{if(r.length===0)return[null];if(Array.isArray(t))return[t.flatMap(s=>k(s,r[0],n))];if(t&&typeof t=="object"){let s={};for(let[i,o]of Object.entries(t)){let a=k(o,r[0],n);a.length>0&&(s[i]=a[0])}return[s]}return[null]}case"has":{if(r.length===0)return[!1];let i=k(t,r[0],n)[0];return Array.isArray(t)&&typeof i=="number"?[i>=0&&i<t.length]:t&&typeof t=="object"&&typeof i=="string"?[i in t]:[!1]}case"in":{if(r.length===0)return[!1];let i=k(t,r[0],n)[0];return Array.isArray(i)&&typeof t=="number"?[t>=0&&t<i.length]:i&&typeof i=="object"&&typeof t=="string"?[t in i]:[!1]}case"contains":{if(r.length===0)return[!1];let s=k(t,r[0],n);return[Dr(t,s[0])]}case"inside":{if(r.length===0)return[!1];let s=k(t,r[0],n);return[Dr(s[0],t)]}case"getpath":{if(r.length===0)return[null];let i=k(t,r[0],n)[0],o=t;for(let a of i){if(o==null)return[null];if(Array.isArray(o)&&typeof a=="number")o=o[a];else if(typeof o=="object"&&typeof a=="string")o=o[a];else return[null]}return[o]}case"setpath":{if(r.length<2)return[null];let i=k(t,r[0],n)[0],a=k(t,r[1],n)[0];return[is(t,i,a)]}case"delpaths":{if(r.length===0)return[t];let i=k(t,r[0],n)[0],o=t;for(let a of i.sort((l,c)=>c.length-l.length))o=os(o,a);return[o]}case"path":{if(r.length===0)return[[]];let s=[];return Qm(t,r[0],n,[],s),s}case"del":return r.length===0?[t]:[Km(t,r[0],n)];case"paths":{let s=[],i=(o,a)=>{if(o&&typeof o=="object")if(Array.isArray(o))for(let l=0;l<o.length;l++)s.push([...a,l]),i(o[l],[...a,l]);else for(let l of Object.keys(o))s.push([...a,l]),i(o[l],[...a,l])};return i(t,[]),r.length>0?s.filter(o=>{let a=t;for(let c of o)if(Array.isArray(a)&&typeof c=="number")a=a[c];else if(a&&typeof a=="object"&&typeof c=="string")a=a[c];else return!1;return k(a,r[0],n).some(ge)}):s}case"leaf_paths":{let s=[],i=(o,a)=>{if(o===null||typeof o!="object")s.push(a);else if(Array.isArray(o))for(let l=0;l<o.length;l++)i(o[l],[...a,l]);else for(let l of Object.keys(o))i(o[l],[...a,l])};return i(t,[]),[s]}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([s,i])=>({key:s,value:i}))]:[null];case"from_entries":if(Array.isArray(t)){let s={};for(let i of t)if(i&&typeof i=="object"){let o=i,a=o.key??o.name??o.k,l=o.value??o.v;a!==void 0&&(s[String(a)]=l)}return[s]}return[null];case"with_entries":{if(r.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let i=Object.entries(t).map(([a,l])=>({key:a,value:l})).flatMap(a=>k(a,r[0],n)),o={};for(let a of i)if(a&&typeof a=="object"){let l=a,c=l.key??l.name??l.k,u=l.value??l.v;c!==void 0&&(o[String(c)]=u)}return[o]}return[null]}case"join":{if(!Array.isArray(t))return[null];let s=r.length>0?k(t,r[0],n):[""],i=String(s[0]);return[t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(i)]}case"split":{if(typeof t!="string"||r.length===0)return[null];let s=k(t,r[0],n),i=String(s[0]);return[t.split(i)]}case"test":{if(typeof t!="string"||r.length===0)return[!1];let s=k(t,r[0],n),i=String(s[0]);try{let o=r.length>1?String(k(t,r[1],n)[0]):"";return[new RegExp(i,o).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||r.length===0)return[null];let s=k(t,r[0],n),i=String(s[0]);try{let o=r.length>1?String(k(t,r[1],n)[0]):"",l=new RegExp(i,`${o}d`).exec(t);if(!l)return[];let c=l.indices;return[{offset:l.index,length:l[0].length,string:l[0],captures:l.slice(1).map((u,f)=>({offset:c?.[f+1]?.[0]??null,length:u?.length??0,string:u??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||r.length===0)return[null];let s=k(t,r[0],n),i=String(s[0]);try{let o=r.length>1?String(k(t,r[1],n)[0]):"",a=new RegExp(i,o),l=t.match(a);return!l||!l.groups?[{}]:[l.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||r.length<2)return[null];let s=k(t,r[0],n),i=k(t,r[1],n),o=String(s[0]),a=String(i[0]);try{let l=r.length>2?String(k(t,r[2],n)[0]):"";return[t.replace(new RegExp(o,l),a)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||r.length<2)return[null];let s=k(t,r[0],n),i=k(t,r[1],n),o=String(s[0]),a=String(i[0]);try{let l=r.length>2?String(k(t,r[2],n)[0]):"g",c=l.includes("g")?l:`${l}g`;return[t.replace(new RegExp(o,c),a)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.toLowerCase()]:[null];case"ascii_upcase":return typeof t=="string"?[t.toUpperCase()]:[null];case"ltrimstr":{if(typeof t!="string"||r.length===0)return[t];let s=k(t,r[0],n),i=String(s[0]);return[t.startsWith(i)?t.slice(i.length):t]}case"rtrimstr":{if(typeof t!="string"||r.length===0)return[t];let s=k(t,r[0],n),i=String(s[0]);return[t.endsWith(i)?t.slice(0,-i.length):t]}case"trim":return typeof t=="string"?[t.trim()]:[t];case"startswith":{if(typeof t!="string"||r.length===0)return[!1];let s=k(t,r[0],n);return[t.startsWith(String(s[0]))]}case"endswith":{if(typeof t!="string"||r.length===0)return[!1];let s=k(t,r[0],n);return[t.endsWith(String(s[0]))]}case"index":{if(r.length===0)return[null];let i=k(t,r[0],n)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.indexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){let o=t.findIndex(a=>Ot(a,i));return[o>=0?o:null]}return[null]}case"rindex":{if(r.length===0)return[null];let i=k(t,r[0],n)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.lastIndexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){for(let o=t.length-1;o>=0;o--)if(Ot(t[o],i))return[o];return[null]}return[null]}case"indices":{if(r.length===0)return[[]];let i=k(t,r[0],n)[0],o=[];if(typeof t=="string"&&typeof i=="string"){let a=t.indexOf(i);for(;a!==-1;)o.push(a),a=t.indexOf(i,a+1)}else if(Array.isArray(t))for(let a=0;a<t.length;a++)Ot(t[a],i)&&o.push(a);return[o]}case"floor":return typeof t=="number"?[Math.floor(t)]:[null];case"ceil":return typeof t=="number"?[Math.ceil(t)]:[null];case"round":return typeof t=="number"?[Math.round(t)]:[null];case"sqrt":return typeof t=="number"?[Math.sqrt(t)]:[null];case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:[null];case"log":return typeof t=="number"?[Math.log(t)]:[null];case"log10":return typeof t=="number"?[Math.log10(t)]:[null];case"log2":return typeof t=="number"?[Math.log2(t)]:[null];case"exp":return typeof t=="number"?[Math.exp(t)]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(typeof t!="number"||r.length===0)return[null];let i=k(t,r[0],n)[0];return[t**i]}case"sin":return typeof t=="number"?[Math.sin(t)]:[null];case"cos":return typeof t=="number"?[Math.cos(t)]:[null];case"tan":return typeof t=="number"?[Math.tan(t)]:[null];case"asin":return typeof t=="number"?[Math.asin(t)]:[null];case"acos":return typeof t=="number"?[Math.acos(t)]:[null];case"atan":return typeof t=="number"?[Math.atan(t)]:[null];case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let s=Number(t);return[Number.isNaN(s)?null:s]}return[null];case"infinite":return[!Number.isFinite(t)];case"nan":return[Number.isNaN(t)];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"now":return[Date.now()/1e3];case"env":return[n.env??{}];case"recurse":{if(r.length===0){let a=[],l=c=>{if(a.push(c),Array.isArray(c))for(let u of c)l(u);else if(c&&typeof c=="object")for(let u of Object.keys(c))l(c[u])};return l(t),a}let s=[],i=new Set,o=a=>{let l=JSON.stringify(a);if(i.has(l))return;i.add(l),s.push(a);let c=k(a,r[0],n);for(let u of c)u!=null&&o(u)};return o(t),s}case"recurse_down":return xl(t,"recurse",r,n);case"walk":{if(r.length===0)return[t];let s=new WeakSet,i=o=>{if(o&&typeof o=="object"){if(s.has(o))return o;s.add(o)}let a;if(Array.isArray(o))a=o.map(i);else if(o&&typeof o=="object"){let c={};for(let[u,f]of Object.entries(o))c[u]=i(f);a=c}else a=o;return k(a,r[0],n)[0]};return[i(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),i=[];for(let o=0;o<s;o++)i.push(t.map(a=>Array.isArray(a)?a[o]:null));return[i]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(s=>s.codePointAt(0))]:[null];case"implode":return Array.isArray(t)?[String.fromCodePoint(...t)]:[null];case"tojson":case"tojsonstream":return[JSON.stringify(t)];case"fromjson":{if(typeof t=="string")try{return[JSON.parse(t)]}catch{return[null]}return[null]}case"limit":{if(r.length<2)return[];let i=k(t,r[0],n)[0];return k(t,r[1],n).slice(0,i)}case"until":{if(r.length<2)return[t];let s=t,i=n.limits.maxIterations;for(let o=0;o<i;o++){if(k(s,r[0],n).some(ge))return[s];let l=k(s,r[1],n);if(l.length===0)return[s];s=l[0]}throw new W(`jq until: too many iterations (${i}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(r.length<2)return[t];let s=[],i=t,o=n.limits.maxIterations;for(let a=0;a<o&&k(i,r[0],n).some(ge);a++){s.push(i);let c=k(i,r[1],n);if(c.length===0)break;i=c[0]}if(s.length>=o)throw new W(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(r.length===0)return[t];let s=[],i=t,o=n.limits.maxIterations;for(let a=0;a<o;a++){s.push(i);let l=k(i,r[0],n);if(l.length===0)break;i=l[0]}if(s.length>=o)throw new W(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"debug":return[t];case"input_line_number":return[1];case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(i=>{let o=String(i??"");return o.includes(",")||o.includes('"')||o.includes(`
451
- `)?`"${o.replace(/"/g,'""')}"`:o}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(s=>String(s??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":return[JSON.stringify(t)];case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let s=n.currentPath;if(s.length===0)return[];let i=r.length>0?k(t,r[0],n)[0]:1;if(i>=0){if(i>s.length)return[];let o=s.slice(0,s.length-i);return[ns(n.root,o)]}else{let o=-i-1;if(o>=s.length)return[t];let a=s.slice(0,o);return[ns(n.root,a)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let s=n.currentPath,i=[];for(let o=s.length-1;o>=0;o--)i.push(ns(n.root,s.slice(0,o)));return[i]}case"root":return n.root!==void 0?[n.root]:[];default:throw new Error(`Unknown function: ${e}`)}}function ft(t,e){let r=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,n=r(t),s=r(e);if(n!==s)return n-s;if(typeof t=="number"&&typeof e=="number")return t-e;if(typeof t=="string"&&typeof e=="string")return t.localeCompare(e);if(typeof t=="boolean"&&typeof e=="boolean")return(t?1:0)-(e?1:0);if(Array.isArray(t)&&Array.isArray(e)){for(let i=0;i<Math.min(t.length,e.length);i++){let o=ft(t[i],e[i]);if(o!==0)return o}return t.length-e.length}return 0}function Dr(t,e){if(Ot(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return e.every(r=>t.some(n=>Dr(n,r)));if(t&&e&&typeof t=="object"&&typeof e=="object"&&!Array.isArray(t)&&!Array.isArray(e)){let r=t,n=e;return Object.keys(n).every(s=>s in r&&Dr(r[s],n[s]))}return!1}function is(t,e,r){if(e.length===0)return r;let[n,...s]=e;if(typeof n=="number"){let o=Array.isArray(t)?[...t]:[];for(;o.length<=n;)o.push(null);return o[n]=is(o[n],s,r),o}let i=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};return i[n]=is(i[n],s,r),i}function os(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i={...t};return delete i[String(s)],i}return t}let[r,...n]=e;if(Array.isArray(t)&&typeof r=="number"){let s=[...t];return s[r]=os(s[r],n),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s={...t};return s[String(r)]=os(s[String(r)],n),s}return t}function Qm(t,e,r,n,s){k(t,e,r).length>0&&s.push(n)}var Gm,wl=C(()=>{"use strict";X();Gm=1e4});function bl(t){let e=[],r=0,n=(c=0)=>t[r+c],s=()=>t[r++],i=()=>r>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=r,u=s();if(!(u===" "||u===" "||u===`
449
+ `),a=[];for(let u of o){let f=u.trim();f&&!f.startsWith("#")&&a.push(f)}let l=a.join("; ");return await n.exec(l,{env:s,cwd:n.cwd})}var Cl,Xm,Jm,cs=C(()=>{"use strict";L();Cl={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},Xm={name:"bash",async execute(t,e){if(N(t))return k(Cl);if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"bash",o=t.slice(3);return Hr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Hr(i,r,n,e)}catch{return{stdout:"",stderr:`bash: ${r}: No such file or directory
450
+ `,exitCode:127}}}},Jm={name:"sh",async execute(t,e){if(N(t))return k({...Cl,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let s=t[1],i=t[2]||"sh",o=t.slice(3);return Hr(s,i,o,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let r=t[0],n=t.slice(1);try{let s=e.fs.resolvePath(e.cwd,r),i=await e.fs.readFile(s);return Hr(i,r,n,e)}catch{return{stdout:"",stderr:`sh: ${r}: No such file or directory
451
+ `,exitCode:127}}}}});function e0(t){return{vars:new Map,limits:{maxIterations:t?.limits?.maxIterations??Ym},env:t?.env}}function us(t,e,r){let n=new Map(t.vars);return n.set(e,r),{vars:n,limits:t.limits,env:t.env,root:t.root,currentPath:t.currentPath}}function fs(t,e){let r=t;for(let n of e)if(r&&typeof r=="object")r=r[n];else return;return r}function Ut(t){if(t.type==="Identity")return[];if(t.type==="Field"){let e=t.base?Ut(t.base):[];return e===null?null:[...e,t.name]}if(t.type==="Index"&&t.index.type==="Literal"){let e=t.base?Ut(t.base):[];if(e===null)return null;let r=t.index.value;return typeof r=="number"||typeof r=="string"?[...e,r]:null}if(t.type==="Pipe"){let e=Ut(t.left);return e===null?null:ps(e,t.right)}return t.type==="Call"&&(t.name==="parent"||t.name==="root"),null}function ps(t,e){if(e.type==="Call"){if(e.name==="parent"){let r=1;if(e.args.length>0&&e.args[0].type==="Literal"){let n=e.args[0].value;typeof n=="number"&&(r=n)}if(r>=0)return t.slice(0,Math.max(0,t.length-r));{let n=-r-1;return t.slice(0,Math.min(n,t.length))}}if(e.name==="root")return[]}if(e.type==="Field"){let r=Ut(e);if(r!==null)return[...t,...r]}if(e.type==="Index"&&e.index.type==="Literal"){let r=Ut(e);if(r!==null)return[...t,...r]}if(e.type==="Pipe"){let r=ps(t,e.left);return r===null?null:ps(r,e.right)}return e.type==="Identity"?t:null}function A(t,e,r){let n=r&&"vars"in r?r:e0(r);switch(n.root===void 0&&(n={...n,root:t,currentPath:[]}),e.type){case"Identity":return[t];case"Field":return(e.base?A(t,e.base,n):[t]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let o=i[e.name];return[o===void 0?null:o]}return[null]});case"Index":return(e.base?A(t,e.base,n):[t]).flatMap(i=>A(i,e.index,n).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){let l=a<0?i.length+a:a;return l>=0&&l<i.length?[i[l]]:[null]}return typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[a]]:[null]}));case"Slice":return(e.base?A(t,e.base,n):[t]).flatMap(i=>{if(!Array.isArray(i)&&typeof i!="string")return[null];let o=i.length,a=e.start?A(t,e.start,n):[0],l=e.end?A(t,e.end,n):[o];return a.flatMap(c=>l.map(u=>{let f=Al(c,o),p=Al(u,o);return Array.isArray(i),i.slice(f,p)}))});case"Iterate":return(e.base?A(t,e.base,n):[t]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=A(t,e.left,n),i=Ut(e.left);return s.flatMap(o=>{if(i!==null){let a={...n,currentPath:[...n.currentPath??[],...i]};return A(o,e.right,a)}return A(o,e.right,n)})}case"Comma":{let s=A(t,e.left,n),i=A(t,e.right,n);return[...s,...i]}case"Literal":return[e.value];case"Array":return e.elements?[A(t,e.elements,n)]:[[]];case"Object":{let s=[{}];for(let i of e.entries){let o=typeof i.key=="string"?[i.key]:A(t,i.key,n),a=A(t,i.value,n),l=[];for(let c of s)for(let u of o)for(let f of a)l.push({...c,[String(u)]:f});s.length=0,s.push(...l)}return s}case"Paren":return A(t,e.expr,n);case"BinaryOp":return n0(t,e.op,e.left,e.right,n);case"UnaryOp":return A(t,e.operand,n).map(i=>e.op==="-"?typeof i=="number"?-i:null:e.op==="not"?!Ne(i):null);case"Cond":return A(t,e.cond,n).flatMap(i=>{if(Ne(i))return A(t,e.then,n);for(let o of e.elifs)if(A(t,o.cond,n).some(Ne))return A(t,o.then,n);return e.else?A(t,e.else,n):[null]});case"Try":try{return A(t,e.body,n)}catch{return e.catch?A(t,e.catch,n):[]}case"Call":return Nl(t,e.name,e.args,n);case"VarBind":return A(t,e.value,n).flatMap(i=>{let o=us(n,e.name,i);return A(t,e.body,o)});case"VarRef":{if(e.name==="$ENV")return[n.env??{}];let s=n.vars.get(e.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,o=a=>{if(a&&typeof a=="object"){if(i.has(a))return;i.add(a)}if(s.push(a),Array.isArray(a))for(let l of a)o(l);else if(a&&typeof a=="object")for(let l of Object.keys(a))o(a[l])};return o(t),s}case"Optional":try{return A(t,e.expr,n)}catch{return[]}case"StringInterp":return[e.parts.map(i=>typeof i=="string"?i:A(t,i,n).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[t0(t,e.path,e.op,e.value,n)];case"Reduce":{let s=A(t,e.expr,n),i=A(t,e.init,n)[0];for(let o of s){let a=us(n,e.varName,o);i=A(i,e.update,a)[0]}return[i]}case"Foreach":{let s=A(t,e.expr,n),i=A(t,e.init,n)[0],o=[];for(let a of s){let l=us(n,e.varName,a);if(i=A(i,e.update,l)[0],e.extract){let c=A(i,e.extract,l);o.push(...c)}else o.push(i)}return o}default:{let s=e;throw new Error(`Unknown AST node type: ${s.type}`)}}}function Al(t,e){return t<0?Math.max(0,e+t):Math.min(t,e)}function t0(t,e,r,n,s){function i(l,c){switch(r){case"=":return c;case"|=":return A(l,n,s)[0]??null;case"+=":return typeof l=="number"&&typeof c=="number"||typeof l=="string"&&typeof c=="string"?l+c:Array.isArray(l)&&Array.isArray(c)?[...l,...c]:l&&c&&typeof l=="object"&&typeof c=="object"?{...l,...c}:c;case"-=":return typeof l=="number"&&typeof c=="number"?l-c:l;case"*=":return typeof l=="number"&&typeof c=="number"?l*c:l;case"/=":return typeof l=="number"&&typeof c=="number"?l/c:l;case"%=":return typeof l=="number"&&typeof c=="number"?l%c:l;case"//=":return l===null||l===!1?c:l;default:return c}}function o(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let p={...f};return p[c.name]=u(p[c.name]),p}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l};return f[c.name]=u(f[c.name]),f}return l}case"Index":{let p=A(t,c.index,s)[0];if(c.base)return o(l,c.base,d=>{if(typeof p=="number"&&Array.isArray(d)){let h=[...d],m=p<0?h.length+p:p;return m>=0&&m<h.length&&(h[m]=u(h[m])),h}if(typeof p=="string"&&d&&typeof d=="object"&&!Array.isArray(d)){let h={...d};return h[p]=u(h[p]),h}return d});if(typeof p=="number"&&Array.isArray(l)){let d=[...l],h=p<0?d.length+p:p;return h>=0&&h<d.length&&(d[h]=u(d[h])),d}if(typeof p=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){let d={...l};return d[p]=u(d[p]),d}return l}case"Iterate":{let f=p=>{if(Array.isArray(p))return p.map(d=>u(d));if(p&&typeof p=="object"){let d={};for(let[h,m]of Object.entries(p))d[h]=u(m);return d}return p};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,p=>p);return o(f,c.right,u)}default:return u(l)}}return o(t,e,l=>{if(r==="|=")return i(l,l);let c=A(t,n,s);return i(l,c[0]??null)})}function r0(t,e,r){function n(s,i){switch(i.type){case"Identity":return null;case"Field":{if(s&&typeof s=="object"&&!Array.isArray(s)){let o={...s};return delete o[i.name],o}return s}case"Index":{let a=A(t,i.index,r)[0];if(typeof a=="number"&&Array.isArray(s)){let l=[...s],c=a<0?l.length+a:a;return c>=0&&c<l.length&&l.splice(c,1),l}if(typeof a=="string"&&s&&typeof s=="object"&&!Array.isArray(s)){let l={...s};return delete l[a],l}return s}case"Iterate":return Array.isArray(s)?[]:s&&typeof s=="object"?{}:s;default:return s}}return n(t,e)}function Ne(t){return t!==null&&t!==!1}function n0(t,e,r,n,s){if(e==="and")return A(t,r,s).flatMap(l=>Ne(l)?A(t,n,s).map(u=>Ne(u)):[!1]);if(e==="or")return A(t,r,s).flatMap(l=>Ne(l)?[!0]:A(t,n,s).map(u=>Ne(u)));if(e==="//"){let l=A(t,r,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:A(t,n,s)}let i=A(t,r,s),o=A(t,n,s);return i.flatMap(a=>o.map(l=>{switch(e){case"+":return typeof a=="number"&&typeof l=="number"||typeof a=="string"&&typeof l=="string"?a+l:Array.isArray(a)&&Array.isArray(l)?[...a,...l]:a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?{...a,...l}:null;case"-":if(typeof a=="number"&&typeof l=="number")return a-l;if(Array.isArray(a)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return a.filter(u=>!c.has(JSON.stringify(u)))}return null;case"*":return typeof a=="number"&&typeof l=="number"?a*l:typeof a=="string"&&typeof l=="number"?a.repeat(l):a&&l&&typeof a=="object"&&typeof l=="object"&&!Array.isArray(a)&&!Array.isArray(l)?kl(a,l):null;case"/":return typeof a=="number"&&typeof l=="number"?a/l:typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":return typeof a=="number"&&typeof l=="number"?a%l:null;case"==":return jt(a,l);case"!=":return!jt(a,l);case"<":return Gr(a,l)<0;case"<=":return Gr(a,l)<=0;case">":return Gr(a,l)>0;case">=":return Gr(a,l)>=0;default:return null}}))}function jt(t,e){return JSON.stringify(t)===JSON.stringify(e)}function Gr(t,e){return typeof t=="number"&&typeof e=="number"?t-e:typeof t=="string"&&typeof e=="string"?t.localeCompare(e):0}function kl(t,e){let r={...t};for(let n of Object.keys(e))n in r&&r[n]&&typeof r[n]=="object"&&!Array.isArray(r[n])&&e[n]&&typeof e[n]=="object"&&!Array.isArray(e[n])?r[n]=kl(r[n],e[n]):r[n]=e[n];return r}function Nl(t,e,r,n){switch(e){case"keys":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t).sort()]:[null];case"keys_unsorted":return Array.isArray(t)?[t.map((s,i)=>i)]:t&&typeof t=="object"?[Object.keys(t)]:[null];case"values":return Array.isArray(t)?[t]:t&&typeof t=="object"?[Object.values(t)]:[null];case"length":return typeof t=="string"?[t.length]:Array.isArray(t)?[t.length]:t&&typeof t=="object"?[Object.keys(t).length]:t===null?[0]:[null];case"utf8bytelength":return typeof t=="string"?[new TextEncoder().encode(t).length]:[null];case"type":return t===null?["null"]:Array.isArray(t)?["array"]:typeof t=="boolean"?["boolean"]:typeof t=="number"?["number"]:typeof t=="string"?["string"]:typeof t=="object"?["object"]:["null"];case"empty":return[];case"error":{let s=r.length>0?A(t,r[0],n)[0]:t;throw new Error(String(s))}case"not":return[!Ne(t)];case"null":return[null];case"true":return[!0];case"false":return[!1];case"first":if(r.length>0){let s=A(t,r[0],n);return s.length>0?[s[0]]:[]}return Array.isArray(t)&&t.length>0?[t[0]]:[null];case"last":if(r.length>0){let s=A(t,r[0],n);return s.length>0?[s[s.length-1]]:[]}return Array.isArray(t)&&t.length>0?[t[t.length-1]]:[null];case"nth":{if(r.length<1)return[null];let i=A(t,r[0],n)[0];if(r.length>1){let o=A(t,r[1],n);return i>=0&&i<o.length?[o[i]]:[]}return Array.isArray(t)?i>=0&&i<t.length?[t[i]]:[null]:[null]}case"range":{if(r.length===0)return[];let s=A(t,r[0],n);if(r.length===1){let c=s[0];return Array.from({length:c},(u,f)=>f)}let i=A(t,r[1],n),o=s[0],a=i[0],l=[];for(let c=o;c<a;c++)l.push(c);return l}case"reverse":return Array.isArray(t)?[[...t].reverse()]:typeof t=="string"?[t.split("").reverse().join("")]:[null];case"sort":return Array.isArray(t)?[[...t].sort(Et)]:[null];case"sort_by":return!Array.isArray(t)||r.length===0?[null]:[[...t].sort((i,o)=>{let a=A(i,r[0],n)[0],l=A(o,r[0],n)[0];return Et(a,l)})];case"unique":if(Array.isArray(t)){let s=new Set,i=[];for(let o of t){let a=JSON.stringify(o);s.has(a)||(s.add(a),i.push(o))}return[i]}return[null];case"unique_by":{if(!Array.isArray(t)||r.length===0)return[null];let s=new Set,i=[];for(let o of t){let a=JSON.stringify(A(o,r[0],n)[0]);s.has(a)||(s.add(a),i.push(o))}return[i]}case"group_by":{if(!Array.isArray(t)||r.length===0)return[null];let s=new Map;for(let i of t){let o=JSON.stringify(A(i,r[0],n)[0]);s.has(o)||s.set(o,[]),s.get(o)?.push(i)}return[[...s.values()]]}case"max":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>Et(s,i)>0?s:i)]:[null];case"max_by":return!Array.isArray(t)||t.length===0||r.length===0?[null]:[t.reduce((s,i)=>{let o=A(s,r[0],n)[0],a=A(i,r[0],n)[0];return Et(o,a)>0?s:i})];case"min":return Array.isArray(t)&&t.length>0?[t.reduce((s,i)=>Et(s,i)<0?s:i)]:[null];case"min_by":return!Array.isArray(t)||t.length===0||r.length===0?[null]:[t.reduce((s,i)=>{let o=A(s,r[0],n)[0],a=A(i,r[0],n)[0];return Et(o,a)<0?s:i})];case"flatten":{if(!Array.isArray(t))return[null];let s=r.length>0?A(t,r[0],n)[0]:Number.POSITIVE_INFINITY;return[t.flat(s)]}case"add":if(Array.isArray(t)){if(t.length===0)return[null];if(t.every(s=>typeof s=="number"))return[t.reduce((s,i)=>s+i,0)];if(t.every(s=>typeof s=="string"))return[t.join("")];if(t.every(s=>Array.isArray(s)))return[t.flat()];if(t.every(s=>s&&typeof s=="object"&&!Array.isArray(s)))return[Object.assign({},...t)]}return[null];case"any":return r.length>0?Array.isArray(t)?[t.some(s=>Ne(A(s,r[0],n)[0]))]:[!1]:Array.isArray(t)?[t.some(Ne)]:[!1];case"all":return r.length>0?Array.isArray(t)?[t.every(s=>Ne(A(s,r[0],n)[0]))]:[!0]:Array.isArray(t)?[t.every(Ne)]:[!0];case"select":return r.length===0?[t]:A(t,r[0],n).some(Ne)?[t]:[];case"map":return r.length===0||!Array.isArray(t)?[null]:[t.flatMap(i=>A(i,r[0],n))];case"map_values":{if(r.length===0)return[null];if(Array.isArray(t))return[t.flatMap(s=>A(s,r[0],n))];if(t&&typeof t=="object"){let s={};for(let[i,o]of Object.entries(t)){let a=A(o,r[0],n);a.length>0&&(s[i]=a[0])}return[s]}return[null]}case"has":{if(r.length===0)return[!1];let i=A(t,r[0],n)[0];return Array.isArray(t)&&typeof i=="number"?[i>=0&&i<t.length]:t&&typeof t=="object"&&typeof i=="string"?[i in t]:[!1]}case"in":{if(r.length===0)return[!1];let i=A(t,r[0],n)[0];return Array.isArray(i)&&typeof t=="number"?[t>=0&&t<i.length]:i&&typeof i=="object"&&typeof t=="string"?[t in i]:[!1]}case"contains":{if(r.length===0)return[!1];let s=A(t,r[0],n);return[qr(t,s[0])]}case"inside":{if(r.length===0)return[!1];let s=A(t,r[0],n);return[qr(s[0],t)]}case"getpath":{if(r.length===0)return[null];let i=A(t,r[0],n)[0],o=t;for(let a of i){if(o==null)return[null];if(Array.isArray(o)&&typeof a=="number")o=o[a];else if(typeof o=="object"&&typeof a=="string")o=o[a];else return[null]}return[o]}case"setpath":{if(r.length<2)return[null];let i=A(t,r[0],n)[0],a=A(t,r[1],n)[0];return[ds(t,i,a)]}case"delpaths":{if(r.length===0)return[t];let i=A(t,r[0],n)[0],o=t;for(let a of i.sort((l,c)=>c.length-l.length))o=hs(o,a);return[o]}case"path":{if(r.length===0)return[[]];let s=[];return s0(t,r[0],n,[],s),s}case"del":return r.length===0?[t]:[r0(t,r[0],n)];case"paths":{let s=[],i=(o,a)=>{if(o&&typeof o=="object")if(Array.isArray(o))for(let l=0;l<o.length;l++)s.push([...a,l]),i(o[l],[...a,l]);else for(let l of Object.keys(o))s.push([...a,l]),i(o[l],[...a,l])};return i(t,[]),r.length>0?s.filter(o=>{let a=t;for(let c of o)if(Array.isArray(a)&&typeof c=="number")a=a[c];else if(a&&typeof a=="object"&&typeof c=="string")a=a[c];else return!1;return A(a,r[0],n).some(Ne)}):s}case"leaf_paths":{let s=[],i=(o,a)=>{if(o===null||typeof o!="object")s.push(a);else if(Array.isArray(o))for(let l=0;l<o.length;l++)i(o[l],[...a,l]);else for(let l of Object.keys(o))i(o[l],[...a,l])};return i(t,[]),[s]}case"to_entries":return t&&typeof t=="object"&&!Array.isArray(t)?[Object.entries(t).map(([s,i])=>({key:s,value:i}))]:[null];case"from_entries":if(Array.isArray(t)){let s={};for(let i of t)if(i&&typeof i=="object"){let o=i,a=o.key??o.name??o.k,l=o.value??o.v;a!==void 0&&(s[String(a)]=l)}return[s]}return[null];case"with_entries":{if(r.length===0)return[t];if(t&&typeof t=="object"&&!Array.isArray(t)){let i=Object.entries(t).map(([a,l])=>({key:a,value:l})).flatMap(a=>A(a,r[0],n)),o={};for(let a of i)if(a&&typeof a=="object"){let l=a,c=l.key??l.name??l.k,u=l.value??l.v;c!==void 0&&(o[String(c)]=u)}return[o]}return[null]}case"join":{if(!Array.isArray(t))return[null];let s=r.length>0?A(t,r[0],n):[""],i=String(s[0]);return[t.map(o=>typeof o=="string"?o:JSON.stringify(o)).join(i)]}case"split":{if(typeof t!="string"||r.length===0)return[null];let s=A(t,r[0],n),i=String(s[0]);return[t.split(i)]}case"test":{if(typeof t!="string"||r.length===0)return[!1];let s=A(t,r[0],n),i=String(s[0]);try{let o=r.length>1?String(A(t,r[1],n)[0]):"";return[new RegExp(i,o).test(t)]}catch{return[!1]}}case"match":{if(typeof t!="string"||r.length===0)return[null];let s=A(t,r[0],n),i=String(s[0]);try{let o=r.length>1?String(A(t,r[1],n)[0]):"",l=new RegExp(i,`${o}d`).exec(t);if(!l)return[];let c=l.indices;return[{offset:l.index,length:l[0].length,string:l[0],captures:l.slice(1).map((u,f)=>({offset:c?.[f+1]?.[0]??null,length:u?.length??0,string:u??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof t!="string"||r.length===0)return[null];let s=A(t,r[0],n),i=String(s[0]);try{let o=r.length>1?String(A(t,r[1],n)[0]):"",a=new RegExp(i,o),l=t.match(a);return!l||!l.groups?[{}]:[l.groups]}catch{return[null]}}case"sub":{if(typeof t!="string"||r.length<2)return[null];let s=A(t,r[0],n),i=A(t,r[1],n),o=String(s[0]),a=String(i[0]);try{let l=r.length>2?String(A(t,r[2],n)[0]):"";return[t.replace(new RegExp(o,l),a)]}catch{return[t]}}case"gsub":{if(typeof t!="string"||r.length<2)return[null];let s=A(t,r[0],n),i=A(t,r[1],n),o=String(s[0]),a=String(i[0]);try{let l=r.length>2?String(A(t,r[2],n)[0]):"g",c=l.includes("g")?l:`${l}g`;return[t.replace(new RegExp(o,c),a)]}catch{return[t]}}case"ascii_downcase":return typeof t=="string"?[t.toLowerCase()]:[null];case"ascii_upcase":return typeof t=="string"?[t.toUpperCase()]:[null];case"ltrimstr":{if(typeof t!="string"||r.length===0)return[t];let s=A(t,r[0],n),i=String(s[0]);return[t.startsWith(i)?t.slice(i.length):t]}case"rtrimstr":{if(typeof t!="string"||r.length===0)return[t];let s=A(t,r[0],n),i=String(s[0]);return[t.endsWith(i)?t.slice(0,-i.length):t]}case"trim":return typeof t=="string"?[t.trim()]:[t];case"startswith":{if(typeof t!="string"||r.length===0)return[!1];let s=A(t,r[0],n);return[t.startsWith(String(s[0]))]}case"endswith":{if(typeof t!="string"||r.length===0)return[!1];let s=A(t,r[0],n);return[t.endsWith(String(s[0]))]}case"index":{if(r.length===0)return[null];let i=A(t,r[0],n)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.indexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){let o=t.findIndex(a=>jt(a,i));return[o>=0?o:null]}return[null]}case"rindex":{if(r.length===0)return[null];let i=A(t,r[0],n)[0];if(typeof t=="string"&&typeof i=="string"){let o=t.lastIndexOf(i);return[o>=0?o:null]}if(Array.isArray(t)){for(let o=t.length-1;o>=0;o--)if(jt(t[o],i))return[o];return[null]}return[null]}case"indices":{if(r.length===0)return[[]];let i=A(t,r[0],n)[0],o=[];if(typeof t=="string"&&typeof i=="string"){let a=t.indexOf(i);for(;a!==-1;)o.push(a),a=t.indexOf(i,a+1)}else if(Array.isArray(t))for(let a=0;a<t.length;a++)jt(t[a],i)&&o.push(a);return[o]}case"floor":return typeof t=="number"?[Math.floor(t)]:[null];case"ceil":return typeof t=="number"?[Math.ceil(t)]:[null];case"round":return typeof t=="number"?[Math.round(t)]:[null];case"sqrt":return typeof t=="number"?[Math.sqrt(t)]:[null];case"fabs":case"abs":return typeof t=="number"?[Math.abs(t)]:[null];case"log":return typeof t=="number"?[Math.log(t)]:[null];case"log10":return typeof t=="number"?[Math.log10(t)]:[null];case"log2":return typeof t=="number"?[Math.log2(t)]:[null];case"exp":return typeof t=="number"?[Math.exp(t)]:[null];case"exp10":return typeof t=="number"?[10**t]:[null];case"exp2":return typeof t=="number"?[2**t]:[null];case"pow":{if(typeof t!="number"||r.length===0)return[null];let i=A(t,r[0],n)[0];return[t**i]}case"sin":return typeof t=="number"?[Math.sin(t)]:[null];case"cos":return typeof t=="number"?[Math.cos(t)]:[null];case"tan":return typeof t=="number"?[Math.tan(t)]:[null];case"asin":return typeof t=="number"?[Math.asin(t)]:[null];case"acos":return typeof t=="number"?[Math.acos(t)]:[null];case"atan":return typeof t=="number"?[Math.atan(t)]:[null];case"tostring":return typeof t=="string"?[t]:[JSON.stringify(t)];case"tonumber":if(typeof t=="number")return[t];if(typeof t=="string"){let s=Number(t);return[Number.isNaN(s)?null:s]}return[null];case"infinite":return[!Number.isFinite(t)];case"nan":return[Number.isNaN(t)];case"isinfinite":return[typeof t=="number"&&!Number.isFinite(t)];case"isnan":return[typeof t=="number"&&Number.isNaN(t)];case"isnormal":return[typeof t=="number"&&Number.isFinite(t)&&t!==0];case"isfinite":return[typeof t=="number"&&Number.isFinite(t)];case"numbers":return typeof t=="number"?[t]:[];case"strings":return typeof t=="string"?[t]:[];case"booleans":return typeof t=="boolean"?[t]:[];case"nulls":return t===null?[t]:[];case"arrays":return Array.isArray(t)?[t]:[];case"objects":return t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"iterables":return Array.isArray(t)||t&&typeof t=="object"&&!Array.isArray(t)?[t]:[];case"scalars":return!Array.isArray(t)&&!(t&&typeof t=="object")?[t]:[];case"now":return[Date.now()/1e3];case"env":return[n.env??{}];case"recurse":{if(r.length===0){let a=[],l=c=>{if(a.push(c),Array.isArray(c))for(let u of c)l(u);else if(c&&typeof c=="object")for(let u of Object.keys(c))l(c[u])};return l(t),a}let s=[],i=new Set,o=a=>{let l=JSON.stringify(a);if(i.has(l))return;i.add(l),s.push(a);let c=A(a,r[0],n);for(let u of c)u!=null&&o(u)};return o(t),s}case"recurse_down":return Nl(t,"recurse",r,n);case"walk":{if(r.length===0)return[t];let s=new WeakSet,i=o=>{if(o&&typeof o=="object"){if(s.has(o))return o;s.add(o)}let a;if(Array.isArray(o))a=o.map(i);else if(o&&typeof o=="object"){let c={};for(let[u,f]of Object.entries(o))c[u]=i(f);a=c}else a=o;return A(a,r[0],n)[0]};return[i(t)]}case"transpose":{if(!Array.isArray(t))return[null];if(t.length===0)return[[]];let s=Math.max(...t.map(o=>Array.isArray(o)?o.length:0)),i=[];for(let o=0;o<s;o++)i.push(t.map(a=>Array.isArray(a)?a[o]:null));return[i]}case"ascii":return typeof t=="string"&&t.length>0?[t.charCodeAt(0)]:[null];case"explode":return typeof t=="string"?[Array.from(t).map(s=>s.codePointAt(0))]:[null];case"implode":return Array.isArray(t)?[String.fromCodePoint(...t)]:[null];case"tojson":case"tojsonstream":return[JSON.stringify(t)];case"fromjson":{if(typeof t=="string")try{return[JSON.parse(t)]}catch{return[null]}return[null]}case"limit":{if(r.length<2)return[];let i=A(t,r[0],n)[0];return A(t,r[1],n).slice(0,i)}case"until":{if(r.length<2)return[t];let s=t,i=n.limits.maxIterations;for(let o=0;o<i;o++){if(A(s,r[0],n).some(Ne))return[s];let l=A(s,r[1],n);if(l.length===0)return[s];s=l[0]}throw new j(`jq until: too many iterations (${i}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(r.length<2)return[t];let s=[],i=t,o=n.limits.maxIterations;for(let a=0;a<o&&A(i,r[0],n).some(Ne);a++){s.push(i);let c=A(i,r[1],n);if(c.length===0)break;i=c[0]}if(s.length>=o)throw new j(`jq while: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"repeat":{if(r.length===0)return[t];let s=[],i=t,o=n.limits.maxIterations;for(let a=0;a<o;a++){s.push(i);let l=A(i,r[0],n);if(l.length===0)break;i=l[0]}if(s.length>=o)throw new j(`jq repeat: too many iterations (${o}), increase executionLimits.maxJqIterations`,"iterations");return s}case"debug":return[t];case"input_line_number":return[1];case"@base64":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"utf-8").toString("base64")]:[btoa(t)]:[null];case"@base64d":return typeof t=="string"?typeof Buffer<"u"?[Buffer.from(t,"base64").toString("utf-8")]:[atob(t)]:[null];case"@uri":return typeof t=="string"?[encodeURIComponent(t)]:[null];case"@csv":return Array.isArray(t)?[t.map(i=>{let o=String(i??"");return o.includes(",")||o.includes('"')||o.includes(`
452
+ `)?`"${o.replace(/"/g,'""')}"`:o}).join(",")]:[null];case"@tsv":return Array.isArray(t)?[t.map(s=>String(s??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":return[JSON.stringify(t)];case"@html":return typeof t=="string"?[t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")]:[null];case"@sh":return typeof t=="string"?[`'${t.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof t=="string"?[t]:t==null?[""]:[String(t)];case"parent":{if(n.root===void 0||n.currentPath===void 0)return[];let s=n.currentPath;if(s.length===0)return[];let i=r.length>0?A(t,r[0],n)[0]:1;if(i>=0){if(i>s.length)return[];let o=s.slice(0,s.length-i);return[fs(n.root,o)]}else{let o=-i-1;if(o>=s.length)return[t];let a=s.slice(0,o);return[fs(n.root,a)]}}case"parents":{if(n.root===void 0||n.currentPath===void 0)return[[]];let s=n.currentPath,i=[];for(let o=s.length-1;o>=0;o--)i.push(fs(n.root,s.slice(0,o)));return[i]}case"root":return n.root!==void 0?[n.root]:[];default:throw new Error(`Unknown function: ${e}`)}}function Et(t,e){let r=i=>i===null?0:typeof i=="boolean"?1:typeof i=="number"?2:typeof i=="string"?3:Array.isArray(i)?4:typeof i=="object"?5:6,n=r(t),s=r(e);if(n!==s)return n-s;if(typeof t=="number"&&typeof e=="number")return t-e;if(typeof t=="string"&&typeof e=="string")return t.localeCompare(e);if(typeof t=="boolean"&&typeof e=="boolean")return(t?1:0)-(e?1:0);if(Array.isArray(t)&&Array.isArray(e)){for(let i=0;i<Math.min(t.length,e.length);i++){let o=Et(t[i],e[i]);if(o!==0)return o}return t.length-e.length}return 0}function qr(t,e){if(jt(t,e))return!0;if(Array.isArray(t)&&Array.isArray(e))return e.every(r=>t.some(n=>qr(n,r)));if(t&&e&&typeof t=="object"&&typeof e=="object"&&!Array.isArray(t)&&!Array.isArray(e)){let r=t,n=e;return Object.keys(n).every(s=>s in r&&qr(r[s],n[s]))}return!1}function ds(t,e,r){if(e.length===0)return r;let[n,...s]=e;if(typeof n=="number"){let o=Array.isArray(t)?[...t]:[];for(;o.length<=n;)o.push(null);return o[n]=ds(o[n],s,r),o}let i=t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};return i[n]=ds(i[n],s,r),i}function hs(t,e){if(e.length===0)return null;if(e.length===1){let s=e[0];if(Array.isArray(t)&&typeof s=="number"){let i=[...t];return i.splice(s,1),i}if(t&&typeof t=="object"&&!Array.isArray(t)){let i={...t};return delete i[String(s)],i}return t}let[r,...n]=e;if(Array.isArray(t)&&typeof r=="number"){let s=[...t];return s[r]=hs(s[r],n),s}if(t&&typeof t=="object"&&!Array.isArray(t)){let s={...t};return s[String(r)]=hs(s[String(r)],n),s}return t}function s0(t,e,r,n,s){A(t,e,r).length>0&&s.push(n)}var Ym,Il=C(()=>{"use strict";oe();Ym=1e4});function vl(t){let e=[],r=0,n=(c=0)=>t[r+c],s=()=>t[r++],i=()=>r>=t.length,o=c=>c>="0"&&c<="9",a=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>a(c)||o(c);for(;!i();){let c=r,u=s();if(!(u===" "||u===" "||u===`
452
453
  `||u==="\r")){if(u==="#"){for(;!i()&&n()!==`
453
- `;)s();continue}if(u==="."&&n()==="."){s(),e.push({type:"DOTDOT",pos:c});continue}if(u==="="&&n()==="="){s(),e.push({type:"EQ",pos:c});continue}if(u==="!"&&n()==="="){s(),e.push({type:"NE",pos:c});continue}if(u==="<"&&n()==="="){s(),e.push({type:"LE",pos:c});continue}if(u===">"&&n()==="="){s(),e.push({type:"GE",pos:c});continue}if(u==="/"&&n()==="/"){s(),n()==="="?(s(),e.push({type:"UPDATE_ALT",pos:c})):e.push({type:"ALT",pos:c});continue}if(u==="+"&&n()==="="){s(),e.push({type:"UPDATE_ADD",pos:c});continue}if(u==="-"&&n()==="="){s(),e.push({type:"UPDATE_SUB",pos:c});continue}if(u==="*"&&n()==="="){s(),e.push({type:"UPDATE_MUL",pos:c});continue}if(u==="/"&&n()==="="){s(),e.push({type:"UPDATE_DIV",pos:c});continue}if(u==="%"&&n()==="="){s(),e.push({type:"UPDATE_MOD",pos:c});continue}if(u==="="&&n()!=="="){e.push({type:"ASSIGN",pos:c});continue}if(u==="."){e.push({type:"DOT",pos:c});continue}if(u==="|"){n()==="="?(s(),e.push({type:"UPDATE_PIPE",pos:c})):e.push({type:"PIPE",pos:c});continue}if(u===","){e.push({type:"COMMA",pos:c});continue}if(u===":"){e.push({type:"COLON",pos:c});continue}if(u===";"){e.push({type:"SEMICOLON",pos:c});continue}if(u==="("){e.push({type:"LPAREN",pos:c});continue}if(u===")"){e.push({type:"RPAREN",pos:c});continue}if(u==="["){e.push({type:"LBRACKET",pos:c});continue}if(u==="]"){e.push({type:"RBRACKET",pos:c});continue}if(u==="{"){e.push({type:"LBRACE",pos:c});continue}if(u==="}"){e.push({type:"RBRACE",pos:c});continue}if(u==="?"){e.push({type:"QUESTION",pos:c});continue}if(u==="+"){e.push({type:"PLUS",pos:c});continue}if(u==="-"){if(o(n())){let f=u;for(;!i()&&(o(n())||n()===".");)f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}e.push({type:"MINUS",pos:c});continue}if(u==="*"){e.push({type:"STAR",pos:c});continue}if(u==="/"){e.push({type:"SLASH",pos:c});continue}if(u==="%"){e.push({type:"PERCENT",pos:c});continue}if(u==="<"){e.push({type:"LT",pos:c});continue}if(u===">"){e.push({type:"GT",pos:c});continue}if(o(u)){let f=u;for(;!i()&&(o(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(t[r+1]==="+"||t[r+1]==="-")&&(f+=s()),f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}if(u==='"'){let f="";for(;!i()&&n()!=='"';)if(n()==="\\"){if(s(),i())break;let d=s();switch(d){case"n":f+=`
454
- `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=d}}else f+=s();i()||s(),e.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(n());)f+=s();let d=Xm[f];d?e.push({type:d,pos:c}):e.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return e.push({type:"EOF",pos:r}),e}function El(t){let e=bl(t);return new as(e).parse()}var Xm,as,Sl=C(()=>{"use strict";Xm={and:"AND",or:"OR",not:"NOT",if:"IF",then:"THEN",elif:"ELIF",else:"ELSE",end:"END",as:"AS",try:"TRY",catch:"CATCH",true:"TRUE",false:"FALSE",null:"NULL",reduce:"REDUCE",foreach:"FOREACH"};as=class t{tokens;pos=0;constructor(e){this.tokens=e}peek(e=0){return this.tokens[this.pos+e]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let r of e)if(this.check(r))return this.advance();return null}expect(e,r){if(!this.check(e))throw new Error(`${r} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let e=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){return this.parsePipe()}parsePipe(){let e=this.parseComma();for(;this.match("PIPE");){let r=this.parseComma();e={type:"Pipe",left:e,right:r}}return e}parseComma(){let e=this.parseVarBind();for(;this.match("COMMA");){let r=this.parseVarBind();e={type:"Comma",left:e,right:r}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match("AS")){let r=this.expect("IDENT","Expected variable name after 'as'"),n=r.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return{type:"VarBind",name:n,value:e,body:s}}return e}parseUpdate(){let e=this.parseAlt(),r={ASSIGN:"=",UPDATE_ADD:"+=",UPDATE_SUB:"-=",UPDATE_MUL:"*=",UPDATE_DIV:"/=",UPDATE_MOD:"%=",UPDATE_ALT:"//=",UPDATE_PIPE:"|="},n=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(n){let s=this.parseVarBind();return{type:"UpdateOp",op:r[n.type],path:e,value:s}}return e}parseAlt(){let e=this.parseOr();for(;this.match("ALT");){let r=this.parseOr();e={type:"BinaryOp",op:"//",left:e,right:r}}return e}parseOr(){let e=this.parseAnd();for(;this.match("OR");){let r=this.parseAnd();e={type:"BinaryOp",op:"or",left:e,right:r}}return e}parseAnd(){let e=this.parseNot();for(;this.match("AND");){let r=this.parseNot();e={type:"BinaryOp",op:"and",left:e,right:r}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),r={EQ:"==",NE:"!=",LT:"<",LE:"<=",GT:">",GE:">="},n=this.match("EQ","NE","LT","LE","GT","GE");if(n){let s=this.parseAddSub();e={type:"BinaryOp",op:r[n.type],left:e,right:s}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match("PLUS")){let r=this.parseMulDiv();e={type:"BinaryOp",op:"+",left:e,right:r}}else if(this.match("MINUS")){let r=this.parseMulDiv();e={type:"BinaryOp",op:"-",left:e,right:r}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match("STAR")){let r=this.parseUnary();e={type:"BinaryOp",op:"*",left:e,right:r}}else if(this.match("SLASH")){let r=this.parseUnary();e={type:"BinaryOp",op:"/",left:e,right:r}}else if(this.match("PERCENT")){let r=this.parseUnary();e={type:"BinaryOp",op:"%",left:e,right:r}}else break;return e}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("QUESTION"))e={type:"Optional",expr:e};else if(this.check("DOT")&&this.peek(1).type==="IDENT")this.advance(),e={type:"Field",name:this.expect("IDENT","Expected field name").value,base:e};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))e={type:"Iterate",base:e};else if(this.check("COLON")){this.advance();let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",end:r,base:e}}else{let r=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",start:r,end:n,base:e}}else this.expect("RBRACKET","Expected ']'"),e={type:"Index",index:r,base:e}}else break;return e}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.match("DOT")){if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let r=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:r}}let e=this.parseExpr();if(this.match("COLON")){let r=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:e,end:r}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:e}}return this.check("IDENT")?{type:"Field",name:this.advance().value}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let r=this.advance().value;return r.includes("\\(")?this.parseStringInterpolation(r):{type:"Literal",value:r}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let e=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:e}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let e=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:e}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let e=this.parsePostfix(),r;return this.match("CATCH")&&(r=this.parsePostfix()),{type:"Try",body:e,catch:r}}if(this.match("REDUCE")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after reduce expression");let r=this.expect("IDENT","Expected variable name"),n=r.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr();return this.expect("RPAREN","Expected ')' after update expression"),{type:"Reduce",expr:e,varName:n,init:s,update:i}}if(this.match("FOREACH")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after foreach expression");let r=this.expect("IDENT","Expected variable name"),n=r.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr(),o;return this.match("SEMICOLON")&&(o=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions"),{type:"Foreach",expr:e,varName:n,init:s,update:i,extract:o}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let r=this.advance().value;if(r.startsWith("$"))return{type:"VarRef",name:r};if(this.match("LPAREN")){let n=[];if(!this.check("RPAREN"))for(n.push(this.parseExpr());this.match("SEMICOLON");)n.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:r,args:n}}return{type:"Call",name:r,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let e=[];if(!this.check("RBRACE"))do{let r,n;if(this.match("LPAREN"))r=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else if(this.check("IDENT")){let s=this.advance().value;this.match("COLON")?(r=s,n=this.parseObjectValue()):(r=s,n={type:"Field",name:s})}else if(this.check("STRING"))r=this.advance().value,this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);e.push({key:r,value:n})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match("PIPE");){let r=this.parseVarBind();e={type:"Pipe",left:e,right:r}}return e}parseIf(){let e=this.parseExpr();this.expect("THEN","Expected 'then'");let r=this.parseExpr(),n=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();n.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:e,then:r,elifs:n,else:s}}parseStringInterpolation(e){let r=[],n="",s=0;for(;s<e.length;)if(e[s]==="\\"&&e[s+1]==="("){n&&(r.push(n),n=""),s+=2;let i=1,o="";for(;s<e.length&&i>0;)e[s]==="("?i++:e[s]===")"&&i--,i>0&&(o+=e[s]),s++;let a=bl(o),l=new t(a);r.push(l.parse())}else n+=e[s],s++;return n&&r.push(n),{type:"StringInterp",parts:r}}}});var Cl=C(()=>{"use strict";wl();Sl()});var Al={};v(Al,{jqCommand:()=>Ym});function Yt(t,e,r,n,s,i=0){if(t===null||t===void 0)return"null";if(typeof t=="boolean")return String(t);if(typeof t=="number")return Number.isFinite(t)?String(t):"null";if(typeof t=="string")return r?t:JSON.stringify(t);let o=s?" ":" ";if(Array.isArray(t))return t.length===0?"[]":e?`[${t.map(l=>Yt(l,!0,!1,n,s)).join(",")}]`:`[
455
- ${t.map(l=>o.repeat(i+1)+Yt(l,!1,!1,n,s,i+1)).join(`,
454
+ `;)s();continue}if(u==="."&&n()==="."){s(),e.push({type:"DOTDOT",pos:c});continue}if(u==="="&&n()==="="){s(),e.push({type:"EQ",pos:c});continue}if(u==="!"&&n()==="="){s(),e.push({type:"NE",pos:c});continue}if(u==="<"&&n()==="="){s(),e.push({type:"LE",pos:c});continue}if(u===">"&&n()==="="){s(),e.push({type:"GE",pos:c});continue}if(u==="/"&&n()==="/"){s(),n()==="="?(s(),e.push({type:"UPDATE_ALT",pos:c})):e.push({type:"ALT",pos:c});continue}if(u==="+"&&n()==="="){s(),e.push({type:"UPDATE_ADD",pos:c});continue}if(u==="-"&&n()==="="){s(),e.push({type:"UPDATE_SUB",pos:c});continue}if(u==="*"&&n()==="="){s(),e.push({type:"UPDATE_MUL",pos:c});continue}if(u==="/"&&n()==="="){s(),e.push({type:"UPDATE_DIV",pos:c});continue}if(u==="%"&&n()==="="){s(),e.push({type:"UPDATE_MOD",pos:c});continue}if(u==="="&&n()!=="="){e.push({type:"ASSIGN",pos:c});continue}if(u==="."){e.push({type:"DOT",pos:c});continue}if(u==="|"){n()==="="?(s(),e.push({type:"UPDATE_PIPE",pos:c})):e.push({type:"PIPE",pos:c});continue}if(u===","){e.push({type:"COMMA",pos:c});continue}if(u===":"){e.push({type:"COLON",pos:c});continue}if(u===";"){e.push({type:"SEMICOLON",pos:c});continue}if(u==="("){e.push({type:"LPAREN",pos:c});continue}if(u===")"){e.push({type:"RPAREN",pos:c});continue}if(u==="["){e.push({type:"LBRACKET",pos:c});continue}if(u==="]"){e.push({type:"RBRACKET",pos:c});continue}if(u==="{"){e.push({type:"LBRACE",pos:c});continue}if(u==="}"){e.push({type:"RBRACE",pos:c});continue}if(u==="?"){e.push({type:"QUESTION",pos:c});continue}if(u==="+"){e.push({type:"PLUS",pos:c});continue}if(u==="-"){if(o(n())){let f=u;for(;!i()&&(o(n())||n()===".");)f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}e.push({type:"MINUS",pos:c});continue}if(u==="*"){e.push({type:"STAR",pos:c});continue}if(u==="/"){e.push({type:"SLASH",pos:c});continue}if(u==="%"){e.push({type:"PERCENT",pos:c});continue}if(u==="<"){e.push({type:"LT",pos:c});continue}if(u===">"){e.push({type:"GT",pos:c});continue}if(o(u)){let f=u;for(;!i()&&(o(n())||n()==="."||n()==="e"||n()==="E");)(n()==="e"||n()==="E")&&(t[r+1]==="+"||t[r+1]==="-")&&(f+=s()),f+=s();e.push({type:"NUMBER",value:Number(f),pos:c});continue}if(u==='"'){let f="";for(;!i()&&n()!=='"';)if(n()==="\\"){if(s(),i())break;let p=s();switch(p){case"n":f+=`
455
+ `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=p}}else f+=s();i()||s(),e.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(n());)f+=s();let p=i0[f];p?e.push({type:p,pos:c}):e.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return e.push({type:"EOF",pos:r}),e}function $l(t){let e=vl(t);return new ms(e).parse()}var i0,ms,Rl=C(()=>{"use strict";i0={and:"AND",or:"OR",not:"NOT",if:"IF",then:"THEN",elif:"ELIF",else:"ELSE",end:"END",as:"AS",try:"TRY",catch:"CATCH",true:"TRUE",false:"FALSE",null:"NULL",reduce:"REDUCE",foreach:"FOREACH"};ms=class t{tokens;pos=0;constructor(e){this.tokens=e}peek(e=0){return this.tokens[this.pos+e]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(e){return this.peek().type===e}match(...e){for(let r of e)if(this.check(r))return this.advance();return null}expect(e,r){if(!this.check(e))throw new Error(`${r} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let e=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return e}parseExpr(){return this.parsePipe()}parsePipe(){let e=this.parseComma();for(;this.match("PIPE");){let r=this.parseComma();e={type:"Pipe",left:e,right:r}}return e}parseComma(){let e=this.parseVarBind();for(;this.match("COMMA");){let r=this.parseVarBind();e={type:"Comma",left:e,right:r}}return e}parseVarBind(){let e=this.parseUpdate();if(this.match("AS")){let r=this.expect("IDENT","Expected variable name after 'as'"),n=r.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return{type:"VarBind",name:n,value:e,body:s}}return e}parseUpdate(){let e=this.parseAlt(),r={ASSIGN:"=",UPDATE_ADD:"+=",UPDATE_SUB:"-=",UPDATE_MUL:"*=",UPDATE_DIV:"/=",UPDATE_MOD:"%=",UPDATE_ALT:"//=",UPDATE_PIPE:"|="},n=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(n){let s=this.parseVarBind();return{type:"UpdateOp",op:r[n.type],path:e,value:s}}return e}parseAlt(){let e=this.parseOr();for(;this.match("ALT");){let r=this.parseOr();e={type:"BinaryOp",op:"//",left:e,right:r}}return e}parseOr(){let e=this.parseAnd();for(;this.match("OR");){let r=this.parseAnd();e={type:"BinaryOp",op:"or",left:e,right:r}}return e}parseAnd(){let e=this.parseNot();for(;this.match("AND");){let r=this.parseNot();e={type:"BinaryOp",op:"and",left:e,right:r}}return e}parseNot(){return this.parseComparison()}parseComparison(){let e=this.parseAddSub(),r={EQ:"==",NE:"!=",LT:"<",LE:"<=",GT:">",GE:">="},n=this.match("EQ","NE","LT","LE","GT","GE");if(n){let s=this.parseAddSub();e={type:"BinaryOp",op:r[n.type],left:e,right:s}}return e}parseAddSub(){let e=this.parseMulDiv();for(;;)if(this.match("PLUS")){let r=this.parseMulDiv();e={type:"BinaryOp",op:"+",left:e,right:r}}else if(this.match("MINUS")){let r=this.parseMulDiv();e={type:"BinaryOp",op:"-",left:e,right:r}}else break;return e}parseMulDiv(){let e=this.parseUnary();for(;;)if(this.match("STAR")){let r=this.parseUnary();e={type:"BinaryOp",op:"*",left:e,right:r}}else if(this.match("SLASH")){let r=this.parseUnary();e={type:"BinaryOp",op:"/",left:e,right:r}}else if(this.match("PERCENT")){let r=this.parseUnary();e={type:"BinaryOp",op:"%",left:e,right:r}}else break;return e}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let e=this.parsePrimary();for(;;)if(this.match("QUESTION"))e={type:"Optional",expr:e};else if(this.check("DOT")&&this.peek(1).type==="IDENT")this.advance(),e={type:"Field",name:this.expect("IDENT","Expected field name").value,base:e};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))e={type:"Iterate",base:e};else if(this.check("COLON")){this.advance();let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",end:r,base:e}}else{let r=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),e={type:"Slice",start:r,end:n,base:e}}else this.expect("RBRACKET","Expected ']'"),e={type:"Index",index:r,base:e}}else break;return e}parsePrimary(){if(this.match("DOTDOT"))return{type:"Recurse"};if(this.match("DOT")){if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let r=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:r}}let e=this.parseExpr();if(this.match("COLON")){let r=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:e,end:r}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:e}}return this.check("IDENT")?{type:"Field",name:this.advance().value}:{type:"Identity"}}if(this.match("TRUE"))return{type:"Literal",value:!0};if(this.match("FALSE"))return{type:"Literal",value:!1};if(this.match("NULL"))return{type:"Literal",value:null};if(this.check("NUMBER"))return{type:"Literal",value:this.advance().value};if(this.check("STRING")){let r=this.advance().value;return r.includes("\\(")?this.parseStringInterpolation(r):{type:"Literal",value:r}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let e=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:e}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let e=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:e}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let e=this.parsePostfix(),r;return this.match("CATCH")&&(r=this.parsePostfix()),{type:"Try",body:e,catch:r}}if(this.match("REDUCE")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after reduce expression");let r=this.expect("IDENT","Expected variable name"),n=r.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr();return this.expect("RPAREN","Expected ')' after update expression"),{type:"Reduce",expr:e,varName:n,init:s,update:i}}if(this.match("FOREACH")){let e=this.parsePostfix();this.expect("AS","Expected 'as' after foreach expression");let r=this.expect("IDENT","Expected variable name"),n=r.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${r.pos}`);this.expect("LPAREN","Expected '(' after variable");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let i=this.parseExpr(),o;return this.match("SEMICOLON")&&(o=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions"),{type:"Foreach",expr:e,varName:n,init:s,update:i,extract:o}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let r=this.advance().value;if(r.startsWith("$"))return{type:"VarRef",name:r};if(this.match("LPAREN")){let n=[];if(!this.check("RPAREN"))for(n.push(this.parseExpr());this.match("SEMICOLON");)n.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:r,args:n}}return{type:"Call",name:r,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let e=[];if(!this.check("RBRACE"))do{let r,n;if(this.match("LPAREN"))r=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else if(this.check("IDENT")){let s=this.advance().value;this.match("COLON")?(r=s,n=this.parseObjectValue()):(r=s,n={type:"Field",name:s})}else if(this.check("STRING"))r=this.advance().value,this.expect("COLON","Expected ':'"),n=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);e.push({key:r,value:n})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:e}}parseObjectValue(){let e=this.parseVarBind();for(;this.match("PIPE");){let r=this.parseVarBind();e={type:"Pipe",left:e,right:r}}return e}parseIf(){let e=this.parseExpr();this.expect("THEN","Expected 'then'");let r=this.parseExpr(),n=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();n.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:e,then:r,elifs:n,else:s}}parseStringInterpolation(e){let r=[],n="",s=0;for(;s<e.length;)if(e[s]==="\\"&&e[s+1]==="("){n&&(r.push(n),n=""),s+=2;let i=1,o="";for(;s<e.length&&i>0;)e[s]==="("?i++:e[s]===")"&&i--,i>0&&(o+=e[s]),s++;let a=vl(o),l=new t(a);r.push(l.parse())}else n+=e[s],s++;return n&&r.push(n),{type:"StringInterp",parts:r}}}});var Pl=C(()=>{"use strict";Il();Rl()});var Fl={};R(Fl,{jqCommand:()=>a0});function cr(t,e,r,n,s,i=0){if(t===null||t===void 0)return"null";if(typeof t=="boolean")return String(t);if(typeof t=="number")return Number.isFinite(t)?String(t):"null";if(typeof t=="string")return r?t:JSON.stringify(t);let o=s?" ":" ";if(Array.isArray(t))return t.length===0?"[]":e?`[${t.map(l=>cr(l,!0,!1,n,s)).join(",")}]`:`[
456
+ ${t.map(l=>o.repeat(i+1)+cr(l,!1,!1,n,s,i+1)).join(`,
456
457
  `)}
457
- ${o.repeat(i)}]`;if(typeof t=="object"){let a=Object.keys(t);return n&&(a=a.sort()),a.length===0?"{}":e?`{${a.map(c=>`${JSON.stringify(c)}:${Yt(t[c],!0,!1,n,s)}`).join(",")}}`:`{
458
- ${a.map(c=>{let u=Yt(t[c],!1,!1,n,s,i+1);return`${o.repeat(i+1)}${JSON.stringify(c)}: ${u}`}).join(`,
458
+ ${o.repeat(i)}]`;if(typeof t=="object"){let a=Object.keys(t);return n&&(a=a.sort()),a.length===0?"{}":e?`{${a.map(c=>`${JSON.stringify(c)}:${cr(t[c],!0,!1,n,s)}`).join(",")}}`:`{
459
+ ${a.map(c=>{let u=cr(t[c],!1,!1,n,s,i+1);return`${o.repeat(i+1)}${JSON.stringify(c)}: ${u}`}).join(`,
459
460
  `)}
460
- ${o.repeat(i)}}`}return String(t)}var Jm,Ym,kl=C(()=>{"use strict";X();O();Cl();Jm={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};Ym={name:"jq",async execute(t,e){if(I(t))return N(Jm);let r=!1,n=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=".",f=!1,d=[];for(let h=0;h<t.length;h++){let y=t[h];if(y==="-r"||y==="--raw-output")r=!0;else if(y==="-c"||y==="--compact-output")n=!0;else if(y==="-e"||y==="--exit-status")s=!0;else if(y==="-s"||y==="--slurp")i=!0;else if(y==="-n"||y==="--null-input")o=!0;else if(y==="-j"||y==="--join-output")a=!0;else if(!(y==="-a"||y==="--ascii")){if(y==="-S"||y==="--sort-keys")l=!0;else if(!(y==="-C"||y==="--color")){if(!(y==="-M"||y==="--monochrome"))if(y==="--tab")c=!0;else if(y==="-")d.push("-");else{if(y.startsWith("--"))return $("jq",y);if(y.startsWith("-")){for(let m of y.slice(1))if(m==="r")r=!0;else if(m==="c")n=!0;else if(m==="e")s=!0;else if(m==="s")i=!0;else if(m==="n")o=!0;else if(m==="j")a=!0;else if(m!=="a"){if(m==="S")l=!0;else if(m!=="C"){if(m!=="M")return $("jq",`-${m}`)}}}else f?d.push(y):(u=y,f=!0)}}}}let p;if(o)p="";else if(d.length===0||d.length===1&&d[0]==="-")p=e.stdin;else try{let h=e.fs.resolvePath(e.cwd,d[0]);p=await e.fs.readFile(h)}catch{return{stdout:"",stderr:`jq: ${d[0]}: No such file or directory
461
- `,exitCode:2}}try{let h=El(u),y,m={limits:e.limits?{maxIterations:e.limits.maxJqIterations}:void 0,env:e.env};if(o)y=k(null,h,m);else if(i){let A=[];for(let F of p.trim().split(`
462
- `))F.trim()&&A.push(JSON.parse(F));y=k(A,h,m)}else{let A=p.trim();if(A.startsWith("{")||A.startsWith("["))y=k(JSON.parse(A),h,m);else{y=[];for(let F of A.split(`
463
- `))F.trim()&&y.push(...k(JSON.parse(F),h,m))}}let w=y.map(A=>Yt(A,n,r,l,c)),b=a?"":`
464
- `,E=w.join(b),S=s&&(y.length===0||y.every(A=>A==null||A===!1))?1:0;return{stdout:E?a?E:`${E}
465
- `:"",stderr:"",exitCode:S}}catch(h){if(h instanceof W)return{stdout:"",stderr:`jq: ${h.message}
466
- `,exitCode:W.EXIT_CODE};let y=h.message;return y.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${y}
467
- `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${y}
468
- `,exitCode:5}}}}});var Il={};v(Il,{base64Command:()=>r0});async function Nl(t,e,r){if(e.length===0||e.length===1&&e[0]==="-")return{ok:!0,data:new TextEncoder().encode(t.stdin)};let n=[];for(let a of e){if(a==="-"){n.push(new TextEncoder().encode(t.stdin));continue}try{let l=t.fs.resolvePath(t.cwd,a),c=await t.fs.readFileBuffer(l);n.push(c)}catch{return{ok:!1,error:{stdout:"",stderr:`${r}: ${a}: No such file or directory
469
- `,exitCode:1}}}}let s=n.reduce((a,l)=>a+l.length,0),i=new Uint8Array(s),o=0;for(let a of n)i.set(a,o),o+=a.length;return{ok:!0,data:i}}var e0,t0,r0,vl=C(()=>{"use strict";ae();O();e0={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},t0={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};r0={name:"base64",async execute(t,e){if(I(t))return N(e0);let r=j("base64",t,t0);if(!r.ok)return r.error;let n=r.result.flags.decode,s=r.result.flags.wrap,i=r.result.positional;try{if(n){let l=await Nl(e,i,"base64");if(!l.ok)return l.error;let u=new TextDecoder().decode(l.data).replace(/\s/g,""),f=Uint8Array.from(atob(u),p=>p.charCodeAt(0));return{stdout:new TextDecoder().decode(f),stderr:"",exitCode:0}}let o=await Nl(e,i,"base64");if(!o.ok)return o.error;let a=btoa(String.fromCharCode(...o.data));if(s>0){let l=[];for(let c=0;c<a.length;c+=s)l.push(a.slice(c,c+s));a=l.join(`
461
+ ${o.repeat(i)}}`}return String(t)}var o0,a0,Ol=C(()=>{"use strict";oe();gt();L();Pl();o0={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};a0={name:"jq",async execute(t,e){if(N(t))return k(o0);let r=!1,n=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=".",f=!1,p=[];for(let h=0;h<t.length;h++){let m=t[h];if(m==="-r"||m==="--raw-output")r=!0;else if(m==="-c"||m==="--compact-output")n=!0;else if(m==="-e"||m==="--exit-status")s=!0;else if(m==="-s"||m==="--slurp")i=!0;else if(m==="-n"||m==="--null-input")o=!0;else if(m==="-j"||m==="--join-output")a=!0;else if(!(m==="-a"||m==="--ascii")){if(m==="-S"||m==="--sort-keys")l=!0;else if(!(m==="-C"||m==="--color")){if(!(m==="-M"||m==="--monochrome"))if(m==="--tab")c=!0;else if(m==="-")p.push("-");else{if(m.startsWith("--"))return P("jq",m);if(m.startsWith("-")){for(let g of m.slice(1))if(g==="r")r=!0;else if(g==="c")n=!0;else if(g==="e")s=!0;else if(g==="s")i=!0;else if(g==="n")o=!0;else if(g==="j")a=!0;else if(g!=="a"){if(g==="S")l=!0;else if(g!=="C"){if(g!=="M")return P("jq",`-${g}`)}}}else f?p.push(m):(u=m,f=!0)}}}}let d=[];if(!o)if(p.length===0||p.length===1&&p[0]==="-")d.push({source:"stdin",content:e.stdin});else{let h=await mt(e,p,{cmdName:"jq",stopOnError:!0});if(h.exitCode!==0)return{stdout:"",stderr:h.stderr,exitCode:2};d=h.files.map(m=>({source:m.filename||"stdin",content:m.content}))}try{let h=$l(u),m=[],g={limits:e.limits?{maxIterations:e.limits.maxJqIterations}:void 0,env:e.env};if(o)m=A(null,h,g);else if(i){let v=[];for(let{content:D}of d)for(let I of D.trim().split(`
462
+ `))I.trim()&&v.push(JSON.parse(I));m=A(v,h,g)}else{let v=D=>{for(let I of D.split(`
463
+ `))I.trim()&&m.push(...A(JSON.parse(I),h,g))};for(let{content:D}of d){let I=D.trim();if(I)if(I.startsWith("{")||I.startsWith("["))try{m.push(...A(JSON.parse(I),h,g))}catch{v(I)}else v(I)}}let w=m.map(v=>cr(v,n,r,l,c)),b=a?"":`
464
+ `,E=w.join(b),S=s&&(m.length===0||m.every(v=>v==null||v===!1))?1:0;return{stdout:E?a?E:`${E}
465
+ `:"",stderr:"",exitCode:S}}catch(h){if(h instanceof j)return{stdout:"",stderr:`jq: ${h.message}
466
+ `,exitCode:j.EXIT_CODE};let m=h.message;return m.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${m}
467
+ `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${m}
468
+ `,exitCode:5}}}}});var Dl={};R(Dl,{base64Command:()=>u0});async function Tl(t,e,r){if(e.length===0||e.length===1&&e[0]==="-")return{ok:!0,data:new TextEncoder().encode(t.stdin)};let n=[];for(let a of e){if(a==="-"){n.push(new TextEncoder().encode(t.stdin));continue}try{let l=t.fs.resolvePath(t.cwd,a),c=await t.fs.readFileBuffer(l);n.push(c)}catch{return{ok:!1,error:{stdout:"",stderr:`${r}: ${a}: No such file or directory
469
+ `,exitCode:1}}}}let s=n.reduce((a,l)=>a+l.length,0),i=new Uint8Array(s),o=0;for(let a of n)i.set(a,o),o+=a.length;return{ok:!0,data:i}}var l0,c0,u0,Ll=C(()=>{"use strict";ye();L();l0={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},c0={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};u0={name:"base64",async execute(t,e){if(N(t))return k(l0);let r=z("base64",t,c0);if(!r.ok)return r.error;let n=r.result.flags.decode,s=r.result.flags.wrap,i=r.result.positional;try{if(n){let l=await Tl(e,i,"base64");if(!l.ok)return l.error;let u=new TextDecoder().decode(l.data).replace(/\s/g,""),f=Uint8Array.from(atob(u),d=>d.charCodeAt(0));return{stdout:new TextDecoder().decode(f),stderr:"",exitCode:0}}let o=await Tl(e,i,"base64");if(!o.ok)return o.error;let a=btoa(String.fromCharCode(...o.data));if(s>0){let l=[];for(let c=0;c<a.length;c+=s)l.push(a.slice(c,c+s));a=l.join(`
470
470
  `)+(a.length>0?`
471
471
  `:"")}return{stdout:a,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`base64: invalid input
472
- `,exitCode:1}}}}});var Rl={};v(Rl,{diffCommand:()=>i0});import*as $l from"diff";var n0,s0,i0,Pl=C(()=>{"use strict";ae();O();n0={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},s0={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},i0={name:"diff",async execute(t,e){if(I(t))return N(n0);let r=j("diff",t,s0);if(!r.ok)return r.error;let n=r.result.flags.brief,s=r.result.flags.reportSame,i=r.result.flags.ignoreCase,o=r.result.positional;if(r.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
472
+ `,exitCode:1}}}}});var _l={};R(_l,{diffCommand:()=>d0});import*as Ml from"diff";var f0,p0,d0,Bl=C(()=>{"use strict";ye();L();f0={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},p0={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},d0={name:"diff",async execute(t,e){if(N(t))return k(f0);let r=z("diff",t,p0);if(!r.ok)return r.error;let n=r.result.flags.brief,s=r.result.flags.reportSame,i=r.result.flags.ignoreCase,o=r.result.positional;if(r.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
473
473
  `,exitCode:2};let a,l,[c,u]=o;try{a=c==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory
474
474
  `,exitCode:2}}try{l=u==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
475
- `,exitCode:2}}let f=a,d=l;return i&&(f=f.toLowerCase(),d=d.toLowerCase()),f===d?s?{stdout:`Files ${c} and ${u} are identical
475
+ `,exitCode:2}}let f=a,p=l;return i&&(f=f.toLowerCase(),p=p.toLowerCase()),f===p?s?{stdout:`Files ${c} and ${u} are identical
476
476
  `,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:n?{stdout:`Files ${c} and ${u} differ
477
- `,stderr:"",exitCode:1}:{stdout:$l.createTwoFilesPatch(c,u,a,l,"","",{context:3}),stderr:"",exitCode:1}}}});var Ol={};v(Ol,{dateCommand:()=>f0});function ye(t,e=2){return String(t).padStart(e,"0")}function c0(t){let e=-t.getTimezoneOffset();return`${e>=0?"+":"-"}${ye(Math.floor(Math.abs(e)/60))}${ye(Math.abs(e)%60)}`}function Mr(t,e,r){let n=r?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},s="",i=0;for(;i<e.length;){if(e[i]==="%"&&i+1<e.length){let o=e[++i];switch(o){case"%":s+="%";break;case"a":s+=a0[n.w];break;case"b":case"h":s+=l0[n.m];break;case"d":s+=ye(n.D);break;case"e":s+=String(n.D).padStart(2," ");break;case"F":s+=`${n.Y}-${ye(n.m+1)}-${ye(n.D)}`;break;case"H":s+=ye(n.H);break;case"I":s+=ye(n.H%12||12);break;case"m":s+=ye(n.m+1);break;case"M":s+=ye(n.M);break;case"n":s+=`
478
- `;break;case"p":s+=n.H<12?"AM":"PM";break;case"P":s+=n.H<12?"am":"pm";break;case"R":s+=`${ye(n.H)}:${ye(n.M)}`;break;case"s":s+=Math.floor(t.getTime()/1e3);break;case"S":s+=ye(n.S);break;case"t":s+=" ";break;case"T":s+=`${ye(n.H)}:${ye(n.M)}:${ye(n.S)}`;break;case"u":s+=n.w||7;break;case"w":s+=n.w;break;case"y":s+=ye(n.Y%100);break;case"Y":s+=n.Y;break;case"z":s+=r?"+0000":c0(t);break;case"Z":s+=r?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:s+=`%${o}`}}else s+=e[i];i++}return s}function u0(t){let e=new Date(t);if(!Number.isNaN(e.getTime()))return e;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let r=t.toLowerCase();return r==="now"||r==="today"?new Date:r==="yesterday"?new Date(Date.now()-864e5):r==="tomorrow"?new Date(Date.now()+864e5):null}var o0,a0,l0,f0,Fl=C(()=>{"use strict";O();o0={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},a0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];f0={name:"date",async execute(t,e){if(I(t))return N(o0);let r=!1,n=null,s=null,i=!1,o=!1;for(let c=0;c<t.length;c++){let u=t[c];if(u==="-u"||u==="--utc")r=!0;else if(u==="-d"||u==="--date")n=t[++c]??"";else if(u.startsWith("--date="))n=u.slice(7);else if(u==="-I"||u==="--iso-8601")i=!0;else if(u==="-R"||u==="--rfc-email")o=!0;else if(u.startsWith("+"))s=u.slice(1);else{if(u.startsWith("--"))return $("date",u);if(u.startsWith("-"))for(let f of u.slice(1))if(f==="u")r=!0;else if(f==="I")i=!0;else if(f==="R")o=!0;else return $("date",`-${f}`)}}let a=n!==null?u0(n):new Date;if(!a)return{stdout:"",stderr:`date: invalid date '${n}'
479
- `,exitCode:1};let l;return s?l=Mr(a,s,r):i?l=Mr(a,"%Y-%m-%dT%H:%M:%S%z",r):o?l=Mr(a,"%a, %d %b %Y %H:%M:%S %z",r):l=Mr(a,"%a %b %e %H:%M:%S %Z %Y",r),{stdout:`${l}
480
- `,stderr:"",exitCode:0}}}});var Tl={};v(Tl,{sleepCommand:()=>h0});function p0(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let r=parseFloat(e[1]);switch(e[2]||"s"){case"s":return r*1e3;case"m":return r*60*1e3;case"h":return r*60*60*1e3;case"d":return r*24*60*60*1e3;default:return null}}var d0,h0,Ll=C(()=>{"use strict";O();d0={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
477
+ `,stderr:"",exitCode:1}:{stdout:Ml.createTwoFilesPatch(c,u,a,l,"","",{context:3}),stderr:"",exitCode:1}}}});var Wl={};R(Wl,{dateCommand:()=>w0});function Ie(t,e=2){return String(t).padStart(e,"0")}function y0(t){let e=-t.getTimezoneOffset();return`${e>=0?"+":"-"}${Ie(Math.floor(Math.abs(e)/60))}${Ie(Math.abs(e)%60)}`}function Vr(t,e,r){let n=r?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},s="",i=0;for(;i<e.length;){if(e[i]==="%"&&i+1<e.length){let o=e[++i];switch(o){case"%":s+="%";break;case"a":s+=m0[n.w];break;case"b":case"h":s+=g0[n.m];break;case"d":s+=Ie(n.D);break;case"e":s+=String(n.D).padStart(2," ");break;case"F":s+=`${n.Y}-${Ie(n.m+1)}-${Ie(n.D)}`;break;case"H":s+=Ie(n.H);break;case"I":s+=Ie(n.H%12||12);break;case"m":s+=Ie(n.m+1);break;case"M":s+=Ie(n.M);break;case"n":s+=`
478
+ `;break;case"p":s+=n.H<12?"AM":"PM";break;case"P":s+=n.H<12?"am":"pm";break;case"R":s+=`${Ie(n.H)}:${Ie(n.M)}`;break;case"s":s+=Math.floor(t.getTime()/1e3);break;case"S":s+=Ie(n.S);break;case"t":s+=" ";break;case"T":s+=`${Ie(n.H)}:${Ie(n.M)}:${Ie(n.S)}`;break;case"u":s+=n.w||7;break;case"w":s+=n.w;break;case"y":s+=Ie(n.Y%100);break;case"Y":s+=n.Y;break;case"z":s+=r?"+0000":y0(t);break;case"Z":s+=r?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:s+=`%${o}`}}else s+=e[i];i++}return s}function x0(t){let e=new Date(t);if(!Number.isNaN(e.getTime()))return e;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let r=t.toLowerCase();return r==="now"||r==="today"?new Date:r==="yesterday"?new Date(Date.now()-864e5):r==="tomorrow"?new Date(Date.now()+864e5):null}var h0,m0,g0,w0,Ul=C(()=>{"use strict";L();h0={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},m0=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],g0=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];w0={name:"date",async execute(t,e){if(N(t))return k(h0);let r=!1,n=null,s=null,i=!1,o=!1;for(let c=0;c<t.length;c++){let u=t[c];if(u==="-u"||u==="--utc")r=!0;else if(u==="-d"||u==="--date")n=t[++c]??"";else if(u.startsWith("--date="))n=u.slice(7);else if(u==="-I"||u==="--iso-8601")i=!0;else if(u==="-R"||u==="--rfc-email")o=!0;else if(u.startsWith("+"))s=u.slice(1);else{if(u.startsWith("--"))return P("date",u);if(u.startsWith("-"))for(let f of u.slice(1))if(f==="u")r=!0;else if(f==="I")i=!0;else if(f==="R")o=!0;else return P("date",`-${f}`)}}let a=n!==null?x0(n):new Date;if(!a)return{stdout:"",stderr:`date: invalid date '${n}'
479
+ `,exitCode:1};let l;return s?l=Vr(a,s,r):i?l=Vr(a,"%Y-%m-%dT%H:%M:%S%z",r):o?l=Vr(a,"%a, %d %b %Y %H:%M:%S %z",r):l=Vr(a,"%a %b %e %H:%M:%S %Z %Y",r),{stdout:`${l}
480
+ `,stderr:"",exitCode:0}}}});var jl={};R(jl,{sleepCommand:()=>S0});function E0(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let r=parseFloat(e[1]);switch(e[2]||"s"){case"s":return r*1e3;case"m":return r*60*1e3;case"h":return r*60*60*1e3;case"d":return r*24*60*60*1e3;default:return null}}var b0,S0,zl=C(()=>{"use strict";L();b0={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
481
481
  s - seconds (default)
482
482
  m - minutes
483
483
  h - hours
484
484
  d - days
485
485
 
486
- NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};h0={name:"sleep",async execute(t,e){if(I(t))return N(d0);if(t.length===0)return{stdout:"",stderr:`sleep: missing operand
487
- `,exitCode:1};let r=0;for(let n of t){let s=p0(n);if(s===null)return{stdout:"",stderr:`sleep: invalid time interval '${n}'
488
- `,exitCode:1};r+=s}return e.sleep?await e.sleep(r):await new Promise(n=>setTimeout(n,r)),{stdout:"",stderr:"",exitCode:0}}}});var Dl={};v(Dl,{timeoutCommand:()=>y0});function g0(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let r=parseFloat(e[1]);switch(e[2]||"s"){case"s":return r*1e3;case"m":return r*60*1e3;case"h":return r*60*60*1e3;case"d":return r*24*60*60*1e3;default:return null}}var m0,y0,Ml=C(()=>{"use strict";O();m0={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
486
+ NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};S0={name:"sleep",async execute(t,e){if(N(t))return k(b0);if(t.length===0)return{stdout:"",stderr:`sleep: missing operand
487
+ `,exitCode:1};let r=0;for(let n of t){let s=E0(n);if(s===null)return{stdout:"",stderr:`sleep: invalid time interval '${n}'
488
+ `,exitCode:1};r+=s}return e.sleep?await e.sleep(r):await new Promise(n=>setTimeout(n,r)),{stdout:"",stderr:"",exitCode:0}}}});var Hl={};R(Hl,{timeoutCommand:()=>k0});function A0(t){let e=t.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!e)return null;let r=parseFloat(e[1]);switch(e[2]||"s"){case"s":return r*1e3;case"m":return r*60*1e3;case"h":return r*60*60*1e3;case"d":return r*24*60*60*1e3;default:return null}}var C0,k0,Gl=C(()=>{"use strict";L();C0={name:"timeout",summary:"run a command with a time limit",usage:"timeout [OPTION] DURATION COMMAND [ARG]...",description:`Start COMMAND, and kill it if still running after DURATION.
489
489
 
490
490
  DURATION is a number with optional suffix:
491
491
  s - seconds (default)
492
492
  m - minutes
493
493
  h - hours
494
- d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]};y0={name:"timeout",async execute(t,e){if(I(t))return N(m0);let r=!1,n=0;for(let d=0;d<t.length;d++){let p=t[d];if(p==="--preserve-status")r=!0,n=d+1;else if(p==="--foreground")n=d+1;else if(p==="-k"||p==="--kill-after")d++,n=d+1;else if(p.startsWith("--kill-after="))n=d+1;else if(p==="-s"||p==="--signal")d++,n=d+1;else if(p.startsWith("--signal="))n=d+1;else{if(p.startsWith("--")&&p!=="--")return $("timeout",p);if(p.startsWith("-")&&p.length>1&&p!=="--")if(p.startsWith("-k"))n=d+1;else if(p.startsWith("-s"))n=d+1;else return $("timeout",p);else{n=d;break}}}let s=t.slice(n);if(s.length===0)return{stdout:"",stderr:`timeout: missing operand
495
- `,exitCode:1};let i=s[0],o=g0(i);if(o===null)return{stdout:"",stderr:`timeout: invalid time interval '${i}'
494
+ d - days`,options:["-k, --kill-after=DURATION send KILL signal after DURATION if still running","-s, --signal=SIGNAL specify signal to send (default: TERM)"," --preserve-status exit with same status as COMMAND, even on timeout"," --foreground run command in foreground"," --help display this help and exit"]};k0={name:"timeout",async execute(t,e){if(N(t))return k(C0);let r=!1,n=0;for(let p=0;p<t.length;p++){let d=t[p];if(d==="--preserve-status")r=!0,n=p+1;else if(d==="--foreground")n=p+1;else if(d==="-k"||d==="--kill-after")p++,n=p+1;else if(d.startsWith("--kill-after="))n=p+1;else if(d==="-s"||d==="--signal")p++,n=p+1;else if(d.startsWith("--signal="))n=p+1;else{if(d.startsWith("--")&&d!=="--")return P("timeout",d);if(d.startsWith("-")&&d.length>1&&d!=="--")if(d.startsWith("-k"))n=p+1;else if(d.startsWith("-s"))n=p+1;else return P("timeout",d);else{n=p;break}}}let s=t.slice(n);if(s.length===0)return{stdout:"",stderr:`timeout: missing operand
495
+ `,exitCode:1};let i=s[0],o=A0(i);if(o===null)return{stdout:"",stderr:`timeout: invalid time interval '${i}'
496
496
  `,exitCode:1};let a=s.slice(1);if(a.length===0)return{stdout:"",stderr:`timeout: missing operand
497
497
  `,exitCode:1};if(!e.exec)return{stdout:"",stderr:`timeout: exec not available
498
- `,exitCode:1};let l=a.map(d=>d.includes(" ")||d.includes(" ")?`'${d.replace(/'/g,"'\\''")}'`:d).join(" "),c=new Promise(d=>{setTimeout(()=>d({timedOut:!0}),o)}),u=e.exec(l,{cwd:e.cwd}).then(d=>({timedOut:!1,result:d})),f=await Promise.race([c,u]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}}});var _l={};v(_l,{seqCommand:()=>x0});var x0,Bl=C(()=>{"use strict";x0={name:"seq",async execute(t){let e=`
498
+ `,exitCode:1};let l=a.map(p=>p.includes(" ")||p.includes(" ")?`'${p.replace(/'/g,"'\\''")}'`:p).join(" "),c=new Promise(p=>{setTimeout(()=>p({timedOut:!0}),o)}),u=e.exec(l,{cwd:e.cwd}).then(p=>({timedOut:!1,result:p})),f=await Promise.race([c,u]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}}});var ql={};R(ql,{seqCommand:()=>N0});var N0,Vl=C(()=>{"use strict";N0={name:"seq",async execute(t){let e=`
499
499
  `,r=!1,n=[],s=0;for(;s<t.length;){let h=t[s];if(h==="-s"&&s+1<t.length){e=t[s+1],s+=2;continue}if(h==="-w"){r=!0,s++;continue}if(h==="--"){s++;break}if(h.startsWith("-")&&h!=="-"){if(h.startsWith("-s")&&h.length>2){e=h.slice(2),s++;continue}if((h==="-ws"||h==="-sw")&&(r=!0,s+1<t.length)){e=t[s+1],s+=2;continue}}n.push(h),s++}for(;s<t.length;)n.push(t[s]),s++;if(n.length===0)return{stdout:"",stderr:`seq: missing operand
500
- `,exitCode:1};let i=1,o=1,a;if(n.length===1?a=parseFloat(n[0]):n.length===2?(i=parseFloat(n[0]),a=parseFloat(n[1])):(i=parseFloat(n[0]),o=parseFloat(n[1]),a=parseFloat(n[2])),Number.isNaN(i)||Number.isNaN(o)||Number.isNaN(a))return{stdout:"",stderr:`seq: invalid floating point argument: '${n.find(y=>Number.isNaN(parseFloat(y)))}'
500
+ `,exitCode:1};let i=1,o=1,a;if(n.length===1?a=parseFloat(n[0]):n.length===2?(i=parseFloat(n[0]),a=parseFloat(n[1])):(i=parseFloat(n[0]),o=parseFloat(n[1]),a=parseFloat(n[2])),Number.isNaN(i)||Number.isNaN(o)||Number.isNaN(a))return{stdout:"",stderr:`seq: invalid floating point argument: '${n.find(m=>Number.isNaN(parseFloat(m)))}'
501
501
  `,exitCode:1};if(o===0)return{stdout:"",stderr:`seq: invalid Zero increment value: '0'
502
- `,exitCode:1};let l=[],c=h=>{let y=String(h),m=y.indexOf(".");return m===-1?0:y.length-m-1},u=Math.max(c(i),c(o),c(a)),f=1e5,d=0;if(o>0)for(let h=i;h<=a+1e-10&&!(d++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));else for(let h=i;h>=a-1e-10&&!(d++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));if(r&&l.length>0){let h=Math.max(...l.map(y=>y.replace("-","").length));for(let y=0;y<l.length;y++){let m=l[y].startsWith("-"),b=(m?l[y].slice(1):l[y]).padStart(h,"0");l[y]=m?`-${b}`:b}}let p=l.join(e);return{stdout:p?`${p}
503
- `:"",stderr:"",exitCode:0}}}});var Wl={};v(Wl,{exprCommand:()=>w0});function b0(t){if(t.length===1)return t[0];let e=0;function r(){let c=n();for(;e<t.length&&t[e]==="|";){e++;let u=n();if(c!=="0"&&c!=="")return c;c=u}return c}function n(){let c=s();for(;e<t.length&&t[e]==="&";){e++;let u=s();(c==="0"||c===""||u==="0"||u==="")&&(c="0")}return c}function s(){let c=i();for(;e<t.length;){let u=t[e];if(["=","!=","<",">","<=",">="].includes(u)){e++;let f=i(),d=parseInt(c,10),p=parseInt(f,10),h=!Number.isNaN(d)&&!Number.isNaN(p),y;u==="="?y=h?d===p:c===f:u==="!="?y=h?d!==p:c!==f:u==="<"?y=h?d<p:c<f:u===">"?y=h?d>p:c>f:u==="<="?y=h?d<=p:c<=f:y=h?d>=p:c>=f,c=y?"1":"0"}else break}return c}function i(){let c=o();for(;e<t.length;){let u=t[e];if(u==="+"||u==="-"){e++;let f=o(),d=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(d)||Number.isNaN(p))throw new Error("non-integer argument");c=String(u==="+"?d+p:d-p)}else break}return c}function o(){let c=a();for(;e<t.length;){let u=t[e];if(u==="*"||u==="/"||u==="%"){e++;let f=a(),d=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(d)||Number.isNaN(p))throw new Error("non-integer argument");if((u==="/"||u==="%")&&p===0)throw new Error("division by zero");u==="*"?c=String(d*p):u==="/"?c=String(Math.trunc(d/p)):c=String(d%p)}else break}return c}function a(){let c=l();for(;e<t.length&&t[e]===":";){e++;let u=l(),f=new RegExp(`^${u}`),d=c.match(f);d?c=d[1]!==void 0?d[1]:String(d[0].length):c="0"}return c}function l(){if(e>=t.length)throw new Error("syntax error");let c=t[e];if(c==="match"){e++;let u=l(),f=l(),d=new RegExp(f),p=u.match(d);return p?p[1]!==void 0?p[1]:String(p[0].length):"0"}if(c==="substr"){e++;let u=l(),f=parseInt(l(),10),d=parseInt(l(),10);if(Number.isNaN(f)||Number.isNaN(d))throw new Error("non-integer argument");return u.substring(f-1,f-1+d)}if(c==="index"){e++;let u=l(),f=l();for(let d=0;d<u.length;d++)if(f.includes(u[d]))return String(d+1);return"0"}if(c==="length"){e++;let u=l();return String(u.length)}if(c==="("){e++;let u=r();if(e>=t.length||t[e]!==")")throw new Error("syntax error");return e++,u}return e++,c}return r()}var w0,Ul=C(()=>{"use strict";w0={name:"expr",async execute(t,e){if(t.length===0)return{stdout:"",stderr:`expr: missing operand
504
- `,exitCode:2};try{let r=b0(t),n=r==="0"||r===""?1:0;return{stdout:`${r}
502
+ `,exitCode:1};let l=[],c=h=>{let m=String(h),g=m.indexOf(".");return g===-1?0:m.length-g-1},u=Math.max(c(i),c(o),c(a)),f=1e5,p=0;if(o>0)for(let h=i;h<=a+1e-10&&!(p++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));else for(let h=i;h>=a-1e-10&&!(p++>f);h+=o)l.push(u>0?h.toFixed(u):String(Math.round(h)));if(r&&l.length>0){let h=Math.max(...l.map(m=>m.replace("-","").length));for(let m=0;m<l.length;m++){let g=l[m].startsWith("-"),b=(g?l[m].slice(1):l[m]).padStart(h,"0");l[m]=g?`-${b}`:b}}let d=l.join(e);return{stdout:d?`${d}
503
+ `:"",stderr:"",exitCode:0}}}});var Kl={};R(Kl,{exprCommand:()=>I0});function v0(t){if(t.length===1)return t[0];let e=0;function r(){let c=n();for(;e<t.length&&t[e]==="|";){e++;let u=n();if(c!=="0"&&c!=="")return c;c=u}return c}function n(){let c=s();for(;e<t.length&&t[e]==="&";){e++;let u=s();(c==="0"||c===""||u==="0"||u==="")&&(c="0")}return c}function s(){let c=i();for(;e<t.length;){let u=t[e];if(["=","!=","<",">","<=",">="].includes(u)){e++;let f=i(),p=parseInt(c,10),d=parseInt(f,10),h=!Number.isNaN(p)&&!Number.isNaN(d),m;u==="="?m=h?p===d:c===f:u==="!="?m=h?p!==d:c!==f:u==="<"?m=h?p<d:c<f:u===">"?m=h?p>d:c>f:u==="<="?m=h?p<=d:c<=f:m=h?p>=d:c>=f,c=m?"1":"0"}else break}return c}function i(){let c=o();for(;e<t.length;){let u=t[e];if(u==="+"||u==="-"){e++;let f=o(),p=parseInt(c,10),d=parseInt(f,10);if(Number.isNaN(p)||Number.isNaN(d))throw new Error("non-integer argument");c=String(u==="+"?p+d:p-d)}else break}return c}function o(){let c=a();for(;e<t.length;){let u=t[e];if(u==="*"||u==="/"||u==="%"){e++;let f=a(),p=parseInt(c,10),d=parseInt(f,10);if(Number.isNaN(p)||Number.isNaN(d))throw new Error("non-integer argument");if((u==="/"||u==="%")&&d===0)throw new Error("division by zero");u==="*"?c=String(p*d):u==="/"?c=String(Math.trunc(p/d)):c=String(p%d)}else break}return c}function a(){let c=l();for(;e<t.length&&t[e]===":";){e++;let u=l(),f=new RegExp(`^${u}`),p=c.match(f);p?c=p[1]!==void 0?p[1]:String(p[0].length):c="0"}return c}function l(){if(e>=t.length)throw new Error("syntax error");let c=t[e];if(c==="match"){e++;let u=l(),f=l(),p=new RegExp(f),d=u.match(p);return d?d[1]!==void 0?d[1]:String(d[0].length):"0"}if(c==="substr"){e++;let u=l(),f=parseInt(l(),10),p=parseInt(l(),10);if(Number.isNaN(f)||Number.isNaN(p))throw new Error("non-integer argument");return u.substring(f-1,f-1+p)}if(c==="index"){e++;let u=l(),f=l();for(let p=0;p<u.length;p++)if(f.includes(u[p]))return String(p+1);return"0"}if(c==="length"){e++;let u=l();return String(u.length)}if(c==="("){e++;let u=r();if(e>=t.length||t[e]!==")")throw new Error("syntax error");return e++,u}return e++,c}return r()}var I0,Zl=C(()=>{"use strict";I0={name:"expr",async execute(t,e){if(t.length===0)return{stdout:"",stderr:`expr: missing operand
504
+ `,exitCode:2};try{let r=v0(t),n=r==="0"||r===""?1:0;return{stdout:`${r}
505
505
  `,stderr:"",exitCode:n}}catch(r){return{stdout:"",stderr:`expr: ${r.message}
506
- `,exitCode:2}}}}});function S0(t){function e(p,h){return p<<h|p>>>32-h}let r=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=t.length*8,i=(t.length%64<56?56:120)-t.length%64,o=new Uint8Array(t.length+i+8);o.set(t),o[t.length]=128;let a=new DataView(o.buffer);a.setUint32(o.length-8,s>>>0,!0),a.setUint32(o.length-4,Math.floor(s/4294967296),!0);let l=1732584193,c=4023233417,u=2562383102,f=271733878;for(let p=0;p<o.length;p+=64){let h=new Uint32Array(16);for(let E=0;E<16;E++)h[E]=a.getUint32(p+E*4,!0);let y=l,m=c,w=u,b=f;for(let E=0;E<64;E++){let S,A;E<16?(S=m&w|~m&b,A=E):E<32?(S=b&m|~b&w,A=(5*E+1)%16):E<48?(S=m^w^b,A=(3*E+5)%16):(S=w^(m|~b),A=7*E%16),S=S+y+r[E]+h[A]>>>0,y=b,b=w,w=m,m=m+e(S,n[E])>>>0}l=l+y>>>0,c=c+m>>>0,u=u+w>>>0,f=f+b>>>0}let d=new Uint8Array(16);return new DataView(d.buffer).setUint32(0,l,!0),new DataView(d.buffer).setUint32(4,c,!0),new DataView(d.buffer).setUint32(8,u,!0),new DataView(d.buffer).setUint32(12,f,!0),Array.from(d).map(p=>p.toString(16).padStart(2,"0")).join("")}async function jl(t,e){if(t==="md5")return S0(e);let r=await globalThis.crypto.subtle.digest(E0[t],new Uint8Array(e).buffer);return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")}function Ft(t,e,r){let n={name:t,summary:r,usage:`${t} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:t,async execute(s,i){if(I(s))return N(n);let o=!1,a=[];for(let f of s)if(f==="-c"||f==="--check")o=!0;else if(!(f==="-b"||f==="-t"||f==="--binary"||f==="--text")){if(f.startsWith("-")&&f!=="-")return $(t,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return new TextEncoder().encode(i.stdin);try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,d="";for(let p of a){let h=p==="-"?i.stdin:await i.fs.readFile(i.fs.resolvePath(i.cwd,p)).catch(()=>null);if(h===null)return{stdout:"",stderr:`${t}: ${p}: No such file or directory
507
- `,exitCode:1};for(let y of h.split(`
508
- `)){let m=y.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!m)continue;let[,w,b]=m,E=await l(b);if(E===null){d+=`${b}: FAILED open or read
509
- `,f++;continue}let S=await jl(e,E)===w.toLowerCase();d+=`${b}: ${S?"OK":"FAILED"}
510
- `,S||f++}}return f>0&&(d+=`${t}: WARNING: ${f} computed checksum${f>1?"s":""} did NOT match
511
- `),{stdout:d,stderr:"",exitCode:f>0?1:0}}let c="",u=0;for(let f of a){let d=await l(f);if(d===null){c+=`${t}: ${f}: No such file or directory
512
- `,u=1;continue}c+=`${await jl(e,d)} ${f}
513
- `}return{stdout:c,stderr:"",exitCode:u}}}}var E0,_r=C(()=>{"use strict";O();E0={sha1:"SHA-1",sha256:"SHA-256"}});var zl={};v(zl,{md5sumCommand:()=>C0});var C0,Hl=C(()=>{"use strict";_r();C0=Ft("md5sum","md5","compute MD5 message digest")});var Gl={};v(Gl,{sha1sumCommand:()=>A0});var A0,ql=C(()=>{"use strict";_r();A0=Ft("sha1sum","sha1","compute SHA1 message digest")});var Vl={};v(Vl,{sha256sumCommand:()=>k0});var k0,Kl=C(()=>{"use strict";_r();k0=Ft("sha256sum","sha256","compute SHA256 message digest")});var Zl=mr(ls=>{ls.read=function(t,e,r,n,s){var i,o,a=s*8-n-1,l=(1<<a)-1,c=l>>1,u=-7,f=r?s-1:0,d=r?-1:1,p=t[e+f];for(f+=d,i=p&(1<<-u)-1,p>>=-u,u+=a;u>0;i=i*256+t[e+f],f+=d,u-=8);for(o=i&(1<<-u)-1,i>>=-u,u+=n;u>0;o=o*256+t[e+f],f+=d,u-=8);if(i===0)i=1-c;else{if(i===l)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,n),i=i-c}return(p?-1:1)*o*Math.pow(2,i-n)};ls.write=function(t,e,r,n,s,i){var o,a,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,d=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:i-1,h=n?1:-1,y=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?e+=d/l:e+=d*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(e*l-1)*Math.pow(2,s),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;t[r+p]=a&255,p+=h,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;t[r+p]=o&255,p+=h,o/=256,c-=8);t[r+p-h]|=y*128}});function Ql(t,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(t):I0(t);case"utf-16le":return v0(t);case"ascii":return $0(t);case"latin1":case"iso-8859-1":return R0(t);case"windows-1252":return P0(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function I0(t){let e="",r=0;for(;r<t.length;){let n=t[r++];if(n<128)e+=String.fromCharCode(n);else if(n<224){let s=t[r++]&63;e+=String.fromCharCode((n&31)<<6|s)}else if(n<240){let s=t[r++]&63,i=t[r++]&63;e+=String.fromCharCode((n&15)<<12|s<<6|i)}else{let s=t[r++]&63,i=t[r++]&63,o=t[r++]&63,a=(n&7)<<18|s<<12|i<<6|o;a-=65536,e+=String.fromCharCode(55296+(a>>10&1023),56320+(a&1023))}}return e}function v0(t){let e="";for(let r=0;r<t.length;r+=2)e+=String.fromCharCode(t[r]|t[r+1]<<8);return e}function $0(t){return String.fromCharCode(...t.map(e=>e&127))}function R0(t){return String.fromCharCode(...t)}function P0(t){let e="";for(let r of t)r>=128&&r<=159&&cs[r]?e+=cs[r]:e+=String.fromCharCode(r);return e}var cs,N0,Xl=C(()=>{cs={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},N0={};for(let[t,e]of Object.entries(cs))N0[e]=Number.parseInt(t)});function be(t){return new DataView(t.buffer,t.byteOffset)}var Jl,Yl,ee,Tt,oe,ec,tc,rc,Ee,er=C(()=>{Jl=Ai(Zl(),1);Xl();Yl={len:1,get(t,e){return be(t).getUint8(e)},put(t,e,r){return be(t).setUint8(e,r),e+1}},ee={len:2,get(t,e){return be(t).getUint16(e,!0)},put(t,e,r){return be(t).setUint16(e,r,!0),e+2}},Tt={len:2,get(t,e){return be(t).getUint16(e)},put(t,e,r){return be(t).setUint16(e,r),e+2}},oe={len:4,get(t,e){return be(t).getUint32(e,!0)},put(t,e,r){return be(t).setUint32(e,r,!0),e+4}},ec={len:4,get(t,e){return be(t).getUint32(e)},put(t,e,r){return be(t).setUint32(e,r),e+4}},tc={len:4,get(t,e){return be(t).getInt32(e)},put(t,e,r){return be(t).setInt32(e,r),e+4}},rc={len:8,get(t,e){return be(t).getBigUint64(e,!0)},put(t,e,r){return be(t).setBigUint64(e,r,!0),e+8}},Ee=class{constructor(e,r){this.len=e,this.encoding=r}get(e,r=0){let n=e.subarray(r,r+this.len);return Ql(n,this.encoding)}}});var F0,J,dt,tr=C(()=>{F0="End-Of-Stream",J=class extends Error{constructor(){super(F0),this.name="EndOfStreamError"}},dt=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}});var nc=C(()=>{});var pt,Br=C(()=>{tr();pt=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,r=!1){let n=await this.read(e,r);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,r=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),r)),n===0&&!r)throw new J;return n}readFromPeekBuffer(e){let r=e.length,n=0;for(;this.peekQueue.length>0&&r>0;){let s=this.peekQueue.pop();if(!s)throw new Error("peekData should be defined");let i=Math.min(s.length,r);e.set(s.subarray(0,i),n),n+=i,r-=i,i<s.length&&this.peekQueue.push(s.subarray(i))}return n}async readRemainderFromStream(e,r){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new dt;let s=await this.readFromStream(e.subarray(n),r);if(s===0)break;n+=s}if(!r&&n<e.length)throw new J;return n}}});var sc=C(()=>{tr();nc();Br()});var Wr,ic=C(()=>{Br();Wr=class extends pt{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var rr,us=C(()=>{ic();rr=class extends Wr{async readFromStream(e,r){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:r?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}}});var Lt,fs=C(()=>{tr();Br();Lt=class extends pt{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,r){let n=Math.min(r.length,e.length);return e.set(r.subarray(0,n)),n<r.length?this.buffer=r.subarray(n):this.buffer=null,n}async readFromStream(e,r){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let s=await this.reader.read();if(s.done){this.endOfStream=!0;break}s.value&&(n+=this.writeChunk(e.subarray(n),s.value))}if(!r&&n===0&&this.endOfStream)throw new J;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function ds(t){try{let e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new Lt(e):new rr(e)}catch(e){if(e instanceof TypeError)return new Lt(t.getReader());throw e}}var oc=C(()=>{us();fs()});var ht=C(()=>{tr();sc();us();fs();oc()});var Ve,nr=C(()=>{ht();Ve=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,r=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:r})<e.len)throw new J;return e.get(n,0)}async peekToken(e,r=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:r})<e.len)throw new J;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new J;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new J;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let r=this.fileInfo.size-this.position;if(e>r)return this.position+=r,r}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,r){if(!this.supportsRandomAccess()&&r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...r}}abort(){return Promise.resolve()}}});var L0,Ur,ac=C(()=>{nr();ht();L0=256e3,Ur=class extends Ve{constructor(e,r){super(r),this.streamReader=e,this.fileInfo=r?.fileInfo??{}}async readBuffer(e,r){let n=this.normalizeOptions(e,r),s=n.position-this.position;if(s>0)return await this.ignore(s),this.readBuffer(e,r);if(s<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!r||!r.mayBeLess)&&i<n.length)throw new J;return i}async peekBuffer(e,r){let n=this.normalizeOptions(e,r),s=0;if(n.position){let i=n.position-this.position;if(i>0){let o=new Uint8Array(n.length+i);return s=await this.peekBuffer(o,{mayBeLess:n.mayBeLess}),e.set(o.subarray(i)),s-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{s=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(i){if(r?.mayBeLess&&i instanceof J)return 0;throw i}if(!n.mayBeLess&&s<n.length)throw new J}return s}async ignore(e){let r=Math.min(L0,e),n=new Uint8Array(r),s=0;for(;s<e;){let i=e-s,o=await this.readBuffer(n,{length:Math.min(r,i)});if(o<0)return o;s+=o}return s}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}});var jr,lc=C(()=>{ht();nr();jr=class extends Ve{constructor(e,r){super(r),this.uint8Array=e,this.fileInfo={...r?.fileInfo??{},size:e.length}}async readBuffer(e,r){r?.position&&(this.position=r.position);let n=await this.peekBuffer(e,r);return this.position+=n,n}async peekBuffer(e,r){let n=this.normalizeOptions(e,r),s=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&s<n.length)throw new J;return e.set(this.uint8Array.subarray(n.position,n.position+s)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});var zr,cc=C(()=>{ht();nr();zr=class extends Ve{constructor(e,r){super(r),this.blob=e,this.fileInfo={...r?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,r){r?.position&&(this.position=r.position);let n=await this.peekBuffer(e,r);return this.position+=n,n}async peekBuffer(e,r){let n=this.normalizeOptions(e,r),s=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&s<n.length)throw new J;let i=await this.blob.slice(n.position,n.position+s).arrayBuffer();return e.set(new Uint8Array(i)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});function uc(t,e){let r=ds(t),n=e??{},s=n.onClose;return n.onClose=async()=>{if(await r.close(),s)return s()},new Ur(r,n)}function fc(t,e){return new jr(t,e)}function dc(t,e){return new zr(t,e)}var pc=C(()=>{ht();ac();lc();cc();ht();nr()});var mc=mr((jE,hc)=>{var Dt=1e3,Mt=Dt*60,_t=Mt*60,mt=_t*24,M0=mt*7,_0=mt*365.25;hc.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return B0(t);if(r==="number"&&isFinite(t))return e.long?U0(t):W0(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function B0(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*_0;case"weeks":case"week":case"w":return r*M0;case"days":case"day":case"d":return r*mt;case"hours":case"hour":case"hrs":case"hr":case"h":return r*_t;case"minutes":case"minute":case"mins":case"min":case"m":return r*Mt;case"seconds":case"second":case"secs":case"sec":case"s":return r*Dt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function W0(t){var e=Math.abs(t);return e>=mt?Math.round(t/mt)+"d":e>=_t?Math.round(t/_t)+"h":e>=Mt?Math.round(t/Mt)+"m":e>=Dt?Math.round(t/Dt)+"s":t+"ms"}function U0(t){var e=Math.abs(t);return e>=mt?Hr(t,e,mt,"day"):e>=_t?Hr(t,e,_t,"hour"):e>=Mt?Hr(t,e,Mt,"minute"):e>=Dt?Hr(t,e,Dt,"second"):t+" ms"}function Hr(t,e,r,n){var s=e>=r*1.5;return Math.round(t/r)+" "+n+(s?"s":"")}});var yc=mr((zE,gc)=>{function j0(t){r.debug=r,r.default=r,r.coerce=l,r.disable=o,r.enable=s,r.enabled=a,r.humanize=mc(),r.destroy=c,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let f=0;for(let d=0;d<u.length;d++)f=(f<<5)-f+u.charCodeAt(d),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(u){let f,d=null,p,h;function y(...m){if(!y.enabled)return;let w=y,b=Number(new Date),E=b-(f||b);w.diff=E,w.prev=f,w.curr=b,f=b,m[0]=r.coerce(m[0]),typeof m[0]!="string"&&m.unshift("%O");let S=0;m[0]=m[0].replace(/%([a-zA-Z%])/g,(F,M)=>{if(F==="%%")return"%";S++;let D=r.formatters[M];if(typeof D=="function"){let U=m[S];F=D.call(w,U),m.splice(S,1),S--}return F}),r.formatArgs.call(w,m),(w.log||r.log).apply(w,m)}return y.namespace=u,y.useColors=r.useColors(),y.color=r.selectColor(u),y.extend=n,y.destroy=r.destroy,Object.defineProperty(y,"enabled",{enumerable:!0,configurable:!1,get:()=>d!==null?d:(p!==r.namespaces&&(p=r.namespaces,h=r.enabled(u)),h),set:m=>{d=m}}),typeof r.init=="function"&&r.init(y),y}function n(u,f){let d=r(this.namespace+(typeof f>"u"?":":f)+u);return d.log=this.log,d}function s(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let d of f)d[0]==="-"?r.skips.push(d.slice(1)):r.names.push(d)}function i(u,f){let d=0,p=0,h=-1,y=0;for(;d<u.length;)if(p<f.length&&(f[p]===u[d]||f[p]==="*"))f[p]==="*"?(h=p,y=d,p++):(d++,p++);else if(h!==-1)p=h+1,y++,d=y;else return!1;for(;p<f.length&&f[p]==="*";)p++;return p===f.length}function o(){let u=[...r.names,...r.skips.map(f=>"-"+f)].join(",");return r.enable(""),u}function a(u){for(let f of r.skips)if(i(u,f))return!1;for(let f of r.names)if(i(u,f))return!0;return!1}function l(u){return u instanceof Error?u.stack||u.message:u}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}gc.exports=j0});var xc=mr((Se,Gr)=>{Se.formatArgs=H0;Se.save=G0;Se.load=q0;Se.useColors=z0;Se.storage=V0();Se.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Se.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function z0(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function H0(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+Gr.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(r++,s==="%c"&&(n=r))}),t.splice(n,0,e)}Se.log=console.debug||console.log||(()=>{});function G0(t){try{t?Se.storage.setItem("debug",t):Se.storage.removeItem("debug")}catch{}}function q0(){let t;try{t=Se.storage.getItem("debug")||Se.storage.getItem("DEBUG")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function V0(){try{return localStorage}catch{}}Gr.exports=yc()(Se);var{formatters:K0}=Gr.exports;K0.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var gt,ps,wc,bc,Ec,Sc=C(()=>{er();gt={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},ps={get(t){return{signature:oe.get(t,0),compressedSize:oe.get(t,8),uncompressedSize:oe.get(t,12)}},len:16},wc={get(t){let e=ee.get(t,6);return{signature:oe.get(t,0),minVersion:ee.get(t,4),dataDescriptor:!!(e&8),compressedMethod:ee.get(t,8),compressedSize:oe.get(t,18),uncompressedSize:oe.get(t,22),filenameLength:ee.get(t,26),extraFieldLength:ee.get(t,28),filename:null}},len:30},bc={get(t){return{signature:oe.get(t,0),nrOfThisDisk:ee.get(t,4),nrOfThisDiskWithTheStart:ee.get(t,6),nrOfEntriesOnThisDisk:ee.get(t,8),nrOfEntriesOfSize:ee.get(t,10),sizeOfCd:oe.get(t,12),offsetOfStartOfCd:oe.get(t,16),zipFileCommentLength:ee.get(t,20)}},len:22},Ec={get(t){let e=ee.get(t,8);return{signature:oe.get(t,0),minVersion:ee.get(t,6),dataDescriptor:!!(e&8),compressedMethod:ee.get(t,10),compressedSize:oe.get(t,20),uncompressedSize:oe.get(t,24),filenameLength:ee.get(t,28),extraFieldLength:ee.get(t,30),fileCommentLength:ee.get(t,32),relativeOffsetOfLocalHeader:oe.get(t,42),filename:null}},len:46}});function Ac(t){let e=new Uint8Array(oe.len);return oe.put(e,0,t),e}function Q0(t,e){let r=t.length,n=e.length;if(n>r)return-1;for(let s=0;s<=r-n;s++){let i=!0;for(let o=0;o<n;o++)if(t[s+o]!==e[o]){i=!1;break}if(i)return s}return-1}function X0(t){let e=t.reduce((s,i)=>s+i.length,0),r=new Uint8Array(e),n=0;for(let s of t)r.set(s,n),n+=s.length;return r}var Cc,He,hs,Z0,qr,sr,kc=C(()=>{er();Cc=Ai(xc(),1);Sc();He=(0,Cc.default)("tokenizer:inflate"),hs=256*1024,Z0=Ac(gt.DataDescriptor),qr=Ac(gt.EndOfCentralDirectory),sr=class t{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(hs)}async isZip(){return await this.peekSignature()===gt.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(oe)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,r=Math.min(16*1024,e.fileInfo.size),n=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-r});for(let s=n.length-4;s>=0;s--)if(n[s]===qr[0]&&n[s+1]===qr[1]&&n[s+2]===qr[2]&&n[s+3]===qr[3])return e.fileInfo.size-r+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){He("Cannot reading central-directory without random-read support");return}He("Reading central-directory...");let e=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){He("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(bc,r),s=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let i=0;i<n.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken(Ec);if(o.signature!==gt.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Ee(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),He(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(e),s}this.tokenizer.setPosition(e)}async unzip(e){let r=await this.readCentralDirectory();if(r)return this.iterateOverCentralDirectory(r,e);let n=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=e(s);n=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=hs;He("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===hs;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=Q0(this.syncBuffer.subarray(0,l),Z0);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),a.push(f)}else await this.tokenizer.ignore(u)}He(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,X0(a),i.handler)}else i.handler?(He(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(He(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(He(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(ps)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-ps.len}`)}while(!n)}async iterateOverCentralDirectory(e,r){for(let n of e){let s=r(n);if(s.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(e,r,n){if(e.compressedMethod===0)return n(r);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);He(`Decompress filename=${e.filename}, compressed-size=${r.length}`);let s=await t.decompressDeflateRaw(r);return n(s)}static async decompressDeflateRaw(e){let r=new ReadableStream({start(i){i.enqueue(e),i.close()}}),n=new DecompressionStream("deflate-raw"),s=r.pipeThrough(n);try{let o=await new Response(s).arrayBuffer();return new Uint8Array(o)}catch(i){let o=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(oe);if(e===gt.LocalFileHeader){let r=await this.tokenizer.readToken(wc);return r.filename=await this.tokenizer.readToken(new Ee(r.filenameLength,"utf-8")),r}if(e===gt.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var ir,Nc=C(()=>{ir=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(r){let n=new Uint8Array(1024),s=await e.readBuffer(n,{mayBeLess:!0});if(s===0){r.close();return}r.enqueue(n.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var Ic=C(()=>{kc();Nc()});function ms(t){let{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}var YE,e1,t1,vc=C(()=>{YE={utf8:new globalThis.TextDecoder("utf8")},e1=new globalThis.TextEncoder,t1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"))});function $c(t,e){if(e==="utf-16le"){let r=[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);r.push(s&255,s>>8&255)}return r}if(e==="utf-16be"){let r=[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);r.push(s>>8&255,s&255)}return r}return[...t].map(r=>r.charCodeAt(0))}function Rc(t,e=0){let r=Number.parseInt(new Ee(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=256;for(let s=e;s<e+148;s++)n+=t[s];for(let s=e+156;s<e+512;s++)n+=t[s];return r===n}var Pc,Oc=C(()=>{er();Pc={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4}});var Fc,Tc,Lc=C(()=>{Fc=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],Tc=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"]});async function Dc(t,e){return new xs(e).fromBuffer(t)}function ys(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function Ge(t,e,r){r={offset:0,...r};for(let[n,s]of e.entries())if(r.mask){if(s!==(r.mask[n]&t[n+r.offset]))return!1}else if(s!==t[n+r.offset])return!1;return!0}var gs,xs,u1,f1,Mc=C(()=>{er();pc();Ic();vc();Oc();Lc();gs=4100;xs=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let r=e.position;for(let n of this.detectors){let s=await n.detect(e);if(s)return s;if(r!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let r=e instanceof Uint8Array?e:new Uint8Array(e);if(r?.length>1)return this.fromTokenizer(fc(r,this.tokenizerOptions))}async fromBlob(e){let r=dc(e,this.tokenizerOptions);try{return await this.fromTokenizer(r)}finally{await r.close()}}async fromStream(e){let r=uc(e,this.tokenizerOptions);try{return await this.fromTokenizer(r)}finally{await r.close()}}async toDetectionStream(e,r){let{sampleSize:n=gs}=r,s,i,o=e.getReader({mode:"byob"});try{let{value:c,done:u}=await o.read(new Uint8Array(n));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,n))}catch(f){if(!(f instanceof J))throw f;s=void 0}i=c}finally{o.releaseLock()}let a=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=e.pipeThrough(a);return l.fileType=s,l}check(e,r){return Ge(this.buffer,e,r)}checkString(e,r){return this.check($c(e,r?.encoding),r)}detectConfident=async e=>{if(this.buffer=new Uint8Array(gs),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8])){let n=new ir(e).inflate(),s=!0;try{let i;try{i=await this.fromStream(n)}catch{s=!1}if(i&&i.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{s&&await n.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);let r=await e.readToken(Pc);return e.position+r>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(r),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let r;return await new sr(e).unzip(n=>{switch(n.filename){case"META-INF/mozilla.rsa":return r={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return r={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(s){let i=new TextDecoder("utf-8").decode(s).trim();r=ys(i)},stop:!0};case"[Content_Types].xml":return{async handler(s){let i=new TextDecoder("utf-8").decode(s),o=i.indexOf('.main+xml"');if(o===-1){let a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";i.includes(`ContentType="${a}"`)&&(r=ys(a))}else{i=i.slice(0,Math.max(0,o));let a=i.lastIndexOf('"'),l=i.slice(Math.max(0,a+1));r=ys(l)}},stop:!0};default:return/classes\d*\.dex/.test(n.filename)?(r={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(n=>{if(!(n instanceof J))throw n}),r??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let r=new Uint8Array(8);return await e.readBuffer(r),Ge(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Ge(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Ge(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Ge(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Ge(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Ge(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){let r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){let a=await e.peekNumber(Yl),l=128,c=0;for(;(a&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await e.readBuffer(u),u}async function n(){let a=await r(),l=await r();l[0]^=128>>l.length-1;let c=Math.min(6,l.length),u=new DataView(a.buffer),f=new DataView(l.buffer,l.length-c,c);return{id:ms(u),len:ms(f)}}async function s(a){for(;a>0;){let l=await n();if(l.id===17026)return(await e.readToken(new Ee(l.len))).replaceAll(/\00.*$/g,"");await e.ignore(l.len),--a}}let i=await n();switch(await s(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let r=new Ee(4,"latin1").get(this.buffer,2);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new Ee(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
514
- `,"\r"," "," ","\0"].some(r=>this.checkString(r,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function r(){return{length:await e.readToken(tc),type:await e.readToken(new Ee(4,"latin1"))}}do{let n=await r();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(n.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let r=new Ee(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
515
- `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function r(){let n=new Uint8Array(16);return await e.readBuffer(n),{id:n,size:Number(await e.readToken(rc))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let n=await r(),s=n.size-24;if(Ge(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let i=new Uint8Array(16);if(s-=await e.readBuffer(i),Ge(i,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Ge(i,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(s)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Ee(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let r=new DataView(this.buffer.buffer).getUint32(12,!0);if(r>12&&this.buffer.length>=r+16)try{let n=new TextDecoder().decode(this.buffer.subarray(16,r+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&Rc(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let r="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:r})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:r})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
516
- `,{offset:2,encoding:r})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(gs),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let r=0;r<=this.options.mpegOffsetTolerance;++r){let n=this.scanMpeg(r);if(n)return n}};async readTiffTag(e){let r=await this.tokenizer.readToken(e?Tt:ee);switch(this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let r=await this.tokenizer.readToken(e?Tt:ee);for(let n=0;n<r;++n){let s=await this.readTiffTag(e);if(s)return s}}async readTiffHeader(e){let r=(e?Tt:ee).get(this.buffer,2),n=(e?ec:oe).get(this.buffer,4);if(r===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){let i=(e?Tt:ee).get(this.buffer,8),o=(e?Tt:ee).get(this.buffer,10);if(i===28&&o===254||i===31&&o===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(n),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},u1=new Set(Fc),f1=new Set(Tc)});var Wc={};v(Wc,{fileCommand:()=>ng});function Y0(t,e){if(Bc[t])return Bc[t];let[r,n]=e.split("/"),s=n?.split("+")[0]?.replace(/-/g," ")||t;switch(r){case"image":return`${s.toUpperCase()} image data`;case"audio":return`${s.toUpperCase()} audio`;case"video":return`${s.toUpperCase()} video`;case"font":return`${s} font`;case"model":return`${s} 3D model`;case"application":return n?.includes("zip")||n?.includes("compressed")?`${s} archive data`:n?.includes("executable")?`${s} executable`:`${t.toUpperCase()} data`;default:return`${t.toUpperCase()} data`}}function eg(t){let e=t.split("/").pop()||t;if(e.startsWith(".")&&!e.includes(".",1))return e;let r=e.lastIndexOf(".");return r===-1||r===0?"":e.slice(r).toLowerCase()}function tg(t,e){if(t.startsWith("#!")){let l=t.split(`
506
+ `,exitCode:2}}}}});function R0(t){function e(d,h){return d<<h|d>>>32-h}let r=new Uint32Array([3614090360,3905402710,606105819,3250441966,4118548399,1200080426,2821735955,4249261313,1770035416,2336552879,4294925233,2304563134,1804603682,4254626195,2792965006,1236535329,4129170786,3225465664,643717713,3921069994,3593408605,38016083,3634488961,3889429448,568446438,3275163606,4107603335,1163531501,2850285829,4243563512,1735328473,2368359562,4294588738,2272392833,1839030562,4259657740,2763975236,1272893353,4139469664,3200236656,681279174,3936430074,3572445317,76029189,3654602809,3873151461,530742520,3299628645,4096336452,1126891415,2878612391,4237533241,1700485571,2399980690,4293915773,2240044497,1873313359,4264355552,2734768916,1309151649,4149444226,3174756917,718787259,3951481745]),n=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],s=t.length*8,i=(t.length%64<56?56:120)-t.length%64,o=new Uint8Array(t.length+i+8);o.set(t),o[t.length]=128;let a=new DataView(o.buffer);a.setUint32(o.length-8,s>>>0,!0),a.setUint32(o.length-4,Math.floor(s/4294967296),!0);let l=1732584193,c=4023233417,u=2562383102,f=271733878;for(let d=0;d<o.length;d+=64){let h=new Uint32Array(16);for(let E=0;E<16;E++)h[E]=a.getUint32(d+E*4,!0);let m=l,g=c,w=u,b=f;for(let E=0;E<64;E++){let S,v;E<16?(S=g&w|~g&b,v=E):E<32?(S=b&g|~b&w,v=(5*E+1)%16):E<48?(S=g^w^b,v=(3*E+5)%16):(S=w^(g|~b),v=7*E%16),S=S+m+r[E]+h[v]>>>0,m=b,b=w,w=g,g=g+e(S,n[E])>>>0}l=l+m>>>0,c=c+g>>>0,u=u+w>>>0,f=f+b>>>0}let p=new Uint8Array(16);return new DataView(p.buffer).setUint32(0,l,!0),new DataView(p.buffer).setUint32(4,c,!0),new DataView(p.buffer).setUint32(8,u,!0),new DataView(p.buffer).setUint32(12,f,!0),Array.from(p).map(d=>d.toString(16).padStart(2,"0")).join("")}async function Ql(t,e){if(t==="md5")return R0(e);let r=await globalThis.crypto.subtle.digest($0[t],new Uint8Array(e).buffer);return Array.from(new Uint8Array(r)).map(n=>n.toString(16).padStart(2,"0")).join("")}function zt(t,e,r){let n={name:t,summary:r,usage:`${t} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:t,async execute(s,i){if(N(s))return k(n);let o=!1,a=[];for(let f of s)if(f==="-c"||f==="--check")o=!0;else if(!(f==="-b"||f==="-t"||f==="--binary"||f==="--text")){if(f.startsWith("-")&&f!=="-")return P(t,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return new TextEncoder().encode(i.stdin);try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,p="";for(let d of a){let h=d==="-"?i.stdin:await i.fs.readFile(i.fs.resolvePath(i.cwd,d)).catch(()=>null);if(h===null)return{stdout:"",stderr:`${t}: ${d}: No such file or directory
507
+ `,exitCode:1};for(let m of h.split(`
508
+ `)){let g=m.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!g)continue;let[,w,b]=g,E=await l(b);if(E===null){p+=`${b}: FAILED open or read
509
+ `,f++;continue}let S=await Ql(e,E)===w.toLowerCase();p+=`${b}: ${S?"OK":"FAILED"}
510
+ `,S||f++}}return f>0&&(p+=`${t}: WARNING: ${f} computed checksum${f>1?"s":""} did NOT match
511
+ `),{stdout:p,stderr:"",exitCode:f>0?1:0}}let c="",u=0;for(let f of a){let p=await l(f);if(p===null){c+=`${t}: ${f}: No such file or directory
512
+ `,u=1;continue}c+=`${await Ql(e,p)} ${f}
513
+ `}return{stdout:c,stderr:"",exitCode:u}}}}var $0,Kr=C(()=>{"use strict";L();$0={sha1:"SHA-1",sha256:"SHA-256"}});var Xl={};R(Xl,{md5sumCommand:()=>P0});var P0,Jl=C(()=>{"use strict";Kr();P0=zt("md5sum","md5","compute MD5 message digest")});var Yl={};R(Yl,{sha1sumCommand:()=>F0});var F0,ec=C(()=>{"use strict";Kr();F0=zt("sha1sum","sha1","compute SHA1 message digest")});var tc={};R(tc,{sha256sumCommand:()=>O0});var O0,rc=C(()=>{"use strict";Kr();O0=zt("sha256sum","sha256","compute SHA256 message digest")});var nc=Ar(gs=>{gs.read=function(t,e,r,n,s){var i,o,a=s*8-n-1,l=(1<<a)-1,c=l>>1,u=-7,f=r?s-1:0,p=r?-1:1,d=t[e+f];for(f+=p,i=d&(1<<-u)-1,d>>=-u,u+=a;u>0;i=i*256+t[e+f],f+=p,u-=8);for(o=i&(1<<-u)-1,i>>=-u,u+=n;u>0;o=o*256+t[e+f],f+=p,u-=8);if(i===0)i=1-c;else{if(i===l)return o?NaN:(d?-1:1)*(1/0);o=o+Math.pow(2,n),i=i-c}return(d?-1:1)*o*Math.pow(2,i-n)};gs.write=function(t,e,r,n,s,i){var o,a,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,p=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:i-1,h=n?1:-1,m=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=u):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?e+=p/l:e+=p*Math.pow(2,1-f),e*l>=2&&(o++,l/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(e*l-1)*Math.pow(2,s),o=o+f):(a=e*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;t[r+d]=a&255,d+=h,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;t[r+d]=o&255,d+=h,o/=256,c-=8);t[r+d-h]|=m*128}});function sc(t,e="utf-8"){switch(e.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(t):D0(t);case"utf-16le":return L0(t);case"ascii":return M0(t);case"latin1":case"iso-8859-1":return _0(t);case"windows-1252":return B0(t);default:throw new RangeError(`Encoding '${e}' not supported`)}}function D0(t){let e="",r=0;for(;r<t.length;){let n=t[r++];if(n<128)e+=String.fromCharCode(n);else if(n<224){let s=t[r++]&63;e+=String.fromCharCode((n&31)<<6|s)}else if(n<240){let s=t[r++]&63,i=t[r++]&63;e+=String.fromCharCode((n&15)<<12|s<<6|i)}else{let s=t[r++]&63,i=t[r++]&63,o=t[r++]&63,a=(n&7)<<18|s<<12|i<<6|o;a-=65536,e+=String.fromCharCode(55296+(a>>10&1023),56320+(a&1023))}}return e}function L0(t){let e="";for(let r=0;r<t.length;r+=2)e+=String.fromCharCode(t[r]|t[r+1]<<8);return e}function M0(t){return String.fromCharCode(...t.map(e=>e&127))}function _0(t){return String.fromCharCode(...t)}function B0(t){let e="";for(let r of t)r>=128&&r<=159&&ys[r]?e+=ys[r]:e+=String.fromCharCode(r);return e}var ys,T0,ic=C(()=>{ys={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"},T0={};for(let[t,e]of Object.entries(ys))T0[e]=Number.parseInt(t)});function Pe(t){return new DataView(t.buffer,t.byteOffset)}var oc,ac,pe,Ht,ge,lc,cc,uc,Fe,ur=C(()=>{oc=Fi(nc(),1);ic();ac={len:1,get(t,e){return Pe(t).getUint8(e)},put(t,e,r){return Pe(t).setUint8(e,r),e+1}},pe={len:2,get(t,e){return Pe(t).getUint16(e,!0)},put(t,e,r){return Pe(t).setUint16(e,r,!0),e+2}},Ht={len:2,get(t,e){return Pe(t).getUint16(e)},put(t,e,r){return Pe(t).setUint16(e,r),e+2}},ge={len:4,get(t,e){return Pe(t).getUint32(e,!0)},put(t,e,r){return Pe(t).setUint32(e,r,!0),e+4}},lc={len:4,get(t,e){return Pe(t).getUint32(e)},put(t,e,r){return Pe(t).setUint32(e,r),e+4}},cc={len:4,get(t,e){return Pe(t).getInt32(e)},put(t,e,r){return Pe(t).setInt32(e,r),e+4}},uc={len:8,get(t,e){return Pe(t).getBigUint64(e,!0)},put(t,e,r){return Pe(t).setBigUint64(e,r,!0),e+8}},Fe=class{constructor(e,r){this.len=e,this.encoding=r}get(e,r=0){let n=e.subarray(r,r+this.len);return sc(n,this.encoding)}}});var U0,ae,St,fr=C(()=>{U0="End-Of-Stream",ae=class extends Error{constructor(){super(U0),this.name="EndOfStreamError"}},St=class extends Error{constructor(e="The operation was aborted"){super(e),this.name="AbortError"}}});var fc=C(()=>{});var Ct,Zr=C(()=>{fr();Ct=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,r=!1){let n=await this.read(e,r);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,r=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),r)),n===0&&!r)throw new ae;return n}readFromPeekBuffer(e){let r=e.length,n=0;for(;this.peekQueue.length>0&&r>0;){let s=this.peekQueue.pop();if(!s)throw new Error("peekData should be defined");let i=Math.min(s.length,r);e.set(s.subarray(0,i),n),n+=i,r-=i,i<s.length&&this.peekQueue.push(s.subarray(i))}return n}async readRemainderFromStream(e,r){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new St;let s=await this.readFromStream(e.subarray(n),r);if(s===0)break;n+=s}if(!r&&n<e.length)throw new ae;return n}}});var pc=C(()=>{fr();fc();Zr()});var Qr,dc=C(()=>{Zr();Qr=class extends Ct{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var pr,xs=C(()=>{dc();pr=class extends Qr{async readFromStream(e,r){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:r?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}}});var Gt,ws=C(()=>{fr();Zr();Gt=class extends Ct{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,r){let n=Math.min(r.length,e.length);return e.set(r.subarray(0,n)),n<r.length?this.buffer=r.subarray(n):this.buffer=null,n}async readFromStream(e,r){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let s=await this.reader.read();if(s.done){this.endOfStream=!0;break}s.value&&(n+=this.writeChunk(e.subarray(n),s.value))}if(!r&&n===0&&this.endOfStream)throw new ae;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function bs(t){try{let e=t.getReader({mode:"byob"});return e instanceof ReadableStreamDefaultReader?new Gt(e):new pr(e)}catch(e){if(e instanceof TypeError)return new Gt(t.getReader());throw e}}var hc=C(()=>{xs();ws()});var At=C(()=>{fr();pc();xs();ws();hc()});var Ye,dr=C(()=>{At();Ye=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(e,r=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:r})<e.len)throw new ae;return e.get(n,0)}async peekToken(e,r=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:r})<e.len)throw new ae;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new ae;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new ae;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let r=this.fileInfo.size-this.position;if(e>r)return this.position+=r,r}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,r){if(!this.supportsRandomAccess()&&r&&r.position!==void 0&&r.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...r}}abort(){return Promise.resolve()}}});var z0,Xr,mc=C(()=>{dr();At();z0=256e3,Xr=class extends Ye{constructor(e,r){super(r),this.streamReader=e,this.fileInfo=r?.fileInfo??{}}async readBuffer(e,r){let n=this.normalizeOptions(e,r),s=n.position-this.position;if(s>0)return await this.ignore(s),this.readBuffer(e,r);if(s<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!r||!r.mayBeLess)&&i<n.length)throw new ae;return i}async peekBuffer(e,r){let n=this.normalizeOptions(e,r),s=0;if(n.position){let i=n.position-this.position;if(i>0){let o=new Uint8Array(n.length+i);return s=await this.peekBuffer(o,{mayBeLess:n.mayBeLess}),e.set(o.subarray(i)),s-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(n.length>0){try{s=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(i){if(r?.mayBeLess&&i instanceof ae)return 0;throw i}if(!n.mayBeLess&&s<n.length)throw new ae}return s}async ignore(e){let r=Math.min(z0,e),n=new Uint8Array(r),s=0;for(;s<e;){let i=e-s,o=await this.readBuffer(n,{length:Math.min(r,i)});if(o<0)return o;s+=o}return s}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}});var Jr,gc=C(()=>{At();dr();Jr=class extends Ye{constructor(e,r){super(r),this.uint8Array=e,this.fileInfo={...r?.fileInfo??{},size:e.length}}async readBuffer(e,r){r?.position&&(this.position=r.position);let n=await this.peekBuffer(e,r);return this.position+=n,n}async peekBuffer(e,r){let n=this.normalizeOptions(e,r),s=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&s<n.length)throw new ae;return e.set(this.uint8Array.subarray(n.position,n.position+s)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});var Yr,yc=C(()=>{At();dr();Yr=class extends Ye{constructor(e,r){super(r),this.blob=e,this.fileInfo={...r?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,r){r?.position&&(this.position=r.position);let n=await this.peekBuffer(e,r);return this.position+=n,n}async peekBuffer(e,r){let n=this.normalizeOptions(e,r),s=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&s<n.length)throw new ae;let i=await this.blob.slice(n.position,n.position+s).arrayBuffer();return e.set(new Uint8Array(i)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}}});function xc(t,e){let r=bs(t),n=e??{},s=n.onClose;return n.onClose=async()=>{if(await r.close(),s)return s()},new Xr(r,n)}function wc(t,e){return new Jr(t,e)}function bc(t,e){return new Yr(t,e)}var Ec=C(()=>{At();mc();gc();yc();At();dr()});var Cc=Ar((s1,Sc)=>{var qt=1e3,Vt=qt*60,Kt=Vt*60,kt=Kt*24,G0=kt*7,q0=kt*365.25;Sc.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return V0(t);if(r==="number"&&isFinite(t))return e.long?Z0(t):K0(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function V0(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*q0;case"weeks":case"week":case"w":return r*G0;case"days":case"day":case"d":return r*kt;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Kt;case"minutes":case"minute":case"mins":case"min":case"m":return r*Vt;case"seconds":case"second":case"secs":case"sec":case"s":return r*qt;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function K0(t){var e=Math.abs(t);return e>=kt?Math.round(t/kt)+"d":e>=Kt?Math.round(t/Kt)+"h":e>=Vt?Math.round(t/Vt)+"m":e>=qt?Math.round(t/qt)+"s":t+"ms"}function Z0(t){var e=Math.abs(t);return e>=kt?en(t,e,kt,"day"):e>=Kt?en(t,e,Kt,"hour"):e>=Vt?en(t,e,Vt,"minute"):e>=qt?en(t,e,qt,"second"):t+" ms"}function en(t,e,r,n){var s=e>=r*1.5;return Math.round(t/r)+" "+n+(s?"s":"")}});var kc=Ar((i1,Ac)=>{function Q0(t){r.debug=r,r.default=r,r.coerce=l,r.disable=o,r.enable=s,r.enabled=a,r.humanize=Cc(),r.destroy=c,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let f=0;for(let p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(u){let f,p=null,d,h;function m(...g){if(!m.enabled)return;let w=m,b=Number(new Date),E=b-(f||b);w.diff=E,w.prev=f,w.curr=b,f=b,g[0]=r.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let S=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(D,I)=>{if(D==="%%")return"%";S++;let $=r.formatters[I];if(typeof $=="function"){let V=g[S];D=$.call(w,V),g.splice(S,1),S--}return D}),r.formatArgs.call(w,g),(w.log||r.log).apply(w,g)}return m.namespace=u,m.useColors=r.useColors(),m.color=r.selectColor(u),m.extend=n,m.destroy=r.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==r.namespaces&&(d=r.namespaces,h=r.enabled(u)),h),set:g=>{p=g}}),typeof r.init=="function"&&r.init(m),m}function n(u,f){let p=r(this.namespace+(typeof f>"u"?":":f)+u);return p.log=this.log,p}function s(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let p of f)p[0]==="-"?r.skips.push(p.slice(1)):r.names.push(p)}function i(u,f){let p=0,d=0,h=-1,m=0;for(;p<u.length;)if(d<f.length&&(f[d]===u[p]||f[d]==="*"))f[d]==="*"?(h=d,m=p,d++):(p++,d++);else if(h!==-1)d=h+1,m++,p=m;else return!1;for(;d<f.length&&f[d]==="*";)d++;return d===f.length}function o(){let u=[...r.names,...r.skips.map(f=>"-"+f)].join(",");return r.enable(""),u}function a(u){for(let f of r.skips)if(i(u,f))return!1;for(let f of r.names)if(i(u,f))return!0;return!1}function l(u){return u instanceof Error?u.stack||u.message:u}function c(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}Ac.exports=Q0});var Nc=Ar((Oe,tn)=>{Oe.formatArgs=J0;Oe.save=Y0;Oe.load=eg;Oe.useColors=X0;Oe.storage=tg();Oe.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Oe.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function X0(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let t;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(t=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(t[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function J0(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+tn.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(r++,s==="%c"&&(n=r))}),t.splice(n,0,e)}Oe.log=console.debug||console.log||(()=>{});function Y0(t){try{t?Oe.storage.setItem("debug",t):Oe.storage.removeItem("debug")}catch{}}function eg(){let t;try{t=Oe.storage.getItem("debug")||Oe.storage.getItem("DEBUG")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function tg(){try{return localStorage}catch{}}tn.exports=kc()(Oe);var{formatters:rg}=tn.exports;rg.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Nt,Es,Ic,vc,$c,Rc=C(()=>{ur();Nt={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Es={get(t){return{signature:ge.get(t,0),compressedSize:ge.get(t,8),uncompressedSize:ge.get(t,12)}},len:16},Ic={get(t){let e=pe.get(t,6);return{signature:ge.get(t,0),minVersion:pe.get(t,4),dataDescriptor:!!(e&8),compressedMethod:pe.get(t,8),compressedSize:ge.get(t,18),uncompressedSize:ge.get(t,22),filenameLength:pe.get(t,26),extraFieldLength:pe.get(t,28),filename:null}},len:30},vc={get(t){return{signature:ge.get(t,0),nrOfThisDisk:pe.get(t,4),nrOfThisDiskWithTheStart:pe.get(t,6),nrOfEntriesOnThisDisk:pe.get(t,8),nrOfEntriesOfSize:pe.get(t,10),sizeOfCd:ge.get(t,12),offsetOfStartOfCd:ge.get(t,16),zipFileCommentLength:pe.get(t,20)}},len:22},$c={get(t){let e=pe.get(t,8);return{signature:ge.get(t,0),minVersion:pe.get(t,6),dataDescriptor:!!(e&8),compressedMethod:pe.get(t,10),compressedSize:ge.get(t,20),uncompressedSize:ge.get(t,24),filenameLength:pe.get(t,28),extraFieldLength:pe.get(t,30),fileCommentLength:pe.get(t,32),relativeOffsetOfLocalHeader:ge.get(t,42),filename:null}},len:46}});function Fc(t){let e=new Uint8Array(ge.len);return ge.put(e,0,t),e}function sg(t,e){let r=t.length,n=e.length;if(n>r)return-1;for(let s=0;s<=r-n;s++){let i=!0;for(let o=0;o<n;o++)if(t[s+o]!==e[o]){i=!1;break}if(i)return s}return-1}function ig(t){let e=t.reduce((s,i)=>s+i.length,0),r=new Uint8Array(e),n=0;for(let s of t)r.set(s,n),n+=s.length;return r}var Pc,Qe,Ss,ng,rn,hr,Oc=C(()=>{ur();Pc=Fi(Nc(),1);Rc();Qe=(0,Pc.default)("tokenizer:inflate"),Ss=256*1024,ng=Fc(Nt.DataDescriptor),rn=Fc(Nt.EndOfCentralDirectory),hr=class t{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(Ss)}async isZip(){return await this.peekSignature()===Nt.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(ge)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,r=Math.min(16*1024,e.fileInfo.size),n=this.syncBuffer.subarray(0,r);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-r});for(let s=n.length-4;s>=0;s--)if(n[s]===rn[0]&&n[s+1]===rn[1]&&n[s+2]===rn[2]&&n[s+3]===rn[3])return e.fileInfo.size-r+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){Qe("Cannot reading central-directory without random-read support");return}Qe("Reading central-directory...");let e=this.tokenizer.position,r=await this.findEndOfCentralDirectoryLocator();if(r>0){Qe("Central-directory 32-bit signature found");let n=await this.tokenizer.readToken(vc,r),s=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let i=0;i<n.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken($c);if(o.signature!==Nt.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new Fe(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),Qe(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(e),s}this.tokenizer.setPosition(e)}async unzip(e){let r=await this.readCentralDirectory();if(r)return this.iterateOverCentralDirectory(r,e);let n=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=e(s);n=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=Ss;Qe("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===Ss;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=sg(this.syncBuffer.subarray(0,l),ng);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),a.push(f)}else await this.tokenizer.ignore(u)}Qe(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,ig(a),i.handler)}else i.handler?(Qe(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(Qe(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(Qe(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(Es)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Es.len}`)}while(!n)}async iterateOverCentralDirectory(e,r){for(let n of e){let s=r(n);if(s.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(e,r,n){if(e.compressedMethod===0)return n(r);if(e.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${e.compressedMethod}`);Qe(`Decompress filename=${e.filename}, compressed-size=${r.length}`);let s=await t.decompressDeflateRaw(r);return n(s)}static async decompressDeflateRaw(e){let r=new ReadableStream({start(i){i.enqueue(e),i.close()}}),n=new DecompressionStream("deflate-raw"),s=r.pipeThrough(n);try{let o=await new Response(s).arrayBuffer();return new Uint8Array(o)}catch(i){let o=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(o)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(ge);if(e===Nt.LocalFileHeader){let r=await this.tokenizer.readToken(Ic);return r.filename=await this.tokenizer.readToken(new Fe(r.filenameLength,"utf-8")),r}if(e===Nt.CentralFileHeader)return!1;throw e===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var mr,Tc=C(()=>{mr=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(r){let n=new Uint8Array(1024),s=await e.readBuffer(n,{mayBeLess:!0});if(s===0){r.close();return}r.enqueue(n.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var Dc=C(()=>{Oc();Tc()});function Cs(t){let{byteLength:e}=t;if(e===6)return t.getUint16(0)*2**32+t.getUint32(2);if(e===5)return t.getUint8(0)*2**32+t.getUint32(1);if(e===4)return t.getUint32(0);if(e===3)return t.getUint8(0)*2**16+t.getUint16(1);if(e===2)return t.getUint16(0);if(e===1)return t.getUint8(0)}var m1,g1,y1,Lc=C(()=>{m1={utf8:new globalThis.TextDecoder("utf8")},g1=new globalThis.TextEncoder,y1=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"))});function Mc(t,e){if(e==="utf-16le"){let r=[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);r.push(s&255,s>>8&255)}return r}if(e==="utf-16be"){let r=[];for(let n=0;n<t.length;n++){let s=t.charCodeAt(n);r.push(s>>8&255,s&255)}return r}return[...t].map(r=>r.charCodeAt(0))}function _c(t,e=0){let r=Number.parseInt(new Fe(6).get(t,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(r))return!1;let n=256;for(let s=e;s<e+148;s++)n+=t[s];for(let s=e+156;s<e+512;s++)n+=t[s];return r===n}var Bc,Wc=C(()=>{ur();Bc={get:(t,e)=>t[e+3]&127|t[e+2]<<7|t[e+1]<<14|t[e]<<21,len:4}});var Uc,jc,zc=C(()=>{Uc=["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","jmp","rm","sav","ppsm","ppsx","tar.gz","reg","dat"],jc=["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia","application/x-spss-sav","application/x-ms-regedit","application/x-ft-windows-registry-hive","application/x-jmp-data"]});async function Hc(t,e){return new Ns(e).fromBuffer(t)}function ks(t){switch(t=t.toLowerCase(),t){case"application/epub+zip":return{ext:"epub",mime:t};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:t};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:t};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:t};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:t};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:t};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:t};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:t};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:t};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:t};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:t};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:t};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:t};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:t};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:t};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:t};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"};default:}}function Xe(t,e,r){r={offset:0,...r};for(let[n,s]of e.entries())if(r.mask){if(s!==(r.mask[n]&t[n+r.offset]))return!1}else if(s!==t[n+r.offset])return!1;return!0}var As,Ns,N1,I1,Gc=C(()=>{ur();Ec();Dc();Lc();Wc();zc();As=4100;Ns=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let r=e.position;for(let n of this.detectors){let s=await n.detect(e);if(s)return s;if(r!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let r=e instanceof Uint8Array?e:new Uint8Array(e);if(r?.length>1)return this.fromTokenizer(wc(r,this.tokenizerOptions))}async fromBlob(e){let r=bc(e,this.tokenizerOptions);try{return await this.fromTokenizer(r)}finally{await r.close()}}async fromStream(e){let r=xc(e,this.tokenizerOptions);try{return await this.fromTokenizer(r)}finally{await r.close()}}async toDetectionStream(e,r){let{sampleSize:n=As}=r,s,i,o=e.getReader({mode:"byob"});try{let{value:c,done:u}=await o.read(new Uint8Array(n));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,n))}catch(f){if(!(f instanceof ae))throw f;s=void 0}i=c}finally{o.releaseLock()}let a=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=e.pipeThrough(a);return l.fileType=s,l}check(e,r){return Xe(this.buffer,e,r)}checkString(e,r){return this.check(Mc(e,r?.encoding),r)}detectConfident=async e=>{if(this.buffer=new Uint8Array(As),e.fileInfo.size===void 0&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8])){let n=new mr(e).inflate(),s=!0;try{let i;try{i=await this.fromStream(n)}catch{s=!1}if(i&&i.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{s&&await n.cancel()}return{ext:"gz",mime:"application/gzip"}}if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);let r=await e.readToken(Bc);return e.position+r>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(r),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let r;return await new hr(e).unzip(n=>{switch(n.filename){case"META-INF/mozilla.rsa":return r={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return r={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(s){let i=new TextDecoder("utf-8").decode(s).trim();r=ks(i)},stop:!0};case"[Content_Types].xml":return{async handler(s){let i=new TextDecoder("utf-8").decode(s),o=i.indexOf('.main+xml"');if(o===-1){let a="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";i.includes(`ContentType="${a}"`)&&(r=ks(a))}else{i=i.slice(0,Math.max(0,o));let a=i.lastIndexOf('"'),l=i.slice(Math.max(0,a+1));r=ks(l)}},stop:!0};default:return/classes\d*\.dex/.test(n.filename)?(r={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(n=>{if(!(n instanceof ae))throw n}),r??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);let r=new Uint8Array(8);return await e.readBuffer(r),Xe(r,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:Xe(r,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:Xe(r,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:Xe(r,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:Xe(r,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:Xe(r,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){let r=await this.readTiffHeader(!1);if(r)return r}if(this.check([77,77])){let r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function r(){let a=await e.peekNumber(ac),l=128,c=0;for(;(a&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await e.readBuffer(u),u}async function n(){let a=await r(),l=await r();l[0]^=128>>l.length-1;let c=Math.min(6,l.length),u=new DataView(a.buffer),f=new DataView(l.buffer,l.length-c,c);return{id:Cs(u),len:Cs(f)}}async function s(a){for(;a>0;){let l=await n();if(l.id===17026)return(await e.readToken(new Fe(l.len))).replaceAll(/\00.*$/g,"");await e.ignore(l.len),--a}}let i=await n();switch(await s(i.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.checkString("regf"))return{ext:"dat",mime:"application/x-ft-windows-registry-hive"};if(this.checkString("$FL2")||this.checkString("$FL3"))return{ext:"sav",mime:"application/x-spss-sav"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){let r=new Fe(4,"latin1").get(this.buffer,2);if(r.match("^d*")&&r>=1e3&&r<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>"))return await e.ignore(8),await e.readToken(new Fe(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
514
+ `,"\r"," "," ","\0"].some(r=>this.checkString(r,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function r(){return{length:await e.readToken(cc),type:await e.readToken(new Fe(4,"latin1"))}}do{let n=await r();if(n.length<0)return;switch(n.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(n.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&(this.buffer[8]&96)!==0){let r=new Fe(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(r){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return r.startsWith("3g")?r.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
515
+ `))return{ext:"reg",mime:"application/x-ms-regedit"};if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function r(){let n=new Uint8Array(16);return await e.readBuffer(n),{id:n,size:Number(await e.readToken(uc))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let n=await r(),s=n.size-24;if(Xe(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let i=new Uint8Array(16);if(s-=await e.readBuffer(i),Xe(i,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(Xe(i,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(s)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new Fe(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.checkString("<?xml ",{offset:2,encoding:"utf-16be"})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){let r=new DataView(this.buffer.buffer).getUint32(12,!0);if(r>12&&this.buffer.length>=r+16)try{let n=new TextDecoder().decode(this.buffer.subarray(16,r+16));if(JSON.parse(n).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:"mxf",mime:"application/mxf"};if(this.checkString("SCRM",{offset:44}))return{ext:"s3m",mime:"audio/x-s3m"};if(this.check([71])&&this.check([71],{offset:188}))return{ext:"mts",mime:"video/mp2t"};if(this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:"mts",mime:"video/mp2t"};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:"mobi",mime:"application/x-mobipocket-ebook"};if(this.check([68,73,67,77],{offset:128}))return{ext:"dcm",mime:"application/dicom"};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:"lnk",mime:"application/x.ms.shortcut"};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:"alias",mime:"application/x.apple.alias"};if(this.checkString("Kaydara FBX Binary \0"))return{ext:"fbx",mime:"application/x.autodesk.fbx"};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:"eot",mime:"application/vnd.ms-fontobject"};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:"indd",mime:"application/x-indesign"};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:"jmp",mime:"application/x-jmp-data"};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&_c(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let r="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:r})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:r})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
516
+ `,{offset:2,encoding:r})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(As),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let r=0;r<=this.options.mpegOffsetTolerance;++r){let n=this.scanMpeg(r);if(n)return n}};async readTiffTag(e){let r=await this.tokenizer.readToken(e?Ht:pe);switch(this.tokenizer.ignore(10),r){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(e){let r=await this.tokenizer.readToken(e?Ht:pe);for(let n=0;n<r;++n){let s=await this.readTiffTag(e);if(s)return s}}async readTiffHeader(e){let r=(e?Ht:pe).get(this.buffer,2),n=(e?lc:ge).get(this.buffer,4);if(r===42){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){let i=(e?Ht:pe).get(this.buffer,8),o=(e?Ht:pe).get(this.buffer,10);if(i===28&&o===254||i===31&&o===11)return{ext:"nef",mime:"image/x-nikon-nef"}}}return await this.tokenizer.ignore(n),await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(r===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},N1=new Set(Uc),I1=new Set(jc)});var Kc={};R(Kc,{fileCommand:()=>fg});function ag(t,e){if(Vc[t])return Vc[t];let[r,n]=e.split("/"),s=n?.split("+")[0]?.replace(/-/g," ")||t;switch(r){case"image":return`${s.toUpperCase()} image data`;case"audio":return`${s.toUpperCase()} audio`;case"video":return`${s.toUpperCase()} video`;case"font":return`${s} font`;case"model":return`${s} 3D model`;case"application":return n?.includes("zip")||n?.includes("compressed")?`${s} archive data`:n?.includes("executable")?`${s} executable`:`${t.toUpperCase()} data`;default:return`${t.toUpperCase()} data`}}function lg(t){let e=t.split("/").pop()||t;if(e.startsWith(".")&&!e.includes(".",1))return e;let r=e.lastIndexOf(".");return r===-1||r===0?"":e.slice(r).toLowerCase()}function cg(t,e){if(t.startsWith("#!")){let l=t.split(`
517
517
  `)[0];return l.includes("python")?{description:"Python script, ASCII text executable",mime:"text/x-python"}:l.includes("node")||l.includes("bun")||l.includes("deno")?{description:"JavaScript script, ASCII text executable",mime:"text/javascript"}:l.includes("bash")?{description:"Bourne-Again shell script, ASCII text executable",mime:"text/x-shellscript"}:l.includes("sh")?{description:"POSIX shell script, ASCII text executable",mime:"text/x-shellscript"}:l.includes("ruby")?{description:"Ruby script, ASCII text executable",mime:"text/x-ruby"}:l.includes("perl")?{description:"Perl script, ASCII text executable",mime:"text/x-perl"}:{description:"script, ASCII text executable",mime:"text/plain"}}let r=t.trimStart();if(r.startsWith("<?xml"))return{description:"XML document",mime:"application/xml"};if(r.startsWith("<!DOCTYPE html")||r.toLowerCase().startsWith("<html"))return{description:"HTML document",mime:"text/html"};let n=t.includes(`\r
518
- `),s=t.includes("\r")&&!n,i="";n?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let o=eg(e);if(o&&_c[o]){let l=_c[o];return l.mime.startsWith("text/")&&i?{description:`${l.description}${i}`,mime:l.mime}:l}let a=!1;for(let l=0;l<Math.min(t.length,8192);l++)if(t.charCodeAt(l)>127){a=!0;break}return a?{description:`UTF-8 Unicode text${i}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${i}`,mime:"text/plain"}}async function rg(t,e){if(e.length===0)return{description:"empty",mime:"inode/x-empty"};let r=await Dc(e);if(r)return{description:Y0(r.ext,r.mime),mime:r.mime};let n=new TextDecoder("utf-8",{fatal:!1}).decode(e);return tg(n,t)}var J0,_c,Bc,ng,Uc=C(()=>{"use strict";Mc();O();J0={name:"file",summary:"determine file type",usage:"file [OPTION]... FILE...",options:["-b, --brief do not prepend filenames to output","-i, --mime output MIME type strings","-L, --dereference follow symlinks"," --help display this help and exit"]},_c={".js":{description:"JavaScript source",mime:"text/javascript"},".mjs":{description:"JavaScript module",mime:"text/javascript"},".cjs":{description:"CommonJS module",mime:"text/javascript"},".ts":{description:"TypeScript source",mime:"text/typescript"},".tsx":{description:"TypeScript JSX source",mime:"text/typescript"},".jsx":{description:"JavaScript JSX source",mime:"text/javascript"},".py":{description:"Python script",mime:"text/x-python"},".rb":{description:"Ruby script",mime:"text/x-ruby"},".go":{description:"Go source",mime:"text/x-go"},".rs":{description:"Rust source",mime:"text/x-rust"},".c":{description:"C source",mime:"text/x-c"},".h":{description:"C header",mime:"text/x-c"},".cpp":{description:"C++ source",mime:"text/x-c++"},".hpp":{description:"C++ header",mime:"text/x-c++"},".java":{description:"Java source",mime:"text/x-java"},".sh":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".bash":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".zsh":{description:"Zsh shell script",mime:"text/x-shellscript"},".json":{description:"JSON data",mime:"application/json"},".yaml":{description:"YAML data",mime:"text/yaml"},".yml":{description:"YAML data",mime:"text/yaml"},".xml":{description:"XML document",mime:"application/xml"},".csv":{description:"CSV text",mime:"text/csv"},".toml":{description:"TOML data",mime:"text/toml"},".html":{description:"HTML document",mime:"text/html"},".htm":{description:"HTML document",mime:"text/html"},".css":{description:"CSS stylesheet",mime:"text/css"},".svg":{description:"SVG image",mime:"image/svg+xml"},".md":{description:"Markdown document",mime:"text/markdown"},".markdown":{description:"Markdown document",mime:"text/markdown"},".txt":{description:"ASCII text",mime:"text/plain"},".rst":{description:"reStructuredText",mime:"text/x-rst"},".env":{description:"ASCII text",mime:"text/plain"},".gitignore":{description:"ASCII text",mime:"text/plain"},".dockerignore":{description:"ASCII text",mime:"text/plain"}},Bc={jpg:"JPEG image data",jpeg:"JPEG image data",png:"PNG image data",gif:"GIF image data",webp:"WebP image data",bmp:"PC bitmap",ico:"MS Windows icon resource",tif:"TIFF image data",tiff:"TIFF image data",psd:"Adobe Photoshop Document",avif:"AVIF image",heic:"HEIC image",heif:"HEIF image",jxl:"JPEG XL image",icns:"Mac OS X icon",svg:"SVG Scalable Vector Graphics image",pdf:"PDF document",epub:"EPUB document",mobi:"Mobipocket E-book",djvu:"DjVu document",zip:"Zip archive data",gz:"gzip compressed data",gzip:"gzip compressed data",bz2:"bzip2 compressed data",xz:"XZ compressed data",tar:"POSIX tar archive",rar:"RAR archive data","7z":"7-zip archive data",lz:"lzip compressed data",lzma:"LZMA compressed data",zst:"Zstandard compressed data",cab:"Microsoft Cabinet archive",ar:"Unix ar archive",rpm:"RPM package",deb:"Debian binary package",apk:"Android Package",dmg:"Apple disk image",iso:"ISO 9660 CD-ROM filesystem data",vhd:"Microsoft Virtual Hard Disk",vhdx:"Microsoft Virtual Hard Disk (new format)",qcow2:"QEMU QCOW Image",mp3:"Audio file with ID3",m4a:"MPEG-4 audio",aac:"AAC audio",wav:"RIFF (little-endian) data, WAVE audio",flac:"FLAC audio bitstream data",ogg:"Ogg data",oga:"Ogg audio",opus:"Ogg Opus audio",aiff:"AIFF audio",wma:"Windows Media Audio",amr:"AMR audio",mid:"MIDI audio",midi:"MIDI audio",ape:"Monkey's Audio",mp4:"ISO Media, MPEG-4",m4v:"MPEG-4 video",webm:"WebM",avi:"RIFF (little-endian) data, AVI",mov:"ISO Media, Apple QuickTime movie",mkv:"Matroska data",wmv:"Windows Media Video",flv:"Flash Video","3gp":"3GPP multimedia","3g2":"3GPP2 multimedia",ogv:"Ogg video",mts:"MPEG transport stream",m2ts:"MPEG transport stream",ts:"MPEG transport stream",mpg:"MPEG video",mpeg:"MPEG video",exe:"PE32 executable",dll:"PE32 DLL",elf:"ELF executable",mach:"Mach-O executable",wasm:"WebAssembly (wasm) binary module",dex:"Android Dalvik executable",class:"Java class file",swf:"Adobe Flash",doc:"Microsoft Word Document",docx:"Microsoft Word 2007+ Document",xls:"Microsoft Excel Spreadsheet",xlsx:"Microsoft Excel 2007+ Spreadsheet",ppt:"Microsoft PowerPoint Presentation",pptx:"Microsoft PowerPoint 2007+ Presentation",odt:"OpenDocument Text",ods:"OpenDocument Spreadsheet",odp:"OpenDocument Presentation",ttf:"TrueType Font",otf:"OpenType Font",woff:"Web Open Font Format",woff2:"Web Open Font Format 2",eot:"Embedded OpenType font",stl:"Stereolithography CAD",obj:"Wavefront 3D Object",gltf:"GL Transmission Format",glb:"GL Transmission Format (binary)",sqlite:"SQLite 3.x database",mdb:"Microsoft Access Database",xml:"XML document",json:"JSON data",macho:"Mach-O binary",ics:"iCalendar data",vcf:"vCard data",msi:"Microsoft Installer",ps:"PostScript",ai:"Adobe Illustrator",indd:"Adobe InDesign",sketch:"Sketch design file",fig:"Figma design file",xd:"Adobe XD",blend:"Blender",fbx:"Autodesk FBX",lnk:"MS Windows shortcut",alias:"Mac OS alias",torrent:"BitTorrent file",pcap:"pcap capture file",arrow:"Apache Arrow",parquet:"Apache Parquet"};ng={name:"file",async execute(t,e){if(I(t))return N(J0);let r=!1,n=!1,s=[];for(let a of t)if(a.startsWith("--")){if(a==="--brief")r=!0;else if(a==="--mime"||a==="--mime-type")n=!0;else if(a!=="--dereference")return $("file",a)}else if(a.startsWith("-")&&a!=="-"){for(let l of a.slice(1))if(l==="b")r=!0;else if(l==="i")n=!0;else if(l!=="L")return $("file",`-${l}`)}else s.push(a);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
519
- `,exitCode:1};let i="",o=0;for(let a of s)try{let l=e.fs.resolvePath(e.cwd,a);if((await e.fs.stat(l)).isDirectory){let p=n?"inode/directory":"directory";i+=r?`${p}
520
- `:`${a}: ${p}
521
- `;continue}let u=await e.fs.readFileBuffer(l),f=await rg(a,u),d=n?f.mime:f.description;i+=r?`${d}
518
+ `),s=t.includes("\r")&&!n,i="";n?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let o=lg(e);if(o&&qc[o]){let l=qc[o];return l.mime.startsWith("text/")&&i?{description:`${l.description}${i}`,mime:l.mime}:l}let a=!1;for(let l=0;l<Math.min(t.length,8192);l++)if(t.charCodeAt(l)>127){a=!0;break}return a?{description:`UTF-8 Unicode text${i}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${i}`,mime:"text/plain"}}async function ug(t,e){if(e.length===0)return{description:"empty",mime:"inode/x-empty"};let r=await Hc(e);if(r)return{description:ag(r.ext,r.mime),mime:r.mime};let n=new TextDecoder("utf-8",{fatal:!1}).decode(e);return cg(n,t)}var og,qc,Vc,fg,Zc=C(()=>{"use strict";Gc();L();og={name:"file",summary:"determine file type",usage:"file [OPTION]... FILE...",options:["-b, --brief do not prepend filenames to output","-i, --mime output MIME type strings","-L, --dereference follow symlinks"," --help display this help and exit"]},qc={".js":{description:"JavaScript source",mime:"text/javascript"},".mjs":{description:"JavaScript module",mime:"text/javascript"},".cjs":{description:"CommonJS module",mime:"text/javascript"},".ts":{description:"TypeScript source",mime:"text/typescript"},".tsx":{description:"TypeScript JSX source",mime:"text/typescript"},".jsx":{description:"JavaScript JSX source",mime:"text/javascript"},".py":{description:"Python script",mime:"text/x-python"},".rb":{description:"Ruby script",mime:"text/x-ruby"},".go":{description:"Go source",mime:"text/x-go"},".rs":{description:"Rust source",mime:"text/x-rust"},".c":{description:"C source",mime:"text/x-c"},".h":{description:"C header",mime:"text/x-c"},".cpp":{description:"C++ source",mime:"text/x-c++"},".hpp":{description:"C++ header",mime:"text/x-c++"},".java":{description:"Java source",mime:"text/x-java"},".sh":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".bash":{description:"Bourne-Again shell script",mime:"text/x-shellscript"},".zsh":{description:"Zsh shell script",mime:"text/x-shellscript"},".json":{description:"JSON data",mime:"application/json"},".yaml":{description:"YAML data",mime:"text/yaml"},".yml":{description:"YAML data",mime:"text/yaml"},".xml":{description:"XML document",mime:"application/xml"},".csv":{description:"CSV text",mime:"text/csv"},".toml":{description:"TOML data",mime:"text/toml"},".html":{description:"HTML document",mime:"text/html"},".htm":{description:"HTML document",mime:"text/html"},".css":{description:"CSS stylesheet",mime:"text/css"},".svg":{description:"SVG image",mime:"image/svg+xml"},".md":{description:"Markdown document",mime:"text/markdown"},".markdown":{description:"Markdown document",mime:"text/markdown"},".txt":{description:"ASCII text",mime:"text/plain"},".rst":{description:"reStructuredText",mime:"text/x-rst"},".env":{description:"ASCII text",mime:"text/plain"},".gitignore":{description:"ASCII text",mime:"text/plain"},".dockerignore":{description:"ASCII text",mime:"text/plain"}},Vc={jpg:"JPEG image data",jpeg:"JPEG image data",png:"PNG image data",gif:"GIF image data",webp:"WebP image data",bmp:"PC bitmap",ico:"MS Windows icon resource",tif:"TIFF image data",tiff:"TIFF image data",psd:"Adobe Photoshop Document",avif:"AVIF image",heic:"HEIC image",heif:"HEIF image",jxl:"JPEG XL image",icns:"Mac OS X icon",svg:"SVG Scalable Vector Graphics image",pdf:"PDF document",epub:"EPUB document",mobi:"Mobipocket E-book",djvu:"DjVu document",zip:"Zip archive data",gz:"gzip compressed data",gzip:"gzip compressed data",bz2:"bzip2 compressed data",xz:"XZ compressed data",tar:"POSIX tar archive",rar:"RAR archive data","7z":"7-zip archive data",lz:"lzip compressed data",lzma:"LZMA compressed data",zst:"Zstandard compressed data",cab:"Microsoft Cabinet archive",ar:"Unix ar archive",rpm:"RPM package",deb:"Debian binary package",apk:"Android Package",dmg:"Apple disk image",iso:"ISO 9660 CD-ROM filesystem data",vhd:"Microsoft Virtual Hard Disk",vhdx:"Microsoft Virtual Hard Disk (new format)",qcow2:"QEMU QCOW Image",mp3:"Audio file with ID3",m4a:"MPEG-4 audio",aac:"AAC audio",wav:"RIFF (little-endian) data, WAVE audio",flac:"FLAC audio bitstream data",ogg:"Ogg data",oga:"Ogg audio",opus:"Ogg Opus audio",aiff:"AIFF audio",wma:"Windows Media Audio",amr:"AMR audio",mid:"MIDI audio",midi:"MIDI audio",ape:"Monkey's Audio",mp4:"ISO Media, MPEG-4",m4v:"MPEG-4 video",webm:"WebM",avi:"RIFF (little-endian) data, AVI",mov:"ISO Media, Apple QuickTime movie",mkv:"Matroska data",wmv:"Windows Media Video",flv:"Flash Video","3gp":"3GPP multimedia","3g2":"3GPP2 multimedia",ogv:"Ogg video",mts:"MPEG transport stream",m2ts:"MPEG transport stream",ts:"MPEG transport stream",mpg:"MPEG video",mpeg:"MPEG video",exe:"PE32 executable",dll:"PE32 DLL",elf:"ELF executable",mach:"Mach-O executable",wasm:"WebAssembly (wasm) binary module",dex:"Android Dalvik executable",class:"Java class file",swf:"Adobe Flash",doc:"Microsoft Word Document",docx:"Microsoft Word 2007+ Document",xls:"Microsoft Excel Spreadsheet",xlsx:"Microsoft Excel 2007+ Spreadsheet",ppt:"Microsoft PowerPoint Presentation",pptx:"Microsoft PowerPoint 2007+ Presentation",odt:"OpenDocument Text",ods:"OpenDocument Spreadsheet",odp:"OpenDocument Presentation",ttf:"TrueType Font",otf:"OpenType Font",woff:"Web Open Font Format",woff2:"Web Open Font Format 2",eot:"Embedded OpenType font",stl:"Stereolithography CAD",obj:"Wavefront 3D Object",gltf:"GL Transmission Format",glb:"GL Transmission Format (binary)",sqlite:"SQLite 3.x database",mdb:"Microsoft Access Database",xml:"XML document",json:"JSON data",macho:"Mach-O binary",ics:"iCalendar data",vcf:"vCard data",msi:"Microsoft Installer",ps:"PostScript",ai:"Adobe Illustrator",indd:"Adobe InDesign",sketch:"Sketch design file",fig:"Figma design file",xd:"Adobe XD",blend:"Blender",fbx:"Autodesk FBX",lnk:"MS Windows shortcut",alias:"Mac OS alias",torrent:"BitTorrent file",pcap:"pcap capture file",arrow:"Apache Arrow",parquet:"Apache Parquet"};fg={name:"file",async execute(t,e){if(N(t))return k(og);let r=!1,n=!1,s=[];for(let a of t)if(a.startsWith("--")){if(a==="--brief")r=!0;else if(a==="--mime"||a==="--mime-type")n=!0;else if(a!=="--dereference")return P("file",a)}else if(a.startsWith("-")&&a!=="-"){for(let l of a.slice(1))if(l==="b")r=!0;else if(l==="i")n=!0;else if(l!=="L")return P("file",`-${l}`)}else s.push(a);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
519
+ `,exitCode:1};let i="",o=0;for(let a of s)try{let l=e.fs.resolvePath(e.cwd,a);if((await e.fs.stat(l)).isDirectory){let d=n?"inode/directory":"directory";i+=r?`${d}
522
520
  `:`${a}: ${d}
521
+ `;continue}let u=await e.fs.readFileBuffer(l),f=await ug(a,u),p=n?f.mime:f.description;i+=r?`${p}
522
+ `:`${a}: ${p}
523
523
  `}catch{i+=r?`cannot open
524
524
  `:`${a}: cannot open (No such file or directory)
525
- `,o=1}return{stdout:i,stderr:"",exitCode:o}}}});var jc={};v(jc,{htmlToMarkdownCommand:()=>og});import sg from"turndown";var ig,og,zc=C(()=>{"use strict";O();ig={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 ![alt](src)"," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '<h1>Hello</h1><p>World</p>' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},og={name:"html-to-markdown",async execute(t,e){if(I(t))return N(ig);let r="-",n="```",s="---",i="atx",o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-b"||c==="--bullet")r=t[++l]??"-";else if(c.startsWith("--bullet="))r=c.slice(9);else if(c==="-c"||c==="--code")n=t[++l]??"```";else if(c.startsWith("--code="))n=c.slice(7);else if(c==="-r"||c==="--hr")s=t[++l]??"---";else if(c.startsWith("--hr="))s=c.slice(5);else if(c.startsWith("--heading-style=")){let u=c.slice(16);(u==="setext"||u==="atx")&&(i=u)}else if(c==="-")o.push("-");else{if(c.startsWith("--"))return $("html-to-markdown",c);if(c.startsWith("-"))return $("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=e.stdin;else try{let l=e.fs.resolvePath(e.cwd,o[0]);a=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
526
- `,exitCode:1}}if(!a.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new sg({bulletListMarker:r,codeBlockStyle:"fenced",fence:n,hr:s,headingStyle:i});return l.remove(["script","style","footer"]),{stdout:`${l.turndown(a).trim()}
525
+ `,o=1}return{stdout:i,stderr:"",exitCode:o}}}});var Qc={};R(Qc,{htmlToMarkdownCommand:()=>hg});import pg from"turndown";var dg,hg,Xc=C(()=>{"use strict";L();dg={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 ![alt](src)"," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '<h1>Hello</h1><p>World</p>' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},hg={name:"html-to-markdown",async execute(t,e){if(N(t))return k(dg);let r="-",n="```",s="---",i="atx",o=[];for(let l=0;l<t.length;l++){let c=t[l];if(c==="-b"||c==="--bullet")r=t[++l]??"-";else if(c.startsWith("--bullet="))r=c.slice(9);else if(c==="-c"||c==="--code")n=t[++l]??"```";else if(c.startsWith("--code="))n=c.slice(7);else if(c==="-r"||c==="--hr")s=t[++l]??"---";else if(c.startsWith("--hr="))s=c.slice(5);else if(c.startsWith("--heading-style=")){let u=c.slice(16);(u==="setext"||u==="atx")&&(i=u)}else if(c==="-")o.push("-");else{if(c.startsWith("--"))return P("html-to-markdown",c);if(c.startsWith("-"))return P("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=e.stdin;else try{let l=e.fs.resolvePath(e.cwd,o[0]);a=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
526
+ `,exitCode:1}}if(!a.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new pg({bulletListMarker:r,codeBlockStyle:"fenced",fence:n,hr:s,headingStyle:i});return l.remove(["script","style","footer"]),{stdout:`${l.turndown(a).trim()}
527
527
  `,stderr:"",exitCode:0}}catch(l){return{stdout:"",stderr:`html-to-markdown: conversion error: ${l.message}
528
- `,exitCode:1}}}}});var Hc={};v(Hc,{helpCommand:()=>cg});function lg(t){let e=[],r=new Set(t);e.push(`Available commands:
529
- `);let n=[];for(let[s,i]of Object.entries(ag)){let o=i.filter(a=>r.has(a));if(o.length>0){e.push(` ${s}:`),e.push(` ${o.join(", ")}
528
+ `,exitCode:1}}}}});var Jc={};R(Jc,{helpCommand:()=>yg});function gg(t){let e=[],r=new Set(t);e.push(`Available commands:
529
+ `);let n=[];for(let[s,i]of Object.entries(mg)){let o=i.filter(a=>r.has(a));if(o.length>0){e.push(` ${s}:`),e.push(` ${o.join(", ")}
530
530
  `);for(let a of o)r.delete(a)}}for(let s of r)n.push(s);return n.length>0&&(e.push(" Other:"),e.push(` ${n.sort().join(", ")}
531
531
  `)),e.push("Use '<command> --help' for details on a specific command."),`${e.join(`
532
532
  `)}
533
- `}var ag,cg,Gc=C(()=>{"use strict";ag={"File operations":["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"],"Text processing":["grep","sed","awk","sort","uniq","cut","tr","tee","diff"],Search:["find"],"Navigation & paths":["pwd","basename","dirname","tree","du"],"Environment & shell":["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"],"Data processing":["xargs","jq","base64","date"],Network:["curl","html-to-markdown"]};cg={name:"help",async execute(t,e){if(t.includes("--help")||t.includes("-h"))return{stdout:`help - display available commands
533
+ `}var mg,yg,Yc=C(()=>{"use strict";mg={"File operations":["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"],"Text processing":["grep","sed","awk","sort","uniq","cut","tr","tee","diff"],Search:["find"],"Navigation & paths":["pwd","basename","dirname","tree","du"],"Environment & shell":["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"],"Data processing":["xargs","jq","base64","date"],Network:["curl","html-to-markdown"]};yg={name:"help",async execute(t,e){if(t.includes("--help")||t.includes("-h"))return{stdout:`help - display available commands
534
534
 
535
535
  Usage: help [command]
536
536
 
@@ -539,149 +539,149 @@ Options:
539
539
 
540
540
  If a command name is provided, shows help for that command.
541
541
  Otherwise, lists all available commands.
542
- `,stderr:"",exitCode:0};if(t.length>0&&e.exec){let n=t[0];return e.exec(`${n} --help`,{cwd:e.cwd})}let r=e.getRegisteredCommands?.()??[];return{stdout:lg(r),stderr:"",exitCode:0}}}});var qc={};v(qc,{whichCommand:()=>dg});var ug,fg,dg,Vc=C(()=>{"use strict";ae();O();ug={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},fg={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},dg={name:"which",async execute(t,e){if(I(t))return N(ug);let r=j("which",t,fg);if(!r.ok)return r.error;let n=r.result.flags.showAll,s=r.result.flags.silent,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:"",exitCode:1};let a=(e.env.PATH||"/bin:/usr/bin").split(":"),l="",c=!0;for(let u of i){let f=!1;for(let d of a){if(!d)continue;let p=`${d}/${u}`;if(await e.fs.exists(p)&&(f=!0,s||(l+=`${p}
543
- `),!n))break}f||(c=!1)}return{stdout:l,stderr:"",exitCode:c?0:1}}}});var Kc={};v(Kc,{tac:()=>hg});async function pg(t,e){if(t.length>0&&t[0]!=="-"){let s=t[0].startsWith("/")?t[0]:`${e.cwd}/${t[0]}`;try{let o=(await e.fs.readFile(s)).split(`
542
+ `,stderr:"",exitCode:0};if(t.length>0&&e.exec){let n=t[0];return e.exec(`${n} --help`,{cwd:e.cwd})}let r=e.getRegisteredCommands?.()??[];return{stdout:gg(r),stderr:"",exitCode:0}}}});var eu={};R(eu,{whichCommand:()=>bg});var xg,wg,bg,tu=C(()=>{"use strict";ye();L();xg={name:"which",summary:"locate a command",usage:"which [-as] program ...",options:["-a List all instances of executables found","-s No output, just return 0 if found, 1 if not","--help display this help and exit"]},wg={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},bg={name:"which",async execute(t,e){if(N(t))return k(xg);let r=z("which",t,wg);if(!r.ok)return r.error;let n=r.result.flags.showAll,s=r.result.flags.silent,i=r.result.positional;if(i.length===0)return{stdout:"",stderr:"",exitCode:1};let a=(e.env.PATH||"/bin:/usr/bin").split(":"),l="",c=!0;for(let u of i){let f=!1;for(let p of a){if(!p)continue;let d=`${p}/${u}`;if(await e.fs.exists(d)&&(f=!0,s||(l+=`${d}
543
+ `),!n))break}f||(c=!1)}return{stdout:l,stderr:"",exitCode:c?0:1}}}});var ru={};R(ru,{tac:()=>Sg});async function Eg(t,e){if(t.length>0&&t[0]!=="-"){let s=t[0].startsWith("/")?t[0]:`${e.cwd}/${t[0]}`;try{let o=(await e.fs.readFile(s)).split(`
544
544
  `);o[o.length-1]===""&&o.pop();let a=o.reverse();return{stdout:a.length>0?`${a.join(`
545
545
  `)}
546
546
  `:"",stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`tac: ${t[0]}: No such file or directory
547
547
  `,exitCode:1}}}let r=e.stdin.split(`
548
548
  `);r[r.length-1]===""&&r.pop();let n=r.reverse();return{stdout:n.length>0?`${n.join(`
549
549
  `)}
550
- `:"",stderr:"",exitCode:0}}var hg,Zc=C(()=>{"use strict";hg={name:"tac",execute:pg}});var Qc={};v(Qc,{hostname:()=>gg});async function mg(t,e){return{stdout:`localhost
551
- `,stderr:"",exitCode:0}}var gg,Xc=C(()=>{"use strict";gg={name:"hostname",execute:mg}});var Jc={};v(Jc,{od:()=>xg});async function yg(t,e){let r=t.includes("-c"),n=t.includes("-An")?"none":"octal",s=e.stdin,i=t.filter(l=>!l.startsWith("-")&&l!=="-");if(i.length>0){let l=i[0].startsWith("/")?i[0]:`${e.cwd}/${i[0]}`;try{s=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`od: ${i[0]}: No such file or directory
552
- `,exitCode:1}}}if(r){let l=[];for(let u of s){let f=u.charCodeAt(0);f===0?l.push("\\0"):f===9?l.push("\\t"):f===10?l.push("\\n"):f===13?l.push("\\r"):f===32?l.push(" "):f>=32&&f<127?l.push(` ${u}`):l.push(`\\${f.toString(8).padStart(3,"0")}`)}let c=[];for(let u=0;u<l.length;u+=16){let f=l.slice(u,u+16),d=n==="none"?"":`${u.toString(8).padStart(7,"0")} `;c.push(d+f.join(" "))}return n!=="none"&&c.push(s.length.toString(8).padStart(7,"0")),{stdout:`${c.join(`
550
+ `:"",stderr:"",exitCode:0}}var Sg,nu=C(()=>{"use strict";Sg={name:"tac",execute:Eg}});var su={};R(su,{hostname:()=>Ag});async function Cg(t,e){return{stdout:`localhost
551
+ `,stderr:"",exitCode:0}}var Ag,iu=C(()=>{"use strict";Ag={name:"hostname",execute:Cg}});var ou={};R(ou,{od:()=>Ng});async function kg(t,e){let r=t.includes("-c"),n=t.includes("-An")?"none":"octal",s=e.stdin,i=t.filter(l=>!l.startsWith("-")&&l!=="-");if(i.length>0){let l=i[0].startsWith("/")?i[0]:`${e.cwd}/${i[0]}`;try{s=await e.fs.readFile(l)}catch{return{stdout:"",stderr:`od: ${i[0]}: No such file or directory
552
+ `,exitCode:1}}}if(r){let l=[];for(let u of s){let f=u.charCodeAt(0);f===0?l.push("\\0"):f===9?l.push("\\t"):f===10?l.push("\\n"):f===13?l.push("\\r"):f===32?l.push(" "):f>=32&&f<127?l.push(` ${u}`):l.push(`\\${f.toString(8).padStart(3,"0")}`)}let c=[];for(let u=0;u<l.length;u+=16){let f=l.slice(u,u+16),p=n==="none"?"":`${u.toString(8).padStart(7,"0")} `;c.push(p+f.join(" "))}return n!=="none"&&c.push(s.length.toString(8).padStart(7,"0")),{stdout:`${c.join(`
553
553
  `)}
554
554
  `,stderr:"",exitCode:0}}let o=[];for(let l of s)o.push(l.charCodeAt(0).toString(8).padStart(3,"0"));let a=[];for(let l=0;l<o.length;l+=8){let c=o.slice(l,l+8),u=n==="none"?"":`${l.toString(8).padStart(7,"0")} `;a.push(u+c.join(" "))}return n!=="none"&&o.length>0&&a.push(s.length.toString(8).padStart(7,"0")),{stdout:a.length>0?`${a.join(`
555
555
  `)}
556
- `:"",stderr:"",exitCode:0}}var xg,Yc=C(()=>{"use strict";xg={name:"od",execute:yg}});var Kr={};v(Kr,{gunzipCommand:()=>Ig,gzipCommand:()=>Ng,zcatCommand:()=>vg});import{constants as ws,gunzipSync as bs,gzipSync as eu}from"node:zlib";function tu(t){return t.best?ws.Z_BEST_COMPRESSION:t.level8?8:t.level7?7:t.level6?6:t.level5?5:t.level4?4:t.level3?3:t.level2?2:t.fast?ws.Z_BEST_SPEED:ws.Z_DEFAULT_COMPRESSION}function ru(t){if(t.length<10)return{originalName:null,mtime:null,headerSize:0};if(t[0]!==31||t[1]!==139)return{originalName:null,mtime:null,headerSize:0};let e=t[3],r=t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n=10;if(e&4){if(n+2>t.length)return{originalName:null,mtime:null,headerSize:0};let i=t[n]|t[n+1]<<8;n+=2+i}let s=null;if(e&8){let i=n;for(;n<t.length&&t[n]!==0;)n++;n<t.length&&(s=new TextDecoder().decode(t.slice(i,n)),n++)}if(e&16){for(;n<t.length&&t[n]!==0;)n++;n++}return e&2&&(n+=2),{originalName:s,mtime:r>0?new Date(r*1e3):null,headerSize:n}}function Cg(t){if(t.length<4)return 0;let e=t.length;return t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24}function Vr(t){return t.length>=2&&t[0]===31&&t[1]===139}async function nu(t,e,r,n,s,i){let o=r.suffix,a,l,c;if(e==="-"||e==="")if(c=new TextEncoder().encode(t.stdin),s){if(!Vr(c))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: stdin: not in gzip format
557
- `,exitCode:1};try{let u=bs(c);return{stdout:new TextDecoder().decode(u),stderr:"",exitCode:0}}catch(u){let f=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`${n}: stdin: ${f}
558
- `,exitCode:1}}}else{let u=tu(r),f=eu(c,{level:u});return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0}}a=t.fs.resolvePath(t.cwd,e);try{if((await t.fs.stat(a)).isDirectory)return r.recursive?await su(t,a,r,n,s,i):r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: is a directory -- ignored
556
+ `:"",stderr:"",exitCode:0}}var Ng,au=C(()=>{"use strict";Ng={name:"od",execute:kg}});var sn={};R(sn,{gunzipCommand:()=>Dg,gzipCommand:()=>Tg,zcatCommand:()=>Lg});import{constants as Is,gunzipSync as vs,gzipSync as lu}from"node:zlib";function cu(t){return t.best?Is.Z_BEST_COMPRESSION:t.level8?8:t.level7?7:t.level6?6:t.level5?5:t.level4?4:t.level3?3:t.level2?2:t.fast?Is.Z_BEST_SPEED:Is.Z_DEFAULT_COMPRESSION}function uu(t){if(t.length<10)return{originalName:null,mtime:null,headerSize:0};if(t[0]!==31||t[1]!==139)return{originalName:null,mtime:null,headerSize:0};let e=t[3],r=t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n=10;if(e&4){if(n+2>t.length)return{originalName:null,mtime:null,headerSize:0};let i=t[n]|t[n+1]<<8;n+=2+i}let s=null;if(e&8){let i=n;for(;n<t.length&&t[n]!==0;)n++;n<t.length&&(s=new TextDecoder().decode(t.slice(i,n)),n++)}if(e&16){for(;n<t.length&&t[n]!==0;)n++;n++}return e&2&&(n+=2),{originalName:s,mtime:r>0?new Date(r*1e3):null,headerSize:n}}function Pg(t){if(t.length<4)return 0;let e=t.length;return t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24}function nn(t){return t.length>=2&&t[0]===31&&t[1]===139}async function fu(t,e,r,n,s,i){let o=r.suffix,a,l,c;if(e==="-"||e==="")if(c=new TextEncoder().encode(t.stdin),s){if(!nn(c))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: stdin: not in gzip format
557
+ `,exitCode:1};try{let u=vs(c);return{stdout:new TextDecoder().decode(u),stderr:"",exitCode:0}}catch(u){let f=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`${n}: stdin: ${f}
558
+ `,exitCode:1}}}else{let u=cu(r),f=lu(c,{level:u});return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0}}a=t.fs.resolvePath(t.cwd,e);try{if((await t.fs.stat(a)).isDirectory)return r.recursive?await pu(t,a,r,n,s,i):r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: is a directory -- ignored
559
559
  `,exitCode:1}}catch{return{stdout:"",stderr:`${n}: ${e}: No such file or directory
560
560
  `,exitCode:1}}try{c=await t.fs.readFileBuffer(a)}catch{return{stdout:"",stderr:`${n}: ${e}: No such file or directory
561
561
  `,exitCode:1}}if(s){if(!e.endsWith(o))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: unknown suffix -- ignored
562
- `,exitCode:1};if(!Vr(c))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: not in gzip format
563
- `,exitCode:1};let u;try{u=bs(c)}catch(f){let d=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`${n}: ${e}: ${d}
564
- `,exitCode:1}}if(i)return{stdout:new TextDecoder().decode(u),stderr:"",exitCode:0};if(r.name){let f=ru(c);f.originalName?l=t.fs.resolvePath(t.cwd,f.originalName):l=a.slice(0,-o.length)}else l=a.slice(0,-o.length);if(!r.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${n}: ${l} already exists; not overwritten
562
+ `,exitCode:1};if(!nn(c))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: not in gzip format
563
+ `,exitCode:1};let u;try{u=vs(c)}catch(f){let p=f instanceof Error?f.message:"unknown error";return{stdout:"",stderr:`${n}: ${e}: ${p}
564
+ `,exitCode:1}}if(i)return{stdout:new TextDecoder().decode(u),stderr:"",exitCode:0};if(r.name){let f=uu(c);f.originalName?l=t.fs.resolvePath(t.cwd,f.originalName):l=a.slice(0,-o.length)}else l=a.slice(0,-o.length);if(!r.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${n}: ${l} already exists; not overwritten
565
565
  `,exitCode:1}}catch{}if(await t.fs.writeFile(l,u),!r.keep&&!i&&await t.fs.rm(a),r.verbose){let f=c.length>0?((1-c.length/u.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${e}: ${f}% -- replaced with ${l.split("/").pop()}
566
566
  `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}else{if(e.endsWith(o))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e} already has ${o} suffix -- unchanged
567
- `,exitCode:1};let u=tu(r),f;try{f=eu(c,{level:u})}catch(d){let p=d instanceof Error?d.message:"unknown error";return{stdout:"",stderr:`${n}: ${e}: ${p}
567
+ `,exitCode:1};let u=cu(r),f;try{f=lu(c,{level:u})}catch(p){let d=p instanceof Error?p.message:"unknown error";return{stdout:"",stderr:`${n}: ${e}: ${d}
568
568
  `,exitCode:1}}if(i)return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0};if(l=a+o,!r.force)try{return await t.fs.stat(l),{stdout:"",stderr:`${n}: ${l} already exists; not overwritten
569
- `,exitCode:1}}catch{}if(await t.fs.writeFile(l,f),!r.keep&&!i&&await t.fs.rm(a),r.verbose){let d=c.length>0?((1-f.length/c.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${e}: ${d}% -- replaced with ${l.split("/").pop()}
570
- `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function su(t,e,r,n,s,i){let o=await t.fs.readdir(e),a="",l="",c=0;for(let u of o){let f=t.fs.resolvePath(e,u),d=await t.fs.stat(f);if(d.isDirectory){let p=await su(t,f,r,n,s,i);a+=p.stdout,l+=p.stderr,p.exitCode!==0&&(c=p.exitCode)}else if(d.isFile){let p=r.suffix;if(s&&!u.endsWith(p)||!s&&u.endsWith(p))continue;let h=f.startsWith(`${t.cwd}/`)?f.slice(t.cwd.length+1):f,y=await nu(t,h,r,n,s,i);a+=y.stdout,l+=y.stderr,y.exitCode!==0&&(c=y.exitCode)}}return{stdout:a,stderr:l,exitCode:c}}async function Ag(t,e,r,n){let s;if(e==="-"||e==="")s=new TextEncoder().encode(t.stdin);else{let f=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${n}: ${e}: No such file or directory
571
- `,exitCode:1}}}if(!Vr(s))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: not in gzip format
572
- `,exitCode:1};let i=s.length,o=Cg(s),a=o>0?((1-i/o)*100).toFixed(1):"0.0",c=ru(s).originalName||(e==="-"?"":e.replace(/\.gz$/,""));return{stdout:`${i.toString().padStart(10)} ${o.toString().padStart(10)} ${a.padStart(5)}% ${c}
573
- `,stderr:"",exitCode:0}}async function kg(t,e,r,n){let s;if(e==="-"||e==="")s=new TextEncoder().encode(t.stdin);else{let i=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${n}: ${e}: No such file or directory
574
- `,exitCode:1}}}if(!Vr(s))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: not in gzip format
575
- `,exitCode:1};try{return bs(s),r.verbose?{stdout:"",stderr:`${e}: OK
569
+ `,exitCode:1}}catch{}if(await t.fs.writeFile(l,f),!r.keep&&!i&&await t.fs.rm(a),r.verbose){let p=c.length>0?((1-f.length/c.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${e}: ${p}% -- replaced with ${l.split("/").pop()}
570
+ `,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function pu(t,e,r,n,s,i){let o=await t.fs.readdir(e),a="",l="",c=0;for(let u of o){let f=t.fs.resolvePath(e,u),p=await t.fs.stat(f);if(p.isDirectory){let d=await pu(t,f,r,n,s,i);a+=d.stdout,l+=d.stderr,d.exitCode!==0&&(c=d.exitCode)}else if(p.isFile){let d=r.suffix;if(s&&!u.endsWith(d)||!s&&u.endsWith(d))continue;let h=f.startsWith(`${t.cwd}/`)?f.slice(t.cwd.length+1):f,m=await fu(t,h,r,n,s,i);a+=m.stdout,l+=m.stderr,m.exitCode!==0&&(c=m.exitCode)}}return{stdout:a,stderr:l,exitCode:c}}async function Fg(t,e,r,n){let s;if(e==="-"||e==="")s=new TextEncoder().encode(t.stdin);else{let f=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${n}: ${e}: No such file or directory
571
+ `,exitCode:1}}}if(!nn(s))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: not in gzip format
572
+ `,exitCode:1};let i=s.length,o=Pg(s),a=o>0?((1-i/o)*100).toFixed(1):"0.0",c=uu(s).originalName||(e==="-"?"":e.replace(/\.gz$/,""));return{stdout:`${i.toString().padStart(10)} ${o.toString().padStart(10)} ${a.padStart(5)}% ${c}
573
+ `,stderr:"",exitCode:0}}async function Og(t,e,r,n){let s;if(e==="-"||e==="")s=new TextEncoder().encode(t.stdin);else{let i=t.fs.resolvePath(t.cwd,e);try{s=await t.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${n}: ${e}: No such file or directory
574
+ `,exitCode:1}}}if(!nn(s))return r.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${n}: ${e}: not in gzip format
575
+ `,exitCode:1};try{return vs(s),r.verbose?{stdout:"",stderr:`${e}: OK
576
576
  `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(i){let o=i instanceof Error?i.message:"invalid";return{stdout:"",stderr:`${n}: ${e}: ${o}
577
- `,exitCode:1}}}async function Es(t,e,r){let n=r==="zcat"?Eg:r==="gunzip"?bg:wg;if(I(t))return N(n);let s=j(r,t,Sg);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,o=s.result.positional,a=r==="gunzip"||r==="zcat"||i.decompress||i.uncompress,l=r==="zcat"||i.stdout||i.toStdout;if(i.list){o.length===0&&(o=["-"]);let d=` compressed uncompressed ratio uncompressed_name
578
- `,p="",h=0;for(let y of o){let m=await Ag(e,y,i,r);d+=m.stdout,p+=m.stderr,m.exitCode!==0&&(h=m.exitCode)}return{stdout:d,stderr:p,exitCode:h}}if(i.test){o.length===0&&(o=["-"]);let d="",p="",h=0;for(let y of o){let m=await kg(e,y,i,r);d+=m.stdout,p+=m.stderr,m.exitCode!==0&&(h=m.exitCode)}return{stdout:d,stderr:p,exitCode:h}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let d of o){let p=await nu(e,d,i,r,a,l);c+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var wg,bg,Eg,Sg,Ng,Ig,vg,Zr=C(()=>{"use strict";ae();O();wg={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
577
+ `,exitCode:1}}}async function $s(t,e,r){let n=r==="zcat"?$g:r==="gunzip"?vg:Ig;if(N(t))return k(n);let s=z(r,t,Rg);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,o=s.result.positional,a=r==="gunzip"||r==="zcat"||i.decompress||i.uncompress,l=r==="zcat"||i.stdout||i.toStdout;if(i.list){o.length===0&&(o=["-"]);let p=` compressed uncompressed ratio uncompressed_name
578
+ `,d="",h=0;for(let m of o){let g=await Fg(e,m,i,r);p+=g.stdout,d+=g.stderr,g.exitCode!==0&&(h=g.exitCode)}return{stdout:p,stderr:d,exitCode:h}}if(i.test){o.length===0&&(o=["-"]);let p="",d="",h=0;for(let m of o){let g=await Og(e,m,i,r);p+=g.stdout,d+=g.stderr,g.exitCode!==0&&(h=g.exitCode)}return{stdout:p,stderr:d,exitCode:h}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let p of o){let d=await fu(e,p,i,r,a,l);c+=d.stdout,u+=d.stderr,d.exitCode!==0&&(f=d.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var Ig,vg,$g,Rg,Tg,Dg,Lg,on=C(()=>{"use strict";ye();L();Ig={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
579
579
 
580
580
  When no FILE is given, or when FILE is -, read from standard input.
581
581
 
582
- With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},bg={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place).
582
+ With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},vg={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place).
583
583
 
584
- When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},Eg={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
584
+ When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},$g={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
585
585
 
586
- When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},Sg={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};Ng={name:"gzip",async execute(t,e){return Es(t,e,"gzip")}},Ig={name:"gunzip",async execute(t,e){return Es(t,e,"gunzip")}},vg={name:"zcat",async execute(t,e){return Es(t,e,"zcat")}}});function Ss(t){let e=t.indexOf("=");if(e>=0){let r=t.slice(0,e),n=t.slice(e+1);return r?`${encodeURIComponent(r)}=${encodeURIComponent(n)}`:encodeURIComponent(n)}return encodeURIComponent(t)}function Cs(t){let e=t.indexOf("=");if(e<0)return null;let r=t.slice(0,e),n=t.slice(e+1),s,i,o=n.match(/;type=([^;]+)$/);o&&(i=o[1],n=n.slice(0,-o[0].length));let a=n.match(/;filename=([^;]+)/);return a&&(s=a[1],n=n.replace(a[0],"")),(n.startsWith("@")||n.startsWith("<"))&&(s=s??n.slice(1).split("/").pop()),{name:r,value:n,filename:s,contentType:i}}function iu(t,e){let r=`----CurlFormBoundary${Date.now().toString(36)}`,n=[];for(let s of t){let i=s.value;if(i.startsWith("@")||i.startsWith("<")){let a=i.slice(1);i=e.get(a)??""}let o=`--${r}\r
586
+ When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},Rg={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};Tg={name:"gzip",async execute(t,e){return $s(t,e,"gzip")}},Dg={name:"gunzip",async execute(t,e){return $s(t,e,"gunzip")}},Lg={name:"zcat",async execute(t,e){return $s(t,e,"zcat")}}});function Rs(t){let e=t.indexOf("=");if(e>=0){let r=t.slice(0,e),n=t.slice(e+1);return r?`${encodeURIComponent(r)}=${encodeURIComponent(n)}`:encodeURIComponent(n)}return encodeURIComponent(t)}function Ps(t){let e=t.indexOf("=");if(e<0)return null;let r=t.slice(0,e),n=t.slice(e+1),s,i,o=n.match(/;type=([^;]+)$/);o&&(i=o[1],n=n.slice(0,-o[0].length));let a=n.match(/;filename=([^;]+)/);return a&&(s=a[1],n=n.replace(a[0],"")),(n.startsWith("@")||n.startsWith("<"))&&(s=s??n.slice(1).split("/").pop()),{name:r,value:n,filename:s,contentType:i}}function du(t,e){let r=`----CurlFormBoundary${Date.now().toString(36)}`,n=[];for(let s of t){let i=s.value;if(i.startsWith("@")||i.startsWith("<")){let a=i.slice(1);i=e.get(a)??""}let o=`--${r}\r
587
587
  `;s.filename?(o+=`Content-Disposition: form-data; name="${s.name}"; filename="${s.filename}"\r
588
588
  `,s.contentType&&(o+=`Content-Type: ${s.contentType}\r
589
589
  `)):o+=`Content-Disposition: form-data; name="${s.name}"\r
590
590
  `,o+=`\r
591
591
  ${i}\r
592
592
  `,n.push(o)}return n.push(`--${r}--\r
593
- `),{body:n.join(""),boundary:r}}var As=C(()=>{"use strict"});var ou,au=C(()=>{"use strict";ou={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]}});function lu(t){let e={method:"GET",headers:{},dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let r=0;r<t.length;r++){let n=t[r];if(n==="-X"||n==="--request")e.method=t[++r]??"GET";else if(n.startsWith("-X"))e.method=n.slice(2);else if(n.startsWith("--request="))e.method=n.slice(10);else if(n==="-H"||n==="--header"){let s=t[++r];if(s){let i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}}else if(n.startsWith("--header=")){let s=n.slice(9),i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}else if(n==="-d"||n==="--data"||n==="--data-raw")e.data=t[++r]??"",e.method==="GET"&&(e.method="POST");else if(n.startsWith("-d"))e.data=n.slice(2),e.method==="GET"&&(e.method="POST");else if(n.startsWith("--data="))e.data=n.slice(7),e.method==="GET"&&(e.method="POST");else if(n.startsWith("--data-raw="))e.data=n.slice(11),e.method==="GET"&&(e.method="POST");else if(n==="--data-binary")e.data=t[++r]??"",e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(n.startsWith("--data-binary="))e.data=n.slice(14),e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(n==="--data-urlencode"){let s=t[++r]??"";e.data=(e.data?`${e.data}&`:"")+Ss(s),e.method==="GET"&&(e.method="POST")}else if(n.startsWith("--data-urlencode=")){let s=n.slice(17);e.data=(e.data?`${e.data}&`:"")+Ss(s),e.method==="GET"&&(e.method="POST")}else if(n==="-F"||n==="--form"){let s=t[++r]??"",i=Cs(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(n.startsWith("--form=")){let s=n.slice(7),i=Cs(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(n==="-u"||n==="--user")e.user=t[++r];else if(n.startsWith("-u"))e.user=n.slice(2);else if(n.startsWith("--user="))e.user=n.slice(7);else if(n==="-A"||n==="--user-agent")e.headers["User-Agent"]=t[++r]??"";else if(n.startsWith("-A"))e.headers["User-Agent"]=n.slice(2);else if(n.startsWith("--user-agent="))e.headers["User-Agent"]=n.slice(13);else if(n==="-e"||n==="--referer")e.headers.Referer=t[++r]??"";else if(n.startsWith("-e"))e.headers.Referer=n.slice(2);else if(n.startsWith("--referer="))e.headers.Referer=n.slice(10);else if(n==="-b"||n==="--cookie")e.headers.Cookie=t[++r]??"";else if(n.startsWith("-b"))e.headers.Cookie=n.slice(2);else if(n.startsWith("--cookie="))e.headers.Cookie=n.slice(9);else if(n==="-c"||n==="--cookie-jar")e.cookieJar=t[++r];else if(n.startsWith("--cookie-jar="))e.cookieJar=n.slice(13);else if(n==="-T"||n==="--upload-file")e.uploadFile=t[++r],e.method==="GET"&&(e.method="PUT");else if(n.startsWith("--upload-file="))e.uploadFile=n.slice(14),e.method==="GET"&&(e.method="PUT");else if(n==="-m"||n==="--max-time"){let s=parseFloat(t[++r]??"0");!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(n.startsWith("--max-time=")){let s=parseFloat(n.slice(11));!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(n==="--connect-timeout"){let s=parseFloat(t[++r]??"0");!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(n.startsWith("--connect-timeout=")){let s=parseFloat(n.slice(18));!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(n==="-o"||n==="--output")e.outputFile=t[++r];else if(n.startsWith("--output="))e.outputFile=n.slice(9);else if(n==="-O"||n==="--remote-name")e.useRemoteName=!0;else if(n==="-I"||n==="--head")e.headOnly=!0,e.method="HEAD";else if(n==="-i"||n==="--include")e.includeHeaders=!0;else if(n==="-s"||n==="--silent")e.silent=!0;else if(n==="-S"||n==="--show-error")e.showError=!0;else if(n==="-f"||n==="--fail")e.failSilently=!0;else if(n==="-L"||n==="--location")e.followRedirects=!0;else if(n==="--max-redirs")r++;else if(!n.startsWith("--max-redirs="))if(n==="-w"||n==="--write-out")e.writeOut=t[++r];else if(n.startsWith("--write-out="))e.writeOut=n.slice(12);else if(n==="-v"||n==="--verbose")e.verbose=!0;else{if(n.startsWith("--")&&n!=="--")return $("curl",n);if(n.startsWith("-")&&n!=="-")for(let s of n.slice(1))switch(s){case"s":e.silent=!0;break;case"S":e.showError=!0;break;case"f":e.failSilently=!0;break;case"L":e.followRedirects=!0;break;case"I":e.headOnly=!0,e.method="HEAD";break;case"i":e.includeHeaders=!0;break;case"O":e.useRemoteName=!0;break;case"v":e.verbose=!0;break;default:return $("curl",`-${s}`)}else n.startsWith("-")||(e.url=n)}}return e}var cu=C(()=>{"use strict";O();As()});function ks(t){return Object.entries(t).map(([e,r])=>`${e}: ${r}`).join(`\r
594
- `)}function uu(t){try{return new URL(t).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function Ns(t,e){let r=t;return r=r.replace(/%\{http_code\}/g,String(e.status)),r=r.replace(/%\{content_type\}/g,e.headers["content-type"]||""),r=r.replace(/%\{url_effective\}/g,e.url),r=r.replace(/%\{size_download\}/g,String(e.bodyLength)),r=r.replace(/\\n/g,`
595
- `),r}var fu=C(()=>{"use strict"});var du={};v(du,{curlCommand:()=>Fg});async function $g(t,e){if(t.uploadFile){let r=e.fs.resolvePath(e.cwd,t.uploadFile);return{body:await e.fs.readFile(r)}}if(t.formFields.length>0){let r=new Map;for(let i of t.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let o=e.fs.resolvePath(e.cwd,i.value.slice(1));try{let a=await e.fs.readFile(o);r.set(i.value.slice(1),a)}catch{r.set(i.value.slice(1),"")}}let{body:n,boundary:s}=iu(t.formFields,r);return{body:n,contentType:`multipart/form-data; boundary=${s}`}}return t.data!==void 0?{body:t.data}:{}}function Rg(t,e){let r={...t.headers};if(t.user){let n=Buffer.from(t.user).toString("base64");r.Authorization=`Basic ${n}`}return e&&!r["Content-Type"]&&(r["Content-Type"]=e),r}async function Pg(t,e,r){if(!t.cookieJar)return;let n=e["set-cookie"];if(!n)return;let s=r.fs.resolvePath(r.cwd,t.cookieJar);await r.fs.writeFile(s,n)}function Og(t,e,r){let n="";if(t.verbose){n+=`> ${t.method} ${r}
593
+ `),{body:n.join(""),boundary:r}}var Fs=C(()=>{"use strict"});var hu,mu=C(()=>{"use strict";hu={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]}});function gu(t){let e={method:"GET",headers:{},dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let r=0;r<t.length;r++){let n=t[r];if(n==="-X"||n==="--request")e.method=t[++r]??"GET";else if(n.startsWith("-X"))e.method=n.slice(2);else if(n.startsWith("--request="))e.method=n.slice(10);else if(n==="-H"||n==="--header"){let s=t[++r];if(s){let i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}}else if(n.startsWith("--header=")){let s=n.slice(9),i=s.indexOf(":");if(i>0){let o=s.slice(0,i).trim(),a=s.slice(i+1).trim();e.headers[o]=a}}else if(n==="-d"||n==="--data"||n==="--data-raw")e.data=t[++r]??"",e.method==="GET"&&(e.method="POST");else if(n.startsWith("-d"))e.data=n.slice(2),e.method==="GET"&&(e.method="POST");else if(n.startsWith("--data="))e.data=n.slice(7),e.method==="GET"&&(e.method="POST");else if(n.startsWith("--data-raw="))e.data=n.slice(11),e.method==="GET"&&(e.method="POST");else if(n==="--data-binary")e.data=t[++r]??"",e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(n.startsWith("--data-binary="))e.data=n.slice(14),e.dataBinary=!0,e.method==="GET"&&(e.method="POST");else if(n==="--data-urlencode"){let s=t[++r]??"";e.data=(e.data?`${e.data}&`:"")+Rs(s),e.method==="GET"&&(e.method="POST")}else if(n.startsWith("--data-urlencode=")){let s=n.slice(17);e.data=(e.data?`${e.data}&`:"")+Rs(s),e.method==="GET"&&(e.method="POST")}else if(n==="-F"||n==="--form"){let s=t[++r]??"",i=Ps(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(n.startsWith("--form=")){let s=n.slice(7),i=Ps(s);i&&e.formFields.push(i),e.method==="GET"&&(e.method="POST")}else if(n==="-u"||n==="--user")e.user=t[++r];else if(n.startsWith("-u"))e.user=n.slice(2);else if(n.startsWith("--user="))e.user=n.slice(7);else if(n==="-A"||n==="--user-agent")e.headers["User-Agent"]=t[++r]??"";else if(n.startsWith("-A"))e.headers["User-Agent"]=n.slice(2);else if(n.startsWith("--user-agent="))e.headers["User-Agent"]=n.slice(13);else if(n==="-e"||n==="--referer")e.headers.Referer=t[++r]??"";else if(n.startsWith("-e"))e.headers.Referer=n.slice(2);else if(n.startsWith("--referer="))e.headers.Referer=n.slice(10);else if(n==="-b"||n==="--cookie")e.headers.Cookie=t[++r]??"";else if(n.startsWith("-b"))e.headers.Cookie=n.slice(2);else if(n.startsWith("--cookie="))e.headers.Cookie=n.slice(9);else if(n==="-c"||n==="--cookie-jar")e.cookieJar=t[++r];else if(n.startsWith("--cookie-jar="))e.cookieJar=n.slice(13);else if(n==="-T"||n==="--upload-file")e.uploadFile=t[++r],e.method==="GET"&&(e.method="PUT");else if(n.startsWith("--upload-file="))e.uploadFile=n.slice(14),e.method==="GET"&&(e.method="PUT");else if(n==="-m"||n==="--max-time"){let s=parseFloat(t[++r]??"0");!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(n.startsWith("--max-time=")){let s=parseFloat(n.slice(11));!Number.isNaN(s)&&s>0&&(e.timeoutMs=s*1e3)}else if(n==="--connect-timeout"){let s=parseFloat(t[++r]??"0");!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(n.startsWith("--connect-timeout=")){let s=parseFloat(n.slice(18));!Number.isNaN(s)&&s>0&&e.timeoutMs===void 0&&(e.timeoutMs=s*1e3)}else if(n==="-o"||n==="--output")e.outputFile=t[++r];else if(n.startsWith("--output="))e.outputFile=n.slice(9);else if(n==="-O"||n==="--remote-name")e.useRemoteName=!0;else if(n==="-I"||n==="--head")e.headOnly=!0,e.method="HEAD";else if(n==="-i"||n==="--include")e.includeHeaders=!0;else if(n==="-s"||n==="--silent")e.silent=!0;else if(n==="-S"||n==="--show-error")e.showError=!0;else if(n==="-f"||n==="--fail")e.failSilently=!0;else if(n==="-L"||n==="--location")e.followRedirects=!0;else if(n==="--max-redirs")r++;else if(!n.startsWith("--max-redirs="))if(n==="-w"||n==="--write-out")e.writeOut=t[++r];else if(n.startsWith("--write-out="))e.writeOut=n.slice(12);else if(n==="-v"||n==="--verbose")e.verbose=!0;else{if(n.startsWith("--")&&n!=="--")return P("curl",n);if(n.startsWith("-")&&n!=="-")for(let s of n.slice(1))switch(s){case"s":e.silent=!0;break;case"S":e.showError=!0;break;case"f":e.failSilently=!0;break;case"L":e.followRedirects=!0;break;case"I":e.headOnly=!0,e.method="HEAD";break;case"i":e.includeHeaders=!0;break;case"O":e.useRemoteName=!0;break;case"v":e.verbose=!0;break;default:return P("curl",`-${s}`)}else n.startsWith("-")||(e.url=n)}}return e}var yu=C(()=>{"use strict";L();Fs()});function Os(t){return Object.entries(t).map(([e,r])=>`${e}: ${r}`).join(`\r
594
+ `)}function xu(t){try{return new URL(t).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function Ts(t,e){let r=t;return r=r.replace(/%\{http_code\}/g,String(e.status)),r=r.replace(/%\{content_type\}/g,e.headers["content-type"]||""),r=r.replace(/%\{url_effective\}/g,e.url),r=r.replace(/%\{size_download\}/g,String(e.bodyLength)),r=r.replace(/\\n/g,`
595
+ `),r}var wu=C(()=>{"use strict"});var bu={};R(bu,{curlCommand:()=>Ug});async function Mg(t,e){if(t.uploadFile){let r=e.fs.resolvePath(e.cwd,t.uploadFile);return{body:await e.fs.readFile(r)}}if(t.formFields.length>0){let r=new Map;for(let i of t.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let o=e.fs.resolvePath(e.cwd,i.value.slice(1));try{let a=await e.fs.readFile(o);r.set(i.value.slice(1),a)}catch{r.set(i.value.slice(1),"")}}let{body:n,boundary:s}=du(t.formFields,r);return{body:n,contentType:`multipart/form-data; boundary=${s}`}}return t.data!==void 0?{body:t.data}:{}}function _g(t,e){let r={...t.headers};if(t.user){let n=Buffer.from(t.user).toString("base64");r.Authorization=`Basic ${n}`}return e&&!r["Content-Type"]&&(r["Content-Type"]=e),r}async function Bg(t,e,r){if(!t.cookieJar)return;let n=e["set-cookie"];if(!n)return;let s=r.fs.resolvePath(r.cwd,t.cookieJar);await r.fs.writeFile(s,n)}function Wg(t,e,r){let n="";if(t.verbose){n+=`> ${t.method} ${r}
596
596
  `;for(let[s,i]of Object.entries(t.headers))n+=`> ${s}: ${i}
597
597
  `;n+=`>
598
598
  `,n+=`< HTTP/1.1 ${e.status} ${e.statusText}
599
599
  `;for(let[s,i]of Object.entries(e.headers))n+=`< ${s}: ${i}
600
600
  `;n+=`<
601
601
  `}return t.includeHeaders&&!t.verbose&&(n+=`HTTP/1.1 ${e.status} ${e.statusText}\r
602
- `,n+=ks(e.headers),n+=`\r
602
+ `,n+=Os(e.headers),n+=`\r
603
603
  \r
604
604
  `),t.headOnly?t.includeHeaders||t.verbose||(n+=`HTTP/1.1 ${e.status} ${e.statusText}\r
605
- `,n+=ks(e.headers),n+=`\r
606
- `):n+=e.body,t.writeOut&&(n+=Ns(t.writeOut,{status:e.status,headers:e.headers,url:e.url,bodyLength:e.body.length})),n}var Fg,pu=C(()=>{"use strict";Be();O();As();au();cu();fu();Fg={name:"curl",async execute(t,e){if(I(t))return N(ou);let r=lu(t);if("exitCode"in r)return r;let n=r;if(!n.url)return{stdout:"",stderr:`curl: no URL specified
605
+ `,n+=Os(e.headers),n+=`\r
606
+ `):n+=e.body,t.writeOut&&(n+=Ts(t.writeOut,{status:e.status,headers:e.headers,url:e.url,bodyLength:e.body.length})),n}var Ug,Eu=C(()=>{"use strict";qe();L();Fs();mu();yu();wu();Ug={name:"curl",async execute(t,e){if(N(t))return k(hu);let r=gu(t);if("exitCode"in r)return r;let n=r;if(!n.url)return{stdout:"",stderr:`curl: no URL specified
607
607
  `,exitCode:2};if(!e.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
608
- `,exitCode:1};let s=n.url;s.match(/^https?:\/\//)||(s=`https://${s}`);try{let{body:i,contentType:o}=await $g(n,e),a=Rg(n,o),l=await e.fetch(s,{method:n.method,headers:Object.keys(a).length>0?a:void 0,body:i,followRedirects:n.followRedirects,timeoutMs:n.timeoutMs});if(await Pg(n,l.headers,e),n.failSilently&&l.status>=400)return{stdout:"",stderr:n.showError||!n.silent?`curl: (22) The requested URL returned error: ${l.status}
609
- `:"",exitCode:22};let c=Og(n,l,s);if(n.outputFile||n.useRemoteName){let u=n.outputFile||uu(s),f=e.fs.resolvePath(e.cwd,u);await e.fs.writeFile(f,n.headOnly?"":l.body),n.verbose||(c=""),n.writeOut&&(c=Ns(n.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:c,stderr:"",exitCode:0}}catch(i){let o=re(i),a=1;return o.includes("Network access denied")?a=7:o.includes("HTTP method")&&o.includes("not allowed")?a=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?a=47:o.includes("aborted")&&(a=28),{stdout:"",stderr:!n.silent||n.showError?`curl: (${a}) ${o}
610
- `:"",exitCode:a}}}}});var Is=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(Ni(),ki))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(vi(),Ii))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(Oi(),Pi))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(Di(),Li))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(_i(),Mi))).mkdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Wi(),Bi))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(ji(),Ui))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Hi(),zi))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(qi(),Gi))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Ki(),Vi))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(Xi(),Qi))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(Yi(),Ji))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(to(),eo))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(io(),so))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(ao(),oo))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(uo(),co))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(ho(),po))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(Ar(),Cr))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(Ar(),Cr))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(Ar(),Cr))).egrepCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(ko(),Ao))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(Ko(),Vo))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(sa(),na))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(oa(),ia))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(la(),aa))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(ua(),ca))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(pa(),da))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(ga(),ma))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(xa(),ya))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(Ea(),ba))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Aa(),Ca))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(Ia(),Na))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(Pa(),Ra))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(La(),Ta))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(_a(),Ma))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Ua(),Wa))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(za(),ja))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Ga(),Ha))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(Xa(),Qa))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(Ya(),Ja))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(tl(),el))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(sl(),nl))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(al(),ol))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Zn(),Kn))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Zn(),Kn))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Xn(),Qn))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Xn(),Qn))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(ul(),cl))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(dl(),fl))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Yn(),Jn))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Yn(),Jn))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(hl(),pl))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(ts(),es))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(ts(),es))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(kl(),Al))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(vl(),Il))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Pl(),Rl))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Fl(),Ol))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(Ll(),Tl))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(Ml(),Dl))).timeoutCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Bl(),_l))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(Ul(),Wl))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(Hl(),zl))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(ql(),Gl))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(Kl(),Vl))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(Uc(),Wc))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(zc(),jc))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(Gc(),Hc))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(Vc(),qc))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(Zc(),Kc))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(Xc(),Qc))).hostname},{name:"od",load:async()=>(await Promise.resolve().then(()=>(Yc(),Jc))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Zr(),Kr))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Zr(),Kr))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Zr(),Kr))).zcatCommand}],mu=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(pu(),du))).curlCommand}],hu=new Map;function gu(t){return{name:t.name,async execute(e,r){let n=hu.get(t.name);return n||(n=await t.load(),hu.set(t.name,n)),n.execute(e,r)}}}function Tg(){return Is.map(t=>t.name)}function Lg(){return mu.map(t=>t.name)}function yu(t){return(t?Is.filter(r=>t.includes(r.name)):Is).map(gu)}function xu(){return mu.map(gu)}function wu(t){return"load"in t&&typeof t.load=="function"}function Dg(t,e){return{name:t,execute:e}}function bu(t){let e=null;return{name:t.name,async execute(r,n){return e||(e=await t.load()),e.execute(r,n)}}}var Mg=new TextEncoder,_g=new TextDecoder;function vs(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),r=>r.charCodeAt(0));case"hex":{let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=parseInt(t.slice(n,n+2),16);return r}case"binary":case"latin1":return Uint8Array.from(t,r=>r.charCodeAt(0));default:return Mg.encode(t)}}function Eu(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(r=>r.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return _g.decode(t)}}function Qr(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var Xr=new TextEncoder;function Bg(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var yt=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[r,n]of Object.entries(e))Bg(n)?this.writeFileSync(r,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(r,n)}normalizePath(e){if(!e||e==="/")return"/";let r=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;r.startsWith("/")||(r=`/${r}`);let n=r.split("/").filter(i=>i&&i!=="."),s=[];for(let i of n)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(e){let r=this.normalizePath(e);if(r==="/")return"/";let n=r.lastIndexOf("/");return n===0?"/":r.slice(0,n)}ensureParentDirs(e){let r=this.dirname(e);r!=="/"&&(this.data.has(r)||(this.ensureParentDirs(r),this.data.set(r,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,r,n,s){let i=this.normalizePath(e);this.ensureParentDirs(i);let o=Qr(n),a=vs(r,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,r){let n=await this.readFileBuffer(e),s=Qr(r);return Eu(n,s)}async readFileBuffer(e){let r=this.normalizePath(e),n=this.data.get(r),s=r;if(!n)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let i=new Set;for(;n&&n.type==="symlink";){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=this.resolveSymlink(s,n.target),n=this.data.get(s)}if(!n)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return n.content instanceof Uint8Array?n.content:Xr.encode(n.content)}async writeFile(e,r,n){this.writeFileSync(e,r,n)}async appendFile(e,r,n){let s=this.normalizePath(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=Qr(n),a=vs(r,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:Xr.encode(i.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:i.mode,mtime:new Date})}else this.writeFileSync(e,r,n)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(n.type==="symlink"){let i=this.resolveSymlink(r,n.target),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);n=o}let s=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=Xr.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}async lstat(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};let s=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=Xr.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}resolveSymlink(e,r){if(r.startsWith("/"))return this.normalizePath(r);let n=this.dirname(e);return this.normalizePath(n==="/"?`/${r}`:`${n}/${r}`)}async mkdir(e,r){this.mkdirSync(e,r)}mkdirSync(e,r){let n=this.normalizePath(e);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!r?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(n);if(s!=="/"&&!this.data.has(s))if(r?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=r==="/"?"/":`${r}/`,i=[];for(let o of this.data.keys())if(o!==r&&o.startsWith(s)){let l=o.slice(s.length).split("/")[0];l&&!i.includes(l)&&i.push(l)}return i.sort()}async rm(e,r){let n=this.normalizePath(e),s=this.data.get(n);if(!s){if(r?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!r?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(a,r)}}}this.data.delete(n)}async cp(e,r,n){let s=this.normalizePath(e),i=this.normalizePath(r),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,n)}}}async mv(e,r){await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,r){if(r.startsWith("/"))return this.normalizePath(r);let n=e==="/"?`/${r}`:`${e}/${r}`;return this.normalizePath(n)}async chmod(e,r){let n=this.normalizePath(e),s=this.data.get(n);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=r}async symlink(e,r){let n=this.normalizePath(r);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,r){let n=this.normalizePath(e),s=this.normalizePath(r),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${r}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}};var Su="5.1.0(1)-release",Cu="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function or(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function Au(){let{pid:t,ppid:e,uid:r,gid:n}=or();return`Name: bash
608
+ `,exitCode:1};let s=n.url;s.match(/^https?:\/\//)||(s=`https://${s}`);try{let{body:i,contentType:o}=await Mg(n,e),a=_g(n,o),l=await e.fetch(s,{method:n.method,headers:Object.keys(a).length>0?a:void 0,body:i,followRedirects:n.followRedirects,timeoutMs:n.timeoutMs});if(await Bg(n,l.headers,e),n.failSilently&&l.status>=400)return{stdout:"",stderr:n.showError||!n.silent?`curl: (22) The requested URL returned error: ${l.status}
609
+ `:"",exitCode:22};let c=Wg(n,l,s);if(n.outputFile||n.useRemoteName){let u=n.outputFile||xu(s),f=e.fs.resolvePath(e.cwd,u);await e.fs.writeFile(f,n.headOnly?"":l.body),n.verbose||(c=""),n.writeOut&&(c=Ts(n.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:c,stderr:"",exitCode:0}}catch(i){let o=de(i),a=1;return o.includes("Network access denied")?a=7:o.includes("HTTP method")&&o.includes("not allowed")?a=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?a=47:o.includes("aborted")&&(a=28),{stdout:"",stderr:!n.silent||n.showError?`curl: (${a}) ${o}
610
+ `:"",exitCode:a}}}}});var Ds=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(Ti(),Oi))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(Li(),Di))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(Wi(),Bi))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(Hi(),zi))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(qi(),Gi))).mkdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Ki(),Vi))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(Qi(),Zi))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Ji(),Xi))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(eo(),Yi))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(ro(),to))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(io(),so))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(ao(),oo))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(co(),lo))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(ho(),po))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(go(),mo))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(wo(),xo))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(So(),Eo))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(Tr(),Or))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(Tr(),Or))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(Tr(),Or))).egrepCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(Oo(),Fo))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(ra(),ta))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(pa(),fa))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(ha(),da))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(ga(),ma))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(xa(),ya))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(Ea(),ba))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(Aa(),Ca))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(Na(),ka))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>($a(),va))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Fa(),Pa))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(Da(),Ta))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(Ba(),_a))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(za(),ja))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(qa(),Ga))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Za(),Ka))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(Xa(),Qa))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Ya(),Ja))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(il(),sl))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(al(),ol))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(cl(),ll))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(pl(),fl))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(ml(),hl))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(ns(),rs))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(ns(),rs))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(is(),ss))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(is(),ss))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(xl(),yl))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(bl(),wl))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(as(),os))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(as(),os))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(Sl(),El))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(cs(),ls))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(cs(),ls))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Ol(),Fl))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Ll(),Dl))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Bl(),_l))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Ul(),Wl))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(zl(),jl))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(Gl(),Hl))).timeoutCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Vl(),ql))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(Zl(),Kl))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(Jl(),Xl))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(ec(),Yl))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(rc(),tc))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(Zc(),Kc))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(Xc(),Qc))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(Yc(),Jc))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(tu(),eu))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(nu(),ru))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(iu(),su))).hostname},{name:"od",load:async()=>(await Promise.resolve().then(()=>(au(),ou))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(on(),sn))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(on(),sn))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(on(),sn))).zcatCommand}],Cu=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(Eu(),bu))).curlCommand}],Su=new Map;function Au(t){return{name:t.name,async execute(e,r){let n=Su.get(t.name);return n||(n=await t.load(),Su.set(t.name,n)),n.execute(e,r)}}}function jg(){return Ds.map(t=>t.name)}function zg(){return Cu.map(t=>t.name)}function ku(t){return(t?Ds.filter(r=>t.includes(r.name)):Ds).map(Au)}function Nu(){return Cu.map(Au)}function Iu(t){return"load"in t&&typeof t.load=="function"}function Hg(t,e){return{name:t,execute:e}}function vu(t){let e=null;return{name:t.name,async execute(r,n){return e||(e=await t.load()),e.execute(r,n)}}}var Gg=new TextEncoder,qg=new TextDecoder;function Ls(t,e){if(t instanceof Uint8Array)return t;switch(e){case"base64":return Uint8Array.from(atob(t),r=>r.charCodeAt(0));case"hex":{let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=parseInt(t.slice(n,n+2),16);return r}case"binary":case"latin1":return Uint8Array.from(t,r=>r.charCodeAt(0));default:return Gg.encode(t)}}function $u(t,e){switch(e){case"base64":return btoa(String.fromCharCode(...t));case"hex":return Array.from(t).map(r=>r.toString(16).padStart(2,"0")).join("");case"binary":case"latin1":return String.fromCharCode(...t);default:return qg.decode(t)}}function an(t){if(t!=null)return typeof t=="string"?t:t.encoding??void 0}var ln=new TextEncoder;function Vg(t){return typeof t=="object"&&t!==null&&!(t instanceof Uint8Array)&&"content"in t}var It=class{data=new Map;constructor(e){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),e)for(let[r,n]of Object.entries(e))Vg(n)?this.writeFileSync(r,n.content,void 0,{mode:n.mode,mtime:n.mtime}):this.writeFileSync(r,n)}normalizePath(e){if(!e||e==="/")return"/";let r=e.endsWith("/")&&e!=="/"?e.slice(0,-1):e;r.startsWith("/")||(r=`/${r}`);let n=r.split("/").filter(i=>i&&i!=="."),s=[];for(let i of n)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(e){let r=this.normalizePath(e);if(r==="/")return"/";let n=r.lastIndexOf("/");return n===0?"/":r.slice(0,n)}ensureParentDirs(e){let r=this.dirname(e);r!=="/"&&(this.data.has(r)||(this.ensureParentDirs(r),this.data.set(r,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(e,r,n,s){let i=this.normalizePath(e);this.ensureParentDirs(i);let o=an(n),a=Ls(r,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(e,r){let n=await this.readFileBuffer(e),s=an(r);return $u(n,s)}async readFileBuffer(e){let r=this.normalizePath(e),n=this.data.get(r),s=r;if(!n)throw new Error(`ENOENT: no such file or directory, open '${e}'`);let i=new Set;for(;n&&n.type==="symlink";){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${e}'`);i.add(s),s=this.resolveSymlink(s,n.target),n=this.data.get(s)}if(!n)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(n.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return n.content instanceof Uint8Array?n.content:ln.encode(n.content)}async writeFile(e,r,n){this.writeFileSync(e,r,n)}async appendFile(e,r,n){let s=this.normalizePath(e),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${e}'`);let o=an(n),a=Ls(r,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:ln.encode(i.content),c=new Uint8Array(l.length+a.length);c.set(l),c.set(a,l.length),this.data.set(s,{type:"file",content:c,mode:i.mode,mtime:new Date})}else this.writeFileSync(e,r,n)}async exists(e){return this.data.has(this.normalizePath(e))}async stat(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(n.type==="symlink"){let i=this.resolveSymlink(r,n.target),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);n=o}let s=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=ln.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}async lstat(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(n.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:n.mode,size:n.target.length,mtime:n.mtime||new Date};let s=0;return n.type==="file"&&n.content&&(n.content instanceof Uint8Array?s=n.content.length:s=ln.encode(n.content).length),{isFile:n.type==="file",isDirectory:n.type==="directory",isSymbolicLink:!1,mode:n.mode,size:s,mtime:n.mtime||new Date}}resolveSymlink(e,r){if(r.startsWith("/"))return this.normalizePath(r);let n=this.dirname(e);return this.normalizePath(n==="/"?`/${r}`:`${n}/${r}`)}async mkdir(e,r){this.mkdirSync(e,r)}mkdirSync(e,r){let n=this.normalizePath(e);if(this.data.has(n)){if(this.data.get(n)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!r?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.dirname(n);if(s!=="/"&&!this.data.has(s))if(r?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.data.set(n,{type:"directory",mode:493,mtime:new Date})}async readdir(e){return(await this.readdirWithFileTypes(e)).map(n=>n.name)}async readdirWithFileTypes(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);if(n.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${e}'`);let s=r==="/"?"/":`${r}/`,i=new Map;for(let[o,a]of this.data.entries())if(o!==r&&o.startsWith(s)){let l=o.slice(s.length),c=l.split("/")[0];c&&!l.includes("/",c.length)&&!i.has(c)&&i.set(c,{name:c,isFile:a.type==="file",isDirectory:a.type==="directory",isSymbolicLink:a.type==="symlink"})}return Array.from(i.values()).sort((o,a)=>o.name<a.name?-1:o.name>a.name?1:0)}async rm(e,r){let n=this.normalizePath(e),s=this.data.get(n);if(!s){if(r?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}if(s.type==="directory"){let i=await this.readdir(n);if(i.length>0){if(!r?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${e}'`);for(let o of i){let a=n==="/"?`/${o}`:`${n}/${o}`;await this.rm(a,r)}}}this.data.delete(n)}async cp(e,r,n){let s=this.normalizePath(e),i=this.normalizePath(r),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${e}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!n?.recursive)throw new Error(`EISDIR: is a directory, cp '${e}'`);await this.mkdir(i,{recursive:!0});let a=await this.readdir(s);for(let l of a){let c=s==="/"?`/${l}`:`${s}/${l}`,u=i==="/"?`/${l}`:`${i}/${l}`;await this.cp(c,u,n)}}}async mv(e,r){await this.cp(e,r,{recursive:!0}),await this.rm(e,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(e,r){if(r.startsWith("/"))return this.normalizePath(r);let n=e==="/"?`/${r}`:`${e}/${r}`;return this.normalizePath(n)}async chmod(e,r){let n=this.normalizePath(e),s=this.data.get(n);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${e}'`);s.mode=r}async symlink(e,r){let n=this.normalizePath(r);if(this.data.has(n))throw new Error(`EEXIST: file already exists, symlink '${r}'`);this.ensureParentDirs(n),this.data.set(n,{type:"symlink",target:e,mode:511,mtime:new Date})}async link(e,r){let n=this.normalizePath(e),s=this.normalizePath(r),i=this.data.get(n);if(!i)throw new Error(`ENOENT: no such file or directory, link '${e}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${e}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${r}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(e){let r=this.normalizePath(e),n=this.data.get(r);if(!n)throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);if(n.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return n.target}};var Ru="5.1.0(1)-release",Pu="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT";function gr(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function Fu(){let{pid:t,ppid:e,uid:r,gid:n}=gr();return`Name: bash
611
611
  State: R (running)
612
612
  Pid: ${t}
613
613
  PPid: ${e}
614
614
  Uid: ${r} ${r} ${r} ${r}
615
615
  Gid: ${n} ${n} ${n} ${n}
616
- `}function Wg(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function Ug(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function jg(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function zg(t){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${Cu}
616
+ `}function Kg(t){let e=t;return typeof e.mkdirSync=="function"&&typeof e.writeFileSync=="function"}function Zg(t,e){t.mkdirSync("/bin",{recursive:!0}),t.mkdirSync("/usr/bin",{recursive:!0}),e&&(t.mkdirSync("/home/user",{recursive:!0}),t.mkdirSync("/tmp",{recursive:!0}))}function Qg(t){t.mkdirSync("/dev",{recursive:!0}),t.writeFileSync("/dev/null",""),t.writeFileSync("/dev/zero",new Uint8Array(0)),t.writeFileSync("/dev/stdin",""),t.writeFileSync("/dev/stdout",""),t.writeFileSync("/dev/stderr","")}function Xg(t){t.mkdirSync("/proc/self/fd",{recursive:!0}),t.writeFileSync("/proc/version",`${Pu}
617
617
  `),t.writeFileSync("/proc/self/exe","/bin/bash"),t.writeFileSync("/proc/self/cmdline","bash\0"),t.writeFileSync("/proc/self/comm",`bash
618
- `),t.writeFileSync("/proc/self/status",Au()),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function ku(t,e){Wg(t)&&(Ug(t,e),jg(t),zg(t))}X();var Hg=["yq","xan","sqlite3"];function Nu(t){return Hg.includes(t)}X();function ue(t,e){return{type:"ArithmeticExpression",expression:Ke(t,e,0).expr}}function Ke(t,e,r){return Gg(t,e,r)}function Gg(t,e,r){let{expr:n,pos:s}=Yr(t,e,r);for(s=ne(e,s);e[s]===",";){s++;let{expr:i,pos:o}=Yr(t,e,s);n={type:"ArithBinary",operator:",",left:n,right:i},s=ne(e,o)}return{expr:n,pos:s}}function Yr(t,e,r){let{expr:n,pos:s}=qg(t,e,r);if(s=ne(e,s),e[s]==="?"){s++;let{expr:i,pos:o}=Ke(t,e,s);if(s=ne(e,o),e[s]===":"){s++;let{expr:a,pos:l}=Ke(t,e,s);return{expr:{type:"ArithTernary",condition:n,consequent:i,alternate:a},pos:l}}}return{expr:n,pos:s}}function qg(t,e,r){let{expr:n,pos:s}=Iu(t,e,r);for(;s=ne(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:i,pos:o}=Iu(t,e,s);n={type:"ArithBinary",operator:"||",left:n,right:i},s=o}return{expr:n,pos:s}}function Iu(t,e,r){let{expr:n,pos:s}=vu(t,e,r);for(;s=ne(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:i,pos:o}=vu(t,e,s);n={type:"ArithBinary",operator:"&&",left:n,right:i},s=o}return{expr:n,pos:s}}function vu(t,e,r){let{expr:n,pos:s}=$u(t,e,r);for(;s=ne(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:i,pos:o}=$u(t,e,s);n={type:"ArithBinary",operator:"|",left:n,right:i},s=o}return{expr:n,pos:s}}function $u(t,e,r){let{expr:n,pos:s}=Ru(t,e,r);for(;s=ne(e,s),e[s]==="^";){s++;let{expr:i,pos:o}=Ru(t,e,s);n={type:"ArithBinary",operator:"^",left:n,right:i},s=o}return{expr:n,pos:s}}function Ru(t,e,r){let{expr:n,pos:s}=Pu(t,e,r);for(;s=ne(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:i,pos:o}=Pu(t,e,s);n={type:"ArithBinary",operator:"&",left:n,right:i},s=o}return{expr:n,pos:s}}function Pu(t,e,r){let{expr:n,pos:s}=Ou(t,e,r);for(;s=ne(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Ou(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}return{expr:n,pos:s}}function Ou(t,e,r){let{expr:n,pos:s}=$s(t,e,r);for(;;)if(s=ne(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=$s(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}else if(e[s]==="<"||e[s]===">"){let i=e[s];s++;let{expr:o,pos:a}=$s(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}else break;return{expr:n,pos:s}}function $s(t,e,r){let{expr:n,pos:s}=Fu(t,e,r);for(;s=ne(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Fu(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}return{expr:n,pos:s}}function Fu(t,e,r){let{expr:n,pos:s}=Tu(t,e,r);for(;s=ne(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let i=e[s];s++;let{expr:o,pos:a}=Tu(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}return{expr:n,pos:s}}function Tu(t,e,r){let{expr:n,pos:s}=Jr(t,e,r);for(;;)if(s=ne(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:i,pos:o}=Jr(t,e,s);n={type:"ArithBinary",operator:"*",left:n,right:i},s=o}else if(e[s]==="/"||e[s]==="%"){let i=e[s];s++;let{expr:o,pos:a}=Jr(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}else break;return{expr:n,pos:s}}function Jr(t,e,r){let{expr:n,pos:s}=Rs(t,e,r),i=ne(e,s);if(e.slice(i,i+2)==="**"){i+=2;let{expr:o,pos:a}=Jr(t,e,i);return{expr:{type:"ArithBinary",operator:"**",left:n,right:o},pos:a}}return{expr:n,pos:s}}function Rs(t,e,r){let n=ne(e,r);if(e.slice(n,n+2)==="++"||e.slice(n,n+2)==="--"){let s=e.slice(n,n+2);n+=2;let{expr:i,pos:o}=Rs(t,e,n);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(e[n]==="+"||e[n]==="-"||e[n]==="!"||e[n]==="~"){let s=e[n];n++;let{expr:i,pos:o}=Rs(t,e,n);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return Kg(t,e,n)}function Vg(t,e){let r=t[e];return r==="$"||r==="`"}function Kg(t,e,r){let{expr:n,pos:s}=Lu(t,e,r),i=[n];for(;Vg(e,s);){let{expr:o,pos:a}=Lu(t,e,s);i.push(o),s=a}if(i.length>1&&(n={type:"ArithConcat",parts:i}),s=ne(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let o=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:o,operand:n,prefix:!1},pos:s}}return{expr:n,pos:s}}function Lu(t,e,r){let n=ne(e,r);if(e.slice(n,n+3)==="$(("){n+=3;let s=1,i=n;for(;n<e.length-1&&s>0;)e[n]==="("&&e[n+1]==="("?(s++,n+=2):e[n]===")"&&e[n+1]===")"?(s--,s>0&&(n+=2)):n++;let o=e.slice(i,n),{expr:a}=Ke(t,o,0);return n+=2,{expr:{type:"ArithNested",expression:a},pos:n}}if(e.slice(n,n+2)==="$("&&e[n+2]!=="("){n+=2;let s=1,i=n;for(;n<e.length&&s>0;)e[n]==="("?s++:e[n]===")"&&s--,s>0&&n++;let o=e.slice(i,n);return n++,{expr:{type:"ArithCommandSubst",command:o},pos:n}}if(e[n]==="`"){n++;let s=n;for(;n<e.length&&e[n]!=="`";)n++;let i=e.slice(s,n);return e[n]==="`"&&n++,{expr:{type:"ArithCommandSubst",command:i},pos:n}}if(e[n]==="("){n++;let{expr:s,pos:i}=Ke(t,e,n);return n=ne(e,i),e[n]===")"&&n++,{expr:{type:"ArithGroup",expression:s},pos:n}}if(/[0-9]/.test(e[n])){let s="",i=!1;for(;n<e.length;){let a=e[n];if(i)if(/[0-9a-zA-Z@_]/.test(a))s+=a,n++;else break;else if(a==="#")i=!0,s+=a,n++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,n++;else break}if(e[n]==="."&&/[0-9]/.test(e[n+1]))throw new le(`${s}.${e[n+1]}...: syntax error: invalid arithmetic operator`);if(e[n]==="["){let a=e.slice(n).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:Bt(s)},pos:n}}if(e[n]==="$"&&e[n+1]==="{"){let s=n+2,i=1,o=s;for(;o<e.length&&i>0;)e[o]==="{"?i++:e[o]==="}"&&i--,i>0&&o++;let a=e.slice(s,o),l=o+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let u=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:u},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let u=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:u},pos:c}}return n=l,{expr:{type:"ArithBracedExpansion",content:a},pos:n}}if(e[n]==="$"&&n+1<e.length&&/[0-9]/.test(e[n+1])){n++;let s="";for(;n<e.length&&/[0-9]/.test(e[n]);)s+=e[n],n++;return{expr:{type:"ArithVariable",name:s},pos:n}}if(e[n]==="$"&&n+1<e.length&&/[a-zA-Z_]/.test(e[n+1])&&n++,/[a-zA-Z_]/.test(e[n])){let s="";for(;n<e.length&&/[a-zA-Z0-9_]/.test(e[n]);)s+=e[n],n++;if(e[n]==="["){n++;let o;if(e[n]==="'"||e[n]==='"'){let c=e[n];for(n++,o="";n<e.length&&e[n]!==c;)o+=e[n],n++;e[n]===c&&n++,n=ne(e,n),e[n]==="]"&&n++}let a;if(o===void 0){let{expr:c,pos:u}=Ke(t,e,n);a=c,n=u,e[n]==="]"&&n++}if(n=ne(e,n),e[n]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:n};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(n,n+c.length)===c&&e.slice(n,n+c.length+1)!=="=="){n+=c.length;let{expr:u,pos:f}=Yr(t,e,n);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:o,value:u},pos:f}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:o},pos:n}}n=ne(e,n);let i=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let o of i)if(e.slice(n,n+o.length)===o&&e.slice(n,n+o.length+1)!=="=="){n+=o.length;let{expr:a,pos:l}=Yr(t,e,n);return{expr:{type:"ArithAssignment",operator:o,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:n}}return{expr:{type:"ArithNumber",value:0},pos:n}}function Bt(t){if(t.includes("#")){let[e,r]=t.split("#"),n=Number.parseInt(e,10);if(n<2||n>64)return Number.NaN;if(n<=36)return Number.parseInt(r,n);let s=0;for(let i of r){let o;if(i>="0"&&i<="9")o=i.charCodeAt(0)-48;else if(i>="a"&&i<="z")o=i.charCodeAt(0)-97+10;else if(i>="A"&&i<="Z")o=i.charCodeAt(0)-65+36;else if(i==="@")o=62;else if(i==="_")o=63;else return Number.NaN;if(o>=n)return Number.NaN;s=s*n+o}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function ne(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
619
- `){e+=2;continue}if(/\s/.test(t[e])){e++;continue}break}return e}var R={script(t){return{type:"Script",statements:t}},statement(t,e=[],r=!1){return{type:"Statement",pipelines:t,operators:e,background:r}},pipeline(t,e=!1){return{type:"Pipeline",commands:t,negated:e}},simpleCommand(t,e=[],r=[],n=[]){return{type:"SimpleCommand",name:t,args:e,assignments:r,redirections:n}},word(t){return{type:"Word",parts:t}},literal(t){return{type:"Literal",value:t}},singleQuoted(t){return{type:"SingleQuoted",value:t}},doubleQuoted(t){return{type:"DoubleQuoted",parts:t}},escaped(t){return{type:"Escaped",value:t}},parameterExpansion(t,e=null){return{type:"ParameterExpansion",parameter:t,operation:e}},commandSubstitution(t,e=!1){return{type:"CommandSubstitution",body:t,legacy:e}},arithmeticExpansion(t){return{type:"ArithmeticExpansion",expression:t}},assignment(t,e,r=!1,n=null){return{type:"Assignment",name:t,value:e,append:r,array:n}},redirection(t,e,r=null){return{type:"Redirection",fd:r,operator:t,target:e}},hereDoc(t,e,r=!1,n=!1){return{type:"HereDoc",delimiter:t,content:e,stripTabs:r,quoted:n}},ifNode(t,e=null,r=[]){return{type:"If",clauses:t,elseBody:e,redirections:r}},forNode(t,e,r,n=[]){return{type:"For",variable:t,words:e,body:r,redirections:n}},whileNode(t,e,r=[]){return{type:"While",condition:t,body:e,redirections:r}},untilNode(t,e,r=[]){return{type:"Until",condition:t,body:e,redirections:r}},caseNode(t,e,r=[]){return{type:"Case",word:t,items:e,redirections:r}},caseItem(t,e,r=";;"){return{type:"CaseItem",patterns:t,body:e,terminator:r}},subshell(t,e=[]){return{type:"Subshell",body:t,redirections:e}},group(t,e=[]){return{type:"Group",body:t,redirections:e}},functionDef(t,e,r=[]){return{type:"FunctionDef",name:t,body:e,redirections:r}},conditionalCommand(t,e=[]){return{type:"ConditionalCommand",expression:t,redirections:e}},arithmeticCommand(t,e=[]){return{type:"ArithmeticCommand",expression:t,redirections:e}}};var g;(function(t){t.EOF="EOF",t.NEWLINE="NEWLINE",t.SEMICOLON="SEMICOLON",t.AMP="AMP",t.PIPE="PIPE",t.PIPE_AMP="PIPE_AMP",t.AND_AND="AND_AND",t.OR_OR="OR_OR",t.BANG="BANG",t.LESS="LESS",t.GREAT="GREAT",t.DLESS="DLESS",t.DGREAT="DGREAT",t.LESSAND="LESSAND",t.GREATAND="GREATAND",t.LESSGREAT="LESSGREAT",t.DLESSDASH="DLESSDASH",t.CLOBBER="CLOBBER",t.TLESS="TLESS",t.AND_GREAT="AND_GREAT",t.AND_DGREAT="AND_DGREAT",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.DSEMI="DSEMI",t.SEMI_AND="SEMI_AND",t.SEMI_SEMI_AND="SEMI_SEMI_AND",t.DBRACK_START="DBRACK_START",t.DBRACK_END="DBRACK_END",t.DPAREN_START="DPAREN_START",t.DPAREN_END="DPAREN_END",t.IF="IF",t.THEN="THEN",t.ELSE="ELSE",t.ELIF="ELIF",t.FI="FI",t.FOR="FOR",t.WHILE="WHILE",t.UNTIL="UNTIL",t.DO="DO",t.DONE="DONE",t.CASE="CASE",t.ESAC="ESAC",t.IN="IN",t.FUNCTION="FUNCTION",t.SELECT="SELECT",t.TIME="TIME",t.COPROC="COPROC",t.WORD="WORD",t.NAME="NAME",t.NUMBER="NUMBER",t.ASSIGNMENT_WORD="ASSIGNMENT_WORD",t.COMMENT="COMMENT",t.HEREDOC_CONTENT="HEREDOC_CONTENT"})(g||(g={}));var en={if:g.IF,then:g.THEN,else:g.ELSE,elif:g.ELIF,fi:g.FI,for:g.FOR,while:g.WHILE,until:g.UNTIL,do:g.DO,done:g.DONE,case:g.CASE,esac:g.ESAC,in:g.IN,function:g.FUNCTION,select:g.SELECT,time:g.TIME,coproc:g.COPROC};function Mu(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return!1;let r=t.slice(e[0].length);if(r===""||r==="+")return!0;if(r[0]==="["){let n=0,s=0;for(;s<r.length;s++)if(r[s]==="[")n++;else if(r[s]==="]"&&(n--,n===0))break;if(n!==0||s>=r.length)return!1;let i=r.slice(s+1);return i===""||i==="+"}return!1}var Zg=[[";",";","&",g.SEMI_SEMI_AND],["<","<","<",g.TLESS],["&",">",">",g.AND_DGREAT]],Qg=[["[","[",g.DBRACK_START],["]","]",g.DBRACK_END],["(","(",g.DPAREN_START],[")",")",g.DPAREN_END],["&","&",g.AND_AND],["|","|",g.OR_OR],[";",";",g.DSEMI],[";","&",g.SEMI_AND],["|","&",g.PIPE_AMP],[">",">",g.DGREAT],["<","&",g.LESSAND],[">","&",g.GREATAND],["<",">",g.LESSGREAT],[">","|",g.CLOBBER],["&",">",g.AND_GREAT]],Xg={"|":g.PIPE,"&":g.AMP,";":g.SEMICOLON,"(":g.LPAREN,")":g.RPAREN,"<":g.LESS,">":g.GREAT};function Jg(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}var tn=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];constructor(e){this.input=e}tokenize(){let r=this.input.length,n=this.tokens,s=this.pendingHeredocs;for(;this.pos<r&&(this.skipWhitespace(),!(this.pos>=r));){if(s.length>0&&n.length>0&&n[n.length-1].type===g.NEWLINE){this.readHeredocContent();continue}let i=this.nextToken();i&&n.push(i)}return n.push({type:g.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),n}skipWhitespace(){let e=this.input,r=e.length,n=this.pos,s=this.column,i=this.line;for(;n<r;){let o=e[n];if(o===" "||o===" ")n++,s++;else if(o==="\\"&&e[n+1]===`
618
+ `),t.writeFileSync("/proc/self/status",Fu()),t.writeFileSync("/proc/self/fd/0","/dev/stdin"),t.writeFileSync("/proc/self/fd/1","/dev/stdout"),t.writeFileSync("/proc/self/fd/2","/dev/stderr")}function Ou(t,e){Kg(t)&&(Zg(t,e),Qg(t),Xg(t))}oe();var Jg=["yq","xan","sqlite3"];function Tu(t){return Jg.includes(t)}oe();function be(t,e){return{type:"ArithmeticExpression",expression:et(t,e,0).expr}}function et(t,e,r){return Yg(t,e,r)}function Yg(t,e,r){let{expr:n,pos:s}=un(t,e,r);for(s=he(e,s);e[s]===",";){s++;let{expr:i,pos:o}=un(t,e,s);n={type:"ArithBinary",operator:",",left:n,right:i},s=he(e,o)}return{expr:n,pos:s}}function un(t,e,r){let{expr:n,pos:s}=ey(t,e,r);if(s=he(e,s),e[s]==="?"){s++;let{expr:i,pos:o}=et(t,e,s);if(s=he(e,o),e[s]===":"){s++;let{expr:a,pos:l}=et(t,e,s);return{expr:{type:"ArithTernary",condition:n,consequent:i,alternate:a},pos:l}}}return{expr:n,pos:s}}function ey(t,e,r){let{expr:n,pos:s}=Du(t,e,r);for(;s=he(e,s),e.slice(s,s+2)==="||";){s+=2;let{expr:i,pos:o}=Du(t,e,s);n={type:"ArithBinary",operator:"||",left:n,right:i},s=o}return{expr:n,pos:s}}function Du(t,e,r){let{expr:n,pos:s}=Lu(t,e,r);for(;s=he(e,s),e.slice(s,s+2)==="&&";){s+=2;let{expr:i,pos:o}=Lu(t,e,s);n={type:"ArithBinary",operator:"&&",left:n,right:i},s=o}return{expr:n,pos:s}}function Lu(t,e,r){let{expr:n,pos:s}=Mu(t,e,r);for(;s=he(e,s),e[s]==="|"&&e[s+1]!=="|";){s++;let{expr:i,pos:o}=Mu(t,e,s);n={type:"ArithBinary",operator:"|",left:n,right:i},s=o}return{expr:n,pos:s}}function Mu(t,e,r){let{expr:n,pos:s}=_u(t,e,r);for(;s=he(e,s),e[s]==="^";){s++;let{expr:i,pos:o}=_u(t,e,s);n={type:"ArithBinary",operator:"^",left:n,right:i},s=o}return{expr:n,pos:s}}function _u(t,e,r){let{expr:n,pos:s}=Bu(t,e,r);for(;s=he(e,s),e[s]==="&"&&e[s+1]!=="&";){s++;let{expr:i,pos:o}=Bu(t,e,s);n={type:"ArithBinary",operator:"&",left:n,right:i},s=o}return{expr:n,pos:s}}function Bu(t,e,r){let{expr:n,pos:s}=Wu(t,e,r);for(;s=he(e,s),e.slice(s,s+2)==="=="||e.slice(s,s+2)==="!=";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Wu(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}return{expr:n,pos:s}}function Wu(t,e,r){let{expr:n,pos:s}=Ms(t,e,r);for(;;)if(s=he(e,s),e.slice(s,s+2)==="<="||e.slice(s,s+2)===">="){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Ms(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}else if(e[s]==="<"||e[s]===">"){let i=e[s];s++;let{expr:o,pos:a}=Ms(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}else break;return{expr:n,pos:s}}function Ms(t,e,r){let{expr:n,pos:s}=Uu(t,e,r);for(;s=he(e,s),e.slice(s,s+2)==="<<"||e.slice(s,s+2)===">>";){let i=e.slice(s,s+2);s+=2;let{expr:o,pos:a}=Uu(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}return{expr:n,pos:s}}function Uu(t,e,r){let{expr:n,pos:s}=ju(t,e,r);for(;s=he(e,s),(e[s]==="+"||e[s]==="-")&&e[s+1]!==e[s];){let i=e[s];s++;let{expr:o,pos:a}=ju(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}return{expr:n,pos:s}}function ju(t,e,r){let{expr:n,pos:s}=cn(t,e,r);for(;;)if(s=he(e,s),e[s]==="*"&&e[s+1]!=="*"){s++;let{expr:i,pos:o}=cn(t,e,s);n={type:"ArithBinary",operator:"*",left:n,right:i},s=o}else if(e[s]==="/"||e[s]==="%"){let i=e[s];s++;let{expr:o,pos:a}=cn(t,e,s);n={type:"ArithBinary",operator:i,left:n,right:o},s=a}else break;return{expr:n,pos:s}}function cn(t,e,r){let{expr:n,pos:s}=_s(t,e,r),i=he(e,s);if(e.slice(i,i+2)==="**"){i+=2;let{expr:o,pos:a}=cn(t,e,i);return{expr:{type:"ArithBinary",operator:"**",left:n,right:o},pos:a}}return{expr:n,pos:s}}function _s(t,e,r){let n=he(e,r);if(e.slice(n,n+2)==="++"||e.slice(n,n+2)==="--"){let s=e.slice(n,n+2);n+=2;let{expr:i,pos:o}=_s(t,e,n);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(e[n]==="+"||e[n]==="-"||e[n]==="!"||e[n]==="~"){let s=e[n];n++;let{expr:i,pos:o}=_s(t,e,n);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return ry(t,e,n)}function ty(t,e){let r=t[e];return r==="$"||r==="`"}function ry(t,e,r){let{expr:n,pos:s}=zu(t,e,r),i=[n];for(;ty(e,s);){let{expr:o,pos:a}=zu(t,e,s);i.push(o),s=a}if(i.length>1&&(n={type:"ArithConcat",parts:i}),s=he(e,s),e.slice(s,s+2)==="++"||e.slice(s,s+2)==="--"){let o=e.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:o,operand:n,prefix:!1},pos:s}}return{expr:n,pos:s}}function zu(t,e,r){let n=he(e,r);if(e.slice(n,n+3)==="$(("){n+=3;let s=1,i=n;for(;n<e.length-1&&s>0;)e[n]==="("&&e[n+1]==="("?(s++,n+=2):e[n]===")"&&e[n+1]===")"?(s--,s>0&&(n+=2)):n++;let o=e.slice(i,n),{expr:a}=et(t,o,0);return n+=2,{expr:{type:"ArithNested",expression:a},pos:n}}if(e.slice(n,n+2)==="$("&&e[n+2]!=="("){n+=2;let s=1,i=n;for(;n<e.length&&s>0;)e[n]==="("?s++:e[n]===")"&&s--,s>0&&n++;let o=e.slice(i,n);return n++,{expr:{type:"ArithCommandSubst",command:o},pos:n}}if(e[n]==="`"){n++;let s=n;for(;n<e.length&&e[n]!=="`";)n++;let i=e.slice(s,n);return e[n]==="`"&&n++,{expr:{type:"ArithCommandSubst",command:i},pos:n}}if(e[n]==="("){n++;let{expr:s,pos:i}=et(t,e,n);return n=he(e,i),e[n]===")"&&n++,{expr:{type:"ArithGroup",expression:s},pos:n}}if(/[0-9]/.test(e[n])){let s="",i=!1;for(;n<e.length;){let a=e[n];if(i)if(/[0-9a-zA-Z@_]/.test(a))s+=a,n++;else break;else if(a==="#")i=!0,s+=a,n++;else if(/[0-9a-fA-FxX]/.test(a))s+=a,n++;else break}if(e[n]==="."&&/[0-9]/.test(e[n+1]))throw new xe(`${s}.${e[n+1]}...: syntax error: invalid arithmetic operator`);if(e[n]==="["){let a=e.slice(n).trim();return{expr:{type:"ArithNumberSubscript",number:s,errorToken:a},pos:e.length}}return{expr:{type:"ArithNumber",value:Zt(s)},pos:n}}if(e[n]==="$"&&e[n+1]==="{"){let s=n+2,i=1,o=s;for(;o<e.length&&i>0;)e[o]==="{"?i++:e[o]==="}"&&i--,i>0&&o++;let a=e.slice(s,o),l=o+1;if(e[l]==="#"){let c=l+1;for(;c<e.length&&/[0-9a-zA-Z@_]/.test(e[c]);)c++;let u=e.slice(l+1,c);return{expr:{type:"ArithDynamicBase",baseExpr:a,value:u},pos:c}}if(/[0-9]/.test(e[l])||e[l]==="x"||e[l]==="X"){let c=l;if(e[l]==="x"||e[l]==="X")for(c++;c<e.length&&/[0-9a-fA-F]/.test(e[c]);)c++;else for(;c<e.length&&/[0-9]/.test(e[c]);)c++;let u=e.slice(l,c);return{expr:{type:"ArithDynamicNumber",prefix:a,suffix:u},pos:c}}return n=l,{expr:{type:"ArithBracedExpansion",content:a},pos:n}}if(e[n]==="$"&&n+1<e.length&&/[0-9]/.test(e[n+1])){n++;let s="";for(;n<e.length&&/[0-9]/.test(e[n]);)s+=e[n],n++;return{expr:{type:"ArithVariable",name:s},pos:n}}if(e[n]==="$"&&n+1<e.length&&/[a-zA-Z_]/.test(e[n+1])&&n++,/[a-zA-Z_]/.test(e[n])){let s="";for(;n<e.length&&/[a-zA-Z0-9_]/.test(e[n]);)s+=e[n],n++;if(e[n]==="["){n++;let o;if(e[n]==="'"||e[n]==='"'){let c=e[n];for(n++,o="";n<e.length&&e[n]!==c;)o+=e[n],n++;e[n]===c&&n++,n=he(e,n),e[n]==="]"&&n++}let a;if(o===void 0){let{expr:c,pos:u}=et(t,e,n);a=c,n=u,e[n]==="]"&&n++}if(n=he(e,n),e[n]==="["&&a)return{expr:{type:"ArithDoubleSubscript",array:s,index:a},pos:n};let l=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let c of l)if(e.slice(n,n+c.length)===c&&e.slice(n,n+c.length+1)!=="=="){n+=c.length;let{expr:u,pos:f}=un(t,e,n);return{expr:{type:"ArithAssignment",operator:c,variable:s,subscript:a,stringKey:o,value:u},pos:f}}return{expr:{type:"ArithArrayElement",array:s,index:a,stringKey:o},pos:n}}n=he(e,n);let i=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="];for(let o of i)if(e.slice(n,n+o.length)===o&&e.slice(n,n+o.length+1)!=="=="){n+=o.length;let{expr:a,pos:l}=un(t,e,n);return{expr:{type:"ArithAssignment",operator:o,variable:s,value:a},pos:l}}return{expr:{type:"ArithVariable",name:s},pos:n}}return{expr:{type:"ArithNumber",value:0},pos:n}}function Zt(t){if(t.includes("#")){let[e,r]=t.split("#"),n=Number.parseInt(e,10);if(n<2||n>64)return Number.NaN;if(n<=36)return Number.parseInt(r,n);let s=0;for(let i of r){let o;if(i>="0"&&i<="9")o=i.charCodeAt(0)-48;else if(i>="a"&&i<="z")o=i.charCodeAt(0)-97+10;else if(i>="A"&&i<="Z")o=i.charCodeAt(0)-65+36;else if(i==="@")o=62;else if(i==="_")o=63;else return Number.NaN;if(o>=n)return Number.NaN;s=s*n+o}return s}return t.startsWith("0x")||t.startsWith("0X")?Number.parseInt(t.slice(2),16):t.startsWith("0")&&t.length>1&&/^[0-9]+$/.test(t)?/[89]/.test(t)?Number.NaN:Number.parseInt(t,8):Number.parseInt(t,10)}function he(t,e){for(;e<t.length;){if(t[e]==="\\"&&t[e+1]===`
619
+ `){e+=2;continue}if(/\s/.test(t[e])){e++;continue}break}return e}var O={script(t){return{type:"Script",statements:t}},statement(t,e=[],r=!1){return{type:"Statement",pipelines:t,operators:e,background:r}},pipeline(t,e=!1){return{type:"Pipeline",commands:t,negated:e}},simpleCommand(t,e=[],r=[],n=[]){return{type:"SimpleCommand",name:t,args:e,assignments:r,redirections:n}},word(t){return{type:"Word",parts:t}},literal(t){return{type:"Literal",value:t}},singleQuoted(t){return{type:"SingleQuoted",value:t}},doubleQuoted(t){return{type:"DoubleQuoted",parts:t}},escaped(t){return{type:"Escaped",value:t}},parameterExpansion(t,e=null){return{type:"ParameterExpansion",parameter:t,operation:e}},commandSubstitution(t,e=!1){return{type:"CommandSubstitution",body:t,legacy:e}},arithmeticExpansion(t){return{type:"ArithmeticExpansion",expression:t}},assignment(t,e,r=!1,n=null){return{type:"Assignment",name:t,value:e,append:r,array:n}},redirection(t,e,r=null){return{type:"Redirection",fd:r,operator:t,target:e}},hereDoc(t,e,r=!1,n=!1){return{type:"HereDoc",delimiter:t,content:e,stripTabs:r,quoted:n}},ifNode(t,e=null,r=[]){return{type:"If",clauses:t,elseBody:e,redirections:r}},forNode(t,e,r,n=[]){return{type:"For",variable:t,words:e,body:r,redirections:n}},whileNode(t,e,r=[]){return{type:"While",condition:t,body:e,redirections:r}},untilNode(t,e,r=[]){return{type:"Until",condition:t,body:e,redirections:r}},caseNode(t,e,r=[]){return{type:"Case",word:t,items:e,redirections:r}},caseItem(t,e,r=";;"){return{type:"CaseItem",patterns:t,body:e,terminator:r}},subshell(t,e=[]){return{type:"Subshell",body:t,redirections:e}},group(t,e=[]){return{type:"Group",body:t,redirections:e}},functionDef(t,e,r=[]){return{type:"FunctionDef",name:t,body:e,redirections:r}},conditionalCommand(t,e=[]){return{type:"ConditionalCommand",expression:t,redirections:e}},arithmeticCommand(t,e=[]){return{type:"ArithmeticCommand",expression:t,redirections:e}}};var y;(function(t){t.EOF="EOF",t.NEWLINE="NEWLINE",t.SEMICOLON="SEMICOLON",t.AMP="AMP",t.PIPE="PIPE",t.PIPE_AMP="PIPE_AMP",t.AND_AND="AND_AND",t.OR_OR="OR_OR",t.BANG="BANG",t.LESS="LESS",t.GREAT="GREAT",t.DLESS="DLESS",t.DGREAT="DGREAT",t.LESSAND="LESSAND",t.GREATAND="GREATAND",t.LESSGREAT="LESSGREAT",t.DLESSDASH="DLESSDASH",t.CLOBBER="CLOBBER",t.TLESS="TLESS",t.AND_GREAT="AND_GREAT",t.AND_DGREAT="AND_DGREAT",t.LPAREN="LPAREN",t.RPAREN="RPAREN",t.LBRACE="LBRACE",t.RBRACE="RBRACE",t.DSEMI="DSEMI",t.SEMI_AND="SEMI_AND",t.SEMI_SEMI_AND="SEMI_SEMI_AND",t.DBRACK_START="DBRACK_START",t.DBRACK_END="DBRACK_END",t.DPAREN_START="DPAREN_START",t.DPAREN_END="DPAREN_END",t.IF="IF",t.THEN="THEN",t.ELSE="ELSE",t.ELIF="ELIF",t.FI="FI",t.FOR="FOR",t.WHILE="WHILE",t.UNTIL="UNTIL",t.DO="DO",t.DONE="DONE",t.CASE="CASE",t.ESAC="ESAC",t.IN="IN",t.FUNCTION="FUNCTION",t.SELECT="SELECT",t.TIME="TIME",t.COPROC="COPROC",t.WORD="WORD",t.NAME="NAME",t.NUMBER="NUMBER",t.ASSIGNMENT_WORD="ASSIGNMENT_WORD",t.COMMENT="COMMENT",t.HEREDOC_CONTENT="HEREDOC_CONTENT"})(y||(y={}));var fn={if:y.IF,then:y.THEN,else:y.ELSE,elif:y.ELIF,fi:y.FI,for:y.FOR,while:y.WHILE,until:y.UNTIL,do:y.DO,done:y.DONE,case:y.CASE,esac:y.ESAC,in:y.IN,function:y.FUNCTION,select:y.SELECT,time:y.TIME,coproc:y.COPROC};function Gu(t){let e=t.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!e)return!1;let r=t.slice(e[0].length);if(r===""||r==="+")return!0;if(r[0]==="["){let n=0,s=0;for(;s<r.length;s++)if(r[s]==="[")n++;else if(r[s]==="]"&&(n--,n===0))break;if(n!==0||s>=r.length)return!1;let i=r.slice(s+1);return i===""||i==="+"}return!1}var ny=[[";",";","&",y.SEMI_SEMI_AND],["<","<","<",y.TLESS],["&",">",">",y.AND_DGREAT]],sy=[["[","[",y.DBRACK_START],["]","]",y.DBRACK_END],["(","(",y.DPAREN_START],[")",")",y.DPAREN_END],["&","&",y.AND_AND],["|","|",y.OR_OR],[";",";",y.DSEMI],[";","&",y.SEMI_AND],["|","&",y.PIPE_AMP],[">",">",y.DGREAT],["<","&",y.LESSAND],[">","&",y.GREATAND],["<",">",y.LESSGREAT],[">","|",y.CLOBBER],["&",">",y.AND_GREAT]],iy={"|":y.PIPE,"&":y.AMP,";":y.SEMICOLON,"(":y.LPAREN,")":y.RPAREN,"<":y.LESS,">":y.GREAT};function oy(t){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)}var pn=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];constructor(e){this.input=e}tokenize(){let r=this.input.length,n=this.tokens,s=this.pendingHeredocs;for(;this.pos<r&&(this.skipWhitespace(),!(this.pos>=r));){if(s.length>0&&n.length>0&&n[n.length-1].type===y.NEWLINE){this.readHeredocContent();continue}let i=this.nextToken();i&&n.push(i)}return n.push({type:y.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),n}skipWhitespace(){let e=this.input,r=e.length,n=this.pos,s=this.column,i=this.line;for(;n<r;){let o=e[n];if(o===" "||o===" ")n++,s++;else if(o==="\\"&&e[n+1]===`
620
620
  `)n+=2,i++,s=1;else break}this.pos=n,this.column=s,this.line=i}nextToken(){let e=this.input,r=this.pos,n=this.line,s=this.column,i=e[r],o=e[r+1],a=e[r+2];if(i==="#")return this.readComment(r,n,s);if(i===`
621
- `)return this.pos=r+1,this.line++,this.column=1,{type:g.NEWLINE,value:`
622
- `,start:r,end:r+1,line:n,column:s};if(i==="<"&&o==="<"&&a==="-")return this.pos=r+3,this.column=s+3,this.registerHeredocFromLookahead(!0),this.makeToken(g.DLESSDASH,"<<-",r,n,s);for(let[c,u,f,d]of Zg)if(i===c&&o===u&&a===f)return this.pos=r+3,this.column=s+3,this.makeToken(d,c+u+f,r,n,s);if(i==="<"&&o==="<")return this.pos=r+2,this.column=s+2,this.registerHeredocFromLookahead(!1),this.makeToken(g.DLESS,"<<",r,n,s);for(let[c,u,f]of Qg)if(i===c&&o===u)return this.pos=r+2,this.column=s+2,this.makeToken(f,c+u,r,n,s);let l=Xg[i];return l?(this.pos=r+1,this.column=s+1,this.makeToken(l,i,r,n,s)):i==="{"?o==="}"?(this.pos=r+2,this.column=s+2,{type:g.WORD,value:"{}",start:r,end:r+2,line:n,column:s,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(r)!==null?this.readWordWithBraceExpansion(r,n,s):this.scanLiteralBraceWord(r)!==null?this.readWordWithBraceExpansion(r,n,s):o!==void 0&&o!==" "&&o!==" "&&o!==`
623
- `?this.readWord(r,n,s):(this.pos=r+1,this.column=s+1,this.makeToken(g.LBRACE,"{",r,n,s)):i==="}"?this.isWordCharFollowing(r+1)?this.readWord(r,n,s):(this.pos=r+1,this.column=s+1,this.makeToken(g.RBRACE,"}",r,n,s)):i==="!"?o==="="?(this.pos=r+2,this.column=s+2,this.makeToken(g.WORD,"!=",r,n,s)):(this.pos=r+1,this.column=s+1,this.makeToken(g.BANG,"!",r,n,s)):this.readWord(r,n,s)}makeToken(e,r,n,s,i){return{type:e,value:r,start:n,end:this.pos,line:s,column:i}}readComment(e,r,n){let s=this.input,i=s.length,o=this.pos;for(;o<i&&s[o]!==`
624
- `;)o++;let a=s.slice(e,o);return this.pos=o,this.column=n+(o-e),{type:g.COMMENT,value:a,start:e,end:o,line:r,column:n}}readWord(e,r,n){let s=this.input,i=s.length,o=this.pos,a=o;for(;o<i;){let m=s[o];if(m===" "||m===" "||m===`
625
- `||m===";"||m==="&"||m==="|"||m==="("||m===")"||m==="<"||m===">"||m==="'"||m==='"'||m==="\\"||m==="$"||m==="`"||m==="{"||m==="}"||m==="~"||m==="*"||m==="?"||m==="[")break;o++}if(o>a){let m=s[o];if(o>=i||m===" "||m===" "||m===`
626
- `||m===";"||m==="&"||m==="|"||m==="("||m===")"||m==="<"||m===">"){let w=s.slice(a,o);if(this.pos=o,this.column=n+(o-a),en[w])return{type:en[w],value:w,start:e,end:o,line:r,column:n};let b=w.indexOf("=");return b>0&&Mu(w.slice(0,b))?{type:g.ASSIGNMENT_WORD,value:w,start:e,end:o,line:r,column:n}:/^[0-9]+$/.test(w)?{type:g.NUMBER,value:w,start:e,end:o,line:r,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)?{type:g.NAME,value:w,start:e,end:o,line:r,column:n,quoted:!1,singleQuoted:!1}:{type:g.WORD,value:w,start:e,end:o,line:r,column:n,quoted:!1,singleQuoted:!1}}}o=this.pos;let l=this.column,c=this.line,u="",f=!1,d=!1,p=!1,h=!1,y=s[o]==='"'||s[o]==="'";for(;o<i;){let m=s[o];if(!p&&!h&&(m===" "||m===" "||m===`
627
- `||m===";"||m==="&"||m==="|"||m==="("||m===")"||m==="<"||m===">"))break;if(m==="$"&&o+1<i&&s[o+1]==="'"&&!p&&!h){for(u+="$'",o+=2,l+=2;o<i&&s[o]!=="'";)s[o]==="\\"&&o+1<i?(u+=s[o]+s[o+1],o+=2,l+=2):(u+=s[o],o++,l++);o<i&&(u+="'",o++,l++);continue}if(m==="$"&&o+1<i&&s[o+1]==='"'&&!p&&!h){o++,l++,h=!0,f=!0,u===""&&(y=!0),o++,l++;continue}if(m==="'"&&!h){p?(p=!1,y||(u+=m)):(p=!0,y?(d=!0,f=!0):u+=m),o++,l++;continue}if(m==='"'&&!p){h?(h=!1,y||(u+=m)):(h=!0,y?f=!0:u+=m),o++,l++;continue}if(m==="\\"&&!p&&o+1<i){let w=s[o+1];if(w===`
621
+ `)return this.pos=r+1,this.line++,this.column=1,{type:y.NEWLINE,value:`
622
+ `,start:r,end:r+1,line:n,column:s};if(i==="<"&&o==="<"&&a==="-")return this.pos=r+3,this.column=s+3,this.registerHeredocFromLookahead(!0),this.makeToken(y.DLESSDASH,"<<-",r,n,s);for(let[c,u,f,p]of ny)if(i===c&&o===u&&a===f)return this.pos=r+3,this.column=s+3,this.makeToken(p,c+u+f,r,n,s);if(i==="<"&&o==="<")return this.pos=r+2,this.column=s+2,this.registerHeredocFromLookahead(!1),this.makeToken(y.DLESS,"<<",r,n,s);for(let[c,u,f]of sy)if(i===c&&o===u)return this.pos=r+2,this.column=s+2,this.makeToken(f,c+u,r,n,s);let l=iy[i];return l?(this.pos=r+1,this.column=s+1,this.makeToken(l,i,r,n,s)):i==="{"?o==="}"?(this.pos=r+2,this.column=s+2,{type:y.WORD,value:"{}",start:r,end:r+2,line:n,column:s,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(r)!==null?this.readWordWithBraceExpansion(r,n,s):this.scanLiteralBraceWord(r)!==null?this.readWordWithBraceExpansion(r,n,s):o!==void 0&&o!==" "&&o!==" "&&o!==`
623
+ `?this.readWord(r,n,s):(this.pos=r+1,this.column=s+1,this.makeToken(y.LBRACE,"{",r,n,s)):i==="}"?this.isWordCharFollowing(r+1)?this.readWord(r,n,s):(this.pos=r+1,this.column=s+1,this.makeToken(y.RBRACE,"}",r,n,s)):i==="!"?o==="="?(this.pos=r+2,this.column=s+2,this.makeToken(y.WORD,"!=",r,n,s)):(this.pos=r+1,this.column=s+1,this.makeToken(y.BANG,"!",r,n,s)):this.readWord(r,n,s)}makeToken(e,r,n,s,i){return{type:e,value:r,start:n,end:this.pos,line:s,column:i}}readComment(e,r,n){let s=this.input,i=s.length,o=this.pos;for(;o<i&&s[o]!==`
624
+ `;)o++;let a=s.slice(e,o);return this.pos=o,this.column=n+(o-e),{type:y.COMMENT,value:a,start:e,end:o,line:r,column:n}}readWord(e,r,n){let s=this.input,i=s.length,o=this.pos,a=o;for(;o<i;){let g=s[o];if(g===" "||g===" "||g===`
625
+ `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"||g==="'"||g==='"'||g==="\\"||g==="$"||g==="`"||g==="{"||g==="}"||g==="~"||g==="*"||g==="?"||g==="[")break;o++}if(o>a){let g=s[o];if(o>=i||g===" "||g===" "||g===`
626
+ `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"){let w=s.slice(a,o);if(this.pos=o,this.column=n+(o-a),fn[w])return{type:fn[w],value:w,start:e,end:o,line:r,column:n};let b=w.indexOf("=");return b>0&&Gu(w.slice(0,b))?{type:y.ASSIGNMENT_WORD,value:w,start:e,end:o,line:r,column:n}:/^[0-9]+$/.test(w)?{type:y.NUMBER,value:w,start:e,end:o,line:r,column:n}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(w)?{type:y.NAME,value:w,start:e,end:o,line:r,column:n,quoted:!1,singleQuoted:!1}:{type:y.WORD,value:w,start:e,end:o,line:r,column:n,quoted:!1,singleQuoted:!1}}}o=this.pos;let l=this.column,c=this.line,u="",f=!1,p=!1,d=!1,h=!1,m=s[o]==='"'||s[o]==="'";for(;o<i;){let g=s[o];if(!d&&!h&&(g===" "||g===" "||g===`
627
+ `||g===";"||g==="&"||g==="|"||g==="("||g===")"||g==="<"||g===">"))break;if(g==="$"&&o+1<i&&s[o+1]==="'"&&!d&&!h){for(u+="$'",o+=2,l+=2;o<i&&s[o]!=="'";)s[o]==="\\"&&o+1<i?(u+=s[o]+s[o+1],o+=2,l+=2):(u+=s[o],o++,l++);o<i&&(u+="'",o++,l++);continue}if(g==="$"&&o+1<i&&s[o+1]==='"'&&!d&&!h){o++,l++,h=!0,f=!0,u===""&&(m=!0),o++,l++;continue}if(g==="'"&&!h){d?(d=!1,m||(u+=g)):(d=!0,m?(p=!0,f=!0):u+=g),o++,l++;continue}if(g==='"'&&!d){h?(h=!1,m||(u+=g)):(h=!0,m?f=!0:u+=g),o++,l++;continue}if(g==="\\"&&!d&&o+1<i){let w=s[o+1];if(w===`
628
628
  `){o+=2,c++,l=1;continue}if(h){if(w==='"'||w==="\\"||w==="$"||w==="`"||w===`
629
- `){w==="$"||w==="`"?u+=m+w:u+=w,o+=2,l+=2;continue}}else{w==='"'||w==="'"?u+=m+w:u+=w,o+=2,l+=2;continue}}if(m==="$"&&o+1<i&&s[o+1]==="("){u+=m,o++,l++,u+=s[o],o++,l++;let w=1,b=!1,E=!1,S=0,A=!1,F="",M=s[o]==="(";for(;w>0&&o<i;){let D=s[o];if(u+=D,b)D==="'"&&(b=!1);else if(E)D==="\\"&&o+1<i?(u+=s[o+1],o++,l++):D==='"'&&(E=!1);else if(D==="'")b=!0,F="";else if(D==='"')E=!0,F="";else if(D==="\\"&&o+1<i)u+=s[o+1],o++,l++,F="";else if(D==="#"&&!M&&(F===""||/\s/.test(s[o-1]||""))){for(;o+1<i&&s[o+1]!==`
630
- `;)o++,l++,u+=s[o];F=""}else/[a-zA-Z_]/.test(D)?F+=D:(F==="case"?(S++,A=!1):F==="in"&&S>0?A=!0:F==="esac"&&S>0&&(S--,A=!1),F="",D==="("?o>0&&s[o-1]==="$"?w++:A||w++:D===")"?A?A=!1:w--:D===";"&&S>0&&o+1<i&&s[o+1]===";"&&(A=!0));D===`
631
- `&&(c++,l=0,F=""),o++,l++}continue}if(m==="$"&&o+1<i&&s[o+1]==="["){u+=m,o++,l++,u+=s[o],o++,l++;let w=1;for(;w>0&&o<i;){let b=s[o];u+=b,b==="["?w++:b==="]"?w--:b===`
632
- `&&(c++,l=0),o++,l++}continue}if(m==="$"&&o+1<i&&s[o+1]==="{"){u+=m,o++,l++,u+=s[o],o++,l++;let w=1;for(;w>0&&o<i;){let b=s[o];u+=b,b==="{"?w++:b==="}"?w--:b===`
633
- `&&(c++,l=0),o++,l++}continue}if(m==="$"&&o+1<i){let w=s[o+1];if(w==="#"||w==="?"||w==="$"||w==="!"||w==="@"||w==="*"||w==="-"||w>="0"&&w<="9"){u+=m+w,o+=2,l+=2;continue}}if(m==="`"){for(u+=m,o++,l++;o<i&&s[o]!=="`";){let w=s[o];u+=w,w==="\\"&&o+1<i&&(u+=s[o+1],o++,l++),w===`
634
- `&&(c++,l=0),o++,l++}o<i&&(u+=s[o],o++,l++);continue}u+=m,o++,m===`
635
- `?(c++,l=1):l++}if(this.pos=o,this.column=l,this.line=c,u==="")return{type:g.WORD,value:"",start:e,end:o,line:r,column:n,quoted:f,singleQuoted:d};if(!f&&en[u])return{type:en[u],value:u,start:e,end:o,line:r,column:n};if(!y){let m=u.indexOf("=");if(m>0&&Mu(u.slice(0,m)))return{type:g.ASSIGNMENT_WORD,value:u,start:e,end:o,line:r,column:n,quoted:f,singleQuoted:d}}return/^[0-9]+$/.test(u)?{type:g.NUMBER,value:u,start:e,end:o,line:r,column:n}:Jg(u)?{type:g.NAME,value:u,start:e,end:o,line:r,column:n,quoted:f,singleQuoted:d}:{type:g.WORD,value:u,start:e,end:o,line:r,column:n,quoted:f,singleQuoted:d}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let r=this.pos,n=this.line,s=this.column,i="";for(;this.pos<this.input.length;){let o=this.pos,a="";for(;this.pos<this.input.length&&this.input[this.pos]!==`
629
+ `){w==="$"||w==="`"?u+=g+w:u+=w,o+=2,l+=2;continue}}else{w==='"'||w==="'"?u+=g+w:u+=w,o+=2,l+=2;continue}}if(g==="$"&&o+1<i&&s[o+1]==="("){u+=g,o++,l++,u+=s[o],o++,l++;let w=1,b=!1,E=!1,S=0,v=!1,D="",I=s[o]==="(";for(;w>0&&o<i;){let $=s[o];if(u+=$,b)$==="'"&&(b=!1);else if(E)$==="\\"&&o+1<i?(u+=s[o+1],o++,l++):$==='"'&&(E=!1);else if($==="'")b=!0,D="";else if($==='"')E=!0,D="";else if($==="\\"&&o+1<i)u+=s[o+1],o++,l++,D="";else if($==="#"&&!I&&(D===""||/\s/.test(s[o-1]||""))){for(;o+1<i&&s[o+1]!==`
630
+ `;)o++,l++,u+=s[o];D=""}else/[a-zA-Z_]/.test($)?D+=$:(D==="case"?(S++,v=!1):D==="in"&&S>0?v=!0:D==="esac"&&S>0&&(S--,v=!1),D="",$==="("?o>0&&s[o-1]==="$"?w++:v||w++:$===")"?v?v=!1:w--:$===";"&&S>0&&o+1<i&&s[o+1]===";"&&(v=!0));$===`
631
+ `&&(c++,l=0,D=""),o++,l++}continue}if(g==="$"&&o+1<i&&s[o+1]==="["){u+=g,o++,l++,u+=s[o],o++,l++;let w=1;for(;w>0&&o<i;){let b=s[o];u+=b,b==="["?w++:b==="]"?w--:b===`
632
+ `&&(c++,l=0),o++,l++}continue}if(g==="$"&&o+1<i&&s[o+1]==="{"){u+=g,o++,l++,u+=s[o],o++,l++;let w=1;for(;w>0&&o<i;){let b=s[o];u+=b,b==="{"?w++:b==="}"?w--:b===`
633
+ `&&(c++,l=0),o++,l++}continue}if(g==="$"&&o+1<i){let w=s[o+1];if(w==="#"||w==="?"||w==="$"||w==="!"||w==="@"||w==="*"||w==="-"||w>="0"&&w<="9"){u+=g+w,o+=2,l+=2;continue}}if(g==="`"){for(u+=g,o++,l++;o<i&&s[o]!=="`";){let w=s[o];u+=w,w==="\\"&&o+1<i&&(u+=s[o+1],o++,l++),w===`
634
+ `&&(c++,l=0),o++,l++}o<i&&(u+=s[o],o++,l++);continue}u+=g,o++,g===`
635
+ `?(c++,l=1):l++}if(this.pos=o,this.column=l,this.line=c,u==="")return{type:y.WORD,value:"",start:e,end:o,line:r,column:n,quoted:f,singleQuoted:p};if(!f&&fn[u])return{type:fn[u],value:u,start:e,end:o,line:r,column:n};if(!m){let g=u.indexOf("=");if(g>0&&Gu(u.slice(0,g)))return{type:y.ASSIGNMENT_WORD,value:u,start:e,end:o,line:r,column:n,quoted:f,singleQuoted:p}}return/^[0-9]+$/.test(u)?{type:y.NUMBER,value:u,start:e,end:o,line:r,column:n}:oy(u)?{type:y.NAME,value:u,start:e,end:o,line:r,column:n,quoted:f,singleQuoted:p}:{type:y.WORD,value:u,start:e,end:o,line:r,column:n,quoted:f,singleQuoted:p}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let e=this.pendingHeredocs.shift();if(!e)break;let r=this.pos,n=this.line,s=this.column,i="";for(;this.pos<this.input.length;){let o=this.pos,a="";for(;this.pos<this.input.length&&this.input[this.pos]!==`
636
636
  `;)a+=this.input[this.pos],this.pos++,this.column++;if((e.stripTabs?a.replace(/^\t+/,""):a)===e.delimiter){this.pos<this.input.length&&this.input[this.pos]===`
637
637
  `&&(this.pos++,this.line++,this.column=1);break}i+=a,this.pos<this.input.length&&this.input[this.pos]===`
638
638
  `&&(i+=`
639
- `,this.pos++,this.line++,this.column=1)}this.tokens.push({type:g.HEREDOC_CONTENT,value:i,start:r,end:this.pos,line:n,column:s})}}addPendingHeredoc(e,r,n){this.pendingHeredocs.push({delimiter:e,stripTabs:r,quoted:n})}registerHeredocFromLookahead(e){let r=this.pos,n=this.column;for(;this.pos<this.input.length&&(this.input[this.pos]===" "||this.input[this.pos]===" ");)this.pos++,this.column++;let s="",i=!1,o=this.input[this.pos];if(o==="'"||o==='"'){i=!0;let a=o;for(this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]!==a;)s+=this.input[this.pos],this.pos++,this.column++}else for(;this.pos<this.input.length&&!/[\s;<>&|()]/.test(this.input[this.pos]);)s+=this.input[this.pos],this.pos++,this.column++;this.pos=r,this.column=n,s&&this.pendingHeredocs.push({delimiter:s,stripTabs:e,quoted:i})}isWordCharFollowing(e){if(e>=this.input.length)return!1;let r=this.input[e];return!(r===" "||r===" "||r===`
639
+ `,this.pos++,this.line++,this.column=1)}this.tokens.push({type:y.HEREDOC_CONTENT,value:i,start:r,end:this.pos,line:n,column:s})}}addPendingHeredoc(e,r,n){this.pendingHeredocs.push({delimiter:e,stripTabs:r,quoted:n})}registerHeredocFromLookahead(e){let r=this.pos,n=this.column;for(;this.pos<this.input.length&&(this.input[this.pos]===" "||this.input[this.pos]===" ");)this.pos++,this.column++;let s="",i=!1,o=this.input[this.pos];if(o==="'"||o==='"'){i=!0;let a=o;for(this.pos++,this.column++;this.pos<this.input.length&&this.input[this.pos]!==a;)s+=this.input[this.pos],this.pos++,this.column++}else for(;this.pos<this.input.length&&!/[\s;<>&|()]/.test(this.input[this.pos]);)s+=this.input[this.pos],this.pos++,this.column++;this.pos=r,this.column=n,s&&this.pendingHeredocs.push({delimiter:s,stripTabs:e,quoted:i})}isWordCharFollowing(e){if(e>=this.input.length)return!1;let r=this.input[e];return!(r===" "||r===" "||r===`
640
640
  `||r===";"||r==="&"||r==="|"||r==="("||r===")"||r==="<"||r===">")}readWordWithBraceExpansion(e,r,n){let s=this.input,i=s.length,o=e,a=n;for(;o<i;){let c=s[o];if(c===" "||c===" "||c===`
641
- `||c===";"||c==="&"||c==="|"||c==="("||c===")"||c==="<"||c===">")break;if(c==="{"){if(this.scanBraceExpansion(o)!==null){let f=1;for(o++,a++;o<i&&f>0;)s[o]==="{"?f++:s[o]==="}"&&f--,o++,a++;continue}o++,a++;continue}if(c==="}"){o++,a++;continue}if(c==="$"&&o+1<i&&s[o+1]==="("){o++,a++,o++,a++;let u=1;for(;u>0&&o<i;)s[o]==="("?u++:s[o]===")"&&u--,o++,a++;continue}if(c==="$"&&o+1<i&&s[o+1]==="{"){o++,a++,o++,a++;let u=1;for(;u>0&&o<i;)s[o]==="{"?u++:s[o]==="}"&&u--,o++,a++;continue}if(c==="`"){for(o++,a++;o<i&&s[o]!=="`";)s[o]==="\\"&&o+1<i?(o+=2,a+=2):(o++,a++);o<i&&(o++,a++);continue}o++,a++}let l=s.slice(e,o);return this.pos=o,this.column=a,{type:g.WORD,value:l,start:e,end:o,line:r,column:n,quoted:!1,singleQuoted:!1}}scanBraceExpansion(e){let r=this.input,n=r.length,s=e+1,i=1,o=!1,a=!1;for(;s<n&&i>0;){let l=r[s];if(l==="{")i++,s++;else if(l==="}")i--,s++;else if(l===","&&i===1)o=!0,s++;else if(l==="."&&s+1<n&&r[s+1]===".")a=!0,s+=2;else{if(l===" "||l===" "||l===`
641
+ `||c===";"||c==="&"||c==="|"||c==="("||c===")"||c==="<"||c===">")break;if(c==="{"){if(this.scanBraceExpansion(o)!==null){let f=1;for(o++,a++;o<i&&f>0;)s[o]==="{"?f++:s[o]==="}"&&f--,o++,a++;continue}o++,a++;continue}if(c==="}"){o++,a++;continue}if(c==="$"&&o+1<i&&s[o+1]==="("){o++,a++,o++,a++;let u=1;for(;u>0&&o<i;)s[o]==="("?u++:s[o]===")"&&u--,o++,a++;continue}if(c==="$"&&o+1<i&&s[o+1]==="{"){o++,a++,o++,a++;let u=1;for(;u>0&&o<i;)s[o]==="{"?u++:s[o]==="}"&&u--,o++,a++;continue}if(c==="`"){for(o++,a++;o<i&&s[o]!=="`";)s[o]==="\\"&&o+1<i?(o+=2,a+=2):(o++,a++);o<i&&(o++,a++);continue}o++,a++}let l=s.slice(e,o);return this.pos=o,this.column=a,{type:y.WORD,value:l,start:e,end:o,line:r,column:n,quoted:!1,singleQuoted:!1}}scanBraceExpansion(e){let r=this.input,n=r.length,s=e+1,i=1,o=!1,a=!1;for(;s<n&&i>0;){let l=r[s];if(l==="{")i++,s++;else if(l==="}")i--,s++;else if(l===","&&i===1)o=!0,s++;else if(l==="."&&s+1<n&&r[s+1]===".")a=!0,s+=2;else{if(l===" "||l===" "||l===`
642
642
  `||l===";"||l==="&"||l==="|")return null;s++}}return i===0&&(o||a)?r.slice(e,s):null}scanLiteralBraceWord(e){let r=this.input,n=r.length,s=e+1,i=1;for(;s<n&&i>0;){let o=r[s];if(o==="{")i++,s++;else if(o==="}"){if(i--,i===0)return r.slice(e,s+1);s++}else{if(o===" "||o===" "||o===`
643
- `||o===";"||o==="&"||o==="|")return null;s++}}return null}};var Ps=1e6,Os=1e5,_u=1e6,Bu=new Set([g.LESS,g.GREAT,g.DLESS,g.DGREAT,g.LESSAND,g.GREATAND,g.LESSGREAT,g.DLESSDASH,g.CLOBBER,g.TLESS,g.AND_GREAT,g.AND_DGREAT]),Wu=new Set([g.LESS,g.GREAT,g.DLESS,g.DGREAT,g.LESSAND,g.GREATAND,g.LESSGREAT,g.DLESSDASH,g.CLOBBER,g.TLESS]),Ze=class extends Error{line;column;token;constructor(e,r,n,s=void 0){super(`Parse error at ${r}:${n}: ${e}`),this.line=r,this.column=n,this.token=s,this.name="ParseException"}};function ju(t,e,r){let n=r+1;for(;n<e.length&&/[a-zA-Z0-9_-]/.test(e[n]);)n++;return n}function Fs(t,e,r,n,s){let i=1,o=r+1;for(;o<e.length&&i>0;)e[o]===n?i++:e[o]===s&&i--,i>0&&o++;return i===0?o:-1}function xt(t,e,r){let n=r,s=1;for(;n<e.length&&s>0;){let i=e[n];if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="'"){let o=e.indexOf("'",n+1);if(o!==-1){n=o+1;continue}}if(i==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}i==="{"?s++:i==="}"&&s--,s>0&&n++}return n}function zu(t,e,r){let n=r,s=!1;for(;n<e.length;){let i=e[n];if(i==="/"&&s||i==="}")break;if(i==="'"){let o=e.indexOf("'",n+1);if(o!==-1){n=o+1,s=!0;continue}}if(i==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++,s=!0;continue}i==="\\"?(n+=2,s=!0):(n++,s=!0)}return n}function Hu(t,e,r){let n=r,s="";for(;n<e.length;){let i=e[n];if(i==="*"||i==="?")s+=i,n++;else if(i==="["){let o=Yg(e,n);o===-1?(s+=i,n++):(s+=e.slice(n,o+1),n=o+1)}else break}return{pattern:s,endIndex:n}}function Yg(t,e){let r=e+1;for(r<t.length&&t[r]==="^"&&r++,r<t.length&&t[r]==="]"&&r++;r<t.length;){let n=t[r];if(n==="\\"&&r+1<t.length){r+=2;continue}if(n==="]")return r;if(n==='"'||n==="$"||n==="`")return-1;if(n==="'"){let s=t.indexOf("'",r+1);if(s!==-1){r=s+1;continue}}if(n==="["&&r+1<t.length&&t[r+1]===":"){let s=t.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}if(n==="["&&r+1<t.length&&(t[r+1]==="."||t[r+1]==="=")){let i=`${t[r+1]}]`,o=t.indexOf(i,r+2);if(o!==-1){r=o+2;continue}}r++}return-1}function Gu(t,e,r){let n="",s=r;for(;s<e.length&&e[s]!=="'";){let i=e[s];if(i==="\\"&&s+1<e.length)switch(e[s+1]){case"n":n+=`
644
- `,s+=2;break;case"t":n+=" ",s+=2;break;case"r":n+="\r",s+=2;break;case"\\":n+="\\",s+=2;break;case"'":n+="'",s+=2;break;case'"':n+='"',s+=2;break;case"a":n+="\x07",s+=2;break;case"b":n+="\b",s+=2;break;case"e":case"E":n+="\x1B",s+=2;break;case"f":n+="\f",s+=2;break;case"v":n+="\v",s+=2;break;case"x":{let a=e.slice(s+2,s+4),l=parseInt(a,16);Number.isNaN(l)?(n+="\\x",s+=2):(n+=String.fromCharCode(l),s+=4);break}case"u":{let a=e.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(n+="\\u",s+=2):(n+=String.fromCharCode(l),s+=6);break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<e.length&&l<s+4&&/[0-7]/.test(e[l]);)a+=e[l],l++;let c=parseInt(a,8);n+=String.fromCharCode(c),s=l;break}default:n+=i,s++}else n+=i,s++}return s<e.length&&e[s]==="'"&&s++,{part:R.literal(n),endIndex:s}}function Ts(t,e){let r=e.trim();return r===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:ue(t,r)}function Uu(t){let e=[],r="",n=0;for(let s=0;s<t.length;s++){let i=t[s];i==="{"?(n++,r+=i):i==="}"?(n--,r+=i):i===","&&n===0?(e.push(r),r=""):r+=i}return e.push(r),e}function qu(t,e,r,n){let s=Fs(t,e,r,"{","}");if(s===-1)return null;let i=e.slice(r+1,s),o=i.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:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&n?{part:{type:"BraceExpansion",items:Uu(i).map(u=>({type:"Word",word:R.word(n(t,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:Uu(i).map(u=>({type:"Word",word:R.word([R.literal(u)])}))},endIndex:s+1}:null}function Vu(t,e){let r="";for(let n of e.parts)switch(n.type){case"Literal":case"SingleQuoted":case"Escaped":r+=n.value;break;case"DoubleQuoted":r+='"';for(let s of n.parts)s.type==="Literal"||s.type==="Escaped"?r+=s.value:s.type==="ParameterExpansion"&&(r+=`\${${s.parameter}}`);r+='"';break;case"ParameterExpansion":r+=`\${${n.parameter}}`;break;case"Glob":r+=n.pattern;break;default:r+=n.type}return r}function Ku(t,e){return{[g.LESS]:"<",[g.GREAT]:">",[g.DGREAT]:">>",[g.LESSAND]:"<&",[g.GREATAND]:">&",[g.LESSGREAT]:"<>",[g.CLOBBER]:">|",[g.TLESS]:"<<<",[g.AND_GREAT]:"&>",[g.AND_DGREAT]:"&>>",[g.DLESS]:"<",[g.DLESSDASH]:"<"}[e]||">"}function rn(t){let e=t.current(),r=e.type;if(r===g.NUMBER){let n=t.peek(1);return e.end!==n.start?!1:Wu.has(n.type)}return Bu.has(r)}function nn(t){let e=null;t.check(g.NUMBER)&&(e=Number.parseInt(t.advance().value,10));let r=t.advance(),n=Ku(t,r.type);if(r.type===g.DLESS||r.type===g.DLESSDASH)return ey(t,n,e,r.type===g.DLESSDASH);t.isWord()||t.error("Expected redirection target");let s=t.parseWord();return R.redirection(n,s,e)}function ey(t,e,r,n){t.isWord()||t.error("Expected here-document delimiter");let s=t.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=R.redirection(n?"<<-":"<<",R.hereDoc(i,R.word([]),n,o),r);return t.addPendingHeredoc(a,i,n,o),a}function Qu(t){let e=t.current().line,r=[],n=null,s=[],i=[];for(;t.check(g.ASSIGNMENT_WORD);)t.checkIterationLimit(),r.push(ty(t));for(;rn(t);)t.checkIterationLimit(),i.push(nn(t));for(t.isWord()&&(n=t.parseWord());(!t.isStatementEnd()||t.check(g.RBRACE))&&!t.check(g.PIPE,g.PIPE_AMP);)if(t.checkIterationLimit(),rn(t))i.push(nn(t));else if(t.check(g.RBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.isWord())s.push(t.parseWord());else if(t.check(g.ASSIGNMENT_WORD)){let a=t.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||t.check(g.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||t.expect(g.LPAREN);let d=Ls(t);t.expect(g.RPAREN);let p=d.map(y=>Vu(t,y)),h=`${f}=(${p.join(" ")})`;s.push(t.parseWordFromString(h,!1,!1))}else s.push(t.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(t.check(g.LPAREN))t.error("syntax error near unexpected token `('");else break;let o=R.simpleCommand(n,s,r,i);return o.line=e,o}function ty(t){let e=t.expect(g.ASSIGNMENT_WORD),r=e.value,n=r.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);n||t.error(`Invalid assignment: ${r}`);let s=n[0],i,o=s.length;if(r[o]==="["){let f=0,d=o+1;for(;o<r.length;o++)if(r[o]==="[")f++;else if(r[o]==="]"&&(f--,f===0))break;f!==0&&t.error(`Invalid assignment: ${r}`),i=r.slice(d,o),o++}let a=r[o]==="+";a&&o++,r[o]!=="="&&t.error(`Invalid assignment: ${r}`),o++;let l=r.slice(o);if(l==="("){let f=Ls(t);t.expect(g.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return R.assignment(d,null,a,f)}if(l===""&&t.check(g.LPAREN)){let f=t.current();if(e.end===f.start){t.advance();let d=Ls(t);t.expect(g.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return R.assignment(p,null,a,d)}}let c=l?t.parseWordFromString(l,e.quoted,e.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return R.assignment(u,c,a,null)}function Ls(t){let e=[];for(t.skipNewlines();!t.check(g.RPAREN,g.EOF);)t.checkIterationLimit(),t.isWord()?e.push(t.parseWord()):t.advance(),t.skipNewlines();return e}function Ds(t){t.expect(g.IF);let e=[],r=t.parseCompoundList();t.expect(g.THEN);let n=t.parseCompoundList();if(n.length===0){let o=t.check(g.FI)?"fi":t.check(g.ELSE)?"else":t.check(g.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${o}'`)}for(e.push({condition:r,body:n});t.check(g.ELIF);){t.advance();let o=t.parseCompoundList();t.expect(g.THEN);let a=t.parseCompoundList();if(a.length===0){let l=t.check(g.FI)?"fi":t.check(g.ELSE)?"else":t.check(g.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${l}'`)}e.push({condition:o,body:a})}let s=null;t.check(g.ELSE)&&(t.advance(),s=t.parseCompoundList(),s.length===0&&t.error("syntax error near unexpected token `fi'")),t.expect(g.FI);let i=t.parseOptionalRedirections();return R.ifNode(e,s,i)}function Ms(t){if(t.expect(g.FOR),t.check(g.DPAREN_START))return ny(t);t.isWord()||t.error("Expected variable name in for loop");let r=t.advance().value,n=null;if(t.skipNewlines(),t.check(g.IN))for(t.advance(),n=[];!t.check(g.SEMICOLON,g.NEWLINE,g.DO,g.EOF)&&t.isWord();)n.push(t.parseWord());t.check(g.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(g.DO);let s=t.parseCompoundList();t.expect(g.DONE);let i=t.parseOptionalRedirections();return R.forNode(r,n,s,i)}function ny(t){t.expect(g.DPAREN_START);let e=null,r=null,n=null,s=["","",""],i=0,o=0;for(;!t.check(g.DPAREN_END,g.EOF);){let c=t.advance();if(c.type===g.SEMICOLON&&o===0){if(i++,i>2)break}else c.value==="("&&o++,c.value===")"&&o--,s[i]+=c.value}t.expect(g.DPAREN_END),s[0].trim()&&(e=ue(t,s[0].trim())),s[1].trim()&&(r=ue(t,s[1].trim())),s[2].trim()&&(n=ue(t,s[2].trim())),t.skipNewlines(),t.check(g.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(g.DO);let a=t.parseCompoundList();t.expect(g.DONE);let l=t.parseOptionalRedirections();return{type:"CStyleFor",init:e,condition:r,update:n,body:a,redirections:l}}function _s(t){t.expect(g.WHILE);let e=t.parseCompoundList();t.expect(g.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(g.DONE);let n=t.parseOptionalRedirections();return R.whileNode(e,r,n)}function Bs(t){t.expect(g.UNTIL);let e=t.parseCompoundList();t.expect(g.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(g.DONE);let n=t.parseOptionalRedirections();return R.untilNode(e,r,n)}function Ws(t){t.expect(g.CASE),t.isWord()||t.error("Expected word after 'case'");let e=t.parseWord();t.skipNewlines(),t.expect(g.IN),t.skipNewlines();let r=[];for(;!t.check(g.ESAC,g.EOF);){t.checkIterationLimit();let s=t.getPos(),i=sy(t);if(i&&r.push(i),t.skipNewlines(),t.getPos()===s&&!i)break}t.expect(g.ESAC);let n=t.parseOptionalRedirections();return R.caseNode(e,r,n)}function sy(t){t.check(g.LPAREN)&&t.advance();let e=[];for(;t.isWord()&&(e.push(t.parseWord()),t.check(g.PIPE));)t.advance();if(e.length===0)return null;t.expect(g.RPAREN),t.skipNewlines();let r=[];for(;!t.check(g.DSEMI,g.SEMI_AND,g.SEMI_SEMI_AND,g.ESAC,g.EOF);){t.checkIterationLimit(),t.isWord()&&t.peek(1).type===g.RPAREN&&t.error("syntax error near unexpected token `)'"),t.check(g.LPAREN)&&t.peek(1).type===g.WORD&&t.error(`syntax error near unexpected token \`${t.peek(1).value}'`);let s=t.getPos(),i=t.parseStatement();if(i&&r.push(i),t.skipSeparators(!1),t.getPos()===s&&!i)break}let n=";;";return t.check(g.DSEMI)?(t.advance(),n=";;"):t.check(g.SEMI_AND)?(t.advance(),n=";&"):t.check(g.SEMI_SEMI_AND)&&(t.advance(),n=";;&"),R.caseItem(e,r,n)}function Us(t){t.peek(1).type,g.LPAREN,t.expect(g.LPAREN),t.check(g.LPAREN)&&t.advance();let e=t.parseCompoundList();t.expect(g.RPAREN);let r=t.parseOptionalRedirections();return R.subshell(e,r)}function js(t){t.expect(g.LBRACE);let e=t.parseCompoundList();t.expect(g.RBRACE);let r=t.parseOptionalRedirections();return R.group(e,r)}var oy=["-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"],ay=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"];function Hs(t){return t.skipNewlines(),ly(t)}function ly(t){let e=Xu(t);for(t.skipNewlines();t.check(g.OR_OR);){t.advance(),t.skipNewlines();let r=Xu(t);e={type:"CondOr",left:e,right:r},t.skipNewlines()}return e}function Xu(t){let e=zs(t);for(t.skipNewlines();t.check(g.AND_AND);){t.advance(),t.skipNewlines();let r=zs(t);e={type:"CondAnd",left:e,right:r},t.skipNewlines()}return e}function zs(t){return t.skipNewlines(),t.check(g.BANG)?(t.advance(),t.skipNewlines(),{type:"CondNot",operand:zs(t)}):cy(t)}function cy(t){if(t.check(g.LPAREN)){t.advance();let e=Hs(t);return t.expect(g.RPAREN),{type:"CondGroup",expression:e}}if(t.isWord()){let e=t.current(),r=e.value;if(oy.includes(r)&&!e.quoted&&(t.advance(),t.check(g.DBRACK_END)&&t.error(`Expected operand after ${r}`),t.isWord())){let s=t.parseWord();return{type:"CondUnary",operator:r,operand:s}}let n=t.parseWord();if(t.isWord()&&ay.includes(t.current().value)){let s=t.advance().value,i=t.parseWord();return{type:"CondBinary",operator:s,left:n,right:i}}if(t.check(g.LESS)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"<",left:n,right:s}}if(t.check(g.GREAT)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:">",left:n,right:s}}if(t.isWord()&&t.current().value==="="){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"==",left:n,right:s}}return{type:"CondWord",word:n}}t.error("Expected conditional expression")}function fy(t,e,r){let n=r+1,s=e[n];if("@*#?$!-0123456789".includes(s))return{part:R.parameterExpansion(s),endIndex:n+1};let i="";for(;n<e.length&&/[a-zA-Z0-9_]/.test(e[n]);)i+=e[n],n++;return{part:R.parameterExpansion(i),endIndex:n}}function dy(t,e,r,n=!1){let s=r+2,i=!1;e[s]==="!"&&(i=!0,s++);let o=!1;e[s]==="#"&&!/[}:#%/^,]/.test(e[s+1]||"}")&&(o=!0,s++);let a="",l=e[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(e[s+1]||""))a=l,s++;else for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)a+=e[s],s++;if(e[s]==="["){let u=Fs(t,e,s,"[","]");a+=e.slice(s,u+1),s=u+1}a===""&&!i&&!o&&e[s]!=="}"&&t.error(`\${${e[s]}}: bad substitution`);let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(e[s]==="*"||e[s]==="@"){let f=e[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else c={type:"Indirection"}}else if(o)if(e[s]===":")for(c={type:"LengthSliceError"};s<e.length&&e[s]!=="}";)s++;else e[s]!=="}"&&/[-+=?]/.test(e[s])?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<e.length&&e[s]!=="}"){let u=py(t,e,s,a,n);c=u.operation,s=u.endIndex}if(s<e.length&&e[s]!=="}"){let u=e[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<e.length&&e[f]!=="}";)f++;let d=e.slice(r,f+1);t.error(`\${${d.slice(2,-1)}}: bad substitution`)}}for(;s<e.length&&e[s]!=="}";)s++;return{part:R.parameterExpansion(a,c),endIndex:s+1}}function py(t,e,r,n,s=!1){let i=r,o=e[i],a=e[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let w=xt(t,e,i),b=e.slice(i,w),E=tt(t,b,!1,!1,!0,!1,s),S=R.word(E.length>0?E:[R.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:S,checkEmpty:!0},endIndex:w};if(l==="=")return{operation:{type:"AssignDefault",word:S,checkEmpty:!0},endIndex:w};if(l==="?")return{operation:{type:"ErrorIfUnset",word:S,checkEmpty:!0},endIndex:w};if(l==="+")return{operation:{type:"UseAlternative",word:S,checkEmpty:!0},endIndex:w}}i++;let c=xt(t,e,i),u=e.slice(i,c),f=-1,d=0,p=0;for(let m=0;m<u.length;m++){let w=u[m];if(w==="("||w==="[")d++;else if(w===")"||w==="]")d--;else if(w==="?"&&d===0)p++;else if(w===":"&&d===0)if(p>0)p--;else{f=m;break}}let h=f>=0?u.slice(0,f):u,y=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:Ts(t,h),length:y?Ts(t,y):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=xt(t,e,i),c=e.slice(i,l),u=tt(t,c,!1,!1,!0,!1,s),f=R.word(u.length>0?u:[R.literal("")]);if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=xt(t,e,i),f=e.slice(i,u),d=tt(t,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:R.word(d.length>0?d:[R.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;e[i]==="#"?(c="start",i++):e[i]==="%"&&(c="end",i++);let u=zu(t,e,i),f=e.slice(i,u),d=tt(t,f,!1,!1,!1),p=R.word(d.length>0?d:[R.literal("")]),h=null,y=u;if(e[u]==="/"){let m=u+1,w=xt(t,e,m),b=e.slice(m,w),E=tt(t,b,!1,!1,!1);h=R.word(E.length>0?E:[R.literal("")]),y=w}return{operation:{type:"PatternReplacement",pattern:p,replacement:h,all:l,anchor:c},endIndex:y}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=xt(t,e,i),f=e.slice(i,u),d=f?R.word([R.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:d},endIndex:u}}return o==="@"&&/[QPaAEK]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function Gs(t,e,r,n=!1){let s=r+1;if(s>=e.length)return{part:R.literal("$"),endIndex:s};let i=e[s];if(i==="("&&e[s+1]==="(")return t.parseArithmeticExpansion(e,r);if(i==="["){let o=1,a=s+1;for(;a<e.length&&o>0;)e[a]==="["?o++:e[a]==="]"&&o--,o>0&&a++;if(o===0){let l=e.slice(s+1,a),c=ue(t,l);return{part:R.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?t.parseCommandSubstitution(e,r):i==="{"?dy(t,e,r,n):/[a-zA-Z_0-9@*#?$!-]/.test(i)?fy(t,e,r):{part:R.literal("$"),endIndex:s}}function hy(t,e){let r=[],n=0,s="",i=()=>{s&&(r.push(R.literal(s)),s="")};for(;n<e.length;){let o=e[n];if(o==="\\"&&n+1<e.length){let a=e[n+1];if(a==="$"||a==="`"){s+=a,n+=2;continue}s+=o,n++;continue}if(o==="$"){i();let{part:a,endIndex:l}=Gs(t,e,n,!0);a&&r.push(a),n=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=t.parseBacktickSubstitution(e,n,!0);r.push(a),n=l;continue}s+=o,n++}return i(),r}function my(t,e,r){let n=[],s=r,i="",o=()=>{i&&(n.push(R.literal(i)),i="")};for(;s<e.length&&e[s]!=='"';){let a=e[s];if(a==="\\"&&s+1<e.length){let l=e[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=Gs(t,e,s,!0);l&&n.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=t.parseBacktickSubstitution(e,s,!0);n.push(l),s=c;continue}i+=a,s++}return o(),{part:R.doubleQuoted(n),endIndex:s}}function tt(t,e,r=!1,n=!1,s=!1,i=!1,o=!1){if(n)return[R.singleQuoted(e)];if(r){let f=hy(t,e);return[R.doubleQuoted(f)]}let a=[],l=0,c="",u=()=>{c&&(a.push(R.literal(c)),c="")};for(;l<e.length;){let f=e[l];if(f==="\\"&&l+1<e.length){let d=e[l+1];(i?d==="$"||d==="`"||d==="\\"||d===`
645
- `:d==="$"||d==="`"||d==="\\"||d==='"'||d===`
646
- `)?c+=d:c+=`\\${d}`,l+=2;continue}if(f==="'"&&!o&&!i){u();let d=e.indexOf("'",l+1);if(d===-1){c+=e.slice(l);break}a.push(R.singleQuoted(e.slice(l+1,d))),l=d+1;continue}if(f==='"'&&!i){u();let{part:d,endIndex:p}=my(t,e,l+1);a.push(d),l=p+1;continue}if(f==="$"&&e[l+1]==="'"){u();let{part:d,endIndex:p}=Gu(t,e,l+2);a.push(d),l=p;continue}if(f==="$"){u();let{part:d,endIndex:p}=Gs(t,e,l);d&&a.push(d),l=p;continue}if(f==="`"){u();let{part:d,endIndex:p}=t.parseBacktickSubstitution(e,l);a.push(d),l=p;continue}if(f==="~"){let d=l>0?e[l-1]:"";if(l===0||d==="="||s&&d===":"){let h=ju(t,e,l),y=e[h];if(y===void 0||y==="/"||y===":"){u();let m=e.slice(l+1,h)||null;a.push({type:"TildeExpansion",user:m}),l=h;continue}}}if(f==="*"||f==="?"||f==="["){u();let{pattern:d,endIndex:p}=Hu(t,e,l);a.push({type:"Glob",pattern:d}),l=p;continue}if(f==="{"&&!s){let d=qu(t,e,l,tt);if(d){u(),a.push(d.part),l=d.endIndex;continue}}c+=f,l++}return u(),a}var pe=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;checkIterationLimit(){if(this.parseIterations++,this.parseIterations>_u)throw new Ze("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(e){if(e.length>Ps)throw new Ze(`Input too large: ${e.length} bytes exceeds limit of ${Ps}`,1,1);let r=new tn(e);if(this.tokens=r.tokenize(),this.tokens.length>Os)throw new Ze(`Too many tokens: ${this.tokens.length} exceeds limit of ${Os}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],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,r,n,s,...i){let o=this.tokens[this.pos]?.type;return o===e||r!==void 0&&o===r||n!==void 0&&o===n||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,r){if(this.check(e))return this.advance();let n=this.current();throw new Ze(r||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let r=this.current();throw new Ze(e,r.line,r.column,r)}skipNewlines(){for(;this.check(g.NEWLINE,g.COMMENT);)this.check(g.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(g.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(g.SEMICOLON,g.COMMENT)){this.advance();continue}if(e&&this.check(g.DSEMI,g.SEMI_AND,g.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,r,n,s){this.pendingHeredocs.push({redirect:e,delimiter:r,stripTabs:n,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(g.HEREDOC_CONTENT)){let r=this.advance(),n;e.quoted?n=R.word([R.literal(r.value)]):n=this.parseWordFromString(r.value,!1,!1,!1,!0),e.redirect.target=R.hereDoc(e.delimiter,n,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(g.EOF,g.NEWLINE,g.SEMICOLON,g.AMP,g.AND_AND,g.OR_OR,g.RPAREN,g.RBRACE,g.DSEMI,g.SEMI_AND,g.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===g.WORD||e===g.NAME||e===g.NUMBER||e===g.ASSIGNMENT_WORD||e===g.IF||e===g.FOR||e===g.WHILE||e===g.UNTIL||e===g.CASE||e===g.LPAREN||e===g.LBRACE||e===g.DPAREN_START||e===g.DBRACK_START||e===g.FUNCTION||e===g.BANG||e===g.IN||e===g.LESS||e===g.GREAT||e===g.DLESS||e===g.DGREAT||e===g.LESSAND||e===g.GREATAND||e===g.LESSGREAT||e===g.DLESSDASH||e===g.CLOBBER||e===g.TLESS||e===g.AND_GREAT||e===g.AND_DGREAT}parseScript(){let e=[],n=0;for(this.skipNewlines();!this.check(g.EOF);){n++,n>1e4&&this.error("Parser stuck: too many iterations (>10000)"),this.checkUnexpectedToken();let s=this.pos,i=this.parseStatement();i&&e.push(i),this.skipSeparators(!1),this.check(g.DSEMI,g.SEMI_AND,g.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===s&&!this.check(g.EOF)&&this.advance()}return R.script(e)}checkUnexpectedToken(){let e=this.current().type,r=this.current().value;(e===g.DO||e===g.DONE||e===g.THEN||e===g.ELSE||e===g.ELIF||e===g.FI||e===g.ESAC)&&this.error(`syntax error near unexpected token \`${r}'`),(e===g.RBRACE||e===g.RPAREN)&&this.error(`syntax error near unexpected token \`${r}'`),(e===g.DSEMI||e===g.SEMI_AND||e===g.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${r}'`),e===g.SEMICOLON&&this.error(`syntax error near unexpected token \`${r}'`)}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=[],r=[],n=!1,s=this.parsePipeline();for(e.push(s);this.check(g.AND_AND,g.OR_OR);){let i=this.advance();r.push(i.type===g.AND_AND?"&&":"||"),this.skipNewlines();let o=this.parsePipeline();e.push(o)}return this.check(g.AMP)&&(this.advance(),n=!0),R.statement(e,r,n)}parsePipeline(){let e=0;for(;this.check(g.BANG);)this.advance(),e++;let r=e%2===1,n=[],s=this.parseCommand();for(n.push(s);this.check(g.PIPE,g.PIPE_AMP);){let i=this.advance();this.skipNewlines();let o=this.parseCommand();i.type===g.PIPE_AMP&&o.type==="SimpleCommand"&&o.redirections.unshift(R.redirection(">&",R.word([R.literal("1")]),2)),n.push(o)}return R.pipeline(n,r)}parseCommand(){return this.check(g.IF)?Ds(this):this.check(g.FOR)?Ms(this):this.check(g.WHILE)?_s(this):this.check(g.UNTIL)?Bs(this):this.check(g.CASE)?Ws(this):this.check(g.LPAREN)?Us(this):this.check(g.LBRACE)?js(this):this.check(g.DPAREN_START)?this.parseArithmeticCommand():this.check(g.DBRACK_START)?this.parseConditionalCommand():this.check(g.FUNCTION)?this.parseFunctionDef():this.check(g.NAME,g.WORD)&&this.peek(1).type===g.LPAREN&&this.peek(2).type===g.RPAREN?this.parseFunctionDef():Qu(this)}isWord(){let e=this.current().type;return e===g.WORD||e===g.NAME||e===g.NUMBER||e===g.IF||e===g.FOR||e===g.WHILE||e===g.UNTIL||e===g.CASE||e===g.FUNCTION||e===g.ELSE||e===g.ELIF||e===g.FI||e===g.THEN||e===g.DO||e===g.DONE||e===g.ESAC||e===g.IN||e===g.SELECT||e===g.TIME||e===g.COPROC||e===g.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordFromString(e,r=!1,n=!1,s=!1,i=!1){let o=tt(this,e,r,n,s,i);return R.word(o)}parseCommandSubstitution(e,r){let n=r+2,s=1,i=n,o=!1,a=!1,l=0,c=!1,u="";for(;i<e.length&&s>0;){let h=e[i];o?h==="'"&&(o=!1):a?h==="\\"&&i+1<e.length?i++:h==='"'&&(a=!1):h==="'"?(o=!0,u=""):h==='"'?(a=!0,u=""):h==="\\"&&i+1<e.length?(i++,u=""):/[a-zA-Z_]/.test(h)?u+=h:(u==="case"?(l++,c=!1):u==="in"&&l>0?c=!0:u==="esac"&&l>0&&(l--,c=!1),u="",h==="("?i>0&&e[i-1]==="$"?s++:c||s++:h===")"?c?c=!1:s--:h===";"&&l>0&&i+1<e.length&&e[i+1]===";"&&(c=!0)),s>0&&i++}s>0&&this.error("unexpected EOF while looking for matching `)'");let f=e.slice(n,i),p=new t().parse(f);return{part:R.commandSubstitution(p,!1),endIndex:i+1}}parseBacktickSubstitution(e,r,n=!1){let i=r+1,o="";for(;i<e.length&&e[i]!=="`";)if(e[i]==="\\"){let c=e[i+1];c==="$"||c==="`"||c==="\\"||c===`
643
+ `||o===";"||o==="&"||o==="|")return null;s++}}return null}};var Bs=1e6,Ws=1e5,qu=1e6,Vu=new Set([y.LESS,y.GREAT,y.DLESS,y.DGREAT,y.LESSAND,y.GREATAND,y.LESSGREAT,y.DLESSDASH,y.CLOBBER,y.TLESS,y.AND_GREAT,y.AND_DGREAT]),Ku=new Set([y.LESS,y.GREAT,y.DLESS,y.DGREAT,y.LESSAND,y.GREATAND,y.LESSGREAT,y.DLESSDASH,y.CLOBBER,y.TLESS]),tt=class extends Error{line;column;token;constructor(e,r,n,s=void 0){super(`Parse error at ${r}:${n}: ${e}`),this.line=r,this.column=n,this.token=s,this.name="ParseException"}};function Qu(t,e,r){let n=r+1;for(;n<e.length&&/[a-zA-Z0-9_-]/.test(e[n]);)n++;return n}function Us(t,e,r,n,s){let i=1,o=r+1;for(;o<e.length&&i>0;)e[o]===n?i++:e[o]===s&&i--,i>0&&o++;return i===0?o:-1}function vt(t,e,r){let n=r,s=1;for(;n<e.length&&s>0;){let i=e[n];if(i==="\\"&&n+1<e.length){n+=2;continue}if(i==="'"){let o=e.indexOf("'",n+1);if(o!==-1){n=o+1;continue}}if(i==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++;continue}i==="{"?s++:i==="}"&&s--,s>0&&n++}return n}function Xu(t,e,r){let n=r,s=!1;for(;n<e.length;){let i=e[n];if(i==="/"&&s||i==="}")break;if(i==="'"){let o=e.indexOf("'",n+1);if(o!==-1){n=o+1,s=!0;continue}}if(i==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?n+=2:n++;n<e.length&&n++,s=!0;continue}i==="\\"?(n+=2,s=!0):(n++,s=!0)}return n}function Ju(t,e,r){let n=r,s="";for(;n<e.length;){let i=e[n];if(i==="*"||i==="?")s+=i,n++;else if(i==="["){let o=ay(e,n);o===-1?(s+=i,n++):(s+=e.slice(n,o+1),n=o+1)}else break}return{pattern:s,endIndex:n}}function ay(t,e){let r=e+1;for(r<t.length&&t[r]==="^"&&r++,r<t.length&&t[r]==="]"&&r++;r<t.length;){let n=t[r];if(n==="\\"&&r+1<t.length){r+=2;continue}if(n==="]")return r;if(n==='"'||n==="$"||n==="`")return-1;if(n==="'"){let s=t.indexOf("'",r+1);if(s!==-1){r=s+1;continue}}if(n==="["&&r+1<t.length&&t[r+1]===":"){let s=t.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}if(n==="["&&r+1<t.length&&(t[r+1]==="."||t[r+1]==="=")){let i=`${t[r+1]}]`,o=t.indexOf(i,r+2);if(o!==-1){r=o+2;continue}}r++}return-1}function Yu(t,e,r){let n="",s=r;for(;s<e.length&&e[s]!=="'";){let i=e[s];if(i==="\\"&&s+1<e.length)switch(e[s+1]){case"n":n+=`
644
+ `,s+=2;break;case"t":n+=" ",s+=2;break;case"r":n+="\r",s+=2;break;case"\\":n+="\\",s+=2;break;case"'":n+="'",s+=2;break;case'"':n+='"',s+=2;break;case"a":n+="\x07",s+=2;break;case"b":n+="\b",s+=2;break;case"e":case"E":n+="\x1B",s+=2;break;case"f":n+="\f",s+=2;break;case"v":n+="\v",s+=2;break;case"x":{let a=e.slice(s+2,s+4),l=parseInt(a,16);Number.isNaN(l)?(n+="\\x",s+=2):(n+=String.fromCharCode(l),s+=4);break}case"u":{let a=e.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(n+="\\u",s+=2):(n+=String.fromCharCode(l),s+=6);break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<e.length&&l<s+4&&/[0-7]/.test(e[l]);)a+=e[l],l++;let c=parseInt(a,8);n+=String.fromCharCode(c),s=l;break}default:n+=i,s++}else n+=i,s++}return s<e.length&&e[s]==="'"&&s++,{part:O.literal(n),endIndex:s}}function js(t,e){let r=e.trim();return r===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:be(t,r)}function Zu(t){let e=[],r="",n=0;for(let s=0;s<t.length;s++){let i=t[s];i==="{"?(n++,r+=i):i==="}"?(n--,r+=i):i===","&&n===0?(e.push(r),r=""):r+=i}return e.push(r),e}function ef(t,e,r,n){let s=Us(t,e,r,"{","}");if(s===-1)return null;let i=e.slice(r+1,s),o=i.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:s+1};let a=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return a?{part:{type:"BraceExpansion",items:[{type:"Range",start:a[1],end:a[2],step:a[3]?Number.parseInt(a[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&n?{part:{type:"BraceExpansion",items:Zu(i).map(u=>({type:"Word",word:O.word(n(t,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:Zu(i).map(u=>({type:"Word",word:O.word([O.literal(u)])}))},endIndex:s+1}:null}function tf(t,e){let r="";for(let n of e.parts)switch(n.type){case"Literal":case"SingleQuoted":case"Escaped":r+=n.value;break;case"DoubleQuoted":r+='"';for(let s of n.parts)s.type==="Literal"||s.type==="Escaped"?r+=s.value:s.type==="ParameterExpansion"&&(r+=`\${${s.parameter}}`);r+='"';break;case"ParameterExpansion":r+=`\${${n.parameter}}`;break;case"Glob":r+=n.pattern;break;default:r+=n.type}return r}function rf(t,e){return{[y.LESS]:"<",[y.GREAT]:">",[y.DGREAT]:">>",[y.LESSAND]:"<&",[y.GREATAND]:">&",[y.LESSGREAT]:"<>",[y.CLOBBER]:">|",[y.TLESS]:"<<<",[y.AND_GREAT]:"&>",[y.AND_DGREAT]:"&>>",[y.DLESS]:"<",[y.DLESSDASH]:"<"}[e]||">"}function dn(t){let e=t.current(),r=e.type;if(r===y.NUMBER){let n=t.peek(1);return e.end!==n.start?!1:Ku.has(n.type)}return Vu.has(r)}function hn(t){let e=null;t.check(y.NUMBER)&&(e=Number.parseInt(t.advance().value,10));let r=t.advance(),n=rf(t,r.type);if(r.type===y.DLESS||r.type===y.DLESSDASH)return ly(t,n,e,r.type===y.DLESSDASH);t.isWord()||t.error("Expected redirection target");let s=t.parseWord();return O.redirection(n,s,e)}function ly(t,e,r,n){t.isWord()||t.error("Expected here-document delimiter");let s=t.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=O.redirection(n?"<<-":"<<",O.hereDoc(i,O.word([]),n,o),r);return t.addPendingHeredoc(a,i,n,o),a}function sf(t){let e=t.current().line,r=[],n=null,s=[],i=[];for(;t.check(y.ASSIGNMENT_WORD);)t.checkIterationLimit(),r.push(cy(t));for(;dn(t);)t.checkIterationLimit(),i.push(hn(t));for(t.isWord()&&(n=t.parseWord());(!t.isStatementEnd()||t.check(y.RBRACE))&&!t.check(y.PIPE,y.PIPE_AMP);)if(t.checkIterationLimit(),dn(t))i.push(hn(t));else if(t.check(y.RBRACE)){let a=t.advance();s.push(t.parseWordFromString(a.value,!1,!1))}else if(t.isWord())s.push(t.parseWord());else if(t.check(y.ASSIGNMENT_WORD)){let a=t.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||t.check(y.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||t.expect(y.LPAREN);let p=zs(t);t.expect(y.RPAREN);let d=p.map(m=>tf(t,m)),h=`${f}=(${d.join(" ")})`;s.push(t.parseWordFromString(h,!1,!1))}else s.push(t.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(t.check(y.LPAREN))t.error("syntax error near unexpected token `('");else break;let o=O.simpleCommand(n,s,r,i);return o.line=e,o}function cy(t){let e=t.expect(y.ASSIGNMENT_WORD),r=e.value,n=r.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);n||t.error(`Invalid assignment: ${r}`);let s=n[0],i,o=s.length;if(r[o]==="["){let f=0,p=o+1;for(;o<r.length;o++)if(r[o]==="[")f++;else if(r[o]==="]"&&(f--,f===0))break;f!==0&&t.error(`Invalid assignment: ${r}`),i=r.slice(p,o),o++}let a=r[o]==="+";a&&o++,r[o]!=="="&&t.error(`Invalid assignment: ${r}`),o++;let l=r.slice(o);if(l==="("){let f=zs(t);t.expect(y.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return O.assignment(p,null,a,f)}if(l===""&&t.check(y.LPAREN)){let f=t.current();if(e.end===f.start){t.advance();let p=zs(t);t.expect(y.RPAREN);let d=i!==void 0?`${s}[${i}]`:s;return O.assignment(d,null,a,p)}}let c=l?t.parseWordFromString(l,e.quoted,e.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return O.assignment(u,c,a,null)}function zs(t){let e=[];for(t.skipNewlines();!t.check(y.RPAREN,y.EOF);)t.checkIterationLimit(),t.isWord()?e.push(t.parseWord()):t.advance(),t.skipNewlines();return e}function Hs(t){t.expect(y.IF);let e=[],r=t.parseCompoundList();t.expect(y.THEN);let n=t.parseCompoundList();if(n.length===0){let o=t.check(y.FI)?"fi":t.check(y.ELSE)?"else":t.check(y.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${o}'`)}for(e.push({condition:r,body:n});t.check(y.ELIF);){t.advance();let o=t.parseCompoundList();t.expect(y.THEN);let a=t.parseCompoundList();if(a.length===0){let l=t.check(y.FI)?"fi":t.check(y.ELSE)?"else":t.check(y.ELIF)?"elif":"fi";t.error(`syntax error near unexpected token \`${l}'`)}e.push({condition:o,body:a})}let s=null;t.check(y.ELSE)&&(t.advance(),s=t.parseCompoundList(),s.length===0&&t.error("syntax error near unexpected token `fi'")),t.expect(y.FI);let i=t.parseOptionalRedirections();return O.ifNode(e,s,i)}function Gs(t){if(t.expect(y.FOR),t.check(y.DPAREN_START))return fy(t);t.isWord()||t.error("Expected variable name in for loop");let r=t.advance().value,n=null;if(t.skipNewlines(),t.check(y.IN))for(t.advance(),n=[];!t.check(y.SEMICOLON,y.NEWLINE,y.DO,y.EOF)&&t.isWord();)n.push(t.parseWord());t.check(y.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(y.DO);let s=t.parseCompoundList();t.expect(y.DONE);let i=t.parseOptionalRedirections();return O.forNode(r,n,s,i)}function fy(t){t.expect(y.DPAREN_START);let e=null,r=null,n=null,s=["","",""],i=0,o=0;for(;!t.check(y.DPAREN_END,y.EOF);){let c=t.advance();if(c.type===y.SEMICOLON&&o===0){if(i++,i>2)break}else c.value==="("&&o++,c.value===")"&&o--,s[i]+=c.value}t.expect(y.DPAREN_END),s[0].trim()&&(e=be(t,s[0].trim())),s[1].trim()&&(r=be(t,s[1].trim())),s[2].trim()&&(n=be(t,s[2].trim())),t.skipNewlines(),t.check(y.SEMICOLON)&&t.advance(),t.skipNewlines(),t.expect(y.DO);let a=t.parseCompoundList();t.expect(y.DONE);let l=t.parseOptionalRedirections();return{type:"CStyleFor",init:e,condition:r,update:n,body:a,redirections:l}}function qs(t){t.expect(y.WHILE);let e=t.parseCompoundList();t.expect(y.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(y.DONE);let n=t.parseOptionalRedirections();return O.whileNode(e,r,n)}function Vs(t){t.expect(y.UNTIL);let e=t.parseCompoundList();t.expect(y.DO);let r=t.parseCompoundList();r.length===0&&t.error("syntax error near unexpected token `done'"),t.expect(y.DONE);let n=t.parseOptionalRedirections();return O.untilNode(e,r,n)}function Ks(t){t.expect(y.CASE),t.isWord()||t.error("Expected word after 'case'");let e=t.parseWord();t.skipNewlines(),t.expect(y.IN),t.skipNewlines();let r=[];for(;!t.check(y.ESAC,y.EOF);){t.checkIterationLimit();let s=t.getPos(),i=py(t);if(i&&r.push(i),t.skipNewlines(),t.getPos()===s&&!i)break}t.expect(y.ESAC);let n=t.parseOptionalRedirections();return O.caseNode(e,r,n)}function py(t){t.check(y.LPAREN)&&t.advance();let e=[];for(;t.isWord()&&(e.push(t.parseWord()),t.check(y.PIPE));)t.advance();if(e.length===0)return null;t.expect(y.RPAREN),t.skipNewlines();let r=[];for(;!t.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND,y.ESAC,y.EOF);){t.checkIterationLimit(),t.isWord()&&t.peek(1).type===y.RPAREN&&t.error("syntax error near unexpected token `)'"),t.check(y.LPAREN)&&t.peek(1).type===y.WORD&&t.error(`syntax error near unexpected token \`${t.peek(1).value}'`);let s=t.getPos(),i=t.parseStatement();if(i&&r.push(i),t.skipSeparators(!1),t.getPos()===s&&!i)break}let n=";;";return t.check(y.DSEMI)?(t.advance(),n=";;"):t.check(y.SEMI_AND)?(t.advance(),n=";&"):t.check(y.SEMI_SEMI_AND)&&(t.advance(),n=";;&"),O.caseItem(e,r,n)}function Zs(t){t.peek(1).type,y.LPAREN,t.expect(y.LPAREN),t.check(y.LPAREN)&&t.advance();let e=t.parseCompoundList();t.expect(y.RPAREN);let r=t.parseOptionalRedirections();return O.subshell(e,r)}function Qs(t){t.expect(y.LBRACE);let e=t.parseCompoundList();t.expect(y.RBRACE);let r=t.parseOptionalRedirections();return O.group(e,r)}var hy=["-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"],my=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"];function Js(t){return t.skipNewlines(),gy(t)}function gy(t){let e=of(t);for(t.skipNewlines();t.check(y.OR_OR);){t.advance(),t.skipNewlines();let r=of(t);e={type:"CondOr",left:e,right:r},t.skipNewlines()}return e}function of(t){let e=Xs(t);for(t.skipNewlines();t.check(y.AND_AND);){t.advance(),t.skipNewlines();let r=Xs(t);e={type:"CondAnd",left:e,right:r},t.skipNewlines()}return e}function Xs(t){return t.skipNewlines(),t.check(y.BANG)?(t.advance(),t.skipNewlines(),{type:"CondNot",operand:Xs(t)}):yy(t)}function yy(t){if(t.check(y.LPAREN)){t.advance();let e=Js(t);return t.expect(y.RPAREN),{type:"CondGroup",expression:e}}if(t.isWord()){let e=t.current(),r=e.value;if(hy.includes(r)&&!e.quoted&&(t.advance(),t.check(y.DBRACK_END)&&t.error(`Expected operand after ${r}`),t.isWord())){let s=t.parseWord();return{type:"CondUnary",operator:r,operand:s}}let n=t.parseWord();if(t.isWord()&&my.includes(t.current().value)){let s=t.advance().value,i=t.parseWord();return{type:"CondBinary",operator:s,left:n,right:i}}if(t.check(y.LESS)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"<",left:n,right:s}}if(t.check(y.GREAT)){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:">",left:n,right:s}}if(t.isWord()&&t.current().value==="="){t.advance();let s=t.parseWord();return{type:"CondBinary",operator:"==",left:n,right:s}}return{type:"CondWord",word:n}}t.error("Expected conditional expression")}function wy(t,e,r){let n=r+1,s=e[n];if("@*#?$!-0123456789".includes(s))return{part:O.parameterExpansion(s),endIndex:n+1};let i="";for(;n<e.length&&/[a-zA-Z0-9_]/.test(e[n]);)i+=e[n],n++;return{part:O.parameterExpansion(i),endIndex:n}}function by(t,e,r,n=!1){let s=r+2,i=!1;e[s]==="!"&&(i=!0,s++);let o=!1;e[s]==="#"&&!/[}:#%/^,]/.test(e[s+1]||"}")&&(o=!0,s++);let a="",l=e[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(e[s+1]||""))a=l,s++;else for(;s<e.length&&/[a-zA-Z0-9_]/.test(e[s]);)a+=e[s],s++;if(e[s]==="["){let u=Us(t,e,s,"[","]");a+=e.slice(s,u+1),s=u+1}a===""&&!i&&!o&&e[s]!=="}"&&t.error(`\${${e[s]}}: bad substitution`);let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(e[s]==="*"||e[s]==="@"){let f=e[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else c={type:"Indirection"}}else if(o)if(e[s]===":")for(c={type:"LengthSliceError"};s<e.length&&e[s]!=="}";)s++;else e[s]!=="}"&&/[-+=?]/.test(e[s])?t.error(`\${#${a}${e.slice(s,e.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<e.length&&e[s]!=="}"){let u=Ey(t,e,s,a,n);c=u.operation,s=u.endIndex}if(s<e.length&&e[s]!=="}"){let u=e[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<e.length&&e[f]!=="}";)f++;let p=e.slice(r,f+1);t.error(`\${${p.slice(2,-1)}}: bad substitution`)}}for(;s<e.length&&e[s]!=="}";)s++;return{part:O.parameterExpansion(a,c),endIndex:s+1}}function Ey(t,e,r,n,s=!1){let i=r,o=e[i],a=e[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let w=vt(t,e,i),b=e.slice(i,w),E=at(t,b,!1,!1,!0,!1,s),S=O.word(E.length>0?E:[O.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:S,checkEmpty:!0},endIndex:w};if(l==="=")return{operation:{type:"AssignDefault",word:S,checkEmpty:!0},endIndex:w};if(l==="?")return{operation:{type:"ErrorIfUnset",word:S,checkEmpty:!0},endIndex:w};if(l==="+")return{operation:{type:"UseAlternative",word:S,checkEmpty:!0},endIndex:w}}i++;let c=vt(t,e,i),u=e.slice(i,c),f=-1,p=0,d=0;for(let g=0;g<u.length;g++){let w=u[g];if(w==="("||w==="[")p++;else if(w===")"||w==="]")p--;else if(w==="?"&&p===0)d++;else if(w===":"&&p===0)if(d>0)d--;else{f=g;break}}let h=f>=0?u.slice(0,f):u,m=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:js(t,h),length:m?js(t,m):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=vt(t,e,i),c=e.slice(i,l),u=at(t,c,!1,!1,!0,!1,s),f=O.word(u.length>0?u:[O.literal("")]);if(o==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(o==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(o==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(o==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(o==="#"||o==="%"){let l=a===o,c=o==="#"?"prefix":"suffix";i+=l?2:1;let u=vt(t,e,i),f=e.slice(i,u),p=at(t,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:O.word(p.length>0?p:[O.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;e[i]==="#"?(c="start",i++):e[i]==="%"&&(c="end",i++);let u=Xu(t,e,i),f=e.slice(i,u),p=at(t,f,!1,!1,!1),d=O.word(p.length>0?p:[O.literal("")]),h=null,m=u;if(e[u]==="/"){let g=u+1,w=vt(t,e,g),b=e.slice(g,w),E=at(t,b,!1,!1,!1);h=O.word(E.length>0?E:[O.literal("")]),m=w}return{operation:{type:"PatternReplacement",pattern:d,replacement:h,all:l,anchor:c},endIndex:m}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=vt(t,e,i),f=e.slice(i,u),p=f?O.word([O.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:p},endIndex:u}}return o==="@"&&/[QPaAEK]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function Ys(t,e,r,n=!1){let s=r+1;if(s>=e.length)return{part:O.literal("$"),endIndex:s};let i=e[s];if(i==="("&&e[s+1]==="(")return t.parseArithmeticExpansion(e,r);if(i==="["){let o=1,a=s+1;for(;a<e.length&&o>0;)e[a]==="["?o++:e[a]==="]"&&o--,o>0&&a++;if(o===0){let l=e.slice(s+1,a),c=be(t,l);return{part:O.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?t.parseCommandSubstitution(e,r):i==="{"?by(t,e,r,n):/[a-zA-Z_0-9@*#?$!-]/.test(i)?wy(t,e,r):{part:O.literal("$"),endIndex:s}}function Sy(t,e){let r=[],n=0,s="",i=()=>{s&&(r.push(O.literal(s)),s="")};for(;n<e.length;){let o=e[n];if(o==="\\"&&n+1<e.length){let a=e[n+1];if(a==="$"||a==="`"){s+=a,n+=2;continue}s+=o,n++;continue}if(o==="$"){i();let{part:a,endIndex:l}=Ys(t,e,n,!0);a&&r.push(a),n=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=t.parseBacktickSubstitution(e,n,!0);r.push(a),n=l;continue}s+=o,n++}return i(),r}function Cy(t,e,r){let n=[],s=r,i="",o=()=>{i&&(n.push(O.literal(i)),i="")};for(;s<e.length&&e[s]!=='"';){let a=e[s];if(a==="\\"&&s+1<e.length){let l=e[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=Ys(t,e,s,!0);l&&n.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=t.parseBacktickSubstitution(e,s,!0);n.push(l),s=c;continue}i+=a,s++}return o(),{part:O.doubleQuoted(n),endIndex:s}}function at(t,e,r=!1,n=!1,s=!1,i=!1,o=!1){if(n)return[O.singleQuoted(e)];if(r){let f=Sy(t,e);return[O.doubleQuoted(f)]}let a=[],l=0,c="",u=()=>{c&&(a.push(O.literal(c)),c="")};for(;l<e.length;){let f=e[l];if(f==="\\"&&l+1<e.length){let p=e[l+1];(i?p==="$"||p==="`"||p==="\\"||p===`
645
+ `:p==="$"||p==="`"||p==="\\"||p==='"'||p===`
646
+ `)?c+=p:c+=`\\${p}`,l+=2;continue}if(f==="'"&&!o&&!i){u();let p=e.indexOf("'",l+1);if(p===-1){c+=e.slice(l);break}a.push(O.singleQuoted(e.slice(l+1,p))),l=p+1;continue}if(f==='"'&&!i){u();let{part:p,endIndex:d}=Cy(t,e,l+1);a.push(p),l=d+1;continue}if(f==="$"&&e[l+1]==="'"){u();let{part:p,endIndex:d}=Yu(t,e,l+2);a.push(p),l=d;continue}if(f==="$"){u();let{part:p,endIndex:d}=Ys(t,e,l);p&&a.push(p),l=d;continue}if(f==="`"){u();let{part:p,endIndex:d}=t.parseBacktickSubstitution(e,l);a.push(p),l=d;continue}if(f==="~"){let p=l>0?e[l-1]:"";if(l===0||p==="="||s&&p===":"){let h=Qu(t,e,l),m=e[h];if(m===void 0||m==="/"||m===":"){u();let g=e.slice(l+1,h)||null;a.push({type:"TildeExpansion",user:g}),l=h;continue}}}if(f==="*"||f==="?"||f==="["){u();let{pattern:p,endIndex:d}=Ju(t,e,l);a.push({type:"Glob",pattern:p}),l=d;continue}if(f==="{"&&!s){let p=ef(t,e,l,at);if(p){u(),a.push(p.part),l=p.endIndex;continue}}c+=f,l++}return u(),a}var Se=class t{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;checkIterationLimit(){if(this.parseIterations++,this.parseIterations>qu)throw new tt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(e){if(e.length>Bs)throw new tt(`Input too large: ${e.length} bytes exceeds limit of ${Bs}`,1,1);let r=new pn(e);if(this.tokens=r.tokenize(),this.tokens.length>Ws)throw new tt(`Too many tokens: ${this.tokens.length} exceeds limit of ${Ws}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(e){return this.tokens=e,this.pos=0,this.pendingHeredocs=[],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,r,n,s,...i){let o=this.tokens[this.pos]?.type;return o===e||r!==void 0&&o===r||n!==void 0&&o===n||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(e,r){if(this.check(e))return this.advance();let n=this.current();throw new tt(r||`Expected ${e}, got ${n.type}`,n.line,n.column,n)}error(e){let r=this.current();throw new tt(e,r.line,r.column,r)}skipNewlines(){for(;this.check(y.NEWLINE,y.COMMENT);)this.check(y.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(e=!0){for(;;){if(this.check(y.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(y.SEMICOLON,y.COMMENT)){this.advance();continue}if(e&&this.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(e,r,n,s){this.pendingHeredocs.push({redirect:e,delimiter:r,stripTabs:n,quoted:s})}processHeredocs(){for(let e of this.pendingHeredocs)if(this.check(y.HEREDOC_CONTENT)){let r=this.advance(),n;e.quoted?n=O.word([O.literal(r.value)]):n=this.parseWordFromString(r.value,!1,!1,!1,!0),e.redirect.target=O.hereDoc(e.delimiter,n,e.stripTabs,e.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(y.EOF,y.NEWLINE,y.SEMICOLON,y.AMP,y.AND_AND,y.OR_OR,y.RPAREN,y.RBRACE,y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)}isCommandStart(){let e=this.current().type;return e===y.WORD||e===y.NAME||e===y.NUMBER||e===y.ASSIGNMENT_WORD||e===y.IF||e===y.FOR||e===y.WHILE||e===y.UNTIL||e===y.CASE||e===y.LPAREN||e===y.LBRACE||e===y.DPAREN_START||e===y.DBRACK_START||e===y.FUNCTION||e===y.BANG||e===y.IN||e===y.LESS||e===y.GREAT||e===y.DLESS||e===y.DGREAT||e===y.LESSAND||e===y.GREATAND||e===y.LESSGREAT||e===y.DLESSDASH||e===y.CLOBBER||e===y.TLESS||e===y.AND_GREAT||e===y.AND_DGREAT}parseScript(){let e=[],n=0;for(this.skipNewlines();!this.check(y.EOF);){n++,n>1e4&&this.error("Parser stuck: too many iterations (>10000)"),this.checkUnexpectedToken();let s=this.pos,i=this.parseStatement();i&&e.push(i),this.skipSeparators(!1),this.check(y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===s&&!this.check(y.EOF)&&this.advance()}return O.script(e)}checkUnexpectedToken(){let e=this.current().type,r=this.current().value;(e===y.DO||e===y.DONE||e===y.THEN||e===y.ELSE||e===y.ELIF||e===y.FI||e===y.ESAC)&&this.error(`syntax error near unexpected token \`${r}'`),(e===y.RBRACE||e===y.RPAREN)&&this.error(`syntax error near unexpected token \`${r}'`),(e===y.DSEMI||e===y.SEMI_AND||e===y.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${r}'`),e===y.SEMICOLON&&this.error(`syntax error near unexpected token \`${r}'`)}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let e=[],r=[],n=!1,s=this.parsePipeline();for(e.push(s);this.check(y.AND_AND,y.OR_OR);){let i=this.advance();r.push(i.type===y.AND_AND?"&&":"||"),this.skipNewlines();let o=this.parsePipeline();e.push(o)}return this.check(y.AMP)&&(this.advance(),n=!0),O.statement(e,r,n)}parsePipeline(){let e=0;for(;this.check(y.BANG);)this.advance(),e++;let r=e%2===1,n=[],s=this.parseCommand();for(n.push(s);this.check(y.PIPE,y.PIPE_AMP);){let i=this.advance();this.skipNewlines();let o=this.parseCommand();i.type===y.PIPE_AMP&&o.type==="SimpleCommand"&&o.redirections.unshift(O.redirection(">&",O.word([O.literal("1")]),2)),n.push(o)}return O.pipeline(n,r)}parseCommand(){return this.check(y.IF)?Hs(this):this.check(y.FOR)?Gs(this):this.check(y.WHILE)?qs(this):this.check(y.UNTIL)?Vs(this):this.check(y.CASE)?Ks(this):this.check(y.LPAREN)?Zs(this):this.check(y.LBRACE)?Qs(this):this.check(y.DPAREN_START)?this.parseArithmeticCommand():this.check(y.DBRACK_START)?this.parseConditionalCommand():this.check(y.FUNCTION)?this.parseFunctionDef():this.check(y.NAME,y.WORD)&&this.peek(1).type===y.LPAREN&&this.peek(2).type===y.RPAREN?this.parseFunctionDef():sf(this)}isWord(){let e=this.current().type;return e===y.WORD||e===y.NAME||e===y.NUMBER||e===y.IF||e===y.FOR||e===y.WHILE||e===y.UNTIL||e===y.CASE||e===y.FUNCTION||e===y.ELSE||e===y.ELIF||e===y.FI||e===y.THEN||e===y.DO||e===y.DONE||e===y.ESAC||e===y.IN||e===y.SELECT||e===y.TIME||e===y.COPROC||e===y.BANG}parseWord(){let e=this.advance();return this.parseWordFromString(e.value,e.quoted,e.singleQuoted)}parseWordFromString(e,r=!1,n=!1,s=!1,i=!1){let o=at(this,e,r,n,s,i);return O.word(o)}parseCommandSubstitution(e,r){let n=r+2,s=1,i=n,o=!1,a=!1,l=0,c=!1,u="";for(;i<e.length&&s>0;){let h=e[i];o?h==="'"&&(o=!1):a?h==="\\"&&i+1<e.length?i++:h==='"'&&(a=!1):h==="'"?(o=!0,u=""):h==='"'?(a=!0,u=""):h==="\\"&&i+1<e.length?(i++,u=""):/[a-zA-Z_]/.test(h)?u+=h:(u==="case"?(l++,c=!1):u==="in"&&l>0?c=!0:u==="esac"&&l>0&&(l--,c=!1),u="",h==="("?i>0&&e[i-1]==="$"?s++:c||s++:h===")"?c?c=!1:s--:h===";"&&l>0&&i+1<e.length&&e[i+1]===";"&&(c=!0)),s>0&&i++}s>0&&this.error("unexpected EOF while looking for matching `)'");let f=e.slice(n,i),d=new t().parse(f);return{part:O.commandSubstitution(d,!1),endIndex:i+1}}parseBacktickSubstitution(e,r,n=!1){let i=r+1,o="";for(;i<e.length&&e[i]!=="`";)if(e[i]==="\\"){let c=e[i+1];c==="$"||c==="`"||c==="\\"||c===`
647
647
  `||n&&c==='"'?(c!==`
648
- `&&(o+=c),i+=2):(o+=e[i],i++)}else o+=e[i],i++;i>=e.length&&this.error("unexpected EOF while looking for matching ``'");let l=new t().parse(o);return{part:R.commandSubstitution(l,!0),endIndex:i+1}}parseArithmeticExpansion(e,r){let n=r+3,s=1,i=0,o=n;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(n,o),l=this.parseArithmeticExpression(a);return{part:R.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){this.expect(g.DPAREN_START);let e="",r=1,n=0,s=!1,i=!1;for(;r>0&&!this.check(g.EOF);){if(s){if(s=!1,n>0){n--,e+=")";continue}if(this.check(g.RPAREN)){r--,i=!0,this.advance();continue}if(this.check(g.DPAREN_END)){r--,i=!0;continue}e+=")";continue}this.check(g.DPAREN_START)?(r++,e+="((",this.advance()):this.check(g.DPAREN_END)?n>=2?(n-=2,e+="))",this.advance()):n===1?(n--,e+=")",s=!0,this.advance()):(r--,i=!0,r>0&&(e+="))"),this.advance()):this.check(g.LPAREN)?(n++,e+="(",this.advance()):this.check(g.RPAREN)?(n>0&&n--,e+=")",this.advance()):(e+=this.current().value,this.advance())}i||this.expect(g.DPAREN_END);let o=this.parseArithmeticExpression(e.trim()),a=this.parseOptionalRedirections();return R.arithmeticCommand(o,a)}parseConditionalCommand(){this.expect(g.DBRACK_START);let e=Hs(this);this.expect(g.DBRACK_END);let r=this.parseOptionalRedirections();return R.conditionalCommand(e,r)}parseFunctionDef(){let e;this.check(g.FUNCTION)?(this.advance(),e=this.expect(g.NAME,"Expected function name").value,this.check(g.LPAREN)&&(this.advance(),this.expect(g.RPAREN))):(e=this.advance().value,this.expect(g.LPAREN),this.expect(g.RPAREN)),this.skipNewlines();let r=this.parseCompoundCommandBody(),n=this.parseOptionalRedirections();return R.functionDef(e,r,n)}parseCompoundCommandBody(){if(this.check(g.LBRACE))return js(this);if(this.check(g.LPAREN))return Us(this);if(this.check(g.IF))return Ds(this);if(this.check(g.FOR))return Ms(this);if(this.check(g.WHILE))return _s(this);if(this.check(g.UNTIL))return Bs(this);if(this.check(g.CASE))return Ws(this);this.error("Expected compound command for function body")}parseCompoundList(){let e=[];for(this.skipNewlines();!this.check(g.EOF,g.FI,g.ELSE,g.ELIF,g.THEN,g.DO,g.DONE,g.ESAC,g.RPAREN,g.RBRACE,g.DSEMI,g.SEMI_AND,g.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let r=this.pos,n=this.parseStatement();if(n&&e.push(n),this.skipSeparators(),this.pos===r&&!n)break}return e}parseOptionalRedirections(){let e=[];for(;rn(this);){this.checkIterationLimit();let r=this.pos;if(e.push(nn(this)),this.pos===r)break}return e}parseArithmeticExpression(e){return ue(this,e)}};function rt(t){return new pe().parse(t)}X();var Wt=class{fs;cwd;constructor(e,r){this.fs=e,this.cwd=r}isGlobPattern(e){return e.includes("*")||e.includes("?")||/\[.*\]/.test(e)}async expandArgs(e,r){let n=[];for(let s=0;s<e.length;s++){let i=e[s];if((r?.[s]??!1)||!this.isGlobPattern(i))n.push(i);else{let a=await this.expand(i);a.length>0?n.push(...a):n.push(i)}}return n}async expand(e){return e.includes("**")?this.expandRecursive(e):this.expandSimple(e)}async expandSimple(e){let r=[],n=e.lastIndexOf("/"),s,i;n===-1?(s=this.cwd,i=e):(s=e.slice(0,n)||"/",i=e.slice(n+1));let o=this.fs.resolvePath(this.cwd,s);try{let a=await this.fs.readdir(o);for(let l of a)if(this.matchPattern(l,i)){let c=n===-1?l:`${s}/${l}`;r.push(c)}}catch{}return r.sort()}async expandRecursive(e){let r=[],n=e.indexOf("**"),s=e.slice(0,n).replace(/\/$/,"")||".",o=e.slice(n+2).replace(/^\//,"");return await this.walkDirectory(s,o,r),r.sort()}async walkDirectory(e,r,n){let s=this.fs.resolvePath(this.cwd,e);try{let i=await this.fs.readdir(s);for(let o of i){let a=e==="."?o:`${e}/${o}`,l=this.fs.resolvePath(this.cwd,a);try{(await this.fs.stat(l)).isDirectory?await this.walkDirectory(a,r,n):r&&this.matchPattern(o,r)&&n.push(a)}catch{}}}catch{}}matchPattern(e,r){return this.patternToRegex(r).test(e)}patternToRegex(e){let r="^";for(let n=0;n<e.length;n++){let s=e[n];if(s==="*")r+=".*";else if(s==="?")r+=".";else if(s==="["){let i=n+1,o="[";for(i<e.length&&(e[i]==="^"||e[i]==="!")&&(o+="^",i++),i<e.length&&e[i]==="]"&&(o+="\\]",i++);i<e.length&&e[i]!=="]";){if(e[i]==="["&&i+1<e.length&&e[i+1]===":"){let a=e.indexOf(":]",i+2);if(a!==-1){let l=e.slice(i+2,a),c=this.posixClassToRegex(l);o+=c,i=a+2;continue}}if(e[i]==="\\"&&i+1<e.length){o+=`\\${e[i+1]}`,i+=2;continue}e[i]==="-"?o+="\\-":o+=e[i],i++}o+="]",r+=o,n=i}else if(s==="\\"&&n+1<e.length){let i=e[n+1];/[.+^${}()|\\*?[\]]/.test(i)?r+=`\\${i}`:r+=i,n++}else/[.+^${}()|]/.test(s)?r+=`\\${s}`:r+=s}return r+="$",new RegExp(r)}posixClassToRegex(e){return{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"}[e]||""}};X();function Oe(t){switch(t.type){case"ArithCommandSubst":return!0;case"ArithNested":return Oe(t.expression);case"ArithBinary":return Oe(t.left)||Oe(t.right);case"ArithUnary":return Oe(t.operand);case"ArithTernary":return Oe(t.condition)||Oe(t.consequent)||Oe(t.alternate);case"ArithAssignment":return Oe(t.value);case"ArithGroup":return Oe(t.expression);case"ArithArrayElement":return t.index?Oe(t.index):!1;case"ArithConcat":return t.parts.some(Oe);default:return!1}}function qs(t){let e=t.operation;return e?!!("word"in e&&e.word&&Qe(e.word)||e.type==="PatternReplacement"&&(e.pattern&&Qe(e.pattern)||e.replacement&&Qe(e.replacement))||e.type==="PatternRemoval"&&e.pattern&&Qe(e.pattern)):!1}function sn(t){switch(t.type){case"CommandSubstitution":return!0;case"ArithmeticExpansion":return Oe(t.expression.expression);case"DoubleQuoted":return t.parts.some(sn);case"BraceExpansion":return t.items.some(e=>e.type==="Word"&&Qe(e.word));case"ParameterExpansion":return qs(t);default:return!1}}function Qe(t){return t.parts.some(sn)}function Vs(t){if(!t.operation)return!1;let e=t.operation,r;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(r=e.word?.parts),!r)return!1;for(let n of r)if(n.type==="DoubleQuoted"||n.type==="SingleQuoted")return!0;return!1}function Ju(t){let e=!1,r=!1,n=!1,s=!1,i=!1;for(let o of t){if((o.type==="SingleQuoted"||o.type==="DoubleQuoted")&&(e=!0,o.type==="DoubleQuoted"))for(let a of o.parts)a.type==="ParameterExpansion"&&a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&!a.operation&&(s=!0);o.type==="CommandSubstitution"&&(r=!0),o.type==="ParameterExpansion"&&(i=!0,(o.parameter==="@"||o.parameter==="*")&&(n=!0),Vs(o)&&(e=!0))}return{hasQuoted:e,hasCommandSub:r,hasArrayVar:n,hasArrayAtExpansion:s,hasParamExpansion:i}}function yy(t,e,r,n,s){let i=r??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;n?.match(/^-?0\d/)&&(l=Math.max(l,n.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,d=String(Math.abs(u)).padStart(l,"0");return f?`-${d}`:d}return String(u)};if(t<=e)for(let u=t,f=0;u<=e&&f<1e4;u+=o,f++)a.push(c(u));else for(let u=t,f=0;u>=e&&f<1e4;u-=o,f++)a.push(c(u));return a}function xy(t,e,r){let n=r??1;n===0&&(n=1);let s=t.charCodeAt(0),i=e.charCodeAt(0),o=Math.abs(n),a=t>="A"&&t<="Z",l=t>="a"&&t<="z",c=e>="A"&&e<="Z",u=e>="a"&&e<="z";if(a&&u||l&&c)return null;let f=[];if(s<=i)for(let d=s,p=0;d<=i&&p<1e4;d+=o,p++)f.push(String.fromCharCode(d));else for(let d=s,p=0;d>=i&&p<1e4;d-=o,p++)f.push(String.fromCharCode(d));return f}function ar(t,e,r,n,s){let i=r!==void 0?`..${r}`:"";return typeof t=="number"&&typeof e=="number"?{expanded:yy(t,e,r,n,s),literal:`{${t}..${e}${i}}`}:typeof t=="string"&&typeof e=="string"?{expanded:xy(t,e,r),literal:`{${t}..${e}${i}}`}:{expanded:null,literal:`{${t}..${e}${i}}`}}function Ne(t,e){let r="",n=0;for(;n<t.length;){let s=t[n];if(s==="\\")if(n+1<t.length){let i=t[n+1];/[\\^$.|+(){}[\]*?]/.test(i)?r+=`\\${i}`:r+=i,n+=2}else r+="\\\\",n++;else if(s==="*")r+=e?".*":".*?",n++;else if(s==="?")r+=".",n++;else if(s==="["){let i=wy(t,n);if(i===-1)r+="\\[",n++;else{let o=t.slice(n+1,i);r+=by(o),n=i+1}}else/[\^$.|+(){}]/.test(s)?(r+=`\\${s}`,n++):(r+=s,n++)}return r}function wy(t,e){let r=e+1;for(r<t.length&&t[r]==="^"&&r++,r<t.length&&t[r]==="]"&&r++;r<t.length;){if(t[r]==="\\"&&r+1<t.length){r+=2;continue}if(t[r]==="]")return r;if(t[r]==="'"){let n=t.indexOf("'",r+1);if(n!==-1){r=n+1;continue}}if(t[r]==="["&&r+1<t.length&&t[r+1]===":"){let n=t.indexOf(":]",r+2);if(n!==-1){r=n+2;continue}}r++}return-1}function by(t){let e="[",r=0;for((t[0]==="^"||t[0]==="!")&&(e+="^",r++);r<t.length;){if(t[r]==="'"){let s=t.indexOf("'",r+1);if(s!==-1){let i=t.slice(r+1,s);for(let o of i)o==="\\"?e+="\\\\":o==="]"?e+="\\]":o==="^"&&e==="["?e+="\\^":e+=o;r=s+1;continue}}if(t[r]==="["&&r+1<t.length&&t[r+1]===":"){let s=t.indexOf(":]",r+2);if(s!==-1){let i=t.slice(r+2,s);e+=Sy(i),r=s+2;continue}}let n=t[r];n==="\\"?r+1<t.length?(e+=`\\${t[r+1]}`,r+=2):(e+="\\\\",r++):n==="-"&&r>0&&r<t.length-1?(e+="-",r++):n==="^"&&r===0?(e+="^",r++):(n==="]"&&r===0?e+="\\]":e+=n,r++)}return e+="]",e}var Ey={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 Sy(t){return Ey[t]??""}X();function lr(t,e){let r=`${e}_`,n=[];for(let s of Object.keys(t.state.env))if(s.startsWith(r)){let i=s.slice(r.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&n.push(o)}return n.sort((s,i)=>s-i)}function cr(t,e){let r=`${e}_`;for(let n of Object.keys(t.state.env))n.startsWith(r)&&delete t.state.env[n]}function Ks(t,e){let r=`${e}_`,n=[];for(let s of Object.keys(t.state.env))if(s.startsWith(r)&&!s.includes("__")){let i=s.slice(r.length);n.push(i)}return n.sort()}function Yu(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function on(t){return t.IFS??`
649
- `}function ef(t){return t.IFS===""}function ur(t){return t.split("").map(e=>/[\\^$.*+?()[\]{}|-]/.test(e)?`\\${e}`:e===" "?"\\t":e===`
650
- `?"\\n":e).join("")}function Cy(t,e){let r=ur(t);return new RegExp(`[${r}]+`,e)}function Ay(t){let e=ur(t);return new RegExp(`^[${e}]+`)}function ky(t){let e=ur(t);return new RegExp(`[${e}]+$`)}function Ut(t){let e=t.IFS;return e===void 0?" ":e[0]||""}function tf(t,e){if(e==="")return{words:[t],wordStarts:[0]};let r=[],n=[],s=Cy(e,"g"),i=0,o=t.match(Ay(e));o&&(i=o[0].length),s.lastIndex=i;let a=s.exec(t);for(;a!==null;)a.index>i&&(n.push(i),r.push(t.substring(i,a.index))),i=s.lastIndex,a=s.exec(t);return i<t.length&&(n.push(i),r.push(t.substring(i))),{words:r,wordStarts:n}}function rf(t,e){return e===""?t:t.replace(ky(e),"")}function fe(t,e){return t.state.associativeArrays?.has(e)?Ks(t,e).map(i=>[i,t.state.env[`${e}_${i}`]]):lr(t,e).map(s=>[s,t.state.env[`${e}_${s}`]])}function nf(t,e){return t.state.associativeArrays?.has(e)?Ks(t,e).length>0:lr(t,e).length>0}function Fe(t,e,r=!0,n=!1){switch(e){case"?":return String(t.state.lastExitCode);case"$":return String(process.pid);case"#":return t.state.env["#"]||"0";case"@":return t.state.env["@"]||"";case"_":return t.state.lastArg;case"-":{let o="";return t.state.options.errexit&&(o+="e"),t.state.options.nounset&&(o+="u"),t.state.options.verbose&&(o+="v"),t.state.options.xtrace&&(o+="x"),t.state.options.pipefail&&(o+="p"),o}case"*":{let o=Number.parseInt(t.state.env["#"]||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(t.state.env[String(l)]||"");return a.join(Ut(t.state.env))}case"0":return t.state.env[0]||"bash";case"PWD":return t.state.env.PWD!==void 0?t.state.env.PWD:"";case"OLDPWD":return t.state.env.OLDPWD!==void 0?t.state.env.OLDPWD:"";case"PPID":{let{ppid:o}=or();return String(o)}case"UID":{let{uid:o}=or();return String(o)}case"EUID":return String(process.geteuid?.()??or().uid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-t.state.startTime)/1e3));case"BASH_VERSION":return Su;case"!":return String(t.state.lastBackgroundPid);case"LINENO":return String(t.state.currentLine)}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(e))throw new qe(`\${${e}}`);let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(a==="@"||a==="*"){let f=fe(t,o);if(f.length>0)return f.map(([,p])=>p).join(" ");let d=t.state.env[o];return d!==void 0?d:""}if(t.state.associativeArrays?.has(o)){let f=Yu(a),d=t.state.env[`${o}_${f}`];if(d===void 0&&r&&t.state.options.nounset)throw new Pe(`${o}[${a}]`);return d||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new pe,d=ue(f,a);c=K(t,d.expression)}catch{let f=t.state.env[a];c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=fe(t,o);if(f.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${o}: bad array subscript
651
- `,"";let p=Math.max(...f.map(([y])=>typeof y=="number"?y:0))+1+c;return p<0?(t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${o}: bad array subscript
652
- `,""):t.state.env[`${o}_${p}`]||""}let u=t.state.env[`${o}_${c}`];if(u===void 0&&r&&t.state.options.nounset)throw new Pe(`${o}[${c}]`);return u||""}if(/^[1-9][0-9]*$/.test(e)){let o=t.state.env[e];if(o===void 0&&r&&t.state.options.nounset)throw new Pe(e);return o||""}let i=t.state.env[e];if(i===void 0&&r&&t.state.options.nounset)throw new Pe(e);return i||""}async function sf(t,e,r,n,s){let i=[];for(let u of e){let f=u.type==="ParameterExpansion"||u.type==="CommandSubstitution"||u.type==="ArithmeticExpansion";if(u.type==="ParameterExpansion"&&Vs(u)){let d=await s(t,u);i.push({value:d,splittable:!1})}else{let d=await s(t,u);i.push({value:d,splittable:f})}}if(!i.some(u=>u.splittable&&new RegExp(`[${n}]`).test(u.value))){let u=i.map(f=>f.value).join("");return u?[u]:[]}let a=new RegExp(`[${n}]+`),l=[],c="";for(let u=0;u<i.length;u++){let f=i[u];if(!f.splittable)c+=f.value;else{let d=f.value.split(a);for(let p=0;p<d.length;p++)p===0?c+=d[p]:(c!==""&&l.push(c),c=d[p])}}return c!==""&&l.push(c),l}function Ie(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function of(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function af(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}function Zs(t){if(t==="")return"''";if(!/['\\\n\r\t\x00-\x1f\x7f]/.test(t))return`'${t}'`;let e="$'";for(let r of t)switch(r){case"'":e+="\\'";break;case"\\":e+="\\\\";break;case`
653
- `:e+="\\n";break;case"\r":e+="\\r";break;case" ":e+="\\t";break;default:{let n=r.charCodeAt(0);n<32||n===127?e+=`\\x${n.toString(16).padStart(2,"0")}`:e+=r}}return`${e}'`}function wt(t,e,r=!1){return e.map(n=>Xe(t,n,r)).join("")}async function bt(t,e,r=!1){let n=[];for(let s of e)n.push(await Te(t,s));return n.join("")}function Ny(t){return af(t)}function lf(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!Ny(e))return!1;return!0}function cf(t){return t.replace(/([*?[\]\\])/g,"\\$1")}function uf(t,e,r=!1){let n=of(e);if(n!==null)return n;switch(e.type){case"ParameterExpansion":return mf(t,e,r);case"TildeExpansion":return r?e.user===null?"~":`~${e.user}`:e.user===null?t.state.env.HOME||"/home/user":e.user==="root"?"/root":`~${e.user}`;case"Glob":return e.pattern;default:return null}}function Xe(t,e,r=!1){let n=uf(t,e,r);if(n!==null)return n;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(Xe(t,i,!0));return s.join("")}case"ArithmeticExpansion":return String(K(t,e.expression.expression));case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=ar(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(an(t,i.word));return s.join(" ")}default:return""}}function an(t,e){let r=e.parts,n=r.length;if(n===1)return Xe(t,r[0]);let s=[];for(let i=0;i<n;i++)s.push(Xe(t,r[i]));return s.join("")}async function Y(t,e){return Qe(e)?hf(t,e):an(t,e)}function ln(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&ln(e.parts))return!0;return!1}function Iy(t){for(let e of t){if(e.type==="BraceExpansion"){for(let r of e.items)if(r.type==="Word"&&Qe(r.word))return!0}if(sn(e))return!0}return!1}var ff=1e4,jt=1e5;function df(t,e,r={count:0}){if(r.count>jt)return[[]];let n=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=ar(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let d of f.expanded)r.count++,i.push(d);else{o=!0,a=f.literal;break}}else{let f=df(t,u.word.parts,r);for(let d of f)r.count++,i.push(d.join(""))}if(o){for(let u of n)r.count++,u.push(a);continue}if(n.length*i.length>ff||r.count>jt)return n;let c=[];for(let u of n)for(let f of i){if(r.count++,r.count>jt)return c.length>0?c:n;c.push([...u,f])}n=c}else{let i=Xe(t,s);for(let o of n)r.count++,o.push(i)}return n}function vy(t,e){let r=e.parts;return ln(r)?df(t,r).map(s=>s.join("")):[an(t,e)]}async function pf(t,e,r={count:0}){if(r.count>jt)return[[]];let n=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=ar(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let d of f.expanded)r.count++,i.push(d);else{o=!0,a=f.literal;break}}else{let f=await pf(t,u.word.parts,r);for(let d of f)r.count++,i.push(d.join(""))}if(o){for(let u of n)r.count++,u.push(a);continue}if(n.length*i.length>ff||r.count>jt)return n;let c=[];for(let u of n)for(let f of i){if(r.count++,r.count>jt)return c.length>0?c:n;c.push([...u,f])}n=c}else{let i=await Te(t,s);for(let o of n)r.count++,o.push(i)}return n}async function $y(t,e){let r=e.parts;return ln(r)?(await pf(t,r)).map(s=>s.join("")):[await Y(t,e)]}async function fr(t,e){let r=e.parts,{hasQuoted:n,hasCommandSub:s,hasArrayVar:i,hasArrayAtExpansion:o,hasParamExpansion:a}=Ju(r),c=ln(r)?Iy(r)?await $y(t,e):vy(t,e):null;if(c&&c.length>1){let d=[];for(let p of c)if(!n&&/[*?[]/.test(p)){let y=await new Wt(t.fs,t.state.cwd).expand(p);y.length>0?d.push(...y):d.push(p)}else d.push(p);return{values:d,quoted:!1}}if(o&&r.length===1&&r[0].type==="DoubleQuoted"){let d=r[0];if(d.parts.length===1&&d.parts[0].type==="ParameterExpansion"){let h=d.parts[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@]\]$/);if(h){let y=h[1],m=fe(t,y);if(m.length>0)return{values:m.map(([,b])=>b),quoted:!0};let w=t.state.env[y];return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}}}if(r.length===1&&r[0].type==="DoubleQuoted"){let d=r[0],p=-1,h=!1;for(let y=0;y<d.parts.length;y++){let m=d.parts[y];if(m.type==="ParameterExpansion"&&(m.parameter==="@"||m.parameter==="*")){p=y,h=m.parameter==="*";break}}if(p!==-1){let y=d.parts[p];y.type==="ParameterExpansion"&&y.operation&&(p=-1)}if(p!==-1){let y=Number.parseInt(t.state.env["#"]||"0",10),m="";for(let S=0;S<p;S++)m+=await Te(t,d.parts[S]);let w="";for(let S=p+1;S<d.parts.length;S++)w+=await Te(t,d.parts[S]);if(y===0){if(h)return{values:[m+w],quoted:!0};let S=m+w;return{values:S?[S]:[],quoted:!0}}let b=[];for(let S=1;S<=y;S++)b.push(t.state.env[String(S)]||"");if(h){let S=Ut(t.state.env);return{values:[m+b.join(S)+w],quoted:!0}}return b.length===1?{values:[m+b[0]+w],quoted:!0}:{values:[m+b[0],...b.slice(1,-1),b[b.length-1]+w],quoted:!0}}}if((s||i||a)&&!ef(t.state.env)){let d=on(t.state.env),p=ur(d),h=await sf(t,r,d,p,Te),y=[],m=new Wt(t.fs,t.state.cwd);for(let w of h)if(/[*?[]/.test(w)){let b=await m.expand(w);b.length>0?y.push(...b):y.push(w)}else y.push(w);return{values:y,quoted:!1}}let f=Qe(e)?await hf(t,e):an(t,e);if(!n&&/[*?[]/.test(f)){let p=await new Wt(t.fs,t.state.cwd).expand(f);if(p.length>0)return{values:p,quoted:!1}}return f===""&&!n?{values:[],quoted:!1}:{values:[f],quoted:n}}async function hf(t,e){let r=e.parts,n=r.length;if(n===1)return Te(t,r[0]);let s=[];for(let i=0;i<n;i++)s.push(await Te(t,r[i]));return s.join("")}async function Te(t,e){if(e.type==="ParameterExpansion"&&qs(e))return Ry(t,e);let r=uf(t,e);if(r!==null)return r;switch(e.type){case"DoubleQuoted":{let n=[];for(let s of e.parts)n.push(await Te(t,s));return n.join("")}case"CommandSubstitution":try{let n=await t.executeScript(e.body);return t.state.lastExitCode=n.exitCode,t.state.env["?"]=String(n.exitCode),n.stdout.replace(/\n+$/,"")}catch(n){if(n instanceof W)throw n;if(n instanceof Q)return t.state.lastExitCode=n.exitCode,t.state.env["?"]=String(n.exitCode),n.stdout.replace(/\n+$/,"");throw n}case"ArithmeticExpansion":return String(await Z(t,e.expression.expression));case"BraceExpansion":{let n=[];for(let s of e.items)if(s.type==="Range"){let i=ar(s.start,s.end,s.step,s.startStr,s.endStr);if(i.expanded)n.push(...i.expanded);else return i.literal}else n.push(await Y(t,s.word));return n.join(" ")}default:return""}}function mf(t,e,r=!1){let{parameter:n,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=Fe(t,n,!i);if(!s)return o;let a=!(n in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?wt(t,s.word.parts,r):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=wt(t,s.word.parts,r),f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,d,p]=f,h;if(/^\d+$/.test(p))h=Number.parseInt(p,10);else{try{let m=new pe,w=ue(m,p);h=K(t,w.expression)}catch{let m=t.state.env[p];h=m?Number.parseInt(m,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${d}_${h}`]=u;let y=Number.parseInt(t.state.env[`${d}__length`]||"0",10);h>=y&&(t.state.env[`${d}__length`]=String(h+1))}else t.state.env[n]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?wt(t,s.word.parts,r):`${n}: parameter null or not set`;throw new Q(1,"",`bash: ${u}
654
- `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?wt(t,s.word.parts,r):"";case"Length":{let c=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c){let u=fe(t,c[1]);return String(u.length)}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&nf(t,n)){let u=t.state.env[`${n}_0`]||"";return String(u.length)}return String(o.length)}case"LengthSliceError":throw new qe(n);case"Substring":{let c=s.offset?K(t,s.offset.expression):0,u=s.length?K(t,s.length.expression):void 0;if(n==="@"||n==="*"){let h=(t.state.env["@"]||"").split(" ").filter(b=>b),y=t.state.env[0]||"bash",m=c===0?[y,...h]:h,w=c===0?0:c-1;if(w<0||w>=m.length)return"";if(u!==void 0){let b=u<0?m.length+u:w+u;return m.slice(w,Math.max(w,b)).join(" ")}return m.slice(w).join(" ")}let f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(f){let y=fe(t,f[1]).map(([,w])=>w),m=c;if(m<0&&(m=y.length+m,m<0))return"";if(u!==void 0){if(u<0){let w=y.length+u;return y.slice(m,Math.max(m,w)).join(" ")}return y.slice(m,m+u).join(" ")}return y.slice(m).join(" ")}let d=[...o],p=c;if(p<0&&(p=Math.max(0,d.length+p)),u!==void 0){if(u<0){let h=d.length+u;return d.slice(p,Math.max(p,h)).join("")}return d.slice(p,p+u).join("")}return d.slice(p).join("")}case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=Ne(f.pattern,s.greedy);else if(f.type==="Literal")c+=Ne(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=Ie(f.value);else if(f.type==="DoubleQuoted"){let d=wt(t,f.parts);c+=Ie(d)}else if(f.type==="ParameterExpansion"){let d=Xe(t,f);c+=Ne(d,s.greedy)}else{let d=Xe(t,f);c+=Ie(d)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let d=o.slice(f);if(u.test(d))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let d of s.pattern.parts)if(d.type==="Glob")c+=Ne(d.pattern,!0);else if(d.type==="Literal")c+=Ne(d.value,!0);else if(d.type==="SingleQuoted"||d.type==="Escaped")c+=Ie(d.value);else if(d.type==="DoubleQuoted"){let p=wt(t,d.parts);c+=Ie(p)}else if(d.type==="ParameterExpansion"){let p=Xe(t,d);c+=Ne(p,!0)}else{let p=Xe(t,d);c+=Ie(p)}let u=s.replacement?wt(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let d=new RegExp(c,f);if(s.all){let p="",h=0,y=d.exec(o);for(;y!==null&&!(y[0].length===0&&y.index===o.length);)p+=o.slice(h,y.index)+u,h=y.index+y[0].length,y[0].length===0&&h++,y=d.exec(o);return p+=o.slice(h),p}return o.replace(d,u)}catch{return o}}case"CaseModification":return s.direction==="upper"?s.all?o.toUpperCase():o.charAt(0).toUpperCase()+o.slice(1):s.all?o.toLowerCase():o.charAt(0).toLowerCase()+o.slice(1);case"Transform":{let c=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c&&s.operator==="Q")return fe(t,c[1]).map(([,d])=>Zs(d)).join(" ");switch(s.operator){case"Q":return Zs(o);case"P":return o;case"a":return"";case"A":return`${n}=${Zs(o)}`;case"E":return o.replace(/\\([\\abefnrtv'"?])/g,(u,f)=>{switch(f){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
655
- `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return f}});case"K":return"";default:return o}}case"Indirection":return Fe(t,o);case"ArrayKeys":{let u=fe(t,s.array).map(([f])=>String(f));return s.star?u.join(Ut(t.state.env)):u.join(" ")}case"VarNamePrefix":{let c=Object.keys(t.state.env).filter(u=>u.startsWith(s.prefix)&&!u.includes("__")).sort();return s.star?c.join(Ut(t.state.env)):c.join(" ")}default:return o}}async function Ry(t,e,r=!1){let{parameter:n,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=Fe(t,n,!i);if(!s)return o;let a=!(n in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?bt(t,s.word.parts,r):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=await bt(t,s.word.parts,r),f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,d,p]=f,h;if(/^\d+$/.test(p))h=Number.parseInt(p,10);else{try{let m=new pe,w=ue(m,p);h=await Z(t,w.expression)}catch{let m=t.state.env[p];h=m?Number.parseInt(m,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${d}_${h}`]=u;let y=Number.parseInt(t.state.env[`${d}__length`]||"0",10);h>=y&&(t.state.env[`${d}__length`]=String(h+1))}else t.state.env[n]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?await bt(t,s.word.parts,r):`${n}: parameter null or not set`;throw new Q(1,"",`bash: ${u}
656
- `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?bt(t,s.word.parts,r):"";case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=Ne(f.pattern,s.greedy);else if(f.type==="Literal")c+=Ne(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=Ie(f.value);else if(f.type==="DoubleQuoted"){let d=await bt(t,f.parts);c+=Ie(d)}else if(f.type==="ParameterExpansion"){let d=await Te(t,f);c+=Ne(d,s.greedy)}else{let d=await Te(t,f);c+=Ie(d)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let d=o.slice(f);if(u.test(d))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let d of s.pattern.parts)if(d.type==="Glob")c+=Ne(d.pattern,!0);else if(d.type==="Literal")c+=Ne(d.value,!0);else if(d.type==="SingleQuoted"||d.type==="Escaped")c+=Ie(d.value);else if(d.type==="DoubleQuoted"){let p=await bt(t,d.parts);c+=Ie(p)}else if(d.type==="ParameterExpansion"){let p=await Te(t,d);c+=Ne(p,!0)}else{let p=await Te(t,d);c+=Ie(p)}let u=s.replacement?await bt(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let d=new RegExp(c,f);if(s.all){let p="",h=0,y=d.exec(o);for(;y!==null&&!(y[0].length===0&&y.index===o.length);)p+=o.slice(h,y.index)+u,h=y.index+y[0].length,y[0].length===0&&h++,y=d.exec(o);return p+=o.slice(h),p}return o.replace(d,u)}catch{return o}}default:return mf(t,e,r)}}function Qs(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?Math.trunc(t/e):0;case"%":return e!==0?t%e:0;case"**":if(e<0)throw new le("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function gf(t,e,r){switch(r){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function Xs(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}function Py(t,e){let r=t.state.env[e];if(r!==void 0)return r;let n=t.state.env[`${e}_0`];return n!==void 0?n:Fe(t,e)}function zt(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let r=t.trim();if(!r)return 0;try{let n=new pe,{expr:s,pos:i}=Ke(n,r,0);if(i<r.length){let o=r.slice(i).trim().split(/\s+/)[0];throw new le(`${r}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(n){if(n instanceof le)throw n;let s=r.split(/\s+/).slice(1)[0]||r;throw new le(`${r}: syntax error in expression (error token is "${s}")`)}}function cn(t,e,r=new Set){if(r.has(e))return 0;r.add(e);let n=Py(t,e);if(!n)return 0;let s=Number.parseInt(n,10);if(!Number.isNaN(s)&&/^-?\d+$/.test(n.trim()))return s;let i=n.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return cn(t,i,r);try{let o=new pe,{expr:a}=Ke(o,i,0);return Le(t,a,r)}catch{return 0}}function Le(t,e,r){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new le("value too great for base");return e.value;case"ArithVariable":return cn(t,e.name,r);case"ArithBinary":{if(e.operator==="||")return Le(t,e.left,r)||Le(t,e.right,r)?1:0;if(e.operator==="&&")return Le(t,e.left,r)&&Le(t,e.right,r)?1:0;let n=Le(t,e.left,r),s=Le(t,e.right,r);return Qs(n,s,e.operator)}case"ArithUnary":{let n=Le(t,e.operand,r);return Xs(n,e.operator)}case"ArithTernary":return Le(t,e.condition,r)?Le(t,e.consequent,r):Le(t,e.alternate,r);case"ArithGroup":return Le(t,e.expression,r);default:return K(t,e)}}function nt(t,e){if(e.startsWith("#")){let f=e.slice(1),d=t.state.env[f]||"";return String(d.length)}if(e.startsWith("!")){let f=e.slice(1),d=t.state.env[f]||"";return t.state.env[d]||""}let r=[":-",":=",":?",":+","-","=","?","+"],n=-1,s="";for(let f of r){let d=e.indexOf(f);d>0&&(n===-1||d<n)&&(n=d,s=f)}if(n===-1)return Fe(t,e);let i=e.slice(0,n),o=e.slice(n+s.length),a=t.state.env[i],l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env[i]=o,o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}function K(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new le("value too great for base");return e.value;case"ArithVariable":return cn(t,e.name);case"ArithNested":return K(t,e.expression);case"ArithCommandSubst":return 0;case"ArithBracedExpansion":{let r=nt(t,e.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=nt(t,e.baseExpr),n=Number.parseInt(r,10);if(n<2||n>64)return 0;let s=`${n}#${e.value}`;return Bt(s)}case"ArithDynamicNumber":{let n=nt(t,e.prefix)+e.suffix;return Bt(n)}case"ArithArrayElement":{let r=t.state.associativeArrays?.has(e.array),n;if(e.stringKey!==void 0)n=`${e.array}_${e.stringKey}`;else if(r&&e.index?.type==="ArithVariable")n=`${e.array}_${e.index.name}`;else if(e.index){let i=K(t,e.index);if(i<0){let a=fe(t,e.array);if(a.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${e.array}: bad array subscript
648
+ `&&(o+=c),i+=2):(o+=e[i],i++)}else o+=e[i],i++;i>=e.length&&this.error("unexpected EOF while looking for matching ``'");let l=new t().parse(o);return{part:O.commandSubstitution(l,!0),endIndex:i+1}}parseArithmeticExpansion(e,r){let n=r+3,s=1,i=0,o=n;for(;o<e.length-1&&s>0;)e[o]==="$"&&e[o+1]==="("?e[o+2]==="("?(s++,o+=3):(i++,o+=2):e[o]==="("&&e[o+1]==="("?(s++,o+=2):e[o]===")"&&e[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):e[o]==="("?(i++,o++):(e[o]===")"&&i>0&&i--,o++);let a=e.slice(n,o),l=this.parseArithmeticExpression(a);return{part:O.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){this.expect(y.DPAREN_START);let e="",r=1,n=0,s=!1,i=!1;for(;r>0&&!this.check(y.EOF);){if(s){if(s=!1,n>0){n--,e+=")";continue}if(this.check(y.RPAREN)){r--,i=!0,this.advance();continue}if(this.check(y.DPAREN_END)){r--,i=!0;continue}e+=")";continue}this.check(y.DPAREN_START)?(r++,e+="((",this.advance()):this.check(y.DPAREN_END)?n>=2?(n-=2,e+="))",this.advance()):n===1?(n--,e+=")",s=!0,this.advance()):(r--,i=!0,r>0&&(e+="))"),this.advance()):this.check(y.LPAREN)?(n++,e+="(",this.advance()):this.check(y.RPAREN)?(n>0&&n--,e+=")",this.advance()):(e+=this.current().value,this.advance())}i||this.expect(y.DPAREN_END);let o=this.parseArithmeticExpression(e.trim()),a=this.parseOptionalRedirections();return O.arithmeticCommand(o,a)}parseConditionalCommand(){this.expect(y.DBRACK_START);let e=Js(this);this.expect(y.DBRACK_END);let r=this.parseOptionalRedirections();return O.conditionalCommand(e,r)}parseFunctionDef(){let e;this.check(y.FUNCTION)?(this.advance(),e=this.expect(y.NAME,"Expected function name").value,this.check(y.LPAREN)&&(this.advance(),this.expect(y.RPAREN))):(e=this.advance().value,this.expect(y.LPAREN),this.expect(y.RPAREN)),this.skipNewlines();let r=this.parseCompoundCommandBody(),n=this.parseOptionalRedirections();return O.functionDef(e,r,n)}parseCompoundCommandBody(){if(this.check(y.LBRACE))return Qs(this);if(this.check(y.LPAREN))return Zs(this);if(this.check(y.IF))return Hs(this);if(this.check(y.FOR))return Gs(this);if(this.check(y.WHILE))return qs(this);if(this.check(y.UNTIL))return Vs(this);if(this.check(y.CASE))return Ks(this);this.error("Expected compound command for function body")}parseCompoundList(){let e=[];for(this.skipNewlines();!this.check(y.EOF,y.FI,y.ELSE,y.ELIF,y.THEN,y.DO,y.DONE,y.ESAC,y.RPAREN,y.RBRACE,y.DSEMI,y.SEMI_AND,y.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let r=this.pos,n=this.parseStatement();if(n&&e.push(n),this.skipSeparators(),this.pos===r&&!n)break}return e}parseOptionalRedirections(){let e=[];for(;dn(this);){this.checkIterationLimit();let r=this.pos;if(e.push(hn(this)),this.pos===r)break}return e}parseArithmeticExpression(e){return be(this,e)}};function lt(t){return new Se().parse(t)}oe();ht();var Qt=class{fs;cwd;constructor(e,r){this.fs=e,this.cwd=r}isGlobPattern(e){return e.includes("*")||e.includes("?")||/\[.*\]/.test(e)}async expandArgs(e,r){let n=e.map((o,a)=>(r?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(n.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<e.length;o++){let a=s[o];a===null?i.push(e[o]):a.length>0?i.push(...a):i.push(e[o])}return i}async expand(e){return e.includes("**")?this.expandRecursive(e):this.expandSimple(e)}async expandSimple(e){let r=[],n=e.lastIndexOf("/"),s,i;n===-1?(s=this.cwd,i=e):(s=e.slice(0,n)||"/",i=e.slice(n+1));let o=this.fs.resolvePath(this.cwd,s);try{let a=await this.fs.readdir(o);for(let l of a)if(this.matchPattern(l,i)){let c=n===-1?l:`${s}/${l}`;r.push(c)}}catch{}return r.sort()}async expandRecursive(e){let r=[],n=e.indexOf("**"),s=e.slice(0,n).replace(/\/$/,"")||".",o=e.slice(n+2).replace(/^\//,"");return await this.walkDirectory(s,o,r),r.sort()}async walkDirectory(e,r,n){let s=this.fs.resolvePath(this.cwd,e);try{if(this.fs.readdirWithFileTypes){let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=e==="."?l.name:`${e}/${l.name}`;l.isDirectory?a.push(c):r&&this.matchPattern(l.name,r)&&o.push(c)}n.push(...o);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u,r,n)))}}else{let i=await this.fs.readdir(s),o=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let p=e==="."?f:`${e}/${f}`,d=this.fs.resolvePath(this.cwd,p);try{let h=await this.fs.stat(d);return{name:f,path:p,isDirectory:h.isDirectory}}catch{return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&r&&this.matchPattern(l.name,r)&&n.push(l.path);let a=o.filter(l=>l.isDirectory);for(let l=0;l<a.length;l+=100){let c=a.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,r,n)))}}}catch{}}matchPattern(e,r){return this.patternToRegex(r).test(e)}patternToRegex(e){let r="^";for(let n=0;n<e.length;n++){let s=e[n];if(s==="*")r+=".*";else if(s==="?")r+=".";else if(s==="["){let i=n+1,o="[";for(i<e.length&&(e[i]==="^"||e[i]==="!")&&(o+="^",i++),i<e.length&&e[i]==="]"&&(o+="\\]",i++);i<e.length&&e[i]!=="]";){if(e[i]==="["&&i+1<e.length&&e[i+1]===":"){let a=e.indexOf(":]",i+2);if(a!==-1){let l=e.slice(i+2,a),c=this.posixClassToRegex(l);o+=c,i=a+2;continue}}if(e[i]==="\\"&&i+1<e.length){o+=`\\${e[i+1]}`,i+=2;continue}e[i]==="-"?o+="\\-":o+=e[i],i++}o+="]",r+=o,n=i}else if(s==="\\"&&n+1<e.length){let i=e[n+1];/[.+^${}()|\\*?[\]]/.test(i)?r+=`\\${i}`:r+=i,n++}else/[.+^${}()|]/.test(s)?r+=`\\${s}`:r+=s}return r+="$",new RegExp(r)}posixClassToRegex(e){return{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"}[e]||""}};oe();function je(t){switch(t.type){case"ArithCommandSubst":return!0;case"ArithNested":return je(t.expression);case"ArithBinary":return je(t.left)||je(t.right);case"ArithUnary":return je(t.operand);case"ArithTernary":return je(t.condition)||je(t.consequent)||je(t.alternate);case"ArithAssignment":return je(t.value);case"ArithGroup":return je(t.expression);case"ArithArrayElement":return t.index?je(t.index):!1;case"ArithConcat":return t.parts.some(je);default:return!1}}function ei(t){let e=t.operation;return e?!!("word"in e&&e.word&&rt(e.word)||e.type==="PatternReplacement"&&(e.pattern&&rt(e.pattern)||e.replacement&&rt(e.replacement))||e.type==="PatternRemoval"&&e.pattern&&rt(e.pattern)):!1}function mn(t){switch(t.type){case"CommandSubstitution":return!0;case"ArithmeticExpansion":return je(t.expression.expression);case"DoubleQuoted":return t.parts.some(mn);case"BraceExpansion":return t.items.some(e=>e.type==="Word"&&rt(e.word));case"ParameterExpansion":return ei(t);default:return!1}}function rt(t){return t.parts.some(mn)}function ti(t){if(!t.operation)return!1;let e=t.operation,r;if((e.type==="DefaultValue"||e.type==="AssignDefault"||e.type==="UseAlternative"||e.type==="ErrorIfUnset")&&(r=e.word?.parts),!r)return!1;for(let n of r)if(n.type==="DoubleQuoted"||n.type==="SingleQuoted")return!0;return!1}function af(t){let e=!1,r=!1,n=!1,s=!1,i=!1;for(let o of t){if((o.type==="SingleQuoted"||o.type==="DoubleQuoted")&&(e=!0,o.type==="DoubleQuoted"))for(let a of o.parts)a.type==="ParameterExpansion"&&a.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&!a.operation&&(s=!0);o.type==="CommandSubstitution"&&(r=!0),o.type==="ParameterExpansion"&&(i=!0,(o.parameter==="@"||o.parameter==="*")&&(n=!0),ti(o)&&(e=!0))}return{hasQuoted:e,hasCommandSub:r,hasArrayVar:n,hasArrayAtExpansion:s,hasParamExpansion:i}}function ky(t,e,r,n,s){let i=r??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;n?.match(/^-?0\d/)&&(l=Math.max(l,n.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,p=String(Math.abs(u)).padStart(l,"0");return f?`-${p}`:p}return String(u)};if(t<=e)for(let u=t,f=0;u<=e&&f<1e4;u+=o,f++)a.push(c(u));else for(let u=t,f=0;u>=e&&f<1e4;u-=o,f++)a.push(c(u));return a}function Ny(t,e,r){let n=r??1;n===0&&(n=1);let s=t.charCodeAt(0),i=e.charCodeAt(0),o=Math.abs(n),a=t>="A"&&t<="Z",l=t>="a"&&t<="z",c=e>="A"&&e<="Z",u=e>="a"&&e<="z";if(a&&u||l&&c)return null;let f=[];if(s<=i)for(let p=s,d=0;p<=i&&d<1e4;p+=o,d++)f.push(String.fromCharCode(p));else for(let p=s,d=0;p>=i&&d<1e4;p-=o,d++)f.push(String.fromCharCode(p));return f}function yr(t,e,r,n,s){let i=r!==void 0?`..${r}`:"";return typeof t=="number"&&typeof e=="number"?{expanded:ky(t,e,r,n,s),literal:`{${t}..${e}${i}}`}:typeof t=="string"&&typeof e=="string"?{expanded:Ny(t,e,r),literal:`{${t}..${e}${i}}`}:{expanded:null,literal:`{${t}..${e}${i}}`}}function Me(t,e){let r="",n=0;for(;n<t.length;){let s=t[n];if(s==="\\")if(n+1<t.length){let i=t[n+1];/[\\^$.|+(){}[\]*?]/.test(i)?r+=`\\${i}`:r+=i,n+=2}else r+="\\\\",n++;else if(s==="*")r+=e?".*":".*?",n++;else if(s==="?")r+=".",n++;else if(s==="["){let i=Iy(t,n);if(i===-1)r+="\\[",n++;else{let o=t.slice(n+1,i);r+=vy(o),n=i+1}}else/[\^$.|+(){}]/.test(s)?(r+=`\\${s}`,n++):(r+=s,n++)}return r}function Iy(t,e){let r=e+1;for(r<t.length&&t[r]==="^"&&r++,r<t.length&&t[r]==="]"&&r++;r<t.length;){if(t[r]==="\\"&&r+1<t.length){r+=2;continue}if(t[r]==="]")return r;if(t[r]==="'"){let n=t.indexOf("'",r+1);if(n!==-1){r=n+1;continue}}if(t[r]==="["&&r+1<t.length&&t[r+1]===":"){let n=t.indexOf(":]",r+2);if(n!==-1){r=n+2;continue}}r++}return-1}function vy(t){let e="[",r=0;for((t[0]==="^"||t[0]==="!")&&(e+="^",r++);r<t.length;){if(t[r]==="'"){let s=t.indexOf("'",r+1);if(s!==-1){let i=t.slice(r+1,s);for(let o of i)o==="\\"?e+="\\\\":o==="]"?e+="\\]":o==="^"&&e==="["?e+="\\^":e+=o;r=s+1;continue}}if(t[r]==="["&&r+1<t.length&&t[r+1]===":"){let s=t.indexOf(":]",r+2);if(s!==-1){let i=t.slice(r+2,s);e+=Ry(i),r=s+2;continue}}let n=t[r];n==="\\"?r+1<t.length?(e+=`\\${t[r+1]}`,r+=2):(e+="\\\\",r++):n==="-"&&r>0&&r<t.length-1?(e+="-",r++):n==="^"&&r===0?(e+="^",r++):(n==="]"&&r===0?e+="\\]":e+=n,r++)}return e+="]",e}var $y={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 Ry(t){return $y[t]??""}oe();function xr(t,e){let r=`${e}_`,n=[];for(let s of Object.keys(t.state.env))if(s.startsWith(r)){let i=s.slice(r.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&n.push(o)}return n.sort((s,i)=>s-i)}function wr(t,e){let r=`${e}_`;for(let n of Object.keys(t.state.env))n.startsWith(r)&&delete t.state.env[n]}function ri(t,e){let r=`${e}_`,n=[];for(let s of Object.keys(t.state.env))if(s.startsWith(r)&&!s.includes("__")){let i=s.slice(r.length);n.push(i)}return n.sort()}function lf(t){return t.startsWith("'")&&t.endsWith("'")||t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t}function gn(t){return t.IFS??`
649
+ `}function cf(t){return t.IFS===""}function br(t){return t.split("").map(e=>/[\\^$.*+?()[\]{}|-]/.test(e)?`\\${e}`:e===" "?"\\t":e===`
650
+ `?"\\n":e).join("")}function Py(t,e){let r=br(t);return new RegExp(`[${r}]+`,e)}function Fy(t){let e=br(t);return new RegExp(`^[${e}]+`)}function Oy(t){let e=br(t);return new RegExp(`[${e}]+$`)}function Xt(t){let e=t.IFS;return e===void 0?" ":e[0]||""}function uf(t,e){if(e==="")return{words:[t],wordStarts:[0]};let r=[],n=[],s=Py(e,"g"),i=0,o=t.match(Fy(e));o&&(i=o[0].length),s.lastIndex=i;let a=s.exec(t);for(;a!==null;)a.index>i&&(n.push(i),r.push(t.substring(i,a.index))),i=s.lastIndex,a=s.exec(t);return i<t.length&&(n.push(i),r.push(t.substring(i))),{words:r,wordStarts:n}}function ff(t,e){return e===""?t:t.replace(Oy(e),"")}function Ee(t,e){return t.state.associativeArrays?.has(e)?ri(t,e).map(i=>[i,t.state.env[`${e}_${i}`]]):xr(t,e).map(s=>[s,t.state.env[`${e}_${s}`]])}function pf(t,e){return t.state.associativeArrays?.has(e)?ri(t,e).length>0:xr(t,e).length>0}function ze(t,e,r=!0,n=!1){switch(e){case"?":return String(t.state.lastExitCode);case"$":return String(process.pid);case"#":return t.state.env["#"]||"0";case"@":return t.state.env["@"]||"";case"_":return t.state.lastArg;case"-":{let o="";return t.state.options.errexit&&(o+="e"),t.state.options.nounset&&(o+="u"),t.state.options.verbose&&(o+="v"),t.state.options.xtrace&&(o+="x"),t.state.options.pipefail&&(o+="p"),o}case"*":{let o=Number.parseInt(t.state.env["#"]||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(t.state.env[String(l)]||"");return a.join(Xt(t.state.env))}case"0":return t.state.env[0]||"bash";case"PWD":return t.state.env.PWD!==void 0?t.state.env.PWD:"";case"OLDPWD":return t.state.env.OLDPWD!==void 0?t.state.env.OLDPWD:"";case"PPID":{let{ppid:o}=gr();return String(o)}case"UID":{let{uid:o}=gr();return String(o)}case"EUID":return String(process.geteuid?.()??gr().uid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-t.state.startTime)/1e3));case"BASH_VERSION":return Ru;case"!":return String(t.state.lastBackgroundPid);case"LINENO":return String(t.state.currentLine)}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(e))throw new Je(`\${${e}}`);let s=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(a==="@"||a==="*"){let f=Ee(t,o);if(f.length>0)return f.map(([,d])=>d).join(" ");let p=t.state.env[o];return p!==void 0?p:""}if(t.state.associativeArrays?.has(o)){let f=lf(a),p=t.state.env[`${o}_${f}`];if(p===void 0&&r&&t.state.options.nounset)throw new Ue(`${o}[${a}]`);return p||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new Se,p=be(f,a);c=ee(t,p.expression)}catch{let f=t.state.env[a];c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=Ee(t,o);if(f.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${o}: bad array subscript
651
+ `,"";let d=Math.max(...f.map(([m])=>typeof m=="number"?m:0))+1+c;return d<0?(t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${o}: bad array subscript
652
+ `,""):t.state.env[`${o}_${d}`]||""}let u=t.state.env[`${o}_${c}`];if(u===void 0&&r&&t.state.options.nounset)throw new Ue(`${o}[${c}]`);return u||""}if(/^[1-9][0-9]*$/.test(e)){let o=t.state.env[e];if(o===void 0&&r&&t.state.options.nounset)throw new Ue(e);return o||""}let i=t.state.env[e];if(i===void 0&&r&&t.state.options.nounset)throw new Ue(e);return i||""}async function df(t,e,r,n,s){let i=[];for(let u of e){let f=u.type==="ParameterExpansion"||u.type==="CommandSubstitution"||u.type==="ArithmeticExpansion";if(u.type==="ParameterExpansion"&&ti(u)){let p=await s(t,u);i.push({value:p,splittable:!1})}else{let p=await s(t,u);i.push({value:p,splittable:f})}}if(!i.some(u=>u.splittable&&new RegExp(`[${n}]`).test(u.value))){let u=i.map(f=>f.value).join("");return u?[u]:[]}let a=new RegExp(`[${n}]+`),l=[],c="";for(let u=0;u<i.length;u++){let f=i[u];if(!f.splittable)c+=f.value;else{let p=f.value.split(a);for(let d=0;d<p.length;d++)d===0?c+=p[d]:(c!==""&&l.push(c),c=p[d])}}return c!==""&&l.push(c),l}function _e(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function hf(t){switch(t.type){case"Literal":return t.value;case"SingleQuoted":return t.value;case"Escaped":return t.value;default:return null}}function mf(t){switch(t.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return t.value==="";default:return!1}}function ni(t){if(t==="")return"''";if(!/['\\\n\r\t\x00-\x1f\x7f]/.test(t))return`'${t}'`;let e="$'";for(let r of t)switch(r){case"'":e+="\\'";break;case"\\":e+="\\\\";break;case`
653
+ `:e+="\\n";break;case"\r":e+="\\r";break;case" ":e+="\\t";break;default:{let n=r.charCodeAt(0);n<32||n===127?e+=`\\x${n.toString(16).padStart(2,"0")}`:e+=r}}return`${e}'`}function $t(t,e,r=!1){return e.map(n=>nt(t,n,r)).join("")}async function Rt(t,e,r=!1){let n=[];for(let s of e)n.push(await He(t,s));return n.join("")}function Ty(t){return mf(t)}function gf(t){if(t.parts.length===0)return!0;for(let e of t.parts)if(!Ty(e))return!1;return!0}function yf(t){return t.replace(/([*?[\]\\])/g,"\\$1")}function xf(t,e,r=!1){let n=hf(e);if(n!==null)return n;switch(e.type){case"ParameterExpansion":return Cf(t,e,r);case"TildeExpansion":return r?e.user===null?"~":`~${e.user}`:e.user===null?t.state.env.HOME||"/home/user":e.user==="root"?"/root":`~${e.user}`;case"Glob":return e.pattern;default:return null}}function nt(t,e,r=!1){let n=xf(t,e,r);if(n!==null)return n;switch(e.type){case"DoubleQuoted":{let s=[];for(let i of e.parts)s.push(nt(t,i,!0));return s.join("")}case"ArithmeticExpansion":return String(ee(t,e.expression.expression));case"BraceExpansion":{let s=[];for(let i of e.items)if(i.type==="Range"){let o=yr(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(yn(t,i.word));return s.join(" ")}default:return""}}function yn(t,e){let r=e.parts,n=r.length;if(n===1)return nt(t,r[0]);let s=[];for(let i=0;i<n;i++)s.push(nt(t,r[i]));return s.join("")}async function le(t,e){return rt(e)?Sf(t,e):yn(t,e)}function xn(t){for(let e of t)if(e.type==="BraceExpansion"||e.type==="DoubleQuoted"&&xn(e.parts))return!0;return!1}function Dy(t){for(let e of t){if(e.type==="BraceExpansion"){for(let r of e.items)if(r.type==="Word"&&rt(r.word))return!0}if(mn(e))return!0}return!1}var wf=1e4,Jt=1e5;function bf(t,e,r={count:0}){if(r.count>Jt)return[[]];let n=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=yr(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let p of f.expanded)r.count++,i.push(p);else{o=!0,a=f.literal;break}}else{let f=bf(t,u.word.parts,r);for(let p of f)r.count++,i.push(p.join(""))}if(o){for(let u of n)r.count++,u.push(a);continue}if(n.length*i.length>wf||r.count>Jt)return n;let c=[];for(let u of n)for(let f of i){if(r.count++,r.count>Jt)return c.length>0?c:n;c.push([...u,f])}n=c}else{let i=nt(t,s);for(let o of n)r.count++,o.push(i)}return n}function Ly(t,e){let r=e.parts;return xn(r)?bf(t,r).map(s=>s.join("")):[yn(t,e)]}async function Ef(t,e,r={count:0}){if(r.count>Jt)return[[]];let n=[[]];for(let s of e)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=yr(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let p of f.expanded)r.count++,i.push(p);else{o=!0,a=f.literal;break}}else{let f=await Ef(t,u.word.parts,r);for(let p of f)r.count++,i.push(p.join(""))}if(o){for(let u of n)r.count++,u.push(a);continue}if(n.length*i.length>wf||r.count>Jt)return n;let c=[];for(let u of n)for(let f of i){if(r.count++,r.count>Jt)return c.length>0?c:n;c.push([...u,f])}n=c}else{let i=await He(t,s);for(let o of n)r.count++,o.push(i)}return n}async function My(t,e){let r=e.parts;return xn(r)?(await Ef(t,r)).map(s=>s.join("")):[await le(t,e)]}async function Er(t,e){let r=e.parts,{hasQuoted:n,hasCommandSub:s,hasArrayVar:i,hasArrayAtExpansion:o,hasParamExpansion:a}=af(r),c=xn(r)?Dy(r)?await My(t,e):Ly(t,e):null;if(c&&c.length>1){let p=[];for(let d of c)if(!n&&/[*?[]/.test(d)){let m=await new Qt(t.fs,t.state.cwd).expand(d);m.length>0?p.push(...m):p.push(d)}else p.push(d);return{values:p,quoted:!1}}if(o&&r.length===1&&r[0].type==="DoubleQuoted"){let p=r[0];if(p.parts.length===1&&p.parts[0].type==="ParameterExpansion"){let h=p.parts[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@]\]$/);if(h){let m=h[1],g=Ee(t,m);if(g.length>0)return{values:g.map(([,b])=>b),quoted:!0};let w=t.state.env[m];return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}}}if(r.length===1&&r[0].type==="DoubleQuoted"){let p=r[0],d=-1,h=!1;for(let m=0;m<p.parts.length;m++){let g=p.parts[m];if(g.type==="ParameterExpansion"&&(g.parameter==="@"||g.parameter==="*")){d=m,h=g.parameter==="*";break}}if(d!==-1){let m=p.parts[d];m.type==="ParameterExpansion"&&m.operation&&(d=-1)}if(d!==-1){let m=Number.parseInt(t.state.env["#"]||"0",10),g="";for(let S=0;S<d;S++)g+=await He(t,p.parts[S]);let w="";for(let S=d+1;S<p.parts.length;S++)w+=await He(t,p.parts[S]);if(m===0){if(h)return{values:[g+w],quoted:!0};let S=g+w;return{values:S?[S]:[],quoted:!0}}let b=[];for(let S=1;S<=m;S++)b.push(t.state.env[String(S)]||"");if(h){let S=Xt(t.state.env);return{values:[g+b.join(S)+w],quoted:!0}}return b.length===1?{values:[g+b[0]+w],quoted:!0}:{values:[g+b[0],...b.slice(1,-1),b[b.length-1]+w],quoted:!0}}}if((s||i||a)&&!cf(t.state.env)){let p=gn(t.state.env),d=br(p),h=await df(t,r,p,d,He),m=[],g=new Qt(t.fs,t.state.cwd);for(let w of h)if(/[*?[]/.test(w)){let b=await g.expand(w);b.length>0?m.push(...b):m.push(w)}else m.push(w);return{values:m,quoted:!1}}let f=rt(e)?await Sf(t,e):yn(t,e);if(!n&&/[*?[]/.test(f)){let d=await new Qt(t.fs,t.state.cwd).expand(f);if(d.length>0)return{values:d,quoted:!1}}return f===""&&!n?{values:[],quoted:!1}:{values:[f],quoted:n}}async function Sf(t,e){let r=e.parts,n=r.length;if(n===1)return He(t,r[0]);let s=[];for(let i=0;i<n;i++)s.push(await He(t,r[i]));return s.join("")}async function He(t,e){if(e.type==="ParameterExpansion"&&ei(e))return _y(t,e);let r=xf(t,e);if(r!==null)return r;switch(e.type){case"DoubleQuoted":{let n=[];for(let s of e.parts)n.push(await He(t,s));return n.join("")}case"CommandSubstitution":try{let n=await t.executeScript(e.body);return t.state.lastExitCode=n.exitCode,t.state.env["?"]=String(n.exitCode),n.stdout.replace(/\n+$/,"")}catch(n){if(n instanceof j)throw n;if(n instanceof ie)return t.state.lastExitCode=n.exitCode,t.state.env["?"]=String(n.exitCode),n.stdout.replace(/\n+$/,"");throw n}case"ArithmeticExpansion":return String(await te(t,e.expression.expression));case"BraceExpansion":{let n=[];for(let s of e.items)if(s.type==="Range"){let i=yr(s.start,s.end,s.step,s.startStr,s.endStr);if(i.expanded)n.push(...i.expanded);else return i.literal}else n.push(await le(t,s.word));return n.join(" ")}default:return""}}function Cf(t,e,r=!1){let{parameter:n,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=ze(t,n,!i);if(!s)return o;let a=!(n in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?$t(t,s.word.parts,r):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=$t(t,s.word.parts,r),f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,p,d]=f,h;if(/^\d+$/.test(d))h=Number.parseInt(d,10);else{try{let g=new Se,w=be(g,d);h=ee(t,w.expression)}catch{let g=t.state.env[d];h=g?Number.parseInt(g,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${p}_${h}`]=u;let m=Number.parseInt(t.state.env[`${p}__length`]||"0",10);h>=m&&(t.state.env[`${p}__length`]=String(h+1))}else t.state.env[n]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?$t(t,s.word.parts,r):`${n}: parameter null or not set`;throw new ie(1,"",`bash: ${u}
654
+ `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?$t(t,s.word.parts,r):"";case"Length":{let c=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c){let u=Ee(t,c[1]);return String(u.length)}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&pf(t,n)){let u=t.state.env[`${n}_0`]||"";return String(u.length)}return String(o.length)}case"LengthSliceError":throw new Je(n);case"Substring":{let c=s.offset?ee(t,s.offset.expression):0,u=s.length?ee(t,s.length.expression):void 0;if(n==="@"||n==="*"){let h=(t.state.env["@"]||"").split(" ").filter(b=>b),m=t.state.env[0]||"bash",g=c===0?[m,...h]:h,w=c===0?0:c-1;if(w<0||w>=g.length)return"";if(u!==void 0){let b=u<0?g.length+u:w+u;return g.slice(w,Math.max(w,b)).join(" ")}return g.slice(w).join(" ")}let f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(f){let m=Ee(t,f[1]).map(([,w])=>w),g=c;if(g<0&&(g=m.length+g,g<0))return"";if(u!==void 0){if(u<0){let w=m.length+u;return m.slice(g,Math.max(g,w)).join(" ")}return m.slice(g,g+u).join(" ")}return m.slice(g).join(" ")}let p=[...o],d=c;if(d<0&&(d=Math.max(0,p.length+d)),u!==void 0){if(u<0){let h=p.length+u;return p.slice(d,Math.max(d,h)).join("")}return p.slice(d,d+u).join("")}return p.slice(d).join("")}case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=Me(f.pattern,s.greedy);else if(f.type==="Literal")c+=Me(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=_e(f.value);else if(f.type==="DoubleQuoted"){let p=$t(t,f.parts);c+=_e(p)}else if(f.type==="ParameterExpansion"){let p=nt(t,f);c+=Me(p,s.greedy)}else{let p=nt(t,f);c+=_e(p)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let p=o.slice(f);if(u.test(p))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let p of s.pattern.parts)if(p.type==="Glob")c+=Me(p.pattern,!0);else if(p.type==="Literal")c+=Me(p.value,!0);else if(p.type==="SingleQuoted"||p.type==="Escaped")c+=_e(p.value);else if(p.type==="DoubleQuoted"){let d=$t(t,p.parts);c+=_e(d)}else if(p.type==="ParameterExpansion"){let d=nt(t,p);c+=Me(d,!0)}else{let d=nt(t,p);c+=_e(d)}let u=s.replacement?$t(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let p=new RegExp(c,f);if(s.all){let d="",h=0,m=p.exec(o);for(;m!==null&&!(m[0].length===0&&m.index===o.length);)d+=o.slice(h,m.index)+u,h=m.index+m[0].length,m[0].length===0&&h++,m=p.exec(o);return d+=o.slice(h),d}return o.replace(p,u)}catch{return o}}case"CaseModification":return s.direction==="upper"?s.all?o.toUpperCase():o.charAt(0).toUpperCase()+o.slice(1):s.all?o.toLowerCase():o.charAt(0).toLowerCase()+o.slice(1);case"Transform":{let c=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(c&&s.operator==="Q")return Ee(t,c[1]).map(([,p])=>ni(p)).join(" ");switch(s.operator){case"Q":return ni(o);case"P":return o;case"a":return"";case"A":return`${n}=${ni(o)}`;case"E":return o.replace(/\\([\\abefnrtv'"?])/g,(u,f)=>{switch(f){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
655
+ `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return f}});case"K":return"";default:return o}}case"Indirection":return ze(t,o);case"ArrayKeys":{let u=Ee(t,s.array).map(([f])=>String(f));return s.star?u.join(Xt(t.state.env)):u.join(" ")}case"VarNamePrefix":{let c=Object.keys(t.state.env).filter(u=>u.startsWith(s.prefix)&&!u.includes("__")).sort();return s.star?c.join(Xt(t.state.env)):c.join(" ")}default:return o}}async function _y(t,e,r=!1){let{parameter:n,operation:s}=e,i=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=ze(t,n,!i);if(!s)return o;let a=!(n in t.state.env),l=o==="";switch(s.type){case"DefaultValue":return(a||s.checkEmpty&&l)&&s.word?Rt(t,s.word.parts,r):o;case"AssignDefault":{if((a||s.checkEmpty&&l)&&s.word){let u=await Rt(t,s.word.parts,r),f=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(f){let[,p,d]=f,h;if(/^\d+$/.test(d))h=Number.parseInt(d,10);else{try{let g=new Se,w=be(g,d);h=await te(t,w.expression)}catch{let g=t.state.env[d];h=g?Number.parseInt(g,10):0}Number.isNaN(h)&&(h=0)}t.state.env[`${p}_${h}`]=u;let m=Number.parseInt(t.state.env[`${p}__length`]||"0",10);h>=m&&(t.state.env[`${p}__length`]=String(h+1))}else t.state.env[n]=u;return u}return o}case"ErrorIfUnset":{if(a||s.checkEmpty&&l){let u=s.word?await Rt(t,s.word.parts,r):`${n}: parameter null or not set`;throw new ie(1,"",`bash: ${u}
656
+ `)}return o}case"UseAlternative":return!(a||s.checkEmpty&&l)&&s.word?Rt(t,s.word.parts,r):"";case"PatternRemoval":{let c="";if(s.pattern)for(let f of s.pattern.parts)if(f.type==="Glob")c+=Me(f.pattern,s.greedy);else if(f.type==="Literal")c+=Me(f.value,s.greedy);else if(f.type==="SingleQuoted"||f.type==="Escaped")c+=_e(f.value);else if(f.type==="DoubleQuoted"){let p=await Rt(t,f.parts);c+=_e(p)}else if(f.type==="ParameterExpansion"){let p=await He(t,f);c+=Me(p,s.greedy)}else{let p=await He(t,f);c+=_e(p)}if(s.side==="prefix")return o.replace(new RegExp(`^${c}`),"");let u=new RegExp(`${c}$`);if(s.greedy)return o.replace(u,"");for(let f=o.length;f>=0;f--){let p=o.slice(f);if(u.test(p))return o.slice(0,f)}return o}case"PatternReplacement":{let c="";if(s.pattern)for(let p of s.pattern.parts)if(p.type==="Glob")c+=Me(p.pattern,!0);else if(p.type==="Literal")c+=Me(p.value,!0);else if(p.type==="SingleQuoted"||p.type==="Escaped")c+=_e(p.value);else if(p.type==="DoubleQuoted"){let d=await Rt(t,p.parts);c+=_e(d)}else if(p.type==="ParameterExpansion"){let d=await He(t,p);c+=Me(d,!0)}else{let d=await He(t,p);c+=_e(d)}let u=s.replacement?await Rt(t,s.replacement.parts):"";if(c==="")return o;s.anchor==="start"?c=`^${c}`:s.anchor==="end"&&(c=`${c}$`);let f=s.all?"g":"";try{let p=new RegExp(c,f);if(s.all){let d="",h=0,m=p.exec(o);for(;m!==null&&!(m[0].length===0&&m.index===o.length);)d+=o.slice(h,m.index)+u,h=m.index+m[0].length,m[0].length===0&&h++,m=p.exec(o);return d+=o.slice(h),d}return o.replace(p,u)}catch{return o}}default:return Cf(t,e,r)}}function si(t,e,r){switch(r){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return e!==0?Math.trunc(t/e):0;case"%":return e!==0?t%e:0;case"**":if(e<0)throw new xe("exponent less than 0");return t**e;case"<<":return t<<e;case">>":return t>>e;case"<":return t<e?1:0;case"<=":return t<=e?1:0;case">":return t>e?1:0;case">=":return t>=e?1:0;case"==":return t===e?1:0;case"!=":return t!==e?1:0;case"&":return t&e;case"|":return t|e;case"^":return t^e;case",":return e;default:return 0}}function Af(t,e,r){switch(r){case"=":return e;case"+=":return t+e;case"-=":return t-e;case"*=":return t*e;case"/=":return e!==0?Math.trunc(t/e):0;case"%=":return e!==0?t%e:0;case"<<=":return t<<e;case">>=":return t>>e;case"&=":return t&e;case"|=":return t|e;case"^=":return t^e;default:return e}}function ii(t,e){switch(e){case"-":return-t;case"+":return+t;case"!":return t===0?1:0;case"~":return~t;default:return t}}function By(t,e){let r=t.state.env[e];if(r!==void 0)return r;let n=t.state.env[`${e}_0`];return n!==void 0?n:ze(t,e)}function Yt(t){if(!t)return 0;let e=Number.parseInt(t,10);if(!Number.isNaN(e)&&/^-?\d+$/.test(t.trim()))return e;let r=t.trim();if(!r)return 0;try{let n=new Se,{expr:s,pos:i}=et(n,r,0);if(i<r.length){let o=r.slice(i).trim().split(/\s+/)[0];throw new xe(`${r}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:e||0}catch(n){if(n instanceof xe)throw n;let s=r.split(/\s+/).slice(1)[0]||r;throw new xe(`${r}: syntax error in expression (error token is "${s}")`)}}function wn(t,e,r=new Set){if(r.has(e))return 0;r.add(e);let n=By(t,e);if(!n)return 0;let s=Number.parseInt(n,10);if(!Number.isNaN(s)&&/^-?\d+$/.test(n.trim()))return s;let i=n.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return wn(t,i,r);try{let o=new Se,{expr:a}=et(o,i,0);return Ge(t,a,r)}catch{return 0}}function Ge(t,e,r){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new xe("value too great for base");return e.value;case"ArithVariable":return wn(t,e.name,r);case"ArithBinary":{if(e.operator==="||")return Ge(t,e.left,r)||Ge(t,e.right,r)?1:0;if(e.operator==="&&")return Ge(t,e.left,r)&&Ge(t,e.right,r)?1:0;let n=Ge(t,e.left,r),s=Ge(t,e.right,r);return si(n,s,e.operator)}case"ArithUnary":{let n=Ge(t,e.operand,r);return ii(n,e.operator)}case"ArithTernary":return Ge(t,e.condition,r)?Ge(t,e.consequent,r):Ge(t,e.alternate,r);case"ArithGroup":return Ge(t,e.expression,r);default:return ee(t,e)}}function ct(t,e){if(e.startsWith("#")){let f=e.slice(1),p=t.state.env[f]||"";return String(p.length)}if(e.startsWith("!")){let f=e.slice(1),p=t.state.env[f]||"";return t.state.env[p]||""}let r=[":-",":=",":?",":+","-","=","?","+"],n=-1,s="";for(let f of r){let p=e.indexOf(f);p>0&&(n===-1||p<n)&&(n=p,s=f)}if(n===-1)return ze(t,e);let i=e.slice(0,n),o=e.slice(n+s.length),a=t.state.env[i],l=a===void 0,c=a==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?o:a||"";case":=":case"=":return l||u&&c?(t.state.env[i]=o,o):a||"";case":+":case"+":return!(l||u&&c)?o:"";case":?":case"?":{if(l||u&&c)throw new Error(o||`${i}: parameter null or not set`);return a||""}default:return a||""}}function ee(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new xe("value too great for base");return e.value;case"ArithVariable":return wn(t,e.name);case"ArithNested":return ee(t,e.expression);case"ArithCommandSubst":return 0;case"ArithBracedExpansion":{let r=ct(t,e.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=ct(t,e.baseExpr),n=Number.parseInt(r,10);if(n<2||n>64)return 0;let s=`${n}#${e.value}`;return Zt(s)}case"ArithDynamicNumber":{let n=ct(t,e.prefix)+e.suffix;return Zt(n)}case"ArithArrayElement":{let r=t.state.associativeArrays?.has(e.array),n;if(e.stringKey!==void 0)n=`${e.array}_${e.stringKey}`;else if(r&&e.index?.type==="ArithVariable")n=`${e.array}_${e.index.name}`;else if(e.index){let i=ee(t,e.index);if(i<0){let a=Ee(t,e.array);if(a.length===0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${e.array}: bad array subscript
657
657
  `,0;let c=Math.max(...a.map(([u])=>typeof u=="number"?u:0))+1+i;if(c<0)return t.state.expansionStderr=(t.state.expansionStderr||"")+`bash: ${e.array}: bad array subscript
658
- `,0;i=c}n=`${e.array}_${i}`;let o=t.state.env[n];if(o!==void 0)return zt(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return zt(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Pe(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[n];return s!==void 0?zt(s):0}case"ArithDoubleSubscript":throw new le("double subscript","","");case"ArithNumberSubscript":throw new le(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return K(t,e.left)||K(t,e.right)?1:0;if(e.operator==="&&")return K(t,e.left)&&K(t,e.right)?1:0;let r=K(t,e.left),n=K(t,e.right);return Qs(r,n,e.operator)}case"ArithUnary":{let r=K(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let n=e.operand.name,s=Number.parseInt(Fe(t,n),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[n]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let n=e.operand.array,s=t.state.associativeArrays?.has(n),i;if(e.operand.stringKey!==void 0)i=`${n}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${n}_${e.operand.index.name}`;else if(e.operand.index){let l=K(t,e.operand.index);i=`${n}_${l}`}else return r;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return r}return Xs(r,e.operator)}case"ArithTernary":return K(t,e.condition)?K(t,e.consequent):K(t,e.alternate);case"ArithAssignment":{let r=e.variable,n=r;if(e.stringKey!==void 0)n=`${r}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(r);if(a&&e.subscript.type==="ArithVariable")n=`${r}_${e.subscript.name}`;else if(a){let l=K(t,e.subscript);n=`${r}_${l}`}else{let l=K(t,e.subscript);if(l<0){let c=fe(t,r);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}n=`${r}_${l}`}}let s=Number.parseInt(t.state.env[n]||"0",10)||0,i=K(t,e.value),o=gf(s,i,e.operator);return t.state.env[n]=String(o),o}case"ArithGroup":return K(t,e.expression);case"ArithConcat":{let r="";for(let n of e.parts)r+=yf(t,n);return Number.parseInt(r,10)||0}default:return 0}}function yf(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return Fe(t,e.name);case"ArithBracedExpansion":return nt(t,e.content);case"ArithCommandSubst":return"0";case"ArithConcat":{let r="";for(let n of e.parts)r+=yf(t,n);return r}default:return String(K(t,e))}}async function Z(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new le("value too great for base");return e.value;case"ArithVariable":return cn(t,e.name);case"ArithNested":return Z(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let n=(await t.execFn(e.command)).stdout.trim();return Number.parseInt(n,10)||0}return 0}case"ArithBracedExpansion":{let r=nt(t,e.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=nt(t,e.baseExpr),n=Number.parseInt(r,10);if(n<2||n>64)return 0;let s=`${n}#${e.value}`;return Bt(s)}case"ArithDynamicNumber":{let n=nt(t,e.prefix)+e.suffix;return Bt(n)}case"ArithArrayElement":{let r=t.state.associativeArrays?.has(e.array),n;if(e.stringKey!==void 0)n=`${e.array}_${e.stringKey}`;else if(r&&e.index?.type==="ArithVariable")n=`${e.array}_${e.index.name}`;else if(e.index){let i=await Z(t,e.index);n=`${e.array}_${i}`;let o=t.state.env[n];if(o!==void 0)return zt(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return zt(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Pe(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[n];return s!==void 0?zt(s):0}case"ArithDoubleSubscript":throw new le("double subscript","","");case"ArithNumberSubscript":throw new le(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return await Z(t,e.left)||await Z(t,e.right)?1:0;if(e.operator==="&&")return await Z(t,e.left)&&await Z(t,e.right)?1:0;let r=await Z(t,e.left),n=await Z(t,e.right);return Qs(r,n,e.operator)}case"ArithUnary":{let r=await Z(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let n=e.operand.name,s=Number.parseInt(Fe(t,n),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[n]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let n=e.operand.array,s=t.state.associativeArrays?.has(n),i;if(e.operand.stringKey!==void 0)i=`${n}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${n}_${e.operand.index.name}`;else if(e.operand.index){let l=await Z(t,e.operand.index);i=`${n}_${l}`}else return r;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return r}return Xs(r,e.operator)}case"ArithTernary":return await Z(t,e.condition)?await Z(t,e.consequent):await Z(t,e.alternate);case"ArithAssignment":{let r=e.variable,n=r;if(e.stringKey!==void 0)n=`${r}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(r);if(a&&e.subscript.type==="ArithVariable")n=`${r}_${e.subscript.name}`;else if(a){let l=await Z(t,e.subscript);n=`${r}_${l}`}else{let l=await Z(t,e.subscript);if(l<0){let c=fe(t,r);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}n=`${r}_${l}`}}let s=Number.parseInt(t.state.env[n]||"0",10)||0,i=await Z(t,e.value),o=gf(s,i,e.operator);return t.state.env[n]=String(o),o}case"ArithGroup":return await Z(t,e.expression);case"ArithConcat":{let r="";for(let n of e.parts)r+=await xf(t,n);return Number.parseInt(r,10)||0}default:return 0}}async function xf(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return Fe(t,e.name);case"ArithBracedExpansion":return nt(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command)).stdout.trim():"0";case"ArithConcat":{let r="";for(let n of e.parts)r+=await xf(t,n);return r}default:return String(await Z(t,e))}}X();X();var V=Object.freeze({stdout:"",stderr:"",exitCode:0});function ve(t=""){return{stdout:t,stderr:"",exitCode:0}}function B(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function T(t,e,r){return{stdout:t,stderr:e,exitCode:r}}function ce(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function Je(t,e,r="",n=""){throw new W(t,e,r,n)}function Js(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new ze;return V}let r=1;if(e.length>0){let n=Number.parseInt(e[0],10);if(Number.isNaN(n)||n<1)throw new Q(128,"",`bash: break: ${e[0]}: numeric argument required
659
- `);r=n}throw new he(r)}async function Ys(t,e){let r,n=!1,s=!1,i=0;for(;i<e.length;)if(e[i]==="--"){i++;break}else if(e[i]==="-L")s=!1,i++;else if(e[i]==="-P")s=!0,i++;else if(e[i].startsWith("-")&&e[i]!=="-")i++;else break;let o=e.slice(i);if(o.length===0||o[0]==="~"?r=t.state.env.HOME||"/":o[0]==="-"?(r=t.state.previousDir,n=!0):r=o[0],!r.startsWith("/")&&!r.startsWith("./")&&!r.startsWith("../")&&r!=="."&&r!==".."){let f=t.state.env.CDPATH;if(f){let d=f.split(":").filter(p=>p);for(let p of d){let h=p.startsWith("/")?`${p}/${r}`:`${t.state.cwd}/${p}/${r}`;try{if((await t.fs.stat(h)).isDirectory){r=h,n=!0;break}}catch{}}}}let l=(r.startsWith("/")?r:`${t.state.cwd}/${r}`).split("/").filter(f=>f&&f!=="."),c="";for(let f of l)if(f==="..")c=c.split("/").slice(0,-1).join("/")||"/";else{c=c?`${c}/${f}`:`/${f}`;try{if(!(await t.fs.stat(c)).isDirectory)return B(`bash: cd: ${r}: Not a directory
660
- `)}catch{return B(`bash: cd: ${r}: No such file or directory
661
- `)}}let u=c||"/";return t.state.previousDir=t.state.cwd,t.state.cwd=u,t.state.env.PWD=t.state.cwd,t.state.env.OLDPWD=t.state.previousDir,ve(n?`${u}
662
- `:"")}X();function ei(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new ze;return V}if(e.length>1)throw new he(1);let r=1;if(e.length>0){let n=Number.parseInt(e[0],10);if(Number.isNaN(n)||n<1)return B(`bash: continue: ${e[0]}: numeric argument required
663
- `);r=n}throw new we(r)}function Et(t,e){t.state.readonlyVars=t.state.readonlyVars||new Set,t.state.readonlyVars.add(e)}function Oy(t,e){return t.state.readonlyVars?.has(e)??!1}function st(t,e,r="bash"){return Oy(t,e)?B(`${r}: ${e}: readonly variable
664
- `):null}function wf(t){let e=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(e)return{name:e[1],isArray:!0,arrayElements:ti(e[2])};if(t.includes("=")){let r=t.indexOf("=");return{name:t.slice(0,r),isArray:!1,value:t.slice(r+1)}}return{name:t,isArray:!1}}function bf(t,e,r={}){let{name:n,isArray:s,arrayElements:i,value:o}=e,{makeReadonly:a=!1,checkReadonly:l=!0}=r;if(l){let c=st(t,n);if(c)return c}if(s&&i){for(let c=0;c<i.length;c++)t.state.env[`${n}_${c}`]=i[c];t.state.env[`${n}__length`]=String(i.length)}else o!==void 0&&(t.state.env[n]=o);return a&&Et(t,n),null}function ri(t,e){let r=!1,n=!1,s=!1,i=!1,o=!1,a=[];for(let l=0;l<e.length;l++){let c=e[l];if(c==="-a")r=!0;else if(c==="-A")n=!0;else if(c==="-r")s=!0;else if(c==="-x")i=!0;else if(c==="-p")o=!0;else if(c==="--"){a.push(...e.slice(l+1));break}else if(c.startsWith("-"))for(let u of c.slice(1))u==="a"?r=!0:u==="A"?n=!0:u==="r"?s=!0:u==="x"?i=!0:u==="p"&&(o=!0);else a.push(c)}if(o&&a.length>0){let l="";for(let c of a){let u=t.state.env[c];if(u!==void 0){let f=u.replace(/\\/g,"\\\\").replace(/"/g,'\\"');l+=`declare -- ${c}="${f}"
665
- `}}return ve(l)}if(a.length===0&&!o){let l="",c=Object.entries(t.state.env).filter(([u])=>!u.startsWith("BASH_")).sort(([u],[f])=>u.localeCompare(f));for(let[u,f]of c){let d=f.replace(/'/g,"'\\''");l+=`declare -- ${u}='${d}'
666
- `}return ve(l)}for(let l of a){let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(c){let u=c[1],f=c[2];if(n&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u)),n&&f.includes("[")){let d=Fy(f);for(let[p,h]of d)t.state.env[`${u}_${p}`]=h}else{let d=ti(f);for(let p=0;p<d.length;p++)t.state.env[`${u}_${p}`]=d[p];t.state.env[`${u}__length`]=String(d.length)}s&&Et(t,u);continue}if(l.includes("=")){let u=l.indexOf("="),f=l.slice(0,u),d=l.slice(u+1),p=st(t,f);if(p)return p;t.state.env[f]=d,s&&Et(t,f)}else{let u=l;n&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u));let f=Object.keys(t.state.env).some(d=>d.startsWith(`${u}_`)&&!d.startsWith(`${u}__length`));!(u in t.state.env)&&!f&&(r||n?t.state.env[`${u}__length`]="0":t.state.env[u]=""),s&&Et(t,u)}}return V}function ti(t){let e=[],r="",n=!1,s=!1,i=!1;for(let o of t){if(i){r+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(o==="'"&&!s){n=!n;continue}if(o==='"'&&!n){s=!s;continue}if((o===" "||o===" "||o===`
667
- `)&&!n&&!s){r&&(e.push(r),r="");continue}r+=o}return r&&e.push(r),e}function Fy(t){let e=[],r=0;for(;r<t.length;){for(;r<t.length&&/\s/.test(t[r]);)r++;if(r>=t.length)break;if(t[r]!=="["){r++;continue}r++;let n="";if(t[r]==="'"||t[r]==='"'){let i=t[r];for(r++;r<t.length&&t[r]!==i;)n+=t[r],r++;t[r]===i&&r++}else for(;r<t.length&&t[r]!=="]"&&t[r]!=="=";)n+=t[r],r++;for(;r<t.length&&t[r]!=="]";)r++;if(t[r]==="]"&&r++,t[r]!=="=")continue;r++;let s="";if(t[r]==="'"||t[r]==='"'){let i=t[r];for(r++;r<t.length&&t[r]!==i;)t[r]==="\\"&&r+1<t.length&&r++,s+=t[r],r++;t[r]===i&&r++}else for(;r<t.length&&!/\s/.test(t[r]);)s+=t[r],r++;e.push([n,s])}return e}function ni(t,e){let r=!1,n=!1,s=[];for(let i=0;i<e.length;i++){let o=e[i];if(o==="-a")r=!0;else if(o==="-A")n=!0;else if(o==="-p"){if(e.length===1){let a="";for(let l of t.state.readonlyVars||[]){let c=t.state.env[l];c!==void 0&&(a+=`declare -r ${l}="${c}"
668
- `)}return ve(a)}}else if(o==="--"){s.push(...e.slice(i+1));break}else o.startsWith("-")||s.push(o)}for(let i of s){let o=wf(i);if(o.value===void 0&&!o.isArray){Et(t,o.name);continue}let a=bf(t,o,{makeReadonly:!0});if(a)return a}return V}X();async function si(t,e){let r=e;if(r.length>0){let s=r[0];if(s==="--")r=r.slice(1);else if(s.startsWith("-")&&s!=="-"&&s.length>1)return B(`bash: eval: ${s}: invalid option
658
+ `,0;i=c}n=`${e.array}_${i}`;let o=t.state.env[n];if(o!==void 0)return Yt(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return Yt(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Ue(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[n];return s!==void 0?Yt(s):0}case"ArithDoubleSubscript":throw new xe("double subscript","","");case"ArithNumberSubscript":throw new xe(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return ee(t,e.left)||ee(t,e.right)?1:0;if(e.operator==="&&")return ee(t,e.left)&&ee(t,e.right)?1:0;let r=ee(t,e.left),n=ee(t,e.right);return si(r,n,e.operator)}case"ArithUnary":{let r=ee(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let n=e.operand.name,s=Number.parseInt(ze(t,n),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[n]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let n=e.operand.array,s=t.state.associativeArrays?.has(n),i;if(e.operand.stringKey!==void 0)i=`${n}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${n}_${e.operand.index.name}`;else if(e.operand.index){let l=ee(t,e.operand.index);i=`${n}_${l}`}else return r;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return r}return ii(r,e.operator)}case"ArithTernary":return ee(t,e.condition)?ee(t,e.consequent):ee(t,e.alternate);case"ArithAssignment":{let r=e.variable,n=r;if(e.stringKey!==void 0)n=`${r}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(r);if(a&&e.subscript.type==="ArithVariable")n=`${r}_${e.subscript.name}`;else if(a){let l=ee(t,e.subscript);n=`${r}_${l}`}else{let l=ee(t,e.subscript);if(l<0){let c=Ee(t,r);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}n=`${r}_${l}`}}let s=Number.parseInt(t.state.env[n]||"0",10)||0,i=ee(t,e.value),o=Af(s,i,e.operator);return t.state.env[n]=String(o),o}case"ArithGroup":return ee(t,e.expression);case"ArithConcat":{let r="";for(let n of e.parts)r+=kf(t,n);return Number.parseInt(r,10)||0}default:return 0}}function kf(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return ze(t,e.name);case"ArithBracedExpansion":return ct(t,e.content);case"ArithCommandSubst":return"0";case"ArithConcat":{let r="";for(let n of e.parts)r+=kf(t,n);return r}default:return String(ee(t,e))}}async function te(t,e){switch(e.type){case"ArithNumber":if(Number.isNaN(e.value))throw new xe("value too great for base");return e.value;case"ArithVariable":return wn(t,e.name);case"ArithNested":return te(t,e.expression);case"ArithCommandSubst":{if(t.execFn){let n=(await t.execFn(e.command)).stdout.trim();return Number.parseInt(n,10)||0}return 0}case"ArithBracedExpansion":{let r=ct(t,e.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=ct(t,e.baseExpr),n=Number.parseInt(r,10);if(n<2||n>64)return 0;let s=`${n}#${e.value}`;return Zt(s)}case"ArithDynamicNumber":{let n=ct(t,e.prefix)+e.suffix;return Zt(n)}case"ArithArrayElement":{let r=t.state.associativeArrays?.has(e.array),n;if(e.stringKey!==void 0)n=`${e.array}_${e.stringKey}`;else if(r&&e.index?.type==="ArithVariable")n=`${e.array}_${e.index.name}`;else if(e.index){let i=await te(t,e.index);n=`${e.array}_${i}`;let o=t.state.env[n];if(o!==void 0)return Yt(o);if(i===0){let a=t.state.env[e.array];if(a!==void 0)return Yt(a)}if(t.state.options.nounset&&!Object.keys(t.state.env).some(l=>l===e.array||l.startsWith(`${e.array}_`)))throw new Ue(`${e.array}[${i}]`);return 0}else return 0;let s=t.state.env[n];return s!==void 0?Yt(s):0}case"ArithDoubleSubscript":throw new xe("double subscript","","");case"ArithNumberSubscript":throw new xe(`${e.number}${e.errorToken}: syntax error: invalid arithmetic operator (error token is "${e.errorToken}")`);case"ArithBinary":{if(e.operator==="||")return await te(t,e.left)||await te(t,e.right)?1:0;if(e.operator==="&&")return await te(t,e.left)&&await te(t,e.right)?1:0;let r=await te(t,e.left),n=await te(t,e.right);return si(r,n,e.operator)}case"ArithUnary":{let r=await te(t,e.operand);if(e.operator==="++"||e.operator==="--"){if(e.operand.type==="ArithVariable"){let n=e.operand.name,s=Number.parseInt(ze(t,n),10)||0,i=e.operator==="++"?s+1:s-1;return t.state.env[n]=String(i),e.prefix?i:s}if(e.operand.type==="ArithArrayElement"){let n=e.operand.array,s=t.state.associativeArrays?.has(n),i;if(e.operand.stringKey!==void 0)i=`${n}_${e.operand.stringKey}`;else if(s&&e.operand.index?.type==="ArithVariable")i=`${n}_${e.operand.index.name}`;else if(e.operand.index){let l=await te(t,e.operand.index);i=`${n}_${l}`}else return r;let o=Number.parseInt(t.state.env[i]||"0",10)||0,a=e.operator==="++"?o+1:o-1;return t.state.env[i]=String(a),e.prefix?a:o}return r}return ii(r,e.operator)}case"ArithTernary":return await te(t,e.condition)?await te(t,e.consequent):await te(t,e.alternate);case"ArithAssignment":{let r=e.variable,n=r;if(e.stringKey!==void 0)n=`${r}_${e.stringKey}`;else if(e.subscript){let a=t.state.associativeArrays?.has(r);if(a&&e.subscript.type==="ArithVariable")n=`${r}_${e.subscript.name}`;else if(a){let l=await te(t,e.subscript);n=`${r}_${l}`}else{let l=await te(t,e.subscript);if(l<0){let c=Ee(t,r);c.length>0&&(l=Math.max(...c.map(([f])=>typeof f=="number"?f:0))+1+l)}n=`${r}_${l}`}}let s=Number.parseInt(t.state.env[n]||"0",10)||0,i=await te(t,e.value),o=Af(s,i,e.operator);return t.state.env[n]=String(o),o}case"ArithGroup":return await te(t,e.expression);case"ArithConcat":{let r="";for(let n of e.parts)r+=await Nf(t,n);return Number.parseInt(r,10)||0}default:return 0}}async function Nf(t,e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return ze(t,e.name);case"ArithBracedExpansion":return ct(t,e.content);case"ArithCommandSubst":return t.execFn?(await t.execFn(e.command)).stdout.trim():"0";case"ArithConcat":{let r="";for(let n of e.parts)r+=await Nf(t,n);return r}default:return String(await te(t,e))}}oe();oe();var Q=Object.freeze({stdout:"",stderr:"",exitCode:0});function Be(t=""){return{stdout:t,stderr:"",exitCode:0}}function U(t,e=1){return{stdout:"",stderr:t,exitCode:e}}function _(t,e,r){return{stdout:t,stderr:e,exitCode:r}}function we(t){return{stdout:"",stderr:"",exitCode:t?0:1}}function st(t,e,r="",n=""){throw new j(t,e,r,n)}function oi(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new Ze;return Q}let r=1;if(e.length>0){let n=Number.parseInt(e[0],10);if(Number.isNaN(n)||n<1)throw new ie(128,"",`bash: break: ${e[0]}: numeric argument required
659
+ `);r=n}throw new Ae(r)}async function ai(t,e){let r,n=!1,s=!1,i=0;for(;i<e.length;)if(e[i]==="--"){i++;break}else if(e[i]==="-L")s=!1,i++;else if(e[i]==="-P")s=!0,i++;else if(e[i].startsWith("-")&&e[i]!=="-")i++;else break;let o=e.slice(i);if(o.length===0||o[0]==="~"?r=t.state.env.HOME||"/":o[0]==="-"?(r=t.state.previousDir,n=!0):r=o[0],!r.startsWith("/")&&!r.startsWith("./")&&!r.startsWith("../")&&r!=="."&&r!==".."){let f=t.state.env.CDPATH;if(f){let p=f.split(":").filter(d=>d);for(let d of p){let h=d.startsWith("/")?`${d}/${r}`:`${t.state.cwd}/${d}/${r}`;try{if((await t.fs.stat(h)).isDirectory){r=h,n=!0;break}}catch{}}}}let l=(r.startsWith("/")?r:`${t.state.cwd}/${r}`).split("/").filter(f=>f&&f!=="."),c="";for(let f of l)if(f==="..")c=c.split("/").slice(0,-1).join("/")||"/";else{c=c?`${c}/${f}`:`/${f}`;try{if(!(await t.fs.stat(c)).isDirectory)return U(`bash: cd: ${r}: Not a directory
660
+ `)}catch{return U(`bash: cd: ${r}: No such file or directory
661
+ `)}}let u=c||"/";return t.state.previousDir=t.state.cwd,t.state.cwd=u,t.state.env.PWD=t.state.cwd,t.state.env.OLDPWD=t.state.previousDir,Be(n?`${u}
662
+ `:"")}oe();function li(t,e){if(t.state.loopDepth===0){if(t.state.parentHasLoopContext)throw new Ze;return Q}if(e.length>1)throw new Ae(1);let r=1;if(e.length>0){let n=Number.parseInt(e[0],10);if(Number.isNaN(n)||n<1)return U(`bash: continue: ${e[0]}: numeric argument required
663
+ `);r=n}throw new Re(r)}function Pt(t,e){t.state.readonlyVars=t.state.readonlyVars||new Set,t.state.readonlyVars.add(e)}function Wy(t,e){return t.state.readonlyVars?.has(e)??!1}function ut(t,e,r="bash"){return Wy(t,e)?U(`${r}: ${e}: readonly variable
664
+ `):null}function If(t){let e=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(e)return{name:e[1],isArray:!0,arrayElements:ci(e[2])};if(t.includes("=")){let r=t.indexOf("=");return{name:t.slice(0,r),isArray:!1,value:t.slice(r+1)}}return{name:t,isArray:!1}}function vf(t,e,r={}){let{name:n,isArray:s,arrayElements:i,value:o}=e,{makeReadonly:a=!1,checkReadonly:l=!0}=r;if(l){let c=ut(t,n);if(c)return c}if(s&&i){for(let c=0;c<i.length;c++)t.state.env[`${n}_${c}`]=i[c];t.state.env[`${n}__length`]=String(i.length)}else o!==void 0&&(t.state.env[n]=o);return a&&Pt(t,n),null}function ui(t,e){let r=!1,n=!1,s=!1,i=!1,o=!1,a=[];for(let l=0;l<e.length;l++){let c=e[l];if(c==="-a")r=!0;else if(c==="-A")n=!0;else if(c==="-r")s=!0;else if(c==="-x")i=!0;else if(c==="-p")o=!0;else if(c==="--"){a.push(...e.slice(l+1));break}else if(c.startsWith("-"))for(let u of c.slice(1))u==="a"?r=!0:u==="A"?n=!0:u==="r"?s=!0:u==="x"?i=!0:u==="p"&&(o=!0);else a.push(c)}if(o&&a.length>0){let l="";for(let c of a){let u=t.state.env[c];if(u!==void 0){let f=u.replace(/\\/g,"\\\\").replace(/"/g,'\\"');l+=`declare -- ${c}="${f}"
665
+ `}}return Be(l)}if(a.length===0&&!o){let l="",c=Object.entries(t.state.env).filter(([u])=>!u.startsWith("BASH_")).sort(([u],[f])=>u.localeCompare(f));for(let[u,f]of c){let p=f.replace(/'/g,"'\\''");l+=`declare -- ${u}='${p}'
666
+ `}return Be(l)}for(let l of a){let c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(c){let u=c[1],f=c[2];if(n&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u)),n&&f.includes("[")){let p=Uy(f);for(let[d,h]of p)t.state.env[`${u}_${d}`]=h}else{let p=ci(f);for(let d=0;d<p.length;d++)t.state.env[`${u}_${d}`]=p[d];t.state.env[`${u}__length`]=String(p.length)}s&&Pt(t,u);continue}if(l.includes("=")){let u=l.indexOf("="),f=l.slice(0,u),p=l.slice(u+1),d=ut(t,f);if(d)return d;t.state.env[f]=p,s&&Pt(t,f)}else{let u=l;n&&(t.state.associativeArrays??=new Set,t.state.associativeArrays.add(u));let f=Object.keys(t.state.env).some(p=>p.startsWith(`${u}_`)&&!p.startsWith(`${u}__length`));!(u in t.state.env)&&!f&&(r||n?t.state.env[`${u}__length`]="0":t.state.env[u]=""),s&&Pt(t,u)}}return Q}function ci(t){let e=[],r="",n=!1,s=!1,i=!1;for(let o of t){if(i){r+=o,i=!1;continue}if(o==="\\"){i=!0;continue}if(o==="'"&&!s){n=!n;continue}if(o==='"'&&!n){s=!s;continue}if((o===" "||o===" "||o===`
667
+ `)&&!n&&!s){r&&(e.push(r),r="");continue}r+=o}return r&&e.push(r),e}function Uy(t){let e=[],r=0;for(;r<t.length;){for(;r<t.length&&/\s/.test(t[r]);)r++;if(r>=t.length)break;if(t[r]!=="["){r++;continue}r++;let n="";if(t[r]==="'"||t[r]==='"'){let i=t[r];for(r++;r<t.length&&t[r]!==i;)n+=t[r],r++;t[r]===i&&r++}else for(;r<t.length&&t[r]!=="]"&&t[r]!=="=";)n+=t[r],r++;for(;r<t.length&&t[r]!=="]";)r++;if(t[r]==="]"&&r++,t[r]!=="=")continue;r++;let s="";if(t[r]==="'"||t[r]==='"'){let i=t[r];for(r++;r<t.length&&t[r]!==i;)t[r]==="\\"&&r+1<t.length&&r++,s+=t[r],r++;t[r]===i&&r++}else for(;r<t.length&&!/\s/.test(t[r]);)s+=t[r],r++;e.push([n,s])}return e}function fi(t,e){let r=!1,n=!1,s=[];for(let i=0;i<e.length;i++){let o=e[i];if(o==="-a")r=!0;else if(o==="-A")n=!0;else if(o==="-p"){if(e.length===1){let a="";for(let l of t.state.readonlyVars||[]){let c=t.state.env[l];c!==void 0&&(a+=`declare -r ${l}="${c}"
668
+ `)}return Be(a)}}else if(o==="--"){s.push(...e.slice(i+1));break}else o.startsWith("-")||s.push(o)}for(let i of s){let o=If(i);if(o.value===void 0&&!o.isArray){Pt(t,o.name);continue}let a=vf(t,o,{makeReadonly:!0});if(a)return a}return Q}oe();async function pi(t,e){let r=e;if(r.length>0){let s=r[0];if(s==="--")r=r.slice(1);else if(s.startsWith("-")&&s!=="-"&&s.length>1)return U(`bash: eval: ${s}: invalid option
669
669
  eval: usage: eval [arg ...]
670
- `,2)}if(r.length===0)return V;let n=r.join(" ");if(n.trim()==="")return V;try{let s=rt(n);return t.executeScript(s)}catch(s){if(s instanceof he||s instanceof we||s instanceof me||s instanceof Q)throw s;if(s.name==="ParseException")return B(`bash: eval: ${s.message}
671
- `);throw s}}X();function ii(t,e){let r,n="";if(e.length===0)r=t.state.lastExitCode;else{let s=e[0],i=Number.parseInt(s,10);s===""||Number.isNaN(i)||!/^-?\d+$/.test(s)?(n=`bash: exit: ${s}: numeric argument required
672
- `,r=2):r=(i%256+256)%256}throw new Q(r,"",n)}function oi(t,e){let r=!1,n=[];for(let o of e)o==="-n"?r=!0:o==="-p"||o==="--"||n.push(o);if(n.length===0&&!r){let o="",a=Object.entries(t.state.env).filter(([l])=>!l.startsWith("BASH_ALIAS_")).sort(([l],[c])=>l.localeCompare(c));for(let[l,c]of a){let u=c.replace(/'/g,"'\\''");o+=`declare -x ${l}='${u}'
673
- `}return ve(o)}if(r){for(let o of n){let a=o.split("=")[0];delete t.state.env[a]}return V}let s="",i=0;for(let o of n){let a,l;if(o.includes("=")){let c=o.indexOf("=");a=o.slice(0,c),l=o.slice(c+1)}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){s+=`bash: export: \`${o}': not a valid identifier
674
- `,i=1;continue}l!==void 0?t.state.env[a]=l:a in t.state.env||(t.state.env[a]="")}return T("",s,i)}function Ty(t){let e=[],r="",n=0;for(let s of t){for(let i of s)i==="("?n++:i===")"&&n--;r?r+=` ${s}`:r=s,n===0&&(e.push(r),r="")}return r&&e.push(r),e}async function ai(t,e){if(e.length===0)return B(`bash: let: expression expected
675
- `);let r=Ty(e),n=0;for(let s of r)try{let o=rt(`(( ${s} ))`).statements[0];if(o&&o.pipelines.length>0&&o.pipelines[0].commands.length>0){let a=o.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(n=await Z(t,a.expression.expression))}}catch(i){return B(`bash: let: ${s}: ${i.message}
676
- `)}return T("","",n===0?1:0)}function Ly(t,e){let r=t.state.env.HOME||"/home/user";return e.split(":").map(i=>i==="~"?r:i==="~root"?"/root":i.startsWith("~/")?r+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function li(t,e){if(t.state.localScopes.length===0)return B(`bash: local: can only be used in a function
677
- `);let r=t.state.localScopes[t.state.localScopes.length-1],n="",s=0;for(let i of e){let o,a;if(i.includes("=")){let l=i.indexOf("=");o=i.slice(0,l),a=Ly(t,i.slice(l+1))}else o=i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){n+=`bash: local: \`${i}': not a valid identifier
678
- `,s=1;continue}r.has(o)||r.set(o,t.state.env[o]),a!==void 0&&(t.state.env[o]=a)}return T("",n,s)}function ci(t,e,r){let n=`
679
- `,s=0,i=0,o=0,a=!1,l="MAPFILE",c=0;for(;c<e.length;){let y=e[c];y==="-d"&&c+1<e.length?(n=e[c+1]||`
680
- `,c+=2):y==="-n"&&c+1<e.length?(s=Number.parseInt(e[c+1],10)||0,c+=2):y==="-O"&&c+1<e.length?(i=Number.parseInt(e[c+1],10)||0,c+=2):y==="-s"&&c+1<e.length?(o=Number.parseInt(e[c+1],10)||0,c+=2):y==="-t"?(a=!0,c++):y==="-u"||y==="-C"||y==="-c"?c+=2:(y.startsWith("-")||(l=y),c++)}let u=r;!u&&t.state.groupStdin!==void 0&&(u=t.state.groupStdin);let f=[],d=u,p=0,h=0;for(;d.length>0;){let y=d.indexOf(n);if(y===-1){d.length>0&&(h<o?h++:(s===0||p<s)&&(f.push(d),p++));break}let m=d.substring(0,y);if(a||(m+=n),d=d.substring(y+n.length),h<o){h++;continue}if(s>0&&p>=s)break;f.push(m),p++}cr(t,l);for(let y=0;y<f.length;y++)t.state.env[`${l}_${i+y}`]=f[y];return f.length>0&&(t.state.env[`${l}__length`]=String(i+f.length)),t.state.groupStdin!==void 0&&!r&&(t.state.groupStdin=""),T("","",0)}function ui(t,e,r){let n=!1,s=`
681
- `,i="",o=-1,a=null,l=[],c=0,u=!1;for(;c<e.length;){let b=e[c];b==="-r"?n=!0:b==="-d"&&c+1<e.length?(s=e[c+1],c++):b==="-p"&&c+1<e.length?(i=e[c+1],c++):b==="-n"&&c+1<e.length?(o=Number.parseInt(e[c+1],10),(Number.isNaN(o)||o<0)&&(u=!0,o=0),c++):b==="-a"&&c+1<e.length?(a=e[c+1],c++):b==="-t"?c+1<e.length&&!e[c+1].startsWith("-")&&c++:b==="-s"||b.startsWith("-")||l.push(b),c++}if(u)return T("","",1);l.length===0&&a===null&&l.push("REPLY");let f=r;!f&&t.state.groupStdin!==void 0&&(f=t.state.groupStdin);let d="",p=0,h=!0;if(o>=0){for(let b=0;b<f.length&&b<o;b++){let E=f[b];if(E===s){p=b+1;break}d+=E,p=b+1}t.state.groupStdin!==void 0&&!r&&(t.state.groupStdin=f.substring(p))}else{let b=f;for(p=0;;){let E=b.indexOf(s);if(E!==-1){let S=b.substring(0,E);if(p+=E+s.length,b=b.substring(E+s.length),!n&&S.endsWith("\\")){d+=S.slice(0,-1);continue}d+=S,h=!0;break}else if(b.length>0){d+=b,p+=b.length,h=!1,b="";break}else{if(d.length===0){for(let S of l)t.state.env[S]="";return a&&cr(t,a),T("","",1)}h=!1;break}}t.state.groupStdin!==void 0&&!r&&(t.state.groupStdin=f.substring(p))}if(s===`
682
- `&&d.endsWith(`
683
- `)&&(d=d.slice(0,-1)),n||(d=d.replace(/\\(.)/g,"$1")),l.length===1&&l[0]==="REPLY")return t.state.env.REPLY=d,T("","",h?0:1);let y=on(t.state.env),{words:m,wordStarts:w}=tf(d,y);if(a){cr(t,a);for(let b=0;b<m.length;b++)t.state.env[`${a}_${b}`]=m[b];return T("","",h?0:1)}for(let b=0;b<l.length;b++){let E=l[b];if(b<l.length-1)t.state.env[E]=m[b]??"";else if(b<w.length){let S=rf(d.substring(w[b]),y);t.state.env[E]=S}else t.state.env[E]=""}return T("","",h?0:1)}X();function fi(t,e){if(t.state.callDepth===0&&t.state.sourceDepth===0)return B("bash: return: can only `return' from a function or sourced script\n");let r=t.state.lastExitCode;if(e.length>0){let n=e[0],s=Number.parseInt(n,10);if(n===""||Number.isNaN(s)||!/^-?\d+$/.test(n))return B(`bash: return: ${n}: numeric argument required
684
- `,2);r=(s%256+256)%256}throw new me(r)}function Dy(t){return/^[a-zA-Z0-9_/.:-]*$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}var un=`set: usage: set [-eux] [+eux] [-o option] [+o option]
670
+ `,2)}if(r.length===0)return Q;let n=r.join(" ");if(n.trim()==="")return Q;try{let s=lt(n);return t.executeScript(s)}catch(s){if(s instanceof Ae||s instanceof Re||s instanceof ke||s instanceof ie)throw s;if(s.name==="ParseException")return U(`bash: eval: ${s.message}
671
+ `);throw s}}oe();function di(t,e){let r,n="";if(e.length===0)r=t.state.lastExitCode;else{let s=e[0],i=Number.parseInt(s,10);s===""||Number.isNaN(i)||!/^-?\d+$/.test(s)?(n=`bash: exit: ${s}: numeric argument required
672
+ `,r=2):r=(i%256+256)%256}throw new ie(r,"",n)}function hi(t,e){let r=!1,n=[];for(let o of e)o==="-n"?r=!0:o==="-p"||o==="--"||n.push(o);if(n.length===0&&!r){let o="",a=Object.entries(t.state.env).filter(([l])=>!l.startsWith("BASH_ALIAS_")).sort(([l],[c])=>l.localeCompare(c));for(let[l,c]of a){let u=c.replace(/'/g,"'\\''");o+=`declare -x ${l}='${u}'
673
+ `}return Be(o)}if(r){for(let o of n){let a=o.split("=")[0];delete t.state.env[a]}return Q}let s="",i=0;for(let o of n){let a,l;if(o.includes("=")){let c=o.indexOf("=");a=o.slice(0,c),l=o.slice(c+1)}else a=o;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(a)){s+=`bash: export: \`${o}': not a valid identifier
674
+ `,i=1;continue}l!==void 0?t.state.env[a]=l:a in t.state.env||(t.state.env[a]="")}return _("",s,i)}function jy(t){let e=[],r="",n=0;for(let s of t){for(let i of s)i==="("?n++:i===")"&&n--;r?r+=` ${s}`:r=s,n===0&&(e.push(r),r="")}return r&&e.push(r),e}async function mi(t,e){if(e.length===0)return U(`bash: let: expression expected
675
+ `);let r=jy(e),n=0;for(let s of r)try{let o=lt(`(( ${s} ))`).statements[0];if(o&&o.pipelines.length>0&&o.pipelines[0].commands.length>0){let a=o.pipelines[0].commands[0];a.type==="ArithmeticCommand"&&(n=await te(t,a.expression.expression))}}catch(i){return U(`bash: let: ${s}: ${i.message}
676
+ `)}return _("","",n===0?1:0)}function zy(t,e){let r=t.state.env.HOME||"/home/user";return e.split(":").map(i=>i==="~"?r:i==="~root"?"/root":i.startsWith("~/")?r+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}function gi(t,e){if(t.state.localScopes.length===0)return U(`bash: local: can only be used in a function
677
+ `);let r=t.state.localScopes[t.state.localScopes.length-1],n="",s=0;for(let i of e){let o,a;if(i.includes("=")){let l=i.indexOf("=");o=i.slice(0,l),a=zy(t,i.slice(l+1))}else o=i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(o)){n+=`bash: local: \`${i}': not a valid identifier
678
+ `,s=1;continue}r.has(o)||r.set(o,t.state.env[o]),a!==void 0&&(t.state.env[o]=a)}return _("",n,s)}function yi(t,e,r){let n=`
679
+ `,s=0,i=0,o=0,a=!1,l="MAPFILE",c=0;for(;c<e.length;){let m=e[c];m==="-d"&&c+1<e.length?(n=e[c+1]||`
680
+ `,c+=2):m==="-n"&&c+1<e.length?(s=Number.parseInt(e[c+1],10)||0,c+=2):m==="-O"&&c+1<e.length?(i=Number.parseInt(e[c+1],10)||0,c+=2):m==="-s"&&c+1<e.length?(o=Number.parseInt(e[c+1],10)||0,c+=2):m==="-t"?(a=!0,c++):m==="-u"||m==="-C"||m==="-c"?c+=2:(m.startsWith("-")||(l=m),c++)}let u=r;!u&&t.state.groupStdin!==void 0&&(u=t.state.groupStdin);let f=[],p=u,d=0,h=0;for(;p.length>0;){let m=p.indexOf(n);if(m===-1){p.length>0&&(h<o?h++:(s===0||d<s)&&(f.push(p),d++));break}let g=p.substring(0,m);if(a||(g+=n),p=p.substring(m+n.length),h<o){h++;continue}if(s>0&&d>=s)break;f.push(g),d++}wr(t,l);for(let m=0;m<f.length;m++)t.state.env[`${l}_${i+m}`]=f[m];return f.length>0&&(t.state.env[`${l}__length`]=String(i+f.length)),t.state.groupStdin!==void 0&&!r&&(t.state.groupStdin=""),_("","",0)}function xi(t,e,r){let n=!1,s=`
681
+ `,i="",o=-1,a=null,l=[],c=0,u=!1;for(;c<e.length;){let b=e[c];b==="-r"?n=!0:b==="-d"&&c+1<e.length?(s=e[c+1],c++):b==="-p"&&c+1<e.length?(i=e[c+1],c++):b==="-n"&&c+1<e.length?(o=Number.parseInt(e[c+1],10),(Number.isNaN(o)||o<0)&&(u=!0,o=0),c++):b==="-a"&&c+1<e.length?(a=e[c+1],c++):b==="-t"?c+1<e.length&&!e[c+1].startsWith("-")&&c++:b==="-s"||b.startsWith("-")||l.push(b),c++}if(u)return _("","",1);l.length===0&&a===null&&l.push("REPLY");let f=r;!f&&t.state.groupStdin!==void 0&&(f=t.state.groupStdin);let p="",d=0,h=!0;if(o>=0){for(let b=0;b<f.length&&b<o;b++){let E=f[b];if(E===s){d=b+1;break}p+=E,d=b+1}t.state.groupStdin!==void 0&&!r&&(t.state.groupStdin=f.substring(d))}else{let b=f;for(d=0;;){let E=b.indexOf(s);if(E!==-1){let S=b.substring(0,E);if(d+=E+s.length,b=b.substring(E+s.length),!n&&S.endsWith("\\")){p+=S.slice(0,-1);continue}p+=S,h=!0;break}else if(b.length>0){p+=b,d+=b.length,h=!1,b="";break}else{if(p.length===0){for(let S of l)t.state.env[S]="";return a&&wr(t,a),_("","",1)}h=!1;break}}t.state.groupStdin!==void 0&&!r&&(t.state.groupStdin=f.substring(d))}if(s===`
682
+ `&&p.endsWith(`
683
+ `)&&(p=p.slice(0,-1)),n||(p=p.replace(/\\(.)/g,"$1")),l.length===1&&l[0]==="REPLY")return t.state.env.REPLY=p,_("","",h?0:1);let m=gn(t.state.env),{words:g,wordStarts:w}=uf(p,m);if(a){wr(t,a);for(let b=0;b<g.length;b++)t.state.env[`${a}_${b}`]=g[b];return _("","",h?0:1)}for(let b=0;b<l.length;b++){let E=l[b];if(b<l.length-1)t.state.env[E]=g[b]??"";else if(b<w.length){let S=ff(p.substring(w[b]),m);t.state.env[E]=S}else t.state.env[E]=""}return _("","",h?0:1)}oe();function wi(t,e){if(t.state.callDepth===0&&t.state.sourceDepth===0)return U("bash: return: can only `return' from a function or sourced script\n");let r=t.state.lastExitCode;if(e.length>0){let n=e[0],s=Number.parseInt(n,10);if(n===""||Number.isNaN(s)||!/^-?\d+$/.test(n))return U(`bash: return: ${n}: numeric argument required
684
+ `,2);r=(s%256+256)%256}throw new ke(r)}function Hy(t){return/^[a-zA-Z0-9_/.:-]*$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}var bn=`set: usage: set [-eux] [+eux] [-o option] [+o option]
685
685
  Options:
686
686
  -e Exit immediately if a command exits with non-zero status
687
687
  +e Disable -e
@@ -697,68 +697,68 @@ Options:
697
697
  +o pipefail Disable pipefail
698
698
  -o xtrace Same as -x
699
699
  +o xtrace Disable xtrace
700
- `,Ef={e:"errexit",u:"nounset",x:"xtrace",v:"verbose",f:null,h:null,C:null,n:null,a:null,b:null,m:null,B:null,H:null,P:null,T:null,E:null,p:null},Sf={errexit:"errexit",pipefail:"pipefail",nounset:"nounset",xtrace:"xtrace",verbose:"verbose",noclobber:null,noglob:null,noexec:null,allexport:null,notify:null,monitor:null,braceexpand:null,histexpand:null,physical:null,functrace:null,errtrace:null,privileged:null,hashall:null,posix:null,vi:null,emacs:null,ignoreeof:null,"interactive-comments":null,keyword:null,onecmd:null},Cf=["errexit","nounset","pipefail","verbose","xtrace"],Af=["allexport","braceexpand","emacs","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","noclobber","noexec","noglob","nolog","notify","onecmd","physical","posix","privileged","vi"];function kf(t,e,r){e!==null&&(t.state.options[e]=r)}function My(t,e){return e+1<t.length&&!t[e+1].startsWith("-")&&!t[e+1].startsWith("+")}function pi(t,e){if(e.includes("--help"))return ve(un);if(e.length===0){let n=Object.entries(t.state.env).filter(([s])=>/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)).sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>`${s}=${Dy(i)}`).join(`
701
- `);return ve(n?`${n}
702
- `:"")}let r=0;for(;r<e.length;){let n=e[r];if((n==="-o"||n==="+o")&&My(e,r)){let s=e[r+1];if(!(s in Sf))return B(`bash: set: ${s}: invalid option name
703
- ${un}`);kf(t,Sf[s],n==="-o"),r+=2;continue}if(n==="-o"){let s=Cf.map(a=>`${a.padEnd(16)}${t.state.options[a]?"on":"off"}`),i=Af.map(a=>`${a.padEnd(16)}off`),o=[...s,...i].sort();return ve(`${o.join(`
700
+ `,$f={e:"errexit",u:"nounset",x:"xtrace",v:"verbose",f:null,h:null,C:null,n:null,a:null,b:null,m:null,B:null,H:null,P:null,T:null,E:null,p:null},Rf={errexit:"errexit",pipefail:"pipefail",nounset:"nounset",xtrace:"xtrace",verbose:"verbose",noclobber:null,noglob:null,noexec:null,allexport:null,notify:null,monitor:null,braceexpand:null,histexpand:null,physical:null,functrace:null,errtrace:null,privileged:null,hashall:null,posix:null,vi:null,emacs:null,ignoreeof:null,"interactive-comments":null,keyword:null,onecmd:null},Pf=["errexit","nounset","pipefail","verbose","xtrace"],Ff=["allexport","braceexpand","emacs","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","noclobber","noexec","noglob","nolog","notify","onecmd","physical","posix","privileged","vi"];function Of(t,e,r){e!==null&&(t.state.options[e]=r)}function Gy(t,e){return e+1<t.length&&!t[e+1].startsWith("-")&&!t[e+1].startsWith("+")}function Ei(t,e){if(e.includes("--help"))return Be(bn);if(e.length===0){let n=Object.entries(t.state.env).filter(([s])=>/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)).sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>`${s}=${Hy(i)}`).join(`
701
+ `);return Be(n?`${n}
702
+ `:"")}let r=0;for(;r<e.length;){let n=e[r];if((n==="-o"||n==="+o")&&Gy(e,r)){let s=e[r+1];if(!(s in Rf))return U(`bash: set: ${s}: invalid option name
703
+ ${bn}`);Of(t,Rf[s],n==="-o"),r+=2;continue}if(n==="-o"){let s=Pf.map(a=>`${a.padEnd(16)}${t.state.options[a]?"on":"off"}`),i=Ff.map(a=>`${a.padEnd(16)}off`),o=[...s,...i].sort();return Be(`${o.join(`
704
704
  `)}
705
- `)}if(n==="+o"){let s=Cf.map(a=>`set ${t.state.options[a]?"-o":"+o"} ${a}`),i=Af.map(a=>`set +o ${a}`),o=[...s,...i].sort();return ve(`${o.join(`
705
+ `)}if(n==="+o"){let s=Pf.map(a=>`set ${t.state.options[a]?"-o":"+o"} ${a}`),i=Ff.map(a=>`set +o ${a}`),o=[...s,...i].sort();return Be(`${o.join(`
706
706
  `)}
707
- `)}if(n.length>1&&(n[0]==="-"||n[0]==="+")&&n[1]!=="-"){let s=n[0]==="-";for(let i=1;i<n.length;i++){let o=n[i];if(!(o in Ef))return B(`bash: set: ${n[0]}${o}: invalid option
708
- ${un}`);kf(t,Ef[o],s)}r++;continue}if(n==="--")return di(t,e.slice(r+1)),V;if(n==="-"){if(t.state.options.xtrace=!1,t.state.options.verbose=!1,r+1<e.length)return di(t,e.slice(r+1)),V;r++;continue}if(n==="+"){r++;continue}return n.startsWith("-")||n.startsWith("+")?B(`bash: set: ${n}: invalid option
709
- ${un}`):(di(t,e.slice(r)),V)}return V}function di(t,e){let r=1;for(;t.state.env[String(r)]!==void 0;)delete t.state.env[String(r)],r++;for(let n=0;n<e.length;n++)t.state.env[String(n+1)]=e[n];t.state.env["#"]=String(e.length),t.state.env["@"]=e.join(" "),t.state.env["*"]=e.join(" ")}function hi(t,e){let r=1;if(e.length>0){let o=Number.parseInt(e[0],10);if(Number.isNaN(o)||o<0)return B(`bash: shift: ${e[0]}: numeric argument required
710
- `);r=o}let n=Number.parseInt(t.state.env["#"]||"0",10);if(r>n)return B(`bash: shift: shift count out of range
711
- `);if(r===0)return V;let s=[];for(let o=1;o<=n;o++)s.push(t.state.env[String(o)]||"");let i=s.slice(r);for(let o=1;o<=n;o++)delete t.state.env[String(o)];for(let o=0;o<i.length;o++)t.state.env[String(o+1)]=i[o];return t.state.env["#"]=String(i.length),t.state.env["@"]=i.join(" "),V}X();async function mi(t,e){let r=e;if(r.length>0&&r[0]==="--"&&(r=r.slice(1)),r.length===0)return T("",`bash: source: filename argument required
712
- `,2);let n=r[0],s=null,i=null;if(n.includes("/")){let l=t.fs.resolvePath(t.state.cwd,n);try{i=await t.fs.readFile(l),s=l}catch{}}else{let c=(t.state.env.PATH||"").split(":").filter(u=>u);for(let u of c){let f=t.fs.resolvePath(t.state.cwd,`${u}/${n}`);try{if((await t.fs.stat(f)).isDirectory)continue;i=await t.fs.readFile(f),s=f;break}catch{}}if(i===null){let u=t.fs.resolvePath(t.state.cwd,n);try{i=await t.fs.readFile(u),s=u}catch{}}}if(i===null)return B(`bash: ${n}: No such file or directory
713
- `);let o={};if(r.length>1){for(let c=1;c<=9;c++)o[String(c)]=t.state.env[String(c)];o["#"]=t.state.env["#"],o["@"]=t.state.env["@"];let l=r.slice(1);t.state.env["#"]=String(l.length),t.state.env["@"]=l.join(" ");for(let c=0;c<l.length&&c<9;c++)t.state.env[String(c+1)]=l[c];for(let c=l.length+1;c<=9;c++)delete t.state.env[String(c)]}let a=()=>{if(t.state.sourceDepth--,r.length>1)for(let[l,c]of Object.entries(o))c===void 0?delete t.state.env[l]:t.state.env[l]=c};t.state.sourceDepth++;try{let l=rt(i),c=await t.executeScript(l);return a(),c}catch(l){if(a(),l instanceof Q)throw l;if(l instanceof me)return T(l.stdout,l.stderr,l.exitCode);if(l.name==="ParseException")return B(`bash: ${n}: ${l.message}
714
- `);throw l}}function gi(t,e){let r="variable",n="",s=0;for(let i of e){if(i==="-v"){r="variable";continue}if(i==="-f"){r="function";continue}if(r==="function"){t.state.functions.delete(i);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let a=o[1],l=o[2];if(l==="@"||l==="*"){let u=fe(t,a);for(let[f]of u)delete t.state.env[`${a}_${f}`];delete t.state.env[a];continue}let c;if(/^-?\d+$/.test(l))c=Number.parseInt(l,10);else{let u=t.state.env[l];c=u?Number.parseInt(u,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let u=fe(t,a),f=u.length;if(f===0){n+=`bash: unset: [${c}]: bad array subscript
715
- `,s=1;continue}let d=f+c;if(d<0){n+=`bash: unset: [${c}]: bad array subscript
716
- `,s=1;continue}let p=u[d][0];delete t.state.env[`${a}_${p}`];continue}delete t.state.env[`${a}_${c}`];continue}delete t.state.env[i],t.state.functions.delete(i)}return T("",n,s)}function yi(t,e){return t.fs.resolvePath(t.state.cwd,e)}var _y=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function fn(t){return _y.includes(t)}async function dn(t,e,r){let n=yi(t,r);switch(e){case"-e":case"-a":return t.fs.exists(n);case"-f":return await t.fs.exists(n)?(await t.fs.stat(n)).isFile:!1;case"-d":return await t.fs.exists(n)?(await t.fs.stat(n)).isDirectory:!1;case"-r":case"-w":case"-x":return t.fs.exists(n);case"-s":return await t.fs.exists(n)?(await t.fs.stat(n)).size>0:!1;case"-L":case"-h":try{return(await t.fs.lstat(n)).isSymbolicLink}catch{return!1}case"-k":return await t.fs.exists(n)?((await t.fs.stat(n)).mode&512)!==0:!1;case"-g":return await t.fs.exists(n)?((await t.fs.stat(n)).mode&1024)!==0:!1;case"-u":return await t.fs.exists(n)?((await t.fs.stat(n)).mode&2048)!==0:!1;case"-G":case"-O":return t.fs.exists(n);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>n===i||n.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return t.fs.exists(n);default:return!1}}var By=["-nt","-ot","-ef"];function pn(t){return By.includes(t)}async function hn(t,e,r,n){let s=yi(t,r),i=yi(t,n);switch(e){case"-nt":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await t.fs.exists(s)||!await t.fs.exists(i))return!1;let o=t.fs.resolvePath(t.state.cwd,s),a=t.fs.resolvePath(t.state.cwd,i);return o===a}catch{return!1}default:return!1}}var Wy=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function mn(t){return Wy.has(t)}function gn(t,e,r){switch(t){case"-eq":return e===r;case"-ne":return e!==r;case"-lt":return e<r;case"-le":return e<=r;case"-gt":return e>r;case"-ge":return e>=r}}function yn(t){return t==="="||t==="=="||t==="!="}function xn(t,e,r,n=!1){let s=n?wn(e,r):e===r;return t==="!="?!s:s}var Uy=new Set(["-z","-n"]);function bn(t){return Uy.has(t)}function En(t,e){switch(t){case"-z":return e==="";case"-n":return e!==""}}function Sn(t,e){let r=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let n=r[1],s=r[2];s=s.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(o,a)=>t.state.env[a]||"");let i;if(/^-?\d+$/.test(s))i=Number.parseInt(s,10);else try{let o=Function(`"use strict"; return (${s})`)();i=typeof o=="number"?Math.floor(o):0}catch{let o=t.state.env[s];i=o?Number.parseInt(o,10):0}if(i<0){let o=lr(t,n);if(o.length===0||(i=Math.max(...o)+1+i,i<0))return!1}return`${n}_${i}`in t.state.env}return e in t.state.env}async function it(t,e){switch(e.type){case"CondBinary":{let r=await Y(t,e.left),n=await Y(t,e.right),s=e.right.parts.length>0&&e.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped");if(yn(e.operator))return xn(e.operator,r,n,!s);if(mn(e.operator))return gn(e.operator,If(t,r),If(t,n));if(pn(e.operator))return hn(t,e.operator,r,n);switch(e.operator){case"=~":try{let i=new RegExp(n),o=r.match(i);if(o){t.state.env.BASH_REMATCH=o[0];for(let a=1;a<o.length;a++)t.state.env[`BASH_REMATCH_${a}`]=o[a]||""}return o!==null}catch{throw new Error("syntax error in regular expression")}case"<":return r<n;case">":return r>n;default:return!1}}case"CondUnary":{let r=await Y(t,e.operand);return fn(e.operator)?dn(t,e.operator,r):bn(e.operator)?En(e.operator,r):e.operator==="-v"?Sn(t,r):e.operator==="-o"?wi(t,r):!1}case"CondNot":return!await it(t,e.operand);case"CondAnd":return await it(t,e.left)?await it(t,e.right):!1;case"CondOr":return await it(t,e.left)?!0:await it(t,e.right);case"CondGroup":return await it(t,e.expression);case"CondWord":return await Y(t,e.word)!=="";default:return!1}}async function Ht(t,e){if(e.length===0)return T("","",1);if(e.length===1)return ce(!!e[0]);if(e.length===2){let n=e[0],s=e[1];return n==="("?B(`test: '(' without matching ')'
717
- `,2):fn(n)?ce(await dn(t,n,s)):bn(n)?ce(En(n,s)):n==="!"?ce(!s):n==="-v"?ce(Sn(t,s)):n==="-o"?ce(wi(t,s)):n==="="||n==="=="||n==="!="||n==="<"||n===">"||n==="-eq"||n==="-ne"||n==="-lt"||n==="-le"||n==="-gt"||n==="-ge"||n==="-nt"||n==="-ot"||n==="-ef"?B(`test: ${n}: unary operator expected
718
- `,2):T("","",1)}if(e.length===3){let n=e[0],s=e[1],i=e[2];if(yn(s))return ce(xn(s,n,i));if(mn(s)){let o=Cn(n),a=Cn(i);return!o.valid||!a.valid?T("","",2):ce(gn(s,o.value,a.value))}if(pn(s))return ce(await hn(t,s,n,i));switch(s){case"-a":return ce(n!==""&&i!=="");case"-o":return ce(n!==""||i!=="");case">":return ce(n>i);case"<":return ce(n<i)}if(n==="!"){let o=await Ht(t,[s,i]);return T("",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(n==="("&&i===")")return ce(s!=="")}if(e.length===4){if(e[0]==="!"){let n=await Ht(t,e.slice(1));return T("",n.stderr,n.exitCode===0?1:n.exitCode===1?0:n.exitCode)}if(e[0]==="("&&e[3]===")")return Ht(t,[e[1],e[2]])}let r=await $f(t,e,0);return r.pos<e.length?B(`test: too many arguments
719
- `,2):ce(r.value)}async function $f(t,e,r){return jy(t,e,r)}async function jy(t,e,r){let{value:n,pos:s}=await Nf(t,e,r);for(;e[s]==="-o";){let i=await Nf(t,e,s+1);n=n||i.value,s=i.pos}return{value:n,pos:s}}async function Nf(t,e,r){let{value:n,pos:s}=await xi(t,e,r);for(;e[s]==="-a";){let i=await xi(t,e,s+1);n=n&&i.value,s=i.pos}return{value:n,pos:s}}async function xi(t,e,r){if(e[r]==="!"){let{value:n,pos:s}=await xi(t,e,r+1);return{value:!n,pos:s}}return zy(t,e,r)}async function zy(t,e,r){let n=e[r];if(n==="("){let{value:i,pos:o}=await $f(t,e,r+1);return{value:i,pos:e[o]===")"?o+1:o}}if(fn(n)){let i=e[r+1]??"";return{value:await dn(t,n,i),pos:r+2}}if(bn(n)){let i=e[r+1]??"";return{value:En(n,i),pos:r+2}}if(n==="-v"){let i=e[r+1]??"";return{value:Sn(t,i),pos:r+2}}if(n==="-o"){let i=e[r+1]??"";return{value:wi(t,i),pos:r+2}}let s=e[r+1];if(yn(s)){let i=n,o=e[r+2]??"";return{value:xn(s,i,o),pos:r+3}}if(mn(s)){let i=Cn(n),o=Cn(e[r+2]??"0");return!i.valid||!o.valid?{value:!1,pos:r+3}:{value:gn(s,i.value,o.value),pos:r+3}}if(pn(s)){let i=n,o=e[r+2]??"";return{value:await hn(t,s,i,o),pos:r+3}}return{value:n!==void 0&&n!=="",pos:r+1}}function wn(t,e){let r="^";for(let n=0;n<e.length;n++){let s=e[n];if(s==="\\")if(n+1<e.length){let i=e[n+1];/[\\^$.|+(){}[\]*?]/.test(i)?r+=`\\${i}`:r+=i,n++}else r+="\\\\";else if(s==="*")r+=".*";else if(s==="?")r+=".";else if(s==="["){let i=e.indexOf("]",n+1);i!==-1?(r+=e.slice(n,i+1),n=i):r+="\\["}else/[\\^$.|+(){}]/.test(s)?r+=`\\${s}`:r+=s}return r+="$",new RegExp(r).test(t)}function wi(t,e){let n={errexit:()=>t.state.options.errexit===!0,nounset:()=>t.state.options.nounset===!0,pipefail:()=>t.state.options.pipefail===!0,xtrace:()=>t.state.options.xtrace===!0,e:()=>t.state.options.errexit===!0,u:()=>t.state.options.nounset===!0,x:()=>t.state.options.xtrace===!0}[e];return n?n():!1}function If(t,e){if(e=e.trim(),e==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(e))return vf(e);try{let r=new pe,n=ue(r,e);return K(t,n.expression)}catch{return vf(e)}}function Hy(t,e){let r=0;for(let n of t){let s;if(n>="0"&&n<="9")s=n.charCodeAt(0)-48;else if(n>="a"&&n<="z")s=n.charCodeAt(0)-97+10;else if(n>="A"&&n<="Z")s=n.charCodeAt(0)-65+36;else if(n==="@")s=62;else if(n==="_")s=63;else return Number.NaN;if(s>=e)return Number.NaN;r=r*e+s}return r}function vf(t){if(t=t.trim(),t==="")return 0;let e=!1;t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1));let r,n=t.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(n){let s=Number.parseInt(n[1],10);s>=2&&s<=64?r=Hy(n[2],s):r=0}else/^0[xX][0-9a-fA-F]+$/.test(t)?r=Number.parseInt(t,16):/^0[0-7]+$/.test(t)?r=Number.parseInt(t,8):r=Number.parseInt(t,10);return Number.isNaN(r)&&(r=0),e?-r:r}function Cn(t){if(t=t.trim(),t==="")return{value:0,valid:!0};let e=!1;if(t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1)),!/^\d+$/.test(t))return{value:0,valid:!1};let r=Number.parseInt(t,10);return Number.isNaN(r)?{value:0,valid:!1}:{value:e?-r:r,valid:!0}}X();async function bi(t,e){let r=t.state.inCondition;t.state.inCondition=!0;let n="",s="",i=0;try{for(let o of e){let a=await t.executeStatement(o);n+=a.stdout,s+=a.stderr,i=a.exitCode}}finally{t.state.inCondition=r}return{stdout:n,stderr:s,exitCode:i}}X();Be();function dr(t,e,r,n){if(t instanceof he)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"break",stdout:e,stderr:r};if(t instanceof we)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"continue",stdout:e,stderr:r};if(t instanceof me||t instanceof Ue||t instanceof Q||t instanceof W)return t.prependOutput(e,r),{action:"rethrow",stdout:e,stderr:r,error:t};let s=re(t);return{action:"error",stdout:e,stderr:`${r}${s}
720
- `,exitCode:1}}X();Be();async function An(t,e,r="",n=""){let s=r,i=n,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(kr(a)||a instanceof Ue||a instanceof Q||a instanceof W||a instanceof ze)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${re(a)}
721
- `,exitCode:1}}return{stdout:s,stderr:i,exitCode:o}}async function Rf(t,e){let r="",n="";for(let s of e.clauses){let i=await bi(t,s.condition);if(r+=i.stdout,n+=i.stderr,i.exitCode===0)return An(t,s.body,r,n)}return e.elseBody?An(t,e.elseBody,r,n):T(r,n,0)}async function Pf(t,e){let r="",n="",s=0,i=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.variable))return B(`bash: \`${e.variable}': not a valid identifier
722
- `);let o=[];if(e.words===null)o=(t.state.env["@"]||"").split(" ").filter(Boolean);else if(e.words.length===0)o=[];else for(let a of e.words){let l=await fr(t,a);o.push(...l.values)}t.state.loopDepth++;try{for(let a of o){i++,i>t.limits.maxLoopIterations&&Je(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n),t.state.env[e.variable]=a;try{for(let l of e.body){let c=await t.executeStatement(l);r+=c.stdout,n+=c.stderr,s=c.exitCode}}catch(l){let c=dr(l,r,n,t.state.loopDepth);if(r=c.stdout,n=c.stderr,c.action==="break")break;if(c.action==="continue")continue;if(c.action==="error")return T(r,n,c.exitCode??1);throw c.error}}}finally{t.state.loopDepth--}return T(r,n,s)}async function Of(t,e){let r="",n="",s=0,i=0;e.init&&await Z(t,e.init.expression),t.state.loopDepth++;try{for(;i++,i>t.limits.maxLoopIterations&&Je(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n),!(e.condition&&await Z(t,e.condition.expression)===0);){try{for(let o of e.body){let a=await t.executeStatement(o);r+=a.stdout,n+=a.stderr,s=a.exitCode}}catch(o){let a=dr(o,r,n,t.state.loopDepth);if(r=a.stdout,n=a.stderr,a.action==="break")break;if(a.action==="continue"){e.update&&await Z(t,e.update.expression);continue}if(a.action==="error")return T(r,n,a.exitCode??1);throw a.error}e.update&&await Z(t,e.update.expression)}}finally{t.state.loopDepth--}return T(r,n,s)}async function Ff(t,e,r=""){let n="",s="",i=0,o=0,a=r;for(let c of e.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await Y(t,u.content);u.stripTabs&&(f=f.split(`
723
- `).map(d=>d.replace(/^\t+/,"")).join(`
724
- `)),a=f}else if(c.operator==="<<<"&&c.target.type==="Word")a=`${await Y(t,c.target)}
725
- `;else if(c.operator==="<"&&c.target.type==="Word")try{let u=await Y(t,c.target),f=t.fs.resolvePath(t.state.cwd,u);a=await t.fs.readFile(f)}catch{let u=await Y(t,c.target);return B(`bash: ${u}: No such file or directory
726
- `)}let l=t.state.groupStdin;a&&(t.state.groupStdin=a),t.state.loopDepth++;try{for(;;){o++,o>t.limits.maxLoopIterations&&Je(`while loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,s);let c=0,u=!1,f=!1,d=t.state.inCondition;t.state.inCondition=!0;try{for(let p of e.condition){let h=await t.executeStatement(p);n+=h.stdout,s+=h.stderr,c=h.exitCode}}catch(p){if(p instanceof he){if(n+=p.stdout,s+=p.stderr,p.levels>1&&t.state.loopDepth>1)throw p.levels--,p.stdout=n,p.stderr=s,t.state.inCondition=d,p;u=!0}else if(p instanceof we){if(n+=p.stdout,s+=p.stderr,p.levels>1&&t.state.loopDepth>1)throw p.levels--,p.stdout=n,p.stderr=s,t.state.inCondition=d,p;f=!0}else throw t.state.inCondition=d,p}finally{t.state.inCondition=d}if(u)break;if(!f){if(c!==0)break;try{for(let p of e.body){let h=await t.executeStatement(p);n+=h.stdout,s+=h.stderr,i=h.exitCode}}catch(p){let h=dr(p,n,s,t.state.loopDepth);if(n=h.stdout,s=h.stderr,h.action==="break")break;if(h.action==="continue")continue;if(h.action==="error")return T(n,s,h.exitCode??1);throw h.error}}}}finally{t.state.loopDepth--,t.state.groupStdin=l}return T(n,s,i)}async function Tf(t,e){let r="",n="",s=0,i=0;t.state.loopDepth++;try{for(;;){i++,i>t.limits.maxLoopIterations&&Je(`until loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n);let o=await bi(t,e.condition);if(r+=o.stdout,n+=o.stderr,o.exitCode===0)break;try{for(let a of e.body){let l=await t.executeStatement(a);r+=l.stdout,n+=l.stderr,s=l.exitCode}}catch(a){let l=dr(a,r,n,t.state.loopDepth);if(r=l.stdout,n=l.stderr,l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return T(r,n,l.exitCode??1);throw l.error}}}finally{t.state.loopDepth--}return T(r,n,s)}async function Lf(t,e){let r="",n="",s=0,i=await Y(t,e.word),o=!1;for(let a=0;a<e.items.length;a++){let l=e.items[a],c=o;if(!o)for(let u of l.patterns){let f=await Y(t,u);if(lf(u)&&(f=cf(f)),wn(i,f)){c=!0;break}}if(c){let u=await An(t,l.body,r,n);if(r=u.stdout,n=u.stderr,s=u.exitCode,l.terminator===";;")break;l.terminator===";&"?o=!0:o=!1}else o=!1}return T(r,n,s)}X();X();function Df(t,e){return t.state.functions.set(e.name,e),V}async function Mf(t,e,r){t.state.callDepth++,t.state.callDepth>t.limits.maxCallDepth&&(t.state.callDepth--,Je(`${e.name}: maximum recursion depth (${t.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),t.state.localScopes.push(new Map);let n={};for(let i=0;i<r.length;i++)n[String(i+1)]=t.state.env[String(i+1)],t.state.env[String(i+1)]=r[i];n["@"]=t.state.env["@"],n["#"]=t.state.env["#"],t.state.env["@"]=r.join(" "),t.state.env["#"]=String(r.length);let s=()=>{let i=t.state.localScopes.pop();if(i)for(let[o,a]of i)a===void 0?delete t.state.env[o]:t.state.env[o]=a;for(let[o,a]of Object.entries(n))a===void 0?delete t.state.env[o]:t.state.env[o]=a;t.state.callDepth--};try{let i=await t.executeCommand(e.body,"");return s(),i}catch(i){if(s(),i instanceof me)return T(i.stdout,i.stderr,i.exitCode);throw i}}Be();async function _f(t,e,r){let{stdout:n,stderr:s,exitCode:i}=e;for(let o of r){if(o.target.type==="HereDoc")continue;let a=await Y(t,o.target);switch(o.operator){case">":{let l=o.fd??1;if(l===1){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
707
+ `)}if(n.length>1&&(n[0]==="-"||n[0]==="+")&&n[1]!=="-"){let s=n[0]==="-";for(let i=1;i<n.length;i++){let o=n[i];if(!(o in $f))return U(`bash: set: ${n[0]}${o}: invalid option
708
+ ${bn}`);Of(t,$f[o],s)}r++;continue}if(n==="--")return bi(t,e.slice(r+1)),Q;if(n==="-"){if(t.state.options.xtrace=!1,t.state.options.verbose=!1,r+1<e.length)return bi(t,e.slice(r+1)),Q;r++;continue}if(n==="+"){r++;continue}return n.startsWith("-")||n.startsWith("+")?U(`bash: set: ${n}: invalid option
709
+ ${bn}`):(bi(t,e.slice(r)),Q)}return Q}function bi(t,e){let r=1;for(;t.state.env[String(r)]!==void 0;)delete t.state.env[String(r)],r++;for(let n=0;n<e.length;n++)t.state.env[String(n+1)]=e[n];t.state.env["#"]=String(e.length),t.state.env["@"]=e.join(" "),t.state.env["*"]=e.join(" ")}function Si(t,e){let r=1;if(e.length>0){let o=Number.parseInt(e[0],10);if(Number.isNaN(o)||o<0)return U(`bash: shift: ${e[0]}: numeric argument required
710
+ `);r=o}let n=Number.parseInt(t.state.env["#"]||"0",10);if(r>n)return U(`bash: shift: shift count out of range
711
+ `);if(r===0)return Q;let s=[];for(let o=1;o<=n;o++)s.push(t.state.env[String(o)]||"");let i=s.slice(r);for(let o=1;o<=n;o++)delete t.state.env[String(o)];for(let o=0;o<i.length;o++)t.state.env[String(o+1)]=i[o];return t.state.env["#"]=String(i.length),t.state.env["@"]=i.join(" "),Q}oe();async function Ci(t,e){let r=e;if(r.length>0&&r[0]==="--"&&(r=r.slice(1)),r.length===0)return _("",`bash: source: filename argument required
712
+ `,2);let n=r[0],s=null,i=null;if(n.includes("/")){let l=t.fs.resolvePath(t.state.cwd,n);try{i=await t.fs.readFile(l),s=l}catch{}}else{let c=(t.state.env.PATH||"").split(":").filter(u=>u);for(let u of c){let f=t.fs.resolvePath(t.state.cwd,`${u}/${n}`);try{if((await t.fs.stat(f)).isDirectory)continue;i=await t.fs.readFile(f),s=f;break}catch{}}if(i===null){let u=t.fs.resolvePath(t.state.cwd,n);try{i=await t.fs.readFile(u),s=u}catch{}}}if(i===null)return U(`bash: ${n}: No such file or directory
713
+ `);let o={};if(r.length>1){for(let c=1;c<=9;c++)o[String(c)]=t.state.env[String(c)];o["#"]=t.state.env["#"],o["@"]=t.state.env["@"];let l=r.slice(1);t.state.env["#"]=String(l.length),t.state.env["@"]=l.join(" ");for(let c=0;c<l.length&&c<9;c++)t.state.env[String(c+1)]=l[c];for(let c=l.length+1;c<=9;c++)delete t.state.env[String(c)]}let a=()=>{if(t.state.sourceDepth--,r.length>1)for(let[l,c]of Object.entries(o))c===void 0?delete t.state.env[l]:t.state.env[l]=c};t.state.sourceDepth++;try{let l=lt(i),c=await t.executeScript(l);return a(),c}catch(l){if(a(),l instanceof ie)throw l;if(l instanceof ke)return _(l.stdout,l.stderr,l.exitCode);if(l.name==="ParseException")return U(`bash: ${n}: ${l.message}
714
+ `);throw l}}function Ai(t,e){let r="variable",n="",s=0;for(let i of e){if(i==="-v"){r="variable";continue}if(i==="-f"){r="function";continue}if(r==="function"){t.state.functions.delete(i);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let a=o[1],l=o[2];if(l==="@"||l==="*"){let u=Ee(t,a);for(let[f]of u)delete t.state.env[`${a}_${f}`];delete t.state.env[a];continue}let c;if(/^-?\d+$/.test(l))c=Number.parseInt(l,10);else{let u=t.state.env[l];c=u?Number.parseInt(u,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let u=Ee(t,a),f=u.length;if(f===0){n+=`bash: unset: [${c}]: bad array subscript
715
+ `,s=1;continue}let p=f+c;if(p<0){n+=`bash: unset: [${c}]: bad array subscript
716
+ `,s=1;continue}let d=u[p][0];delete t.state.env[`${a}_${d}`];continue}delete t.state.env[`${a}_${c}`];continue}delete t.state.env[i],t.state.functions.delete(i)}return _("",n,s)}function ki(t,e){return t.fs.resolvePath(t.state.cwd,e)}var qy=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function En(t){return qy.includes(t)}async function Sn(t,e,r){let n=ki(t,r);switch(e){case"-e":case"-a":return t.fs.exists(n);case"-f":return await t.fs.exists(n)?(await t.fs.stat(n)).isFile:!1;case"-d":return await t.fs.exists(n)?(await t.fs.stat(n)).isDirectory:!1;case"-r":case"-w":case"-x":return t.fs.exists(n);case"-s":return await t.fs.exists(n)?(await t.fs.stat(n)).size>0:!1;case"-L":case"-h":try{return(await t.fs.lstat(n)).isSymbolicLink}catch{return!1}case"-k":return await t.fs.exists(n)?((await t.fs.stat(n)).mode&512)!==0:!1;case"-g":return await t.fs.exists(n)?((await t.fs.stat(n)).mode&1024)!==0:!1;case"-u":return await t.fs.exists(n)?((await t.fs.stat(n)).mode&2048)!==0:!1;case"-G":case"-O":return t.fs.exists(n);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].some(i=>n===i||n.endsWith(i));case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return t.fs.exists(n);default:return!1}}var Vy=["-nt","-ot","-ef"];function Cn(t){return Vy.includes(t)}async function An(t,e,r,n){let s=ki(t,r),i=ki(t,n);switch(e){case"-nt":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime>a.mtime}catch{return!1}case"-ot":try{let o=await t.fs.stat(s),a=await t.fs.stat(i);return o.mtime<a.mtime}catch{return!1}case"-ef":try{if(!await t.fs.exists(s)||!await t.fs.exists(i))return!1;let o=t.fs.resolvePath(t.state.cwd,s),a=t.fs.resolvePath(t.state.cwd,i);return o===a}catch{return!1}default:return!1}}var Ky=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function kn(t){return Ky.has(t)}function Nn(t,e,r){switch(t){case"-eq":return e===r;case"-ne":return e!==r;case"-lt":return e<r;case"-le":return e<=r;case"-gt":return e>r;case"-ge":return e>=r}}function In(t){return t==="="||t==="=="||t==="!="}function vn(t,e,r,n=!1){let s=n?$n(e,r):e===r;return t==="!="?!s:s}var Zy=new Set(["-z","-n"]);function Rn(t){return Zy.has(t)}function Pn(t,e){switch(t){case"-z":return e==="";case"-n":return e!==""}}function Fn(t,e){let r=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let n=r[1],s=r[2];s=s.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(o,a)=>t.state.env[a]||"");let i;if(/^-?\d+$/.test(s))i=Number.parseInt(s,10);else try{let o=Function(`"use strict"; return (${s})`)();i=typeof o=="number"?Math.floor(o):0}catch{let o=t.state.env[s];i=o?Number.parseInt(o,10):0}if(i<0){let o=xr(t,n);if(o.length===0||(i=Math.max(...o)+1+i,i<0))return!1}return`${n}_${i}`in t.state.env}return e in t.state.env}async function ft(t,e){switch(e.type){case"CondBinary":{let r=await le(t,e.left),n=await le(t,e.right),s=e.right.parts.length>0&&e.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped");if(In(e.operator))return vn(e.operator,r,n,!s);if(kn(e.operator))return Nn(e.operator,Df(t,r),Df(t,n));if(Cn(e.operator))return An(t,e.operator,r,n);switch(e.operator){case"=~":try{let i=new RegExp(n),o=r.match(i);if(o){t.state.env.BASH_REMATCH=o[0];for(let a=1;a<o.length;a++)t.state.env[`BASH_REMATCH_${a}`]=o[a]||""}return o!==null}catch{throw new Error("syntax error in regular expression")}case"<":return r<n;case">":return r>n;default:return!1}}case"CondUnary":{let r=await le(t,e.operand);return En(e.operator)?Sn(t,e.operator,r):Rn(e.operator)?Pn(e.operator,r):e.operator==="-v"?Fn(t,r):e.operator==="-o"?Ii(t,r):!1}case"CondNot":return!await ft(t,e.operand);case"CondAnd":return await ft(t,e.left)?await ft(t,e.right):!1;case"CondOr":return await ft(t,e.left)?!0:await ft(t,e.right);case"CondGroup":return await ft(t,e.expression);case"CondWord":return await le(t,e.word)!=="";default:return!1}}async function er(t,e){if(e.length===0)return _("","",1);if(e.length===1)return we(!!e[0]);if(e.length===2){let n=e[0],s=e[1];return n==="("?U(`test: '(' without matching ')'
717
+ `,2):En(n)?we(await Sn(t,n,s)):Rn(n)?we(Pn(n,s)):n==="!"?we(!s):n==="-v"?we(Fn(t,s)):n==="-o"?we(Ii(t,s)):n==="="||n==="=="||n==="!="||n==="<"||n===">"||n==="-eq"||n==="-ne"||n==="-lt"||n==="-le"||n==="-gt"||n==="-ge"||n==="-nt"||n==="-ot"||n==="-ef"?U(`test: ${n}: unary operator expected
718
+ `,2):_("","",1)}if(e.length===3){let n=e[0],s=e[1],i=e[2];if(In(s))return we(vn(s,n,i));if(kn(s)){let o=On(n),a=On(i);return!o.valid||!a.valid?_("","",2):we(Nn(s,o.value,a.value))}if(Cn(s))return we(await An(t,s,n,i));switch(s){case"-a":return we(n!==""&&i!=="");case"-o":return we(n!==""||i!=="");case">":return we(n>i);case"<":return we(n<i)}if(n==="!"){let o=await er(t,[s,i]);return _("",o.stderr,o.exitCode===0?1:o.exitCode===1?0:o.exitCode)}if(n==="("&&i===")")return we(s!=="")}if(e.length===4){if(e[0]==="!"){let n=await er(t,e.slice(1));return _("",n.stderr,n.exitCode===0?1:n.exitCode===1?0:n.exitCode)}if(e[0]==="("&&e[3]===")")return er(t,[e[1],e[2]])}let r=await Mf(t,e,0);return r.pos<e.length?U(`test: too many arguments
719
+ `,2):we(r.value)}async function Mf(t,e,r){return Qy(t,e,r)}async function Qy(t,e,r){let{value:n,pos:s}=await Tf(t,e,r);for(;e[s]==="-o";){let i=await Tf(t,e,s+1);n=n||i.value,s=i.pos}return{value:n,pos:s}}async function Tf(t,e,r){let{value:n,pos:s}=await Ni(t,e,r);for(;e[s]==="-a";){let i=await Ni(t,e,s+1);n=n&&i.value,s=i.pos}return{value:n,pos:s}}async function Ni(t,e,r){if(e[r]==="!"){let{value:n,pos:s}=await Ni(t,e,r+1);return{value:!n,pos:s}}return Xy(t,e,r)}async function Xy(t,e,r){let n=e[r];if(n==="("){let{value:i,pos:o}=await Mf(t,e,r+1);return{value:i,pos:e[o]===")"?o+1:o}}if(En(n)){let i=e[r+1]??"";return{value:await Sn(t,n,i),pos:r+2}}if(Rn(n)){let i=e[r+1]??"";return{value:Pn(n,i),pos:r+2}}if(n==="-v"){let i=e[r+1]??"";return{value:Fn(t,i),pos:r+2}}if(n==="-o"){let i=e[r+1]??"";return{value:Ii(t,i),pos:r+2}}let s=e[r+1];if(In(s)){let i=n,o=e[r+2]??"";return{value:vn(s,i,o),pos:r+3}}if(kn(s)){let i=On(n),o=On(e[r+2]??"0");return!i.valid||!o.valid?{value:!1,pos:r+3}:{value:Nn(s,i.value,o.value),pos:r+3}}if(Cn(s)){let i=n,o=e[r+2]??"";return{value:await An(t,s,i,o),pos:r+3}}return{value:n!==void 0&&n!=="",pos:r+1}}function $n(t,e){let r="^";for(let n=0;n<e.length;n++){let s=e[n];if(s==="\\")if(n+1<e.length){let i=e[n+1];/[\\^$.|+(){}[\]*?]/.test(i)?r+=`\\${i}`:r+=i,n++}else r+="\\\\";else if(s==="*")r+=".*";else if(s==="?")r+=".";else if(s==="["){let i=e.indexOf("]",n+1);i!==-1?(r+=e.slice(n,i+1),n=i):r+="\\["}else/[\\^$.|+(){}]/.test(s)?r+=`\\${s}`:r+=s}return r+="$",new RegExp(r).test(t)}function Ii(t,e){let n={errexit:()=>t.state.options.errexit===!0,nounset:()=>t.state.options.nounset===!0,pipefail:()=>t.state.options.pipefail===!0,xtrace:()=>t.state.options.xtrace===!0,e:()=>t.state.options.errexit===!0,u:()=>t.state.options.nounset===!0,x:()=>t.state.options.xtrace===!0}[e];return n?n():!1}function Df(t,e){if(e=e.trim(),e==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(e))return Lf(e);try{let r=new Se,n=be(r,e);return ee(t,n.expression)}catch{return Lf(e)}}function Jy(t,e){let r=0;for(let n of t){let s;if(n>="0"&&n<="9")s=n.charCodeAt(0)-48;else if(n>="a"&&n<="z")s=n.charCodeAt(0)-97+10;else if(n>="A"&&n<="Z")s=n.charCodeAt(0)-65+36;else if(n==="@")s=62;else if(n==="_")s=63;else return Number.NaN;if(s>=e)return Number.NaN;r=r*e+s}return r}function Lf(t){if(t=t.trim(),t==="")return 0;let e=!1;t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1));let r,n=t.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(n){let s=Number.parseInt(n[1],10);s>=2&&s<=64?r=Jy(n[2],s):r=0}else/^0[xX][0-9a-fA-F]+$/.test(t)?r=Number.parseInt(t,16):/^0[0-7]+$/.test(t)?r=Number.parseInt(t,8):r=Number.parseInt(t,10);return Number.isNaN(r)&&(r=0),e?-r:r}function On(t){if(t=t.trim(),t==="")return{value:0,valid:!0};let e=!1;if(t.startsWith("-")?(e=!0,t=t.slice(1)):t.startsWith("+")&&(t=t.slice(1)),!/^\d+$/.test(t))return{value:0,valid:!1};let r=Number.parseInt(t,10);return Number.isNaN(r)?{value:0,valid:!1}:{value:e?-r:r,valid:!0}}oe();async function vi(t,e){let r=t.state.inCondition;t.state.inCondition=!0;let n="",s="",i=0;try{for(let o of e){let a=await t.executeStatement(o);n+=a.stdout,s+=a.stderr,i=a.exitCode}}finally{t.state.inCondition=r}return{stdout:n,stderr:s,exitCode:i}}oe();qe();function Sr(t,e,r,n){if(t instanceof Ae)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"break",stdout:e,stderr:r};if(t instanceof Re)return e+=t.stdout,r+=t.stderr,t.levels>1&&n>1?(t.levels--,t.stdout=e,t.stderr=r,{action:"rethrow",stdout:e,stderr:r,error:t}):{action:"continue",stdout:e,stderr:r};if(t instanceof ke||t instanceof Ke||t instanceof ie||t instanceof j)return t.prependOutput(e,r),{action:"rethrow",stdout:e,stderr:r,error:t};let s=de(t);return{action:"error",stdout:e,stderr:`${r}${s}
720
+ `,exitCode:1}}oe();qe();async function Tn(t,e,r="",n=""){let s=r,i=n,o=0;try{for(let a of e){let l=await t.executeStatement(a);s+=l.stdout,i+=l.stderr,o=l.exitCode}}catch(a){if(Dr(a)||a instanceof Ke||a instanceof ie||a instanceof j||a instanceof Ze)throw a.prependOutput(s,i),a;return{stdout:s,stderr:`${i}${de(a)}
721
+ `,exitCode:1}}return{stdout:s,stderr:i,exitCode:o}}async function _f(t,e){let r="",n="";for(let s of e.clauses){let i=await vi(t,s.condition);if(r+=i.stdout,n+=i.stderr,i.exitCode===0)return Tn(t,s.body,r,n)}return e.elseBody?Tn(t,e.elseBody,r,n):_(r,n,0)}async function Bf(t,e){let r="",n="",s=0,i=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e.variable))return U(`bash: \`${e.variable}': not a valid identifier
722
+ `);let o=[];if(e.words===null)o=(t.state.env["@"]||"").split(" ").filter(Boolean);else if(e.words.length===0)o=[];else for(let a of e.words){let l=await Er(t,a);o.push(...l.values)}t.state.loopDepth++;try{for(let a of o){i++,i>t.limits.maxLoopIterations&&st(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n),t.state.env[e.variable]=a;try{for(let l of e.body){let c=await t.executeStatement(l);r+=c.stdout,n+=c.stderr,s=c.exitCode}}catch(l){let c=Sr(l,r,n,t.state.loopDepth);if(r=c.stdout,n=c.stderr,c.action==="break")break;if(c.action==="continue")continue;if(c.action==="error")return _(r,n,c.exitCode??1);throw c.error}}}finally{t.state.loopDepth--}return _(r,n,s)}async function Wf(t,e){let r="",n="",s=0,i=0;e.init&&await te(t,e.init.expression),t.state.loopDepth++;try{for(;i++,i>t.limits.maxLoopIterations&&st(`for loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n),!(e.condition&&await te(t,e.condition.expression)===0);){try{for(let o of e.body){let a=await t.executeStatement(o);r+=a.stdout,n+=a.stderr,s=a.exitCode}}catch(o){let a=Sr(o,r,n,t.state.loopDepth);if(r=a.stdout,n=a.stderr,a.action==="break")break;if(a.action==="continue"){e.update&&await te(t,e.update.expression);continue}if(a.action==="error")return _(r,n,a.exitCode??1);throw a.error}e.update&&await te(t,e.update.expression)}}finally{t.state.loopDepth--}return _(r,n,s)}async function Uf(t,e,r=""){let n="",s="",i=0,o=0,a=r;for(let c of e.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await le(t,u.content);u.stripTabs&&(f=f.split(`
723
+ `).map(p=>p.replace(/^\t+/,"")).join(`
724
+ `)),a=f}else if(c.operator==="<<<"&&c.target.type==="Word")a=`${await le(t,c.target)}
725
+ `;else if(c.operator==="<"&&c.target.type==="Word")try{let u=await le(t,c.target),f=t.fs.resolvePath(t.state.cwd,u);a=await t.fs.readFile(f)}catch{let u=await le(t,c.target);return U(`bash: ${u}: No such file or directory
726
+ `)}let l=t.state.groupStdin;a&&(t.state.groupStdin=a),t.state.loopDepth++;try{for(;;){o++,o>t.limits.maxLoopIterations&&st(`while loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,s);let c=0,u=!1,f=!1,p=t.state.inCondition;t.state.inCondition=!0;try{for(let d of e.condition){let h=await t.executeStatement(d);n+=h.stdout,s+=h.stderr,c=h.exitCode}}catch(d){if(d instanceof Ae){if(n+=d.stdout,s+=d.stderr,d.levels>1&&t.state.loopDepth>1)throw d.levels--,d.stdout=n,d.stderr=s,t.state.inCondition=p,d;u=!0}else if(d instanceof Re){if(n+=d.stdout,s+=d.stderr,d.levels>1&&t.state.loopDepth>1)throw d.levels--,d.stdout=n,d.stderr=s,t.state.inCondition=p,d;f=!0}else throw t.state.inCondition=p,d}finally{t.state.inCondition=p}if(u)break;if(!f){if(c!==0)break;try{for(let d of e.body){let h=await t.executeStatement(d);n+=h.stdout,s+=h.stderr,i=h.exitCode}}catch(d){let h=Sr(d,n,s,t.state.loopDepth);if(n=h.stdout,s=h.stderr,h.action==="break")break;if(h.action==="continue")continue;if(h.action==="error")return _(n,s,h.exitCode??1);throw h.error}}}}finally{t.state.loopDepth--,t.state.groupStdin=l}return _(n,s,i)}async function jf(t,e){let r="",n="",s=0,i=0;t.state.loopDepth++;try{for(;;){i++,i>t.limits.maxLoopIterations&&st(`until loop: too many iterations (${t.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,n);let o=await vi(t,e.condition);if(r+=o.stdout,n+=o.stderr,o.exitCode===0)break;try{for(let a of e.body){let l=await t.executeStatement(a);r+=l.stdout,n+=l.stderr,s=l.exitCode}}catch(a){let l=Sr(a,r,n,t.state.loopDepth);if(r=l.stdout,n=l.stderr,l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return _(r,n,l.exitCode??1);throw l.error}}}finally{t.state.loopDepth--}return _(r,n,s)}async function zf(t,e){let r="",n="",s=0,i=await le(t,e.word),o=!1;for(let a=0;a<e.items.length;a++){let l=e.items[a],c=o;if(!o)for(let u of l.patterns){let f=await le(t,u);if(gf(u)&&(f=yf(f)),$n(i,f)){c=!0;break}}if(c){let u=await Tn(t,l.body,r,n);if(r=u.stdout,n=u.stderr,s=u.exitCode,l.terminator===";;")break;l.terminator===";&"?o=!0:o=!1}else o=!1}return _(r,n,s)}oe();oe();function Hf(t,e){return t.state.functions.set(e.name,e),Q}async function Gf(t,e,r){t.state.callDepth++,t.state.callDepth>t.limits.maxCallDepth&&(t.state.callDepth--,st(`${e.name}: maximum recursion depth (${t.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),t.state.localScopes.push(new Map);let n={};for(let i=0;i<r.length;i++)n[String(i+1)]=t.state.env[String(i+1)],t.state.env[String(i+1)]=r[i];n["@"]=t.state.env["@"],n["#"]=t.state.env["#"],t.state.env["@"]=r.join(" "),t.state.env["#"]=String(r.length);let s=()=>{let i=t.state.localScopes.pop();if(i)for(let[o,a]of i)a===void 0?delete t.state.env[o]:t.state.env[o]=a;for(let[o,a]of Object.entries(n))a===void 0?delete t.state.env[o]:t.state.env[o]=a;t.state.callDepth--};try{let i=await t.executeCommand(e.body,"");return s(),i}catch(i){if(s(),i instanceof ke)return _(i.stdout,i.stderr,i.exitCode);throw i}}qe();async function qf(t,e,r){let{stdout:n,stderr:s,exitCode:i}=e;for(let o of r){if(o.target.type==="HereDoc")continue;let a=await le(t,o.target);switch(o.operator){case">":{let l=o.fd??1;if(l===1){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
727
727
  `,i=1,n="";break}}catch{}await t.fs.writeFile(c,n),n=""}else if(l===2)if(a==="/dev/null")s="";else{let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
728
728
  `,i=1;break}}catch{}await t.fs.writeFile(c,s),s=""}break}case">>":{let l=o.fd??1;if(l===1){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
729
729
  `,i=1,n="";break}}catch{}await t.fs.appendFile(c,n),n=""}else if(l===2){let c=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(c)).isDirectory){s+=`bash: ${a}: Is a directory
730
730
  `,i=1;break}}catch{}await t.fs.appendFile(c,s),s=""}break}case">&":{let l=o.fd??1;a==="2"||a==="&2"?l===1&&(s+=n,n=""):(a==="1"||a==="&1")&&(n+=s,s="");break}case"&>":{let l=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(l)).isDirectory){s=`bash: ${a}: Is a directory
731
731
  `,i=1,n="";break}}catch{}await t.fs.writeFile(l,n+s),n="",s="";break}case"&>>":{let l=t.fs.resolvePath(t.state.cwd,a);try{if((await t.fs.stat(l)).isDirectory){s=`bash: ${a}: Is a directory
732
- `,i=1,n="";break}}catch{}await t.fs.appendFile(l,n+s),n="",s="";break}}}return T(n,s,i)}var pr=class{ctx;constructor(e,r){this.ctx={state:r,fs:e.fs,commands:e.commands,limits:e.limits,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep}}async executeScript(e){let r="",n="",s=0;for(let i of e.statements)try{let o=await this.executeStatement(i);r+=o.stdout,n+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}catch(o){if(o instanceof Q)throw o.prependOutput(r,n),o;if(o instanceof W)throw o;if(o instanceof Ue)return r+=o.stdout,n+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Pe)return r+=o.stdout,n+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof qe)return r+=o.stdout,n+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof he||o instanceof we){if(this.ctx.state.loopDepth>0)throw o.prependOutput(r,n),o;r+=o.stdout,n+=o.stderr;continue}throw o instanceof me&&o.prependOutput(r,n),o}return{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}}}async executeStatement(e){this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Je(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands");let r="",n="",s=0,i=-1,o=!1;for(let a=0;a<e.pipelines.length;a++){let l=e.pipelines[a],c=a>0?e.operators[a-1]:null;if(c==="&&"&&s!==0||c==="||"&&s===0)continue;let u=await this.executePipeline(l);r+=u.stdout,n+=u.stderr,s=u.exitCode,i=a,o=l.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}if(this.ctx.state.options.errexit&&s!==0&&i===e.pipelines.length-1&&!o&&!this.ctx.state.inCondition)throw new Ue(s,r,n);return T(r,n,s)}async executePipeline(e){let r="",n=V,s=0,i=[];for(let o=0;o<e.commands.length;o++){let a=e.commands[o],l=o===e.commands.length-1,c;try{c=await this.executeCommand(a,r)}catch(u){if(u instanceof qe)c={stdout:u.stdout,stderr:u.stderr,exitCode:1};else if(u instanceof Q&&e.commands.length>1)c={stdout:u.stdout,stderr:u.stderr,exitCode:u.exitCode};else throw u}i.push(c.exitCode),c.exitCode!==0&&(s=c.exitCode),l?n=c:(r=c.stdout,n={stdout:"",stderr:c.stderr,exitCode:c.exitCode})}for(let o of Object.keys(this.ctx.state.env))o.startsWith("PIPESTATUS_")&&delete this.ctx.state.env[o];for(let o=0;o<i.length;o++)this.ctx.state.env[`PIPESTATUS_${o}`]=String(i[o]);return this.ctx.state.env.PIPESTATUS__length=String(i.length),this.ctx.state.options.pipefail&&s!==0&&(n={...n,exitCode:s}),e.negated&&(n={...n,exitCode:n.exitCode===0?1:0}),n}async executeCommand(e,r){switch(e.type){case"SimpleCommand":return this.executeSimpleCommand(e,r);case"If":return Rf(this.ctx,e);case"For":return Pf(this.ctx,e);case"CStyleFor":return Of(this.ctx,e);case"While":return Ff(this.ctx,e,r);case"Until":return Tf(this.ctx,e);case"Case":return Lf(this.ctx,e);case"Subshell":return this.executeSubshell(e,r);case"Group":return this.executeGroup(e,r);case"FunctionDef":return Df(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return V}}async executeSimpleCommand(e,r){try{return await this.executeSimpleCommandInner(e,r)}catch(n){if(n instanceof le)return B(n.stderr);throw n}}async executeSimpleCommandInner(e,r){e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.expansionStderr="";let n={};for(let l of e.assignments){let c=l.name;if(l.array){if(/\[.+\]$/.test(c))return T("",`bash: ${c}: cannot assign list to array member
733
- `,1);let y=st(this.ctx,c);if(y)return y;let m=[];for(let b of l.array){let E=await fr(this.ctx,b);m.push(...E.values)}let w=0;if(l.append){let b=fe(this.ctx,c);b.length>0&&(w=Math.max(...b.map(([S])=>typeof S=="number"?S:0))+1)}else{let b=`${c}_`;for(let E of Object.keys(this.ctx.state.env))E.startsWith(b)&&!E.includes("__")&&delete this.ctx.state.env[E]}for(let b=0;b<m.length;b++)this.ctx.state.env[`${c}_${w+b}`]=m[b];l.append||(this.ctx.state.env[`${c}__length`]=String(m.length));continue}let u=l.value?await Y(this.ctx,l.value):"";if(c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return T("",`bash: ${c}: bad array subscript
734
- `,1);let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(d){let y=d[1],m=d[2],w=st(this.ctx,y);if(w)return w;let b=this.ctx.state.associativeArrays?.has(y),E;if(b){let A;if(m.startsWith("'")&&m.endsWith("'"))A=m.slice(1,-1);else if(m.startsWith('"')&&m.endsWith('"')){let F=m.slice(1,-1),D=new pe().parseWordFromString(F,!0,!1);A=await Y(this.ctx,D)}else if(m.includes("$")){let M=new pe().parseWordFromString(m,!1,!1);A=await Y(this.ctx,M)}else A=m;E=`${y}_${A}`}else{let A;if(/^-?\d+$/.test(m))A=Number.parseInt(m,10);else{try{let F=new pe,M=ue(F,m);A=K(this.ctx,M.expression)}catch{let F=this.ctx.state.env[m];A=F?Number.parseInt(F,10):0}Number.isNaN(A)&&(A=0)}if(A<0){let F=fe(this.ctx,y);if(F.length===0)return T("",`bash: ${y}[${m}]: bad array subscript
735
- `,1);if(A=Math.max(...F.map(([D])=>typeof D=="number"?D:0))+1+A,A<0)return T("",`bash: ${y}[${m}]: bad array subscript
736
- `,1)}E=`${y}_${A}`}let S=l.append?(this.ctx.state.env[E]||"")+u:u;e.name?(n[E]=this.ctx.state.env[E],this.ctx.state.env[E]=S):this.ctx.state.env[E]=S;continue}let p=st(this.ctx,c);if(p)return p;let h=l.append?(this.ctx.state.env[c]||"")+u:u;e.name?(n[c]=this.ctx.state.env[c],this.ctx.state.env[c]=h):this.ctx.state.env[c]=h}if(!e.name)return T("","",this.ctx.state.lastExitCode);for(let l of e.redirections){if((l.operator==="<<"||l.operator==="<<-")&&l.target.type==="HereDoc"){let c=l.target,u=await Y(this.ctx,c.content);c.stripTabs&&(u=u.split(`
732
+ `,i=1,n="";break}}catch{}await t.fs.appendFile(l,n+s),n="",s="";break}}}return _(n,s,i)}var Cr=class{ctx;constructor(e,r){this.ctx={state:r,fs:e.fs,commands:e.commands,limits:e.limits,execFn:e.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:e.fetch,sleep:e.sleep}}async executeScript(e){let r="",n="",s=0;for(let i of e.statements)try{let o=await this.executeStatement(i);r+=o.stdout,n+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}catch(o){if(o instanceof ie)throw o.prependOutput(r,n),o;if(o instanceof j)throw o;if(o instanceof Ke)return r+=o.stdout,n+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Ue)return r+=o.stdout,n+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Je)return r+=o.stdout,n+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s),{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}};if(o instanceof Ae||o instanceof Re){if(this.ctx.state.loopDepth>0)throw o.prependOutput(r,n),o;r+=o.stdout,n+=o.stderr;continue}throw o instanceof ke&&o.prependOutput(r,n),o}return{stdout:r,stderr:n,exitCode:s,env:{...this.ctx.state.env}}}async executeStatement(e){this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&st(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands");let r="",n="",s=0,i=-1,o=!1;for(let a=0;a<e.pipelines.length;a++){let l=e.pipelines[a],c=a>0?e.operators[a-1]:null;if(c==="&&"&&s!==0||c==="||"&&s===0)continue;let u=await this.executePipeline(l);r+=u.stdout,n+=u.stderr,s=u.exitCode,i=a,o=l.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env["?"]=String(s)}if(this.ctx.state.options.errexit&&s!==0&&i===e.pipelines.length-1&&!o&&!this.ctx.state.inCondition)throw new Ke(s,r,n);return _(r,n,s)}async executePipeline(e){let r="",n=Q,s=0,i=[];for(let o=0;o<e.commands.length;o++){let a=e.commands[o],l=o===e.commands.length-1,c;try{c=await this.executeCommand(a,r)}catch(u){if(u instanceof Je)c={stdout:u.stdout,stderr:u.stderr,exitCode:1};else if(u instanceof ie&&e.commands.length>1)c={stdout:u.stdout,stderr:u.stderr,exitCode:u.exitCode};else throw u}i.push(c.exitCode),c.exitCode!==0&&(s=c.exitCode),l?n=c:(r=c.stdout,n={stdout:"",stderr:c.stderr,exitCode:c.exitCode})}for(let o of Object.keys(this.ctx.state.env))o.startsWith("PIPESTATUS_")&&delete this.ctx.state.env[o];for(let o=0;o<i.length;o++)this.ctx.state.env[`PIPESTATUS_${o}`]=String(i[o]);return this.ctx.state.env.PIPESTATUS__length=String(i.length),this.ctx.state.options.pipefail&&s!==0&&(n={...n,exitCode:s}),e.negated&&(n={...n,exitCode:n.exitCode===0?1:0}),n}async executeCommand(e,r){switch(e.type){case"SimpleCommand":return this.executeSimpleCommand(e,r);case"If":return _f(this.ctx,e);case"For":return Bf(this.ctx,e);case"CStyleFor":return Wf(this.ctx,e);case"While":return Uf(this.ctx,e,r);case"Until":return jf(this.ctx,e);case"Case":return zf(this.ctx,e);case"Subshell":return this.executeSubshell(e,r);case"Group":return this.executeGroup(e,r);case"FunctionDef":return Hf(this.ctx,e);case"ArithmeticCommand":return this.executeArithmeticCommand(e);case"ConditionalCommand":return this.executeConditionalCommand(e);default:return Q}}async executeSimpleCommand(e,r){try{return await this.executeSimpleCommandInner(e,r)}catch(n){if(n instanceof xe)return U(n.stderr);throw n}}async executeSimpleCommandInner(e,r){e.line!==void 0&&(this.ctx.state.currentLine=e.line),this.ctx.state.expansionStderr="";let n={};for(let l of e.assignments){let c=l.name;if(l.array){if(/\[.+\]$/.test(c))return _("",`bash: ${c}: cannot assign list to array member
733
+ `,1);let m=ut(this.ctx,c);if(m)return m;let g=[];for(let b of l.array){let E=await Er(this.ctx,b);g.push(...E.values)}let w=0;if(l.append){let b=Ee(this.ctx,c);b.length>0&&(w=Math.max(...b.map(([S])=>typeof S=="number"?S:0))+1)}else{let b=`${c}_`;for(let E of Object.keys(this.ctx.state.env))E.startsWith(b)&&!E.includes("__")&&delete this.ctx.state.env[E]}for(let b=0;b<g.length;b++)this.ctx.state.env[`${c}_${w+b}`]=g[b];l.append||(this.ctx.state.env[`${c}__length`]=String(g.length));continue}let u=l.value?await le(this.ctx,l.value):"";if(c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return _("",`bash: ${c}: bad array subscript
734
+ `,1);let p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(p){let m=p[1],g=p[2],w=ut(this.ctx,m);if(w)return w;let b=this.ctx.state.associativeArrays?.has(m),E;if(b){let v;if(g.startsWith("'")&&g.endsWith("'"))v=g.slice(1,-1);else if(g.startsWith('"')&&g.endsWith('"')){let D=g.slice(1,-1),$=new Se().parseWordFromString(D,!0,!1);v=await le(this.ctx,$)}else if(g.includes("$")){let I=new Se().parseWordFromString(g,!1,!1);v=await le(this.ctx,I)}else v=g;E=`${m}_${v}`}else{let v;if(/^-?\d+$/.test(g))v=Number.parseInt(g,10);else{try{let D=new Se,I=be(D,g);v=ee(this.ctx,I.expression)}catch{let D=this.ctx.state.env[g];v=D?Number.parseInt(D,10):0}Number.isNaN(v)&&(v=0)}if(v<0){let D=Ee(this.ctx,m);if(D.length===0)return _("",`bash: ${m}[${g}]: bad array subscript
735
+ `,1);if(v=Math.max(...D.map(([$])=>typeof $=="number"?$:0))+1+v,v<0)return _("",`bash: ${m}[${g}]: bad array subscript
736
+ `,1)}E=`${m}_${v}`}let S=l.append?(this.ctx.state.env[E]||"")+u:u;e.name?(n[E]=this.ctx.state.env[E],this.ctx.state.env[E]=S):this.ctx.state.env[E]=S;continue}let d=ut(this.ctx,c);if(d)return d;let h=l.append?(this.ctx.state.env[c]||"")+u:u;e.name?(n[c]=this.ctx.state.env[c],this.ctx.state.env[c]=h):this.ctx.state.env[c]=h}if(!e.name)return _("","",this.ctx.state.lastExitCode);for(let l of e.redirections){if((l.operator==="<<"||l.operator==="<<-")&&l.target.type==="HereDoc"){let c=l.target,u=await le(this.ctx,c.content);c.stripTabs&&(u=u.split(`
737
737
  `).map(f=>f.replace(/^\t+/,"")).join(`
738
- `)),r=u;continue}if(l.operator==="<<<"&&l.target.type==="Word"){r=`${await Y(this.ctx,l.target)}
739
- `;continue}if(l.operator==="<"&&l.target.type==="Word")try{let c=await Y(this.ctx,l.target),u=this.ctx.fs.resolvePath(this.ctx.state.cwd,c);r=await this.ctx.fs.readFile(u)}catch{let c=await Y(this.ctx,l.target);for(let[u,f]of Object.entries(n))f===void 0?delete this.ctx.state.env[u]:this.ctx.state.env[u]=f;return B(`bash: ${c}: No such file or directory
740
- `)}}let s=await Y(this.ctx,e.name),i=[],o=[];for(let l of e.args){let c=await fr(this.ctx,l);for(let u of c.values)i.push(u),o.push(c.quoted)}if(!s){if(e.name.parts.every(c=>c.type==="CommandSubstitution"||c.type==="ParameterExpansion"||c.type==="ArithmeticExpansion")){if(i.length>0){let c=i.shift();return o.shift(),await this.runCommand(c,i,o,r)}return T("","",this.ctx.state.lastExitCode)}return B(`bash: : command not found
741
- `,127)}let a=await this.runCommand(s,i,o,r);a=await _f(this.ctx,a,e.redirections),this.ctx.state.lastArg=i.length>0?i[i.length-1]:s;for(let[l,c]of Object.entries(n))c===void 0?delete this.ctx.state.env[l]:this.ctx.state.env[l]=c;return this.ctx.state.expansionStderr&&(a={...a,stderr:this.ctx.state.expansionStderr+a.stderr},this.ctx.state.expansionStderr=""),a}async runCommand(e,r,n,s,i=!1){if(e==="cd")return await Ys(this.ctx,r);if(e==="export")return oi(this.ctx,r);if(e==="unset")return gi(this.ctx,r);if(e==="exit")return ii(this.ctx,r);if(e==="local")return li(this.ctx,r);if(e==="set")return pi(this.ctx,r);if(e==="break")return Js(this.ctx,r);if(e==="continue")return ei(this.ctx,r);if(e==="return")return fi(this.ctx,r);if(e==="eval")return si(this.ctx,r);if(e==="shift")return hi(this.ctx,r);if(e==="source"||e===".")return mi(this.ctx,r);if(e==="read")return ui(this.ctx,r,s);if(e==="mapfile"||e==="readarray")return ci(this.ctx,r,s);if(e==="declare"||e==="typeset")return ri(this.ctx,r);if(e==="readonly")return ni(this.ctx,r);if(!i){let u=this.ctx.state.functions.get(e);if(u)return Mf(this.ctx,u,r)}if(e===":"||e==="true")return V;if(e==="false")return ce(!1);if(e==="let")return ai(this.ctx,r);if(e==="command"){if(r.length===0)return V;let u=r;for(;u.length>0&&u[0].startsWith("-");)u=u.slice(1);if(u.length===0)return V;let[f,...d]=u;return this.runCommand(f,d,[],s,!0)}if(e==="builtin"){if(r.length===0)return V;let[u,...f]=r;return this.runCommand(u,f,[],s)}if(e==="shopt")return V;if(e==="exec"){if(r.length===0)return V;let[u,...f]=r;return this.runCommand(u,f,[],s)}if(e==="wait")return V;if(e==="type")return this.handleType(r);if(e==="[["){let u=r.lastIndexOf("]]");if(u!==-1){let f=r.slice(0,u);return Ht(this.ctx,f)}return B("bash: [[: missing `]]'\n",2)}if(e==="["||e==="test"){let u=r;if(e==="["){if(r[r.length-1]!=="]")return B("[: missing `]'\n",2);u=r.slice(0,-1)}return Ht(this.ctx,u)}let o=await this.resolveCommand(e);if(!o)return Nu(e)?B(`bash: ${e}: command not available in browser environments. Exclude '${e}' from your commands or use the Node.js bundle.
742
- `,127):B(`bash: ${e}: command not found
743
- `,127);let{cmd:a,path:l}=o,c={fs:this.ctx.fs,cwd:this.ctx.state.cwd,env:this.ctx.state.env,stdin:s,limits:this.ctx.limits,exec:this.ctx.execFn,fetch:this.ctx.fetch,getRegisteredCommands:()=>Array.from(this.ctx.commands.keys()),sleep:this.ctx.sleep};try{return await a.execute(r,c)}catch(u){return B(`${e}: ${re(u)}
738
+ `)),r=u;continue}if(l.operator==="<<<"&&l.target.type==="Word"){r=`${await le(this.ctx,l.target)}
739
+ `;continue}if(l.operator==="<"&&l.target.type==="Word")try{let c=await le(this.ctx,l.target),u=this.ctx.fs.resolvePath(this.ctx.state.cwd,c);r=await this.ctx.fs.readFile(u)}catch{let c=await le(this.ctx,l.target);for(let[u,f]of Object.entries(n))f===void 0?delete this.ctx.state.env[u]:this.ctx.state.env[u]=f;return U(`bash: ${c}: No such file or directory
740
+ `)}}let s=await le(this.ctx,e.name),i=[],o=[];for(let l of e.args){let c=await Er(this.ctx,l);for(let u of c.values)i.push(u),o.push(c.quoted)}if(!s){if(e.name.parts.every(c=>c.type==="CommandSubstitution"||c.type==="ParameterExpansion"||c.type==="ArithmeticExpansion")){if(i.length>0){let c=i.shift();return o.shift(),await this.runCommand(c,i,o,r)}return _("","",this.ctx.state.lastExitCode)}return U(`bash: : command not found
741
+ `,127)}let a=await this.runCommand(s,i,o,r);a=await qf(this.ctx,a,e.redirections),this.ctx.state.lastArg=i.length>0?i[i.length-1]:s;for(let[l,c]of Object.entries(n))c===void 0?delete this.ctx.state.env[l]:this.ctx.state.env[l]=c;return this.ctx.state.expansionStderr&&(a={...a,stderr:this.ctx.state.expansionStderr+a.stderr},this.ctx.state.expansionStderr=""),a}async runCommand(e,r,n,s,i=!1){if(e==="cd")return await ai(this.ctx,r);if(e==="export")return hi(this.ctx,r);if(e==="unset")return Ai(this.ctx,r);if(e==="exit")return di(this.ctx,r);if(e==="local")return gi(this.ctx,r);if(e==="set")return Ei(this.ctx,r);if(e==="break")return oi(this.ctx,r);if(e==="continue")return li(this.ctx,r);if(e==="return")return wi(this.ctx,r);if(e==="eval")return pi(this.ctx,r);if(e==="shift")return Si(this.ctx,r);if(e==="source"||e===".")return Ci(this.ctx,r);if(e==="read")return xi(this.ctx,r,s);if(e==="mapfile"||e==="readarray")return yi(this.ctx,r,s);if(e==="declare"||e==="typeset")return ui(this.ctx,r);if(e==="readonly")return fi(this.ctx,r);if(!i){let u=this.ctx.state.functions.get(e);if(u)return Gf(this.ctx,u,r)}if(e===":"||e==="true")return Q;if(e==="false")return we(!1);if(e==="let")return mi(this.ctx,r);if(e==="command"){if(r.length===0)return Q;let u=r;for(;u.length>0&&u[0].startsWith("-");)u=u.slice(1);if(u.length===0)return Q;let[f,...p]=u;return this.runCommand(f,p,[],s,!0)}if(e==="builtin"){if(r.length===0)return Q;let[u,...f]=r;return this.runCommand(u,f,[],s)}if(e==="shopt")return Q;if(e==="exec"){if(r.length===0)return Q;let[u,...f]=r;return this.runCommand(u,f,[],s)}if(e==="wait")return Q;if(e==="type")return this.handleType(r);if(e==="[["){let u=r.lastIndexOf("]]");if(u!==-1){let f=r.slice(0,u);return er(this.ctx,f)}return U("bash: [[: missing `]]'\n",2)}if(e==="["||e==="test"){let u=r;if(e==="["){if(r[r.length-1]!=="]")return U("[: missing `]'\n",2);u=r.slice(0,-1)}return er(this.ctx,u)}let o=await this.resolveCommand(e);if(!o)return Tu(e)?U(`bash: ${e}: command not available in browser environments. Exclude '${e}' from your commands or use the Node.js bundle.
742
+ `,127):U(`bash: ${e}: command not found
743
+ `,127);let{cmd:a,path:l}=o,c={fs:this.ctx.fs,cwd:this.ctx.state.cwd,env:this.ctx.state.env,stdin:s,limits:this.ctx.limits,exec:this.ctx.execFn,fetch:this.ctx.fetch,getRegisteredCommands:()=>Array.from(this.ctx.commands.keys()),sleep:this.ctx.sleep};try{return await a.execute(r,c)}catch(u){return U(`${e}: ${de(u)}
744
744
  `)}}async resolveCommand(e){if(e.includes("/")){let i=this.ctx.fs.resolvePath(this.ctx.state.cwd,e);if(!await this.ctx.fs.exists(i))return null;let o=i.split("/").pop()||e,a=this.ctx.commands.get(o);return a?{cmd:a,path:i}:null}let n=(this.ctx.state.env.PATH||"/bin:/usr/bin").split(":");for(let i of n){if(!i)continue;let o=`${i}/${e}`;if(await this.ctx.fs.exists(o)){let a=this.ctx.commands.get(e);if(a)return{cmd:a,path:o}}}if(!await this.ctx.fs.exists("/bin")){let i=this.ctx.commands.get(e);if(i)return{cmd:i,path:`/bin/${e}`}}return null}async findCommandInPath(e){let r=[],s=(this.ctx.state.env.PATH||"/bin:/usr/bin").split(":");for(let i of s){if(!i)continue;let o=`${i}/${e}`;await this.ctx.fs.exists(o)&&r.push(o)}return r}handleType(e){let r=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),n=new Set(["cd","export","unset","exit","local","set","break","continue","return","eval","shift","source",".","read","declare","typeset","readonly",":","true","false","let","command","builtin","shopt","exec","wait","type","[","test"]),s="",i="",o=0;for(let a of e)r.has(a)?s+=`${a} is a shell keyword
745
745
  `:n.has(a)?s+=`${a} is a shell builtin
746
746
  `:this.ctx.state.functions.has(a)?s+=`${a} is a function
747
747
  `:this.ctx.commands.has(a)?s+=`${a} is /bin/${a}
748
748
  `:(i+=`bash: type: ${a}: not found
749
- `,o=1);return T(s,i,o)}async executeSubshell(e,r=""){let n={...this.ctx.state.env},s=this.ctx.state.cwd,i=this.ctx.state.loopDepth,o=this.ctx.state.parentHasLoopContext;this.ctx.state.parentHasLoopContext=i>0,this.ctx.state.loopDepth=0;let a=this.ctx.state.groupStdin;r&&(this.ctx.state.groupStdin=r);let l="",c="",u=0;try{for(let f of e.body){let d=await this.executeStatement(f);l+=d.stdout,c+=d.stderr,u=d.exitCode}}catch(f){if(this.ctx.state.env=n,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,f instanceof W)throw f;if(f instanceof ze)return l+=f.stdout,c+=f.stderr,T(l,c,0);if(f instanceof he||f instanceof we)return l+=f.stdout,c+=f.stderr,T(l,c,0);if(f instanceof Q)return l+=f.stdout,c+=f.stderr,T(l,c,f.exitCode);if(f instanceof me)return l+=f.stdout,c+=f.stderr,T(l,c,f.exitCode);if(f instanceof Ue)throw f.stdout=l+f.stdout,f.stderr=c+f.stderr,f;return T(l,`${c}${re(f)}
750
- `,1)}return this.ctx.state.env=n,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,T(l,c,u)}async executeGroup(e,r=""){let n="",s="",i=0,o=this.ctx.state.groupStdin;r&&(this.ctx.state.groupStdin=r);try{for(let a of e.body){let l=await this.executeStatement(a);n+=l.stdout,s+=l.stderr,i=l.exitCode}}catch(a){if(this.ctx.state.groupStdin=o,a instanceof W)throw a;if(kr(a)||a instanceof Ue||a instanceof Q)throw a.prependOutput(n,s),a;return T(n,`${s}${re(a)}
751
- `,1)}return this.ctx.state.groupStdin=o,T(n,s,i)}async executeArithmeticCommand(e){try{let r=await Z(this.ctx,e.expression.expression);return ce(r!==0)}catch(r){return B(`bash: arithmetic expression: ${r.message}
752
- `)}}async executeConditionalCommand(e){try{let r=await it(this.ctx,e.expression);return ce(r)}catch(r){return B(`bash: conditional expression: ${r.message}
753
- `,2)}}};var ot={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3};function Bf(t){return t?{maxCallDepth:t.maxCallDepth??ot.maxCallDepth,maxCommandCount:t.maxCommandCount??ot.maxCommandCount,maxLoopIterations:t.maxLoopIterations??ot.maxLoopIterations,maxAwkIterations:t.maxAwkIterations??ot.maxAwkIterations,maxSedIterations:t.maxSedIterations??ot.maxSedIterations,maxJqIterations:t.maxJqIterations??ot.maxJqIterations,maxSqliteTimeoutMs:t.maxSqliteTimeoutMs??ot.maxSqliteTimeoutMs}:{...ot}}function Wf(t){try{let e=new URL(t);return{origin:e.origin,pathname:e.pathname,href:e.href}}catch{return null}}function Gy(t){let e=Wf(t);return e?{origin:e.origin,pathPrefix:e.pathname}:null}function qy(t,e){let r=Wf(t);if(!r)return!1;let n=Gy(e);return!n||r.origin!==n.origin?!1:n.pathPrefix==="/"||n.pathPrefix===""?!0:r.pathname.startsWith(n.pathPrefix)}function Ei(t,e){return!e||e.length===0?!1:e.some(r=>qy(t,r))}var Gt=class extends Error{constructor(e){super(`Network access denied: URL not in allow-list: ${e}`),this.name="NetworkAccessDeniedError"}},qt=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name="TooManyRedirectsError"}},Vt=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name="RedirectNotAllowedError"}},kn=class extends Error{constructor(e,r){super(`HTTP method '${e}' not allowed. Allowed methods: ${r.join(", ")}`),this.name="MethodNotAllowedError"}};var Vy=20,Ky=3e4,Zy=["GET","HEAD"],Qy=new Set(["GET","HEAD","OPTIONS"]),Xy=new Set([301,302,303,307,308]);function Si(t){let e=t.maxRedirects??Vy,r=t.timeoutMs??Ky,n=t.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:t.allowedMethods??Zy;function s(a){if(!t.dangerouslyAllowFullInternetAccess&&!Ei(a,t.allowedUrlPrefixes??[]))throw new Gt(a)}function i(a){if(t.dangerouslyAllowFullInternetAccess)return;let l=a.toUpperCase();if(!n.includes(l))throw new kn(l,n)}async function o(a,l={}){let c=l.method?.toUpperCase()??"GET";s(a),i(c);let u=a,f=0,d=l.followRedirects??!0,p=l.timeoutMs!==void 0?Math.min(l.timeoutMs,r):r;for(;;){let h=new AbortController,y=setTimeout(()=>h.abort(),p);try{let m={method:c,headers:l.headers,signal:h.signal,redirect:"manual"};l.body&&!Qy.has(c)&&(m.body=l.body);let w=await fetch(u,m);if(Xy.has(w.status)&&d){let b=w.headers.get("location");if(!b)return await Uf(w,u);let E=new URL(b,u).href;if(!t.dangerouslyAllowFullInternetAccess&&!Ei(E,t.allowedUrlPrefixes??[]))throw new Vt(E);if(f++,f>e)throw new qt(e);u=E;continue}return await Uf(w,u)}finally{clearTimeout(y)}}}return o}async function Uf(t,e){let r={};return t.headers.forEach((n,s)=>{r[s.toLowerCase()]=n}),{status:t.status,statusText:t.statusText,headers:r,body:await t.text(),url:e}}var Ci=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;logger;state;constructor(e={}){let r=e.fs??new yt(e.files);this.fs=r,this.useDefaultLayout=!e.cwd&&!e.files;let n=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s={HOME:this.useDefaultLayout?"/home/user":"/",PATH:"/bin:/usr/bin",IFS:`
754
- `,OSTYPE:"linux-gnu",MACHTYPE:"x86_64-pc-linux-gnu",HOSTTYPE:"x86_64",PWD:n,OLDPWD:n,...e.env};if(this.limits=Bf({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.network&&(this.secureFetch=Si(e.network)),this.sleepFn=e.sleep,this.logger=e.logger,this.state={env:s,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1},inCondition:!1,loopDepth:0},ku(r,this.useDefaultLayout),n!=="/"&&r instanceof yt)try{r.mkdirSync(n,{recursive:!0})}catch{}for(let i of yu(e.commands))this.registerCommand(i);if(e.network)for(let i of xu())this.registerCommand(i);if(e.customCommands)for(let i of e.customCommands)wu(i)?this.registerCommand(bu(i)):this.registerCommand(i)}registerCommand(e){this.commands.set(e.name,e);let r=this.fs;if(typeof r.writeFileSync=="function")try{r.writeFileSync(`/bin/${e.name}`,`#!/bin/bash
749
+ `,o=1);return _(s,i,o)}async executeSubshell(e,r=""){let n={...this.ctx.state.env},s=this.ctx.state.cwd,i=this.ctx.state.loopDepth,o=this.ctx.state.parentHasLoopContext;this.ctx.state.parentHasLoopContext=i>0,this.ctx.state.loopDepth=0;let a=this.ctx.state.groupStdin;r&&(this.ctx.state.groupStdin=r);let l="",c="",u=0;try{for(let f of e.body){let p=await this.executeStatement(f);l+=p.stdout,c+=p.stderr,u=p.exitCode}}catch(f){if(this.ctx.state.env=n,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,f instanceof j)throw f;if(f instanceof Ze)return l+=f.stdout,c+=f.stderr,_(l,c,0);if(f instanceof Ae||f instanceof Re)return l+=f.stdout,c+=f.stderr,_(l,c,0);if(f instanceof ie)return l+=f.stdout,c+=f.stderr,_(l,c,f.exitCode);if(f instanceof ke)return l+=f.stdout,c+=f.stderr,_(l,c,f.exitCode);if(f instanceof Ke)throw f.stdout=l+f.stdout,f.stderr=c+f.stderr,f;return _(l,`${c}${de(f)}
750
+ `,1)}return this.ctx.state.env=n,this.ctx.state.cwd=s,this.ctx.state.loopDepth=i,this.ctx.state.parentHasLoopContext=o,this.ctx.state.groupStdin=a,_(l,c,u)}async executeGroup(e,r=""){let n="",s="",i=0,o=this.ctx.state.groupStdin;r&&(this.ctx.state.groupStdin=r);try{for(let a of e.body){let l=await this.executeStatement(a);n+=l.stdout,s+=l.stderr,i=l.exitCode}}catch(a){if(this.ctx.state.groupStdin=o,a instanceof j)throw a;if(Dr(a)||a instanceof Ke||a instanceof ie)throw a.prependOutput(n,s),a;return _(n,`${s}${de(a)}
751
+ `,1)}return this.ctx.state.groupStdin=o,_(n,s,i)}async executeArithmeticCommand(e){try{let r=await te(this.ctx,e.expression.expression);return we(r!==0)}catch(r){return U(`bash: arithmetic expression: ${r.message}
752
+ `)}}async executeConditionalCommand(e){try{let r=await ft(this.ctx,e.expression);return we(r)}catch(r){return U(`bash: conditional expression: ${r.message}
753
+ `,2)}}};var pt={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3};function Vf(t){return t?{maxCallDepth:t.maxCallDepth??pt.maxCallDepth,maxCommandCount:t.maxCommandCount??pt.maxCommandCount,maxLoopIterations:t.maxLoopIterations??pt.maxLoopIterations,maxAwkIterations:t.maxAwkIterations??pt.maxAwkIterations,maxSedIterations:t.maxSedIterations??pt.maxSedIterations,maxJqIterations:t.maxJqIterations??pt.maxJqIterations,maxSqliteTimeoutMs:t.maxSqliteTimeoutMs??pt.maxSqliteTimeoutMs}:{...pt}}function Kf(t){try{let e=new URL(t);return{origin:e.origin,pathname:e.pathname,href:e.href}}catch{return null}}function Yy(t){let e=Kf(t);return e?{origin:e.origin,pathPrefix:e.pathname}:null}function ex(t,e){let r=Kf(t);if(!r)return!1;let n=Yy(e);return!n||r.origin!==n.origin?!1:n.pathPrefix==="/"||n.pathPrefix===""?!0:r.pathname.startsWith(n.pathPrefix)}function $i(t,e){return!e||e.length===0?!1:e.some(r=>ex(t,r))}var tr=class extends Error{constructor(e){super(`Network access denied: URL not in allow-list: ${e}`),this.name="NetworkAccessDeniedError"}},rr=class extends Error{constructor(e){super(`Too many redirects (max: ${e})`),this.name="TooManyRedirectsError"}},nr=class extends Error{constructor(e){super(`Redirect target not in allow-list: ${e}`),this.name="RedirectNotAllowedError"}},Dn=class extends Error{constructor(e,r){super(`HTTP method '${e}' not allowed. Allowed methods: ${r.join(", ")}`),this.name="MethodNotAllowedError"}};var tx=20,rx=3e4,nx=["GET","HEAD"],sx=new Set(["GET","HEAD","OPTIONS"]),ix=new Set([301,302,303,307,308]);function Ri(t){let e=t.maxRedirects??tx,r=t.timeoutMs??rx,n=t.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:t.allowedMethods??nx;function s(a){if(!t.dangerouslyAllowFullInternetAccess&&!$i(a,t.allowedUrlPrefixes??[]))throw new tr(a)}function i(a){if(t.dangerouslyAllowFullInternetAccess)return;let l=a.toUpperCase();if(!n.includes(l))throw new Dn(l,n)}async function o(a,l={}){let c=l.method?.toUpperCase()??"GET";s(a),i(c);let u=a,f=0,p=l.followRedirects??!0,d=l.timeoutMs!==void 0?Math.min(l.timeoutMs,r):r;for(;;){let h=new AbortController,m=setTimeout(()=>h.abort(),d);try{let g={method:c,headers:l.headers,signal:h.signal,redirect:"manual"};l.body&&!sx.has(c)&&(g.body=l.body);let w=await fetch(u,g);if(ix.has(w.status)&&p){let b=w.headers.get("location");if(!b)return await Zf(w,u);let E=new URL(b,u).href;if(!t.dangerouslyAllowFullInternetAccess&&!$i(E,t.allowedUrlPrefixes??[]))throw new nr(E);if(f++,f>e)throw new rr(e);u=E;continue}return await Zf(w,u)}finally{clearTimeout(m)}}}return o}async function Zf(t,e){let r={};return t.headers.forEach((n,s)=>{r[s.toLowerCase()]=n}),{status:t.status,statusText:t.statusText,headers:r,body:await t.text(),url:e}}var Pi=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;logger;state;constructor(e={}){let r=e.fs??new It(e.files);this.fs=r,this.useDefaultLayout=!e.cwd&&!e.files;let n=e.cwd||(this.useDefaultLayout?"/home/user":"/"),s={HOME:this.useDefaultLayout?"/home/user":"/",PATH:"/bin:/usr/bin",IFS:`
754
+ `,OSTYPE:"linux-gnu",MACHTYPE:"x86_64-pc-linux-gnu",HOSTTYPE:"x86_64",PWD:n,OLDPWD:n,...e.env};if(this.limits=Vf({...e.executionLimits,...e.maxCallDepth!==void 0&&{maxCallDepth:e.maxCallDepth},...e.maxCommandCount!==void 0&&{maxCommandCount:e.maxCommandCount},...e.maxLoopIterations!==void 0&&{maxLoopIterations:e.maxLoopIterations}}),e.network&&(this.secureFetch=Ri(e.network)),this.sleepFn=e.sleep,this.logger=e.logger,this.state={env:s,cwd:n,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1},inCondition:!1,loopDepth:0},Ou(r,this.useDefaultLayout),n!=="/"&&r instanceof It)try{r.mkdirSync(n,{recursive:!0})}catch{}for(let i of ku(e.commands))this.registerCommand(i);if(e.network)for(let i of Nu())this.registerCommand(i);if(e.customCommands)for(let i of e.customCommands)Iu(i)?this.registerCommand(vu(i)):this.registerCommand(i)}registerCommand(e){this.commands.set(e.name,e);let r=this.fs;if(typeof r.writeFileSync=="function")try{r.writeFileSync(`/bin/${e.name}`,`#!/bin/bash
755
755
  # Built-in command: ${e.name}
756
756
  `)}catch{}}logResult(e){return this.logger&&(e.stdout&&this.logger.debug("stdout",{output:e.stdout}),e.stderr&&this.logger.info("stderr",{output:e.stderr}),this.logger.info("exit",{exitCode:e.exitCode})),e}async exec(e,r){if(this.state.callDepth===0&&(this.state.commandCount=0),this.state.commandCount++,this.state.commandCount>this.limits.maxCommandCount)return{stdout:"",stderr:`bash: maximum command count (${this.limits.maxCommandCount}) exceeded (possible infinite loop). Increase with executionLimits.maxCommandCount option.
757
757
  `,exitCode:1,env:{...this.state.env,...r?.env}};if(!e.trim())return{stdout:"",stderr:"",exitCode:0,env:{...this.state.env,...r?.env}};this.logger?.info("exec",{command:e});let n=r?.cwd??this.state.cwd,s={...this.state,env:{...this.state.env,...r?.env,...r?.cwd?{PWD:r.cwd}:{}},cwd:n,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options}},i=e;r?.rawScript||(i=e.split(`
758
758
  `).map(a=>a.trimStart()).join(`
759
- `));try{let o=rt(i),a={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn},c=await new pr(a,s).executeScript(o);return this.logResult(c)}catch(o){if(o instanceof Q)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode,env:{...this.state.env,...r?.env}});if(o instanceof le)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:1,env:{...this.state.env,...r?.env}});if(o instanceof W)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:W.EXIT_CODE,env:{...this.state.env,...r?.env}});if(o.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${o.message}
759
+ `));try{let o=lt(i),a={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn},c=await new Cr(a,s).executeScript(o);return this.logResult(c)}catch(o){if(o instanceof ie)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode,env:{...this.state.env,...r?.env}});if(o instanceof xe)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:1,env:{...this.state.env,...r?.env}});if(o instanceof j)return this.logResult({stdout:o.stdout,stderr:o.stderr,exitCode:j.EXIT_CODE,env:{...this.state.env,...r?.env}});if(o.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${o.message}
760
760
  `,exitCode:2,env:{...this.state.env,...r?.env}});if(o instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${o.message}
761
- `,exitCode:1,env:{...this.state.env,...r?.env}});throw o}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,r){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),r)}getCwd(){return this.state.cwd}getEnv(){return{...this.state.env}}};export{Ci as Bash,yt as InMemoryFs,Gt as NetworkAccessDeniedError,Vt as RedirectNotAllowedError,qt as TooManyRedirectsError,Dg as defineCommand,Tg as getCommandNames,Lg as getNetworkCommandNames};
761
+ `,exitCode:1,env:{...this.state.env,...r?.env}});throw o}}async readFile(e){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,e))}async writeFile(e,r){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,e),r)}getCwd(){return this.state.cwd}getEnv(){return{...this.state.env}}};export{Pi as Bash,It as InMemoryFs,tr as NetworkAccessDeniedError,nr as RedirectNotAllowedError,rr as TooManyRedirectsError,Hg as defineCommand,jg as getCommandNames,zg as getNetworkCommandNames};
762
762
  /*! Bundled license information:
763
763
 
764
764
  ieee754/index.js: