just-bash 2.9.1 → 2.9.2

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.
@@ -1,6 +1,6 @@
1
1
  var xg=Object.create;var ko=Object.defineProperty;var Eg=Object.getOwnPropertyDescriptor;var Ag=Object.getOwnPropertyNames;var Sg=Object.getPrototypeOf,Cg=Object.prototype.hasOwnProperty;var I=(e,t)=>()=>(e&&(t=e(e=0)),t);var $s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Q=(e,t)=>{for(var n in t)ko(e,n,{get:t[n],enumerable:!0})},Ng=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ag(t))!Cg.call(e,s)&&s!==n&&ko(e,s,{get:()=>t[s],enumerable:!(r=Eg(t,s))||r.enumerable});return e};var eu=(e,t,n)=>(n=e!=null?xg(Sg(e)):{},Ng(t||!e||!e.__esModule?ko(n,"default",{value:e,enumerable:!0}):n,e));var tu={};Q(tu,{echoCommand:()=>vg});function kg(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"){if(n+1>=e.length){t+="\\";break}let r=e[n+1];switch(r){case"\\":t+="\\",n+=2;break;case"n":t+=`
2
2
  `,n+=2;break;case"t":t+=" ",n+=2;break;case"r":t+="\r",n+=2;break;case"a":t+="\x07",n+=2;break;case"b":t+="\b",n+=2;break;case"f":t+="\f",n+=2;break;case"v":t+="\v",n+=2;break;case"e":case"E":t+="\x1B",n+=2;break;case"c":return{output:t,stop:!0};case"0":{let s="",i=n+2;for(;i<e.length&&i<n+5&&/[0-7]/.test(e[i]);)s+=e[i],i++;if(s.length===0)t+="\0";else{let o=parseInt(s,8)%256;t+=String.fromCharCode(o)}n=i;break}case"x":{let s="",i=n+2;for(;i<e.length&&i<n+4&&/[0-9a-fA-F]/.test(e[i]);)s+=e[i],i++;if(s.length===0)t+="\\x",n+=2;else{let o=parseInt(s,16);t+=String.fromCharCode(o),n=i}break}case"u":{let s="",i=n+2;for(;i<e.length&&i<n+6&&/[0-9a-fA-F]/.test(e[i]);)s+=e[i],i++;if(s.length===0)t+="\\u",n+=2;else{let o=parseInt(s,16);t+=String.fromCodePoint(o),n=i}break}case"U":{let s="",i=n+2;for(;i<e.length&&i<n+10&&/[0-9a-fA-F]/.test(e[i]);)s+=e[i],i++;if(s.length===0)t+="\\U",n+=2;else{let o=parseInt(s,16);try{t+=String.fromCodePoint(o)}catch{t+=`\\U${s}`}n=i}break}default:t+=`\\${r}`,n+=2}}else t+=e[n],n++;return{output:t,stop:!1}}var vg,nu=I(()=>{"use strict";vg={name:"echo",async execute(e,t){let n=!1,r=t.xpgEcho??!1,s=0;for(;s<e.length;){let o=e[s];if(o==="-n")n=!0,s++;else if(o==="-e")r=!0,s++;else if(o==="-E")r=!1,s++;else if(o==="-ne"||o==="-en")n=!0,r=!0,s++;else break}let i=e.slice(s).join(" ");if(r){let o=kg(i);if(i=o.output,o.stop)return{stdout:i,stderr:"",exitCode:0}}return n||(i+=`
3
- `),{stdout:i,stderr:"",exitCode:0}}}});function F(e){let t=`${e.name} - ${e.summary}
3
+ `),{stdout:i,stderr:"",exitCode:0}}}});function M(e){let t=`${e.name} - ${e.summary}
4
4
 
5
5
  `;if(t+=`Usage: ${e.usage}
6
6
  `,e.description){if(t+=`
@@ -19,25 +19,25 @@ Examples:
19
19
  `}if(e.notes&&e.notes.length>0){t+=`
20
20
  Notes:
21
21
  `;for(let n of e.notes)t+=` ${n}
22
- `}return{stdout:t,stderr:"",exitCode:0}}function U(e){return e.includes("--help")}function X(e,t){return{stdout:"",stderr:t.startsWith("--")?`${e}: unrecognized option '${t}'
22
+ `}return{stdout:t,stderr:"",exitCode:0}}function F(e){return e.includes("--help")}function X(e,t){return{stdout:"",stderr:t.startsWith("--")?`${e}: unrecognized option '${t}'
23
23
  `:`${e}: invalid option -- '${t.replace(/^-/,"")}'
24
24
  `,exitCode:1}}var ne=I(()=>{"use strict"});function we(e,t,n){let r=new Map,s=new Map;for(let[l,c]of Object.entries(n)){let u={name:l,type:c.type};c.short&&r.set(c.short,u),c.long&&s.set(c.long,u)}let i=Object.create(null);for(let[l,c]of Object.entries(n))c.default!==void 0?i[l]=c.default:c.type==="boolean"&&(i[l]=!1);let o=[],a=!1;for(let l=0;l<t.length;l++){let c=t[l];if(a||!c.startsWith("-")||c==="-"){o.push(c);continue}if(c==="--"){a=!0;continue}if(c.startsWith("--")){let u=c.indexOf("="),f,h;u!==-1?(f=c.slice(2,u),h=c.slice(u+1)):f=c.slice(2);let p=s.get(f);if(!p)return{ok:!1,error:X(e,c)};let{name:m,type:d}=p;if(d==="boolean")i[m]=!0;else{if(h===void 0){if(l+1>=t.length)return{ok:!1,error:{stdout:"",stderr:`${e}: option '--${f}' requires an argument
25
25
  `,exitCode:1}};h=t[++l]}i[m]=d==="number"?parseInt(h,10):h}}else{let u=c.slice(1);for(let f=0;f<u.length;f++){let h=u[f],p=r.get(h);if(!p)return{ok:!1,error:X(e,`-${h}`)};let{name:m,type:d}=p;if(d==="boolean")i[m]=!0;else{let g;if(f+1<u.length)g=u.slice(f+1);else if(l+1<t.length)g=t[++l];else return{ok:!1,error:{stdout:"",stderr:`${e}: option requires an argument -- '${h}'
26
26
  `,exitCode:1}};i[m]=d==="number"?parseInt(g,10):g;break}}}}return{ok:!0,result:{flags:i,positional:o}}}var qe=I(()=>{"use strict";ne()});var or=I(()=>{"use strict"});async function Bn(e,t,n){let{cmdName:r,allowStdinMarker:s=!0,stopOnError:i=!1,batchSize:o=100}=n;if(t.length===0)return{files:[{filename:"",content:e.stdin}],stderr:"",exitCode:0};let a=[],l="",c=0;for(let u=0;u<t.length;u+=o){let f=t.slice(u,u+o),h=await Promise.all(f.map(async p=>{if(s&&p==="-")return{filename:"-",content:e.stdin,error:null};try{let m=e.fs.resolvePath(e.cwd,p),d=await e.fs.readFile(m,"binary");return{filename:p,content:d,error:null}}catch{return{filename:p,content:"",error:`${r}: ${p}: No such file or directory
27
- `}}}));for(let p of h)if(p.error){if(l+=p.error,c=1,i)return{files:a,stderr:l,exitCode:c}}else a.push({filename:p.filename,content:p.content})}return{files:a,stderr:l,exitCode:c}}async function ar(e,t,n){let r=await Bn(e,t,{...n,stopOnError:!0});return r.exitCode!==0?{ok:!1,error:{stdout:"",stderr:r.stderr,exitCode:r.exitCode}}:{ok:!0,content:r.files.map(i=>i.content).join("")}}var Hn=I(()=>{"use strict";or()});var ru={};Q(ru,{catCommand:()=>Og});function $g(e,t){let n=e.split(`
27
+ `}}}));for(let p of h)if(p.error){if(l+=p.error,c=1,i)return{files:a,stderr:l,exitCode:c}}else a.push({filename:p.filename,content:p.content})}return{files:a,stderr:l,exitCode:c}}async function ar(e,t,n){let r=await Bn(e,t,{...n,stopOnError:!0});return r.exitCode!==0?{ok:!1,error:{stdout:"",stderr:r.stderr,exitCode:r.exitCode}}:{ok:!0,content:r.files.map(i=>i.content).join("")}}var Hn=I(()=>{"use strict";or()});var ru={};Q(ru,{catCommand:()=>Rg});function $g(e,t){let n=e.split(`
28
28
  `),r=e.endsWith(`
29
29
  `),s=r?n.slice(0,-1):n;return{content:s.map((o,a)=>`${String(t+a).padStart(6," ")} ${o}`).join(`
30
30
  `)+(r?`
31
- `:""),nextLineNumber:t+s.length}}var Ig,Rg,Og,su=I(()=>{"use strict";qe();Hn();ne();Ig={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"]},Rg={number:{short:"n",long:"number",type:"boolean"}},Og={name:"cat",async execute(e,t){if(U(e))return F(Ig);let n=we("cat",e,Rg);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await Bn(t,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files)if(r){let c=$g(l,a);o+=c.content,a=c.nextLineNumber}else o+=l;return{stdout:o,stderr:i.stderr,exitCode:i.exitCode}}}});function Fe(e){return e instanceof Error?e.message:String(e)}var Mt=I(()=>{"use strict"});function Ts(e,t,n){let r=e;n>=0&&r.length>n&&(r=r.slice(0,n));let s=Math.abs(t);return s>r.length&&(t<0?r=r.padEnd(s," "):r=r.padStart(s," ")),r}function iu(e,t){let n=t,r=0,s=-1,i=!1;for(n<e.length&&e[n]==="-"&&(i=!0,n++);n<e.length&&/\d/.test(e[n]);)r=r*10+parseInt(e[n],10),n++;if(n<e.length&&e[n]===".")for(n++,s=0;n<e.length&&/\d/.test(e[n]);)s=s*10+parseInt(e[n],10),n++;return i&&r>0&&(r=-r),[r,s,n-t]}function Ps(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length)switch(e[n+1]){case"n":t+=`
31
+ `:""),nextLineNumber:t+s.length}}var Ig,Og,Rg,su=I(()=>{"use strict";qe();Hn();ne();Ig={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"]},Og={number:{short:"n",long:"number",type:"boolean"}},Rg={name:"cat",async execute(e,t){if(F(e))return M(Ig);let n=we("cat",e,Og);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await Bn(t,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),o="",a=1;for(let{content:l}of i.files)if(r){let c=$g(l,a);o+=c.content,a=c.nextLineNumber}else o+=l;return{stdout:o,stderr:i.stderr,exitCode:i.exitCode}}}});function Fe(e){return e instanceof Error?e.message:String(e)}var Mt=I(()=>{"use strict"});function Ts(e,t,n){let r=e;n>=0&&r.length>n&&(r=r.slice(0,n));let s=Math.abs(t);return s>r.length&&(t<0?r=r.padEnd(s," "):r=r.padStart(s," ")),r}function iu(e,t){let n=t,r=0,s=-1,i=!1;for(n<e.length&&e[n]==="-"&&(i=!0,n++);n<e.length&&/\d/.test(e[n]);)r=r*10+parseInt(e[n],10),n++;if(n<e.length&&e[n]===".")for(n++,s=0;n<e.length&&/\d/.test(e[n]);)s=s*10+parseInt(e[n],10),n++;return i&&r>0&&(r=-r),[r,s,n-t]}function Ps(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length)switch(e[n+1]){case"n":t+=`
32
32
  `,n+=2;break;case"t":t+=" ",n+=2;break;case"r":t+="\r",n+=2;break;case"\\":t+="\\",n+=2;break;case"a":t+="\x07",n+=2;break;case"b":t+="\b",n+=2;break;case"f":t+="\f",n+=2;break;case"v":t+="\v",n+=2;break;case"e":case"E":t+="\x1B",n+=2;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<e.length&&i<n+4&&/[0-7]/.test(e[i]);)s+=e[i],i++;t+=String.fromCharCode(parseInt(s,8)),n=i;break}case"x":{let s=[],i=n;for(;i+3<e.length&&e[i]==="\\"&&e[i+1]==="x"&&/[0-9a-fA-F]{2}/.test(e.slice(i+2,i+4));)s.push(parseInt(e.slice(i+2,i+4),16)),i+=4;if(s.length>0){try{let o=new TextDecoder("utf-8",{fatal:!0});t+=o.decode(new Uint8Array(s))}catch{for(let o of s)t+=String.fromCharCode(o)}n=i}else t+=e[n],n++;break}case"u":{let s="",i=n+2;for(;i<e.length&&i<n+6&&/[0-9a-fA-F]/.test(e[i]);)s+=e[i],i++;s?(t+=String.fromCodePoint(parseInt(s,16)),n=i):(t+="\\u",n+=2);break}case"U":{let s="",i=n+2;for(;i<e.length&&i<n+10&&/[0-9a-fA-F]/.test(e[i]);)s+=e[i],i++;s?(t+=String.fromCodePoint(parseInt(s,16)),n=i):(t+="\\U",n+=2);break}default:t+=e[n],n++}else t+=e[n],n++;return t}var vo=I(()=>{"use strict"});function lu(e,t,n){let r=new Date(t*1e3),s="",i=0;for(;i<e.length;)if(e[i]==="%"&&i+1<e.length){let o=e[i+1],a=Pg(r,o,n);a!==null?(s+=a,i+=2):(s+=e[i],i++)}else s+=e[i],i++;return s}function Tg(e,t){let n={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",weekday:"short",hour12:!1,timeZone:t};try{let s=new Intl.DateTimeFormat("en-US",n).formatToParts(e),i=l=>s.find(c=>c.type===l)?.value??"",o=new Map([["Sun",0],["Mon",1],["Tue",2],["Wed",3],["Thu",4],["Fri",5],["Sat",6]]),a=i("weekday");return{year:Number.parseInt(i("year"),10)||e.getFullYear(),month:Number.parseInt(i("month"),10)||e.getMonth()+1,day:Number.parseInt(i("day"),10)||e.getDate(),hour:Number.parseInt(i("hour"),10)||e.getHours(),minute:Number.parseInt(i("minute"),10)||e.getMinutes(),second:Number.parseInt(i("second"),10)||e.getSeconds(),weekday:o.get(a)??e.getDay()}}catch{return{year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate(),hour:e.getHours(),minute:e.getMinutes(),second:e.getSeconds(),weekday:e.getDay()}}}function Pg(e,t,n){let r=Tg(e,n),s=(l,c=2)=>String(l).padStart(c,"0"),i=cu(r.year,r.month,r.day),o=ou(r.year,r.month,r.day,r.weekday,0),a=ou(r.year,r.month,r.day,r.weekday,1);switch(t){case"a":return["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][r.weekday];case"A":return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][r.weekday];case"b":case"h":return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.month-1];case"B":return["January","February","March","April","May","June","July","August","September","October","November","December"][r.month-1];case"c":return`${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][r.weekday]} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.month-1]} ${String(r.day).padStart(2," ")} ${s(r.hour)}:${s(r.minute)}:${s(r.second)} ${r.year}`;case"C":return s(Math.floor(r.year/100));case"d":return s(r.day);case"D":return`${s(r.month)}/${s(r.day)}/${s(r.year%100)}`;case"e":return String(r.day).padStart(2," ");case"F":return`${r.year}-${s(r.month)}-${s(r.day)}`;case"g":return s(au(r.year,r.month,r.day)%100);case"G":return String(au(r.year,r.month,r.day));case"H":return s(r.hour);case"I":return s(r.hour%12||12);case"j":return String(i).padStart(3,"0");case"k":return String(r.hour).padStart(2," ");case"l":return String(r.hour%12||12).padStart(2," ");case"m":return s(r.month);case"M":return s(r.minute);case"n":return`
33
- `;case"N":return"000000000";case"p":return r.hour<12?"AM":"PM";case"P":return r.hour<12?"am":"pm";case"r":return`${s(r.hour%12||12)}:${s(r.minute)}:${s(r.second)} ${r.hour<12?"AM":"PM"}`;case"R":return`${s(r.hour)}:${s(r.minute)}`;case"s":return String(Math.floor(e.getTime()/1e3));case"S":return s(r.second);case"t":return" ";case"T":return`${s(r.hour)}:${s(r.minute)}:${s(r.second)}`;case"u":return String(r.weekday===0?7:r.weekday);case"U":return s(o);case"V":return s(_g(r.year,r.month,r.day));case"w":return String(r.weekday);case"W":return s(a);case"x":return`${s(r.month)}/${s(r.day)}/${s(r.year%100)}`;case"X":return`${s(r.hour)}:${s(r.minute)}:${s(r.second)}`;case"y":return s(r.year%100);case"Y":return String(r.year);case"z":return Dg(e,n);case"Z":return Lg(e,n);case"%":return"%";default:return null}}function Dg(e,t){if(!t){let o=-e.getTimezoneOffset(),a=o>=0?"+":"-",l=Math.floor(Math.abs(o)/60),c=Math.abs(o)%60;return`${a}${String(l).padStart(2,"0")}${String(c).padStart(2,"0")}`}try{let l=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).formatToParts(e).find(c=>c.type==="timeZoneName");if(l){let c=l.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(c)return`${c[1]}${c[2]}${c[3]}`;if(l.value==="GMT"||l.value==="UTC")return"+0000"}}catch{}let n=-e.getTimezoneOffset(),r=n>=0?"+":"-",s=Math.floor(Math.abs(n)/60),i=Math.abs(n)%60;return`${r}${String(s).padStart(2,"0")}${String(i).padStart(2,"0")}`}function Lg(e,t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(i=>i.type==="timeZoneName")?.value??"UTC"}catch{return"UTC"}}function cu(e,t,n){let r=[31,28,31,30,31,30,31,31,30,31,30,31];(e%4===0&&e%100!==0||e%400===0)&&(r[1]=29);let i=n;for(let o=0;o<t-1;o++)i+=r[o];return i}function ou(e,t,n,r,s){let i=cu(e,t,n),l=(new Date(e,0,1).getDay()-s+7)%7,c=(r-s+7)%7,u=i-1+l;return Math.floor((u-c+7)/7)}function _g(e,t,n){let r=new Date(e,t-1,n,12,0,0);r.setDate(r.getDate()+3-(r.getDay()+6)%7);let s=new Date(r.getFullYear(),0,4);s.setDate(s.getDate()+3-(s.getDay()+6)%7);let i=r.getTime()-s.getTime();return 1+Math.round(i/(10080*60*1e3))}function au(e,t,n){let r=new Date(e,t-1,n,12,0,0);return r.setDate(r.getDate()+3-(r.getDay()+6)%7),r.getFullYear()}var uu=I(()=>{"use strict"});var hu={};Q(hu,{printfCommand:()=>Ug});import{sprintf as lr}from"sprintf-js";function Mg(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<e.length&&(e[n+1]&192)===128&&r>=194){let s=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(s),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let s=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(s>=55296&&s<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(s),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128&&(e[n+3]&192)===128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let s=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(s>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(s),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function Wg(e,t,n,r){let s="",i=0,o=0,a=!1,l="";for(;i<e.length;)if(e[i]==="%"&&i+1<e.length){let c=i;if(i++,e[i]==="%"){s+="%",i++;continue}let u=e.slice(c).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(u){let S=u[1]?parseInt(u[1],10):0,C=u[2]?parseInt(u[2],10):-1,$=u[3],M=u[0],_=t[n+o]||"";o++;let B;_===""||_==="-1"||_==="-2"?B=Math.floor(Date.now()/1e3):B=parseInt(_,10)||0;let v=lu($,B,r);if(C>=0&&v.length>C&&(v=v.slice(0,C)),S!==0){let k=Math.abs(S);v.length<k&&(S<0?v=v.padEnd(k," "):v=v.padStart(k," "))}s+=v,i=c+M.length;continue}for(;i<e.length&&"+-0 #'".includes(e[i]);)i++;let f=!1;if(e[i]==="*")f=!0,i++;else for(;i<e.length&&/\d/.test(e[i]);)i++;let h=!1;if(e[i]===".")if(i++,e[i]==="*")h=!0,i++;else for(;i<e.length&&/\d/.test(e[i]);)i++;i<e.length&&"hlL".includes(e[i])&&i++;let p=e[i]||"";i++;let d=e.slice(c,i);if(f){let S=parseInt(t[n+o]||"0",10);o++,d=d.replace("*",String(S))}if(h){let S=parseInt(t[n+o]||"0",10);o++,d=d.replace(".*",`.${S}`)}let g=t[n+o]||"";o++;let{value:y,parseError:w,parseErrMsg:b,stopped:x}=Bg(d,p,g);if(s+=y,w&&(a=!0,b&&(l=b)),x)return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!0}}else s+=e[i],i++;return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!1}}function Bg(e,t,n){let r=!1,s="";switch(t){case"d":case"i":{let i=Ds(n);return r=Qt,r&&(s=`printf: ${n}: invalid number
33
+ `;case"N":return"000000000";case"p":return r.hour<12?"AM":"PM";case"P":return r.hour<12?"am":"pm";case"r":return`${s(r.hour%12||12)}:${s(r.minute)}:${s(r.second)} ${r.hour<12?"AM":"PM"}`;case"R":return`${s(r.hour)}:${s(r.minute)}`;case"s":return String(Math.floor(e.getTime()/1e3));case"S":return s(r.second);case"t":return" ";case"T":return`${s(r.hour)}:${s(r.minute)}:${s(r.second)}`;case"u":return String(r.weekday===0?7:r.weekday);case"U":return s(o);case"V":return s(_g(r.year,r.month,r.day));case"w":return String(r.weekday);case"W":return s(a);case"x":return`${s(r.month)}/${s(r.day)}/${s(r.year%100)}`;case"X":return`${s(r.hour)}:${s(r.minute)}:${s(r.second)}`;case"y":return s(r.year%100);case"Y":return String(r.year);case"z":return Dg(e,n);case"Z":return Lg(e,n);case"%":return"%";default:return null}}function Dg(e,t){if(!t){let o=-e.getTimezoneOffset(),a=o>=0?"+":"-",l=Math.floor(Math.abs(o)/60),c=Math.abs(o)%60;return`${a}${String(l).padStart(2,"0")}${String(c).padStart(2,"0")}`}try{let l=new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"longOffset"}).formatToParts(e).find(c=>c.type==="timeZoneName");if(l){let c=l.value.match(/GMT([+-])(\d{2}):(\d{2})/);if(c)return`${c[1]}${c[2]}${c[3]}`;if(l.value==="GMT"||l.value==="UTC")return"+0000"}}catch{}let n=-e.getTimezoneOffset(),r=n>=0?"+":"-",s=Math.floor(Math.abs(n)/60),i=Math.abs(n)%60;return`${r}${String(s).padStart(2,"0")}${String(i).padStart(2,"0")}`}function Lg(e,t){try{return new Intl.DateTimeFormat("en-US",{timeZone:t,timeZoneName:"short"}).formatToParts(e).find(i=>i.type==="timeZoneName")?.value??"UTC"}catch{return"UTC"}}function cu(e,t,n){let r=[31,28,31,30,31,30,31,31,30,31,30,31];(e%4===0&&e%100!==0||e%400===0)&&(r[1]=29);let i=n;for(let o=0;o<t-1;o++)i+=r[o];return i}function ou(e,t,n,r,s){let i=cu(e,t,n),l=(new Date(e,0,1).getDay()-s+7)%7,c=(r-s+7)%7,u=i-1+l;return Math.floor((u-c+7)/7)}function _g(e,t,n){let r=new Date(e,t-1,n,12,0,0);r.setDate(r.getDate()+3-(r.getDay()+6)%7);let s=new Date(r.getFullYear(),0,4);s.setDate(s.getDate()+3-(s.getDay()+6)%7);let i=r.getTime()-s.getTime();return 1+Math.round(i/(10080*60*1e3))}function au(e,t,n){let r=new Date(e,t-1,n,12,0,0);return r.setDate(r.getDate()+3-(r.getDay()+6)%7),r.getFullYear()}var uu=I(()=>{"use strict"});var hu={};Q(hu,{printfCommand:()=>Ug});import{sprintf as lr}from"sprintf-js";function Mg(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<e.length&&(e[n+1]&192)===128&&r>=194){let s=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(s),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let s=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(s>=55296&&s<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(s),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128&&(e[n+3]&192)===128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let s=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(s>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(s),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function Wg(e,t,n,r){let s="",i=0,o=0,a=!1,l="";for(;i<e.length;)if(e[i]==="%"&&i+1<e.length){let c=i;if(i++,e[i]==="%"){s+="%",i++;continue}let u=e.slice(c).match(/^%(-?\d*)(?:\.(\d+))?\(([^)]*)\)T/);if(u){let S=u[1]?parseInt(u[1],10):0,C=u[2]?parseInt(u[2],10):-1,R=u[3],U=u[0],L=t[n+o]||"";o++;let B;L===""||L==="-1"||L==="-2"?B=Math.floor(Date.now()/1e3):B=parseInt(L,10)||0;let v=lu(R,B,r);if(C>=0&&v.length>C&&(v=v.slice(0,C)),S!==0){let k=Math.abs(S);v.length<k&&(S<0?v=v.padEnd(k," "):v=v.padStart(k," "))}s+=v,i=c+U.length;continue}for(;i<e.length&&"+-0 #'".includes(e[i]);)i++;let f=!1;if(e[i]==="*")f=!0,i++;else for(;i<e.length&&/\d/.test(e[i]);)i++;let h=!1;if(e[i]===".")if(i++,e[i]==="*")h=!0,i++;else for(;i<e.length&&/\d/.test(e[i]);)i++;i<e.length&&"hlL".includes(e[i])&&i++;let p=e[i]||"";i++;let d=e.slice(c,i);if(f){let S=parseInt(t[n+o]||"0",10);o++,d=d.replace("*",String(S))}if(h){let S=parseInt(t[n+o]||"0",10);o++,d=d.replace(".*",`.${S}`)}let g=t[n+o]||"";o++;let{value:y,parseError:w,parseErrMsg:b,stopped:x}=Bg(d,p,g);if(s+=y,w&&(a=!0,b&&(l=b)),x)return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!0}}else s+=e[i],i++;return{result:s,argsConsumed:o,error:a,errMsg:l,stopped:!1}}function Bg(e,t,n){let r=!1,s="";switch(t){case"d":case"i":{let i=Ds(n);return r=Qt,r&&(s=`printf: ${n}: invalid number
34
34
  `),{value:fu(e,i),parseError:r,parseErrMsg:s}}case"o":{let i=Ds(n);return r=Qt,r&&(s=`printf: ${n}: invalid number
35
35
  `),{value:Hg(e,i),parseError:r,parseErrMsg:s}}case"u":{let i=Ds(n);r=Qt,r&&(s=`printf: ${n}: invalid number
36
36
  `);let o=i<0?i>>>0:i;return{value:fu(e.replace("u","d"),o),parseError:r,parseErrMsg:s}}case"x":case"X":{let i=Ds(n);return r=Qt,r&&(s=`printf: ${n}: invalid number
37
37
  `),{value:zg(e,i),parseError:r,parseErrMsg:s}}case"e":case"E":case"f":case"F":case"g":case"G":{let i=parseFloat(n)||0;return{value:qg(e,t,i),parseError:!1,parseErrMsg:""}}case"c":{if(n==="")return{value:"",parseError:!1,parseErrMsg:""};let a=new TextEncoder().encode(n)[0];return{value:String.fromCharCode(a),parseError:!1,parseErrMsg:""}}case"s":return{value:Gg(e,n),parseError:!1,parseErrMsg:""};case"q":return{value:Vg(e,n),parseError:!1,parseErrMsg:""};case"b":{let i=Zg(n);return{value:i.value,parseError:!1,parseErrMsg:"",stopped:i.stopped}}default:try{return{value:lr(e,n),parseError:!1,parseErrMsg:""}}catch{return{value:"",parseError:!0,parseErrMsg:`printf: [sprintf] unexpected placeholder
38
38
  `}}}}function Ds(e){Qt=!1;let t=e.trimStart(),n=t!==t.trimEnd();if(e=t.trimEnd(),e.startsWith("'")&&e.length>=2||e.startsWith('"')&&e.length>=2)return e.charCodeAt(1);if(e.startsWith("\\'")&&e.length>=3||e.startsWith('\\"')&&e.length>=3)return e.charCodeAt(2);if(e.startsWith("+")&&(e=e.slice(1)),e.startsWith("0x")||e.startsWith("0X")){let r=parseInt(e,16);return Number.isNaN(r)?(Qt=!0,0):(n&&(Qt=!0),r)}if(e.startsWith("0")&&e.length>1&&/^-?0[0-7]+$/.test(e))return n&&(Qt=!0),parseInt(e,8)||0;if(/^\d+#/.test(e)){Qt=!0;let r=e.match(/^(\d+)#/);return r?parseInt(r[1],10):0}if(e!==""&&!/^-?\d+$/.test(e)){Qt=!0;let r=parseInt(e,10);return Number.isNaN(r)?0:r}return n&&(Qt=!0),parseInt(e,10)||0}function fu(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[diu]$/);if(!n)return lr(e.replace(/\.\d*/,""),t);let r=n[1]||"",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=t<0,a=Math.abs(t),l=String(a);i>=0&&(l=l.padStart(i,"0"));let c="";o?c="-":r.includes("+")?c="+":r.includes(" ")&&(c=" ");let u=c+l;return s>u.length&&(r.includes("-")?u=u.padEnd(s," "):r.includes("0")&&i<0?u=c+l.padStart(s-c.length,"0"):u=u.padStart(s," ")),u}function Hg(e,t){let n=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?o$/);if(!n)return lr(e,t);let r=n[1]||"",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=Math.abs(t).toString(8);i>=0&&(o=o.padStart(i,"0")),r.includes("#")&&!o.startsWith("0")&&(o=`0${o}`);let a=o;return s>a.length&&(r.includes("-")?a=a.padEnd(s," "):r.includes("0")&&i<0?a=a.padStart(s,"0"):a=a.padStart(s," ")),a}function zg(e,t){let n=e.includes("X"),r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[xX]$/);if(!r)return lr(e,t);let s=r[1]||"",i=r[2]?parseInt(r[2],10):0,o=r[3]!==void 0?r[4]?parseInt(r[4],10):0:-1,a=Math.abs(t).toString(16);n&&(a=a.toUpperCase()),o>=0&&(a=a.padStart(o,"0"));let l="";s.includes("#")&&t!==0&&(l=n?"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 jg(e){if(e==="")return"''";if(/^[a-zA-Z0-9_./-]+$/.test(e))return e;if(/[\x00-\x1f\x7f-\xff]/.test(e)){let r="$'";for(let s of e){let i=s.charCodeAt(0);s==="'"?r+="\\'":s==="\\"?r+="\\\\":s===`
39
39
  `?r+="\\n":s===" "?r+="\\t":s==="\r"?r+="\\r":s==="\x07"?r+="\\a":s==="\b"?r+="\\b":s==="\f"?r+="\\f":s==="\v"?r+="\\v":s==="\x1B"?r+="\\E":i<32||i>=127&&i<=255?r+=`\\${i.toString(8).padStart(3,"0")}`:s==='"'?r+='\\"':r+=s}return r+="'",r}let n="";for(let r of e)" |&;<>()$`\\\"'*?[#~=%!{}".includes(r)?n+=`\\${r}`:n+=r;return n}function Gg(e,t){let n=e.match(/^%(-?)(\d*)(\.(\d*))?s$/);if(!n)return lr(e.replace(/0+(?=\d)/,""),t);let r=n[1]==="-",s=n[2]?parseInt(n[2],10):0,i=n[3]!==void 0?n[4]?parseInt(n[4],10):0:-1,o=r?-s:s;return Ts(t,o,i)}function Vg(e,t){let n=jg(t),r=e.match(/^%(-?)(\d*)q$/);if(!r)return n;let s=r[1]==="-",i=r[2]?parseInt(r[2],10):0,o=n;return i>o.length&&(s?o=o.padEnd(i," "):o=o.padStart(i," ")),o}function qg(e,t,n){let r=e.match(/^%([- +#0']*)(\d*)(\.(\d*))?[eEfFgG]$/);if(!r)return lr(e,n);let s=r[1]||"",i=r[2]?parseInt(r[2],10):0,o=r[3]!==void 0?r[4]?parseInt(r[4],10):0:6,a,l=t.toLowerCase();if(l==="e"?(a=n.toExponential(o),a=a.replace(/e([+-])(\d)$/,"e$10$2"),t==="E"&&(a=a.toUpperCase())):l==="f"?(a=n.toFixed(o),s.includes("#")&&o===0&&!a.includes(".")&&(a+=".")):l==="g"?(a=n.toPrecision(o||1),s.includes("#")||(a=a.replace(/\.?0+$/,""),a=a.replace(/\.?0+e/,"e")),a=a.replace(/e([+-])(\d)$/,"e$10$2"),t==="G"&&(a=a.toUpperCase())):a=n.toString(),n>=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 Zg(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length)switch(e[n+1]){case"n":t+=`
40
- `,n+=2;break;case"t":t+=" ",n+=2;break;case"r":t+="\r",n+=2;break;case"\\":t+="\\",n+=2;break;case"a":t+="\x07",n+=2;break;case"b":t+="\b",n+=2;break;case"f":t+="\f",n+=2;break;case"v":t+="\v",n+=2;break;case"c":return{value:t,stopped:!0};case"x":{let s=[],i=n;for(;i+1<e.length&&e[i]==="\\"&&e[i+1]==="x";){let o="",a=i+2;for(;a<e.length&&a<i+4&&/[0-9a-fA-F]/.test(e[a]);)o+=e[a],a++;if(o)s.push(parseInt(o,16)),i=a;else break}s.length>0?(t+=Mg(s),n=i):(t+="\\x",n+=2);break}case"u":{let s="",i=n+2;for(;i<e.length&&i<n+6&&/[0-9a-fA-F]/.test(e[i]);)s+=e[i],i++;s?(t+=String.fromCodePoint(parseInt(s,16)),n=i):(t+="\\u",n+=2);break}case"0":{let s="",i=n+2;for(;i<e.length&&i<n+5&&/[0-7]/.test(e[i]);)s+=e[i],i++;s?t+=String.fromCharCode(parseInt(s,8)):t+="\0",n=i;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<e.length&&i<n+4&&/[0-7]/.test(e[i]);)s+=e[i],i++;t+=String.fromCharCode(parseInt(s,8)),n=i;break}default:t+=e[n],n++}else t+=e[n],n++;return{value:t,stopped:!1}}var Fg,Ug,Qt,pu=I(()=>{"use strict";Mt();ne();vo();uu();Fg={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)"]},Ug={name:"printf",async execute(e,t){if(U(e))return F(Fg);if(e.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
40
+ `,n+=2;break;case"t":t+=" ",n+=2;break;case"r":t+="\r",n+=2;break;case"\\":t+="\\",n+=2;break;case"a":t+="\x07",n+=2;break;case"b":t+="\b",n+=2;break;case"f":t+="\f",n+=2;break;case"v":t+="\v",n+=2;break;case"c":return{value:t,stopped:!0};case"x":{let s=[],i=n;for(;i+1<e.length&&e[i]==="\\"&&e[i+1]==="x";){let o="",a=i+2;for(;a<e.length&&a<i+4&&/[0-9a-fA-F]/.test(e[a]);)o+=e[a],a++;if(o)s.push(parseInt(o,16)),i=a;else break}s.length>0?(t+=Mg(s),n=i):(t+="\\x",n+=2);break}case"u":{let s="",i=n+2;for(;i<e.length&&i<n+6&&/[0-9a-fA-F]/.test(e[i]);)s+=e[i],i++;s?(t+=String.fromCodePoint(parseInt(s,16)),n=i):(t+="\\u",n+=2);break}case"0":{let s="",i=n+2;for(;i<e.length&&i<n+5&&/[0-7]/.test(e[i]);)s+=e[i],i++;s?t+=String.fromCharCode(parseInt(s,8)):t+="\0",n=i;break}case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let s="",i=n+1;for(;i<e.length&&i<n+4&&/[0-7]/.test(e[i]);)s+=e[i],i++;t+=String.fromCharCode(parseInt(s,8)),n=i;break}default:t+=e[n],n++}else t+=e[n],n++;return{value:t,stopped:!1}}var Fg,Ug,Qt,pu=I(()=>{"use strict";Mt();ne();vo();uu();Fg={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)"]},Ug={name:"printf",async execute(e,t){if(F(e))return M(Fg);if(e.length===0)return{stdout:"",stderr:`printf: usage: printf format [arguments]
41
41
  `,exitCode:2};let n=null,r=0;for(;r<e.length;){let o=e[r];if(o==="--"){r++;break}if(o==="-v"){if(r+1>=e.length)return{stdout:"",stderr:`printf: -v: option requires an argument
42
42
  `,exitCode:1};if(n=e[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(\[[^\]]+\])?$/.test(n))return{stdout:"",stderr:`printf: \`${n}': not a valid identifier
43
43
  `,exitCode:2};r+=2}else{if(o.startsWith("-")&&o!=="-")break;break}}if(r>=e.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
@@ -52,16 +52,16 @@ Notes:
52
52
  `,stderr:"",exitCode:0}}let m=await t.fs.readdir(h);if(f||(m=m.filter(g=>!g.startsWith("."))),c){let g=[];for(let y of m){let w=h==="/"?`/${y}`:`${h}/${y}`;try{let b=await t.fs.stat(w);g.push({name:y,size:b.size??0})}catch{g.push({name:y,size:0})}}g.sort((y,w)=>w.size-y.size),m=g.map(y=>y.name)}else m.sort();n&&(m=[".","..",...m]),a&&m.reverse();let d="";if((i||o)&&(d+=`${e}:
53
53
  `),s){d+=`total ${m.length}
54
54
  `;let g=m.filter(x=>x==="."||x===".."),y=m.filter(x=>x!=="."&&x!=="..");for(let x of g)d+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${x}
55
- `;let w=[];for(let x=0;x<y.length;x+=100){let S=y.slice(x,x+100),C=await Promise.all(S.map(async $=>{let M=h==="/"?`/${$}`:`${h}/${$}`;try{let _=await t.fs.stat(M),B=_.isDirectory?"drwxr-xr-x":"-rw-r--r--",v=_.isDirectory?"/":"",k=_.size??0,T=l?Ls(k).padStart(5):String(k).padStart(5),R=_.mtime??new Date(0),O=_s(R);return{name:$,line:`${B} 1 user user ${T} ${O} ${$}${v}
56
- `}}catch{return{name:$,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${$}
55
+ `;let w=[];for(let x=0;x<y.length;x+=100){let S=y.slice(x,x+100),C=await Promise.all(S.map(async R=>{let U=h==="/"?`/${R}`:`${h}/${R}`;try{let L=await t.fs.stat(U),B=L.isDirectory?"drwxr-xr-x":"-rw-r--r--",v=L.isDirectory?"/":"",k=L.size??0,T=l?Ls(k).padStart(5):String(k).padStart(5),O=L.mtime??new Date(0),$=_s(O);return{name:R,line:`${B} 1 user user ${T} ${$} ${R}${v}
56
+ `}}catch{return{name:R,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${R}
57
57
  `}}}));w.push(...C)}let b=new Map(y.map((x,S)=>[x,S]));w.sort((x,S)=>(b.get(x.name)??0)-(b.get(S.name)??0));for(let{line:x}of w)d+=x}else d+=m.join(`
58
58
  `)+(m.length?`
59
- `:"");if(i){let g=m.filter(b=>b!=="."&&b!==".."),y=[];if(t.fs.readdirWithFileTypes)y=(await t.fs.readdirWithFileTypes(h)).filter(x=>x.isDirectory&&g.includes(x.name)).map(x=>({name:x.name,isDirectory:!0}));else for(let b=0;b<g.length;b+=100){let x=g.slice(b,b+100),S=await Promise.all(x.map(async C=>{let $=h==="/"?`/${C}`:`${h}/${C}`;try{let M=await t.fs.stat($);return{name:C,isDirectory:M.isDirectory}}catch{return{name:C,isDirectory:!1}}}));y.push(...S.filter(C=>C.isDirectory))}y.sort((b,x)=>b.name.localeCompare(x.name)),a&&y.reverse();let w=[];for(let b=0;b<y.length;b+=100){let x=y.slice(b,b+100),S=await Promise.all(x.map(async C=>{let $=e==="."?`./${C.name}`:`${e}/${C.name}`,M=await mu($,t,n,r,s,i,!1,a,l,c,!0);return{name:C.name,result:M}}));w.push(...S)}w.sort((b,x)=>b.name.localeCompare(x.name)),a&&w.reverse();for(let{result:b}of w)d+=`
59
+ `:"");if(i){let g=m.filter(b=>b!=="."&&b!==".."),y=[];if(t.fs.readdirWithFileTypes)y=(await t.fs.readdirWithFileTypes(h)).filter(x=>x.isDirectory&&g.includes(x.name)).map(x=>({name:x.name,isDirectory:!0}));else for(let b=0;b<g.length;b+=100){let x=g.slice(b,b+100),S=await Promise.all(x.map(async C=>{let R=h==="/"?`/${C}`:`${h}/${C}`;try{let U=await t.fs.stat(R);return{name:C,isDirectory:U.isDirectory}}catch{return{name:C,isDirectory:!1}}}));y.push(...S.filter(C=>C.isDirectory))}y.sort((b,x)=>b.name.localeCompare(x.name)),a&&y.reverse();let w=[];for(let b=0;b<y.length;b+=100){let x=y.slice(b,b+100),S=await Promise.all(x.map(async C=>{let R=e==="."?`./${C.name}`:`${e}/${C.name}`,U=await mu(R,t,n,r,s,i,!1,a,l,c,!0);return{name:C.name,result:U}}));w.push(...S)}w.sort((b,x)=>b.name.localeCompare(x.name)),a&&w.reverse();for(let{result:b}of w)d+=`
60
60
  `,d+=b.stdout}return{stdout:d,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`ls: ${e}: No such file or directory
61
- `,exitCode:2}}}var Qg,Kg,Xg,yu=I(()=>{"use strict";qe();or();ne();Qg={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"]},Kg={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"}},Xg={name:"ls",async execute(e,t){if(U(e))return F(Qg);let n=we("ls",e,Kg);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.showAlmostAll,i=n.result.flags.longFormat,o=n.result.flags.humanReadable,a=n.result.flags.recursive,l=n.result.flags.reverse,c=n.result.flags.sortBySize,u=n.result.flags.directoryOnly,f=n.result.flags.sortByTime;n.result.flags.onePerLine;let h=n.result.positional;h.length===0&&h.push(".");let p="",m="",d=0;for(let g=0;g<h.length;g++){let y=h[g];if(g>0&&p&&!p.endsWith(`
61
+ `,exitCode:2}}}var Qg,Kg,Xg,yu=I(()=>{"use strict";qe();or();ne();Qg={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"]},Kg={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"}},Xg={name:"ls",async execute(e,t){if(F(e))return M(Qg);let n=we("ls",e,Kg);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.showAlmostAll,i=n.result.flags.longFormat,o=n.result.flags.humanReadable,a=n.result.flags.recursive,l=n.result.flags.reverse,c=n.result.flags.sortBySize,u=n.result.flags.directoryOnly,f=n.result.flags.sortByTime;n.result.flags.onePerLine;let h=n.result.positional;h.length===0&&h.push(".");let p="",m="",d=0;for(let g=0;g<h.length;g++){let y=h[g];if(g>0&&p&&!p.endsWith(`
62
62
 
63
63
  `)&&(p+=`
64
- `),u){let w=t.fs.resolvePath(t.cwd,y);try{let b=await t.fs.stat(w);if(i){let x=b.isDirectory?"drwxr-xr-x":"-rw-r--r--",S=b.isDirectory?"/":"",C=b.size??0,$=o?Ls(C).padStart(5):String(C).padStart(5),M=b.mtime??new Date(0),_=_s(M);p+=`${x} 1 user user ${$} ${_} ${y}${S}
64
+ `),u){let w=t.fs.resolvePath(t.cwd,y);try{let b=await t.fs.stat(w);if(i){let x=b.isDirectory?"drwxr-xr-x":"-rw-r--r--",S=b.isDirectory?"/":"",C=b.size??0,R=o?Ls(C).padStart(5):String(C).padStart(5),U=b.mtime??new Date(0),L=_s(U);p+=`${x} 1 user user ${R} ${L} ${y}${S}
65
65
  `}else p+=`${y}
66
66
  `}catch{m+=`ls: cannot access '${y}': No such file or directory
67
67
  `,d=2}continue}if(y.includes("*")||y.includes("?")||y.includes("[")){let w=await Yg(y,t,r,s,i,l,o,c);p+=w.stdout,m+=w.stderr,w.exitCode!==0&&(d=w.exitCode)}else{let w=await mu(y,t,r,s,i,a,h.length>1,l,o,c);p+=w.stdout,m+=w.stderr,w.exitCode!==0&&(d=w.exitCode)}}return{stdout:p,stderr:m,exitCode:d}}}});var wu={};Q(wu,{mkdirCommand:()=>e7});var Jg,e7,bu=I(()=>{"use strict";Mt();qe();Jg={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},e7={name:"mkdir",async execute(e,t){let n=we("mkdir",e,Jg);if(!n.ok)return n.error;let r=n.result.flags.recursive,s=n.result.flags.verbose,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`mkdir: missing operand
@@ -92,18 +92,18 @@ Options:
92
92
  `)}catch(f){if(!s){let h=Fe(f);h.includes("ENOENT")||h.includes("no such file")?l+=`rm: cannot remove '${u}': No such file or directory
93
93
  `:h.includes("ENOTEMPTY")||h.includes("not empty")?l+=`rm: cannot remove '${u}': Directory not empty
94
94
  `:l+=`rm: cannot remove '${u}': ${h}
95
- `,c=1}}return{stdout:a,stderr:l,exitCode:c}}}});var Iu={};Q(Iu,{cpCommand:()=>f7});var c7,u7,f7,Ru=I(()=>{"use strict";Mt();qe();ne();c7={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"]},u7={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"}},f7={name:"cp",async execute(e,t){if(U(e))return F(c7);let n=we("cp",e,u7);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,s=n.result.flags.noClobber,i=n.result.flags.preserve,o=n.result.flags.verbose,a=n.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
95
+ `,c=1}}return{stdout:a,stderr:l,exitCode:c}}}});var Iu={};Q(Iu,{cpCommand:()=>f7});var c7,u7,f7,Ou=I(()=>{"use strict";Mt();qe();ne();c7={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"]},u7={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"}},f7={name:"cp",async execute(e,t){if(F(e))return M(c7);let n=we("cp",e,u7);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,s=n.result.flags.noClobber,i=n.result.flags.preserve,o=n.result.flags.verbose,a=n.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
96
96
  `,exitCode:1};let l=a.pop()??"",c=a,u=t.fs.resolvePath(t.cwd,l),f="",h="",p=0,m=!1;try{m=(await t.fs.stat(u)).isDirectory}catch{}if(c.length>1&&!m)return{stdout:"",stderr:`cp: target '${l}' is not a directory
97
97
  `,exitCode:1};for(let d of c)try{let g=t.fs.resolvePath(t.cwd,d),y=await t.fs.stat(g),w=u;if(m){let b=d.split("/").pop()||d;w=u==="/"?`/${b}`:`${u}/${b}`}if(y.isDirectory&&!r){h+=`cp: -r not specified; omitting directory '${d}'
98
98
  `,p=1;continue}if(s)try{await t.fs.stat(w);continue}catch{}await t.fs.cp(g,w,{recursive:r}),o&&(f+=`'${d}' -> '${w}'
99
99
  `)}catch(g){let y=Fe(g);y.includes("ENOENT")||y.includes("no such file")?h+=`cp: cannot stat '${d}': No such file or directory
100
100
  `:h+=`cp: cannot copy '${d}': ${y}
101
- `,p=1}return{stdout:f,stderr:h,exitCode:p}}}});var Ou={};Q(Ou,{mvCommand:()=>d7});var h7,p7,d7,$u=I(()=>{"use strict";Mt();qe();ne();h7={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"]},p7={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},d7={name:"mv",async execute(e,t){if(U(e))return F(h7);let n=we("mv",e,p7);if(!n.ok)return n.error;let r=n.result.flags.force,s=n.result.flags.noClobber,i=n.result.flags.verbose,o=n.result.positional;if(s&&(r=!1),o.length<2)return{stdout:"",stderr:`mv: missing destination file operand
101
+ `,p=1}return{stdout:f,stderr:h,exitCode:p}}}});var Ru={};Q(Ru,{mvCommand:()=>d7});var h7,p7,d7,$u=I(()=>{"use strict";Mt();qe();ne();h7={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"]},p7={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},d7={name:"mv",async execute(e,t){if(F(e))return M(h7);let n=we("mv",e,p7);if(!n.ok)return n.error;let r=n.result.flags.force,s=n.result.flags.noClobber,i=n.result.flags.verbose,o=n.result.positional;if(s&&(r=!1),o.length<2)return{stdout:"",stderr:`mv: missing destination file operand
102
102
  `,exitCode:1};let a=o.pop()??"",l=o,c=t.fs.resolvePath(t.cwd,a),u="",f="",h=0,p=!1;try{p=(await t.fs.stat(c)).isDirectory}catch{}if(l.length>1&&!p)return{stdout:"",stderr:`mv: target '${a}' is not a directory
103
103
  `,exitCode:1};for(let m of l)try{let d=t.fs.resolvePath(t.cwd,m),g=c;if(p){let y=m.split("/").pop()||m;g=c==="/"?`/${y}`:`${c}/${y}`}if(s)try{await t.fs.stat(g);continue}catch{}if(await t.fs.mv(d,g),i){let y=p?`${a}/${m.split("/").pop()||m}`:a;u+=`renamed '${m}' -> '${y}'
104
104
  `}}catch(d){let g=Fe(d);g.includes("ENOENT")||g.includes("no such file")?f+=`mv: cannot stat '${m}': No such file or directory
105
105
  `:f+=`mv: cannot move '${m}': ${g}
106
- `,h=1}return{stdout:u,stderr:f,exitCode:h}}}});var Tu={};Q(Tu,{lnCommand:()=>g7});var m7,g7,Pu=I(()=>{"use strict";ne();m7={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"]},g7={name:"ln",async execute(e,t){if(U(e))return F(m7);let n=!1,r=!1,s=!1,i=0;for(;i<e.length&&e[i].startsWith("-");){let f=e[i];if(f==="-s"||f==="--symbolic")n=!0,i++;else if(f==="-f"||f==="--force")r=!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")&&(n=!0),f.includes("f")&&(r=!0),f.includes("v")&&(s=!0),i++;else if(f==="--"){i++;break}else return{stdout:"",stderr:`ln: invalid option -- '${f.slice(1)}'
106
+ `,h=1}return{stdout:u,stderr:f,exitCode:h}}}});var Tu={};Q(Tu,{lnCommand:()=>g7});var m7,g7,Pu=I(()=>{"use strict";ne();m7={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"]},g7={name:"ln",async execute(e,t){if(F(e))return M(m7);let n=!1,r=!1,s=!1,i=0;for(;i<e.length&&e[i].startsWith("-");){let f=e[i];if(f==="-s"||f==="--symbolic")n=!0,i++;else if(f==="-f"||f==="--force")r=!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")&&(n=!0),f.includes("f")&&(r=!0),f.includes("v")&&(s=!0),i++;else if(f==="--"){i++;break}else return{stdout:"",stderr:`ln: invalid option -- '${f.slice(1)}'
107
107
  `,exitCode:1}}let o=e.slice(i);if(o.length<2)return{stdout:"",stderr:`ln: missing file operand
108
108
  `,exitCode:1};let a=o[0],l=o[1],c=t.fs.resolvePath(t.cwd,l);if(await t.fs.exists(c))if(r)try{await t.fs.rm(c,{force:!0})}catch{return{stdout:"",stderr:`ln: cannot remove '${l}': Permission denied
109
109
  `,exitCode:1}}else return{stdout:"",stderr:`ln: failed to create ${n?"symbolic ":""}link '${l}': File exists
@@ -112,14 +112,14 @@ Options:
112
112
  `,exitCode:1}:{stdout:"",stderr:`ln: ${h.message}
113
113
  `,exitCode:1}}let u="";return s&&(u=`'${l}' -> '${a}'
114
114
  `),{stdout:u,stderr:"",exitCode:0}}}});var Lu={};Q(Lu,{chmodCommand:()=>w7});async function Du(e,t,n,r,s){let i="",o=await e.fs.readdir(t);for(let a of o){let l=t==="/"?`/${a}`:`${t}/${a}`,c;if(n!==void 0)c=n;else if(r!==void 0){let f=await e.fs.stat(l);c=Io(r,f.mode)}else c=420;await e.fs.chmod(l,c),s&&(i+=`mode of '${l}' changed to ${c.toString(8).padStart(4,"0")}
115
- `),(await e.fs.stat(l)).isDirectory&&(i+=await Du(e,l,n,r,s))}return i}function Io(e,t=420){if(/^[0-7]+$/.test(e))return parseInt(e,8);let n=t&4095,r=e.split(",");for(let s of r){let i=s.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!i)throw new Error(`Invalid mode: ${e}`);let o=i[1]||"a",a=i[2],l=i[3];(o==="a"||o==="")&&(o="ugo");let c=0;l.includes("r")&&(c|=4),l.includes("w")&&(c|=2),(l.includes("x")||l.includes("X"))&&(c|=1);let u=0;l.includes("s")&&(o.includes("u")&&(u|=2048),o.includes("g")&&(u|=1024)),l.includes("t")&&(u|=512);for(let f of o){let h=0;f==="u"?h=6:f==="g"?h=3:f==="o"&&(h=0);let p=c<<h;a==="+"?n|=p:a==="-"?n&=~p:a==="="&&(n&=~(7<<h),n|=p)}a==="+"?n|=u:a==="-"?n&=~u:a==="="&&(l.includes("s")&&(o.includes("u")&&(n&=-2049,n|=u&2048),o.includes("g")&&(n&=-1025,n|=u&1024)),l.includes("t")&&(n&=-513,n|=u&512))}return n}var y7,w7,_u=I(()=>{"use strict";ne();y7={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"]},w7={name:"chmod",async execute(e,t){if(U(e))return F(y7);if(e.length<2)return{stdout:"",stderr:`chmod: missing operand
115
+ `),(await e.fs.stat(l)).isDirectory&&(i+=await Du(e,l,n,r,s))}return i}function Io(e,t=420){if(/^[0-7]+$/.test(e))return parseInt(e,8);let n=t&4095,r=e.split(",");for(let s of r){let i=s.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!i)throw new Error(`Invalid mode: ${e}`);let o=i[1]||"a",a=i[2],l=i[3];(o==="a"||o==="")&&(o="ugo");let c=0;l.includes("r")&&(c|=4),l.includes("w")&&(c|=2),(l.includes("x")||l.includes("X"))&&(c|=1);let u=0;l.includes("s")&&(o.includes("u")&&(u|=2048),o.includes("g")&&(u|=1024)),l.includes("t")&&(u|=512);for(let f of o){let h=0;f==="u"?h=6:f==="g"?h=3:f==="o"&&(h=0);let p=c<<h;a==="+"?n|=p:a==="-"?n&=~p:a==="="&&(n&=~(7<<h),n|=p)}a==="+"?n|=u:a==="-"?n&=~u:a==="="&&(l.includes("s")&&(o.includes("u")&&(n&=-2049,n|=u&2048),o.includes("g")&&(n&=-1025,n|=u&1024)),l.includes("t")&&(n&=-513,n|=u&512))}return n}var y7,w7,_u=I(()=>{"use strict";ne();y7={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"]},w7={name:"chmod",async execute(e,t){if(F(e))return M(y7);if(e.length<2)return{stdout:"",stderr:`chmod: missing operand
116
116
  `,exitCode:1};let n=!1,r=!1,s=0;for(;s<e.length&&e[s].startsWith("-");){let h=e[s];if(h==="-R"||h==="--recursive")n=!0,s++;else if(h==="-v"||h==="--verbose")r=!0,s++;else if(h==="--"){s++;break}else{if(/^[+-]?[rwxugo]+/.test(h)||/^\d+$/.test(h))break;if(/^-[Rv]+$/.test(h)){h.includes("R")&&(n=!0),h.includes("v")&&(r=!0),s++;continue}return{stdout:"",stderr:`chmod: invalid option -- '${h.slice(1)}'
117
117
  `,exitCode:1}}}if(e.length-s<2)return{stdout:"",stderr:`chmod: missing operand
118
118
  `,exitCode:1};let i=e[s],o=e.slice(s+1),a=/^[0-7]+$/.test(i),l;if(a)l=parseInt(i,8);else try{Io(i,420)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${i}'
119
119
  `,exitCode:1}}let c="",u="",f=!1;for(let h of o){let p=t.fs.resolvePath(t.cwd,h);try{let m;if(a&&l!==void 0)m=l;else{let d=await t.fs.stat(p);m=Io(i,d.mode)}if(await t.fs.chmod(p,m),r&&(c+=`mode of '${h}' changed to ${m.toString(8).padStart(4,"0")}
120
120
  `),n&&(await t.fs.stat(p)).isDirectory){let g=await Du(t,p,a?l:void 0,a?void 0:i,r);c+=g}}catch{u+=`chmod: cannot access '${h}': No such file or directory
121
121
  `,f=!0}}return{stdout:c,stderr:u,exitCode:f?1:0}}}});var Mu={};Q(Mu,{pwdCommand:()=>b7});var b7,Fu=I(()=>{"use strict";b7={name:"pwd",async execute(e,t){let n=!1;for(let s of e)if(s==="-P")n=!0;else if(s==="-L")n=!1;else{if(s==="--")break;s.startsWith("-")}let r=t.cwd;if(n)try{r=await t.fs.realpath(t.cwd)}catch{}return{stdout:`${r}
122
- `,stderr:"",exitCode:0}}}});var Uu={};Q(Uu,{readlinkCommand:()=>E7});var x7,E7,Wu=I(()=>{"use strict";ne();x7={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"]},E7={name:"readlink",async execute(e,t){if(U(e))return F(x7);let n=!1,r=0;for(;r<e.length&&e[r].startsWith("-");){let a=e[r];if(a==="-f"||a==="--canonicalize")n=!0,r++;else if(a==="--"){r++;break}else return{stdout:"",stderr:`readlink: invalid option -- '${a.slice(1)}'
122
+ `,stderr:"",exitCode:0}}}});var Uu={};Q(Uu,{readlinkCommand:()=>E7});var x7,E7,Wu=I(()=>{"use strict";ne();x7={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"]},E7={name:"readlink",async execute(e,t){if(F(e))return M(x7);let n=!1,r=0;for(;r<e.length&&e[r].startsWith("-");){let a=e[r];if(a==="-f"||a==="--canonicalize")n=!0,r++;else if(a==="--"){r++;break}else return{stdout:"",stderr:`readlink: invalid option -- '${a.slice(1)}'
123
123
  `,exitCode:1}}let s=e.slice(r);if(s.length===0)return{stdout:"",stderr:`readlink: missing operand
124
124
  `,exitCode:1};let i="",o=!1;for(let a of s){let l=t.fs.resolvePath(t.cwd,a);try{if(n){let c=l,u=new Set;for(;!u.has(c);){u.add(c);try{let f=await t.fs.readlink(c);if(f.startsWith("/"))c=f;else{let h=c.substring(0,c.lastIndexOf("/"))||"/";c=t.fs.resolvePath(h,f)}}catch{break}}i+=`${c}
125
125
  `}else{let c=await t.fs.readlink(l);i+=`${c}
@@ -138,11 +138,11 @@ Options:
138
138
  `&&i--;let o=0;for(;i>=0&&o<t;){if(e[i]===`
139
139
  `&&(o++,o===t)){i++;break}i--}i<0&&(i=0);let a=e.slice(i);return e[s-1]===`
140
140
  `?a:`${a}
141
- `}var Ro=I(()=>{"use strict";ne()});var zu={};Q(zu,{headCommand:()=>S7});var A7,S7,ju=I(()=>{"use strict";ne();Ro();A7={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"]},S7={name:"head",async execute(e,t){if(U(e))return F(A7);let n=Ms(e,"head");if(!n.ok)return n.error;let{lines:r,bytes:s}=n.options;return Fs(t,n.options,"head",i=>Bu(i,r,s))}}});var Gu={};Q(Gu,{tailCommand:()=>N7});var C7,N7,Vu=I(()=>{"use strict";Ro();ne();C7={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"]},N7={name:"tail",async execute(e,t){if(U(e))return F(C7);let n=Ms(e,"tail");if(!n.ok)return n.error;let{lines:r,bytes:s,fromLine:i}=n.options;return Fs(t,n.options,"tail",o=>Hu(o,r,s,i??!1))}}});var Zu={};Q(Zu,{wcCommand:()=>I7});function qu(e){let t=e.length,n=0,r=0,s=!1;for(let i=0;i<t;i++){let o=e[i];o===`
142
- `?(n++,s&&(r++,s=!1)):o===" "||o===" "||o==="\r"?s&&(r++,s=!1):s=!0}return s&&r++,{lines:n,words:r,chars:t}}function Oo(e,t,n,r,s,i){let o=[];t&&o.push(String(e.lines).padStart(i)),n&&o.push(String(e.words).padStart(i)),r&&o.push(String(e.chars).padStart(i));let a=o.join(" ");return s&&(a+=` ${s}`),a}var k7,v7,I7,Qu=I(()=>{"use strict";qe();Hn();ne();k7={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"]},v7={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"}},I7={name:"wc",async execute(e,t){if(U(e))return F(k7);let n=we("wc",e,v7);if(!n.ok)return n.error;let{lines:r,words:s}=n.result.flags,i=n.result.flags.bytes||n.result.flags.chars,o=n.result.positional;!r&&!s&&!i&&(r=s=i=!0);let a=await Bn(t,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let y=qu(a.files[0].content);return{stdout:`${Oo(y,r,s,i,"",0)}
143
- `,stderr:"",exitCode:0}}let l=[],c=0,u=0,f=0;for(let{filename:y,content:w}of a.files){let b=qu(w);c+=b.lines,u+=b.words,f+=b.chars,l.push({filename:y,stats:b})}let h=o.length>1?c:Math.max(...l.map(y=>y.stats.lines)),p=o.length>1?u:Math.max(...l.map(y=>y.stats.words)),m=o.length>1?f:Math.max(...l.map(y=>y.stats.chars)),d=o.length>1?3:0;r&&(d=Math.max(d,String(h).length)),s&&(d=Math.max(d,String(p).length)),i&&(d=Math.max(d,String(m).length));let g="";for(let{filename:y,stats:w}of l)g+=`${Oo(w,r,s,i,y,d)}
144
- `;return o.length>1&&(g+=`${Oo({lines:c,words:u,chars:f},r,s,i,"total",d)}
145
- `),{stdout:g,stderr:a.stderr,exitCode:a.exitCode}}}});var Xu={};Q(Xu,{statCommand:()=>$7});function Ku(e,t){let n=t?"d":"-",r=[e&256?"r":"-",e&128?"w":"-",e&64?"x":"-",e&32?"r":"-",e&16?"w":"-",e&8?"x":"-",e&4?"r":"-",e&2?"w":"-",e&1?"x":"-"];return n+r.join("")}var R7,O7,$7,Yu=I(()=>{"use strict";qe();ne();R7={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"]},O7={format:{short:"c",type:"string"}},$7={name:"stat",async execute(e,t){if(U(e))return F(R7);let n=we("stat",e,O7);if(!n.ok)return n.error;let r=n.result.flags.format??null,s=n.result.positional;if(s.length===0)return{stdout:"",stderr:`stat: missing operand
141
+ `}var Oo=I(()=>{"use strict";ne()});var zu={};Q(zu,{headCommand:()=>S7});var A7,S7,ju=I(()=>{"use strict";ne();Oo();A7={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"]},S7={name:"head",async execute(e,t){if(F(e))return M(A7);let n=Ms(e,"head");if(!n.ok)return n.error;let{lines:r,bytes:s}=n.options;return Fs(t,n.options,"head",i=>Bu(i,r,s))}}});var Gu={};Q(Gu,{tailCommand:()=>N7});var C7,N7,Vu=I(()=>{"use strict";Oo();ne();C7={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"]},N7={name:"tail",async execute(e,t){if(F(e))return M(C7);let n=Ms(e,"tail");if(!n.ok)return n.error;let{lines:r,bytes:s,fromLine:i}=n.options;return Fs(t,n.options,"tail",o=>Hu(o,r,s,i??!1))}}});var Zu={};Q(Zu,{wcCommand:()=>I7});function qu(e){let t=e.length,n=0,r=0,s=!1;for(let i=0;i<t;i++){let o=e[i];o===`
142
+ `?(n++,s&&(r++,s=!1)):o===" "||o===" "||o==="\r"?s&&(r++,s=!1):s=!0}return s&&r++,{lines:n,words:r,chars:t}}function Ro(e,t,n,r,s,i){let o=[];t&&o.push(String(e.lines).padStart(i)),n&&o.push(String(e.words).padStart(i)),r&&o.push(String(e.chars).padStart(i));let a=o.join(" ");return s&&(a+=` ${s}`),a}var k7,v7,I7,Qu=I(()=>{"use strict";qe();Hn();ne();k7={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"]},v7={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"}},I7={name:"wc",async execute(e,t){if(F(e))return M(k7);let n=we("wc",e,v7);if(!n.ok)return n.error;let{lines:r,words:s}=n.result.flags,i=n.result.flags.bytes||n.result.flags.chars,o=n.result.positional;!r&&!s&&!i&&(r=s=i=!0);let a=await Bn(t,o,{cmdName:"wc",stopOnError:!1});if(o.length===0){let y=qu(a.files[0].content);return{stdout:`${Ro(y,r,s,i,"",0)}
143
+ `,stderr:"",exitCode:0}}let l=[],c=0,u=0,f=0;for(let{filename:y,content:w}of a.files){let b=qu(w);c+=b.lines,u+=b.words,f+=b.chars,l.push({filename:y,stats:b})}let h=o.length>1?c:Math.max(...l.map(y=>y.stats.lines)),p=o.length>1?u:Math.max(...l.map(y=>y.stats.words)),m=o.length>1?f:Math.max(...l.map(y=>y.stats.chars)),d=o.length>1?3:0;r&&(d=Math.max(d,String(h).length)),s&&(d=Math.max(d,String(p).length)),i&&(d=Math.max(d,String(m).length));let g="";for(let{filename:y,stats:w}of l)g+=`${Ro(w,r,s,i,y,d)}
144
+ `;return o.length>1&&(g+=`${Ro({lines:c,words:u,chars:f},r,s,i,"total",d)}
145
+ `),{stdout:g,stderr:a.stderr,exitCode:a.exitCode}}}});var Xu={};Q(Xu,{statCommand:()=>$7});function Ku(e,t){let n=t?"d":"-",r=[e&256?"r":"-",e&128?"w":"-",e&64?"x":"-",e&32?"r":"-",e&16?"w":"-",e&8?"x":"-",e&4?"r":"-",e&2?"w":"-",e&1?"x":"-"];return n+r.join("")}var O7,R7,$7,Yu=I(()=>{"use strict";qe();ne();O7={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"]},R7={format:{short:"c",type:"string"}},$7={name:"stat",async execute(e,t){if(F(e))return M(O7);let n=we("stat",e,R7);if(!n.ok)return n.error;let r=n.result.flags.format??null,s=n.result.positional;if(s.length===0)return{stdout:"",stderr:`stat: missing operand
146
146
  `,exitCode:1};let i="",o="",a=!1;for(let l of s){let c=t.fs.resolvePath(t.cwd,l);try{let u=await t.fs.stat(c);if(r){let f=r,h=u.mode.toString(8),p=Ku(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,h),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}
147
147
  `}else{let f=u.mode.toString(8).padStart(4,"0"),h=Ku(u.mode,u.isDirectory);i+=` File: ${l}
148
148
  `,i+=` Size: ${u.size} Blocks: ${Math.ceil(u.size/512)}
@@ -167,31 +167,31 @@ Options:
167
167
  `)+1&&t.runes[3]===he.MAX_RUNE&&(t.runes=[],t.op=D.Op.ANY_CHAR_NOT_NL))}collapse(t,n){if(t.length===1)return t[0];let r=0;for(let a of t)r+=a.op===n?a.subs.length:1;let s=new Array(r).fill(null),i=0;for(let a of t)a.op===n?(s.splice(i,a.subs.length,...a.subs),i+=a.subs.length,this.reuse(a)):s[i++]=a;let o=this.newRegexp(n);if(o.subs=s,n===D.Op.ALTERNATE&&(o.subs=this.factor(o.subs),o.subs.length===1)){let a=o;o=o.subs[0],this.reuse(a)}return o}factor(t){if(t.length<2)return t;let n=0,r=t.length,s=0,i=null,o=0,a=0,l=0;for(let u=0;u<=r;u++){let f=null,h=0,p=0;if(u<r){let m=t[n+u];if(m.op===D.Op.CONCAT&&m.subs.length>0&&(m=m.subs[0]),m.op===D.Op.LITERAL&&(f=m.runes,h=m.runes.length,p=m.flags&K.FOLD_CASE),p===a){let d=0;for(;d<o&&d<h&&i[d]===f[d];)d++;if(d>0){o=d;continue}}}if(u!==l)if(u===l+1)t[s++]=t[n+l];else{let m=this.newRegexp(D.Op.LITERAL);m.flags=a,m.runes=i.slice(0,o);for(let y=l;y<u;y++)t[n+y]=this.removeLeadingString(t[n+y],o),this.checkLimits(t[n+y]);let d=this.collapse(t.slice(n+l,n+u),D.Op.ALTERNATE),g=this.newRegexp(D.Op.CONCAT);g.subs=[m,d],t[s++]=g}l=u,i=f,o=h,a=p}r=s,n=0,l=0,s=0;let c=null;for(let u=0;u<=r;u++){let f=null;if(!(u<r&&(f=e.leadingRegexp(t[n+u]),c!==null&&c.equals(f)&&(e.isCharClass(c)||c.op===D.Op.REPEAT&&c.min===c.max&&e.isCharClass(c.subs[0]))))){if(u!==l)if(u===l+1)t[s++]=t[n+l];else{let h=c;for(let d=l;d<u;d++){let g=d!==l;t[n+d]=this.removeLeadingRegexp(t[n+d],g),this.checkLimits(t[n+d])}let p=this.collapse(t.slice(n+l,n+u),D.Op.ALTERNATE),m=this.newRegexp(D.Op.CONCAT);m.subs=[h,p],t[s++]=m}l=u,c=f}}r=s,n=0,l=0,s=0;for(let u=0;u<=r;u++)if(!(u<r&&e.isCharClass(t[n+u]))){if(u!==l)if(u===l+1)t[s++]=t[n+l];else{let f=l;for(let p=l+1;p<u;p++){let m=t[n+f],d=t[n+p];(m.op<d.op||m.op===d.op&&(m.runes!==null?m.runes.length:0)<(d.runes!==null?d.runes.length:0))&&(f=p)}let h=t[n+l];t[n+l]=t[n+f],t[n+f]=h;for(let p=l+1;p<u;p++)e.mergeCharClass(t[n+l],t[n+p]),this.reuse(t[n+p]);this.cleanAlt(t[n+l]),t[s++]=t[n+l]}u<r&&(t[s++]=t[n+u]),l=u+1}r=s,n=0,l=0,s=0;for(let u=0;u<r;++u)u+1<r&&t[n+u].op===D.Op.EMPTY_MATCH&&t[n+u+1].op===D.Op.EMPTY_MATCH||(t[s++]=t[n+u]);return r=s,n=0,t.slice(n,r)}removeLeadingString(t,n){if(t.op===D.Op.CONCAT&&t.subs.length>0){let r=this.removeLeadingString(t.subs[0],n);if(t.subs[0]=r,r.op===D.Op.EMPTY_MATCH)switch(this.reuse(r),t.subs.length){case 0:case 1:t.op=D.Op.EMPTY_MATCH,t.subs=null;break;case 2:{let s=t;t=t.subs[1],this.reuse(s);break}default:t.subs=t.subs.slice(1,t.subs.length);break}return t}return t.op===D.Op.LITERAL&&(t.runes=t.runes.slice(n,t.runes.length),t.runes.length===0&&(t.op=D.Op.EMPTY_MATCH)),t}removeLeadingRegexp(t,n){if(t.op===D.Op.CONCAT&&t.subs.length>0){switch(n&&this.reuse(t.subs[0]),t.subs=t.subs.slice(1,t.subs.length),t.subs.length){case 0:{t.op=D.Op.EMPTY_MATCH,t.subs=D.emptySubs();break}case 1:{let r=t;t=t.subs[0],this.reuse(r);break}}return t}return n&&this.reuse(t),this.newRegexp(D.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&K.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,s=new Bo(this.wholeRegexp);for(;s.more();){let o=-1;e:switch(s.peek()){case P.CODES.get("("):if((this.flags&K.PERL_X)!==0&&s.lookingAt("(?")){this.parsePerlFlags(s);break}this.op(D.Op.LEFT_PAREN).cap=++this.numCap,s.skip(1);break;case P.CODES.get("|"):this.parseVerticalBar(),s.skip(1);break;case P.CODES.get(")"):this.parseRightParen(),s.skip(1);break;case P.CODES.get("^"):(this.flags&K.ONE_LINE)!==0?this.op(D.Op.BEGIN_TEXT):this.op(D.Op.BEGIN_LINE),s.skip(1);break;case P.CODES.get("$"):(this.flags&K.ONE_LINE)!==0?this.op(D.Op.END_TEXT).flags|=K.WAS_DOLLAR:this.op(D.Op.END_LINE),s.skip(1);break;case P.CODES.get("."):(this.flags&K.DOT_NL)!==0?this.op(D.Op.ANY_CHAR):this.op(D.Op.ANY_CHAR_NOT_NL),s.skip(1);break;case P.CODES.get("["):this.parseClass(s);break;case P.CODES.get("*"):case P.CODES.get("+"):case P.CODES.get("?"):{o=s.pos();let a=null;switch(s.pop()){case P.CODES.get("*"):a=D.Op.STAR;break;case P.CODES.get("+"):a=D.Op.PLUS;break;case P.CODES.get("?"):a=D.Op.QUEST;break}this.repeat(a,n,r,o,s,t);break}case P.CODES.get("{"):{o=s.pos();let a=e.parseRepeat(s);if(a<0){s.rewindTo(o),this.literal(s.pop());break}n=a>>16,r=(a&he.MAX_BMP)<<16>>16,this.repeat(D.Op.REPEAT,n,r,o,s,t);break}case P.CODES.get("\\"):{let a=s.pos();if(s.skip(1),(this.flags&K.PERL_X)!==0&&s.more())switch(s.pop()){case P.CODES.get("A"):this.op(D.Op.BEGIN_TEXT);break e;case P.CODES.get("b"):this.op(D.Op.WORD_BOUNDARY);break e;case P.CODES.get("B"):this.op(D.Op.NO_WORD_BOUNDARY);break e;case P.CODES.get("C"):throw new De(e.ERR_INVALID_ESCAPE,"\\C");case P.CODES.get("Q"):{let f=s.rest(),h=f.indexOf("\\E");h>=0&&(f=f.substring(0,h)),s.skipString(f),s.skipString("\\E");let p=0;for(;p<f.length;){let m=f.codePointAt(p);this.literal(m),p+=Ne.charCount(m)}break e}case P.CODES.get("z"):this.op(D.Op.END_TEXT);break e;default:s.rewindTo(a);break}let l=this.newRegexp(D.Op.CHAR_CLASS);if(l.flags=this.flags,s.lookingAt("\\p")||s.lookingAt("\\P")){let u=new sn;if(this.parseUnicodeClass(s,u)){l.runes=u.toArray(),this.push(l);break e}}let c=new sn;if(this.parsePerlClassEscape(s,c)){l.runes=c.toArray(),this.push(l);break e}s.rewindTo(a),this.reuse(l),this.literal(e.parseEscape(s));break}default:this.literal(s.pop());break}t=o}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new De(e.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){let n=t.pos(),r=t.rest();if(r.startsWith("(?P<")||r.startsWith("(?<")){let a=r.charAt(2)==="P"?4:3,l=r.indexOf(">");if(l<0)throw new De(e.ERR_INVALID_NAMED_CAPTURE,r);let c=r.substring(a,l);if(t.skipString(c),t.skip(a+1),!e.isValidCaptureName(c))throw new De(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,l+1));let u=this.op(D.Op.LEFT_PAREN);if(u.cap=++this.numCap,this.namedGroups[c])throw new De(e.ERR_DUPLICATE_NAMED_CAPTURE,c);this.namedGroups[c]=this.numCap,u.name=c;return}t.skip(2);let s=this.flags,i=1,o=!1;e:for(;t.more();){let a=t.pop();switch(a){case P.CODES.get("i"):s|=K.FOLD_CASE,o=!0;break;case P.CODES.get("m"):s&=-17,o=!0;break;case P.CODES.get("s"):s|=K.DOT_NL,o=!0;break;case P.CODES.get("U"):s|=K.NON_GREEDY,o=!0;break;case P.CODES.get("-"):if(i<0)break e;i=-1,s=~s,o=!1;break;case P.CODES.get(":"):case P.CODES.get(")"):if(i<0){if(!o)break e;s=~s}a===P.CODES.get(":")&&this.op(D.Op.LEFT_PAREN),this.flags=s;return;default:break e}}throw new De(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(D.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===D.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let s=r;r=n,n=s,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let n=this.stack[t-1],r=this.stack[t-2];if(r.op===D.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=n,this.stack[t-1]=r,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new De(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);let n=this.pop(),r=this.pop();if(r.op!==D.Op.LEFT_PAREN)throw new De(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=r.flags,r.cap===0?this.push(n):(r.op=D.Op.CAPTURE,r.subs=[n],this.push(r))}parsePerlClassEscape(t,n){let r=t.pos();if((this.flags&K.PERL_X)===0||!t.more()||t.pop()!==P.CODES.get("\\")||!t.more())return!1;t.pop();let s=t.from(r),i=nf.has(s)?nf.get(s):null;return i===null?!1:(n.appendGroup(i,(this.flags&K.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),s=r.indexOf(":]");if(s<0)return!1;let i=r.substring(0,s+2);t.skipString(i);let o=wf.has(i)?wf.get(i):null;if(o===null)throw new De(e.ERR_INVALID_CHAR_RANGE,i);return n.appendGroup(o,(this.flags&K.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&K.UNICODE_GROUPS)===0||!t.lookingAt("\\p")&&!t.lookingAt("\\P"))return!1;t.skip(1);let s=1,i=t.pop();if(i===P.CODES.get("P")&&(s=-1),!t.more())throw t.rewindTo(r),new De(e.ERR_INVALID_CHAR_RANGE,t.rest());i=t.pop();let o;if(i!==P.CODES.get("{"))o=Ne.runeToString(i);else{let u=t.rest(),f=u.indexOf("}");if(f<0)throw t.rewindTo(r),new De(e.ERR_INVALID_CHAR_RANGE,t.rest());o=u.substring(0,f),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===P.CODES.get("^")&&(s=0-s,o=o.substring(1));let a=e.unicodeTable(o);if(a===null)throw new De(e.ERR_INVALID_CHAR_RANGE,t.from(r));let l=a.first,c=a.second;if((this.flags&K.FOLD_CASE)===0||c===null)n.appendTableWithSign(l,s);else{let u=new sn().appendTable(l).appendTable(c).cleanClass().toArray();n.appendClassWithSign(u,s)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(D.Op.CHAR_CLASS);r.flags=this.flags;let s=new sn,i=1;t.more()&&t.lookingAt("^")&&(i=-1,t.skip(1),(this.flags&K.CLASS_NL)===0&&s.appendRange(P.CODES.get(`
168
168
  `),P.CODES.get(`
169
169
  `)));let o=!0;for(;!t.more()||t.peek()!==P.CODES.get("]")||o;){if(t.more()&&t.lookingAt("-")&&(this.flags&K.PERL_X)===0&&!o){let u=t.rest();if(u==="-"||!u.startsWith("-]"))throw t.rewindTo(n),new De(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let a=t.pos();if(t.lookingAt("[:")){if(this.parseNamedClass(t,s))continue;t.rewindTo(a)}if(this.parseUnicodeClass(t,s)||this.parsePerlClassEscape(t,s))continue;t.rewindTo(a);let l=e.parseClassChar(t,n),c=l;if(t.more()&&t.lookingAt("-")){if(t.skip(1),t.more()&&t.lookingAt("]"))t.skip(-1);else if(c=e.parseClassChar(t,n),c<l)throw new De(e.ERR_INVALID_CHAR_RANGE,t.from(a))}(this.flags&K.FOLD_CASE)===0?s.appendRange(l,c):s.appendFoldedRange(l,c)}t.skip(1),s.cleanClass(),i<0&&s.negateClass(),r.runes=s.toArray(),this.push(r)}},zo=class{constructor(t){this.value=t}get(){return this.value}set(t){this.value=t}compareAndSet(t,n){return this.value===t?(this.value=n,!0):!1}},jo=class e{static initTest(t){let n=e.compile(t),r=new e(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(t){return e.compileImpl(t,K.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,K.POSIX,!0)}static compileImpl(t,n,r){let s=Ho.parse(t,n),i=s.maxCap();s=Wo.simplify(s);let o=Uo.compileRegexp(s),a=new e(t,o,i,r),[l,c]=o.prefix();return a.prefixComplete=l,a.prefix=c,a.prefixUTF8=Ne.stringToUtf8ByteArray(a.prefix),a.prefix.length>0&&(a.prefixRune=a.prefix.codePointAt(0)),a.namedGroups=s.namedGroups,a}static match(t,n){return e.compile(t).match(n)}constructor(t,n,r=0,s=0){this.expr=t,this.prog=n,this.numSubexp=r,this.longest=s,this.cond=n.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new zo}numberOfCapturingGroups(){return this.numSubexp}numberOfInstructions(){return this.prog.numInst()}get(){let t;do t=this.pooled.get();while(t&&!this.pooled.compareAndSet(t,t.next));return t}reset(){this.pooled.set(null)}put(t,n){let r=this.pooled.get();do r=this.pooled.get(),!n&&r&&(t=Vr.fromMachine(t),n=!0),t.next!==r&&(t.next=r);while(!this.pooled.compareAndSet(r,t))}toString(){return this.expr}doExecute(t,n,r,s){let i=this.get(),o=!1;i?i.next!==null&&(i=Vr.fromMachine(i),o=!0):(i=Vr.fromRE2(this),o=!0),i.init(s);let a=i.match(t,n,r)?i.submatches():null;return this.put(i,o),a}match(t){return this.doExecute(je.fromUTF16(t),0,K.UNANCHORED,0)!==null}matchWithGroup(t,n,r,s,i){return t instanceof Nn||(t=ur.utf16(t)),this.matchMachineInput(t,n,r,s,i)}matchMachineInput(t,n,r,s,i){if(n>r)return[!1,null];let o=t.isUTF16Encoding()?je.fromUTF16(t.asCharSequence(),0,r):je.fromUTF8(t.asBytes(),0,r),a=this.doExecute(o,n,s,2*i);return a===null?[!1,null]:[!0,a]}matchUTF8(t){return this.doExecute(je.fromUTF8(t),0,K.UNANCHORED,0)!==null}replaceAll(t,n){return this.replaceAllFunc(t,()=>n,2*t.length+1)}replaceFirst(t,n){return this.replaceAllFunc(t,()=>n,1)}replaceAllFunc(t,n,r){let s=0,i=0,o="",a=je.fromUTF16(t),l=0;for(;i<=t.length;){let c=this.doExecute(a,i,K.UNANCHORED,2);if(c===null||c.length===0)break;o+=t.substring(s,c[0]),(c[1]>s||c[0]===0)&&(o+=n(t.substring(c[0],c[1])),l++),s=c[1];let u=a.step(i)&7;if(i+u>c[1]?i+=u:i+1>c[1]?i++:i=c[1],l>=r)break}return o+=t.substring(s),o}pad(t){if(t===null)return null;let n=(1+this.numSubexp)*2;if(t.length<n){let r=new Array(n).fill(-1);for(let s=0;s<t.length;s++)r[s]=t[s];t=r}return t}allMatches(t,n,r=s=>s){let s=[],i=t.endPos();n<0&&(n=i+1);let o=0,a=0,l=-1;for(;a<n&&o<=i;){let c=this.doExecute(t,o,K.UNANCHORED,this.prog.numCap);if(c===null||c.length===0)break;let u=!0;if(c[1]===o){c[0]===l&&(u=!1);let f=t.step(o);f<0?o=i+1:o+=f&7}else o=c[1];l=c[1],u&&(s.push(r(this.pad(c))),a++)}return s}findUTF8(t){let n=this.doExecute(je.fromUTF8(t),0,K.UNANCHORED,2);return n===null?null:t.slice(n[0],n[1])}findUTF8Index(t){let n=this.doExecute(je.fromUTF8(t),0,K.UNANCHORED,2);return n===null?null:n.slice(0,2)}find(t){let n=this.doExecute(je.fromUTF16(t),0,K.UNANCHORED,2);return n===null?"":t.substring(n[0],n[1])}findIndex(t){return this.doExecute(je.fromUTF16(t),0,K.UNANCHORED,2)}findUTF8Submatch(t){let n=this.doExecute(je.fromUTF8(t),0,K.UNANCHORED,this.prog.numCap);if(n===null)return null;let r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<n.length&&n[2*s]>=0&&(r[s]=t.slice(n[2*s],n[2*s+1]));return r}findUTF8SubmatchIndex(t){return this.pad(this.doExecute(je.fromUTF8(t),0,K.UNANCHORED,this.prog.numCap))}findSubmatch(t){let n=this.doExecute(je.fromUTF16(t),0,K.UNANCHORED,this.prog.numCap);if(n===null)return null;let r=new Array(1+this.numSubexp).fill(null);for(let s=0;s<r.length;s++)2*s<n.length&&n[2*s]>=0&&(r[s]=t.substring(n[2*s],n[2*s+1]));return r}findSubmatchIndex(t){return this.pad(this.doExecute(je.fromUTF16(t),0,K.UNANCHORED,this.prog.numCap))}findAllUTF8(t,n){let r=this.allMatches(je.fromUTF8(t),n,s=>t.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(t,n){let r=this.allMatches(je.fromUTF8(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAll(t,n){let r=this.allMatches(je.fromUTF16(t),n,s=>t.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(t,n){let r=this.allMatches(je.fromUTF16(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(t,n){let r=this.allMatches(je.fromUTF8(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let o=0;o<i.length;o++)s[2*o]>=0&&(i[o]=t.slice(s[2*o],s[2*o+1]));return i});return r.length===0?null:r}findAllUTF8SubmatchIndex(t,n){let r=this.allMatches(je.fromUTF8(t),n);return r.length===0?null:r}findAllSubmatch(t,n){let r=this.allMatches(je.fromUTF16(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let o=0;o<i.length;o++)s[2*o]>=0&&(i[o]=t.substring(s[2*o],s[2*o+1]));return i});return r.length===0?null:r}findAllSubmatchIndex(t,n){let r=this.allMatches(je.fromUTF16(t),n);return r.length===0?null:r}},Go=class e{static isUpperCaseAlpha(t){return"A"<=t&&t<="Z"}static isHexadecimal(t){return"0"<=t&&t<="9"||"A"<=t&&t<="F"||"a"<=t&&t<="f"}static getUtf8CharSize(t){let n=t.charCodeAt(0);return n<128?1:n<2048?2:n<65536?3:4}static translate(t){if(typeof t!="string")return t;let n="",r=!1,s=t.length;s===0&&(n="(?:)",r=!0);let i=0;for(;i<s;){let o=t[i];if(o==="\\"){if(i+1<s)switch(o=t[i+1],o){case"\\":{n+="\\\\",i+=2;continue}case"c":{if(i+2<s){let l=t[i+2];if(e.isUpperCaseAlpha(l)){n+="\\x",n+=(l.charCodeAt(0)-64>>4).toString(16).toUpperCase(),n+=(l.charCodeAt(0)-64&15).toString(16).toUpperCase(),i+=3,r=!0;continue}}n+="\\c",i+=2;continue}case"u":{if(i+2<s){let l=t[i+2];if(e.isHexadecimal(l)){n+="\\x{"+l,i+=3;for(let c=0;c<3&&i<s&&(l=t[i],!!e.isHexadecimal(l));++i,++c)n+=l;n+="}",r=!0;continue}else if(l==="{"){n+="\\x",i+=2,r=!0;continue}}n+="\\u",i+=2;continue}default:{n+="\\";let l=e.getUtf8CharSize(o);n+=t.substring(i+1,i+1+l),i+=l+1;continue}}}else if(o==="/"){n+="\\/",i+=1,r=!0;continue}else if(o==="("&&i+2<s&&t[i+1]==="?"&&t[i+2]==="<"&&(i+3>=s||t[i+3]!=="="&&t[i+3]!=="!")){n+="(?P<",i+=3,r=!0;continue}let a=e.getUtf8CharSize(o);n+=t.substring(i,i+a),i+=a}return r?n:t}},kn=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(t){return Ne.quoteMeta(t)}static translateRegExp(t){return Go.translate(t)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new Po("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH");let s=K.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(s&=-129);let i=new e(t,n);return i.re2Input=jo.compileImpl(r,s,(n&e.LONGEST_MATCH)!==0),i}static matches(t,n){return e.compile(t).matcher(n).matches()}static initTest(t,n,r){if(t==null)throw new Error("pattern is null");if(r==null)throw new Error("re2 is null");let s=new e(t,n);return s.re2Input=r,s}constructor(t,n){this.patternInput=t,this.flagsInput=n}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(t){return this.matcher(t).matches()}matcher(t){return Array.isArray(t)&&(t=ur.utf8(t)),new Do(this,t)}split(t,n=0){let r=this.matcher(t),s=[],i=0,o=0;for(;r.find();){if(o===0&&r.end()===0){o=r.end();continue}if(n>0&&s.length===n-1)break;if(o===r.start()){if(n===0){i+=1,o=r.end();continue}}else for(;i>0;)s.push(""),i-=1;s.push(r.substring(o,r.start())),o=r.end()}if(n===0&&o!==r.inputLength()){for(;i>0;)s.push(""),i-=1;s.push(r.substring(o,r.inputLength()))}return(n!==0||s.length===0)&&s.push(r.substring(o,r.inputLength())),s}toString(){return this.patternInput}programSize(){return this.re2Input.numberOfInstructions()}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(t){return this===t?!0:t===null||this.constructor!==t.constructor?!1:this.flagsInput===t.flagsInput&&this.patternInput===t.patternInput}}});function T7(e){let t=0;return e.includes("i")&&(t|=kn.CASE_INSENSITIVE),e.includes("m")&&(t|=kn.MULTILINE),e.includes("s")&&(t|=kn.DOTALL),t}function P7(e){return kn.translateRegExp(e)}function V(e,t=""){return new Bs(e,t)}var Bs,bn,Ef=I(()=>{"use strict";xf();Bs=class{_re2;_pattern;_flags;_global;_ignoreCase;_multiline;_lastIndex=0;_nativeRegex=null;constructor(t,n=""){this._pattern=t,this._flags=n,this._global=n.includes("g"),this._ignoreCase=n.includes("i"),this._multiline=n.includes("m");try{let r=P7(t),s=T7(n);this._re2=kn.compile(r,s)}catch(r){if(r instanceof De){let s=r.message||"",i="";throw s.includes("(?=")||s.includes("(?!")||s.includes("(?<")||s.includes("(?<!")||t.includes("(?=")||t.includes("(?!")||t.includes("(?<=")||t.includes("(?<!")?i=" Lookahead (?=, ?!) and lookbehind (?<=, ?<!) assertions are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support these features.":(s.includes("backreference")||/\\[1-9]/.test(t))&&(i=" Backreferences (\\1, \\2, etc.) are not supported in this environment because the regex engine uses RE2 for ReDoS protection. RE2 guarantees linear-time matching but cannot support backreferences."),new SyntaxError(`Invalid regular expression: /${t}/: ${s}${i}`)}throw r}}test(t){return this._global&&(this._lastIndex=0),this._re2.matcher(t).find()}exec(t){let n=this._re2.matcher(t),r=this._global?this._lastIndex:0;if(!n.find(r))return this._global&&(this._lastIndex=0),null;let s=this._re2.groupCount(),i=[];i.push(n.group(0)??"");for(let l=1;l<=s;l++){let c=n.group(l);i.push(c)}let o=i;o.index=n.start(0),o.input=t;let a=this._re2.namedGroups();if(a&&Object.keys(a).length>0){let l=Object.create(null);for(let[c,u]of Object.entries(a)){let f=n.group(u);f!==null&&(l[c]=f)}o.groups=l}return this._global&&(this._lastIndex=n.end(0),n.start(0)===n.end(0)&&this._lastIndex++),o}match(t){if(this._global&&(this._lastIndex=0),!this._global)return this.exec(t);let n=[],r=this._re2.matcher(t),s=0;for(;r.find(s);){let i=r.group(0)??"";if(n.push(i),s=r.end(0),r.start(0)===r.end(0)&&s++,s>t.length)break}return n.length>0?n:null}replace(t,n){if(this._global&&(this._lastIndex=0),typeof n=="string"){let c=this._re2.matcher(t);return this._global?c.replaceAll(n,!0):c.replaceFirst(n,!0)}let r=[],s=this._re2.matcher(t),i=0,o=0,a=this._re2.groupCount(),l=this._re2.namedGroups();for(;s.find(o);){r.push(t.slice(i,s.start(0)));let c=[],u=s.group(0)??"";for(let f=1;f<=a;f++)c.push(s.group(f));if(c.push(s.start(0)),c.push(t),l&&Object.keys(l).length>0){let f=Object.create(null);for(let[h,p]of Object.entries(l))f[h]=s.group(p)??"";c.push(f)}if(r.push(n(u,...c)),i=s.end(0),o=i,s.start(0)===s.end(0)&&o++,!this._global||o>t.length)break}return r.push(t.slice(i)),r.join("")}split(t,n){return n===void 0||n<0?this._re2.split(t,-1):n===0?[]:this._re2.split(t,-1).slice(0,n)}search(t){let n=this._re2.matcher(t);return n.find()?n.start(0):-1}*matchAll(t){if(!this._global)throw new Error("matchAll requires global flag");this._lastIndex=0;let n=this._re2.matcher(t),r=this._re2.groupCount(),s=this._re2.namedGroups(),i=0;for(;n.find(i);){let o=[];o.push(n.group(0)??"");for(let l=1;l<=r;l++)o.push(n.group(l));let a=o;if(a.index=n.start(0),a.input=t,s&&Object.keys(s).length>0){let l=Object.create(null);for(let[c,u]of Object.entries(s)){let f=n.group(u);f!==null&&(l[c]=f)}a.groups=l}if(yield a,i=n.end(0),n.start(0)===n.end(0)&&i++,i>t.length)break}}get native(){if(!this._nativeRegex)try{this._nativeRegex=new RegExp(this._pattern,this._flags)}catch{this._nativeRegex=new RegExp("",this._flags),Object.defineProperty(this._nativeRegex,"source",{value:this._pattern,writable:!1})}return this._nativeRegex}get source(){return this._pattern}get flags(){return this._flags}get global(){return this._global}get ignoreCase(){return this._ignoreCase}get multiline(){return this._multiline}get lastIndex(){return this._lastIndex}set lastIndex(t){this._lastIndex=t}};bn=class{_regex;constructor(t){this._regex=t}test(t){return this._regex.global&&(this._regex.lastIndex=0),this._regex.test(t)}exec(t){return this._regex.exec(t)}match(t){return this._regex.global&&(this._regex.lastIndex=0),t.match(this._regex)}replace(t,n){return this._regex.global&&(this._regex.lastIndex=0),t.replace(this._regex,n)}split(t,n){return t.split(this._regex,n)}search(t){return t.search(this._regex)}*matchAll(t){if(!this._regex.global)throw new Error("matchAll requires global flag");this._regex.lastIndex=0;let n=this._regex.exec(t);for(;n!==null;)yield n,n[0].length===0&&this._regex.lastIndex++,n=this._regex.exec(t)}get native(){return this._regex}get source(){return this._regex.source}get flags(){return this._regex.flags}get global(){return this._regex.global}get ignoreCase(){return this._regex.ignoreCase}get multiline(){return this._regex.multiline}get lastIndex(){return this._regex.lastIndex}set lastIndex(t){this._regex.lastIndex=t}}});var Me=I(()=>{"use strict";Ef()});function dt(e,t,n){let r=typeof n=="boolean"?{ignoreCase:n}:n??{},s=t;r.stripQuotes&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))&&(s=s.slice(1,-1));let i=r.ignoreCase?`i:${s}`:s,o=Af.get(i);return o||(o=D7(s,r.ignoreCase),Af.set(i,o)),o.test(e)}function D7(e,t){let n="^";for(let r=0;r<e.length;r++){let s=e[r];if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=r+1;for(;i<e.length&&e[i]!=="]";)i++;n+=e.slice(r,i+1),r=i}else s==="."||s==="+"||s==="^"||s==="$"||s==="{"||s==="}"||s==="("||s===")"||s==="|"||s==="\\"?n+=`\\${s}`:n+=s}return n+="$",V(n,t?"i":"")}var Af,Vo=I(()=>{"use strict";Me();Af=new Map});function Sf(e,t){return e.replace(/\$(&|\d+|<([^>]+)>)/g,(n,r,s)=>{if(r==="&")return t[0];if(s!==void 0)return t.groups?.[s]??"";let i=parseInt(r,10);return t[i]??""})}function hr(e,t,n={}){let{invertMatch:r=!1,showLineNumbers:s=!1,countOnly:i=!1,countMatches:o=!1,filename:a="",onlyMatching:l=!1,beforeContext:c=0,afterContext:u=0,maxCount:f=0,contextSeparator:h="--",showColumn:p=!1,vimgrep:m=!1,showByteOffset:d=!1,replace:g=null,passthru:y=!1,multiline:w=!1,kResetGroup:b}=n;if(w)return L7(e,t,{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:h,showColumn:p,showByteOffset:d,replace:g,kResetGroup:b});let x=e.split(`
170
- `),S=x.length,C=S>0&&x[S-1]===""?S-1:S;if(i||o){let k=0,T=(o||l)&&!r;for(let O=0;O<C;O++)if(t.lastIndex=0,T)for(let L=t.exec(x[O]);L!==null;L=t.exec(x[O]))k++,L[0].length===0&&t.lastIndex++;else t.test(x[O])!==r&&k++;return{output:`${a?`${a}:${k}`:String(k)}
171
- `,matched:k>0,matchCount:k}}if(c===0&&u===0&&!y){let k=[],T=!1,R=0,O=0;for(let L=0;L<C&&!(f>0&&R>=f);L++){let ie=x[L];if(t.lastIndex=0,t.test(ie)!==r)if(T=!0,R++,l){t.lastIndex=0;for(let te=t.exec(ie);te!==null;te=t.exec(ie)){let z=b!==void 0?te[b]??"":te[0],ee=g!==null?Sf(g,te):z,Ee=a?`${a}:`:"";d&&(Ee+=`${O+te.index}:`),s&&(Ee+=`${L+1}:`),p&&(Ee+=`${te.index+1}:`),k.push(Ee+ee),te[0].length===0&&t.lastIndex++}}else if(m){t.lastIndex=0;for(let te=t.exec(ie);te!==null;te=t.exec(ie)){let z=a?`${a}:`:"";d&&(z+=`${O+te.index}:`),s&&(z+=`${L+1}:`),p&&(z+=`${te.index+1}:`),k.push(z+ie),te[0].length===0&&t.lastIndex++}}else{t.lastIndex=0;let te=t.exec(ie),z=te?te.index+1:1,ee=ie;g!==null&&(t.lastIndex=0,ee=t.replace(ie,(...oe)=>{if(oe[0].length===0)return"";let j=oe,ve=oe[oe.length-1];return typeof ve=="object"&&ve!==null?(j.groups=ve,j.input=oe[oe.length-2],j.index=oe[oe.length-3]):(j.input=oe[oe.length-1],j.index=oe[oe.length-2]),Sf(g,j)}));let Ee=a?`${a}:`:"";d&&(Ee+=`${O+(te?te.index:0)}:`),s&&(Ee+=`${L+1}:`),p&&(Ee+=`${z}:`),k.push(Ee+ee)}O+=ie.length+1}return{output:k.length>0?`${k.join(`
170
+ `),S=x.length,C=S>0&&x[S-1]===""?S-1:S;if(i||o){let k=0,T=(o||l)&&!r;for(let $=0;$<C;$++)if(t.lastIndex=0,T)for(let _=t.exec(x[$]);_!==null;_=t.exec(x[$]))k++,_[0].length===0&&t.lastIndex++;else t.test(x[$])!==r&&k++;return{output:`${a?`${a}:${k}`:String(k)}
171
+ `,matched:k>0,matchCount:k}}if(c===0&&u===0&&!y){let k=[],T=!1,O=0,$=0;for(let _=0;_<C&&!(f>0&&O>=f);_++){let ie=x[_];if(t.lastIndex=0,t.test(ie)!==r)if(T=!0,O++,l){t.lastIndex=0;for(let te=t.exec(ie);te!==null;te=t.exec(ie)){let z=b!==void 0?te[b]??"":te[0],ee=g!==null?Sf(g,te):z,Ee=a?`${a}:`:"";d&&(Ee+=`${$+te.index}:`),s&&(Ee+=`${_+1}:`),p&&(Ee+=`${te.index+1}:`),k.push(Ee+ee),te[0].length===0&&t.lastIndex++}}else if(m){t.lastIndex=0;for(let te=t.exec(ie);te!==null;te=t.exec(ie)){let z=a?`${a}:`:"";d&&(z+=`${$+te.index}:`),s&&(z+=`${_+1}:`),p&&(z+=`${te.index+1}:`),k.push(z+ie),te[0].length===0&&t.lastIndex++}}else{t.lastIndex=0;let te=t.exec(ie),z=te?te.index+1:1,ee=ie;g!==null&&(t.lastIndex=0,ee=t.replace(ie,(...oe)=>{if(oe[0].length===0)return"";let j=oe,ve=oe[oe.length-1];return typeof ve=="object"&&ve!==null?(j.groups=ve,j.input=oe[oe.length-2],j.index=oe[oe.length-3]):(j.input=oe[oe.length-1],j.index=oe[oe.length-2]),Sf(g,j)}));let Ee=a?`${a}:`:"";d&&(Ee+=`${$+(te?te.index:0)}:`),s&&(Ee+=`${_+1}:`),p&&(Ee+=`${z}:`),k.push(Ee+ee)}$+=ie.length+1}return{output:k.length>0?`${k.join(`
172
172
  `)}
173
- `:"",matched:T,matchCount:R}}if(y){let k=[],T=!1,R=0;for(let O=0;O<C;O++){let L=x[O];t.lastIndex=0;let ue=t.test(L)!==r;ue&&(T=!0,R++);let te=ue?":":"-",z=a?`${a}${te}`:"";s&&(z+=`${O+1}${te}`),k.push(z+L)}return{output:k.length>0?`${k.join(`
173
+ `:"",matched:T,matchCount:O}}if(y){let k=[],T=!1,O=0;for(let $=0;$<C;$++){let _=x[$];t.lastIndex=0;let ue=t.test(_)!==r;ue&&(T=!0,O++);let te=ue?":":"-",z=a?`${a}${te}`:"";s&&(z+=`${$+1}${te}`),k.push(z+_)}return{output:k.length>0?`${k.join(`
174
174
  `)}
175
- `:"",matched:T,matchCount:R}}let $=[],M=0,_=new Set,B=-1,v=[];for(let k=0;k<C&&!(f>0&&M>=f);k++)t.lastIndex=0,t.test(x[k])!==r&&(v.push(k),M++);for(let k of v){let T=Math.max(0,k-c);B>=0&&T>B+1&&$.push(h);for(let O=T;O<k;O++)if(!_.has(O)){_.add(O),B=O;let L=x[O];s&&(L=`${O+1}-${L}`),a&&(L=`${a}-${L}`),$.push(L)}if(!_.has(k)){_.add(k),B=k;let O=x[k];if(l){t.lastIndex=0;for(let L=t.exec(O);L!==null;L=t.exec(O)){let ie=b!==void 0?L[b]??"":L[0],ue=g!==null?g:ie,te=a?`${a}:`:"";s&&(te+=`${k+1}:`),p&&(te+=`${L.index+1}:`),$.push(te+ue),L[0].length===0&&t.lastIndex++}}else{let L=O;s&&(L=`${k+1}:${L}`),a&&(L=`${a}:${L}`),$.push(L)}}let R=Math.min(C-1,k+u);for(let O=k+1;O<=R;O++)if(!_.has(O)){_.add(O),B=O;let L=x[O];s&&(L=`${O+1}-${L}`),a&&(L=`${a}-${L}`),$.push(L)}}return{output:$.length>0?`${$.join(`
175
+ `:"",matched:T,matchCount:O}}let R=[],U=0,L=new Set,B=-1,v=[];for(let k=0;k<C&&!(f>0&&U>=f);k++)t.lastIndex=0,t.test(x[k])!==r&&(v.push(k),U++);for(let k of v){let T=Math.max(0,k-c);B>=0&&T>B+1&&R.push(h);for(let $=T;$<k;$++)if(!L.has($)){L.add($),B=$;let _=x[$];s&&(_=`${$+1}-${_}`),a&&(_=`${a}-${_}`),R.push(_)}if(!L.has(k)){L.add(k),B=k;let $=x[k];if(l){t.lastIndex=0;for(let _=t.exec($);_!==null;_=t.exec($)){let ie=b!==void 0?_[b]??"":_[0],ue=g!==null?g:ie,te=a?`${a}:`:"";s&&(te+=`${k+1}:`),p&&(te+=`${_.index+1}:`),R.push(te+ue),_[0].length===0&&t.lastIndex++}}else{let _=$;s&&(_=`${k+1}:${_}`),a&&(_=`${a}:${_}`),R.push(_)}}let O=Math.min(C-1,k+u);for(let $=k+1;$<=O;$++)if(!L.has($)){L.add($),B=$;let _=x[$];s&&(_=`${$+1}-${_}`),a&&(_=`${a}-${_}`),R.push(_)}}return{output:R.length>0?`${R.join(`
176
176
  `)}
177
- `:"",matched:M>0,matchCount:M}}function L7(e,t,n){let{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:h,showColumn:p,showByteOffset:m,replace:d,kResetGroup:g}=n,y=e.split(`
177
+ `:"",matched:U>0,matchCount:U}}function L7(e,t,n){let{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:o,filename:a,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:h,showColumn:p,showByteOffset:m,replace:d,kResetGroup:g}=n,y=e.split(`
178
178
  `),w=y.length,b=w>0&&y[w-1]===""?w-1:w,x=[0];for(let v=0;v<e.length;v++)e[v]===`
179
- `&&x.push(v+1);let S=v=>{let k=0;for(let T=0;T<x.length&&!(x[T]>v);T++)k=T;return k},C=v=>{let k=S(v);return v-x[k]+1},$=[];t.lastIndex=0;for(let v=t.exec(e);v!==null&&!(f>0&&$.length>=f);v=t.exec(e)){let k=S(v.index),T=S(v.index+Math.max(0,v[0].length-1)),R=g!==void 0?v[g]??"":v[0];$.push({startLine:k,endLine:T,byteOffset:v.index,column:C(v.index),matchText:R}),v[0].length===0&&t.lastIndex++}if(i||o){let v;if(o)v=r?0:$.length;else{let T=new Set;for(let R of $)for(let O=R.startLine;O<=R.endLine;O++)T.add(O);v=r?b-T.size:T.size}return{output:`${a?`${a}:${v}`:String(v)}
180
- `,matched:v>0,matchCount:v}}if(r){let v=new Set;for(let T of $)for(let R=T.startLine;R<=T.endLine;R++)v.add(R);let k=[];for(let T=0;T<b;T++)if(!v.has(T)){let R=y[T];s&&(R=`${T+1}:${R}`),a&&(R=`${a}:${R}`),k.push(R)}return{output:k.length>0?`${k.join(`
179
+ `&&x.push(v+1);let S=v=>{let k=0;for(let T=0;T<x.length&&!(x[T]>v);T++)k=T;return k},C=v=>{let k=S(v);return v-x[k]+1},R=[];t.lastIndex=0;for(let v=t.exec(e);v!==null&&!(f>0&&R.length>=f);v=t.exec(e)){let k=S(v.index),T=S(v.index+Math.max(0,v[0].length-1)),O=g!==void 0?v[g]??"":v[0];R.push({startLine:k,endLine:T,byteOffset:v.index,column:C(v.index),matchText:O}),v[0].length===0&&t.lastIndex++}if(i||o){let v;if(o)v=r?0:R.length;else{let T=new Set;for(let O of R)for(let $=O.startLine;$<=O.endLine;$++)T.add($);v=r?b-T.size:T.size}return{output:`${a?`${a}:${v}`:String(v)}
180
+ `,matched:v>0,matchCount:v}}if(r){let v=new Set;for(let T of R)for(let O=T.startLine;O<=T.endLine;O++)v.add(O);let k=[];for(let T=0;T<b;T++)if(!v.has(T)){let O=y[T];s&&(O=`${T+1}:${O}`),a&&(O=`${a}:${O}`),k.push(O)}return{output:k.length>0?`${k.join(`
181
181
  `)}
182
- `:"",matched:k.length>0,matchCount:k.length}}if($.length===0)return{output:"",matched:!1,matchCount:0};let M=new Set,_=-1,B=[];for(let v of $){let k=Math.max(0,v.startLine-c),T=Math.min(b-1,v.endLine+u);_>=0&&k>_+1&&B.push(h);for(let R=k;R<v.startLine;R++)if(!M.has(R)){M.add(R),_=R;let O=y[R];s&&(O=`${R+1}-${O}`),a&&(O=`${a}-${O}`),B.push(O)}if(l){let R=d!==null?d:v.matchText,O=a?`${a}:`:"";m&&(O+=`${v.byteOffset}:`),s&&(O+=`${v.startLine+1}:`),p&&(O+=`${v.column}:`),B.push(O+R);for(let L=v.startLine;L<=v.endLine;L++)M.add(L),_=L}else for(let R=v.startLine;R<=v.endLine&&R<b;R++)if(!M.has(R)){M.add(R),_=R;let O=y[R];d!==null&&R===v.startLine&&(t.lastIndex=0,O=t.replace(O,d));let L=a?`${a}:`:"";m&&R===v.startLine&&(L+=`${v.byteOffset}:`),s&&(L+=`${R+1}:`),p&&R===v.startLine&&(L+=`${v.column}:`),B.push(L+O)}for(let R=v.endLine+1;R<=T;R++)if(!M.has(R)){M.add(R),_=R;let O=y[R];s&&(O=`${R+1}-${O}`),a&&(O=`${a}-${O}`),B.push(O)}}return{output:B.length>0?`${B.join(`
182
+ `:"",matched:k.length>0,matchCount:k.length}}if(R.length===0)return{output:"",matched:!1,matchCount:0};let U=new Set,L=-1,B=[];for(let v of R){let k=Math.max(0,v.startLine-c),T=Math.min(b-1,v.endLine+u);L>=0&&k>L+1&&B.push(h);for(let O=k;O<v.startLine;O++)if(!U.has(O)){U.add(O),L=O;let $=y[O];s&&($=`${O+1}-${$}`),a&&($=`${a}-${$}`),B.push($)}if(l){let O=d!==null?d:v.matchText,$=a?`${a}:`:"";m&&($+=`${v.byteOffset}:`),s&&($+=`${v.startLine+1}:`),p&&($+=`${v.column}:`),B.push($+O);for(let _=v.startLine;_<=v.endLine;_++)U.add(_),L=_}else for(let O=v.startLine;O<=v.endLine&&O<b;O++)if(!U.has(O)){U.add(O),L=O;let $=y[O];d!==null&&O===v.startLine&&(t.lastIndex=0,$=t.replace($,d));let _=a?`${a}:`:"";m&&O===v.startLine&&(_+=`${v.byteOffset}:`),s&&(_+=`${O+1}:`),p&&O===v.startLine&&(_+=`${v.column}:`),B.push(_+$)}for(let O=v.endLine+1;O<=T;O++)if(!U.has(O)){U.add(O),L=O;let $=y[O];s&&($=`${O+1}-${$}`),a&&($=`${a}-${$}`),B.push($)}}return{output:B.length>0?`${B.join(`
183
183
  `)}
184
- `:"",matched:!0,matchCount:$.length}}var Cf=I(()=>{"use strict"});function Nf(e){let t="",n=0;for(;n<e.length;){if(e.slice(n,n+7)==="[[:<:]]"){t+="\\b",n+=7;continue}if(e.slice(n,n+7)==="[[:>:]]"){t+="\\b",n+=7;continue}if(e[n]==="["){let r="[";for(n++,n<e.length&&(e[n]==="^"||e[n]==="!")&&(r+="^",n++),n<e.length&&e[n]==="]"&&(r+="\\]",n++);n<e.length&&e[n]!=="]";){if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let s=e.indexOf(":]",n+2);if(s!==-1){let i=e.slice(n+2,s),o=_7.get(i);if(o){r+=o,n=s+2;continue}}}if(e[n]==="\\"&&n+1<e.length){r+=e[n]+e[n+1],n+=2;continue}r+=e[n],n++}n<e.length&&e[n]==="]"&&(r+="]",n++),t+=r;continue}if(e[n]==="\\"&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++}return t}function Zr(e,t){let n,r;switch(t.mode){case"fixed":n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":{if(n=Nf(e),n=n.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),t.mode==="perl"){n=M7(n),n=F7(n),n=U7(n);let o=z7(n);n=o.pattern,r=o.kResetGroup}break}default:n=Nf(e),n=V7(n);break}t.wholeWord&&(n=`\\b(?:${n})\\b`),t.lineRegexp&&(n=`^${n}$`);let s=/\\u\{[0-9A-Fa-f]+\}/.test(n),i="g"+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.multilineDotall?"s":"")+(s?"u":"");return{regex:V(n,i),kResetGroup:r}}function M7(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length&&e[n+1]==="Q"){n+=2;let r="";for(;n<e.length;){if(e[n]==="\\"&&n+1<e.length&&e[n+1]==="E"){n+=2;break}r+=e[n],n++}t+=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}else t+=e[n],n++;return t}function F7(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function U7(e){let t="",n=0;for(;n<e.length;){if(e[n]==="("&&n+1<e.length&&e[n+1]==="?"){let r=e.slice(n).match(/^\(\?([imsx]*)(-[imsx]*)?(:|$|\))/);if(r){let s=r[1]||"",i=r[2]||"",o=r[3];if(o===":"){let a=n+r[0].length-1,l=W7(e,n);if(l!==-1){let c=e.slice(a+1,l),u=B7(c,s,i);t+=`(?:${u})`,n=l+1;continue}}else if(o===")"||o===""){n+=r[0].length;continue}}}t+=e[n],n++}return t}function W7(e,t){let n=0,r=t;for(;r<e.length;){if(e[r]==="\\"){r+=2;continue}if(e[r]==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r++,r++;r++;continue}if(e[r]==="(")n++;else if(e[r]===")"&&(n--,n===0))return r;r++}return-1}function B7(e,t,n){let r=e;return t.includes("i")&&(r=H7(r)),r}function H7(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="\\"){n+1<e.length?(t+=r+e[n+1],n+=2):(t+=r,n++);continue}if(r==="["){t+=r,n++,n<e.length&&e[n]==="^"&&(t+=e[n],n++);let s=[];for(;n<e.length&&e[n]!=="]";)if(e[n]==="\\")s.push(e[n]),n++,n<e.length&&(s.push(e[n]),n++);else if(e[n]==="-"&&s.length>0&&n+1<e.length&&e[n+1]!=="]"){let i=s[s.length-1],o=e[n+1];s.push("-"),s.push(o),/[a-z]/.test(i)&&/[a-z]/.test(o)?(s.push(i.toUpperCase()),s.push("-"),s.push(o.toUpperCase())):/[A-Z]/.test(i)&&/[A-Z]/.test(o)&&(s.push(i.toLowerCase()),s.push("-"),s.push(o.toLowerCase())),n+=2}else{let i=e[n];if(s.push(i),/[a-zA-Z]/.test(i)){let o=i===i.toLowerCase()?i.toUpperCase():i.toLowerCase();s.includes(o)||s.push(o)}n++}t+=s.join(""),n<e.length&&(t+=e[n],n++);continue}if(/[a-zA-Z]/.test(r)){let s=r.toLowerCase(),i=r.toUpperCase();t+=`[${i}${s}]`}else t+=r;n++}return t}function z7(e){let t=j7(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),s=G7(n);return{pattern:`(?:${n})(${r})`,kResetGroup:s+1}}function j7(e){let t=0;for(;t<e.length-1;)if(e[t]==="\\"){if(e[t+1]==="K"){let n=0,r=t-1;for(;r>=0&&e[r]==="\\";)n++,r--;if(n%2===0)return t}t+=2}else t++;return-1}function G7(e){let t=0,n=0;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n++,n++;n++;continue}if(e[n]==="(")if(n+1<e.length&&e[n+1]==="?"){if(n+2<e.length){let r=e[n+2];if(r===":"||r==="="||r==="!"){n++;continue}if(r==="<"&&n+3<e.length){let s=e[n+3];if(s==="="||s==="!"){n++;continue}t++,n++;continue}}}else t++;n++}return t}function qo(e){let t=e.replace(/\$\{0\}|\$0(?![0-9])/g,"$$&");return t=t.replace(/\$\{([^0-9}][^}]*)\}/g,"$$<$1>"),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,"$$<$1>"),t}function V7(e){let t="",n=0,r=!0,s=0;for(;n<e.length;){let i=e[n];if(i==="["){for(t+=i,n++,n<e.length&&(e[n]==="^"||e[n]==="!")&&(t+=e[n],n++),n<e.length&&e[n]==="]"&&(t+=e[n],n++);n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?(t+=e[n]+e[n+1],n+=2):(t+=e[n],n++);n<e.length&&e[n]==="]"&&(t+=e[n],n++),r=!1;continue}if(i==="\\"&&n+1<e.length){let o=e[n+1];if(o==="|"){t+="|",n+=2,r=!0;continue}if(o==="("){t+="(",n+=2,s++,r=!0;continue}if(o===")"){t+=")",n+=2,s=Math.max(0,s-1),r=!1;continue}if(o==="{"){let l=e.slice(n).match(/^\\{(\d+)(,(\d*)?)?\\}/);if(l){let c=l[1],u=l[2]!==void 0,f=l[3]||"";u?t+=`{${c},${f}}`:t+=`{${c}}`,n+=l[0].length,r=!1;continue}t+="\\{",n+=2,r=!1;continue}if(o==="}"){t+="\\}",n+=2,r=!1;continue}t+=i+o,n+=2,r=!1;continue}if(i==="*"&&r){t+="\\*",n++;continue}if(i==="^"){if(r){t+="^",n++;continue}t+="\\^",n++;continue}if(i==="$"){let o=n===e.length-1,a=n+2<e.length&&e[n+1]==="\\"&&e[n+2]===")";o||a?t+="$":t+="\\$",n++,r=!1;continue}i==="+"||i==="?"||i==="|"||i==="("||i===")"||i==="{"||i==="}"?t+=`\\${i}`:t+=i,n++,r=!1}return t}var _7,kf=I(()=>{"use strict";Me();_7=new Map([["alpha","a-zA-Z"],["digit","0-9"],["alnum","a-zA-Z0-9"],["lower","a-z"],["upper","A-Z"],["xdigit","0-9A-Fa-f"],["space"," \\t\\n\\r\\f\\v"],["blank"," \\t"],["punct","!-/:-@\\[-`{-~"],["graph","!-~"],["print"," -~"],["cntrl","\\x00-\\x1F\\x7F"],["ascii","\\x00-\\x7F"],["word","a-zA-Z0-9_"]])});var Zo=I(()=>{"use strict";Cf();kf()});var zs={};Q(zs,{egrepCommand:()=>K7,fgrepCommand:()=>Q7,grepCommand:()=>Qo});async function vf(e,t,n,r){let s=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(s)).isDirectory){let a=e.split("/").pop()||"";if(t){let l=t.replace(/^\//,"");dt(a,l,{stripQuotes:!0})&&r.push(e)}return}let o=await n.fs.readdir(s);for(let a of o){let l=e==="."?a:`${e}/${a}`,c=n.fs.resolvePath(n.cwd,l);if((await n.fs.stat(c)).isDirectory)await vf(l,t,n,r);else if(t){let f=t.replace(/^\//,"");dt(a,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function Z7(e,t){let n=[],r=e.lastIndexOf("/"),s,i;if(r===-1?(s=t.cwd,i=e):(s=e.slice(0,r)||"/",i=e.slice(r+1)),e.includes("**")){let a=[],l=e.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await vf(c,u,t,a),a.map(f=>({path:f}))}let o=t.fs.resolvePath(t.cwd,s);try{if(t.fs.readdirWithFileTypes){let a=await t.fs.readdirWithFileTypes(o);for(let l of a)if(dt(l.name,i,{stripQuotes:!0})){let c=r===-1?l.name:`${s}/${l.name}`;n.push({path:c,isFile:l.isFile})}}else{let a=await t.fs.readdir(o);for(let l of a)if(dt(l,i,{stripQuotes:!0})){let c=r===-1?l:`${s}/${l}`;n.push({path:c})}}}catch{}return n.sort((a,l)=>a.path.localeCompare(l.path))}async function Hs(e,t,n=[],r=[],s=[],i){let o=t.fs.resolvePath(t.cwd,e),a=[];try{let l,c;if(i!==void 0)l=i,c=!i;else{let f=await t.fs.stat(o);l=f.isFile,c=f.isDirectory}if(l){let f=e.split("/").pop()||e;return r.length>0&&r.some(h=>dt(f,h,{stripQuotes:!0}))?[]:n.length>0&&!n.some(h=>dt(f,h,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!c)return[];let u=e.split("/").pop()||e;if(s.length>0&&s.some(f=>dt(u,f,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let f=await t.fs.readdirWithFileTypes(o);for(let h of f){if(h.name.startsWith("."))continue;let p=e==="."?h.name:`${e}/${h.name}`,m=await Hs(p,t,n,r,s,h.isFile);a.push(...m)}}else{let f=await t.fs.readdir(o);for(let h of f){if(h.startsWith("."))continue;let p=e==="."?h:`${e}/${h}`,m=await Hs(p,t,n,r,s);a.push(...m)}}}catch{}return a}var q7,Qo,Q7,K7,js=I(()=>{"use strict";Vo();ne();Zo();q7={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"]},Qo={name:"grep",async execute(e,t){if(U(e))return F(q7);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,h=!1,p=!1,m=!1,d=!1,g=!1,y=0,w=0,b=0,x=[],S=[],C=[],$=null,M=[];for(let z=0;z<e.length;z++){let ee=e[z];if(ee.startsWith("-")&&ee!=="-"){if(ee==="-e"&&z+1<e.length){$=e[++z];continue}if(ee.startsWith("--include=")){x.push(ee.slice(10));continue}if(ee.startsWith("--exclude=")){S.push(ee.slice(10));continue}if(ee.startsWith("--exclude-dir=")){C.push(ee.slice(14));continue}if(ee.startsWith("--max-count=")){y=parseInt(ee.slice(12),10);continue}let Ee=ee.match(/^-m(\d+)$/);if(Ee){y=parseInt(Ee[1],10);continue}if(ee==="-m"&&z+1<e.length){y=parseInt(e[++z],10);continue}let oe=ee.match(/^-([ABC])(\d+)$/);if(oe){let j=parseInt(oe[2],10);oe[1]==="A"?b=j:oe[1]==="B"?w=j:oe[1]==="C"&&(w=j,b=j);continue}if((ee==="-A"||ee==="-B"||ee==="-C")&&z+1<e.length){let j=parseInt(e[++z],10);ee==="-A"?b=j:ee==="-B"?w=j:(w=j,b=j);continue}let ke=ee.startsWith("--")?[ee]:ee.slice(1).split("");for(let j of ke)if(j==="i"||j==="--ignore-case")n=!0;else if(j==="n"||j==="--line-number")r=!0;else if(j==="v"||j==="--invert-match")s=!0;else if(j==="c"||j==="--count")i=!0;else if(j==="l"||j==="--files-with-matches")o=!0;else if(j==="L"||j==="--files-without-match")a=!0;else if(j==="r"||j==="R"||j==="--recursive")l=!0;else if(j==="w"||j==="--word-regexp")c=!0;else if(j==="x"||j==="--line-regexp")u=!0;else if(j==="E"||j==="--extended-regexp")f=!0;else if(j==="P"||j==="--perl-regexp")h=!0;else if(j==="F"||j==="--fixed-strings")p=!0;else if(j==="o"||j==="--only-matching")m=!0;else if(j==="h"||j==="--no-filename")d=!0;else if(j==="q"||j==="--quiet"||j==="--silent")g=!0;else{if(j.startsWith("--"))return X("grep",j);if(j.length===1)return X("grep",`-${j}`)}}else $===null?$=ee:M.push(ee)}if($===null)return{stdout:"",stderr:`grep: missing pattern
185
- `,exitCode:2};let _=p?"fixed":f?"extended":h?"perl":"basic",B,v;try{let z=Zr($,{mode:_,ignoreCase:n,wholeWord:c,lineRegexp:u});B=z.regex,v=z.kResetGroup}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${$}
186
- `,exitCode:2}}if(M.length===0&&t.stdin!==void 0){let z=hr(t.stdin,B,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:"",onlyMatching:m,beforeContext:w,afterContext:b,maxCount:y,kResetGroup:v});return g?{stdout:"",stderr:"",exitCode:z.matched?0:1}:{stdout:z.output,stderr:"",exitCode:z.matched?0:1}}if(M.length===0)return{stdout:"",stderr:`grep: no input files
187
- `,exitCode:2};let k="",T="",R=!1,O=!1,L=[];for(let z of M)if(z.includes("*")||z.includes("?")||z.includes("[")){let ee=await Z7(z,t);if(l)for(let Ee of ee){let oe=await Hs(Ee.path,t,x,S,C,Ee.isFile);L.push(...oe)}else L.push(...ee)}else if(l){let ee=await Hs(z,t,x,S,C);L.push(...ee)}else L.push({path:z});let ie=(L.length>1||l)&&!d,ue=50;for(let z=0;z<L.length;z+=ue){let ee=L.slice(z,z+ue),Ee=await Promise.all(ee.map(async oe=>{let ke=oe.path,j=ke.split("/").pop()||ke;if(S.length>0&&!l&&S.some(ve=>dt(j,ve,{stripQuotes:!0}))||x.length>0&&!l&&!x.some(ve=>dt(j,ve,{stripQuotes:!0})))return null;try{let ve=t.fs.resolvePath(t.cwd,ke),_e=!1;if(oe.isFile===void 0?_e=(await t.fs.stat(ve)).isDirectory:_e=!oe.isFile,_e)return l?null:{error:`grep: ${ke}: Is a directory
184
+ `:"",matched:!0,matchCount:R.length}}var Cf=I(()=>{"use strict"});function Nf(e){let t="",n=0;for(;n<e.length;){if(e.slice(n,n+7)==="[[:<:]]"){t+="\\b",n+=7;continue}if(e.slice(n,n+7)==="[[:>:]]"){t+="\\b",n+=7;continue}if(e[n]==="["){let r="[";for(n++,n<e.length&&(e[n]==="^"||e[n]==="!")&&(r+="^",n++),n<e.length&&e[n]==="]"&&(r+="\\]",n++);n<e.length&&e[n]!=="]";){if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let s=e.indexOf(":]",n+2);if(s!==-1){let i=e.slice(n+2,s),o=_7.get(i);if(o){r+=o,n=s+2;continue}}}if(e[n]==="\\"&&n+1<e.length){r+=e[n]+e[n+1],n+=2;continue}r+=e[n],n++}n<e.length&&e[n]==="]"&&(r+="]",n++),t+=r;continue}if(e[n]==="\\"&&n+1<e.length){t+=e[n]+e[n+1],n+=2;continue}t+=e[n],n++}return t}function Zr(e,t){let n,r;switch(t.mode){case"fixed":n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":{if(n=Nf(e),n=n.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),t.mode==="perl"){n=M7(n),n=F7(n),n=U7(n);let o=z7(n);n=o.pattern,r=o.kResetGroup}break}default:n=Nf(e),n=V7(n);break}t.wholeWord&&(n=`\\b(?:${n})\\b`),t.lineRegexp&&(n=`^${n}$`);let s=/\\u\{[0-9A-Fa-f]+\}/.test(n),i="g"+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.multilineDotall?"s":"")+(s?"u":"");return{regex:V(n,i),kResetGroup:r}}function M7(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length&&e[n+1]==="Q"){n+=2;let r="";for(;n<e.length;){if(e[n]==="\\"&&n+1<e.length&&e[n+1]==="E"){n+=2;break}r+=e[n],n++}t+=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}else t+=e[n],n++;return t}function F7(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function U7(e){let t="",n=0;for(;n<e.length;){if(e[n]==="("&&n+1<e.length&&e[n+1]==="?"){let r=e.slice(n).match(/^\(\?([imsx]*)(-[imsx]*)?(:|$|\))/);if(r){let s=r[1]||"",i=r[2]||"",o=r[3];if(o===":"){let a=n+r[0].length-1,l=W7(e,n);if(l!==-1){let c=e.slice(a+1,l),u=B7(c,s,i);t+=`(?:${u})`,n=l+1;continue}}else if(o===")"||o===""){n+=r[0].length;continue}}}t+=e[n],n++}return t}function W7(e,t){let n=0,r=t;for(;r<e.length;){if(e[r]==="\\"){r+=2;continue}if(e[r]==="["){for(r++;r<e.length&&e[r]!=="]";)e[r]==="\\"&&r++,r++;r++;continue}if(e[r]==="(")n++;else if(e[r]===")"&&(n--,n===0))return r;r++}return-1}function B7(e,t,n){let r=e;return t.includes("i")&&(r=H7(r)),r}function H7(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r==="\\"){n+1<e.length?(t+=r+e[n+1],n+=2):(t+=r,n++);continue}if(r==="["){t+=r,n++,n<e.length&&e[n]==="^"&&(t+=e[n],n++);let s=[];for(;n<e.length&&e[n]!=="]";)if(e[n]==="\\")s.push(e[n]),n++,n<e.length&&(s.push(e[n]),n++);else if(e[n]==="-"&&s.length>0&&n+1<e.length&&e[n+1]!=="]"){let i=s[s.length-1],o=e[n+1];s.push("-"),s.push(o),/[a-z]/.test(i)&&/[a-z]/.test(o)?(s.push(i.toUpperCase()),s.push("-"),s.push(o.toUpperCase())):/[A-Z]/.test(i)&&/[A-Z]/.test(o)&&(s.push(i.toLowerCase()),s.push("-"),s.push(o.toLowerCase())),n+=2}else{let i=e[n];if(s.push(i),/[a-zA-Z]/.test(i)){let o=i===i.toLowerCase()?i.toUpperCase():i.toLowerCase();s.includes(o)||s.push(o)}n++}t+=s.join(""),n<e.length&&(t+=e[n],n++);continue}if(/[a-zA-Z]/.test(r)){let s=r.toLowerCase(),i=r.toUpperCase();t+=`[${i}${s}]`}else t+=r;n++}return t}function z7(e){let t=j7(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),s=G7(n);return{pattern:`(?:${n})(${r})`,kResetGroup:s+1}}function j7(e){let t=0;for(;t<e.length-1;)if(e[t]==="\\"){if(e[t+1]==="K"){let n=0,r=t-1;for(;r>=0&&e[r]==="\\";)n++,r--;if(n%2===0)return t}t+=2}else t++;return-1}function G7(e){let t=0,n=0;for(;n<e.length;){if(e[n]==="\\"){n+=2;continue}if(e[n]==="["){for(n++;n<e.length&&e[n]!=="]";)e[n]==="\\"&&n++,n++;n++;continue}if(e[n]==="(")if(n+1<e.length&&e[n+1]==="?"){if(n+2<e.length){let r=e[n+2];if(r===":"||r==="="||r==="!"){n++;continue}if(r==="<"&&n+3<e.length){let s=e[n+3];if(s==="="||s==="!"){n++;continue}t++,n++;continue}}}else t++;n++}return t}function qo(e){let t=e.replace(/\$\{0\}|\$0(?![0-9])/g,"$$&");return t=t.replace(/\$\{([^0-9}][^}]*)\}/g,"$$<$1>"),t=t.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)(?![>0-9])/g,"$$<$1>"),t}function V7(e){let t="",n=0,r=!0,s=0;for(;n<e.length;){let i=e[n];if(i==="["){for(t+=i,n++,n<e.length&&(e[n]==="^"||e[n]==="!")&&(t+=e[n],n++),n<e.length&&e[n]==="]"&&(t+=e[n],n++);n<e.length&&e[n]!=="]";)e[n]==="\\"&&n+1<e.length?(t+=e[n]+e[n+1],n+=2):(t+=e[n],n++);n<e.length&&e[n]==="]"&&(t+=e[n],n++),r=!1;continue}if(i==="\\"&&n+1<e.length){let o=e[n+1];if(o==="|"){t+="|",n+=2,r=!0;continue}if(o==="("){t+="(",n+=2,s++,r=!0;continue}if(o===")"){t+=")",n+=2,s=Math.max(0,s-1),r=!1;continue}if(o==="{"){let l=e.slice(n).match(/^\\{(\d+)(,(\d*)?)?\\}/);if(l){let c=l[1],u=l[2]!==void 0,f=l[3]||"";u?t+=`{${c},${f}}`:t+=`{${c}}`,n+=l[0].length,r=!1;continue}t+="\\{",n+=2,r=!1;continue}if(o==="}"){t+="\\}",n+=2,r=!1;continue}t+=i+o,n+=2,r=!1;continue}if(i==="*"&&r){t+="\\*",n++;continue}if(i==="^"){if(r){t+="^",n++;continue}t+="\\^",n++;continue}if(i==="$"){let o=n===e.length-1,a=n+2<e.length&&e[n+1]==="\\"&&e[n+2]===")";o||a?t+="$":t+="\\$",n++,r=!1;continue}i==="+"||i==="?"||i==="|"||i==="("||i===")"||i==="{"||i==="}"?t+=`\\${i}`:t+=i,n++,r=!1}return t}var _7,kf=I(()=>{"use strict";Me();_7=new Map([["alpha","a-zA-Z"],["digit","0-9"],["alnum","a-zA-Z0-9"],["lower","a-z"],["upper","A-Z"],["xdigit","0-9A-Fa-f"],["space"," \\t\\n\\r\\f\\v"],["blank"," \\t"],["punct","!-/:-@\\[-`{-~"],["graph","!-~"],["print"," -~"],["cntrl","\\x00-\\x1F\\x7F"],["ascii","\\x00-\\x7F"],["word","a-zA-Z0-9_"]])});var Zo=I(()=>{"use strict";Cf();kf()});var zs={};Q(zs,{egrepCommand:()=>K7,fgrepCommand:()=>Q7,grepCommand:()=>Qo});async function vf(e,t,n,r){let s=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(s)).isDirectory){let a=e.split("/").pop()||"";if(t){let l=t.replace(/^\//,"");dt(a,l,{stripQuotes:!0})&&r.push(e)}return}let o=await n.fs.readdir(s);for(let a of o){let l=e==="."?a:`${e}/${a}`,c=n.fs.resolvePath(n.cwd,l);if((await n.fs.stat(c)).isDirectory)await vf(l,t,n,r);else if(t){let f=t.replace(/^\//,"");dt(a,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function Z7(e,t){let n=[],r=e.lastIndexOf("/"),s,i;if(r===-1?(s=t.cwd,i=e):(s=e.slice(0,r)||"/",i=e.slice(r+1)),e.includes("**")){let a=[],l=e.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await vf(c,u,t,a),a.map(f=>({path:f}))}let o=t.fs.resolvePath(t.cwd,s);try{if(t.fs.readdirWithFileTypes){let a=await t.fs.readdirWithFileTypes(o);for(let l of a)if(dt(l.name,i,{stripQuotes:!0})){let c=r===-1?l.name:`${s}/${l.name}`;n.push({path:c,isFile:l.isFile})}}else{let a=await t.fs.readdir(o);for(let l of a)if(dt(l,i,{stripQuotes:!0})){let c=r===-1?l:`${s}/${l}`;n.push({path:c})}}}catch{}return n.sort((a,l)=>a.path.localeCompare(l.path))}async function Hs(e,t,n=[],r=[],s=[],i){let o=t.fs.resolvePath(t.cwd,e),a=[];try{let l,c;if(i!==void 0)l=i,c=!i;else{let f=await t.fs.stat(o);l=f.isFile,c=f.isDirectory}if(l){let f=e.split("/").pop()||e;return r.length>0&&r.some(h=>dt(f,h,{stripQuotes:!0}))?[]:n.length>0&&!n.some(h=>dt(f,h,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!c)return[];let u=e.split("/").pop()||e;if(s.length>0&&s.some(f=>dt(u,f,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let f=await t.fs.readdirWithFileTypes(o);for(let h of f){if(h.name.startsWith("."))continue;let p=e==="."?h.name:`${e}/${h.name}`,m=await Hs(p,t,n,r,s,h.isFile);a.push(...m)}}else{let f=await t.fs.readdir(o);for(let h of f){if(h.startsWith("."))continue;let p=e==="."?h:`${e}/${h}`,m=await Hs(p,t,n,r,s);a.push(...m)}}}catch{}return a}var q7,Qo,Q7,K7,js=I(()=>{"use strict";Vo();ne();Zo();q7={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"]},Qo={name:"grep",async execute(e,t){if(F(e))return M(q7);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,h=!1,p=!1,m=!1,d=!1,g=!1,y=0,w=0,b=0,x=[],S=[],C=[],R=null,U=[];for(let z=0;z<e.length;z++){let ee=e[z];if(ee.startsWith("-")&&ee!=="-"){if(ee==="-e"&&z+1<e.length){R=e[++z];continue}if(ee.startsWith("--include=")){x.push(ee.slice(10));continue}if(ee.startsWith("--exclude=")){S.push(ee.slice(10));continue}if(ee.startsWith("--exclude-dir=")){C.push(ee.slice(14));continue}if(ee.startsWith("--max-count=")){y=parseInt(ee.slice(12),10);continue}let Ee=ee.match(/^-m(\d+)$/);if(Ee){y=parseInt(Ee[1],10);continue}if(ee==="-m"&&z+1<e.length){y=parseInt(e[++z],10);continue}let oe=ee.match(/^-([ABC])(\d+)$/);if(oe){let j=parseInt(oe[2],10);oe[1]==="A"?b=j:oe[1]==="B"?w=j:oe[1]==="C"&&(w=j,b=j);continue}if((ee==="-A"||ee==="-B"||ee==="-C")&&z+1<e.length){let j=parseInt(e[++z],10);ee==="-A"?b=j:ee==="-B"?w=j:(w=j,b=j);continue}let ke=ee.startsWith("--")?[ee]:ee.slice(1).split("");for(let j of ke)if(j==="i"||j==="--ignore-case")n=!0;else if(j==="n"||j==="--line-number")r=!0;else if(j==="v"||j==="--invert-match")s=!0;else if(j==="c"||j==="--count")i=!0;else if(j==="l"||j==="--files-with-matches")o=!0;else if(j==="L"||j==="--files-without-match")a=!0;else if(j==="r"||j==="R"||j==="--recursive")l=!0;else if(j==="w"||j==="--word-regexp")c=!0;else if(j==="x"||j==="--line-regexp")u=!0;else if(j==="E"||j==="--extended-regexp")f=!0;else if(j==="P"||j==="--perl-regexp")h=!0;else if(j==="F"||j==="--fixed-strings")p=!0;else if(j==="o"||j==="--only-matching")m=!0;else if(j==="h"||j==="--no-filename")d=!0;else if(j==="q"||j==="--quiet"||j==="--silent")g=!0;else{if(j.startsWith("--"))return X("grep",j);if(j.length===1)return X("grep",`-${j}`)}}else R===null?R=ee:U.push(ee)}if(R===null)return{stdout:"",stderr:`grep: missing pattern
185
+ `,exitCode:2};let L=p?"fixed":f?"extended":h?"perl":"basic",B,v;try{let z=Zr(R,{mode:L,ignoreCase:n,wholeWord:c,lineRegexp:u});B=z.regex,v=z.kResetGroup}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${R}
186
+ `,exitCode:2}}if(U.length===0&&t.stdin!==void 0){let z=hr(t.stdin,B,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:"",onlyMatching:m,beforeContext:w,afterContext:b,maxCount:y,kResetGroup:v});return g?{stdout:"",stderr:"",exitCode:z.matched?0:1}:{stdout:z.output,stderr:"",exitCode:z.matched?0:1}}if(U.length===0)return{stdout:"",stderr:`grep: no input files
187
+ `,exitCode:2};let k="",T="",O=!1,$=!1,_=[];for(let z of U)if(z.includes("*")||z.includes("?")||z.includes("[")){let ee=await Z7(z,t);if(l)for(let Ee of ee){let oe=await Hs(Ee.path,t,x,S,C,Ee.isFile);_.push(...oe)}else _.push(...ee)}else if(l){let ee=await Hs(z,t,x,S,C);_.push(...ee)}else _.push({path:z});let ie=(_.length>1||l)&&!d,ue=50;for(let z=0;z<_.length;z+=ue){let ee=_.slice(z,z+ue),Ee=await Promise.all(ee.map(async oe=>{let ke=oe.path,j=ke.split("/").pop()||ke;if(S.length>0&&!l&&S.some(ve=>dt(j,ve,{stripQuotes:!0}))||x.length>0&&!l&&!x.some(ve=>dt(j,ve,{stripQuotes:!0})))return null;try{let ve=t.fs.resolvePath(t.cwd,ke),_e=!1;if(oe.isFile===void 0?_e=(await t.fs.stat(ve)).isDirectory:_e=!oe.isFile,_e)return l?null:{error:`grep: ${ke}: Is a directory
188
188
  `};let ze=await t.fs.readFile(ve),Ye=hr(ze,B,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:ie?ke:"",onlyMatching:m,beforeContext:w,afterContext:b,maxCount:y,kResetGroup:v});return{file:ke,result:Ye}}catch{return{error:`grep: ${ke}: No such file or directory
189
- `}}}));for(let oe of Ee){if(oe===null)continue;if("error"in oe&&oe.error){T+=oe.error,oe.error.includes("Is a directory")||(O=!0);continue}if(!("file"in oe)||!oe.result)continue;let{file:ke,result:j}=oe;if(j.matched){if(R=!0,g)return{stdout:"",stderr:"",exitCode:0};o?k+=`${ke}
189
+ `}}}));for(let oe of Ee){if(oe===null)continue;if("error"in oe&&oe.error){T+=oe.error,oe.error.includes("Is a directory")||($=!0);continue}if(!("file"in oe)||!oe.result)continue;let{file:ke,result:j}=oe;if(j.matched){if(O=!0,g)return{stdout:"",stderr:"",exitCode:0};o?k+=`${ke}
190
190
  `:a||(k+=j.output)}else a?k+=`${ke}
191
- `:i&&!o&&(k+=j.output)}}let te;return O?te=2:a?te=k.length>0?0:1:te=R?0:1,g?{stdout:"",stderr:"",exitCode:te}:{stdout:k,stderr:T,exitCode:te}}};Q7={name:"fgrep",async execute(e,t){return Qo.execute(["-F",...e],t)}},K7={name:"egrep",async execute(e,t){return Qo.execute(["-E",...e],t)}}});function Rf(){let e=[];for(let[t,n]of Object.entries(If).sort()){let r=[];for(let s of n.extensions)r.push(`*${s}`);for(let s of n.globs)r.push(s);e.push(`${t}: ${r.join(", ")}`)}return`${e.join(`
191
+ `:i&&!o&&(k+=j.output)}}let te;return $?te=2:a?te=k.length>0?0:1:te=O?0:1,g?{stdout:"",stderr:"",exitCode:te}:{stdout:k,stderr:T,exitCode:te}}};Q7={name:"fgrep",async execute(e,t){return Qo.execute(["-F",...e],t)}},K7={name:"egrep",async execute(e,t){return Qo.execute(["-E",...e],t)}}});function Of(){let e=[];for(let[t,n]of Object.entries(If).sort()){let r=[];for(let s of n.extensions)r.push(`*${s}`);for(let s of n.globs)r.push(s);e.push(`${t}: ${r.join(", ")}`)}return`${e.join(`
192
192
  `)}
193
- `}var If,Qr,Ko=I(()=>{"use strict";Me();If={js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}},Qr=class{types;constructor(){this.types=new Map(Object.entries(If).map(([t,n])=>[t,{extensions:[...n.extensions],globs:[...n.globs]}]))}addType(t){let n=t.indexOf(":");if(n===-1)return;let r=t.slice(0,n),s=t.slice(n+1);if(s.startsWith("include:")){let i=s.slice(8),o=this.types.get(i);if(o){let a=this.types.get(r)||{extensions:[],globs:[]};a.extensions.push(...o.extensions),a.globs.push(...o.globs),this.types.set(r,a)}}else{let i=this.types.get(r)||{extensions:[],globs:[]};if(s.startsWith("*.")&&!s.slice(2).includes("*")){let o=s.slice(1);i.extensions.includes(o)||i.extensions.push(o)}else i.globs.includes(s)||i.globs.push(s);this.types.set(r,i)}}clearType(t){let n=this.types.get(t);n&&(n.extensions=[],n.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,n){let r=t.toLowerCase();for(let s of n){if(s==="all"){if(this.matchesAnyType(t))return!0;continue}let i=this.types.get(s);if(i){for(let o of i.extensions)if(r.endsWith(o))return!0;for(let o of i.globs)if(o.includes("*")){let a=o.replace(/\./g,"\\.").replace(/\*/g,".*");if(V(`^${a}$`,"i").test(t))return!0}else if(r===o.toLowerCase())return!0}}return!1}matchesAnyType(t){let n=t.toLowerCase();for(let r of this.types.values()){for(let s of r.extensions)if(n.endsWith(s))return!0;for(let s of r.globs)if(s.includes("*")){let i=s.replace(/\./g,"\\.").replace(/\*/g,".*");if(V(`^${i}$`,"i").test(t))return!0}else if(n===s.toLowerCase())return!0}return!1}}});function Of(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:1/0,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var $f=I(()=>{"use strict"});function X7(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let n=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return n*1024;case"M":return n*1024*1024;case"G":return n*1024*1024*1024;default:return n}}function Y7(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e}
194
- `,exitCode:1}}function Tf(e){return null}function t4(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function n4(e,t,n){let r=e[t];for(let s of Pf){if(r.startsWith(`--${s.long}=`)){let i=r.slice(`--${s.long}=`.length),o=Gs(n,s,i);return o?{newIndex:t,error:o}:{newIndex:t}}if(s.short&&r.startsWith(`-${s.short}`)&&r.length>2){let i=r.slice(2),o=Gs(n,s,i);return o?{newIndex:t,error:o}:{newIndex:t}}if(s.short&&r===`-${s.short}`||r===`--${s.long}`){if(t+1>=e.length)return null;let i=e[t+1],o=Gs(n,s,i);return o?{newIndex:t+1,error:o}:{newIndex:t+1}}}return null}function r4(e){return Pf.find(t=>t.short===e)}function Gs(e,t,n){if(t.validate){let s=t.validate(n);if(s)return s}let r=t.parse?t.parse(n):n;t.multi?e[t.target].push(r):e[t.target]=r}function s4(e,t){let n=e[t];if(n==="--sort"&&t+1<e.length){let r=e[t+1];if(r==="path"||r==="none")return{value:r,newIndex:t+1}}if(n.startsWith("--sort=")){let r=n.slice(7);if(r==="path"||r==="none")return{value:r,newIndex:t}}return null}function i4(e,t){let n=e[t],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:t}:(n==="-A"||n==="-B"||n==="-C")&&t+1<e.length?{flag:n[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function o4(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function Df(e){let t=Of(),n=null,r=[],s=-1,i=-1,o=-1,a=!1;for(let l=0;l<e.length;l++){let c=e[l];if(c.startsWith("-")&&c!=="-"){let u=i4(e,l);if(u){let{flag:g,value:y,newIndex:w}=u;g==="A"?s=Math.max(s,y):g==="B"?i=Math.max(i,y):o=y,l=w;continue}let f=o4(c);if(f!==null){t.maxCount=f;continue}let h=n4(e,l,t);if(h){if(h.error)return{success:!1,error:h.error};l=h.newIndex;continue}let p=s4(e,l);if(p){t.sort=p.value,l=p.newIndex;continue}let m=c.startsWith("--")?[c]:c.slice(1).split(""),d=!1;for(let g of m){if(e4.has(g)){t.lineNumber=!0,a=!0;continue}if(g==="u"||g==="--unrestricted"){t4(t);continue}if(g==="P"||g==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
193
+ `}var If,Qr,Ko=I(()=>{"use strict";Me();If={js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}},Qr=class{types;constructor(){this.types=new Map(Object.entries(If).map(([t,n])=>[t,{extensions:[...n.extensions],globs:[...n.globs]}]))}addType(t){let n=t.indexOf(":");if(n===-1)return;let r=t.slice(0,n),s=t.slice(n+1);if(s.startsWith("include:")){let i=s.slice(8),o=this.types.get(i);if(o){let a=this.types.get(r)||{extensions:[],globs:[]};a.extensions.push(...o.extensions),a.globs.push(...o.globs),this.types.set(r,a)}}else{let i=this.types.get(r)||{extensions:[],globs:[]};if(s.startsWith("*.")&&!s.slice(2).includes("*")){let o=s.slice(1);i.extensions.includes(o)||i.extensions.push(o)}else i.globs.includes(s)||i.globs.push(s);this.types.set(r,i)}}clearType(t){let n=this.types.get(t);n&&(n.extensions=[],n.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,n){let r=t.toLowerCase();for(let s of n){if(s==="all"){if(this.matchesAnyType(t))return!0;continue}let i=this.types.get(s);if(i){for(let o of i.extensions)if(r.endsWith(o))return!0;for(let o of i.globs)if(o.includes("*")){let a=o.replace(/\./g,"\\.").replace(/\*/g,".*");if(V(`^${a}$`,"i").test(t))return!0}else if(r===o.toLowerCase())return!0}}return!1}matchesAnyType(t){let n=t.toLowerCase();for(let r of this.types.values()){for(let s of r.extensions)if(n.endsWith(s))return!0;for(let s of r.globs)if(s.includes("*")){let i=s.replace(/\./g,"\\.").replace(/\*/g,".*");if(V(`^${i}$`,"i").test(t))return!0}else if(n===s.toLowerCase())return!0}return!1}}});function Rf(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:1/0,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var $f=I(()=>{"use strict"});function X7(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let n=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return n*1024;case"M":return n*1024*1024;case"G":return n*1024*1024*1024;default:return n}}function Y7(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e}
194
+ `,exitCode:1}}function Tf(e){return null}function t4(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function n4(e,t,n){let r=e[t];for(let s of Pf){if(r.startsWith(`--${s.long}=`)){let i=r.slice(`--${s.long}=`.length),o=Gs(n,s,i);return o?{newIndex:t,error:o}:{newIndex:t}}if(s.short&&r.startsWith(`-${s.short}`)&&r.length>2){let i=r.slice(2),o=Gs(n,s,i);return o?{newIndex:t,error:o}:{newIndex:t}}if(s.short&&r===`-${s.short}`||r===`--${s.long}`){if(t+1>=e.length)return null;let i=e[t+1],o=Gs(n,s,i);return o?{newIndex:t+1,error:o}:{newIndex:t+1}}}return null}function r4(e){return Pf.find(t=>t.short===e)}function Gs(e,t,n){if(t.validate){let s=t.validate(n);if(s)return s}let r=t.parse?t.parse(n):n;t.multi?e[t.target].push(r):e[t.target]=r}function s4(e,t){let n=e[t];if(n==="--sort"&&t+1<e.length){let r=e[t+1];if(r==="path"||r==="none")return{value:r,newIndex:t+1}}if(n.startsWith("--sort=")){let r=n.slice(7);if(r==="path"||r==="none")return{value:r,newIndex:t}}return null}function i4(e,t){let n=e[t],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:t}:(n==="-A"||n==="-B"||n==="-C")&&t+1<e.length?{flag:n[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function o4(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function Df(e){let t=Rf(),n=null,r=[],s=-1,i=-1,o=-1,a=!1;for(let l=0;l<e.length;l++){let c=e[l];if(c.startsWith("-")&&c!=="-"){let u=i4(e,l);if(u){let{flag:g,value:y,newIndex:w}=u;g==="A"?s=Math.max(s,y):g==="B"?i=Math.max(i,y):o=y,l=w;continue}let f=o4(c);if(f!==null){t.maxCount=f;continue}let h=n4(e,l,t);if(h){if(h.error)return{success:!1,error:h.error};l=h.newIndex;continue}let p=s4(e,l);if(p){t.sort=p.value,l=p.newIndex;continue}let m=c.startsWith("--")?[c]:c.slice(1).split(""),d=!1;for(let g of m){if(e4.has(g)){t.lineNumber=!0,a=!0;continue}if(g==="u"||g==="--unrestricted"){t4(t);continue}if(g==="P"||g==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
195
195
  `,exitCode:1}};if(g.length===1){let w=r4(g);if(w){if(l+1>=e.length)return{success:!1,error:X("rg",`-${g}`)};let b=Gs(t,w,e[l+1]);if(b)return{success:!1,error:b};l++,d=!0;continue}}let y=J7.get(g);if(y){y(t);continue}if(g.startsWith("--"))return{success:!1,error:X("rg",g)};if(g.length===1)return{success:!1,error:X("rg",`-${g}`)}}}else n===null&&t.patterns.length===0&&t.patternFiles.length===0?n=c:r.push(c)}return(s>=0||o>=0)&&(t.afterContext=Math.max(s>=0?s:0,o>=0?o:0)),(i>=0||o>=0)&&(t.beforeContext=Math.max(i>=0?i:0,o>=0?o:0)),n!==null&&t.patterns.push(n),(t.column||t.vimgrep)&&(a=!0),{success:!0,options:t,paths:r,explicitLineNumbers:a}}var Pf,J7,e4,Lf=I(()=>{"use strict";ne();$f();Pf=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:Tf},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:Tf},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:parseInt},{long:"max-filesize",target:"maxFilesize",parse:X7,validate:Y7},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",target:"maxDepth",parse:()=>1/0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],J7=new Map([["i",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["--ignore-case",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["s",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["--case-sensitive",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["S",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["--smart-case",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["F",e=>{e.fixedStrings=!0}],["--fixed-strings",e=>{e.fixedStrings=!0}],["w",e=>{e.wordRegexp=!0}],["--word-regexp",e=>{e.wordRegexp=!0}],["x",e=>{e.lineRegexp=!0}],["--line-regexp",e=>{e.lineRegexp=!0}],["v",e=>{e.invertMatch=!0}],["--invert-match",e=>{e.invertMatch=!0}],["U",e=>{e.multiline=!0}],["--multiline",e=>{e.multiline=!0}],["--multiline-dotall",e=>{e.multilineDotall=!0,e.multiline=!0}],["c",e=>{e.count=!0}],["--count",e=>{e.count=!0}],["--count-matches",e=>{e.countMatches=!0}],["l",e=>{e.filesWithMatches=!0}],["--files",e=>{e.files=!0}],["--files-with-matches",e=>{e.filesWithMatches=!0}],["--files-without-match",e=>{e.filesWithoutMatch=!0}],["--stats",e=>{e.stats=!0}],["o",e=>{e.onlyMatching=!0}],["--only-matching",e=>{e.onlyMatching=!0}],["q",e=>{e.quiet=!0}],["--quiet",e=>{e.quiet=!0}],["N",e=>{e.lineNumber=!1}],["--no-line-number",e=>{e.lineNumber=!1}],["H",e=>{e.withFilename=!0}],["--with-filename",e=>{e.withFilename=!0}],["I",e=>{e.noFilename=!0}],["--no-filename",e=>{e.noFilename=!0}],["0",e=>{e.nullSeparator=!0}],["--null",e=>{e.nullSeparator=!0}],["b",e=>{e.byteOffset=!0}],["--byte-offset",e=>{e.byteOffset=!0}],["--column",e=>{e.column=!0,e.lineNumber=!0}],["--no-column",e=>{e.column=!1}],["--vimgrep",e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0}],["--json",e=>{e.json=!0}],["--hidden",e=>{e.hidden=!0}],["--no-ignore",e=>{e.noIgnore=!0}],["--no-ignore-dot",e=>{e.noIgnoreDot=!0}],["--no-ignore-vcs",e=>{e.noIgnoreVcs=!0}],["L",e=>{e.followSymlinks=!0}],["--follow",e=>{e.followSymlinks=!0}],["z",e=>{e.searchZip=!0}],["--search-zip",e=>{e.searchZip=!0}],["a",e=>{e.searchBinary=!0}],["--text",e=>{e.searchBinary=!0}],["--heading",e=>{e.heading=!0}],["--passthru",e=>{e.passthru=!0}],["--include-zero",e=>{e.includeZero=!0}],["--glob-case-insensitive",e=>{e.globCaseInsensitive=!0}]]),e4=new Set(["n","--line-number"])});async function Xo(e,t,n=!1,r=!1,s=[]){let i=new Xr(e,t,n,r);await i.load(t);for(let o of s)try{let a=e.resolvePath(t,o),l=await e.readFile(a);i.addPatternsFromContent(l,t)}catch{}return i}var Kr,Xr,_f=I(()=>{"use strict";Me();Kr=class{patterns=[];basePath;constructor(t="/"){this.basePath=t}parse(t){let n=t.split(`
196
196
  `);for(let r of n){let s=r.replace(/\s+$/,"");if(!s||s.startsWith("#"))continue;let i=!1;s.startsWith("!")&&(i=!0,s=s.slice(1));let o=!1;s.endsWith("/")&&(o=!0,s=s.slice(0,-1));let a=!1;s.startsWith("/")?(a=!0,s=s.slice(1)):s.includes("/")&&!s.startsWith("**/")&&(a=!0);let l=this.patternToRegex(s,a);this.patterns.push({pattern:r,regex:l,negated:i,directoryOnly:o,rooted:a})}}patternToRegex(t,n){let r="";n?r="^":r="(?:^|/)";let s=0;for(;s<t.length;){let i=t[s];if(i==="*")t[s+1]==="*"?t[s+2]==="/"?(r+="(?:.*/)?",s+=3):(s+2>=t.length,r+=".*",s+=2):(r+="[^/]*",s++);else if(i==="?")r+="[^/]",s++;else if(i==="["){let o=s+1;for(o<t.length&&t[o]==="!"&&o++,o<t.length&&t[o]==="]"&&o++;o<t.length&&t[o]!=="]";)o++;if(o<t.length){let a=t.slice(s,o+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),r+=a,s=o+1}else r+="\\[",s++}else i==="/"?(r+="/",s++):(r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s++)}return r+="(?:/.*)?$",V(r)}matches(t,n){let r=t.replace(/^\.\//,"");r=r.replace(/^\//,"");let s=!1;for(let i of this.patterns)i.directoryOnly&&!n||i.regex.test(r)&&(s=!i.negated);return s}isWhitelisted(t,n){let r=t.replace(/^\.\//,"");r=r.replace(/^\//,"");for(let s of this.patterns)if(!(s.directoryOnly&&!n)&&s.negated&&s.regex.test(r))return!0;return!1}getBasePath(){return this.basePath}},Xr=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(t,n,r=!1,s=!1){this.fs=t,this.skipDotIgnore=r,this.skipVcsIgnore=s}async load(t){let n=[],r=t;for(;;){n.unshift(r);let i=this.fs.resolvePath(r,"..");if(i===r)break;r=i}let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let i of n){this.loadedDirs.add(i);for(let o of s){let a=this.fs.resolvePath(i,o);try{let l=await this.fs.readFile(a),c=new Kr(i);c.parse(l),this.parsers.push(c)}catch{}}}}async loadForDirectory(t){if(this.loadedDirs.has(t))return;this.loadedDirs.add(t);let n=[];this.skipVcsIgnore||n.push(".gitignore"),this.skipDotIgnore||n.push(".rgignore",".ignore");for(let r of n){let s=this.fs.resolvePath(t,r);try{let i=await this.fs.readFile(s),o=new Kr(t);o.parse(i),this.parsers.push(o)}catch{}}}addPatternsFromContent(t,n){let r=new Kr(n);r.parse(t),this.parsers.push(r)}matches(t,n){for(let r of this.parsers){let s=r.getBasePath();if(!t.startsWith(s))continue;let i=t.slice(s.length).replace(/^\//,"");if(r.matches(i,n))return!0}return!1}isWhitelisted(t,n){for(let r of this.parsers){let s=r.getBasePath();if(!t.startsWith(s))continue;let i=t.slice(s.length).replace(/^\//,"");if(r.isWhitelisted(i,n))return!0}return!1}static isCommonIgnored(t){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(t)}}});import{gunzipSync as a4}from"node:zlib";function l4(e){return e.length>=2&&e[0]===31&&e[1]===139}function c4(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r==="["&&!t?t=!0:r==="]"&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}async function Mf(e){let{ctx:t,options:n,paths:r,explicitLineNumbers:s}=e;for(let g of n.globs){let y=g.startsWith("!")?g.slice(1):g,w=c4(y);if(w)return{stdout:"",stderr:`${w}
197
197
  `,exitCode:1}}if(n.files){let g=[...n.patterns,...r];return h4(t,g,n)}let i=[...n.patterns];for(let g of n.patternFiles)try{let y;if(g==="-")y=t.stdin;else{let b=t.fs.resolvePath(t.cwd,g);y=await t.fs.readFile(b)}let w=y.split(`
@@ -199,9 +199,9 @@ Options:
199
199
  `,exitCode:2}}if(i.length===0)return n.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
200
200
  `,exitCode:2};let o=r.length===0?["."]:r,a=u4(n,i),l,c;try{let g=f4(i,n,a);l=g.regex,c=g.kResetGroup}catch{return{stdout:"",stderr:`rg: invalid regex: ${i.join(", ")}
201
201
  `,exitCode:2}}let u=null;n.noIgnore||(u=await Xo(t.fs,t.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let f=new Qr;for(let g of n.typeClear)f.clearType(g);for(let g of n.typeAdd)f.addType(g);let{files:h,singleExplicitFile:p}=await Ff(t,o,n,u,f);if(h.length===0)return{stdout:"",stderr:"",exitCode:1};let m=!n.noFilename&&(n.withFilename||!p||h.length>1),d=n.lineNumber;return s||(p&&h.length===1&&(d=!1),n.onlyMatching&&(d=!1)),m4(t,h,l,n,m,d,c)}function u4(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(n=>/[A-Z]/.test(n)):!1}function f4(e,t,n){let r;return e.length===1?r=e[0]:r=e.map(s=>t.fixedStrings?s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${s})`).join("|"),Zr(r,{mode:t.fixedStrings&&e.length===1?"fixed":"perl",ignoreCase:n,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function Ff(e,t,n,r,s){let i=[],o=0,a=0;for(let c of t){let u=e.fs.resolvePath(e.cwd,c);try{let f=await e.fs.stat(u);if(f.isFile){if(o++,n.maxFilesize>0&&f.size>n.maxFilesize)continue;Wf(c,n,r,u,s)&&i.push(c)}else f.isDirectory&&(a++,await Uf(e,c,u,0,n,r,s,i))}catch{}}return{files:n.sort==="path"?i.sort():i,singleExplicitFile:o===1&&a===0}}async function Uf(e,t,n,r,s,i,o,a){if(!(r>=s.maxDepth)){i&&await i.loadForDirectory(n);try{let l=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(n):(await e.fs.readdir(n)).map(c=>({name:c,isFile:void 0}));for(let c of l){let u=c.name;if(!s.noIgnore&&Xr.isCommonIgnored(u))continue;let f=u.startsWith("."),h=t==="."?u:t==="./"?`./${u}`:t.endsWith("/")?`${t}${u}`:`${t}/${u}`,p=e.fs.resolvePath(n,u),m,d,g=!1;if(c.isFile!==void 0&&"isDirectory"in c){let b=c;if(g=b.isSymbolicLink===!0,g&&!s.followSymlinks)continue;if(g&&s.followSymlinks)try{let x=await e.fs.stat(p);m=x.isFile,d=x.isDirectory}catch{continue}else m=b.isFile,d=b.isDirectory}else try{let b=e.fs.lstat?await e.fs.lstat(p):await e.fs.stat(p);if(g=b.isSymbolicLink===!0,g&&!s.followSymlinks)continue;let x=g&&s.followSymlinks?await e.fs.stat(p):b;m=x.isFile,d=x.isDirectory}catch{continue}if(!i?.matches(p,d)&&!(f&&!s.hidden&&!i?.isWhitelisted(p,d))){if(d)await Uf(e,h,p,r+1,s,i,o,a);else if(m){if(s.maxFilesize>0)try{if((await e.fs.stat(p)).size>s.maxFilesize)continue}catch{continue}Wf(h,s,i,p,o)&&a.push(h)}}}}catch{}}}function Wf(e,t,n,r,s){let i=e.split("/").pop()||e;if(n?.matches(r,!1)||t.types.length>0&&!s.matchesType(i,t.types)||t.typesNot.length>0&&s.matchesType(i,t.typesNot))return!1;if(t.globs.length>0){let o=t.globCaseInsensitive,a=t.globs.filter(c=>!c.startsWith("!")),l=t.globs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(a.length>0){let c=!1;for(let u of a)if(Xt(i,u,o)||Xt(e,u,o)){c=!0;break}if(!c)return!1}for(let c of l)if(c.startsWith("/")){let u=c.slice(1);if(Xt(e,u,o))return!1}else if(Xt(i,c,o)||Xt(e,c,o))return!1}if(t.iglobs.length>0){let o=t.iglobs.filter(l=>!l.startsWith("!")),a=t.iglobs.filter(l=>l.startsWith("!")).map(l=>l.slice(1));if(o.length>0){let l=!1;for(let c of o)if(Xt(i,c,!0)||Xt(e,c,!0)){l=!0;break}if(!l)return!1}for(let l of a)if(l.startsWith("/")){let c=l.slice(1);if(Xt(e,c,!0))return!1}else if(Xt(i,l,!0)||Xt(e,l,!0))return!1}return!0}function Xt(e,t,n=!1){let r="^";for(let s=0;s<t.length;s++){let i=t[s];if(i==="*")t[s+1]==="*"?(r+=".*",s++):r+="[^/]*";else if(i==="?")r+="[^/]";else if(i==="["){let o=s+1;for(o<t.length&&t[o]==="!"&&o++,o<t.length&&t[o]==="]"&&o++;o<t.length&&t[o]!=="]";)o++;if(o<t.length){let a=t.slice(s,o+1);a.startsWith("[!")&&(a=`[^${a.slice(2)}`),r+=a,s=o}else r+="\\["}else r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return r+="$",V(r,n?"i":"").test(e)}async function h4(e,t,n){let r=null;n.noIgnore||(r=await Xo(e.fs,e.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let s=new Qr;for(let c of n.typeClear)s.clearType(c);for(let c of n.typeAdd)s.addType(c);let i=t.length===0?["."]:t,{files:o}=await Ff(e,i,n,r,s);if(o.length===0)return{stdout:"",stderr:"",exitCode:1};if(n.quiet)return{stdout:"",stderr:"",exitCode:0};let a=n.nullSeparator?"\0":`
202
- `;return{stdout:o.map(c=>c+a).join(""),stderr:"",exitCode:0}}function p4(e,t){if(t.length===0)return!0;for(let n of t)if(Xt(e,n,!1))return!0;return!1}async function d4(e,t,n,r){try{if(r.preprocessor&&e.exec){let o=n.split("/").pop()||n;if(p4(o,r.preprocessorGlobs)){let a=await e.exec(`${r.preprocessor} "${t}"`,{cwd:e.cwd});if(a.exitCode===0&&a.stdout){let l=a.stdout.slice(0,8192);return{content:a.stdout,isBinary:l.includes("\0")}}}}if(r.searchZip&&n.endsWith(".gz")){let o=await e.fs.readFileBuffer(t);if(l4(o))try{let a=a4(o),l=new TextDecoder().decode(a),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await e.fs.readFile(t),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function m4(e,t,n,r,s,i,o){let a="",l=!1,c=[],u=0,f=0,h=0,p=50;e:for(let g=0;g<t.length;g+=p){let y=t.slice(g,g+p),w=await Promise.all(y.map(async b=>{let x=e.fs.resolvePath(e.cwd,b),S=await d4(e,x,b,r);if(!S)return null;let{content:C,isBinary:$}=S;if(h+=C.length,$&&!r.searchBinary)return null;let M=s&&!r.heading?b:"",_=hr(C,n,{invertMatch:r.invertMatch,showLineNumbers:i,countOnly:r.count,countMatches:r.countMatches,filename:M,onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace!==null?qo(r.replace):null,passthru:r.passthru,multiline:r.multiline,kResetGroup:o});return r.json&&_.matched?{file:b,result:_,content:C,isBinary:!1}:{file:b,result:_}}));for(let b of w){if(!b)continue;let{file:x,result:S}=b;if(S.matched){if(l=!0,f++,u+=S.matchCount,r.quiet&&!r.json)break e;if(r.json&&!r.quiet){let C=b.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:x}}}));let $=C.split(`
203
- `);n.lastIndex=0;let M=0;for(let _=0;_<$.length;_++){let B=$[_];n.lastIndex=0;let v=[];for(let k=n.exec(B);k!==null;k=n.exec(B)){let T={match:{text:k[0]},start:k.index,end:k.index+k[0].length};r.replace!==null&&(T.replacement={text:r.replace}),v.push(T),k[0].length===0&&n.lastIndex++}if(v.length>0){let k={type:"match",data:{path:{text:x},lines:{text:`${B}
204
- `},line_number:_+1,absolute_offset:M,submatches:v}};c.push(JSON.stringify(k))}M+=B.length+1}c.push(JSON.stringify({type:"end",data:{path:{text:x},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:C.length,bytes_printed:0,matched_lines:S.matchCount,matches:S.matchCount}}}))}else if(r.filesWithMatches){let C=r.nullSeparator?"\0":`
202
+ `;return{stdout:o.map(c=>c+a).join(""),stderr:"",exitCode:0}}function p4(e,t){if(t.length===0)return!0;for(let n of t)if(Xt(e,n,!1))return!0;return!1}async function d4(e,t,n,r){try{if(r.preprocessor&&e.exec){let o=n.split("/").pop()||n;if(p4(o,r.preprocessorGlobs)){let a=await e.exec(`${r.preprocessor} "${t}"`,{cwd:e.cwd});if(a.exitCode===0&&a.stdout){let l=a.stdout.slice(0,8192);return{content:a.stdout,isBinary:l.includes("\0")}}}}if(r.searchZip&&n.endsWith(".gz")){let o=await e.fs.readFileBuffer(t);if(l4(o))try{let a=a4(o),l=new TextDecoder().decode(a),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await e.fs.readFile(t),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function m4(e,t,n,r,s,i,o){let a="",l=!1,c=[],u=0,f=0,h=0,p=50;e:for(let g=0;g<t.length;g+=p){let y=t.slice(g,g+p),w=await Promise.all(y.map(async b=>{let x=e.fs.resolvePath(e.cwd,b),S=await d4(e,x,b,r);if(!S)return null;let{content:C,isBinary:R}=S;if(h+=C.length,R&&!r.searchBinary)return null;let U=s&&!r.heading?b:"",L=hr(C,n,{invertMatch:r.invertMatch,showLineNumbers:i,countOnly:r.count,countMatches:r.countMatches,filename:U,onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace!==null?qo(r.replace):null,passthru:r.passthru,multiline:r.multiline,kResetGroup:o});return r.json&&L.matched?{file:b,result:L,content:C,isBinary:!1}:{file:b,result:L}}));for(let b of w){if(!b)continue;let{file:x,result:S}=b;if(S.matched){if(l=!0,f++,u+=S.matchCount,r.quiet&&!r.json)break e;if(r.json&&!r.quiet){let C=b.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:x}}}));let R=C.split(`
203
+ `);n.lastIndex=0;let U=0;for(let L=0;L<R.length;L++){let B=R[L];n.lastIndex=0;let v=[];for(let k=n.exec(B);k!==null;k=n.exec(B)){let T={match:{text:k[0]},start:k.index,end:k.index+k[0].length};r.replace!==null&&(T.replacement={text:r.replace}),v.push(T),k[0].length===0&&n.lastIndex++}if(v.length>0){let k={type:"match",data:{path:{text:x},lines:{text:`${B}
204
+ `},line_number:L+1,absolute_offset:U,submatches:v}};c.push(JSON.stringify(k))}U+=B.length+1}c.push(JSON.stringify({type:"end",data:{path:{text:x},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:C.length,bytes_printed:0,matched_lines:S.matchCount,matches:S.matchCount}}}))}else if(r.filesWithMatches){let C=r.nullSeparator?"\0":`
205
205
  `;a+=`${x}${C}`}else r.filesWithoutMatch||(r.heading&&!r.noFilename&&(a+=`${x}
206
206
  `),a+=S.output)}else if(r.filesWithoutMatch){let C=r.nullSeparator?"\0":`
207
207
  `;a+=`${x}${C}`}else r.includeZero&&(r.count||r.countMatches)&&(a+=S.output)}}r.json&&(c.push(JSON.stringify({type:"summary",data:{elapsed_total:{secs:0,nanos:0,human:"0s"},stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:t.length,searches_with_match:f,bytes_searched:h,bytes_printed:0,matched_lines:u,matches:u}}})),a=`${c.join(`
@@ -219,7 +219,7 @@ EXAMPLES:
219
219
  rg -t js foo Search only JavaScript files
220
220
  rg -g '*.ts' foo Search files matching glob
221
221
  rg --hidden foo Include hidden files
222
- rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},y4={name:"rg",async execute(e,t){if(U(e))return F(g4);if(e.includes("--type-list"))return{stdout:Rf(),stderr:"",exitCode:0};let n=Df(e);return n.success?Mf({ctx:t,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}}});function Vs(e){return e instanceof ut||e instanceof ft||e instanceof it}var mt,ut,ft,it,Ct,gt,pe,$e,yt,an,pr,re,ln,Ft,xe=I(()=>{"use strict";mt=class extends Error{stdout;stderr;constructor(t,n="",r=""){super(t),this.stdout=n,this.stderr=r}prependOutput(t,n){this.stdout=t+this.stdout,this.stderr=n+this.stderr}},ut=class extends mt{levels;name="BreakError";constructor(t=1,n="",r=""){super("break",n,r),this.levels=t}},ft=class extends mt{levels;name="ContinueError";constructor(t=1,n="",r=""){super("continue",n,r),this.levels=t}},it=class extends mt{exitCode;name="ReturnError";constructor(t=0,n="",r=""){super("return",n,r),this.exitCode=t}},Ct=class extends mt{exitCode;name="ErrexitError";constructor(t,n="",r=""){super(`errexit: command exited with status ${t}`,n,r),this.exitCode=t}},gt=class extends mt{varName;name="NounsetError";constructor(t,n=""){super(`${t}: unbound variable`,n,`bash: ${t}: unbound variable
222
+ rg -l foo List files with matches only`,options:["-e, --regexp PATTERN search for PATTERN (can be used multiple times)","-f, --file FILE read patterns from FILE, one per line","-i, --ignore-case case-insensitive search","-s, --case-sensitive case-sensitive search (overrides smart-case)","-S, --smart-case smart case (default: case-insensitive unless pattern has uppercase)","-F, --fixed-strings treat pattern as literal string","-w, --word-regexp match whole words only","-x, --line-regexp match whole lines only","-v, --invert-match select non-matching lines","-r, --replace TEXT replace matches with TEXT","-c, --count print count of matching lines per file"," --count-matches print count of individual matches per file","-l, --files-with-matches print only file names with matches"," --files-without-match print file names without matches"," --files list files that would be searched","-o, --only-matching print only matching parts","-m, --max-count NUM stop after NUM matches per file","-q, --quiet suppress output, exit 0 on match"," --stats print search statistics","-n, --line-number print line numbers (default: on)","-N, --no-line-number do not print line numbers","-I, --no-filename suppress the prefixing of file names","-0, --null use NUL as filename separator","-b, --byte-offset show byte offset of each match"," --column show column number of first match"," --vimgrep show results in vimgrep format"," --json show results in JSON Lines format","-A NUM print NUM lines after each match","-B NUM print NUM lines before each match","-C NUM print NUM lines before and after each match"," --context-separator SEP separator for context groups (default: --)","-U, --multiline match patterns across lines","-z, --search-zip search in compressed files (gzip only)","-g, --glob GLOB include files matching GLOB","-t, --type TYPE only search files of TYPE (e.g., js, py, ts)","-T, --type-not TYPE exclude files of TYPE","-L, --follow follow symbolic links","-u, --unrestricted reduce filtering (-u: no ignore, -uu: +hidden, -uuu: +binary)","-a, --text search binary files as text"," --hidden search hidden files and directories"," --no-ignore don't respect .gitignore/.ignore files","-d, --max-depth NUM maximum search depth"," --sort TYPE sort files (path, none)"," --heading show file path above matches"," --passthru print all lines (non-matches use - separator)"," --include-zero include files with 0 matches in count output"," --type-list list all available file types"," --help display this help and exit"]},y4={name:"rg",async execute(e,t){if(F(e))return M(g4);if(e.includes("--type-list"))return{stdout:Of(),stderr:"",exitCode:0};let n=Df(e);return n.success?Mf({ctx:t,options:n.options,paths:n.paths,explicitLineNumbers:n.explicitLineNumbers}):n.error}}});function Vs(e){return e instanceof ut||e instanceof ft||e instanceof it}var mt,ut,ft,it,Ct,gt,pe,$e,yt,an,pr,re,ln,Ft,xe=I(()=>{"use strict";mt=class extends Error{stdout;stderr;constructor(t,n="",r=""){super(t),this.stdout=n,this.stderr=r}prependOutput(t,n){this.stdout=t+this.stdout,this.stderr=n+this.stderr}},ut=class extends mt{levels;name="BreakError";constructor(t=1,n="",r=""){super("break",n,r),this.levels=t}},ft=class extends mt{levels;name="ContinueError";constructor(t=1,n="",r=""){super("continue",n,r),this.levels=t}},it=class extends mt{exitCode;name="ReturnError";constructor(t=0,n="",r=""){super("return",n,r),this.exitCode=t}},Ct=class extends mt{exitCode;name="ErrexitError";constructor(t,n="",r=""){super(`errexit: command exited with status ${t}`,n,r),this.exitCode=t}},gt=class extends mt{varName;name="NounsetError";constructor(t,n=""){super(`${t}: unbound variable`,n,`bash: ${t}: unbound variable
223
223
  `),this.varName=t}},pe=class extends mt{exitCode;name="ExitError";constructor(t,n="",r=""){super("exit",n,r),this.exitCode=t}},$e=class extends mt{name="ArithmeticError";fatal;constructor(t,n="",r="",s=!1){super(t,n,r),this.stderr=r||`bash: ${t}
224
224
  `,this.fatal=s}},yt=class extends mt{name="BadSubstitutionError";constructor(t,n="",r=""){super(t,n,r),this.stderr=r||`bash: ${t}: bad substitution
225
225
  `}},an=class extends mt{name="GlobError";constructor(t,n="",r=""){super(`no match: ${t}`,n,r),this.stderr=r||`bash: no match: ${t}
@@ -269,14 +269,14 @@ ${c}`,t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1}else{t.quit=!0;br
269
269
  ${c}`}else s.push(c)}let i=s.join(`
270
270
  `),a=new sa([i],t||r).parse();if(!a.error&&a.commands.length>0){let l=N4(a.commands);if(l)return{commands:[],error:l,silentMode:n,extendedRegexMode:r}}return{...a,silentMode:n,extendedRegexMode:r}}function N4(e){let t=new Set;Kf(e,t);let n=Xf(e,t);if(n)return`undefined label '${n}'`}function Kf(e,t){for(let n of e)n.type==="label"?t.add(n.name):n.type==="group"&&Kf(n.commands,t)}function Xf(e,t){for(let n of e){if((n.type==="branch"||n.type==="branchOnSubst"||n.type==="branchOnNoSubst")&&n.label&&!t.has(n.label))return n.label;if(n.type==="group"){let r=Xf(n.commands,t);if(r)return r}}}var sa,Yf=I(()=>{"use strict";Zf();sa=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(t,n=!1){this.scripts=t,this.extendedRegex=n}parse(){let t=[];for(let n of this.scripts){let r=new qs(n);for(this.tokens=r.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(Y.NEWLINE)||this.check(Y.SEMICOLON)){this.advance();continue}let s=this.parseCommand();if(s.error)return{commands:[],error:s.error};s.command&&t.push(s.command)}}return{commands:t}}parseCommand(){let t=this.parseAddressRange();if(t?.error)return{command:null,error:t.error};let n=t?.address;for(this.check(Y.NEGATION)&&(this.advance(),n&&(n.negated=!0));this.check(Y.NEWLINE)||this.check(Y.SEMICOLON);)this.advance();if(this.isAtEnd())return n&&(n.start!==void 0||n.end!==void 0)?{command:null,error:"command expected"}:{command:null};let r=this.peek();switch(r.type){case Y.COMMAND:return this.parseSimpleCommand(r,n);case Y.SUBSTITUTE:return this.parseSubstituteFromToken(r,n);case Y.TRANSLITERATE:return this.parseTransliterateFromToken(r,n);case Y.LABEL_DEF:return this.advance(),{command:{type:"label",name:r.label||""}};case Y.BRANCH:return this.advance(),{command:{type:"branch",address:n,label:r.label}};case Y.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:n,label:r.label}};case Y.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:n,label:r.label}};case Y.TEXT_CMD:return this.advance(),this.parseTextCommand(r,n);case Y.FILE_READ:return this.advance(),{command:{type:"readFile",address:n,filename:r.filename||""}};case Y.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:n,filename:r.filename||""}};case Y.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:n,filename:r.filename||""}};case Y.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:n,filename:r.filename||""}};case Y.EXECUTE:return this.advance(),{command:{type:"execute",address:n,command:r.command}};case Y.VERSION:return this.advance(),{command:{type:"version",address:n,minVersion:r.label}};case Y.LBRACE:return this.parseGroup(n);case Y.RBRACE:return{command:null};case Y.ERROR:return{command:null,error:`invalid command: ${r.value}`};default:return n&&(n.start!==void 0||n.end!==void 0)?{command:null,error:"command expected"}:{command:null}}}parseSimpleCommand(t,n){this.advance();let r=t.value;switch(r){case"p":return{command:{type:"print",address:n}};case"P":return{command:{type:"printFirstLine",address:n}};case"d":return{command:{type:"delete",address:n}};case"D":return{command:{type:"deleteFirstLine",address:n}};case"h":return{command:{type:"hold",address:n}};case"H":return{command:{type:"holdAppend",address:n}};case"g":return{command:{type:"get",address:n}};case"G":return{command:{type:"getAppend",address:n}};case"x":return{command:{type:"exchange",address:n}};case"n":return{command:{type:"next",address:n}};case"N":return{command:{type:"nextAppend",address:n}};case"q":return{command:{type:"quit",address:n}};case"Q":return{command:{type:"quitSilent",address:n}};case"z":return{command:{type:"zap",address:n}};case"=":return{command:{type:"lineNumber",address:n}};case"l":return{command:{type:"list",address:n}};case"F":return{command:{type:"printFilename",address:n}};default:return{command:null,error:`unknown command: ${r}`}}}parseSubstituteFromToken(t,n){this.advance();let r=t.flags||"",s,i=r.match(/(\d+)/);return i&&(s=parseInt(i[1],10)),{command:{type:"substitute",address:n,pattern:t.pattern||"",replacement:t.replacement||"",global:r.includes("g"),ignoreCase:r.includes("i")||r.includes("I"),printOnMatch:r.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(t,n){this.advance();let r=t.source||"",s=t.dest||"";return r.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:n,source:r,dest:s}}}parseTextCommand(t,n){let r=t.value,s=t.text||"";switch(r){case"a":return{command:{type:"append",address:n,text:s}};case"i":return{command:{type:"insert",address:n,text:s}};case"c":return{command:{type:"change",address:n,text:s}};default:return{command:null,error:`unknown text command: ${r}`}}}parseGroup(t){this.advance();let n=[];for(;!this.isAtEnd()&&!this.check(Y.RBRACE);){if(this.check(Y.NEWLINE)||this.check(Y.SEMICOLON)){this.advance();continue}let r=this.parseCommand();if(r.error)return{command:null,error:r.error};r.command&&n.push(r.command)}return this.check(Y.RBRACE)?(this.advance(),{command:{type:"group",address:t,commands:n}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){let t=this.parseAddress();if(t===void 0)return;let n;if(this.check(Y.RELATIVE_OFFSET))n={offset:this.advance().offset||0};else if(this.check(Y.COMMA)&&(this.advance(),n=this.parseAddress(),n===void 0))return{error:"expected context address"};return{address:{start:t,end:n}}}parseAddress(){let t=this.peek();switch(t.type){case Y.NUMBER:return this.advance(),t.value;case Y.DOLLAR:return this.advance(),"$";case Y.PATTERN:return this.advance(),{pattern:t.pattern||t.value};case Y.STEP:return this.advance(),{first:t.first||0,step:t.step||0};case Y.RELATIVE_OFFSET:return this.advance(),{offset:t.offset||0};default:return}}peek(){return this.tokens[this.pos]||{type:Y.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(t){return this.peek().type===t}isAtEnd(){return this.peek().type===Y.EOF}}});var Jf={};Q(Jf,{sedCommand:()=>v4});async function ia(e,t,n,r={}){let{limits:s,filename:i,fs:o,cwd:a}=r,l=e.endsWith(`
271
271
  `),c=e.split(`
272
- `);c.length>0&&c[c.length-1]===""&&c.pop();let u=c.length,f="",h,p=!1,m="",d,g=new Map,y=new Map,w=new Map,b=new Map,x=s?{maxIterations:s.maxSedIterations}:void 0;for(let S=0;S<c.length;S++){let C={...Vf(u,i,g),patternSpace:c[S],holdSpace:m,lastPattern:d,lineNumber:S+1,totalLines:u,substitutionMade:!1},$={lines:c,currentLineIndex:S},M=0,_=1e4;C.linesConsumedInCycle=0;do{if(M++,M>_)break;if(C.restartCycle=!1,C.pendingFileReads=[],C.pendingFileWrites=[],ra(t,C,$,x),o&&a){for(let O of C.pendingFileReads){let L=o.resolvePath(a,O.filename);try{if(O.wholeFile){let ie=await o.readFile(L);C.appendBuffer.push(ie.replace(/\n$/,""))}else{if(!y.has(L)){let te=await o.readFile(L);y.set(L,te.split(`
273
- `)),w.set(L,0)}let ie=y.get(L),ue=w.get(L);ie&&ue!==void 0&&ue<ie.length&&(C.appendBuffer.push(ie[ue]),w.set(L,ue+1))}}catch{}}for(let O of C.pendingFileWrites){let L=o.resolvePath(a,O.filename),ie=b.get(L)||"";b.set(L,ie+O.content)}}}while(C.restartCycle&&!C.deleted&&!C.quit&&!C.quitSilent);if(S+=C.linesConsumedInCycle,m=C.holdSpace,d=C.lastPattern,!n)for(let O of C.nCommandOutput)f+=`${O}
274
- `;let B=C.lineNumberOutput.length>0;for(let O of C.lineNumberOutput)f+=`${O}
275
- `;let v=[],k=[];for(let O of C.appendBuffer)O.startsWith("__INSERT__")?v.push(O.slice(10)):k.push(O);for(let O of v)f+=`${O}
272
+ `);c.length>0&&c[c.length-1]===""&&c.pop();let u=c.length,f="",h,p=!1,m="",d,g=new Map,y=new Map,w=new Map,b=new Map,x=s?{maxIterations:s.maxSedIterations}:void 0;for(let S=0;S<c.length;S++){let C={...Vf(u,i,g),patternSpace:c[S],holdSpace:m,lastPattern:d,lineNumber:S+1,totalLines:u,substitutionMade:!1},R={lines:c,currentLineIndex:S},U=0,L=1e4;C.linesConsumedInCycle=0;do{if(U++,U>L)break;if(C.restartCycle=!1,C.pendingFileReads=[],C.pendingFileWrites=[],ra(t,C,R,x),o&&a){for(let $ of C.pendingFileReads){let _=o.resolvePath(a,$.filename);try{if($.wholeFile){let ie=await o.readFile(_);C.appendBuffer.push(ie.replace(/\n$/,""))}else{if(!y.has(_)){let te=await o.readFile(_);y.set(_,te.split(`
273
+ `)),w.set(_,0)}let ie=y.get(_),ue=w.get(_);ie&&ue!==void 0&&ue<ie.length&&(C.appendBuffer.push(ie[ue]),w.set(_,ue+1))}}catch{}}for(let $ of C.pendingFileWrites){let _=o.resolvePath(a,$.filename),ie=b.get(_)||"";b.set(_,ie+$.content)}}}while(C.restartCycle&&!C.deleted&&!C.quit&&!C.quitSilent);if(S+=C.linesConsumedInCycle,m=C.holdSpace,d=C.lastPattern,!n)for(let $ of C.nCommandOutput)f+=`${$}
274
+ `;let B=C.lineNumberOutput.length>0;for(let $ of C.lineNumberOutput)f+=`${$}
275
+ `;let v=[],k=[];for(let $ of C.appendBuffer)$.startsWith("__INSERT__")?v.push($.slice(10)):k.push($);for(let $ of v)f+=`${$}
276
276
  `;let T=!1;!C.deleted&&!C.quitSilent?n?C.printed&&(f+=`${C.patternSpace}
277
277
  `,T=!0):(f+=`${C.patternSpace}
278
278
  `,T=!0):C.changedText!==void 0&&(f+=`${C.changedText}
279
- `,T=!0);for(let O of k)f+=`${O}
279
+ `,T=!0);for(let $ of k)f+=`${$}
280
280
  `;if(p=(B||T)&&k.length===0,C.quit||C.quitSilent){if(C.exitCode!==void 0&&(h=C.exitCode),C.errorMessage)return{output:"",exitCode:h||1,errorMessage:C.errorMessage};break}}if(o&&a)for(let[S,C]of b)try{await o.writeFile(S,C)}catch{}return!l&&p&&f.endsWith(`
281
281
  `)&&(f=f.slice(0,-1)),{output:f,exitCode:h}}var k4,v4,e1=I(()=>{"use strict";xe();ne();qf();Yf();k4={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:
282
282
  s/regexp/replacement/[flags] substitute
@@ -307,7 +307,7 @@ Addresses:
307
307
  $ last line
308
308
  /regexp/ lines matching regexp
309
309
  N,M range from line N to M
310
- first~step every step-th line starting at first`};v4={name:"sed",async execute(e,t){if(U(e))return F(k4);let n=[],r=[],s=!1,i=!1,o=!1,a=[];for(let m=0;m<e.length;m++){let d=e[m];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")m+1<e.length&&n.push(e[++m]);else if(d==="-f")m+1<e.length&&r.push(e[++m]);else{if(d.startsWith("--"))return X("sed",d);if(d==="-")a.push(d);else if(d.startsWith("-")&&d.length>1){for(let g of d.slice(1))if(g!=="n"&&g!=="e"&&g!=="f"&&g!=="i"&&g!=="E"&&g!=="r")return X("sed",`-${g}`);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")&&m+1<e.length&&n.push(e[++m]),d.includes("f")&&!d.includes("e")&&m+1<e.length&&r.push(e[++m])}else!d.startsWith("-")&&n.length===0&&r.length===0?n.push(d):d.startsWith("-")||a.push(d)}}for(let m of r){let d=t.fs.resolvePath(t.cwd,m);try{let g=await t.fs.readFile(d);for(let y of g.split(`
310
+ first~step every step-th line starting at first`};v4={name:"sed",async execute(e,t){if(F(e))return M(k4);let n=[],r=[],s=!1,i=!1,o=!1,a=[];for(let m=0;m<e.length;m++){let d=e[m];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")m+1<e.length&&n.push(e[++m]);else if(d==="-f")m+1<e.length&&r.push(e[++m]);else{if(d.startsWith("--"))return X("sed",d);if(d==="-")a.push(d);else if(d.startsWith("-")&&d.length>1){for(let g of d.slice(1))if(g!=="n"&&g!=="e"&&g!=="f"&&g!=="i"&&g!=="E"&&g!=="r")return X("sed",`-${g}`);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")&&m+1<e.length&&n.push(e[++m]),d.includes("f")&&!d.includes("e")&&m+1<e.length&&r.push(e[++m])}else!d.startsWith("-")&&n.length===0&&r.length===0?n.push(d):d.startsWith("-")||a.push(d)}}for(let m of r){let d=t.fs.resolvePath(t.cwd,m);try{let g=await t.fs.readFile(d);for(let y of g.split(`
311
311
  `)){let w=y.trim();w&&!w.startsWith("#")&&n.push(w)}}catch{return{stdout:"",stderr:`sed: couldn't open file ${m}: No such file or directory
312
312
  `,exitCode:1}}}if(n.length===0)return{stdout:"",stderr:`sed: no script specified
313
313
  `,exitCode:1};let{commands:l,error:c,silentMode:u}=Qf(n,o);if(c)return{stdout:"",stderr:`sed: ${c}
@@ -323,20 +323,20 @@ Addresses:
323
323
  `)&&(h+=`
324
324
  `),h+=d}try{let m=await ia(h,l,f,{limits:t.limits,filename:a.length===1?a[0]:void 0,fs:t.fs,cwd:t.cwd});return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage}
325
325
  `:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof re)return{stdout:"",stderr:`sed: ${m.message}
326
- `,exitCode:re.EXIT_CODE};throw m}}}});function wt(e){return Object.assign(Object.create(null),Object.fromEntries(e))}function Yt(e,t){return Object.assign(Object.create(null),Object.fromEntries(e),t)}function Zs(...e){return Object.assign(Object.create(null),...e)}var vn=I(()=>{"use strict"});function oa(e={}){let{fieldSep:t=O4,maxIterations:n=I4,maxRecursionDepth:r=R4,fs:s,cwd:i,exec:o}=e;return{FS:" ",OFS:" ",ORS:`
327
- `,OFMT:"%.6g",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:r,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:s,cwd:i,exec:o}}var I4,R4,O4,t1=I(()=>{"use strict";Me();I4=1e4,R4=100,O4=new bn(/\s+/)});function n1(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return t!==0?e/t:0;case"%":return t!==0?e%t:0;case"^":case"**":return e**t;default:return 0}}var r1=I(()=>{"use strict"});function Gt(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function ot(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function Qs(e,t){if(e.type==="regex")return e.pattern;let n=ot(await t.evalExpr(e));return n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)),n}async function i1(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(Gt(await t.evalExpr(e.index)))}`:"$0":"$0"}function o1(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||""}return ot(t.vars[e]??"")}function a1(e,t,n){if(e==="$0")n.line=t,n.fields=n.FS===" "?t.trim().split(/\s+/).filter(Boolean):n.fieldSep.split(t),n.NF=n.fields.length;else if(e.startsWith("$")){let r=parseInt(e.slice(1),10)-1;for(;n.fields.length<=r;)n.fields.push("");n.fields[r]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function $4(e,t,n){return e.length===0?t.line.length:ot(await n.evalExpr(e[0])).length}async function T4(e,t,n){if(e.length<2)return"";let r=ot(await n.evalExpr(e[0])),s=Math.floor(Gt(await n.evalExpr(e[1])))-1;if(e.length>=3){let i=Math.floor(Gt(await n.evalExpr(e[2])));return r.substr(Math.max(0,s),i)}return r.substr(Math.max(0,s))}async function P4(e,t,n){if(e.length<2)return 0;let r=ot(await n.evalExpr(e[0])),s=ot(await n.evalExpr(e[1])),i=r.indexOf(s);return i===-1?0:i+1}async function D4(e,t,n){if(e.length<2)return 0;let r=ot(await n.evalExpr(e[0])),s=e[1];if(s.type!=="variable")return 0;let i=s.name,o=t.FS;if(e.length>=3){let l=e[2];if(l.type==="regex")o=V(l.pattern);else{let c=ot(await n.evalExpr(l));o=c===" "?V("\\s+"):c}}else t.FS===" "&&(o=V("\\s+"));let a=typeof o=="string"?r.split(o):o.split(r);t.arrays[i]=Object.create(null);for(let l=0;l<a.length;l++)t.arrays[i][String(l+1)]=a[l];return a.length}async function L4(e,t,n){if(e.length<2)return 0;let r=await Qs(e[0],n),s=ot(await n.evalExpr(e[1])),i=await i1(e[2],n),o=o1(i,t);try{let l=V(r).replace(o,l1(s)),c=l!==o?1:0;return a1(i,l,t),c}catch{return 0}}async function _4(e,t,n){if(e.length<2)return 0;let r=await Qs(e[0],n),s=ot(await n.evalExpr(e[1])),i=await i1(e[2],n),o=o1(i,t);try{let a=V(r,"g"),l=a.match(o),c=l?l.length:0,u=a.replace(o,l1(s));return a1(i,u,t),c}catch{return 0}}function l1(e){return t=>{let n="",r=0;for(;r<e.length;)if(e[r]==="\\"&&r+1<e.length){let s=e[r+1];s==="&"?(n+="&",r+=2):s==="\\"?(n+="\\",r+=2):(n+=e[r+1],r+=2)}else e[r]==="&"?(n+=t,r++):(n+=e[r],r++);return n}}async function M4(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let r=ot(await n.evalExpr(e[0])),s=await Qs(e[1],n);try{let o=V(s).exec(r);if(o)return t.RSTART=o.index+1,t.RLENGTH=o[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function F4(e,t,n){if(e.length<3)return"";let r=await Qs(e[0],n),s=ot(await n.evalExpr(e[1])),i=ot(await n.evalExpr(e[2])),o=e.length>=4?ot(await n.evalExpr(e[3])):t.line;try{let a=i.toLowerCase()==="g",l=a?0:parseInt(i,10)||1;if(a)return V(r,"g").replace(o,(u,...f)=>s1(s,u,f.slice(0,-2)));{let c=0;return V(r,"g").replace(o,(f,...h)=>(c++,c===l?s1(s,f,h.slice(0,-2)):f))}}catch{return o}}function s1(e,t,n){let r="",s=0;for(;s<e.length;)if(e[s]==="\\"&&s+1<e.length){let i=e[s+1];if(i==="&")r+="&",s+=2;else if(i==="0")r+=t,s+=2;else if(i>="1"&&i<="9"){let o=parseInt(i,10)-1;r+=n[o]||"",s+=2}else i==="n"?(r+=`
326
+ `,exitCode:re.EXIT_CODE};throw m}}}});function wt(e){return Object.assign(Object.create(null),Object.fromEntries(e))}function Yt(e,t){return Object.assign(Object.create(null),Object.fromEntries(e),t)}function Zs(...e){return Object.assign(Object.create(null),...e)}var vn=I(()=>{"use strict"});function oa(e={}){let{fieldSep:t=R4,maxIterations:n=I4,maxRecursionDepth:r=O4,fs:s,cwd:i,exec:o}=e;return{FS:" ",OFS:" ",ORS:`
327
+ `,OFMT:"%.6g",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,SUBSEP:"",fields:[],line:"",vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:r,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:s,cwd:i,exec:o}}var I4,O4,R4,t1=I(()=>{"use strict";Me();I4=1e4,O4=100,R4=new bn(/\s+/)});function n1(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":return t!==0?e/t:0;case"%":return t!==0?e%t:0;case"^":case"**":return e**t;default:return 0}}var r1=I(()=>{"use strict"});function Gt(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function ot(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function Qs(e,t){if(e.type==="regex")return e.pattern;let n=ot(await t.evalExpr(e));return n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)),n}async function i1(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(Gt(await t.evalExpr(e.index)))}`:"$0":"$0"}function o1(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||""}return ot(t.vars[e]??"")}function a1(e,t,n){if(e==="$0")n.line=t,n.fields=n.FS===" "?t.trim().split(/\s+/).filter(Boolean):n.fieldSep.split(t),n.NF=n.fields.length;else if(e.startsWith("$")){let r=parseInt(e.slice(1),10)-1;for(;n.fields.length<=r;)n.fields.push("");n.fields[r]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function $4(e,t,n){return e.length===0?t.line.length:ot(await n.evalExpr(e[0])).length}async function T4(e,t,n){if(e.length<2)return"";let r=ot(await n.evalExpr(e[0])),s=Math.floor(Gt(await n.evalExpr(e[1])))-1;if(e.length>=3){let i=Math.floor(Gt(await n.evalExpr(e[2])));return r.substr(Math.max(0,s),i)}return r.substr(Math.max(0,s))}async function P4(e,t,n){if(e.length<2)return 0;let r=ot(await n.evalExpr(e[0])),s=ot(await n.evalExpr(e[1])),i=r.indexOf(s);return i===-1?0:i+1}async function D4(e,t,n){if(e.length<2)return 0;let r=ot(await n.evalExpr(e[0])),s=e[1];if(s.type!=="variable")return 0;let i=s.name,o=t.FS;if(e.length>=3){let l=e[2];if(l.type==="regex")o=V(l.pattern);else{let c=ot(await n.evalExpr(l));o=c===" "?V("\\s+"):c}}else t.FS===" "&&(o=V("\\s+"));let a=typeof o=="string"?r.split(o):o.split(r);t.arrays[i]=Object.create(null);for(let l=0;l<a.length;l++)t.arrays[i][String(l+1)]=a[l];return a.length}async function L4(e,t,n){if(e.length<2)return 0;let r=await Qs(e[0],n),s=ot(await n.evalExpr(e[1])),i=await i1(e[2],n),o=o1(i,t);try{let l=V(r).replace(o,l1(s)),c=l!==o?1:0;return a1(i,l,t),c}catch{return 0}}async function _4(e,t,n){if(e.length<2)return 0;let r=await Qs(e[0],n),s=ot(await n.evalExpr(e[1])),i=await i1(e[2],n),o=o1(i,t);try{let a=V(r,"g"),l=a.match(o),c=l?l.length:0,u=a.replace(o,l1(s));return a1(i,u,t),c}catch{return 0}}function l1(e){return t=>{let n="",r=0;for(;r<e.length;)if(e[r]==="\\"&&r+1<e.length){let s=e[r+1];s==="&"?(n+="&",r+=2):s==="\\"?(n+="\\",r+=2):(n+=e[r+1],r+=2)}else e[r]==="&"?(n+=t,r++):(n+=e[r],r++);return n}}async function M4(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let r=ot(await n.evalExpr(e[0])),s=await Qs(e[1],n);try{let o=V(s).exec(r);if(o)return t.RSTART=o.index+1,t.RLENGTH=o[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function F4(e,t,n){if(e.length<3)return"";let r=await Qs(e[0],n),s=ot(await n.evalExpr(e[1])),i=ot(await n.evalExpr(e[2])),o=e.length>=4?ot(await n.evalExpr(e[3])):t.line;try{let a=i.toLowerCase()==="g",l=a?0:parseInt(i,10)||1;if(a)return V(r,"g").replace(o,(u,...f)=>s1(s,u,f.slice(0,-2)));{let c=0;return V(r,"g").replace(o,(f,...h)=>(c++,c===l?s1(s,f,h.slice(0,-2)):f))}}catch{return o}}function s1(e,t,n){let r="",s=0;for(;s<e.length;)if(e[s]==="\\"&&s+1<e.length){let i=e[s+1];if(i==="&")r+="&",s+=2;else if(i==="0")r+=t,s+=2;else if(i>="1"&&i<="9"){let o=parseInt(i,10)-1;r+=n[o]||"",s+=2}else i==="n"?(r+=`
328
328
  `,s+=2):i==="t"?(r+=" ",s+=2):(r+=i,s+=2)}else e[s]==="&"?(r+=t,s++):(r+=e[s],s++);return r}async function U4(e,t,n){return e.length===0?"":ot(await n.evalExpr(e[0])).toLowerCase()}async function W4(e,t,n){return e.length===0?"":ot(await n.evalExpr(e[0])).toUpperCase()}async function B4(e,t,n){if(e.length===0)return"";let r=ot(await n.evalExpr(e[0])),s=[];for(let i=1;i<e.length;i++)s.push(await n.evalExpr(e[i]));return Ks(r,s)}async function H4(e,t,n){return e.length===0?0:Math.floor(Gt(await n.evalExpr(e[0])))}async function z4(e,t,n){return e.length===0?0:Math.sqrt(Gt(await n.evalExpr(e[0])))}async function j4(e,t,n){return e.length===0?0:Math.sin(Gt(await n.evalExpr(e[0])))}async function G4(e,t,n){return e.length===0?0:Math.cos(Gt(await n.evalExpr(e[0])))}async function V4(e,t,n){let r=e.length>0?Gt(await n.evalExpr(e[0])):0,s=e.length>1?Gt(await n.evalExpr(e[1])):0;return Math.atan2(r,s)}async function q4(e,t,n){return e.length===0?0:Math.log(Gt(await n.evalExpr(e[0])))}async function Z4(e,t,n){return e.length===0?1:Math.exp(Gt(await n.evalExpr(e[0])))}function Q4(e,t,n){return t.random?t.random():Math.random()}async function K4(e,t,n){let r=e.length>0?Gt(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=r,r}function X4(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function aa(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}function Ks(e,t){let n=0,r="",s=0;for(;s<e.length;)if(e[s]==="%"&&s+1<e.length){let i=s+1,o="",a="",l="",c,u=i;for(;i<e.length&&/\d/.test(e[i]);)i++;i>u&&e[i]==="$"?(c=parseInt(e.substring(u,i),10)-1,i++):i=u;let f=()=>{if(i<e.length){if(i+1<e.length&&(e[i]==="h"&&e[i+1]==="h"||e[i]==="l"&&e[i+1]==="l")){i+=2;return}/[lzjh]/.test(e[i])&&i++}};for(;i<e.length&&/[-+ #0]/.test(e[i]);)o+=e[i++];if(e[i]==="*"){let d=t[n++],g=d!==void 0?Math.floor(Number(d)):0;g<0?(o+="-",a=String(-g)):a=String(g),i++}else for(;i<e.length&&/\d/.test(e[i]);)a+=e[i++];if(e[i]===".")if(i++,e[i]==="*"){let d=t[n++];l=String(d!==void 0?Math.floor(Number(d)):0),i++}else for(;i<e.length&&/\d/.test(e[i]);)l+=e[i++];f();let h=e[i],m=t[c!==void 0?c:n];switch(h){case"s":{let d=m!==void 0?String(m):"";if(l&&(d=d.substring(0,parseInt(l,10))),a){let g=parseInt(a,10);o.includes("-")?d=d.padEnd(g):d=d.padStart(g)}r+=d,c===void 0&&n++;break}case"d":case"i":{let d=m!==void 0?Math.floor(Number(m)):0;Number.isNaN(d)&&(d=0);let g=d<0,y=Math.abs(d).toString();if(l){let x=parseInt(l,10);y=y.padStart(x,"0")}let w="";g?w="-":o.includes("+")?w="+":o.includes(" ")&&(w=" ");let b=w+y;if(a){let x=parseInt(a,10);o.includes("-")?b=b.padEnd(x):o.includes("0")&&!l?b=w+y.padStart(x-w.length,"0"):b=b.padStart(x)}r+=b,c===void 0&&n++;break}case"f":{let d=m!==void 0?Number(m):0;Number.isNaN(d)&&(d=0);let g=l?parseInt(l,10):6,y=d.toFixed(g);if(a){let w=parseInt(a,10);o.includes("-")?y=y.padEnd(w):y=y.padStart(w)}r+=y,c===void 0&&n++;break}case"e":case"E":{let d=m!==void 0?Number(m):0;Number.isNaN(d)&&(d=0);let g=l?parseInt(l,10):6,y=d.toExponential(g);if(h==="E"&&(y=y.toUpperCase()),a){let w=parseInt(a,10);o.includes("-")?y=y.padEnd(w):y=y.padStart(w)}r+=y,c===void 0&&n++;break}case"g":case"G":{let d=m!==void 0?Number(m):0;Number.isNaN(d)&&(d=0);let g=l?parseInt(l,10):6,y=d!==0?Math.floor(Math.log10(Math.abs(d))):0,w;if(d===0?w="0":y<-4||y>=g?(w=d.toExponential(g-1),h==="G"&&(w=w.toUpperCase())):w=d.toPrecision(g),w.includes(".")&&(w=w.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),w.includes("e")&&(w=w.replace(/\.?0+e/,"e")),a){let b=parseInt(a,10);o.includes("-")?w=w.padEnd(b):w=w.padStart(b)}r+=w,c===void 0&&n++;break}case"x":case"X":{let d=m!==void 0?Math.floor(Number(m)):0;Number.isNaN(d)&&(d=0);let g=Math.abs(d).toString(16);if(h==="X"&&(g=g.toUpperCase()),l){let b=parseInt(l,10);g=g.padStart(b,"0")}let y=d<0?"-":"",w=y+g;if(a){let b=parseInt(a,10);o.includes("-")?w=w.padEnd(b):o.includes("0")&&!l?w=y+g.padStart(b-y.length,"0"):w=w.padStart(b)}r+=w,c===void 0&&n++;break}case"o":{let d=m!==void 0?Math.floor(Number(m)):0;Number.isNaN(d)&&(d=0);let g=Math.abs(d).toString(8);if(l){let b=parseInt(l,10);g=g.padStart(b,"0")}let y=d<0?"-":"",w=y+g;if(a){let b=parseInt(a,10);o.includes("-")?w=w.padEnd(b):o.includes("0")&&!l?w=y+g.padStart(b-y.length,"0"):w=w.padStart(b)}r+=w,c===void 0&&n++;break}case"c":{typeof m=="number"?r+=String.fromCharCode(m):r+=String(m??"").charAt(0)||"",c===void 0&&n++;break}case"%":r+="%";break;default:r+=e.substring(s,i+1)}s=i+1}else if(e[s]==="\\"&&s+1<e.length){let i=e[s+1];switch(i){case"n":r+=`
329
- `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;default:r+=i}s+=2}else r+=e[s++];return r}var c1,la=I(()=>{"use strict";Me();c1=new Map([["length",$4],["substr",T4],["index",P4],["split",D4],["sub",L4],["gsub",_4],["match",M4],["gensub",F4],["tolower",U4],["toupper",W4],["sprintf",B4],["int",H4],["sqrt",z4],["sin",j4],["cos",G4],["atan2",V4],["log",q4],["exp",Z4],["rand",Q4],["srand",K4],["system",X4("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",aa("systime")],["mktime",aa("mktime")],["strftime",aa("strftime")]])});function bt(e){return typeof e=="number"?e!==0:!(e===""||e==="0")}function He(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function Re(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function ca(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function Yr(e,t){try{return V(e).test(t)}catch{return!1}}var mr=I(()=>{"use strict";Me()});function u1(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function Xs(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function ua(e,t,n){if(t===0)e.line=Re(n),e.fields=u1(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=Re(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function gr(e,t){e.line=t,e.fields=u1(e,t),e.NF=e.fields.length}function f1(e,t){if(e.FS=t,t===" ")e.fieldSep=new bn(/\s+/);else try{e.fieldSep=V(t)}catch{e.fieldSep=V(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var Ys=I(()=>{"use strict";Me();mr()});function Js(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;case"OFMT":return e.OFMT;case"NR":return e.NR;case"NF":return e.NF;case"FNR":return e.FNR;case"FILENAME":return e.FILENAME;case"RSTART":return e.RSTART;case"RLENGTH":return e.RLENGTH;case"SUBSEP":return e.SUBSEP;case"ARGC":return e.ARGC}return e.vars[t]??""}function yr(e,t,n){switch(t){case"FS":f1(e,Re(n));return;case"OFS":e.OFS=Re(n);return;case"ORS":e.ORS=Re(n);return;case"OFMT":e.OFMT=Re(n);return;case"NR":e.NR=Math.floor(He(n));return;case"NF":{let r=Math.floor(He(n));if(r<e.NF)e.fields=e.fields.slice(0,r),e.line=e.fields.join(e.OFS);else if(r>e.NF){for(;e.fields.length<r;)e.fields.push("");e.line=e.fields.join(e.OFS)}e.NF=r;return}case"FNR":e.FNR=Math.floor(He(n));return;case"FILENAME":e.FILENAME=Re(n);return;case"RSTART":e.RSTART=Math.floor(He(n));return;case"RLENGTH":e.RLENGTH=Math.floor(He(n));return;case"SUBSEP":e.SUBSEP=Re(n);return}e.vars[t]=n}function Jr(e,t){let n=t,r=new Set,s=e.arrayAliases.get(n);for(;s!==void 0&&!r.has(n);)r.add(n),n=s,s=e.arrayAliases.get(n);return n}function ei(e,t,n){if(t==="ARGV")return e.ARGV[n]??"";if(t==="ENVIRON")return e.ENVIRON[n]??"";let r=Jr(e,t);return e.arrays[r]?.[n]??""}function fa(e,t,n,r){let s=Jr(e,t);e.arrays[s]||(e.arrays[s]=Object.create(null)),e.arrays[s][n]=r}function h1(e,t,n){if(t==="ARGV")return e.ARGV[n]!==void 0;if(t==="ENVIRON")return e.ENVIRON[n]!==void 0;let r=Jr(e,t);return e.arrays[r]?.[n]!==void 0}function p1(e,t,n){let r=Jr(e,t);e.arrays[r]&&delete e.arrays[r][n]}function d1(e,t){let n=Jr(e,t);delete e.arrays[n]}var ha=I(()=>{"use strict";Ys();mr()});function m1(e){pa=e}async function le(e,t){switch(t.type){case"number":return t.value;case"string":return t.value;case"regex":return Yr(t.pattern,e.line)?1:0;case"field":return Y4(e,t);case"variable":return Js(e,t.name);case"array_access":return J4(e,t);case"binary":return e3(e,t);case"unary":return r3(e,t);case"ternary":return bt(await le(e,t.condition))?await le(e,t.consequent):await le(e,t.alternate);case"call":return s3(e,t.name,t.args);case"assignment":return o3(e,t);case"pre_increment":return a3(e,t.operand);case"pre_decrement":return l3(e,t.operand);case"post_increment":return c3(e,t.operand);case"post_decrement":return u3(e,t.operand);case"in":return f3(e,t.key,t.array);case"getline":return h3(e,t.variable,t.file,t.command);case"tuple":return m3(e,t.elements);default:return""}}async function Y4(e,t){let n=Math.floor(He(await le(e,t.index)));return Xs(e,n)}async function J4(e,t){let n=Re(await le(e,t.key));return ei(e,t.array,n)}async function e3(e,t){let n=t.operator;if(n==="||")return bt(await le(e,t.left))||bt(await le(e,t.right))?1:0;if(n==="&&")return bt(await le(e,t.left))&&bt(await le(e,t.right))?1:0;if(n==="~"){let a=await le(e,t.left),l=t.right.type==="regex"?t.right.pattern:Re(await le(e,t.right));try{return V(l).test(Re(a))?1:0}catch{return 0}}if(n==="!~"){let a=await le(e,t.left),l=t.right.type==="regex"?t.right.pattern:Re(await le(e,t.right));try{return V(l).test(Re(a))?0:1}catch{return 1}}let r=await le(e,t.left),s=await le(e,t.right);if(n===" ")return Re(r)+Re(s);if(t3(n))return n3(r,s,n);let i=He(r),o=He(s);return n1(i,o,n)}function t3(e){return["<","<=",">",">=","==","!="].includes(e)}function n3(e,t,n){let r=ca(e),s=ca(t);if(r&&s){let a=He(e),l=He(t);switch(n){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=Re(e),o=Re(t);switch(n){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 r3(e,t){let n=await le(e,t.operand);switch(t.operator){case"!":return bt(n)?0:1;case"-":return-He(n);case"+":return+He(n);default:return n}}async function s3(e,t,n){let r=c1.get(t);if(r)return r(n,e,{evalExpr:i=>le(e,i)});let s=e.functions.get(t);return s?i3(e,s,n):""}async function i3(e,t,n){if(e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new re(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let r=Object.create(null);for(let o of t.params)r[o]=e.vars[o];let s=[];for(let o=0;o<t.params.length;o++){let a=t.params[o];if(o<n.length){let l=n[o];l.type==="variable"&&(e.arrayAliases.set(a,l.name),s.push(a));let c=await le(e,l);e.vars[a]=c}else e.vars[a]=""}e.hasReturn=!1,e.returnValue=void 0,pa&&await pa(e,t.body.statements);let i=e.returnValue??"";for(let o of t.params)r[o]!==void 0?e.vars[o]=r[o]:delete e.vars[o];for(let o of s)e.arrayAliases.delete(o);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,i}async function o3(e,t){let n=await le(e,t.value),r=t.target,s=t.operator,i;if(s==="=")i=n;else{let o;if(r.type==="field"){let c=Math.floor(He(await le(e,r.index)));o=Xs(e,c)}else if(r.type==="variable")o=Js(e,r.name);else{let c=Re(await le(e,r.key));o=ei(e,r.array,c)}let a=He(o),l=He(n);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=n}}if(r.type==="field"){let o=Math.floor(He(await le(e,r.index)));ua(e,o,i)}else if(r.type==="variable")yr(e,r.name,i);else{let o=Re(await le(e,r.key));fa(e,r.array,o,i)}return i}async function ti(e,t,n,r){let s;if(t.type==="field"){let i=Math.floor(He(await le(e,t.index)));s=He(Xs(e,i)),ua(e,i,s+n)}else if(t.type==="variable")s=He(Js(e,t.name)),yr(e,t.name,s+n);else{let i=Re(await le(e,t.key));s=He(ei(e,t.array,i)),fa(e,t.array,i,s+n)}return r?s+n:s}async function a3(e,t){return ti(e,t,1,!0)}async function l3(e,t){return ti(e,t,-1,!0)}async function c3(e,t){return ti(e,t,1,!1)}async function u3(e,t){return ti(e,t,-1,!1)}async function f3(e,t,n){let r;if(t.type==="tuple"){let s=[];for(let i of t.elements)s.push(Re(await le(e,i)));r=s.join(e.SUBSEP)}else r=Re(await le(e,t));return h1(e,n,r)?1:0}async function h3(e,t,n,r){if(r)return p3(e,t,r);if(n)return d3(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let s=e.lineIndex+1;if(s>=e.lines.length)return 0;let i=e.lines[s];return t?yr(e,t,i):gr(e,i),e.NR++,e.lineIndex=s,1}async function p3(e,t,n){if(!e.exec)return-1;let r=Re(await le(e,n)),s=`__cmd_${r}`,i=`__cmdi_${r}`,o,a;if(e.vars[s]===void 0)try{o=(await e.exec(r)).stdout.split(`
330
- `),o.length>0&&o[o.length-1]===""&&o.pop(),e.vars[s]=JSON.stringify(o),e.vars[i]=-1,a=-1}catch{return-1}else o=JSON.parse(e.vars[s]),a=e.vars[i];let l=a+1;if(l>=o.length)return 0;let c=o[l];return e.vars[i]=l,t?yr(e,t,c):gr(e,c),1}async function d3(e,t,n){if(!e.fs||!e.cwd)return-1;let r=Re(await le(e,n));if(r==="/dev/null")return 0;let s=e.fs.resolvePath(e.cwd,r),i=`__fc_${s}`,o=`__fi_${s}`,a,l;if(e.vars[i]===void 0)try{a=(await e.fs.readFile(s)).split(`
331
- `),a.length>0&&a[a.length-1]===""&&a.pop(),e.vars[i]=JSON.stringify(a),e.vars[o]=-1,l=-1}catch{return-1}else a=JSON.parse(e.vars[i]),l=e.vars[o];let c=l+1;if(c>=a.length)return 0;let u=a[c];return e.vars[o]=c,t?yr(e,t,u):gr(e,u),1}async function m3(e,t){if(t.length===0)return"";for(let n=0;n<t.length-1;n++)await le(e,t[n]);return le(e,t[t.length-1])}var pa,da=I(()=>{"use strict";xe();Me();r1();la();Ys();mr();ha();pa=null});async function wr(e,t){for(let n of t)if(await jn(e,n),g3(e))break}function g3(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function jn(e,t){switch(t.type){case"block":await wr(e,t.statements);break;case"expr_stmt":await le(e,t.expression);break;case"print":await y3(e,t.args,t.output);break;case"printf":await w3(e,t.format,t.args,t.output);break;case"if":await b3(e,t);break;case"while":await x3(e,t);break;case"do_while":await E3(e,t);break;case"for":await A3(e,t);break;case"for_in":await S3(e,t);break;case"break":e.loopBreak=!0;break;case"continue":e.loopContinue=!0;break;case"next":e.shouldNext=!0;break;case"nextfile":e.shouldNextFile=!0;break;case"exit":e.shouldExit=!0,e.exitCode=t.code?Math.floor(He(await le(e,t.code))):0;break;case"return":e.hasReturn=!0,e.returnValue=t.value?await le(e,t.value):"";break;case"delete":await C3(e,t.target);break}}async function y3(e,t,n){let r=[];for(let i of t){let o=await le(e,i);typeof o=="number"?Number.isInteger(o)&&Math.abs(o)<Number.MAX_SAFE_INTEGER?r.push(String(o)):r.push(Ks(e.OFMT,[o])):r.push(Re(o))}let s=r.join(e.OFS)+e.ORS;n?await g1(e,n.redirect,n.file,s):e.output+=s}async function w3(e,t,n,r){let s=Re(await le(e,t)),i=[];for(let a of n)i.push(await le(e,a));let o=Ks(s,i);r?await g1(e,r.redirect,r.file,o):e.output+=o}async function g1(e,t,n,r){if(!e.fs||!e.cwd){e.output+=r;return}let s=Re(await le(e,n)),i=e.fs.resolvePath(e.cwd,s);t===">"?e.openedFiles.has(i)?await e.fs.appendFile(i,r):(await e.fs.writeFile(i,r),e.openedFiles.add(i)):(e.openedFiles.has(i)||e.openedFiles.add(i),await e.fs.appendFile(i,r))}async function b3(e,t){bt(await le(e,t.condition))?await jn(e,t.consequent):t.alternate&&await jn(e,t.alternate)}async function x3(e,t){let n=0;for(;bt(await le(e,t.condition));){if(n++,n>e.maxIterations)throw new re(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function E3(e,t){let n=0;do{if(n++,n>e.maxIterations)throw new re(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(bt(await le(e,t.condition)))}async function A3(e,t){t.init&&await le(e,t.init);let n=0;for(;!t.condition||bt(await le(e,t.condition));){if(n++,n>e.maxIterations)throw new re(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;t.update&&await le(e,t.update)}}async function S3(e,t){let n=e.arrays[t.array];if(n)for(let r of Object.keys(n)){if(e.vars[t.variable]=r,e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function C3(e,t){if(t.type==="array_access"){let n=Re(await le(e,t.key));p1(e,t.array,n)}else t.type==="variable"&&d1(e,t.name)}var y1=I(()=>{"use strict";xe();la();da();mr();ha();m1(wr)});var es,w1=I(()=>{"use strict";da();Ys();y1();mr();es=class{ctx;program=null;rangeStates=[];constructor(t){this.ctx=t}execute(t){this.program=t,this.ctx.output="";for(let n of t.functions)this.ctx.functions.set(n.name,n);this.rangeStates=t.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let t of this.program.rules)if(t.pattern?.type==="begin"&&(await wr(this.ctx,t.action.statements),this.ctx.shouldExit))break}}async executeLine(t){if(!(!this.program||this.ctx.shouldExit)){gr(this.ctx,t),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let n=0;n<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);n++){let r=this.program.rules[n];r.pattern?.type==="begin"||r.pattern?.type==="end"||await this.matchesRule(r,n)&&await wr(this.ctx,r.action.statements)}}}async executeEnd(){if(this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let t of this.program.rules)if(t.pattern?.type==="end"&&(await wr(this.ctx,t.action.statements),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(t,n){let r=t.pattern;if(!r)return!0;switch(r.type){case"begin":case"end":return!1;case"regex_pattern":return Yr(r.pattern,this.ctx.line);case"expr_pattern":return bt(await le(this.ctx,r.expression));case"range":{let s=await this.matchPattern(r.start),i=await this.matchPattern(r.end);return this.rangeStates[n]?(i&&(this.rangeStates[n]=!1),!0):s?(this.rangeStates[n]=!0,i&&(this.rangeStates[n]=!1),!0):!1}default:return!1}}async matchPattern(t){switch(t.type){case"regex_pattern":return Yr(t.pattern,this.ctx.line);case"expr_pattern":return bt(await le(this.ctx,t.expression));default:return!1}}}});var b1=I(()=>{"use strict";t1();w1()});function k3(e){return e.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 A,N3,ni,x1=I(()=>{"use strict";(function(e){e.NUMBER="NUMBER",e.STRING="STRING",e.REGEX="REGEX",e.IDENT="IDENT",e.BEGIN="BEGIN",e.END="END",e.IF="IF",e.ELSE="ELSE",e.WHILE="WHILE",e.DO="DO",e.FOR="FOR",e.IN="IN",e.BREAK="BREAK",e.CONTINUE="CONTINUE",e.NEXT="NEXT",e.NEXTFILE="NEXTFILE",e.EXIT="EXIT",e.RETURN="RETURN",e.DELETE="DELETE",e.FUNCTION="FUNCTION",e.PRINT="PRINT",e.PRINTF="PRINTF",e.GETLINE="GETLINE",e.PLUS="PLUS",e.MINUS="MINUS",e.STAR="STAR",e.SLASH="SLASH",e.PERCENT="PERCENT",e.CARET="CARET",e.EQ="EQ",e.NE="NE",e.LT="LT",e.GT="GT",e.LE="LE",e.GE="GE",e.MATCH="MATCH",e.NOT_MATCH="NOT_MATCH",e.AND="AND",e.OR="OR",e.NOT="NOT",e.ASSIGN="ASSIGN",e.PLUS_ASSIGN="PLUS_ASSIGN",e.MINUS_ASSIGN="MINUS_ASSIGN",e.STAR_ASSIGN="STAR_ASSIGN",e.SLASH_ASSIGN="SLASH_ASSIGN",e.PERCENT_ASSIGN="PERCENT_ASSIGN",e.CARET_ASSIGN="CARET_ASSIGN",e.INCREMENT="INCREMENT",e.DECREMENT="DECREMENT",e.QUESTION="QUESTION",e.COLON="COLON",e.COMMA="COMMA",e.SEMICOLON="SEMICOLON",e.NEWLINE="NEWLINE",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.LBRACKET="LBRACKET",e.RBRACKET="RBRACKET",e.DOLLAR="DOLLAR",e.APPEND="APPEND",e.PIPE="PIPE",e.EOF="EOF"})(A||(A={}));N3=new Map([["BEGIN",A.BEGIN],["END",A.END],["if",A.IF],["else",A.ELSE],["while",A.WHILE],["do",A.DO],["for",A.FOR],["in",A.IN],["break",A.BREAK],["continue",A.CONTINUE],["next",A.NEXT],["nextfile",A.NEXTFILE],["exit",A.EXIT],["return",A.RETURN],["delete",A.DELETE],["function",A.FUNCTION],["print",A.PRINT],["printf",A.PRINTF],["getline",A.GETLINE]]);ni=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(t){this.input=t}tokenize(){let t=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&(t.push(n),this.lastTokenType=n.type)}return t.push(this.makeToken(A.EOF,"")),t}makeToken(t,n){return{type:t,value:n,line:this.line,column:this.column}}peek(t=0){return this.input[this.pos+t]||""}advance(){let t=this.input[this.pos++]||"";return t===`
329
+ `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;default:r+=i}s+=2}else r+=e[s++];return r}var c1,la=I(()=>{"use strict";Me();c1=new Map([["length",$4],["substr",T4],["index",P4],["split",D4],["sub",L4],["gsub",_4],["match",M4],["gensub",F4],["tolower",U4],["toupper",W4],["sprintf",B4],["int",H4],["sqrt",z4],["sin",j4],["cos",G4],["atan2",V4],["log",q4],["exp",Z4],["rand",Q4],["srand",K4],["system",X4("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",aa("systime")],["mktime",aa("mktime")],["strftime",aa("strftime")]])});function bt(e){return typeof e=="number"?e!==0:!(e===""||e==="0")}function He(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function Oe(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function ca(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function Yr(e,t){try{return V(e).test(t)}catch{return!1}}var mr=I(()=>{"use strict";Me()});function u1(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function Xs(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function ua(e,t,n){if(t===0)e.line=Oe(n),e.fields=u1(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=Oe(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function gr(e,t){e.line=t,e.fields=u1(e,t),e.NF=e.fields.length}function f1(e,t){if(e.FS=t,t===" ")e.fieldSep=new bn(/\s+/);else try{e.fieldSep=V(t)}catch{e.fieldSep=V(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var Ys=I(()=>{"use strict";Me();mr()});function Js(e,t){switch(t){case"FS":return e.FS;case"OFS":return e.OFS;case"ORS":return e.ORS;case"OFMT":return e.OFMT;case"NR":return e.NR;case"NF":return e.NF;case"FNR":return e.FNR;case"FILENAME":return e.FILENAME;case"RSTART":return e.RSTART;case"RLENGTH":return e.RLENGTH;case"SUBSEP":return e.SUBSEP;case"ARGC":return e.ARGC}return e.vars[t]??""}function yr(e,t,n){switch(t){case"FS":f1(e,Oe(n));return;case"OFS":e.OFS=Oe(n);return;case"ORS":e.ORS=Oe(n);return;case"OFMT":e.OFMT=Oe(n);return;case"NR":e.NR=Math.floor(He(n));return;case"NF":{let r=Math.floor(He(n));if(r<e.NF)e.fields=e.fields.slice(0,r),e.line=e.fields.join(e.OFS);else if(r>e.NF){for(;e.fields.length<r;)e.fields.push("");e.line=e.fields.join(e.OFS)}e.NF=r;return}case"FNR":e.FNR=Math.floor(He(n));return;case"FILENAME":e.FILENAME=Oe(n);return;case"RSTART":e.RSTART=Math.floor(He(n));return;case"RLENGTH":e.RLENGTH=Math.floor(He(n));return;case"SUBSEP":e.SUBSEP=Oe(n);return}e.vars[t]=n}function Jr(e,t){let n=t,r=new Set,s=e.arrayAliases.get(n);for(;s!==void 0&&!r.has(n);)r.add(n),n=s,s=e.arrayAliases.get(n);return n}function ei(e,t,n){if(t==="ARGV")return e.ARGV[n]??"";if(t==="ENVIRON")return e.ENVIRON[n]??"";let r=Jr(e,t);return e.arrays[r]?.[n]??""}function fa(e,t,n,r){let s=Jr(e,t);e.arrays[s]||(e.arrays[s]=Object.create(null)),e.arrays[s][n]=r}function h1(e,t,n){if(t==="ARGV")return e.ARGV[n]!==void 0;if(t==="ENVIRON")return e.ENVIRON[n]!==void 0;let r=Jr(e,t);return e.arrays[r]?.[n]!==void 0}function p1(e,t,n){let r=Jr(e,t);e.arrays[r]&&delete e.arrays[r][n]}function d1(e,t){let n=Jr(e,t);delete e.arrays[n]}var ha=I(()=>{"use strict";Ys();mr()});function m1(e){pa=e}async function le(e,t){switch(t.type){case"number":return t.value;case"string":return t.value;case"regex":return Yr(t.pattern,e.line)?1:0;case"field":return Y4(e,t);case"variable":return Js(e,t.name);case"array_access":return J4(e,t);case"binary":return e3(e,t);case"unary":return r3(e,t);case"ternary":return bt(await le(e,t.condition))?await le(e,t.consequent):await le(e,t.alternate);case"call":return s3(e,t.name,t.args);case"assignment":return o3(e,t);case"pre_increment":return a3(e,t.operand);case"pre_decrement":return l3(e,t.operand);case"post_increment":return c3(e,t.operand);case"post_decrement":return u3(e,t.operand);case"in":return f3(e,t.key,t.array);case"getline":return h3(e,t.variable,t.file,t.command);case"tuple":return m3(e,t.elements);default:return""}}async function Y4(e,t){let n=Math.floor(He(await le(e,t.index)));return Xs(e,n)}async function J4(e,t){let n=Oe(await le(e,t.key));return ei(e,t.array,n)}async function e3(e,t){let n=t.operator;if(n==="||")return bt(await le(e,t.left))||bt(await le(e,t.right))?1:0;if(n==="&&")return bt(await le(e,t.left))&&bt(await le(e,t.right))?1:0;if(n==="~"){let a=await le(e,t.left),l=t.right.type==="regex"?t.right.pattern:Oe(await le(e,t.right));try{return V(l).test(Oe(a))?1:0}catch{return 0}}if(n==="!~"){let a=await le(e,t.left),l=t.right.type==="regex"?t.right.pattern:Oe(await le(e,t.right));try{return V(l).test(Oe(a))?0:1}catch{return 1}}let r=await le(e,t.left),s=await le(e,t.right);if(n===" ")return Oe(r)+Oe(s);if(t3(n))return n3(r,s,n);let i=He(r),o=He(s);return n1(i,o,n)}function t3(e){return["<","<=",">",">=","==","!="].includes(e)}function n3(e,t,n){let r=ca(e),s=ca(t);if(r&&s){let a=He(e),l=He(t);switch(n){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=Oe(e),o=Oe(t);switch(n){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 r3(e,t){let n=await le(e,t.operand);switch(t.operator){case"!":return bt(n)?0:1;case"-":return-He(n);case"+":return+He(n);default:return n}}async function s3(e,t,n){let r=c1.get(t);if(r)return r(n,e,{evalExpr:i=>le(e,i)});let s=e.functions.get(t);return s?i3(e,s,n):""}async function i3(e,t,n){if(e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new re(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let r=Object.create(null);for(let o of t.params)r[o]=e.vars[o];let s=[];for(let o=0;o<t.params.length;o++){let a=t.params[o];if(o<n.length){let l=n[o];l.type==="variable"&&(e.arrayAliases.set(a,l.name),s.push(a));let c=await le(e,l);e.vars[a]=c}else e.vars[a]=""}e.hasReturn=!1,e.returnValue=void 0,pa&&await pa(e,t.body.statements);let i=e.returnValue??"";for(let o of t.params)r[o]!==void 0?e.vars[o]=r[o]:delete e.vars[o];for(let o of s)e.arrayAliases.delete(o);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,i}async function o3(e,t){let n=await le(e,t.value),r=t.target,s=t.operator,i;if(s==="=")i=n;else{let o;if(r.type==="field"){let c=Math.floor(He(await le(e,r.index)));o=Xs(e,c)}else if(r.type==="variable")o=Js(e,r.name);else{let c=Oe(await le(e,r.key));o=ei(e,r.array,c)}let a=He(o),l=He(n);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=n}}if(r.type==="field"){let o=Math.floor(He(await le(e,r.index)));ua(e,o,i)}else if(r.type==="variable")yr(e,r.name,i);else{let o=Oe(await le(e,r.key));fa(e,r.array,o,i)}return i}async function ti(e,t,n,r){let s;if(t.type==="field"){let i=Math.floor(He(await le(e,t.index)));s=He(Xs(e,i)),ua(e,i,s+n)}else if(t.type==="variable")s=He(Js(e,t.name)),yr(e,t.name,s+n);else{let i=Oe(await le(e,t.key));s=He(ei(e,t.array,i)),fa(e,t.array,i,s+n)}return r?s+n:s}async function a3(e,t){return ti(e,t,1,!0)}async function l3(e,t){return ti(e,t,-1,!0)}async function c3(e,t){return ti(e,t,1,!1)}async function u3(e,t){return ti(e,t,-1,!1)}async function f3(e,t,n){let r;if(t.type==="tuple"){let s=[];for(let i of t.elements)s.push(Oe(await le(e,i)));r=s.join(e.SUBSEP)}else r=Oe(await le(e,t));return h1(e,n,r)?1:0}async function h3(e,t,n,r){if(r)return p3(e,t,r);if(n)return d3(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let s=e.lineIndex+1;if(s>=e.lines.length)return 0;let i=e.lines[s];return t?yr(e,t,i):gr(e,i),e.NR++,e.lineIndex=s,1}async function p3(e,t,n){if(!e.exec)return-1;let r=Oe(await le(e,n)),s=`__cmd_${r}`,i=`__cmdi_${r}`,o,a;if(e.vars[s]===void 0)try{o=(await e.exec(r)).stdout.split(`
330
+ `),o.length>0&&o[o.length-1]===""&&o.pop(),e.vars[s]=JSON.stringify(o),e.vars[i]=-1,a=-1}catch{return-1}else o=JSON.parse(e.vars[s]),a=e.vars[i];let l=a+1;if(l>=o.length)return 0;let c=o[l];return e.vars[i]=l,t?yr(e,t,c):gr(e,c),1}async function d3(e,t,n){if(!e.fs||!e.cwd)return-1;let r=Oe(await le(e,n));if(r==="/dev/null")return 0;let s=e.fs.resolvePath(e.cwd,r),i=`__fc_${s}`,o=`__fi_${s}`,a,l;if(e.vars[i]===void 0)try{a=(await e.fs.readFile(s)).split(`
331
+ `),a.length>0&&a[a.length-1]===""&&a.pop(),e.vars[i]=JSON.stringify(a),e.vars[o]=-1,l=-1}catch{return-1}else a=JSON.parse(e.vars[i]),l=e.vars[o];let c=l+1;if(c>=a.length)return 0;let u=a[c];return e.vars[o]=c,t?yr(e,t,u):gr(e,u),1}async function m3(e,t){if(t.length===0)return"";for(let n=0;n<t.length-1;n++)await le(e,t[n]);return le(e,t[t.length-1])}var pa,da=I(()=>{"use strict";xe();Me();r1();la();Ys();mr();ha();pa=null});async function wr(e,t){for(let n of t)if(await jn(e,n),g3(e))break}function g3(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function jn(e,t){switch(t.type){case"block":await wr(e,t.statements);break;case"expr_stmt":await le(e,t.expression);break;case"print":await y3(e,t.args,t.output);break;case"printf":await w3(e,t.format,t.args,t.output);break;case"if":await b3(e,t);break;case"while":await x3(e,t);break;case"do_while":await E3(e,t);break;case"for":await A3(e,t);break;case"for_in":await S3(e,t);break;case"break":e.loopBreak=!0;break;case"continue":e.loopContinue=!0;break;case"next":e.shouldNext=!0;break;case"nextfile":e.shouldNextFile=!0;break;case"exit":e.shouldExit=!0,e.exitCode=t.code?Math.floor(He(await le(e,t.code))):0;break;case"return":e.hasReturn=!0,e.returnValue=t.value?await le(e,t.value):"";break;case"delete":await C3(e,t.target);break}}async function y3(e,t,n){let r=[];for(let i of t){let o=await le(e,i);typeof o=="number"?Number.isInteger(o)&&Math.abs(o)<Number.MAX_SAFE_INTEGER?r.push(String(o)):r.push(Ks(e.OFMT,[o])):r.push(Oe(o))}let s=r.join(e.OFS)+e.ORS;n?await g1(e,n.redirect,n.file,s):e.output+=s}async function w3(e,t,n,r){let s=Oe(await le(e,t)),i=[];for(let a of n)i.push(await le(e,a));let o=Ks(s,i);r?await g1(e,r.redirect,r.file,o):e.output+=o}async function g1(e,t,n,r){if(!e.fs||!e.cwd){e.output+=r;return}let s=Oe(await le(e,n)),i=e.fs.resolvePath(e.cwd,s);t===">"?e.openedFiles.has(i)?await e.fs.appendFile(i,r):(await e.fs.writeFile(i,r),e.openedFiles.add(i)):(e.openedFiles.has(i)||e.openedFiles.add(i),await e.fs.appendFile(i,r))}async function b3(e,t){bt(await le(e,t.condition))?await jn(e,t.consequent):t.alternate&&await jn(e,t.alternate)}async function x3(e,t){let n=0;for(;bt(await le(e,t.condition));){if(n++,n>e.maxIterations)throw new re(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function E3(e,t){let n=0;do{if(n++,n>e.maxIterations)throw new re(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(bt(await le(e,t.condition)))}async function A3(e,t){t.init&&await le(e,t.init);let n=0;for(;!t.condition||bt(await le(e,t.condition));){if(n++,n>e.maxIterations)throw new re(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;t.update&&await le(e,t.update)}}async function S3(e,t){let n=e.arrays[t.array];if(n)for(let r of Object.keys(n)){if(e.vars[t.variable]=r,e.loopContinue=!1,await jn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function C3(e,t){if(t.type==="array_access"){let n=Oe(await le(e,t.key));p1(e,t.array,n)}else t.type==="variable"&&d1(e,t.name)}var y1=I(()=>{"use strict";xe();la();da();mr();ha();m1(wr)});var es,w1=I(()=>{"use strict";da();Ys();y1();mr();es=class{ctx;program=null;rangeStates=[];constructor(t){this.ctx=t}execute(t){this.program=t,this.ctx.output="";for(let n of t.functions)this.ctx.functions.set(n.name,n);this.rangeStates=t.rules.map(()=>!1)}async executeBegin(){if(this.program){for(let t of this.program.rules)if(t.pattern?.type==="begin"&&(await wr(this.ctx,t.action.statements),this.ctx.shouldExit))break}}async executeLine(t){if(!(!this.program||this.ctx.shouldExit)){gr(this.ctx,t),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let n=0;n<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);n++){let r=this.program.rules[n];r.pattern?.type==="begin"||r.pattern?.type==="end"||await this.matchesRule(r,n)&&await wr(this.ctx,r.action.statements)}}}async executeEnd(){if(this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let t of this.program.rules)if(t.pattern?.type==="end"&&(await wr(this.ctx,t.action.statements),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(t,n){let r=t.pattern;if(!r)return!0;switch(r.type){case"begin":case"end":return!1;case"regex_pattern":return Yr(r.pattern,this.ctx.line);case"expr_pattern":return bt(await le(this.ctx,r.expression));case"range":{let s=await this.matchPattern(r.start),i=await this.matchPattern(r.end);return this.rangeStates[n]?(i&&(this.rangeStates[n]=!1),!0):s?(this.rangeStates[n]=!0,i&&(this.rangeStates[n]=!1),!0):!1}default:return!1}}async matchPattern(t){switch(t.type){case"regex_pattern":return Yr(t.pattern,this.ctx.line);case"expr_pattern":return bt(await le(this.ctx,t.expression));default:return!1}}}});var b1=I(()=>{"use strict";t1();w1()});function k3(e){return e.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 A,N3,ni,x1=I(()=>{"use strict";(function(e){e.NUMBER="NUMBER",e.STRING="STRING",e.REGEX="REGEX",e.IDENT="IDENT",e.BEGIN="BEGIN",e.END="END",e.IF="IF",e.ELSE="ELSE",e.WHILE="WHILE",e.DO="DO",e.FOR="FOR",e.IN="IN",e.BREAK="BREAK",e.CONTINUE="CONTINUE",e.NEXT="NEXT",e.NEXTFILE="NEXTFILE",e.EXIT="EXIT",e.RETURN="RETURN",e.DELETE="DELETE",e.FUNCTION="FUNCTION",e.PRINT="PRINT",e.PRINTF="PRINTF",e.GETLINE="GETLINE",e.PLUS="PLUS",e.MINUS="MINUS",e.STAR="STAR",e.SLASH="SLASH",e.PERCENT="PERCENT",e.CARET="CARET",e.EQ="EQ",e.NE="NE",e.LT="LT",e.GT="GT",e.LE="LE",e.GE="GE",e.MATCH="MATCH",e.NOT_MATCH="NOT_MATCH",e.AND="AND",e.OR="OR",e.NOT="NOT",e.ASSIGN="ASSIGN",e.PLUS_ASSIGN="PLUS_ASSIGN",e.MINUS_ASSIGN="MINUS_ASSIGN",e.STAR_ASSIGN="STAR_ASSIGN",e.SLASH_ASSIGN="SLASH_ASSIGN",e.PERCENT_ASSIGN="PERCENT_ASSIGN",e.CARET_ASSIGN="CARET_ASSIGN",e.INCREMENT="INCREMENT",e.DECREMENT="DECREMENT",e.QUESTION="QUESTION",e.COLON="COLON",e.COMMA="COMMA",e.SEMICOLON="SEMICOLON",e.NEWLINE="NEWLINE",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.LBRACKET="LBRACKET",e.RBRACKET="RBRACKET",e.DOLLAR="DOLLAR",e.APPEND="APPEND",e.PIPE="PIPE",e.EOF="EOF"})(A||(A={}));N3=new Map([["BEGIN",A.BEGIN],["END",A.END],["if",A.IF],["else",A.ELSE],["while",A.WHILE],["do",A.DO],["for",A.FOR],["in",A.IN],["break",A.BREAK],["continue",A.CONTINUE],["next",A.NEXT],["nextfile",A.NEXTFILE],["exit",A.EXIT],["return",A.RETURN],["delete",A.DELETE],["function",A.FUNCTION],["print",A.PRINT],["printf",A.PRINTF],["getline",A.GETLINE]]);ni=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(t){this.input=t}tokenize(){let t=[];for(;this.pos<this.input.length;){let n=this.nextToken();n&&(t.push(n),this.lastTokenType=n.type)}return t.push(this.makeToken(A.EOF,"")),t}makeToken(t,n){return{type:t,value:n,line:this.line,column:this.column}}peek(t=0){return this.input[this.pos+t]||""}advance(){let t=this.input[this.pos++]||"";return t===`
332
332
  `?(this.line++,this.column=1):this.column++,t}skipWhitespace(){for(;this.pos<this.input.length;){let t=this.peek();if(t===" "||t===" "||t==="\r")this.advance();else if(t==="\\")if(this.peek(1)===`
333
333
  `)this.advance(),this.advance();else break;else if(t==="#")for(;this.pos<this.input.length&&this.peek()!==`
334
334
  `;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let t=this.line,n=this.column,r=this.peek();return r===`
335
335
  `?(this.advance(),{type:A.NEWLINE,value:`
336
336
  `,line:t,column:n}):r==='"'?this.readString():r==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(r)||r==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(r)||r==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,A.NEWLINE,A.SEMICOLON,A.LBRACE,A.RBRACE,A.LPAREN,A.LBRACKET,A.COMMA,A.ASSIGN,A.PLUS_ASSIGN,A.MINUS_ASSIGN,A.STAR_ASSIGN,A.SLASH_ASSIGN,A.PERCENT_ASSIGN,A.CARET_ASSIGN,A.AND,A.OR,A.NOT,A.MATCH,A.NOT_MATCH,A.QUESTION,A.COLON,A.LT,A.GT,A.LE,A.GE,A.EQ,A.NE,A.PLUS,A.MINUS,A.STAR,A.PERCENT,A.CARET,A.PRINT,A.PRINTF,A.IF,A.WHILE,A.DO,A.FOR,A.RETURN]).has(this.lastTokenType)}readString(){let t=this.line,n=this.column;this.advance();let r="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let s=this.advance();switch(s){case"n":r+=`
337
337
  `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"f":r+="\f";break;case"b":r+="\b";break;case"v":r+="\v";break;case"a":r+="\x07";break;case"\\":r+="\\";break;case'"':r+='"';break;case"/":r+="/";break;case"x":{let i="";for(;i.length<2&&/[0-9a-fA-F]/.test(this.peek());)i+=this.advance();i.length>0?r+=String.fromCharCode(parseInt(i,16)):r+="x";break}default:if(/[0-7]/.test(s)){let i=s;for(;i.length<3&&/[0-7]/.test(this.peek());)i+=this.advance();r+=String.fromCharCode(parseInt(i,8))}else r+=s}}else r+=this.advance();return this.peek()==='"'&&this.advance(),{type:A.STRING,value:r,line:t,column:n}}readRegex(){let t=this.line,n=this.column;this.advance();let r="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")r+=this.advance(),this.pos<this.input.length&&(r+=this.advance());else{if(this.peek()===`
338
- `)break;r+=this.advance()}return this.peek()==="/"&&this.advance(),r=k3(r),{type:A.REGEX,value:r,line:t,column:n}}readNumber(){let t=this.line,n=this.column,r="";for(;this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(r+=this.advance();this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(r+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(r+=this.advance());this.isDigit(this.peek());)r+=this.advance();return{type:A.NUMBER,value:parseFloat(r),line:t,column:n}}readIdentifier(){let t=this.line,n=this.column,r="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)r+=this.advance();let s=N3.get(r);return s!==void 0?{type:s,value:r,line:t,column:n}:{type:A.IDENT,value:r,line:t,column:n}}readOperator(){let t=this.line,n=this.column,r=this.advance(),s=this.peek();switch(r){case"+":return s==="+"?(this.advance(),{type:A.INCREMENT,value:"++",line:t,column:n}):s==="="?(this.advance(),{type:A.PLUS_ASSIGN,value:"+=",line:t,column:n}):{type:A.PLUS,value:"+",line:t,column:n};case"-":return s==="-"?(this.advance(),{type:A.DECREMENT,value:"--",line:t,column:n}):s==="="?(this.advance(),{type:A.MINUS_ASSIGN,value:"-=",line:t,column:n}):{type:A.MINUS,value:"-",line:t,column:n};case"*":return s==="*"?(this.advance(),{type:A.CARET,value:"**",line:t,column:n}):s==="="?(this.advance(),{type:A.STAR_ASSIGN,value:"*=",line:t,column:n}):{type:A.STAR,value:"*",line:t,column:n};case"/":return s==="="?(this.advance(),{type:A.SLASH_ASSIGN,value:"/=",line:t,column:n}):{type:A.SLASH,value:"/",line:t,column:n};case"%":return s==="="?(this.advance(),{type:A.PERCENT_ASSIGN,value:"%=",line:t,column:n}):{type:A.PERCENT,value:"%",line:t,column:n};case"^":return s==="="?(this.advance(),{type:A.CARET_ASSIGN,value:"^=",line:t,column:n}):{type:A.CARET,value:"^",line:t,column:n};case"=":return s==="="?(this.advance(),{type:A.EQ,value:"==",line:t,column:n}):{type:A.ASSIGN,value:"=",line:t,column:n};case"!":return s==="="?(this.advance(),{type:A.NE,value:"!=",line:t,column:n}):s==="~"?(this.advance(),{type:A.NOT_MATCH,value:"!~",line:t,column:n}):{type:A.NOT,value:"!",line:t,column:n};case"<":return s==="="?(this.advance(),{type:A.LE,value:"<=",line:t,column:n}):{type:A.LT,value:"<",line:t,column:n};case">":return s==="="?(this.advance(),{type:A.GE,value:">=",line:t,column:n}):s===">"?(this.advance(),{type:A.APPEND,value:">>",line:t,column:n}):{type:A.GT,value:">",line:t,column:n};case"&":return s==="&"?(this.advance(),{type:A.AND,value:"&&",line:t,column:n}):{type:A.IDENT,value:"&",line:t,column:n};case"|":return s==="|"?(this.advance(),{type:A.OR,value:"||",line:t,column:n}):{type:A.PIPE,value:"|",line:t,column:n};case"~":return{type:A.MATCH,value:"~",line:t,column:n};case"?":return{type:A.QUESTION,value:"?",line:t,column:n};case":":return{type:A.COLON,value:":",line:t,column:n};case",":return{type:A.COMMA,value:",",line:t,column:n};case";":return{type:A.SEMICOLON,value:";",line:t,column:n};case"(":return{type:A.LPAREN,value:"(",line:t,column:n};case")":return{type:A.RPAREN,value:")",line:t,column:n};case"{":return{type:A.LBRACE,value:"{",line:t,column:n};case"}":return{type:A.RBRACE,value:"}",line:t,column:n};case"[":return{type:A.LBRACKET,value:"[",line:t,column:n};case"]":return{type:A.RBRACKET,value:"]",line:t,column:n};case"$":return{type:A.DOLLAR,value:"$",line:t,column:n};default:return{type:A.IDENT,value:r,line:t,column:n}}}isDigit(t){return t>="0"&&t<="9"}isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}isAlphaNumeric(t){return this.isDigit(t)||this.isAlpha(t)}}});function N1(e){e.expect(Z.PRINT);let t=[];if(e.check(Z.NEWLINE)||e.check(Z.SEMICOLON)||e.check(Z.RBRACE)||e.check(Z.PIPE)||e.check(Z.GT)||e.check(Z.APPEND))t.push({type:"field",index:{type:"number",value:0}});else for(t.push(ri(e));e.check(Z.COMMA);)e.advance(),t.push(ri(e));let n;return e.check(Z.GT)?(e.advance(),n={redirect:">",file:e.parsePrimary()}):e.check(Z.APPEND)&&(e.advance(),n={redirect:">>",file:e.parsePrimary()}),{type:"print",args:t,output:n}}function ri(e){return v3(e)?ma(e,!0):ma(e,!1)}function ma(e,t){let n=t?e.parseTernary():I3(e);if(e.match(Z.ASSIGN,Z.PLUS_ASSIGN,Z.MINUS_ASSIGN,Z.STAR_ASSIGN,Z.SLASH_ASSIGN,Z.PERCENT_ASSIGN,Z.CARET_ASSIGN)){let r=e.advance(),s=ma(e,t);if(n.type!=="variable"&&n.type!=="field"&&n.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:new Map([["=","="],["+=","+="],["-=","-="],["*=","*="],["/=","/="],["%=","%="],["^=","^="]]).get(r.value)??"=",target:n,value:s}}return n}function v3(e){let t=0,n=e.pos;for(;n<e.tokens.length;){let r=e.tokens[n];if(r.type===Z.LPAREN&&t++,r.type===Z.RPAREN&&t--,r.type===Z.QUESTION&&t===0)return!0;if(r.type===Z.NEWLINE||r.type===Z.SEMICOLON||r.type===Z.RBRACE||r.type===Z.COMMA||r.type===Z.PIPE)return!1;n++}return!1}function I3(e){let t=E1(e);for(;e.check(Z.OR);){e.advance();let n=E1(e);t={type:"binary",operator:"||",left:t,right:n}}return t}function E1(e){let t=A1(e);for(;e.check(Z.AND);){e.advance();let n=A1(e);t={type:"binary",operator:"&&",left:t,right:n}}return t}function A1(e){let t=R3(e);if(e.check(Z.IN)){e.advance();let n=String(e.expect(Z.IDENT).value);return{type:"in",key:t,array:n}}return t}function R3(e){let t=S1(e);for(;O3(e)&&!$3(e);){let n=S1(e);t={type:"binary",operator:" ",left:t,right:n}}return t}function S1(e){let t=C1(e);for(;e.match(Z.MATCH,Z.NOT_MATCH);){let n=e.advance().type===Z.MATCH?"~":"!~",r=C1(e);t={type:"binary",operator:n,left:t,right:r}}return t}function C1(e){let t=e.parseAddSub();for(;e.match(Z.LT,Z.LE,Z.GE,Z.EQ,Z.NE);){let n=e.advance(),r=e.parseAddSub();t={type:"binary",operator:new Map([["<","<"],["<=","<="],[">=",">="],["==","=="],["!=","!="]]).get(n.value)??"==",left:t,right:r}}return t}function O3(e){return e.match(Z.NUMBER,Z.STRING,Z.IDENT,Z.DOLLAR,Z.LPAREN,Z.NOT,Z.MINUS,Z.PLUS,Z.INCREMENT,Z.DECREMENT)}function $3(e){return e.match(Z.AND,Z.OR,Z.QUESTION,Z.ASSIGN,Z.PLUS_ASSIGN,Z.MINUS_ASSIGN,Z.STAR_ASSIGN,Z.SLASH_ASSIGN,Z.PERCENT_ASSIGN,Z.CARET_ASSIGN,Z.COMMA,Z.SEMICOLON,Z.NEWLINE,Z.RBRACE,Z.RPAREN,Z.RBRACKET,Z.COLON,Z.PIPE,Z.APPEND,Z.GT,Z.IN)}function k1(e){e.expect(Z.PRINTF);let t=e.check(Z.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():ri(e),r=[];for(;e.check(Z.COMMA);)e.advance(),t&&e.skipNewlines(),r.push(t?e.parseExpression():ri(e));t&&(e.skipNewlines(),e.expect(Z.RPAREN));let s;return e.check(Z.GT)?(e.advance(),s={redirect:">",file:e.parsePrimary()}):e.check(Z.APPEND)&&(e.advance(),s={redirect:">>",file:e.parsePrimary()}),{type:"printf",format:n,args:r,output:s}}var Z,v1=I(()=>{"use strict";Z={LPAREN:"LPAREN",RPAREN:"RPAREN",QUESTION:"QUESTION",NEWLINE:"NEWLINE",SEMICOLON:"SEMICOLON",RBRACE:"RBRACE",COMMA:"COMMA",PIPE:"PIPE",GT:"GT",APPEND:"APPEND",AND:"AND",OR:"OR",ASSIGN:"ASSIGN",PLUS_ASSIGN:"PLUS_ASSIGN",MINUS_ASSIGN:"MINUS_ASSIGN",STAR_ASSIGN:"STAR_ASSIGN",SLASH_ASSIGN:"SLASH_ASSIGN",PERCENT_ASSIGN:"PERCENT_ASSIGN",CARET_ASSIGN:"CARET_ASSIGN",RBRACKET:"RBRACKET",COLON:"COLON",IN:"IN",PRINT:"PRINT",PRINTF:"PRINTF",IDENT:"IDENT",LT:"LT",LE:"LE",GE:"GE",EQ:"EQ",NE:"NE",MATCH:"MATCH",NOT_MATCH:"NOT_MATCH",NUMBER:"NUMBER",STRING:"STRING",DOLLAR:"DOLLAR",NOT:"NOT",MINUS:"MINUS",PLUS:"PLUS",INCREMENT:"INCREMENT",DECREMENT:"DECREMENT"}});var si,I1=I(()=>{"use strict";x1();v1();si=class{tokens=[];pos=0;parse(t){let n=new ni(t);return this.tokens=n.tokenize(),this.pos=0,this.parseProgram()}setPos(t){this.pos=t}current(){return this.tokens[this.pos]||{type:A.EOF,value:"",line:0,column:0}}advance(){let t=this.current();return this.pos<this.tokens.length&&this.pos++,t}match(...t){return t.includes(this.current().type)}check(t){return this.current().type===t}expect(t,n){if(!this.check(t)){let r=this.current();throw new Error(n||`Expected ${t}, got ${r.type} at line ${r.line}:${r.column}`)}return this.advance()}skipNewlines(){for(;this.check(A.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(A.NEWLINE)||this.check(A.SEMICOLON);)this.advance()}parseProgram(){let t=[],n=[];for(this.skipNewlines();!this.check(A.EOF)&&(this.skipNewlines(),!this.check(A.EOF));)this.check(A.FUNCTION)?t.push(this.parseFunction()):n.push(this.parseRule()),this.skipTerminators();return{functions:t,rules:n}}parseFunction(){this.expect(A.FUNCTION);let t=this.expect(A.IDENT).value;this.expect(A.LPAREN);let n=[];if(!this.check(A.RPAREN))for(n.push(this.expect(A.IDENT).value);this.check(A.COMMA);)this.advance(),n.push(this.expect(A.IDENT).value);this.expect(A.RPAREN),this.skipNewlines();let r=this.parseBlock();return{name:t,params:n,body:r}}parseRule(){let t;if(this.check(A.BEGIN))this.advance(),t={type:"begin"};else if(this.check(A.END))this.advance(),t={type:"end"};else if(this.check(A.LBRACE))t=void 0;else if(this.check(A.REGEX)){let r=this.advance();if(this.check(A.AND)||this.check(A.OR)){let s={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:r.value}};t={type:"expr_pattern",expression:this.parseLogicalOrRest(s)}}else{let s={type:"regex_pattern",pattern:r.value};if(this.check(A.COMMA)){this.advance();let i;this.check(A.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:s,end:i}}else t=s}}else{let s={type:"expr_pattern",expression:this.parseExpression()};if(this.check(A.COMMA)){this.advance();let i;this.check(A.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:s,end:i}}else t=s}this.skipNewlines();let n;return this.check(A.LBRACE)?n=this.parseBlock():n={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:t,action:n}}parseBlock(){this.expect(A.LBRACE),this.skipNewlines();let t=[];for(;!this.check(A.RBRACE)&&!this.check(A.EOF);)t.push(this.parseStatement()),this.skipTerminators();return this.expect(A.RBRACE),{type:"block",statements:t}}parseStatement(){if(this.check(A.SEMICOLON)||this.check(A.NEWLINE))return this.advance(),{type:"block",statements:[]};if(this.check(A.LBRACE))return this.parseBlock();if(this.check(A.IF))return this.parseIf();if(this.check(A.WHILE))return this.parseWhile();if(this.check(A.DO))return this.parseDoWhile();if(this.check(A.FOR))return this.parseFor();if(this.check(A.BREAK))return this.advance(),{type:"break"};if(this.check(A.CONTINUE))return this.advance(),{type:"continue"};if(this.check(A.NEXT))return this.advance(),{type:"next"};if(this.check(A.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(A.EXIT)){this.advance();let n;return!this.check(A.NEWLINE)&&!this.check(A.SEMICOLON)&&!this.check(A.RBRACE)&&!this.check(A.EOF)&&(n=this.parseExpression()),{type:"exit",code:n}}if(this.check(A.RETURN)){this.advance();let n;return!this.check(A.NEWLINE)&&!this.check(A.SEMICOLON)&&!this.check(A.RBRACE)&&!this.check(A.EOF)&&(n=this.parseExpression()),{type:"return",value:n}}if(this.check(A.DELETE)){this.advance();let n=this.parsePrimary();if(n.type!=="array_access"&&n.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:n}}return this.check(A.PRINT)?N1(this):this.check(A.PRINTF)?k1(this):{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(A.IF),this.expect(A.LPAREN);let t=this.parseExpression();this.expect(A.RPAREN),this.skipNewlines();let n=this.parseStatement();this.skipTerminators();let r;return this.check(A.ELSE)&&(this.advance(),this.skipNewlines(),r=this.parseStatement()),{type:"if",condition:t,consequent:n,alternate:r}}parseWhile(){this.expect(A.WHILE),this.expect(A.LPAREN);let t=this.parseExpression();this.expect(A.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:"while",condition:t,body:n}}parseDoWhile(){this.expect(A.DO),this.skipNewlines();let t=this.parseStatement();this.skipNewlines(),this.expect(A.WHILE),this.expect(A.LPAREN);let n=this.parseExpression();return this.expect(A.RPAREN),{type:"do_while",body:t,condition:n}}parseFor(){if(this.expect(A.FOR),this.expect(A.LPAREN),this.check(A.IDENT)){let i=this.advance();if(this.check(A.IN)){this.advance();let o=this.expect(A.IDENT).value;this.expect(A.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for_in",variable:i.value,array:o,body:a}}this.pos--}let t;this.check(A.SEMICOLON)||(t=this.parseExpression()),this.expect(A.SEMICOLON);let n;this.check(A.SEMICOLON)||(n=this.parseExpression()),this.expect(A.SEMICOLON);let r;this.check(A.RPAREN)||(r=this.parseExpression()),this.expect(A.RPAREN),this.skipNewlines();let s=this.parseStatement();return{type:"for",init:t,condition:n,update:r,body:s}}parseExpression(){return this.parseAssignment()}parseAssignment(){let t=this.parseTernary();if(this.match(A.ASSIGN,A.PLUS_ASSIGN,A.MINUS_ASSIGN,A.STAR_ASSIGN,A.SLASH_ASSIGN,A.PERCENT_ASSIGN,A.CARET_ASSIGN)){let n=this.advance(),r=this.parseAssignment();if(t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[n.value],target:t,value:r}}return t}parseTernary(){let t=this.parsePipeGetline();if(this.check(A.QUESTION)){this.advance();let n=this.parseExpression();this.expect(A.COLON);let r=this.parseExpression();t={type:"ternary",condition:t,consequent:n,alternate:r}}return t}parsePipeGetline(){let t=this.parseOr();if(this.check(A.PIPE)){if(this.advance(),!this.check(A.GETLINE))throw new Error("Expected 'getline' after '|' in expression context");this.advance();let n;return this.check(A.IDENT)&&(n=this.advance().value),{type:"getline",command:t,variable:n}}return t}parseOr(){let t=this.parseAnd();for(;this.check(A.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalOrRest(t){for(t=this.parseLogicalAndRest(t);this.check(A.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalAndRest(t){for(;this.check(A.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseAnd(){let t=this.parseIn();for(;this.check(A.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseIn(){let t=this.parseConcatenation();if(this.check(A.IN)){this.advance();let n=this.expect(A.IDENT).value;return{type:"in",key:t,array:n}}return t}parseConcatenation(){let t=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let n=this.parseMatch();t={type:"binary",operator:" ",left:t,right:n}}return t}parseMatch(){let t=this.parseComparison();for(;this.match(A.MATCH,A.NOT_MATCH);){let n=this.advance().type===A.MATCH?"~":"!~",r=this.parseComparison();t={type:"binary",operator:n,left:t,right:r}}return t}parseComparison(){let t=this.parseAddSub();for(;this.match(A.LT,A.LE,A.GT,A.GE,A.EQ,A.NE);){let n=this.advance(),r=this.parseAddSub();t={type:"binary",operator:new Map([["<","<"],["<=","<="],[">",">"],[">=",">="],["==","=="],["!=","!="]]).get(n.value)??"==",left:t,right:r}}return t}canStartExpression(){return this.match(A.NUMBER,A.STRING,A.IDENT,A.DOLLAR,A.LPAREN,A.NOT,A.MINUS,A.PLUS,A.INCREMENT,A.DECREMENT)}isConcatTerminator(){return this.match(A.AND,A.OR,A.QUESTION,A.ASSIGN,A.PLUS_ASSIGN,A.MINUS_ASSIGN,A.STAR_ASSIGN,A.SLASH_ASSIGN,A.PERCENT_ASSIGN,A.CARET_ASSIGN,A.COMMA,A.SEMICOLON,A.NEWLINE,A.RBRACE,A.RPAREN,A.RBRACKET,A.COLON,A.PIPE,A.APPEND,A.IN)}parseAddSub(){let t=this.parseMulDiv();for(;this.match(A.PLUS,A.MINUS);){let n=this.advance().value,r=this.parseMulDiv();t={type:"binary",operator:n,left:t,right:r}}return t}parseMulDiv(){let t=this.parseUnary();for(;this.match(A.STAR,A.SLASH,A.PERCENT);){let n=this.advance(),r=this.parseUnary();t={type:"binary",operator:new Map([["*","*"],["/","/"],["%","%"]]).get(n.value)??"*",left:t,right:r}}return t}parseUnary(){if(this.check(A.INCREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(A.DECREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(A.NOT,A.MINUS,A.PLUS)){let t=this.advance().value,n=this.parseUnary();return{type:"unary",operator:t,operand:n}}return this.parsePower()}parsePower(){let t=this.parsePostfix();if(this.check(A.CARET)){this.advance();let n=this.parsePower();t={type:"binary",operator:"^",left:t,right:n}}return t}parsePostfix(){let t=this.parsePrimary();if(this.check(A.INCREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:t}}if(this.check(A.DECREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:t}}return t}parseFieldIndex(){if(this.check(A.INCREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(A.DECREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(A.NOT,A.MINUS,A.PLUS)){let t=this.advance().value,n=this.parseFieldIndex();return{type:"unary",operator:t,operand:n}}return this.parseFieldIndexPower()}parseFieldIndexPower(){let t=this.parseFieldIndexPrimary();if(this.check(A.CARET)){this.advance();let n=this.parseFieldIndexPower();t={type:"binary",operator:"^",left:t,right:n}}return t}parseFieldIndexPrimary(){if(this.check(A.NUMBER))return{type:"number",value:this.advance().value};if(this.check(A.STRING))return{type:"string",value:this.advance().value};if(this.check(A.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(A.LPAREN)){this.advance();let t=this.parseExpression();return this.expect(A.RPAREN),t}if(this.check(A.IDENT)){let t=this.advance().value;if(this.check(A.LPAREN)){this.advance();let n=[];if(!this.check(A.RPAREN))for(n.push(this.parseExpression());this.check(A.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(A.RPAREN),{type:"call",name:t,args:n}}if(this.check(A.LBRACKET)){this.advance();let n=this.parseExpression();if(this.check(A.COMMA)){let r=[n];for(;this.check(A.COMMA);)this.advance(),r.push(this.parseExpression());this.expect(A.RBRACKET);let s=r.reduce((i,o)=>({type:"binary",operator:" ",left:{type:"binary",operator:" ",left:i,right:{type:"variable",name:"SUBSEP"}},right:o}));return{type:"array_access",array:t,key:s}}return this.expect(A.RBRACKET),{type:"array_access",array:t,key:n}}return{type:"variable",name:t}}throw new Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(A.NUMBER))return{type:"number",value:this.advance().value};if(this.check(A.STRING))return{type:"string",value:this.advance().value};if(this.check(A.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(A.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(A.LPAREN)){this.advance();let t=this.parseExpression();if(this.check(A.COMMA)){let n=[t];for(;this.check(A.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(A.RPAREN),{type:"tuple",elements:n}}return this.expect(A.RPAREN),t}if(this.check(A.GETLINE)){this.advance();let t,n;return this.check(A.IDENT)&&(t=this.advance().value),this.check(A.LT)&&(this.advance(),n=this.parsePrimary()),{type:"getline",variable:t,file:n}}if(this.check(A.IDENT)){let t=this.advance().value;if(this.check(A.LPAREN)){this.advance();let n=[];if(this.skipNewlines(),!this.check(A.RPAREN))for(n.push(this.parseExpression());this.check(A.COMMA);)this.advance(),this.skipNewlines(),n.push(this.parseExpression());return this.skipNewlines(),this.expect(A.RPAREN),{type:"call",name:t,args:n}}if(this.check(A.LBRACKET)){this.advance();let n=[this.parseExpression()];for(;this.check(A.COMMA);)this.advance(),n.push(this.parseExpression());this.expect(A.RBRACKET);let r;if(n.length===1)r=n[0];else{r=n[0];for(let s=1;s<n.length;s++)r={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:r,right:{type:"variable",name:"SUBSEP"}},right:n[s]}}return{type:"array_access",array:t,key:r}}return{type:"variable",name:t}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}}});var $1={};Q($1,{awkCommand2:()=>P3});function ga(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
339
- `).replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\a/g,"\x07").replace(/\\v/g,"\v").replace(/\\\\/g,"\\")}function R1(e){if(e===" ")return V("\\s+");if(/[[\](){}.*+?^$|\\]/.test(e))try{return V(e)}catch{return V(O1(e))}return V(O1(e))}function O1(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var T3,P3,T1=I(()=>{"use strict";vn();xe();Me();ne();b1();I1();T3={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"]},P3={name:"awk",async execute(e,t){if(U(e))return F(T3);let n=new bn(/\s+/),r=" ",s=Object.create(null),i=0;for(let d=0;d<e.length;d++){let g=e[d];if(g==="-F"&&d+1<e.length)r=ga(e[++d]),n=R1(r),i=d+1;else if(g.startsWith("-F"))r=ga(g.slice(2)),n=R1(r),i=d+1;else if(g==="-v"&&d+1<e.length){let y=e[++d],w=y.indexOf("=");if(w>0){let b=y.slice(0,w),x=ga(y.slice(w+1));s[b]=x}i=d+1}else{if(g.startsWith("--"))return X("awk",g);if(g.startsWith("-")&&g.length>1){let y=g[1];if(y!=="F"&&y!=="v")return X("awk",`-${y}`);i=d+1}else if(!g.startsWith("-")){i=d;break}}}if(i>=e.length)return{stdout:"",stderr:`awk: missing program
338
+ `)break;r+=this.advance()}return this.peek()==="/"&&this.advance(),r=k3(r),{type:A.REGEX,value:r,line:t,column:n}}readNumber(){let t=this.line,n=this.column,r="";for(;this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="."&&this.isDigit(this.peek(1)))for(r+=this.advance();this.isDigit(this.peek());)r+=this.advance();if(this.peek()==="e"||this.peek()==="E")for(r+=this.advance(),(this.peek()==="+"||this.peek()==="-")&&(r+=this.advance());this.isDigit(this.peek());)r+=this.advance();return{type:A.NUMBER,value:parseFloat(r),line:t,column:n}}readIdentifier(){let t=this.line,n=this.column,r="";for(;this.isAlphaNumeric(this.peek())||this.peek()==="_";)r+=this.advance();let s=N3.get(r);return s!==void 0?{type:s,value:r,line:t,column:n}:{type:A.IDENT,value:r,line:t,column:n}}readOperator(){let t=this.line,n=this.column,r=this.advance(),s=this.peek();switch(r){case"+":return s==="+"?(this.advance(),{type:A.INCREMENT,value:"++",line:t,column:n}):s==="="?(this.advance(),{type:A.PLUS_ASSIGN,value:"+=",line:t,column:n}):{type:A.PLUS,value:"+",line:t,column:n};case"-":return s==="-"?(this.advance(),{type:A.DECREMENT,value:"--",line:t,column:n}):s==="="?(this.advance(),{type:A.MINUS_ASSIGN,value:"-=",line:t,column:n}):{type:A.MINUS,value:"-",line:t,column:n};case"*":return s==="*"?(this.advance(),{type:A.CARET,value:"**",line:t,column:n}):s==="="?(this.advance(),{type:A.STAR_ASSIGN,value:"*=",line:t,column:n}):{type:A.STAR,value:"*",line:t,column:n};case"/":return s==="="?(this.advance(),{type:A.SLASH_ASSIGN,value:"/=",line:t,column:n}):{type:A.SLASH,value:"/",line:t,column:n};case"%":return s==="="?(this.advance(),{type:A.PERCENT_ASSIGN,value:"%=",line:t,column:n}):{type:A.PERCENT,value:"%",line:t,column:n};case"^":return s==="="?(this.advance(),{type:A.CARET_ASSIGN,value:"^=",line:t,column:n}):{type:A.CARET,value:"^",line:t,column:n};case"=":return s==="="?(this.advance(),{type:A.EQ,value:"==",line:t,column:n}):{type:A.ASSIGN,value:"=",line:t,column:n};case"!":return s==="="?(this.advance(),{type:A.NE,value:"!=",line:t,column:n}):s==="~"?(this.advance(),{type:A.NOT_MATCH,value:"!~",line:t,column:n}):{type:A.NOT,value:"!",line:t,column:n};case"<":return s==="="?(this.advance(),{type:A.LE,value:"<=",line:t,column:n}):{type:A.LT,value:"<",line:t,column:n};case">":return s==="="?(this.advance(),{type:A.GE,value:">=",line:t,column:n}):s===">"?(this.advance(),{type:A.APPEND,value:">>",line:t,column:n}):{type:A.GT,value:">",line:t,column:n};case"&":return s==="&"?(this.advance(),{type:A.AND,value:"&&",line:t,column:n}):{type:A.IDENT,value:"&",line:t,column:n};case"|":return s==="|"?(this.advance(),{type:A.OR,value:"||",line:t,column:n}):{type:A.PIPE,value:"|",line:t,column:n};case"~":return{type:A.MATCH,value:"~",line:t,column:n};case"?":return{type:A.QUESTION,value:"?",line:t,column:n};case":":return{type:A.COLON,value:":",line:t,column:n};case",":return{type:A.COMMA,value:",",line:t,column:n};case";":return{type:A.SEMICOLON,value:";",line:t,column:n};case"(":return{type:A.LPAREN,value:"(",line:t,column:n};case")":return{type:A.RPAREN,value:")",line:t,column:n};case"{":return{type:A.LBRACE,value:"{",line:t,column:n};case"}":return{type:A.RBRACE,value:"}",line:t,column:n};case"[":return{type:A.LBRACKET,value:"[",line:t,column:n};case"]":return{type:A.RBRACKET,value:"]",line:t,column:n};case"$":return{type:A.DOLLAR,value:"$",line:t,column:n};default:return{type:A.IDENT,value:r,line:t,column:n}}}isDigit(t){return t>="0"&&t<="9"}isAlpha(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}isAlphaNumeric(t){return this.isDigit(t)||this.isAlpha(t)}}});function N1(e){e.expect(Z.PRINT);let t=[];if(e.check(Z.NEWLINE)||e.check(Z.SEMICOLON)||e.check(Z.RBRACE)||e.check(Z.PIPE)||e.check(Z.GT)||e.check(Z.APPEND))t.push({type:"field",index:{type:"number",value:0}});else for(t.push(ri(e));e.check(Z.COMMA);)e.advance(),t.push(ri(e));let n;return e.check(Z.GT)?(e.advance(),n={redirect:">",file:e.parsePrimary()}):e.check(Z.APPEND)&&(e.advance(),n={redirect:">>",file:e.parsePrimary()}),{type:"print",args:t,output:n}}function ri(e){return v3(e)?ma(e,!0):ma(e,!1)}function ma(e,t){let n=t?e.parseTernary():I3(e);if(e.match(Z.ASSIGN,Z.PLUS_ASSIGN,Z.MINUS_ASSIGN,Z.STAR_ASSIGN,Z.SLASH_ASSIGN,Z.PERCENT_ASSIGN,Z.CARET_ASSIGN)){let r=e.advance(),s=ma(e,t);if(n.type!=="variable"&&n.type!=="field"&&n.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:new Map([["=","="],["+=","+="],["-=","-="],["*=","*="],["/=","/="],["%=","%="],["^=","^="]]).get(r.value)??"=",target:n,value:s}}return n}function v3(e){let t=0,n=e.pos;for(;n<e.tokens.length;){let r=e.tokens[n];if(r.type===Z.LPAREN&&t++,r.type===Z.RPAREN&&t--,r.type===Z.QUESTION&&t===0)return!0;if(r.type===Z.NEWLINE||r.type===Z.SEMICOLON||r.type===Z.RBRACE||r.type===Z.COMMA||r.type===Z.PIPE)return!1;n++}return!1}function I3(e){let t=E1(e);for(;e.check(Z.OR);){e.advance();let n=E1(e);t={type:"binary",operator:"||",left:t,right:n}}return t}function E1(e){let t=A1(e);for(;e.check(Z.AND);){e.advance();let n=A1(e);t={type:"binary",operator:"&&",left:t,right:n}}return t}function A1(e){let t=O3(e);if(e.check(Z.IN)){e.advance();let n=String(e.expect(Z.IDENT).value);return{type:"in",key:t,array:n}}return t}function O3(e){let t=S1(e);for(;R3(e)&&!$3(e);){let n=S1(e);t={type:"binary",operator:" ",left:t,right:n}}return t}function S1(e){let t=C1(e);for(;e.match(Z.MATCH,Z.NOT_MATCH);){let n=e.advance().type===Z.MATCH?"~":"!~",r=C1(e);t={type:"binary",operator:n,left:t,right:r}}return t}function C1(e){let t=e.parseAddSub();for(;e.match(Z.LT,Z.LE,Z.GE,Z.EQ,Z.NE);){let n=e.advance(),r=e.parseAddSub();t={type:"binary",operator:new Map([["<","<"],["<=","<="],[">=",">="],["==","=="],["!=","!="]]).get(n.value)??"==",left:t,right:r}}return t}function R3(e){return e.match(Z.NUMBER,Z.STRING,Z.IDENT,Z.DOLLAR,Z.LPAREN,Z.NOT,Z.MINUS,Z.PLUS,Z.INCREMENT,Z.DECREMENT)}function $3(e){return e.match(Z.AND,Z.OR,Z.QUESTION,Z.ASSIGN,Z.PLUS_ASSIGN,Z.MINUS_ASSIGN,Z.STAR_ASSIGN,Z.SLASH_ASSIGN,Z.PERCENT_ASSIGN,Z.CARET_ASSIGN,Z.COMMA,Z.SEMICOLON,Z.NEWLINE,Z.RBRACE,Z.RPAREN,Z.RBRACKET,Z.COLON,Z.PIPE,Z.APPEND,Z.GT,Z.IN)}function k1(e){e.expect(Z.PRINTF);let t=e.check(Z.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():ri(e),r=[];for(;e.check(Z.COMMA);)e.advance(),t&&e.skipNewlines(),r.push(t?e.parseExpression():ri(e));t&&(e.skipNewlines(),e.expect(Z.RPAREN));let s;return e.check(Z.GT)?(e.advance(),s={redirect:">",file:e.parsePrimary()}):e.check(Z.APPEND)&&(e.advance(),s={redirect:">>",file:e.parsePrimary()}),{type:"printf",format:n,args:r,output:s}}var Z,v1=I(()=>{"use strict";Z={LPAREN:"LPAREN",RPAREN:"RPAREN",QUESTION:"QUESTION",NEWLINE:"NEWLINE",SEMICOLON:"SEMICOLON",RBRACE:"RBRACE",COMMA:"COMMA",PIPE:"PIPE",GT:"GT",APPEND:"APPEND",AND:"AND",OR:"OR",ASSIGN:"ASSIGN",PLUS_ASSIGN:"PLUS_ASSIGN",MINUS_ASSIGN:"MINUS_ASSIGN",STAR_ASSIGN:"STAR_ASSIGN",SLASH_ASSIGN:"SLASH_ASSIGN",PERCENT_ASSIGN:"PERCENT_ASSIGN",CARET_ASSIGN:"CARET_ASSIGN",RBRACKET:"RBRACKET",COLON:"COLON",IN:"IN",PRINT:"PRINT",PRINTF:"PRINTF",IDENT:"IDENT",LT:"LT",LE:"LE",GE:"GE",EQ:"EQ",NE:"NE",MATCH:"MATCH",NOT_MATCH:"NOT_MATCH",NUMBER:"NUMBER",STRING:"STRING",DOLLAR:"DOLLAR",NOT:"NOT",MINUS:"MINUS",PLUS:"PLUS",INCREMENT:"INCREMENT",DECREMENT:"DECREMENT"}});var si,I1=I(()=>{"use strict";x1();v1();si=class{tokens=[];pos=0;parse(t){let n=new ni(t);return this.tokens=n.tokenize(),this.pos=0,this.parseProgram()}setPos(t){this.pos=t}current(){return this.tokens[this.pos]||{type:A.EOF,value:"",line:0,column:0}}advance(){let t=this.current();return this.pos<this.tokens.length&&this.pos++,t}match(...t){return t.includes(this.current().type)}check(t){return this.current().type===t}expect(t,n){if(!this.check(t)){let r=this.current();throw new Error(n||`Expected ${t}, got ${r.type} at line ${r.line}:${r.column}`)}return this.advance()}skipNewlines(){for(;this.check(A.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(A.NEWLINE)||this.check(A.SEMICOLON);)this.advance()}parseProgram(){let t=[],n=[];for(this.skipNewlines();!this.check(A.EOF)&&(this.skipNewlines(),!this.check(A.EOF));)this.check(A.FUNCTION)?t.push(this.parseFunction()):n.push(this.parseRule()),this.skipTerminators();return{functions:t,rules:n}}parseFunction(){this.expect(A.FUNCTION);let t=this.expect(A.IDENT).value;this.expect(A.LPAREN);let n=[];if(!this.check(A.RPAREN))for(n.push(this.expect(A.IDENT).value);this.check(A.COMMA);)this.advance(),n.push(this.expect(A.IDENT).value);this.expect(A.RPAREN),this.skipNewlines();let r=this.parseBlock();return{name:t,params:n,body:r}}parseRule(){let t;if(this.check(A.BEGIN))this.advance(),t={type:"begin"};else if(this.check(A.END))this.advance(),t={type:"end"};else if(this.check(A.LBRACE))t=void 0;else if(this.check(A.REGEX)){let r=this.advance();if(this.check(A.AND)||this.check(A.OR)){let s={type:"binary",operator:"~",left:{type:"field",index:{type:"number",value:0}},right:{type:"regex",pattern:r.value}};t={type:"expr_pattern",expression:this.parseLogicalOrRest(s)}}else{let s={type:"regex_pattern",pattern:r.value};if(this.check(A.COMMA)){this.advance();let i;this.check(A.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:s,end:i}}else t=s}}else{let s={type:"expr_pattern",expression:this.parseExpression()};if(this.check(A.COMMA)){this.advance();let i;this.check(A.REGEX)?i={type:"regex_pattern",pattern:this.advance().value}:i={type:"expr_pattern",expression:this.parseExpression()},t={type:"range",start:s,end:i}}else t=s}this.skipNewlines();let n;return this.check(A.LBRACE)?n=this.parseBlock():n={type:"block",statements:[{type:"print",args:[{type:"field",index:{type:"number",value:0}}]}]},{pattern:t,action:n}}parseBlock(){this.expect(A.LBRACE),this.skipNewlines();let t=[];for(;!this.check(A.RBRACE)&&!this.check(A.EOF);)t.push(this.parseStatement()),this.skipTerminators();return this.expect(A.RBRACE),{type:"block",statements:t}}parseStatement(){if(this.check(A.SEMICOLON)||this.check(A.NEWLINE))return this.advance(),{type:"block",statements:[]};if(this.check(A.LBRACE))return this.parseBlock();if(this.check(A.IF))return this.parseIf();if(this.check(A.WHILE))return this.parseWhile();if(this.check(A.DO))return this.parseDoWhile();if(this.check(A.FOR))return this.parseFor();if(this.check(A.BREAK))return this.advance(),{type:"break"};if(this.check(A.CONTINUE))return this.advance(),{type:"continue"};if(this.check(A.NEXT))return this.advance(),{type:"next"};if(this.check(A.NEXTFILE))return this.advance(),{type:"nextfile"};if(this.check(A.EXIT)){this.advance();let n;return!this.check(A.NEWLINE)&&!this.check(A.SEMICOLON)&&!this.check(A.RBRACE)&&!this.check(A.EOF)&&(n=this.parseExpression()),{type:"exit",code:n}}if(this.check(A.RETURN)){this.advance();let n;return!this.check(A.NEWLINE)&&!this.check(A.SEMICOLON)&&!this.check(A.RBRACE)&&!this.check(A.EOF)&&(n=this.parseExpression()),{type:"return",value:n}}if(this.check(A.DELETE)){this.advance();let n=this.parsePrimary();if(n.type!=="array_access"&&n.type!=="variable")throw new Error("delete requires array element or array");return{type:"delete",target:n}}return this.check(A.PRINT)?N1(this):this.check(A.PRINTF)?k1(this):{type:"expr_stmt",expression:this.parseExpression()}}parseIf(){this.expect(A.IF),this.expect(A.LPAREN);let t=this.parseExpression();this.expect(A.RPAREN),this.skipNewlines();let n=this.parseStatement();this.skipTerminators();let r;return this.check(A.ELSE)&&(this.advance(),this.skipNewlines(),r=this.parseStatement()),{type:"if",condition:t,consequent:n,alternate:r}}parseWhile(){this.expect(A.WHILE),this.expect(A.LPAREN);let t=this.parseExpression();this.expect(A.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:"while",condition:t,body:n}}parseDoWhile(){this.expect(A.DO),this.skipNewlines();let t=this.parseStatement();this.skipNewlines(),this.expect(A.WHILE),this.expect(A.LPAREN);let n=this.parseExpression();return this.expect(A.RPAREN),{type:"do_while",body:t,condition:n}}parseFor(){if(this.expect(A.FOR),this.expect(A.LPAREN),this.check(A.IDENT)){let i=this.advance();if(this.check(A.IN)){this.advance();let o=this.expect(A.IDENT).value;this.expect(A.RPAREN),this.skipNewlines();let a=this.parseStatement();return{type:"for_in",variable:i.value,array:o,body:a}}this.pos--}let t;this.check(A.SEMICOLON)||(t=this.parseExpression()),this.expect(A.SEMICOLON);let n;this.check(A.SEMICOLON)||(n=this.parseExpression()),this.expect(A.SEMICOLON);let r;this.check(A.RPAREN)||(r=this.parseExpression()),this.expect(A.RPAREN),this.skipNewlines();let s=this.parseStatement();return{type:"for",init:t,condition:n,update:r,body:s}}parseExpression(){return this.parseAssignment()}parseAssignment(){let t=this.parseTernary();if(this.match(A.ASSIGN,A.PLUS_ASSIGN,A.MINUS_ASSIGN,A.STAR_ASSIGN,A.SLASH_ASSIGN,A.PERCENT_ASSIGN,A.CARET_ASSIGN)){let n=this.advance(),r=this.parseAssignment();if(t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid assignment target");return{type:"assignment",operator:{"=":"=","+=":"+=","-=":"-=","*=":"*=","/=":"/=","%=":"%=","^=":"^="}[n.value],target:t,value:r}}return t}parseTernary(){let t=this.parsePipeGetline();if(this.check(A.QUESTION)){this.advance();let n=this.parseExpression();this.expect(A.COLON);let r=this.parseExpression();t={type:"ternary",condition:t,consequent:n,alternate:r}}return t}parsePipeGetline(){let t=this.parseOr();if(this.check(A.PIPE)){if(this.advance(),!this.check(A.GETLINE))throw new Error("Expected 'getline' after '|' in expression context");this.advance();let n;return this.check(A.IDENT)&&(n=this.advance().value),{type:"getline",command:t,variable:n}}return t}parseOr(){let t=this.parseAnd();for(;this.check(A.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalOrRest(t){for(t=this.parseLogicalAndRest(t);this.check(A.OR);){this.advance();let n=this.parseAnd();t={type:"binary",operator:"||",left:t,right:n}}return t}parseLogicalAndRest(t){for(;this.check(A.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseAnd(){let t=this.parseIn();for(;this.check(A.AND);){this.advance();let n=this.parseIn();t={type:"binary",operator:"&&",left:t,right:n}}return t}parseIn(){let t=this.parseConcatenation();if(this.check(A.IN)){this.advance();let n=this.expect(A.IDENT).value;return{type:"in",key:t,array:n}}return t}parseConcatenation(){let t=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let n=this.parseMatch();t={type:"binary",operator:" ",left:t,right:n}}return t}parseMatch(){let t=this.parseComparison();for(;this.match(A.MATCH,A.NOT_MATCH);){let n=this.advance().type===A.MATCH?"~":"!~",r=this.parseComparison();t={type:"binary",operator:n,left:t,right:r}}return t}parseComparison(){let t=this.parseAddSub();for(;this.match(A.LT,A.LE,A.GT,A.GE,A.EQ,A.NE);){let n=this.advance(),r=this.parseAddSub();t={type:"binary",operator:new Map([["<","<"],["<=","<="],[">",">"],[">=",">="],["==","=="],["!=","!="]]).get(n.value)??"==",left:t,right:r}}return t}canStartExpression(){return this.match(A.NUMBER,A.STRING,A.IDENT,A.DOLLAR,A.LPAREN,A.NOT,A.MINUS,A.PLUS,A.INCREMENT,A.DECREMENT)}isConcatTerminator(){return this.match(A.AND,A.OR,A.QUESTION,A.ASSIGN,A.PLUS_ASSIGN,A.MINUS_ASSIGN,A.STAR_ASSIGN,A.SLASH_ASSIGN,A.PERCENT_ASSIGN,A.CARET_ASSIGN,A.COMMA,A.SEMICOLON,A.NEWLINE,A.RBRACE,A.RPAREN,A.RBRACKET,A.COLON,A.PIPE,A.APPEND,A.IN)}parseAddSub(){let t=this.parseMulDiv();for(;this.match(A.PLUS,A.MINUS);){let n=this.advance().value,r=this.parseMulDiv();t={type:"binary",operator:n,left:t,right:r}}return t}parseMulDiv(){let t=this.parseUnary();for(;this.match(A.STAR,A.SLASH,A.PERCENT);){let n=this.advance(),r=this.parseUnary();t={type:"binary",operator:new Map([["*","*"],["/","/"],["%","%"]]).get(n.value)??"*",left:t,right:r}}return t}parseUnary(){if(this.check(A.INCREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(A.DECREMENT)){this.advance();let t=this.parseUnary();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(A.NOT,A.MINUS,A.PLUS)){let t=this.advance().value,n=this.parseUnary();return{type:"unary",operator:t,operand:n}}return this.parsePower()}parsePower(){let t=this.parsePostfix();if(this.check(A.CARET)){this.advance();let n=this.parsePower();t={type:"binary",operator:"^",left:t,right:n}}return t}parsePostfix(){let t=this.parsePrimary();if(this.check(A.INCREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid increment operand");return{type:"post_increment",operand:t}}if(this.check(A.DECREMENT)){if(this.advance(),t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access")throw new Error("Invalid decrement operand");return{type:"post_decrement",operand:t}}return t}parseFieldIndex(){if(this.check(A.INCREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"+",operand:{type:"unary",operator:"+",operand:t}}:{type:"pre_increment",operand:t}}if(this.check(A.DECREMENT)){this.advance();let t=this.parseFieldIndex();return t.type!=="variable"&&t.type!=="field"&&t.type!=="array_access"?{type:"unary",operator:"-",operand:{type:"unary",operator:"-",operand:t}}:{type:"pre_decrement",operand:t}}if(this.match(A.NOT,A.MINUS,A.PLUS)){let t=this.advance().value,n=this.parseFieldIndex();return{type:"unary",operator:t,operand:n}}return this.parseFieldIndexPower()}parseFieldIndexPower(){let t=this.parseFieldIndexPrimary();if(this.check(A.CARET)){this.advance();let n=this.parseFieldIndexPower();t={type:"binary",operator:"^",left:t,right:n}}return t}parseFieldIndexPrimary(){if(this.check(A.NUMBER))return{type:"number",value:this.advance().value};if(this.check(A.STRING))return{type:"string",value:this.advance().value};if(this.check(A.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(A.LPAREN)){this.advance();let t=this.parseExpression();return this.expect(A.RPAREN),t}if(this.check(A.IDENT)){let t=this.advance().value;if(this.check(A.LPAREN)){this.advance();let n=[];if(!this.check(A.RPAREN))for(n.push(this.parseExpression());this.check(A.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(A.RPAREN),{type:"call",name:t,args:n}}if(this.check(A.LBRACKET)){this.advance();let n=this.parseExpression();if(this.check(A.COMMA)){let r=[n];for(;this.check(A.COMMA);)this.advance(),r.push(this.parseExpression());this.expect(A.RBRACKET);let s=r.reduce((i,o)=>({type:"binary",operator:" ",left:{type:"binary",operator:" ",left:i,right:{type:"variable",name:"SUBSEP"}},right:o}));return{type:"array_access",array:t,key:s}}return this.expect(A.RBRACKET),{type:"array_access",array:t,key:n}}return{type:"variable",name:t}}throw new Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(A.NUMBER))return{type:"number",value:this.advance().value};if(this.check(A.STRING))return{type:"string",value:this.advance().value};if(this.check(A.REGEX))return{type:"regex",pattern:this.advance().value};if(this.check(A.DOLLAR))return this.advance(),{type:"field",index:this.parseFieldIndex()};if(this.check(A.LPAREN)){this.advance();let t=this.parseExpression();if(this.check(A.COMMA)){let n=[t];for(;this.check(A.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(A.RPAREN),{type:"tuple",elements:n}}return this.expect(A.RPAREN),t}if(this.check(A.GETLINE)){this.advance();let t,n;return this.check(A.IDENT)&&(t=this.advance().value),this.check(A.LT)&&(this.advance(),n=this.parsePrimary()),{type:"getline",variable:t,file:n}}if(this.check(A.IDENT)){let t=this.advance().value;if(this.check(A.LPAREN)){this.advance();let n=[];if(this.skipNewlines(),!this.check(A.RPAREN))for(n.push(this.parseExpression());this.check(A.COMMA);)this.advance(),this.skipNewlines(),n.push(this.parseExpression());return this.skipNewlines(),this.expect(A.RPAREN),{type:"call",name:t,args:n}}if(this.check(A.LBRACKET)){this.advance();let n=[this.parseExpression()];for(;this.check(A.COMMA);)this.advance(),n.push(this.parseExpression());this.expect(A.RBRACKET);let r;if(n.length===1)r=n[0];else{r=n[0];for(let s=1;s<n.length;s++)r={type:"binary",operator:" ",left:{type:"binary",operator:" ",left:r,right:{type:"variable",name:"SUBSEP"}},right:n[s]}}return{type:"array_access",array:t,key:r}}return{type:"variable",name:t}}throw new Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}}});var $1={};Q($1,{awkCommand2:()=>P3});function ga(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
339
+ `).replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\a/g,"\x07").replace(/\\v/g,"\v").replace(/\\\\/g,"\\")}function O1(e){if(e===" ")return V("\\s+");if(/[[\](){}.*+?^$|\\]/.test(e))try{return V(e)}catch{return V(R1(e))}return V(R1(e))}function R1(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var T3,P3,T1=I(()=>{"use strict";vn();xe();Me();ne();b1();I1();T3={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"]},P3={name:"awk",async execute(e,t){if(F(e))return M(T3);let n=new bn(/\s+/),r=" ",s=Object.create(null),i=0;for(let d=0;d<e.length;d++){let g=e[d];if(g==="-F"&&d+1<e.length)r=ga(e[++d]),n=O1(r),i=d+1;else if(g.startsWith("-F"))r=ga(g.slice(2)),n=O1(r),i=d+1;else if(g==="-v"&&d+1<e.length){let y=e[++d],w=y.indexOf("=");if(w>0){let b=y.slice(0,w),x=ga(y.slice(w+1));s[b]=x}i=d+1}else{if(g.startsWith("--"))return X("awk",g);if(g.startsWith("-")&&g.length>1){let y=g[1];if(y!=="F"&&y!=="v")return X("awk",`-${y}`);i=d+1}else if(!g.startsWith("-")){i=d;break}}}if(i>=e.length)return{stdout:"",stderr:`awk: missing program
340
340
  `,exitCode:1};let o=e[i],a=e.slice(i+1),l=new si,c;try{c=l.parse(o)}catch(d){return{stdout:"",stderr:`awk: ${d instanceof Error?d.message:String(d)}
341
341
  `,exitCode:1}}let u={readFile:t.fs.readFile.bind(t.fs),writeFile:t.fs.writeFile.bind(t.fs),appendFile:async(d,g)=>{try{let y=await t.fs.readFile(d);await t.fs.writeFile(d,y+g)}catch{await t.fs.writeFile(d,g)}},resolvePath:t.fs.resolvePath.bind(t.fs)},f=oa({fieldSep:n,maxIterations:t.limits?.maxAwkIterations,fs:u,cwd:t.cwd,exec:t.exec?d=>t.exec(d,{cwd:t.cwd}):void 0});f.FS=r,f.vars=Object.assign(Object.create(null),s),f.ARGC=a.length+1,f.ARGV=Object.create(null),f.ARGV[0]="awk";for(let d=0;d<a.length;d++)f.ARGV[String(d+1)]=a[d];f.ENVIRON=wt(t.env);let h=new es(f);h.execute(c);let p=c.rules.some(d=>d.pattern?.type!=="begin"&&d.pattern?.type!=="end"),m=c.rules.some(d=>d.pattern?.type==="end");try{if(await h.executeBegin(),f.shouldExit)return await h.executeEnd(),{stdout:h.getOutput(),stderr:"",exitCode:h.getExitCode()};if(!p&&!m)return{stdout:h.getOutput(),stderr:"",exitCode:h.getExitCode()};let d=[];if(a.length>0)for(let g of a)try{let y=t.fs.resolvePath(t.cwd,g),b=(await t.fs.readFile(y)).split(`
342
342
  `);b.length>0&&b[b.length-1]===""&&b.pop(),d.push({filename:g,lines:b})}catch{return{stdout:"",stderr:`awk: ${g}: No such file or directory
@@ -352,14 +352,14 @@ Examples:
352
352
  -k2,2 sort by second field only
353
353
  -k1.3 sort by first field starting at 3rd character
354
354
  -k1,2n sort by fields 1-2 numerically
355
- -k2 -k1 sort by field 2, then by field 1`},F3={name:"sort",async execute(e,t){if(U(e))return F(M3);let n={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},r=[];for(let c=0;c<e.length;c++){let u=e[c];if(u==="-r"||u==="--reverse")n.reverse=!0;else if(u==="-n"||u==="--numeric-sort")n.numeric=!0;else if(u==="-u"||u==="--unique")n.unique=!0;else if(u==="-f"||u==="--ignore-case")n.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")n.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")n.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")n.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")n.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")n.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")n.stable=!0;else if(u==="-c"||u==="--check")n.checkOnly=!0;else if(u==="-o"||u==="--output")n.outputFile=e[++c]||null;else if(u.startsWith("-o"))n.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))n.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")n.fieldDelimiter=e[++c]||null;else if(u.startsWith("-t"))n.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))n.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=e[++c];if(f){let h=ii(f);h&&n.keys.push(h)}}else if(u.startsWith("-k")){let f=ii(u.slice(2));f&&n.keys.push(f)}else if(u.startsWith("--key=")){let f=ii(u.slice(6));f&&n.keys.push(f)}else{if(u.startsWith("--"))return X("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let h of u.slice(1))if(h==="r")n.reverse=!0;else if(h==="n")n.numeric=!0;else if(h==="u")n.unique=!0;else if(h==="f")n.ignoreCase=!0;else if(h==="h")n.humanNumeric=!0;else if(h==="V")n.versionSort=!0;else if(h==="d")n.dictionaryOrder=!0;else if(h==="M")n.monthSort=!0;else if(h==="b")n.ignoreLeadingBlanks=!0;else if(h==="s")n.stable=!0;else if(h==="c")n.checkOnly=!0;else{f=!0;break}if(f)return X("sort",u)}else r.push(u)}}let s=await ar(t,r,{cmdName:"sort"});if(!s.ok)return s.error;let o=s.content.split(`
355
+ -k2 -k1 sort by field 2, then by field 1`},F3={name:"sort",async execute(e,t){if(F(e))return M(M3);let n={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},r=[];for(let c=0;c<e.length;c++){let u=e[c];if(u==="-r"||u==="--reverse")n.reverse=!0;else if(u==="-n"||u==="--numeric-sort")n.numeric=!0;else if(u==="-u"||u==="--unique")n.unique=!0;else if(u==="-f"||u==="--ignore-case")n.ignoreCase=!0;else if(u==="-h"||u==="--human-numeric-sort")n.humanNumeric=!0;else if(u==="-V"||u==="--version-sort")n.versionSort=!0;else if(u==="-d"||u==="--dictionary-order")n.dictionaryOrder=!0;else if(u==="-M"||u==="--month-sort")n.monthSort=!0;else if(u==="-b"||u==="--ignore-leading-blanks")n.ignoreLeadingBlanks=!0;else if(u==="-s"||u==="--stable")n.stable=!0;else if(u==="-c"||u==="--check")n.checkOnly=!0;else if(u==="-o"||u==="--output")n.outputFile=e[++c]||null;else if(u.startsWith("-o"))n.outputFile=u.slice(2)||null;else if(u.startsWith("--output="))n.outputFile=u.slice(9)||null;else if(u==="-t"||u==="--field-separator")n.fieldDelimiter=e[++c]||null;else if(u.startsWith("-t"))n.fieldDelimiter=u.slice(2)||null;else if(u.startsWith("--field-separator="))n.fieldDelimiter=u.slice(18)||null;else if(u==="-k"||u==="--key"){let f=e[++c];if(f){let h=ii(f);h&&n.keys.push(h)}}else if(u.startsWith("-k")){let f=ii(u.slice(2));f&&n.keys.push(f)}else if(u.startsWith("--key=")){let f=ii(u.slice(6));f&&n.keys.push(f)}else{if(u.startsWith("--"))return X("sort",u);if(u.startsWith("-")&&!u.startsWith("--")){let f=!1;for(let h of u.slice(1))if(h==="r")n.reverse=!0;else if(h==="n")n.numeric=!0;else if(h==="u")n.unique=!0;else if(h==="f")n.ignoreCase=!0;else if(h==="h")n.humanNumeric=!0;else if(h==="V")n.versionSort=!0;else if(h==="d")n.dictionaryOrder=!0;else if(h==="M")n.monthSort=!0;else if(h==="b")n.ignoreLeadingBlanks=!0;else if(h==="s")n.stable=!0;else if(h==="c")n.checkOnly=!0;else{f=!0;break}if(f)return X("sort",u)}else r.push(u)}}let s=await ar(t,r,{cmdName:"sort"});if(!s.ok)return s.error;let o=s.content.split(`
356
356
  `);o.length>0&&o[o.length-1]===""&&o.pop();let a=M1(n);if(n.checkOnly){let c=r.length>0?r[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]}
357
357
  `,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}o.sort(a),n.unique&&(o=F1(o,n));let l=o.length>0?`${o.join(`
358
358
  `)}
359
- `:"";if(n.outputFile){let c=t.fs.resolvePath(t.cwd,n.outputFile);return await t.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}}});var z1={};Q(z1,{uniqCommand:()=>B3});var U3,W3,B3,j1=I(()=>{"use strict";qe();Hn();ne();U3={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"]},W3={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"}},B3={name:"uniq",async execute(e,t){if(U(e))return F(U3);let n=we("uniq",e,W3);if(!n.ok)return n.error;let{count:r,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=n.result.flags,a=n.result.positional,l=await ar(t,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=l.content.split(`
359
+ `:"";if(n.outputFile){let c=t.fs.resolvePath(t.cwd,n.outputFile);return await t.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}}});var z1={};Q(z1,{uniqCommand:()=>B3});var U3,W3,B3,j1=I(()=>{"use strict";qe();Hn();ne();U3={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"]},W3={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"}},B3={name:"uniq",async execute(e,t){if(F(e))return M(U3);let n=we("uniq",e,W3);if(!n.ok)return n.error;let{count:r,duplicatesOnly:s,uniqueOnly:i,ignoreCase:o}=n.result.flags,a=n.result.positional,l=await ar(t,a,{cmdName:"uniq"});if(!l.ok)return l.error;let u=l.content.split(`
360
360
  `);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],h=u[0],p=1,m=(y,w)=>o?y.toLowerCase()===w.toLowerCase():y===w;for(let y=1;y<u.length;y++)m(u[y],h)?p++:(f.push({line:h,count:p}),h=u[y],p=1);f.push({line:h,count:p});let d=f;s?d=f.filter(y=>y.count>1):i&&(d=f.filter(y=>y.count===1));let g="";for(let{line:y,count:w}of d)r?g+=`${String(w).padStart(4)} ${y}
361
361
  `:g+=`${y}
362
- `;return{stdout:g,stderr:"",exitCode:0}}}});var G1={};Q(G1,{commCommand:()=>z3});var H3,z3,V1=I(()=>{"use strict";ne();H3={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"]},z3={name:"comm",async execute(e,t){if(U(e))return F(H3);let n=!1,r=!1,s=!1,i=[];for(let g of e)if(g==="-1")n=!0;else if(g==="-2")r=!0;else if(g==="-3")s=!0;else if(g==="-12"||g==="-21")n=!0,r=!0;else if(g==="-13"||g==="-31")n=!0,s=!0;else if(g==="-23"||g==="-32")r=!0,s=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")n=!0,r=!0,s=!0;else{if(g.startsWith("-")&&g!=="-")return X("comm",g);i.push(g)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
362
+ `;return{stdout:g,stderr:"",exitCode:0}}}});var G1={};Q(G1,{commCommand:()=>z3});var H3,z3,V1=I(()=>{"use strict";ne();H3={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"]},z3={name:"comm",async execute(e,t){if(F(e))return M(H3);let n=!1,r=!1,s=!1,i=[];for(let g of e)if(g==="-1")n=!0;else if(g==="-2")r=!0;else if(g==="-3")s=!0;else if(g==="-12"||g==="-21")n=!0,r=!0;else if(g==="-13"||g==="-31")n=!0,s=!0;else if(g==="-23"||g==="-32")r=!0,s=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")n=!0,r=!0,s=!0;else{if(g.startsWith("-")&&g!=="-")return X("comm",g);i.push(g)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
363
363
  Try 'comm --help' for more information.
364
364
  `,exitCode:1};let o=async g=>{if(g==="-")return t.stdin;try{let y=t.fs.resolvePath(t.cwd,g);return await t.fs.readFile(y)}catch{return null}},a=await o(i[0]);if(a===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
365
365
  `,exitCode:1};let l=await o(i[1]);if(l===null)return{stdout:"",stderr:`comm: ${i[1]}: No such file or directory
@@ -370,11 +370,11 @@ Try 'comm --help' for more information.
370
370
  `),f++):c[f]<u[h]?(n||(p+=`${c[f]}
371
371
  `),f++):c[f]>u[h]?(r||(p+=`${m}${u[h]}
372
372
  `),h++):(s||(p+=`${d}${c[f]}
373
- `),f++,h++);return{stdout:p,stderr:"",exitCode:0}}}});var q1={};Q(q1,{cutCommand:()=>q3});function G3(e){let t=[],n=e.split(",");for(let r of n)if(r.includes("-")){let[s,i]=r.split("-");t.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(r,10);t.push({start:s,end:s})}return t}function V3(e,t){let n=[];for(let r of t){let s=r.start-1,i=r.end===null?e.length:r.end;for(let o=s;o<i&&o<e.length;o++)o>=0&&!n.includes(e[o])&&n.push(e[o])}return n}var j3,q3,Z1=I(()=>{"use strict";Hn();ne();j3={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"]};q3={name:"cut",async execute(e,t){if(U(e))return F(j3);let n=" ",r=null,s=null,i=!1,o=[];for(let h=0;h<e.length;h++){let p=e[h];if(p==="-d")n=e[++h]||" ";else if(p.startsWith("-d"))n=p.slice(2);else if(p==="-f")r=e[++h];else if(p.startsWith("-f"))r=p.slice(2);else if(p==="-c")s=e[++h];else if(p.startsWith("-c"))s=p.slice(2);else if(p==="-s"||p==="--only-delimited")i=!0;else{if(p.startsWith("--"))return X("cut",p);if(p.startsWith("-")){let m=!1;for(let d of p.slice(1))if(d==="s")i=!0;else if(!"dfc".includes(d)){m=!0;break}if(m)return X("cut",p)}else o.push(p)}}if(!r&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
373
+ `),f++,h++);return{stdout:p,stderr:"",exitCode:0}}}});var q1={};Q(q1,{cutCommand:()=>q3});function G3(e){let t=[],n=e.split(",");for(let r of n)if(r.includes("-")){let[s,i]=r.split("-");t.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(r,10);t.push({start:s,end:s})}return t}function V3(e,t){let n=[];for(let r of t){let s=r.start-1,i=r.end===null?e.length:r.end;for(let o=s;o<i&&o<e.length;o++)o>=0&&!n.includes(e[o])&&n.push(e[o])}return n}var j3,q3,Z1=I(()=>{"use strict";Hn();ne();j3={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"]};q3={name:"cut",async execute(e,t){if(F(e))return M(j3);let n=" ",r=null,s=null,i=!1,o=[];for(let h=0;h<e.length;h++){let p=e[h];if(p==="-d")n=e[++h]||" ";else if(p.startsWith("-d"))n=p.slice(2);else if(p==="-f")r=e[++h];else if(p.startsWith("-f"))r=p.slice(2);else if(p==="-c")s=e[++h];else if(p.startsWith("-c"))s=p.slice(2);else if(p==="-s"||p==="--only-delimited")i=!0;else{if(p.startsWith("--"))return X("cut",p);if(p.startsWith("-")){let m=!1;for(let d of p.slice(1))if(d==="s")i=!0;else if(!"dfc".includes(d)){m=!0;break}if(m)return X("cut",p)}else o.push(p)}}if(!r&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
374
374
  `,exitCode:1};let a=await ar(t,o,{cmdName:"cut"});if(!a.ok)return a.error;let c=a.content.split(`
375
375
  `);c.length>0&&c[c.length-1]===""&&c.pop();let u=G3(r||s||"1"),f="";for(let h of c)if(s){let p=h.split(""),m=[];for(let d of u){let g=d.start-1,y=d.end===null?p.length:d.end;for(let w=g;w<y&&w<p.length;w++)w>=0&&m.push(p[w])}f+=`${m.join("")}
376
376
  `}else{if(i&&!h.includes(n))continue;let p=h.split(n),m=V3(p,u);f+=`${m.join(n)}
377
- `}return{stdout:f,stderr:"",exitCode:0}}}});var K1={};Q(K1,{pasteCommand:()=>K3});function Q1(e,t){if(e.length===0)return"";if(e.length===1)return e[0];let n=e[0];for(let r=1;r<e.length;r++){let s=(r-1)%t.length;n+=t[s]+e[r]}return n}var Z3,Q3,K3,X1=I(()=>{"use strict";qe();ne();Z3={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"]},Q3={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},K3={name:"paste",async execute(e,t){if(U(e))return F(Z3);let n=we("paste",e,Q3);if(!n.ok)return n.error;let r=n.result.flags.delimiter,s=n.result.flags.serial,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
377
+ `}return{stdout:f,stderr:"",exitCode:0}}}});var K1={};Q(K1,{pasteCommand:()=>K3});function Q1(e,t){if(e.length===0)return"";if(e.length===1)return e[0];let n=e[0];for(let r=1;r<e.length;r++){let s=(r-1)%t.length;n+=t[s]+e[r]}return n}var Z3,Q3,K3,X1=I(()=>{"use strict";qe();ne();Z3={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"]},Q3={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},K3={name:"paste",async execute(e,t){if(F(e))return M(Z3);let n=we("paste",e,Q3);if(!n.ok)return n.error;let r=n.result.flags.delimiter,s=n.result.flags.serial,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
378
378
  `,exitCode:1};let o=t.stdin?t.stdin.split(`
379
379
  `):[""];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 h=[];for(let p=c;p<o.length;p+=a)h.push(o[p]);l.push(h),c++}else{let h=t.fs.resolvePath(t.cwd,f);try{let m=(await t.fs.readFile(h)).split(`
380
380
  `);m.length>0&&m[m.length-1]===""&&m.pop(),l.push(m)}catch{return{stdout:"",stderr:`paste: ${f}: No such file or directory
@@ -396,9 +396,9 @@ Try 'comm --help' for more information.
396
396
  [:cntrl:] all control characters
397
397
  [:xdigit:] all hexadecimal digits
398
398
  \\n, \\t, \\r escape sequences`},Y3=new Map([["[:alnum:]","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"],["[:alpha:]","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"],["[:blank:]"," "],["[:cntrl:]",Array.from({length:32},(e,t)=>String.fromCharCode(t)).join("").concat("\x7F")],["[:digit:]","0123456789"],["[:graph:]",Array.from({length:94},(e,t)=>String.fromCharCode(33+t)).join("")],["[:lower:]","abcdefghijklmnopqrstuvwxyz"],["[:print:]",Array.from({length:95},(e,t)=>String.fromCharCode(32+t)).join("")],["[:punct:]","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"],["[:space:]",`
399
- \r\f\v`],["[:upper:]","ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["[:xdigit:]","0123456789ABCDEFabcdef"]]);J3={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"}},e8={name:"tr",async execute(e,t){if(U(e))return F(X3);let n=we("tr",e,J3);if(!n.ok)return n.error;let r=n.result.flags.complement||n.result.flags.complementUpper,s=n.result.flags.delete,i=n.result.flags.squeeze,o=n.result.positional;if(o.length<1)return{stdout:"",stderr:`tr: missing operand
399
+ \r\f\v`],["[:upper:]","ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["[:xdigit:]","0123456789ABCDEFabcdef"]]);J3={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"}},e8={name:"tr",async execute(e,t){if(F(e))return M(X3);let n=we("tr",e,J3);if(!n.ok)return n.error;let r=n.result.flags.complement||n.result.flags.complementUpper,s=n.result.flags.delete,i=n.result.flags.squeeze,o=n.result.positional;if(o.length<1)return{stdout:"",stderr:`tr: missing operand
400
400
  `,exitCode:1};if(!s&&!i&&o.length<2)return{stdout:"",stderr:`tr: missing operand after SET1
401
- `,exitCode:1};let a=Y1(o[0]),l=o.length>1?Y1(o[1]):"",c=t.stdin,u=h=>{let p=a.includes(h);return r?!p:p},f="";if(s)for(let h of c)u(h)||(f+=h);else if(i&&o.length===1){let h="";for(let p of c)u(p)&&p===h||(f+=p,h=p)}else{if(r){let h=l.length>0?l[l.length-1]:"";for(let p of c)a.includes(p)?f+=p:f+=h}else{let h=new Map;for(let p=0;p<a.length;p++){let m=p<l.length?l[p]:l[l.length-1];h.set(a[p],m)}for(let p of c)f+=h.get(p)??p}if(i){let h="",p="";for(let m of f)l.includes(m)&&m===p||(h+=m,p=m);f=h}}return{stdout:f,stderr:"",exitCode:0}}}});var th={};Q(th,{rev:()=>r8});function n8(e){return Array.from(e).reverse().join("")}var t8,r8,nh=I(()=>{"use strict";ne();t8={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"]};r8={name:"rev",execute:async(e,t)=>{if(U(e))return F(t8);let n=[];for(let i of e)if(i==="--"){let o=e.indexOf(i);n.push(...e.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return X("rev",i);n.push(i)}let r="",s=i=>{let o=i.split(`
401
+ `,exitCode:1};let a=Y1(o[0]),l=o.length>1?Y1(o[1]):"",c=t.stdin,u=h=>{let p=a.includes(h);return r?!p:p},f="";if(s)for(let h of c)u(h)||(f+=h);else if(i&&o.length===1){let h="";for(let p of c)u(p)&&p===h||(f+=p,h=p)}else{if(r){let h=l.length>0?l[l.length-1]:"";for(let p of c)a.includes(p)?f+=p:f+=h}else{let h=new Map;for(let p=0;p<a.length;p++){let m=p<l.length?l[p]:l[l.length-1];h.set(a[p],m)}for(let p of c)f+=h.get(p)??p}if(i){let h="",p="";for(let m of f)l.includes(m)&&m===p||(h+=m,p=m);f=h}}return{stdout:f,stderr:"",exitCode:0}}}});var th={};Q(th,{rev:()=>r8});function n8(e){return Array.from(e).reverse().join("")}var t8,r8,nh=I(()=>{"use strict";ne();t8={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"]};r8={name:"rev",execute:async(e,t)=>{if(F(e))return M(t8);let n=[];for(let i of e)if(i==="--"){let o=e.indexOf(i);n.push(...e.slice(o+1));break}else{if(i.startsWith("-")&&i!=="-")return X("rev",i);n.push(i)}let r="",s=i=>{let o=i.split(`
402
402
  `),a=i.endsWith(`
403
403
  `)&&o[o.length-1]==="";return a&&o.pop(),o.map(n8).join(`
404
404
  `)+(a?`
@@ -407,7 +407,7 @@ Try 'comm --help' for more information.
407
407
  `),s=[],i=n,o=e.endsWith(`
408
408
  `)&&r[r.length-1]==="";o&&r.pop();for(let a of r)if(o8(a,t.bodyStyle)){let l=i8(i,t.numberFormat,t.width);s.push(`${l}${t.separator}${a}`),i+=t.increment}else{let l=" ".repeat(t.width);s.push(`${l}${t.separator}${a}`)}return{output:s.join(`
409
409
  `)+(o?`
410
- `:""),nextNumber:i}}var s8,a8,ih=I(()=>{"use strict";ne();s8={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"]};a8={name:"nl",execute:async(e,t)=>{if(U(e))return F(s8);let n={bodyStyle:"t",numberFormat:"rn",width:6,separator:" ",startNumber:1,increment:1},r=[],s=0;for(;s<e.length;){let a=e[s];if(a==="-b"&&s+1<e.length){let l=e[s+1];if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
410
+ `:""),nextNumber:i}}var s8,a8,ih=I(()=>{"use strict";ne();s8={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"]};a8={name:"nl",execute:async(e,t)=>{if(F(e))return M(s8);let n={bodyStyle:"t",numberFormat:"rn",width:6,separator:" ",startNumber:1,increment:1},r=[],s=0;for(;s<e.length;){let a=e[s];if(a==="-b"&&s+1<e.length){let l=e[s+1];if(l!=="a"&&l!=="t"&&l!=="n")return{exitCode:1,stdout:"",stderr:`nl: invalid body numbering style: '${l}'
411
411
  `};n.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}'
412
412
  `};n.bodyStyle=l,s++}else if(a==="-n"&&s+1<e.length){let l=e[s+1];if(l!=="ln"&&l!=="rn"&&l!=="rz")return{exitCode:1,stdout:"",stderr:`nl: invalid line numbering format: '${l}'
413
413
  `};n.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}'
@@ -423,7 +423,7 @@ Try 'comm --help' for more information.
423
423
  `),r=e.endsWith(`
424
424
  `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>u8(i,t)).join(`
425
425
  `)+(r?`
426
- `:"")}var l8,f8,lh=I(()=>{"use strict";ne();l8={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"]};f8={name:"fold",execute:async(e,t)=>{if(U(e))return F(l8);let n={width:80,breakAtSpaces:!1,countBytes:!1},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-w"&&s+1<e.length){let a=parseInt(e[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${e[s+1]}'
426
+ `:"")}var l8,f8,lh=I(()=>{"use strict";ne();l8={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"]};f8={name:"fold",execute:async(e,t)=>{if(F(e))return M(l8);let n={width:80,breakAtSpaces:!1,countBytes:!1},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-w"&&s+1<e.length){let a=parseInt(e[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${e[s+1]}'
427
427
  `};n.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)}'
428
428
  `};n.width=a,s++}else if(o==="-s")n.breakAtSpaces=!0,s++;else if(o==="-b")n.countBytes=!0,s++;else if(o==="-bs"||o==="-sb")n.breakAtSpaces=!0,n.countBytes=!0,s++;else if(o.match(/^-[sb]+w\d+$/)){o.includes("s")&&(n.breakAtSpaces=!0),o.includes("b")&&(n.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}'
429
429
  `};n.width=l,s++}else if(o.match(/^-[sb]+w$/)&&s+1<e.length){o.includes("s")&&(n.breakAtSpaces=!0),o.includes("b")&&(n.countBytes=!0);let a=parseInt(e[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`fold: invalid number of columns: '${e[s+1]}'
@@ -432,7 +432,7 @@ Try 'comm --help' for more information.
432
432
  `),r=e.endsWith(`
433
433
  `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>d8(i,t)).join(`
434
434
  `)+(r?`
435
- `:"")}var h8,m8,fh=I(()=>{"use strict";ne();h8={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"]};m8={name:"expand",execute:async(e,t)=>{if(U(e))return F(h8);let n={tabStops:[8],leadingOnly:!1},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-t"&&s+1<e.length){let a=oi(e[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${e[s+1]}'
435
+ `:"")}var h8,m8,fh=I(()=>{"use strict";ne();h8={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"]};m8={name:"expand",execute:async(e,t)=>{if(F(e))return M(h8);let n={tabStops:[8],leadingOnly:!1},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-t"&&s+1<e.length){let a=oi(e[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${e[s+1]}'
436
436
  `};n.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=oi(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(2)}'
437
437
  `};n.tabStops=a,s++}else if(o==="--tabs"&&s+1<e.length){let a=oi(e[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${e[s+1]}'
438
438
  `};n.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=oi(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`expand: invalid tab size: '${o.slice(7)}'
@@ -441,12 +441,12 @@ Try 'comm --help' for more information.
441
441
  `),r=e.endsWith(`
442
442
  `)&&n[n.length-1]==="";return r&&n.pop(),n.map(i=>y8(i,t)).join(`
443
443
  `)+(r?`
444
- `:"")}var g8,w8,mh=I(()=>{"use strict";ne();g8={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"]};w8={name:"unexpand",execute:async(e,t)=>{if(U(e))return F(g8);let n={tabStops:[8],allBlanks:!1},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-t"&&s+1<e.length){let a=ai(e[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${e[s+1]}'
444
+ `:"")}var g8,w8,mh=I(()=>{"use strict";ne();g8={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"]};w8={name:"unexpand",execute:async(e,t)=>{if(F(e))return M(g8);let n={tabStops:[8],allBlanks:!1},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-t"&&s+1<e.length){let a=ai(e[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${e[s+1]}'
445
445
  `};n.tabStops=a,s+=2}else if(o.startsWith("-t")&&o.length>2){let a=ai(o.slice(2));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(2)}'
446
446
  `};n.tabStops=a,s++}else if(o==="--tabs"&&s+1<e.length){let a=ai(e[s+1]);if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${e[s+1]}'
447
447
  `};n.tabStops=a,s+=2}else if(o.startsWith("--tabs=")){let a=ai(o.slice(7));if(!a)return{exitCode:1,stdout:"",stderr:`unexpand: invalid tab size: '${o.slice(7)}'
448
448
  `};n.tabStops=a,s++}else if(o==="-a"||o==="--all")n.allBlanks=!0,s++;else if(o==="--"){r.push(...e.slice(s+1));break}else{if(o.startsWith("-")&&o!=="-")return X("unexpand",o);r.push(o),s++}}let i="";if(r.length===0){let o=t.stdin??"";i=ph(o,n)}else for(let o of r){let a=t.fs.resolvePath(t.cwd,o),l=await t.fs.readFile(a);if(l===null)return{exitCode:1,stdout:i,stderr:`unexpand: ${o}: No such file or directory
449
- `};i+=ph(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var wh={};Q(wh,{strings:()=>E8});function x8(e){return e>=32&&e<=126||e===9}function gh(e,t){if(t===null)return"";switch(t){case"o":return`${e.toString(8).padStart(7," ")} `;case"x":return`${e.toString(16).padStart(7," ")} `;case"d":return`${e.toString(10).padStart(7," ")} `;default:return t}}function yh(e,t){let n=[],r="",s=0,i=typeof e=="string"?new TextEncoder().encode(e):e;for(let o=0;o<i.length;o++){let a=i[o];if(x8(a))r.length===0&&(s=o),r+=String.fromCharCode(a);else{if(r.length>=t.minLength){let l=gh(s,t.offsetFormat);n.push(`${l}${r}`)}r=""}}if(r.length>=t.minLength){let o=gh(s,t.offsetFormat);n.push(`${o}${r}`)}return n}var b8,E8,bh=I(()=>{"use strict";ne();b8={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"]};E8={name:"strings",execute:async(e,t)=>{if(U(e))return F(b8);let n={minLength:4,offsetFormat:null},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-n"&&s+1<e.length){let a=Number.parseInt(e[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${e[s+1]}'
449
+ `};i+=ph(l,n)}return{exitCode:0,stdout:i,stderr:""}}}});var wh={};Q(wh,{strings:()=>E8});function x8(e){return e>=32&&e<=126||e===9}function gh(e,t){if(t===null)return"";switch(t){case"o":return`${e.toString(8).padStart(7," ")} `;case"x":return`${e.toString(16).padStart(7," ")} `;case"d":return`${e.toString(10).padStart(7," ")} `;default:return t}}function yh(e,t){let n=[],r="",s=0,i=typeof e=="string"?new TextEncoder().encode(e):e;for(let o=0;o<i.length;o++){let a=i[o];if(x8(a))r.length===0&&(s=o),r+=String.fromCharCode(a);else{if(r.length>=t.minLength){let l=gh(s,t.offsetFormat);n.push(`${l}${r}`)}r=""}}if(r.length>=t.minLength){let o=gh(s,t.offsetFormat);n.push(`${o}${r}`)}return n}var b8,E8,bh=I(()=>{"use strict";ne();b8={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"]};E8={name:"strings",execute:async(e,t)=>{if(F(e))return M(b8);let n={minLength:4,offsetFormat:null},r=[],s=0;for(;s<e.length;){let o=e[s];if(o==="-n"&&s+1<e.length){let a=Number.parseInt(e[s+1],10);if(Number.isNaN(a)||a<1)return{exitCode:1,stdout:"",stderr:`strings: invalid minimum string length: '${e[s+1]}'
450
450
  `};n.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)}'
451
451
  `};n.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)}'
452
452
  `};n.minLength=a,s++}else if(o==="-t"&&s+1<e.length){let a=e[s+1];if(a!=="o"&&a!=="x"&&a!=="d")return{exitCode:1,stdout:"",stderr:`strings: invalid radix: '${a}'
@@ -463,7 +463,7 @@ Try 'comm --help' for more information.
463
463
  `)&&n[n.length-1]==="";r&&n.pop();let s=[];for(let i=0;i<n.length;i+=t){let o=n.slice(i,i+t),l=i+t>=n.length&&!r?o.join(`
464
464
  `):`${o.join(`
465
465
  `)}
466
- `;s.push({content:l,hasContent:!0})}return s}function N8(e,t){let r=new TextEncoder().encode(e),s=new TextDecoder,i=[];for(let o=0;o<r.length;o+=t){let a=r.slice(o,o+t);i.push({content:s.decode(a),hasContent:a.length>0})}return i}function k8(e,t){let r=new TextEncoder().encode(e),s=new TextDecoder,i=[],o=Math.ceil(r.length/t);for(let a=0;a<t;a++){let l=a*o,c=Math.min(l+o,r.length),u=r.slice(l,c);i.push({content:s.decode(u),hasContent:u.length>0})}return i}var A8,v8,Ah=I(()=>{"use strict";ne();A8={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, ..."]};v8={name:"split",execute:async(e,t)=>{if(U(e))return F(A8);let n={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},r=[],s=0;for(;s<e.length;){let c=e[s];if(c==="-l"&&s+1<e.length){let u=Number.parseInt(e[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${e[s+1]}'
466
+ `;s.push({content:l,hasContent:!0})}return s}function N8(e,t){let r=new TextEncoder().encode(e),s=new TextDecoder,i=[];for(let o=0;o<r.length;o+=t){let a=r.slice(o,o+t);i.push({content:s.decode(a),hasContent:a.length>0})}return i}function k8(e,t){let r=new TextEncoder().encode(e),s=new TextDecoder,i=[],o=Math.ceil(r.length/t);for(let a=0;a<t;a++){let l=a*o,c=Math.min(l+o,r.length),u=r.slice(l,c);i.push({content:s.decode(u),hasContent:u.length>0})}return i}var A8,v8,Ah=I(()=>{"use strict";ne();A8={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, ..."]};v8={name:"split",execute:async(e,t)=>{if(F(e))return M(A8);let n={mode:"lines",lines:1e3,bytes:0,chunks:0,useNumericSuffix:!1,suffixLength:2,additionalSuffix:""},r=[],s=0;for(;s<e.length;){let c=e[s];if(c==="-l"&&s+1<e.length){let u=Number.parseInt(e[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid number of lines: '${e[s+1]}'
467
467
  `};n.mode="lines",n.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)}'
468
468
  `};n.mode="lines",n.lines=u,s++}else if(c==="-b"&&s+1<e.length){let u=xh(e[s+1]);if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${e[s+1]}'
469
469
  `};n.mode="bytes",n.bytes=u,s+=2}else if(c.match(/^-b.+$/)){let u=xh(c.slice(2));if(u===null)return{exitCode:1,stdout:"",stderr:`split: invalid number of bytes: '${c.slice(2)}'
@@ -472,13 +472,13 @@ Try 'comm --help' for more information.
472
472
  `};n.mode="chunks",n.chunks=u,s++}else if(c==="-a"&&s+1<e.length){let u=Number.parseInt(e[s+1],10);if(Number.isNaN(u)||u<1)return{exitCode:1,stdout:"",stderr:`split: invalid suffix length: '${e[s+1]}'
473
473
  `};n.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)}'
474
474
  `};n.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")n.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))n.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<e.length)n.additionalSuffix=e[s+1],s+=2;else if(c==="--"){r.push(...e.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return X("split",c);r.push(c),s++}}let i="-",o="x";r.length>=1&&(i=r[0]),r.length>=2&&(o=r[1]);let a;if(i==="-")a=t.stdin??"";else{let c=t.fs.resolvePath(t.cwd,i),u=await t.fs.readFile(c);if(u===null)return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
475
- `};a=u}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(n.mode){case"lines":l=C8(a,n.lines);break;case"bytes":l=N8(a,n.bytes);break;case"chunks":l=k8(a,n.chunks);break;default:return n.mode}for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=S8(c,n.useNumericSuffix,n.suffixLength),h=`${o}${f}${n.additionalSuffix}`,p=t.fs.resolvePath(t.cwd,h);await t.fs.writeFile(p,u.content)}return{exitCode:0,stdout:"",stderr:""}}}});var Ch={};Q(Ch,{column:()=>P8});function Sh(e,t,n){return t?n?e.split(t):e.split(t).filter(r=>r.length>0):n?e.split(/[ \t]/):e.split(/[ \t]+/).filter(r=>r.length>0)}function O8(e){let t=[];for(let n of e)for(let r=0;r<n.length;r++){let s=n[r].length;(t[r]===void 0||s>t[r])&&(t[r]=s)}return t}function $8(e,t){if(e.length===0)return"";let n=O8(e),r=[];for(let s of e){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(n[o]));r.push(i.join(t))}return r.join(`
475
+ `};a=u}if(a==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(n.mode){case"lines":l=C8(a,n.lines);break;case"bytes":l=N8(a,n.bytes);break;case"chunks":l=k8(a,n.chunks);break;default:return n.mode}for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=S8(c,n.useNumericSuffix,n.suffixLength),h=`${o}${f}${n.additionalSuffix}`,p=t.fs.resolvePath(t.cwd,h);await t.fs.writeFile(p,u.content)}return{exitCode:0,stdout:"",stderr:""}}}});var Ch={};Q(Ch,{column:()=>P8});function Sh(e,t,n){return t?n?e.split(t):e.split(t).filter(r=>r.length>0):n?e.split(/[ \t]/):e.split(/[ \t]+/).filter(r=>r.length>0)}function R8(e){let t=[];for(let n of e)for(let r=0;r<n.length;r++){let s=n[r].length;(t[r]===void 0||s>t[r])&&(t[r]=s)}return t}function $8(e,t){if(e.length===0)return"";let n=R8(e),r=[];for(let s of e){let i=[];for(let o=0;o<s.length;o++)o===s.length-1?i.push(s[o]):i.push(s[o].padEnd(n[o]));r.push(i.join(t))}return r.join(`
476
476
  `)}function T8(e,t,n){if(e.length===0)return"";let r=Math.max(...e.map(c=>c.length)),s=n.length,i=r+s,o=Math.max(1,Math.floor((t+s)/i)),a=Math.ceil(e.length/o),l=[];for(let c=0;c<a;c++){let u=[];for(let f=0;f<o;f++){let h=f*a+c;h<e.length&&(f===o-1||(f+1)*a+c>=e.length?u.push(e[h]):u.push(e[h].padEnd(r)))}l.push(u.join(n))}return l.join(`
477
- `)}var I8,R8,P8,Nh=I(()=>{"use strict";qe();ne();I8={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"]},R8={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"}};P8={name:"column",execute:async(e,t)=>{if(U(e))return F(I8);let n=we("column",e,R8);if(!n.ok)return n.error;let{table:r,separator:s,outputSep:i,width:o,noMerge:a}=n.result.flags,l=n.result.positional,c=i??" ",u;if(l.length===0)u=t.stdin??"";else{let d=[];for(let g of l)if(g==="-")d.push(t.stdin??"");else{let y=t.fs.resolvePath(t.cwd,g),w=await t.fs.readFile(y);if(w===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
477
+ `)}var I8,O8,P8,Nh=I(()=>{"use strict";qe();ne();I8={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"]},O8={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"}};P8={name:"column",execute:async(e,t)=>{if(F(e))return M(I8);let n=we("column",e,O8);if(!n.ok)return n.error;let{table:r,separator:s,outputSep:i,width:o,noMerge:a}=n.result.flags,l=n.result.positional,c=i??" ",u;if(l.length===0)u=t.stdin??"";else{let d=[];for(let g of l)if(g==="-")d.push(t.stdin??"");else{let y=t.fs.resolvePath(t.cwd,g),w=await t.fs.readFile(y);if(w===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
478
478
  `};d.push(w)}u=d.join("")}if(u===""||u.trim()==="")return{exitCode:0,stdout:"",stderr:""};let f=u.split(`
479
479
  `);u.endsWith(`
480
480
  `)&&f[f.length-1]===""&&f.pop();let p=f.filter(d=>d.trim().length>0),m;if(r){let d=p.map(g=>Sh(g,s,a));m=$8(d,c)}else{let d=[];for(let g of p){let y=Sh(g,s,a);d.push(...y)}m=T8(d,o,c)}return m.length>0&&(m+=`
481
- `),{exitCode:0,stdout:m,stderr:""}}}});var kh={};Q(kh,{join:()=>F8});function L8(e,t){return t?e.split(t):e.split(/[ \t]+/).filter(n=>n.length>0)}function _8(e,t,n,r){let s=L8(e,t),i=s[n-1]??"";return r&&(i=i.toLowerCase()),{fields:s,joinKey:i,original:e}}function wa(e,t,n){let r=n.separator??" ";if(n.outputFormat){let o=[];for(let{file:a,field:l}of n.outputFormat){let c=a===1?e:t;c&&l===0?o.push(c.joinKey):c&&c.fields[l-1]!==void 0?o.push(c.fields[l-1]):o.push(n.emptyString)}return o.join(r)}let s=[],i=e?.joinKey??t?.joinKey??"";if(s.push(i),e)for(let o=0;o<e.fields.length;o++)o!==n.field1-1&&s.push(e.fields[o]);if(t)for(let o=0;o<t.fields.length;o++)o!==n.field2-1&&s.push(t.fields[o]);return s.join(r)}function M8(e){let t=e.split(","),n=[];for(let r of t){let s=r.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;n.push({file:i,field:o})}return n}var D8,F8,vh=I(()=>{"use strict";ne();D8={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"]};F8={name:"join",execute:async(e,t)=>{if(U(e))return F(D8);let n={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},r=[],s=0;for(;s<e.length;){let h=e[s];if(h==="-1"&&s+1<e.length){let p=Number.parseInt(e[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${e[s+1]}'
481
+ `),{exitCode:0,stdout:m,stderr:""}}}});var kh={};Q(kh,{join:()=>F8});function L8(e,t){return t?e.split(t):e.split(/[ \t]+/).filter(n=>n.length>0)}function _8(e,t,n,r){let s=L8(e,t),i=s[n-1]??"";return r&&(i=i.toLowerCase()),{fields:s,joinKey:i,original:e}}function wa(e,t,n){let r=n.separator??" ";if(n.outputFormat){let o=[];for(let{file:a,field:l}of n.outputFormat){let c=a===1?e:t;c&&l===0?o.push(c.joinKey):c&&c.fields[l-1]!==void 0?o.push(c.fields[l-1]):o.push(n.emptyString)}return o.join(r)}let s=[],i=e?.joinKey??t?.joinKey??"";if(s.push(i),e)for(let o=0;o<e.fields.length;o++)o!==n.field1-1&&s.push(e.fields[o]);if(t)for(let o=0;o<t.fields.length;o++)o!==n.field2-1&&s.push(t.fields[o]);return s.join(r)}function M8(e){let t=e.split(","),n=[];for(let r of t){let s=r.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;n.push({file:i,field:o})}return n}var D8,F8,vh=I(()=>{"use strict";ne();D8={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"]};F8={name:"join",execute:async(e,t)=>{if(F(e))return M(D8);let n={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},r=[],s=0;for(;s<e.length;){let h=e[s];if(h==="-1"&&s+1<e.length){let p=Number.parseInt(e[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${e[s+1]}'
482
482
  `};n.field1=p,s+=2}else if(h==="-2"&&s+1<e.length){let p=Number.parseInt(e[s+1],10);if(Number.isNaN(p)||p<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${e[s+1]}'
483
483
  `};n.field2=p,s+=2}else if((h==="-t"||h==="--field-separator")&&s+1<e.length)n.separator=e[s+1],s+=2;else if(h.startsWith("-t")&&h.length>2)n.separator=h.slice(2),s++;else if(h==="-a"&&s+1<e.length){let p=Number.parseInt(e[s+1],10);if(p!==1&&p!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${e[s+1]}'
484
484
  `};n.printUnpairable.add(p),s+=2}else if(h.match(/^-a[12]$/))n.printUnpairable.add(Number.parseInt(h[2],10)),s++;else if(h==="-v"&&s+1<e.length){let p=Number.parseInt(e[s+1],10);if(p!==1&&p!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${e[s+1]}'
@@ -490,21 +490,21 @@ Try 'comm --help' for more information.
490
490
  `);return h.endsWith(`
491
491
  `)&&m[m.length-1]===""&&m.pop(),m.filter(d=>d.length>0).map(d=>_8(d,n.separator,p,n.ignoreCase))},a=o(i[0],n.field1),l=o(i[1],n.field2),c=new Map;for(let h of l){let p=c.get(h.joinKey);p?p.push(h):c.set(h.joinKey,[h])}let u=[],f=new Set;for(let h of a){let p=c.get(h.joinKey);if(p&&p.length>0){if(f.add(h.joinKey),n.onlyUnpairable.size===0)for(let m of p)u.push(wa(h,m,n))}else(n.printUnpairable.has(1)||n.onlyUnpairable.has(1))&&u.push(wa(h,null,n))}if(n.printUnpairable.has(2)||n.onlyUnpairable.has(2))for(let h of l)f.has(h.joinKey)||u.push(wa(null,h,n));return{exitCode:0,stdout:u.length>0?`${u.join(`
492
492
  `)}
493
- `:"",stderr:""}}}});var Ih={};Q(Ih,{teeCommand:()=>B8});var U8,W8,B8,Rh=I(()=>{"use strict";qe();ne();U8={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"]},W8={append:{short:"a",long:"append",type:"boolean"}},B8={name:"tee",async execute(e,t){if(U(e))return F(U8);let n=we("tee",e,W8);if(!n.ok)return n.error;let{append:r}=n.result.flags,s=n.result.positional,i=t.stdin,o="",a=0;for(let l of s)try{let c=t.fs.resolvePath(t.cwd,l);r?await t.fs.appendFile(c,i):await t.fs.writeFile(c,i)}catch{o+=`tee: ${l}: No such file or directory
494
- `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function Vt(e,t){switch(e.type){case"name":{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],i=t.name;if(e.ignoreCase){if(!i.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:dt(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,r=t.relativePath,s=n.split("/");for(let o=0;o<s.length-1;o++){let a=s[o];if(a&&a!=="."&&a!==".."&&!a.includes("*")&&!a.includes("?")&&!a.includes("[")){let l=`/${a}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(l))return{matches:!1,pruned:!1,printed:!1}}}let i=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let o=i[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(o))return{matches:!1,pruned:!1,printed:!1}}return{matches:dt(r,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:V(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24),s;return e.comparison==="more"?s=r>e.days:e.comparison==="less"?s=r<e.days:s=Math.floor(r)===e.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=t.size>n:e.comparison==="less"?r=t.size<n:e.unit==="b"?r=Math.ceil(t.size/512)===e.value:r=t.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,r=e.mode&511,s;return e.matchType==="exact"?s=n===r:e.matchType==="all"?s=(n&r)===r:s=(n&r)!==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 n=Vt(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=Vt(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=Vt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=Vt(e.left,t);if(n.matches)return n;let r=Vt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function ts(e){if(!e)return!1;switch(e.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 ts(e.expr);case"and":case"or":return ts(e.left)||ts(e.right)}}function ns(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return ns(e.expr);case"and":case"or":return ns(e.left)||ns(e.right);default:return!1}}function Oh(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=H8(e);if(z8(e)&&n.length===1){let i=n[0].split("/").filter(o=>o.length>0);if(i.length>=2)for(let o=i.length-2;o>=0;o--){let a=i[o];if(!a.includes("*")&&!a.includes("?")&&!a.includes("[")&&a!=="."&&a!==".."){let l=i[o+1];if(l&&(l.includes("*")||l.includes("?"))){t.terminalDirName=a;let c=l.match(/^\*(\.[a-zA-Z0-9]+)$/);c&&(t.requiredExtension=c[1])}break}}}return t}function H8(e){let t=[],n=r=>{r.type==="path"?t.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(e),t}function z8(e){let t=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?t(n.expr):n.type==="and"||n.type==="or"?t(n.left)||t(n.right):!1;return t(e)}function $h(e){let t=[],n=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),t}function rs(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return rs(e.expr);case"and":case"or":return rs(e.left)&&rs(e.right)}}function Gn(e,t,n,r,s){switch(e.type){case"name":{let i=e.pattern,o=i.match(/^\*(\.[a-zA-Z0-9]+)$/);if(o){let a=o[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:dt(t,i,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let i=e.pattern,o=i.split("/");for(let l=0;l<o.length-1;l++){let c=o[l];if(c&&c!=="."&&c!==".."&&!c.includes("*")&&!c.includes("?")&&!c.includes("[")){let u=`/${c}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let a=i.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let l=a[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(l))return{matches:!1,pruned:!1,printed:!1}}return{matches:dt(n,i,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let i=e.ignoreCase?"i":"";return{matches:V(e.pattern,i).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:r,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,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 i=Gn(e.expr,t,n,r,s);return{matches:!i.matches,pruned:i.pruned,printed:!1}}case"and":{let i=Gn(e.left,t,n,r,s);if(!i.matches)return{matches:!1,pruned:i.pruned,printed:!1};let o=Gn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:i.printed||o.printed}}case"or":{let i=Gn(e.left,t,n,r,s);if(i.matches)return i;let o=Gn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:o.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function ss(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return ss(e.expr);case"and":case"or":return ss(e.left)||ss(e.right);default:return!1}}function In(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return In(e.expr);case"and":case"or":return In(e.left)&&In(e.right)}}function Th(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!In(e))return ba(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Vt(e,n).pruned}}function ba(e,t){switch(e.type){case"or":{if(In(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(Vt(e.left,n).pruned)return{shouldPrune:!0}}return ba(e.right,t)}case"and":{if(In(e.left)&&In(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Vt(e,n).pruned}}if(In(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return Vt(e.left,n).matches?ba(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Ph=I(()=>{"use strict";Me();Vo()});function Dh(e,t){let n=[],r=[],s=t;for(;s<e.length;){let o=e[s];if(o==="("||o==="\\("){n.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){n.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(o==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(o==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(o==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<e.length){let a=e[++s];if(a==="f"||a==="d")n.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
493
+ `:"",stderr:""}}}});var Ih={};Q(Ih,{teeCommand:()=>B8});var U8,W8,B8,Oh=I(()=>{"use strict";qe();ne();U8={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"]},W8={append:{short:"a",long:"append",type:"boolean"}},B8={name:"tee",async execute(e,t){if(F(e))return M(U8);let n=we("tee",e,W8);if(!n.ok)return n.error;let{append:r}=n.result.flags,s=n.result.positional,i=t.stdin,o="",a=0;for(let l of s)try{let c=t.fs.resolvePath(t.cwd,l);r?await t.fs.appendFile(c,i):await t.fs.writeFile(c,i)}catch{o+=`tee: ${l}: No such file or directory
494
+ `,a=1}return{stdout:i,stderr:o,exitCode:a}}}});function Vt(e,t){switch(e.type){case"name":{let n=e.pattern,r=n.match(/^\*(\.[a-zA-Z0-9]+)$/);if(r){let s=r[1],i=t.name;if(e.ignoreCase){if(!i.toLowerCase().endsWith(s.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!i.endsWith(s))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:dt(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,r=t.relativePath,s=n.split("/");for(let o=0;o<s.length-1;o++){let a=s[o];if(a&&a!=="."&&a!==".."&&!a.includes("*")&&!a.includes("?")&&!a.includes("[")){let l=`/${a}/`;if(e.ignoreCase){if(!r.toLowerCase().includes(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.includes(l))return{matches:!1,pruned:!1,printed:!1}}}let i=n.match(/\*(\.[a-zA-Z0-9]+)$/);if(i){let o=i[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(o))return{matches:!1,pruned:!1,printed:!1}}return{matches:dt(r,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:V(e.pattern,n).test(t.relativePath),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:t.isFile,pruned:!1,printed:!1}:e.fileType==="d"?{matches:t.isDirectory,pruned:!1,printed:!1}:{matches:!1,pruned:!1,printed:!1};case"empty":return{matches:t.isEmpty,pruned:!1,printed:!1};case"mtime":{let r=(Date.now()-t.mtime)/(1e3*60*60*24),s;return e.comparison==="more"?s=r>e.days:e.comparison==="less"?s=r<e.days:s=Math.floor(r)===e.days,{matches:s,pruned:!1,printed:!1}}case"newer":{let n=t.newerRefTimes.get(e.refPath);return n===void 0?{matches:!1,pruned:!1,printed:!1}:{matches:t.mtime>n,pruned:!1,printed:!1}}case"size":{let n=e.value;switch(e.unit){case"c":n=e.value;break;case"k":n=e.value*1024;break;case"M":n=e.value*1024*1024;break;case"G":n=e.value*1024*1024*1024;break;case"b":n=e.value*512;break}let r;return e.comparison==="more"?r=t.size>n:e.comparison==="less"?r=t.size<n:e.unit==="b"?r=Math.ceil(t.size/512)===e.value:r=t.size===n,{matches:r,pruned:!1,printed:!1}}case"perm":{let n=t.mode&511,r=e.mode&511,s;return e.matchType==="exact"?s=n===r:e.matchType==="all"?s=(n&r)===r:s=(n&r)!==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 n=Vt(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=Vt(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=Vt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=Vt(e.left,t);if(n.matches)return n;let r=Vt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function ts(e){if(!e)return!1;switch(e.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 ts(e.expr);case"and":case"or":return ts(e.left)||ts(e.right)}}function ns(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return ns(e.expr);case"and":case"or":return ns(e.left)||ns(e.right);default:return!1}}function Rh(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=H8(e);if(z8(e)&&n.length===1){let i=n[0].split("/").filter(o=>o.length>0);if(i.length>=2)for(let o=i.length-2;o>=0;o--){let a=i[o];if(!a.includes("*")&&!a.includes("?")&&!a.includes("[")&&a!=="."&&a!==".."){let l=i[o+1];if(l&&(l.includes("*")||l.includes("?"))){t.terminalDirName=a;let c=l.match(/^\*(\.[a-zA-Z0-9]+)$/);c&&(t.requiredExtension=c[1])}break}}}return t}function H8(e){let t=[],n=r=>{r.type==="path"?t.push(r.pattern):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right))};return n(e),t}function z8(e){let t=n=>n.type==="type"&&n.fileType==="f"?!0:n.type==="not"?t(n.expr):n.type==="and"||n.type==="or"?t(n.left)||t(n.right):!1;return t(e)}function $h(e){let t=[],n=r=>{r&&(r.type==="newer"?t.push(r.refPath):r.type==="not"?n(r.expr):(r.type==="and"||r.type==="or")&&(n(r.left),n(r.right)))};return n(e),t}function rs(e){if(!e)return!0;switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return rs(e.expr);case"and":case"or":return rs(e.left)&&rs(e.right)}}function Gn(e,t,n,r,s){switch(e.type){case"name":{let i=e.pattern,o=i.match(/^\*(\.[a-zA-Z0-9]+)$/);if(o){let a=o[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(a))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:dt(t,i,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let i=e.pattern,o=i.split("/");for(let l=0;l<o.length-1;l++){let c=o[l];if(c&&c!=="."&&c!==".."&&!c.includes("*")&&!c.includes("?")&&!c.includes("[")){let u=`/${c}/`;if(e.ignoreCase){if(!n.toLowerCase().includes(u.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.includes(u))return{matches:!1,pruned:!1,printed:!1}}}let a=i.match(/\*(\.[a-zA-Z0-9]+)$/);if(a){let l=a[1];if(e.ignoreCase){if(!n.toLowerCase().endsWith(l.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!n.endsWith(l))return{matches:!1,pruned:!1,printed:!1}}return{matches:dt(n,i,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let i=e.ignoreCase?"i":"";return{matches:V(e.pattern,i).test(n),pruned:!1,printed:!1}}catch{return{matches:!1,pruned:!1,printed:!1}}case"type":return e.fileType==="f"?{matches:r,pruned:!1,printed:!1}:e.fileType==="d"?{matches:s,pruned:!1,printed:!1}:{matches:!1,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 i=Gn(e.expr,t,n,r,s);return{matches:!i.matches,pruned:i.pruned,printed:!1}}case"and":{let i=Gn(e.left,t,n,r,s);if(!i.matches)return{matches:!1,pruned:i.pruned,printed:!1};let o=Gn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:i.printed||o.printed}}case"or":{let i=Gn(e.left,t,n,r,s);if(i.matches)return i;let o=Gn(e.right,t,n,r,s);return{matches:o.matches,pruned:i.pruned||o.pruned,printed:o.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function ss(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return ss(e.expr);case"and":case"or":return ss(e.left)||ss(e.right);default:return!1}}function In(e){switch(e.type){case"name":case"path":case"regex":case"type":case"prune":case"print":return!0;case"empty":case"mtime":case"newer":case"size":case"perm":return!1;case"not":return In(e.expr);case"and":case"or":return In(e.left)&&In(e.right)}}function Th(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!In(e))return ba(e,t);let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Vt(e,n).pruned}}function ba(e,t){switch(e.type){case"or":{if(In(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};if(Vt(e.left,n).pruned)return{shouldPrune:!0}}return ba(e.right,t)}case"and":{if(In(e.left)&&In(e.right)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return{shouldPrune:Vt(e,n).pruned}}if(In(e.left)){let n={name:t.name,relativePath:t.relativePath,isFile:t.isFile,isDirectory:t.isDirectory,isEmpty:!1,mtime:0,size:0,mode:0,newerRefTimes:new Map};return Vt(e.left,n).matches?ba(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Ph=I(()=>{"use strict";Me();Vo()});function Dh(e,t){let n=[],r=[],s=t;for(;s<e.length;){let o=e[s];if(o==="("||o==="\\("){n.push({type:"lparen"}),s++;continue}if(o===")"||o==="\\)"){n.push({type:"rparen"}),s++;continue}if(o==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(o==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(o==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(o==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(o==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(o==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(o==="-type"&&s+1<e.length){let a=e[++s];if(a==="f"||a==="d")n.push({type:"expr",expr:{type:"type",fileType:a}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${a}
495
495
  `,actions:[]}}else if(o==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(o==="-mtime"&&s+1<e.length){let a=e[++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)||n.push({type:"expr",expr:{type:"mtime",days:u,comparison:l}})}else if(o==="-newer"&&s+1<e.length){let a=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:a}})}else if(o==="-size"&&s+1<e.length){let a=e[++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),h=u[2]||"b";n.push({type:"expr",expr:{type:"size",value:f,unit:h,comparison:l}})}}else if(o==="-perm"&&s+1<e.length){let a=e[++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)||n.push({type:"expr",expr:{type:"perm",mode:u,matchType:l}})}else if(o==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(o==="-not"||o==="!")n.push({type:"not"});else if(o==="-o"||o==="-or")n.push({type:"op",op:"or"});else if(o==="-a"||o==="-and")n.push({type:"op",op:"and"});else if(o==="-maxdepth"||o==="-mindepth")s++;else if(o!=="-depth")if(o==="-exec"){let a=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)a.push(e[s]),s++;if(s>=e.length)return{expr:null,pathIndex:s,error:"find: missing argument to `-exec'\n",actions:[]};let l=e[s]==="+";r.push({type:"exec",command:a,batchMode:l})}else if(o==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(o==="-print0")r.push({type:"print0"});else if(o==="-printf"&&s+1<e.length){let a=e[++s];r.push({type:"printf",format:a})}else if(o==="-delete")r.push({type:"delete"});else{if(o.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${o}'
496
- `,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let i=j8(n);return i.error?{expr:null,pathIndex:s,error:i.error,actions:r}:{expr:i.expr,pathIndex:s,actions:r}}function j8(e){let t=0;function n(){let a=r();if(!a)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="or"){t++;let c=r();if(!c)return a;a={type:"or",left:a,right:c}}else break}return a}function r(){let a=s();if(!a)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="and"){t++;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(t<e.length&&e[t].type==="not"){t++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(t>=e.length)return null;let a=e[t];if(a.type==="lparen"){t++;let l=n();return t<e.length&&e[t].type==="rparen"&&t++,l}return a.type==="expr"?(t++,a.expr):(a.type==="rparen",null)}return{expr:n()}}var Lh=I(()=>{"use strict"});var Mh={};Q(Mh,{findCommand:()=>Q8});function G8(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function V8(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}function K8(e,t){let n=Ps(e),r="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){r+="%",s++;continue}let[i,o,a]=iu(n,s);if(s+=a,s>=n.length){r+="%";break}let l=n[s],c;switch(l){case"f":c=t.name,s++;break;case"h":{let u=t.path.lastIndexOf("/");c=u>0?t.path.slice(0,u):".",s++;break}case"p":c=t.path,s++;break;case"P":{let u=t.startingPoint;t.path===u?c="":t.path.startsWith(`${u}/`)?c=t.path.slice(u.length+1):u==="."&&t.path.startsWith("./")?c=t.path.slice(2):c=t.path,s++;break}case"s":c=String(t.size),s++;break;case"d":c=String(t.depth),s++;break;case"m":c=(t.mode&511).toString(8),s++;break;case"M":c=X8(t.mode,t.isDirectory),s++;break;case"t":{let u=new Date(t.mtime);c=Y8(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(t.mtime);c=J8(f,u),s+=2}else c="%T",s++;break}default:r+=`%${i!==0||o!==-1?`${i}.${o}`:""}${l}`,s++;continue}r+=Ts(c,i,o)}else r+=n[s],s++;return r}function X8(e,t){let n=e&511,r=t?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function Y8(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=t[e.getDay()],s=n[e.getMonth()],i=String(e.getDate()).padStart(2," "),o=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0"),c=e.getFullYear();return`${r} ${s} ${i} ${o}:${a}:${l} ${c}`}function J8(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var _h,q8,Z8,Q8,Fh=I(()=>{"use strict";ne();vo();Ph();Lh();_h=500;q8={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"]},Z8=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),Q8={name:"find",async execute(e,t){if(U(e))return F(q8);let n=[],r=null,s=null,i=!1,o=!1;for(let k=0;k<e.length;k++){let T=e[k];if(T==="-maxdepth"&&k+1<e.length)o=!0,r=parseInt(e[++k],10);else if(T==="-mindepth"&&k+1<e.length)o=!0,s=parseInt(e[++k],10);else if(T==="-depth")o=!0,i=!0;else if(T==="-exec")for(o=!0,k++;k<e.length&&e[k]!==";"&&e[k]!=="+";)k++;else!T.startsWith("-")&&T!==";"&&T!=="+"&&T!=="("&&T!==")"&&T!=="\\("&&T!=="\\)"&&T!=="!"?o||n.push(T):Z8.has(T)?(o=!0,k++):(T.startsWith("-")||T==="("||T==="\\("||T==="!")&&(o=!0)}n.length===0&&n.push(".");let{expr:a,error:l,actions:c}=Dh(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some(k=>k.type==="print"),f=c.length===0,h=[],p=c.some(k=>k.type==="printf"),m=[],d="",g=0,y=$h(a),w=new Map;for(let k of y){let T=t.fs.resolvePath(t.cwd,k);try{let R=await t.fs.stat(T);w.set(k,R.mtime?.getTime()??Date.now())}catch{}}let b=c.some(k=>{if(k.type!=="printf")return!1;let T=k.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(T)}),x=ts(a)||b,S=ns(a),C=Oh(a),$=ss(a),M=rs(a),_=typeof t.fs.readdirWithFileTypes=="function";for(let k of n){let ie=function(z){let Ee=s===null||z.depth>=s,oe=!1;if(Ee&&a!==null){let j=Date.now(),ve;if(M)ve=Gn(a,z.name,z.relativePath,z.isFile,z.isDirectory);else{let _e={name:z.name,relativePath:z.relativePath,isFile:z.isFile,isDirectory:z.isDirectory,isEmpty:z.isEmpty,mtime:z.stat?.mtime?.getTime()??Date.now(),size:z.stat?.size??0,mode:z.stat?.mode??420,newerRefTimes:w};ve=Vt(a,_e)}Ee=ve.matches,oe=u?ve.printed:Ee,R.evalCalls++,R.evalTime+=Date.now()-j}else Ee&&(oe=!0);return oe?{print:!0,printfData:p?{path:z.relativePath,name:z.name,size:z.stat?.size??0,mtime:z.stat?.mtime?.getTime()??Date.now(),mode:z.stat?.mode??420,isDirectory:z.isDirectory,depth:z.depth,startingPoint:k}:null}:{print:!1,printfData:null}};var v=ie;k.length>1&&k.endsWith("/")&&(k=k.slice(0,-1));let T=t.fs.resolvePath(t.cwd,k);try{await t.fs.stat(T)}catch{d+=`find: ${k}: No such file or directory
497
- `,g=1;continue}let R=G8(),O=Date.now();async function L(z){let{path:ee,depth:Ee,typeInfo:oe}=z;if(R.nodeCount++,r!==null&&Ee>r)return null;let ke,j,ve;if(oe&&!x)ke=oe.isFile,j=oe.isDirectory;else{try{let Wn=Date.now();ve=await t.fs.stat(ee),R.statCalls++,R.statTime+=Date.now()-Wn}catch{return null}if(!ve)return null;ke=ve.isFile,j=ve.isDirectory}let _e;ee===T?_e=k.split("/").pop()||k:_e=ee.split("/").pop()||"";let ze=ee===T?k:k==="."?`./${ee.slice(T==="/"?T.length:T.length+1)}`:k+ee.slice(T.length),Ye=[],nt=null,Je=null,et=!1;j&&$&&!i&&(et=Th(a,{name:_e,relativePath:ze,isFile:ke,isDirectory:j}).shouldPrune,et&&R.earlyPrunes++);let Lt=r!==null&&Ee>=r,_t=C.terminalDirName!==null&&_e===C.terminalDirName,Gr=!Lt&&!_t&&!et;if(j&&((Gr||S||_t)&&!et)){let Wn=Date.now();if(_&&t.fs.readdirWithFileTypes){if(nt=await t.fs.readdirWithFileTypes(ee),Je=nt.map(St=>St.name),R.readdirCalls++,R.readdirTime+=Date.now()-Wn,Gr)Ye=nt.map((St,zt)=>({path:ee==="/"?`/${St.name}`:`${ee}/${St.name}`,depth:Ee+1,typeInfo:{isFile:St.isFile,isDirectory:St.isDirectory},resultIndex:zt}));else if(_t){let St=C.requiredExtension;Ye=nt.filter(zt=>zt.isFile&&(!St||zt.name.endsWith(St))).map((zt,bg)=>({path:ee==="/"?`/${zt.name}`:`${ee}/${zt.name}`,depth:Ee+1,typeInfo:{isFile:zt.isFile,isDirectory:zt.isDirectory},resultIndex:bg}))}}else Je=await t.fs.readdir(ee),R.readdirCalls++,R.readdirTime+=Date.now()-Wn,Gr&&(Ye=Je.map((St,zt)=>({path:ee==="/"?`/${St}`:`${ee}/${St}`,depth:Ee+1,resultIndex:zt})))}let Os=ke?(ve?.size??0)===0:Je!==null&&Je.length===0,ir=et;if(!i&&a!==null&&!et&&$){let Wn=Date.now(),St={name:_e,relativePath:ze,isFile:ke,isDirectory:j,isEmpty:Os,mtime:ve?.mtime?.getTime()??Date.now(),size:ve?.size??0,mode:ve?.mode??420,newerRefTimes:w};ir=Vt(a,St).pruned,R.evalCalls++,R.evalTime+=Date.now()-Wn}return{relativePath:ze,name:_e,isFile:ke,isDirectory:j,isEmpty:Os,stat:ve,depth:Ee,children:ir?[]:Ye,pruned:ir}}async function ue(){let z={paths:[],printfData:[]};if(i){let ve=function(_e){let ze={paths:[],printfData:[]},Ye=oe[_e];if(!Ye)return ze;for(let et of Ye.childIndices){let Lt=ve(et);ze.paths.push(...Lt.paths),ze.printfData.push(...Lt.printfData)}let{print:nt,printfData:Je}=ie(Ye.node);return nt&&(ze.paths.push(Ye.node.relativePath),Je&&ze.printfData.push(Je)),ze};var ee=ve;let oe=[],ke=[{item:{path:T,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],j=new Map;for(;ke.length>0;){let _e=Date.now(),ze=ke.splice(0,_h),Ye=await Promise.all(ze.map(nt=>L(nt.item)));R.batchCount++,R.batchTime+=Date.now()-_e;for(let nt=0;nt<ze.length;nt++){let Je=Ye[nt],et=ze[nt];if(!Je)continue;let Lt=oe.length;if(et.parentIndex>=0){let _t=j.get(et.parentIndex)||[];_t.push(Lt),j.set(et.parentIndex,_t)}oe.push({node:Je,parentIndex:et.parentIndex,childIndices:[]});for(let _t=0;_t<Je.children.length;_t++)ke.push({item:Je.children[_t],parentIndex:Lt,childOrderInParent:_t})}}for(let[_e,ze]of j)_e>=0&&_e<oe.length&&(oe[_e].childIndices=ze);if(oe.length>0){let _e=ve(0);z.paths.push(..._e.paths),z.printfData.push(..._e.printfData)}}else{let _e=function(ze){let Ye=oe.get(ze);Ye&&(z.paths.push(Ye.path),Ye.printfData&&z.printfData.push(Ye.printfData));let nt=ve.get(ze);if(nt)for(let Je of nt)_e(Je)};var Ee=_e;let oe=new Map,ke=0,j=[{item:{path:T,depth:0,resultIndex:0},orderIndex:ke++}],ve=new Map;for(;j.length>0;){let ze=Date.now(),Ye=j.splice(0,_h),nt=await Promise.all(Ye.map(async({item:Je,orderIndex:et})=>{let Lt=await L(Je);return Lt?{node:Lt,orderIndex:et}:null}));R.batchCount++,R.batchTime+=Date.now()-ze;for(let Je of nt){if(!Je)continue;let{node:et,orderIndex:Lt}=Je,{print:_t,printfData:Gr}=ie(et);if(_t&&oe.set(Lt,{path:et.relativePath,printfData:Gr}),et.children.length>0){let No=[];for(let Os of et.children){let ir=ke++;No.push(ir),j.push({item:Os,orderIndex:ir})}ve.set(Lt,No)}}}_e(0)}return z}let te=await ue();if(h.push(...te.paths),m.push(...te.printfData),t.trace){let z=Date.now()-O;V8(t.trace,R,z),t.trace({category:"find",name:"searchPath",durationMs:z,details:{path:k,resultsFound:te.paths.length}})}}let B="";if(c.length>0)for(let k of c)switch(k.type){case"print":B+=h.length>0?`${h.join(`
496
+ `,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let i=j8(n);return i.error?{expr:null,pathIndex:s,error:i.error,actions:r}:{expr:i.expr,pathIndex:s,actions:r}}function j8(e){let t=0;function n(){let a=r();if(!a)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="or"){t++;let c=r();if(!c)return a;a={type:"or",left:a,right:c}}else break}return a}function r(){let a=s();if(!a)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="and"){t++;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(t<e.length&&e[t].type==="not"){t++;let a=s();return a?{type:"not",expr:a}:null}return i()}function i(){if(t>=e.length)return null;let a=e[t];if(a.type==="lparen"){t++;let l=n();return t<e.length&&e[t].type==="rparen"&&t++,l}return a.type==="expr"?(t++,a.expr):(a.type==="rparen",null)}return{expr:n()}}var Lh=I(()=>{"use strict"});var Mh={};Q(Mh,{findCommand:()=>Q8});function G8(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function V8(e,t,n){e({category:"find",name:"summary",durationMs:n,details:{readdirCalls:t.readdirCalls,readdirTimeMs:t.readdirTime,statCalls:t.statCalls,statTimeMs:t.statTime,evalCalls:t.evalCalls,evalTimeMs:t.evalTime,nodeCount:t.nodeCount,batchCount:t.batchCount,batchTimeMs:t.batchTime,earlyPrunes:t.earlyPrunes,otherTimeMs:n-t.readdirTime-t.statTime-t.evalTime-t.batchTime}})}function K8(e,t){let n=Ps(e),r="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){r+="%",s++;continue}let[i,o,a]=iu(n,s);if(s+=a,s>=n.length){r+="%";break}let l=n[s],c;switch(l){case"f":c=t.name,s++;break;case"h":{let u=t.path.lastIndexOf("/");c=u>0?t.path.slice(0,u):".",s++;break}case"p":c=t.path,s++;break;case"P":{let u=t.startingPoint;t.path===u?c="":t.path.startsWith(`${u}/`)?c=t.path.slice(u.length+1):u==="."&&t.path.startsWith("./")?c=t.path.slice(2):c=t.path,s++;break}case"s":c=String(t.size),s++;break;case"d":c=String(t.depth),s++;break;case"m":c=(t.mode&511).toString(8),s++;break;case"M":c=X8(t.mode,t.isDirectory),s++;break;case"t":{let u=new Date(t.mtime);c=Y8(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(t.mtime);c=J8(f,u),s+=2}else c="%T",s++;break}default:r+=`%${i!==0||o!==-1?`${i}.${o}`:""}${l}`,s++;continue}r+=Ts(c,i,o)}else r+=n[s],s++;return r}function X8(e,t){let n=e&511,r=t?"d":"-";return r+=n&256?"r":"-",r+=n&128?"w":"-",r+=n&64?"x":"-",r+=n&32?"r":"-",r+=n&16?"w":"-",r+=n&8?"x":"-",r+=n&4?"r":"-",r+=n&2?"w":"-",r+=n&1?"x":"-",r}function Y8(e){let t=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],r=t[e.getDay()],s=n[e.getMonth()],i=String(e.getDate()).padStart(2," "),o=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0"),c=e.getFullYear();return`${r} ${s} ${i} ${o}:${a}:${l} ${c}`}function J8(e,t){switch(t){case"@":return String(e.getTime()/1e3);case"Y":return String(e.getFullYear());case"m":return String(e.getMonth()+1).padStart(2,"0");case"d":return String(e.getDate()).padStart(2,"0");case"H":return String(e.getHours()).padStart(2,"0");case"M":return String(e.getMinutes()).padStart(2,"0");case"S":return String(e.getSeconds()).padStart(2,"0");case"T":return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}:${String(e.getSeconds()).padStart(2,"0")}`;case"F":return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`;default:return`%T${t}`}}var _h,q8,Z8,Q8,Fh=I(()=>{"use strict";ne();vo();Ph();Lh();_h=500;q8={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"]},Z8=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),Q8={name:"find",async execute(e,t){if(F(e))return M(q8);let n=[],r=null,s=null,i=!1,o=!1;for(let k=0;k<e.length;k++){let T=e[k];if(T==="-maxdepth"&&k+1<e.length)o=!0,r=parseInt(e[++k],10);else if(T==="-mindepth"&&k+1<e.length)o=!0,s=parseInt(e[++k],10);else if(T==="-depth")o=!0,i=!0;else if(T==="-exec")for(o=!0,k++;k<e.length&&e[k]!==";"&&e[k]!=="+";)k++;else!T.startsWith("-")&&T!==";"&&T!=="+"&&T!=="("&&T!==")"&&T!=="\\("&&T!=="\\)"&&T!=="!"?o||n.push(T):Z8.has(T)?(o=!0,k++):(T.startsWith("-")||T==="("||T==="\\("||T==="!")&&(o=!0)}n.length===0&&n.push(".");let{expr:a,error:l,actions:c}=Dh(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some(k=>k.type==="print"),f=c.length===0,h=[],p=c.some(k=>k.type==="printf"),m=[],d="",g=0,y=$h(a),w=new Map;for(let k of y){let T=t.fs.resolvePath(t.cwd,k);try{let O=await t.fs.stat(T);w.set(k,O.mtime?.getTime()??Date.now())}catch{}}let b=c.some(k=>{if(k.type!=="printf")return!1;let T=k.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(T)}),x=ts(a)||b,S=ns(a),C=Rh(a),R=ss(a),U=rs(a),L=typeof t.fs.readdirWithFileTypes=="function";for(let k of n){let ie=function(z){let Ee=s===null||z.depth>=s,oe=!1;if(Ee&&a!==null){let j=Date.now(),ve;if(U)ve=Gn(a,z.name,z.relativePath,z.isFile,z.isDirectory);else{let _e={name:z.name,relativePath:z.relativePath,isFile:z.isFile,isDirectory:z.isDirectory,isEmpty:z.isEmpty,mtime:z.stat?.mtime?.getTime()??Date.now(),size:z.stat?.size??0,mode:z.stat?.mode??420,newerRefTimes:w};ve=Vt(a,_e)}Ee=ve.matches,oe=u?ve.printed:Ee,O.evalCalls++,O.evalTime+=Date.now()-j}else Ee&&(oe=!0);return oe?{print:!0,printfData:p?{path:z.relativePath,name:z.name,size:z.stat?.size??0,mtime:z.stat?.mtime?.getTime()??Date.now(),mode:z.stat?.mode??420,isDirectory:z.isDirectory,depth:z.depth,startingPoint:k}:null}:{print:!1,printfData:null}};var v=ie;k.length>1&&k.endsWith("/")&&(k=k.slice(0,-1));let T=t.fs.resolvePath(t.cwd,k);try{await t.fs.stat(T)}catch{d+=`find: ${k}: No such file or directory
497
+ `,g=1;continue}let O=G8(),$=Date.now();async function _(z){let{path:ee,depth:Ee,typeInfo:oe}=z;if(O.nodeCount++,r!==null&&Ee>r)return null;let ke,j,ve;if(oe&&!x)ke=oe.isFile,j=oe.isDirectory;else{try{let Wn=Date.now();ve=await t.fs.stat(ee),O.statCalls++,O.statTime+=Date.now()-Wn}catch{return null}if(!ve)return null;ke=ve.isFile,j=ve.isDirectory}let _e;ee===T?_e=k.split("/").pop()||k:_e=ee.split("/").pop()||"";let ze=ee===T?k:k==="."?`./${ee.slice(T==="/"?T.length:T.length+1)}`:k+ee.slice(T.length),Ye=[],nt=null,Je=null,et=!1;j&&R&&!i&&(et=Th(a,{name:_e,relativePath:ze,isFile:ke,isDirectory:j}).shouldPrune,et&&O.earlyPrunes++);let Lt=r!==null&&Ee>=r,_t=C.terminalDirName!==null&&_e===C.terminalDirName,Gr=!Lt&&!_t&&!et;if(j&&((Gr||S||_t)&&!et)){let Wn=Date.now();if(L&&t.fs.readdirWithFileTypes){if(nt=await t.fs.readdirWithFileTypes(ee),Je=nt.map(St=>St.name),O.readdirCalls++,O.readdirTime+=Date.now()-Wn,Gr)Ye=nt.map((St,zt)=>({path:ee==="/"?`/${St.name}`:`${ee}/${St.name}`,depth:Ee+1,typeInfo:{isFile:St.isFile,isDirectory:St.isDirectory},resultIndex:zt}));else if(_t){let St=C.requiredExtension;Ye=nt.filter(zt=>zt.isFile&&(!St||zt.name.endsWith(St))).map((zt,bg)=>({path:ee==="/"?`/${zt.name}`:`${ee}/${zt.name}`,depth:Ee+1,typeInfo:{isFile:zt.isFile,isDirectory:zt.isDirectory},resultIndex:bg}))}}else Je=await t.fs.readdir(ee),O.readdirCalls++,O.readdirTime+=Date.now()-Wn,Gr&&(Ye=Je.map((St,zt)=>({path:ee==="/"?`/${St}`:`${ee}/${St}`,depth:Ee+1,resultIndex:zt})))}let Rs=ke?(ve?.size??0)===0:Je!==null&&Je.length===0,ir=et;if(!i&&a!==null&&!et&&R){let Wn=Date.now(),St={name:_e,relativePath:ze,isFile:ke,isDirectory:j,isEmpty:Rs,mtime:ve?.mtime?.getTime()??Date.now(),size:ve?.size??0,mode:ve?.mode??420,newerRefTimes:w};ir=Vt(a,St).pruned,O.evalCalls++,O.evalTime+=Date.now()-Wn}return{relativePath:ze,name:_e,isFile:ke,isDirectory:j,isEmpty:Rs,stat:ve,depth:Ee,children:ir?[]:Ye,pruned:ir}}async function ue(){let z={paths:[],printfData:[]};if(i){let ve=function(_e){let ze={paths:[],printfData:[]},Ye=oe[_e];if(!Ye)return ze;for(let et of Ye.childIndices){let Lt=ve(et);ze.paths.push(...Lt.paths),ze.printfData.push(...Lt.printfData)}let{print:nt,printfData:Je}=ie(Ye.node);return nt&&(ze.paths.push(Ye.node.relativePath),Je&&ze.printfData.push(Je)),ze};var ee=ve;let oe=[],ke=[{item:{path:T,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],j=new Map;for(;ke.length>0;){let _e=Date.now(),ze=ke.splice(0,_h),Ye=await Promise.all(ze.map(nt=>_(nt.item)));O.batchCount++,O.batchTime+=Date.now()-_e;for(let nt=0;nt<ze.length;nt++){let Je=Ye[nt],et=ze[nt];if(!Je)continue;let Lt=oe.length;if(et.parentIndex>=0){let _t=j.get(et.parentIndex)||[];_t.push(Lt),j.set(et.parentIndex,_t)}oe.push({node:Je,parentIndex:et.parentIndex,childIndices:[]});for(let _t=0;_t<Je.children.length;_t++)ke.push({item:Je.children[_t],parentIndex:Lt,childOrderInParent:_t})}}for(let[_e,ze]of j)_e>=0&&_e<oe.length&&(oe[_e].childIndices=ze);if(oe.length>0){let _e=ve(0);z.paths.push(..._e.paths),z.printfData.push(..._e.printfData)}}else{let _e=function(ze){let Ye=oe.get(ze);Ye&&(z.paths.push(Ye.path),Ye.printfData&&z.printfData.push(Ye.printfData));let nt=ve.get(ze);if(nt)for(let Je of nt)_e(Je)};var Ee=_e;let oe=new Map,ke=0,j=[{item:{path:T,depth:0,resultIndex:0},orderIndex:ke++}],ve=new Map;for(;j.length>0;){let ze=Date.now(),Ye=j.splice(0,_h),nt=await Promise.all(Ye.map(async({item:Je,orderIndex:et})=>{let Lt=await _(Je);return Lt?{node:Lt,orderIndex:et}:null}));O.batchCount++,O.batchTime+=Date.now()-ze;for(let Je of nt){if(!Je)continue;let{node:et,orderIndex:Lt}=Je,{print:_t,printfData:Gr}=ie(et);if(_t&&oe.set(Lt,{path:et.relativePath,printfData:Gr}),et.children.length>0){let No=[];for(let Rs of et.children){let ir=ke++;No.push(ir),j.push({item:Rs,orderIndex:ir})}ve.set(Lt,No)}}}_e(0)}return z}let te=await ue();if(h.push(...te.paths),m.push(...te.printfData),t.trace){let z=Date.now()-$;V8(t.trace,O,z),t.trace({category:"find",name:"searchPath",durationMs:z,details:{path:k,resultsFound:te.paths.length}})}}let B="";if(c.length>0)for(let k of c)switch(k.type){case"print":B+=h.length>0?`${h.join(`
498
498
  `)}
499
- `:"";break;case"print0":B+=h.length>0?`${h.join("\0")}\0`:"";break;case"delete":{let T=[...h].sort((R,O)=>O.length-R.length);for(let R of T){let O=t.fs.resolvePath(t.cwd,R);try{await t.fs.rm(O,{recursive:!1})}catch(L){let ie=L instanceof Error?L.message:String(L);d+=`find: cannot delete '${R}': ${ie}
499
+ `:"";break;case"print0":B+=h.length>0?`${h.join("\0")}\0`:"";break;case"delete":{let T=[...h].sort((O,$)=>$.length-O.length);for(let O of T){let $=t.fs.resolvePath(t.cwd,O);try{await t.fs.rm($,{recursive:!1})}catch(_){let ie=_ instanceof Error?_.message:String(_);d+=`find: cannot delete '${O}': ${ie}
500
500
  `,g=1}}break}case"printf":for(let T of m)B+=K8(k.format,T);break;case"exec":if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
501
- `,exitCode:1};if(k.batchMode){let T=[];for(let L of k.command)L==="{}"?T.push(...h):T.push(L);let R=T.map(L=>`"${L}"`).join(" "),O=await t.exec(R,{cwd:t.cwd});B+=O.stdout,d+=O.stderr,O.exitCode!==0&&(g=O.exitCode)}else for(let T of h){let O=k.command.map(ie=>ie==="{}"?T:ie).map(ie=>`"${ie}"`).join(" "),L=await t.exec(O,{cwd:t.cwd});B+=L.stdout,d+=L.stderr,L.exitCode!==0&&(g=L.exitCode)}break}else f&&(B=h.length>0?`${h.join(`
501
+ `,exitCode:1};if(k.batchMode){let T=[];for(let _ of k.command)_==="{}"?T.push(...h):T.push(_);let O=T.map(_=>`"${_}"`).join(" "),$=await t.exec(O,{cwd:t.cwd});B+=$.stdout,d+=$.stderr,$.exitCode!==0&&(g=$.exitCode)}else for(let T of h){let $=k.command.map(ie=>ie==="{}"?T:ie).map(ie=>`"${ie}"`).join(" "),_=await t.exec($,{cwd:t.cwd});B+=_.stdout,d+=_.stderr,_.exitCode!==0&&(g=_.exitCode)}break}else f&&(B=h.length>0?`${h.join(`
502
502
  `)}
503
503
  `:"");return{stdout:B,stderr:d,exitCode:g}}}});var Uh={};Q(Uh,{basenameCommand:()=>ty});var ey,ty,Wh=I(()=>{"use strict";ne();ey={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX]
504
- basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},ty={name:"basename",async execute(e,t){if(U(e))return F(ey);let n=!1,r="",s=[];for(let o=0;o<e.length;o++){let a=e[o];a==="-a"||a==="--multiple"?n=!0:a==="-s"&&o+1<e.length?(r=e[++o],n=!0):a.startsWith("--suffix=")?(r=a.slice(9),n=!0):a.startsWith("-")||s.push(a)}if(s.length===0)return{stdout:"",stderr:`basename: missing operand
504
+ basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},ty={name:"basename",async execute(e,t){if(F(e))return M(ey);let n=!1,r="",s=[];for(let o=0;o<e.length;o++){let a=e[o];a==="-a"||a==="--multiple"?n=!0:a==="-s"&&o+1<e.length?(r=e[++o],n=!0):a.startsWith("--suffix=")?(r=a.slice(9),n=!0):a.startsWith("-")||s.push(a)}if(s.length===0)return{stdout:"",stderr:`basename: missing operand
505
505
  `,exitCode:1};!n&&s.length>=2&&(r=s.pop()??"");let i=[];for(let o of s){let a=o.replace(/\/+$/,""),l=a.split("/").pop()||a;r&&l.endsWith(r)&&(l=l.slice(0,-r.length)),i.push(l)}return{stdout:`${i.join(`
506
506
  `)}
507
- `,stderr:"",exitCode:0}}}});var Bh={};Q(Bh,{dirnameCommand:()=>ry});var ny,ry,Hh=I(()=>{"use strict";ne();ny={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},ry={name:"dirname",async execute(e,t){if(U(e))return F(ny);let n=e.filter(s=>!s.startsWith("-"));if(n.length===0)return{stdout:"",stderr:`dirname: missing operand
507
+ `,stderr:"",exitCode:0}}}});var Bh={};Q(Bh,{dirnameCommand:()=>ry});var ny,ry,Hh=I(()=>{"use strict";ne();ny={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},ry={name:"dirname",async execute(e,t){if(F(e))return M(ny);let n=e.filter(s=>!s.startsWith("-"));if(n.length===0)return{stdout:"",stderr:`dirname: missing operand
508
508
  `,exitCode:1};let r=[];for(let s of n){let i=s.replace(/\/+$/,""),o=i.lastIndexOf("/");o===-1?r.push("."):o===0?r.push("/"):r.push(i.slice(0,o))}return{stdout:`${r.join(`
509
509
  `)}
510
510
  `,stderr:"",exitCode:0}}}});var jh={};Q(jh,{treeCommand:()=>oy});async function ay(e,t,n,r,s){let i={output:"",stderr:"",dirCount:0,fileCount:0},o=e.fs.resolvePath(e.cwd,t);try{if(!(await e.fs.stat(o)).isDirectory)return i.output=`${t}
@@ -515,36 +515,36 @@ basename OPTION... NAME...`,options:["-a, --multiple support multiple argument
515
515
  `}}}catch{i.stderr=`tree: ${t}: Permission denied
516
516
  `}return i}async function zh(e,t,n,r,s){let i={output:"",stderr:"",dirCount:0,fileCount:0};if(n.maxDepth!==null&&s>=n.maxDepth)return i;try{let o=[];if(e.fs.readdirWithFileTypes)o=(await e.fs.readdirWithFileTypes(t)).map(c=>({name:c.name,isDirectory:c.isDirectory}));else{let l=await e.fs.readdir(t);for(let c=0;c<l.length;c+=100){let u=l.slice(c,c+100),f=await Promise.all(u.map(async h=>{let p=t==="/"?`/${h}`:`${t}/${h}`;try{let m=await e.fs.stat(p);return{name:h,isDirectory:m.isDirectory}}catch{return null}}));o.push(...f.filter(h=>h!==null))}}let a=o.filter(l=>!(!n.showHidden&&l.name.startsWith(".")||n.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=t==="/"?`/${c.name}`:`${t}/${c.name}`,f=l===a.length-1,h=f?"`-- ":"|-- ",p=r+(f?" ":"| ");if(c.isDirectory){i.dirCount++;let m=n.fullPath?u:c.name;i.output+=`${r+h+m}
517
517
  `;let d=await zh(e,u,n,p,s+1);i.output+=d.output,i.dirCount+=d.dirCount,i.fileCount+=d.fileCount}else{i.fileCount++;let m=n.fullPath?u:c.name;i.output+=`${r+h+m}
518
- `}}}catch{}return i}var sy,iy,oy,Gh=I(()=>{"use strict";qe();or();ne();sy={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"]},iy={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},oy={name:"tree",async execute(e,t){if(U(e))return F(sy);let n=we("tree",e,iy);if(!n.ok)return n.error;let r={showHidden:n.result.flags.showHidden,directoriesOnly:n.result.flags.directoriesOnly,maxDepth:n.result.flags.maxDepth??null,fullPath:n.result.flags.fullPath},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0,l=0;for(let c of s){let u=await ay(t,c,r,"",0);i+=u.output,o+=u.stderr,a+=u.dirCount,l+=u.fileCount}return i+=`
518
+ `}}}catch{}return i}var sy,iy,oy,Gh=I(()=>{"use strict";qe();or();ne();sy={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"]},iy={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},oy={name:"tree",async execute(e,t){if(F(e))return M(sy);let n=we("tree",e,iy);if(!n.ok)return n.error;let r={showHidden:n.result.flags.showHidden,directoriesOnly:n.result.flags.directoriesOnly,maxDepth:n.result.flags.maxDepth??null,fullPath:n.result.flags.fullPath},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0,l=0;for(let c of s){let u=await ay(t,c,r,"",0);i+=u.output,o+=u.stderr,a+=u.dirCount,l+=u.fileCount}return i+=`
519
519
  ${a} director${a===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"s"}`),i+=`
520
520
  `,{stdout:i,stderr:o,exitCode:o?1:0}}}});var qh={};Q(qh,{duCommand:()=>uy});async function Vh(e,t,n,r,s){let i={output:"",totalSize:0,stderr:""};try{let o=await e.fs.stat(t);if(!o.isDirectory)return i.totalSize=o.size,(r.allFiles||s===0)&&(i.output=li(o.size,r.humanReadable)+" "+n+`
521
521
  `),i;let a=0,l=[];if(e.fs.readdirWithFileTypes){let f=await e.fs.readdirWithFileTypes(t),h=f.filter(m=>m.isFile),p=f.filter(m=>m.isDirectory);for(let m=0;m<h.length;m+=100){let d=h.slice(m,m+100),g=await Promise.all(d.map(async y=>{let w=t==="/"?`/${y.name}`:`${t}/${y.name}`;try{let b=await e.fs.stat(w);return{name:y.name,isDirectory:!1,size:b.size}}catch{return{name:y.name,isDirectory:!1,size:0}}}));l.push(...g)}l.push(...p.map(m=>({name:m.name,isDirectory:!0})))}else{let f=await e.fs.readdir(t);for(let h=0;h<f.length;h+=100){let p=f.slice(h,h+100),m=await Promise.all(p.map(async d=>{let g=t==="/"?`/${d}`:`${t}/${d}`;try{let y=await e.fs.stat(g);return{name:d,isDirectory:y.isDirectory,size:y.isDirectory?void 0:y.size}}catch{return{name:d,isDirectory:!1,size:0}}}));l.push(...m)}}l.sort((f,h)=>f.name.localeCompare(h.name));let c=l.filter(f=>!f.isDirectory);for(let f of c){let h=f.size??0;if(a+=h,r.allFiles&&!r.summarize){let p=n==="."?f.name:`${n}/${f.name}`;i.output+=li(h,r.humanReadable)+" "+p+`
522
522
  `}}let u=l.filter(f=>f.isDirectory);for(let f=0;f<u.length;f+=100){let h=u.slice(f,f+100),p=await Promise.all(h.map(async m=>{let d=t==="/"?`/${m.name}`:`${t}/${m.name}`,g=n==="."?m.name:`${n}/${m.name}`;return{name:m.name,result:await Vh(e,d,g,r,s+1)}}));p.sort((m,d)=>m.name.localeCompare(d.name));for(let{result:m}of p)a+=m.totalSize,r.summarize||(r.maxDepth===null||s+1<=r.maxDepth)&&(i.output+=m.output)}i.totalSize=a,(r.summarize||r.maxDepth===null||s<=r.maxDepth)&&(i.output+=`${li(a,r.humanReadable)} ${n}
523
523
  `)}catch{i.stderr=`du: cannot read directory '${n}': Permission denied
524
- `}return i}function li(e,t){return t?e<1024?`${e}`:e<1024*1024?`${(e/1024).toFixed(1)}K`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)}M`:`${(e/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(e/1024)||1)}var ly,cy,uy,Zh=I(()=>{"use strict";qe();or();ne();ly={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"]},cy={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"}},uy={name:"du",async execute(e,t){if(U(e))return F(ly);let n=we("du",e,cy);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0;for(let l of s){let c=t.fs.resolvePath(t.cwd,l);try{await t.fs.stat(c);let u=await Vh(t,c,l,r,0);i+=u.output,a+=u.totalSize,o+=u.stderr}catch{o+=`du: cannot access '${l}': No such file or directory
524
+ `}return i}function li(e,t){return t?e<1024?`${e}`:e<1024*1024?`${(e/1024).toFixed(1)}K`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)}M`:`${(e/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(e/1024)||1)}var ly,cy,uy,Zh=I(()=>{"use strict";qe();or();ne();ly={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"]},cy={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"}},uy={name:"du",async execute(e,t){if(F(e))return M(ly);let n=we("du",e,cy);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},s=n.result.positional;s.length===0&&s.push(".");let i="",o="",a=0;for(let l of s){let c=t.fs.resolvePath(t.cwd,l);try{await t.fs.stat(c);let u=await Vh(t,c,l,r,0);i+=u.output,a+=u.totalSize,o+=u.stderr}catch{o+=`du: cannot access '${l}': No such file or directory
525
525
  `}}return r.grandTotal&&s.length>0&&(i+=`${li(a,r.humanReadable)} total
526
- `),{stdout:i,stderr:o,exitCode:o?1:0}}}});var xa={};Q(xa,{envCommand:()=>hy,printenvCommand:()=>dy});var fy,hy,py,dy,Ea=I(()=>{"use strict";ne();fy={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"]},hy={name:"env",async execute(e,t){if(U(e))return F(fy);let n=!1,r=[],s=new Map,i=-1;for(let m=0;m<e.length;m++){let d=e[m];if(d==="-i"||d==="--ignore-environment")n=!0;else if(d==="-u"&&m+1<e.length)r.push(e[++m]);else if(d.startsWith("-u"))r.push(d.slice(2));else if(d.startsWith("--unset="))r.push(d.slice(8));else{if(d.startsWith("--")&&d!=="--")return X("env",d);if(d.startsWith("-")&&d!=="-"){for(let g of d.slice(1))if(g!=="i"&&g!=="u")return X("env",`-${g}`);d.includes("i")&&(n=!0)}else if(d.includes("=")&&i===-1){let g=d.indexOf("="),y=d.slice(0,g),w=d.slice(g+1);s.set(y,w)}else{i=m;break}}}let o;if(n)o=new Map(s);else{o=new Map(t.env);for(let m of r)o.delete(m);for(let[m,d]of s)o.set(m,d)}if(i===-1){let m=[];for(let[d,g]of o)m.push(`${d}=${g}`);return{stdout:m.join(`
526
+ `),{stdout:i,stderr:o,exitCode:o?1:0}}}});var xa={};Q(xa,{envCommand:()=>hy,printenvCommand:()=>dy});var fy,hy,py,dy,Ea=I(()=>{"use strict";ne();fy={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"]},hy={name:"env",async execute(e,t){if(F(e))return M(fy);let n=!1,r=[],s=new Map,i=-1;for(let m=0;m<e.length;m++){let d=e[m];if(d==="-i"||d==="--ignore-environment")n=!0;else if(d==="-u"&&m+1<e.length)r.push(e[++m]);else if(d.startsWith("-u"))r.push(d.slice(2));else if(d.startsWith("--unset="))r.push(d.slice(8));else{if(d.startsWith("--")&&d!=="--")return X("env",d);if(d.startsWith("-")&&d!=="-"){for(let g of d.slice(1))if(g!=="i"&&g!=="u")return X("env",`-${g}`);d.includes("i")&&(n=!0)}else if(d.includes("=")&&i===-1){let g=d.indexOf("="),y=d.slice(0,g),w=d.slice(g+1);s.set(y,w)}else{i=m;break}}}let o;if(n)o=new Map(s);else{o=new Map(t.env);for(let m of r)o.delete(m);for(let[m,d]of s)o.set(m,d)}if(i===-1){let m=[];for(let[d,g]of o)m.push(`${d}=${g}`);return{stdout:m.join(`
527
527
  `)+(m.length>0?`
528
528
  `:""),stderr:"",exitCode:0}}if(!t.exec)return{stdout:"",stderr:`env: command execution not supported in this context
529
- `,exitCode:1};let a=e.slice(i),l=a[0],u=a.slice(1).map(m=>/[\s"'\\$`!*?[\]{}|&;<>()]/.test(m)?`'${m.replace(/'/g,"'\\''")}'`:m),f=["command",l,...u].join(" "),h=Object.entries(s).map(([m,d])=>`${m}="${d}"`).join(" "),p=h?`${h} ${f}`:f;return t.exec(p,{cwd:t.cwd})}},py={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},dy={name:"printenv",async execute(e,t){if(U(e))return F(py);let n=e.filter(i=>!i.startsWith("-"));if(n.length===0){let i=[];for(let[o,a]of t.env)i.push(`${o}=${a}`);return{stdout:i.join(`
529
+ `,exitCode:1};let a=e.slice(i),l=a[0],u=a.slice(1).map(m=>/[\s"'\\$`!*?[\]{}|&;<>()]/.test(m)?`'${m.replace(/'/g,"'\\''")}'`:m),f=["command",l,...u].join(" "),h=Object.entries(s).map(([m,d])=>`${m}="${d}"`).join(" "),p=h?`${h} ${f}`:f;return t.exec(p,{cwd:t.cwd})}},py={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},dy={name:"printenv",async execute(e,t){if(F(e))return M(py);let n=e.filter(i=>!i.startsWith("-"));if(n.length===0){let i=[];for(let[o,a]of t.env)i.push(`${o}=${a}`);return{stdout:i.join(`
530
530
  `)+(i.length>0?`
531
531
  `:""),stderr:"",exitCode:0}}let r=[],s=0;for(let i of n){let o=t.env.get(i);o!==void 0?r.push(o):s=1}return{stdout:r.join(`
532
532
  `)+(r.length>0?`
533
- `:""),stderr:"",exitCode:s}}}});var Aa={};Q(Aa,{aliasCommand:()=>gy,unaliasCommand:()=>yy});var my,br,gy,yy,Sa=I(()=>{"use strict";ne();my={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},br="BASH_ALIAS_",gy={name:"alias",async execute(e,t){if(U(e))return F(my);if(e.length===0){let r="";for(let[s,i]of t.env)if(s.startsWith(br)){let o=s.slice(br.length);r+=`alias ${o}='${i}'
533
+ `:""),stderr:"",exitCode:s}}}});var Aa={};Q(Aa,{aliasCommand:()=>gy,unaliasCommand:()=>yy});var my,br,gy,yy,Sa=I(()=>{"use strict";ne();my={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},br="BASH_ALIAS_",gy={name:"alias",async execute(e,t){if(F(e))return M(my);if(e.length===0){let r="";for(let[s,i]of t.env)if(s.startsWith(br)){let o=s.slice(br.length);r+=`alias ${o}='${i}'
534
534
  `}return{stdout:r,stderr:"",exitCode:0}}let n=e[0]==="--"?e.slice(1):e;for(let r of n){let s=r.indexOf("=");if(s===-1){let i=br+r;return t.env.get(i)?{stdout:`alias ${r}='${t.env.get(i)}'
535
535
  `,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${r}: not found
536
- `,exitCode:1}}else{let i=r.slice(0,s),o=r.slice(s+1);(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))&&(o=o.slice(1,-1)),t.env.set(br+i,o)}}return{stdout:"",stderr:"",exitCode:0}}},yy={name:"unalias",async execute(e,t){if(U(e))return F({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(e.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
536
+ `,exitCode:1}}else{let i=r.slice(0,s),o=r.slice(s+1);(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))&&(o=o.slice(1,-1)),t.env.set(br+i,o)}}return{stdout:"",stderr:"",exitCode:0}}},yy={name:"unalias",async execute(e,t){if(F(e))return M({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(e.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
537
537
  `,exitCode:1};if(e[0]==="-a"){for(let i of t.env.keys())i.startsWith(br)&&t.env.delete(i);return{stdout:"",stderr:"",exitCode:0}}let n=e[0]==="--"?e.slice(1):e,r=!1,s="";for(let i of n){let o=br+i;t.env.get(o)?t.env.delete(o):(s+=`unalias: ${i}: not found
538
- `,r=!0)}return{stdout:"",stderr:s,exitCode:r?1:0}}}});var Kh={};Q(Kh,{historyCommand:()=>by});var wy,Qh,by,Xh=I(()=>{"use strict";ne();wy={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},Qh="BASH_HISTORY",by={name:"history",async execute(e,t){if(U(e))return F(wy);let n=t.env.get(Qh)||"[]",r;try{r=JSON.parse(n)}catch{r=[]}if(e[0]==="-c")return t.env.set(Qh,"[]"),{stdout:"",stderr:"",exitCode:0};let s=r.length;e[0]&&/^\d+$/.test(e[0])&&(s=Math.min(parseInt(e[0],10),r.length));let i=r.length-s,o="";for(let a=i;a<r.length;a++){let l=(a+1).toString().padStart(5," ");o+=`${l} ${r[a]}
539
- `}return{stdout:o,stderr:"",exitCode:0}}}});var Yh={};Q(Yh,{xargsCommand:()=>Ey});var xy,Ey,Jh=I(()=>{"use strict";ne();xy={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"]},Ey={name:"xargs",async execute(e,t){if(U(e))return F(xy);let n=null,r=null,s=null,i=null,o=!1,a=!1,l=!1,c=0;for(let w=0;w<e.length;w++){let b=e[w];if(b==="-I"&&w+1<e.length)n=e[++w],c=w+1;else if(b==="-d"&&w+1<e.length)r=e[++w].replace(/\\n/g,`
538
+ `,r=!0)}return{stdout:"",stderr:s,exitCode:r?1:0}}}});var Kh={};Q(Kh,{historyCommand:()=>by});var wy,Qh,by,Xh=I(()=>{"use strict";ne();wy={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},Qh="BASH_HISTORY",by={name:"history",async execute(e,t){if(F(e))return M(wy);let n=t.env.get(Qh)||"[]",r;try{r=JSON.parse(n)}catch{r=[]}if(e[0]==="-c")return t.env.set(Qh,"[]"),{stdout:"",stderr:"",exitCode:0};let s=r.length;e[0]&&/^\d+$/.test(e[0])&&(s=Math.min(parseInt(e[0],10),r.length));let i=r.length-s,o="";for(let a=i;a<r.length;a++){let l=(a+1).toString().padStart(5," ");o+=`${l} ${r[a]}
539
+ `}return{stdout:o,stderr:"",exitCode:0}}}});var Yh={};Q(Yh,{xargsCommand:()=>Ey});var xy,Ey,Jh=I(()=>{"use strict";ne();xy={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"]},Ey={name:"xargs",async execute(e,t){if(F(e))return M(xy);let n=null,r=null,s=null,i=null,o=!1,a=!1,l=!1,c=0;for(let w=0;w<e.length;w++){let b=e[w];if(b==="-I"&&w+1<e.length)n=e[++w],c=w+1;else if(b==="-d"&&w+1<e.length)r=e[++w].replace(/\\n/g,`
540
540
  `).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=w+1;else if(b==="-n"&&w+1<e.length)s=parseInt(e[++w],10),c=w+1;else if(b==="-P"&&w+1<e.length)i=parseInt(e[++w],10),c=w+1;else if(b==="-0"||b==="--null")o=!0,c=w+1;else if(b==="-t"||b==="--verbose")a=!0,c=w+1;else if(b==="-r"||b==="--no-run-if-empty")l=!0,c=w+1;else{if(b.startsWith("--"))return X("xargs",b);if(b.startsWith("-")&&b.length>1){for(let x of b.slice(1))if(!"0tr".includes(x))return X("xargs",`-${x}`);b.includes("0")&&(o=!0),b.includes("t")&&(a=!0),b.includes("r")&&(l=!0),c=w+1}else if(!b.startsWith("-")){c=w;break}}}let u=e.slice(c);u.length===0&&u.push("echo");let f;if(o?f=t.stdin.split("\0").filter(w=>w.length>0):r!==null?f=t.stdin.replace(/\n$/,"").split(r).filter(b=>b.length>0):f=t.stdin.split(/\s+/).map(w=>w.trim()).filter(w=>w.length>0),f.length===0)return l?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let h="",p="",m=0,d=w=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(w)?`"${w.replace(/([\\"`$])/g,"\\$1")}"`:w,g=async w=>{let b=w.map(d).join(" ");return a&&(p+=`${b}
541
541
  `),t.exec?t.exec(b,{cwd:t.cwd}):{stdout:`${b}
542
- `,stderr:"",exitCode:0}},y=async w=>{if(i!==null&&i>1)for(let b=0;b<w.length;b+=i){let x=w.slice(b,b+i),S=await Promise.all(x.map(g));for(let C of S)h+=C.stdout,p+=C.stderr,C.exitCode!==0&&(m=C.exitCode)}else for(let b of w){let x=await g(b);h+=x.stdout,p+=x.stderr,x.exitCode!==0&&(m=x.exitCode)}};if(n!==null){let w=f.map(b=>u.map(x=>x.replaceAll(n,b)));await y(w)}else if(s!==null){let w=[];for(let b=0;b<f.length;b+=s){let x=f.slice(b,b+s);w.push([...u,...x])}await y(w)}else{let w=[...u,...f],b=await g(w);h+=b.stdout,p+=b.stderr,m=b.exitCode}return{stdout:h,stderr:p,exitCode:m}}}});var Ca={};Q(Ca,{falseCommand:()=>Sy,trueCommand:()=>Ay});var Ay,Sy,Na=I(()=>{"use strict";Ay={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},Sy={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}}});var ep={};Q(ep,{clearCommand:()=>Ny});var Cy,Ny,tp=I(()=>{"use strict";ne();Cy={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},Ny={name:"clear",async execute(e,t){return U(e)?F(Cy):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}}});var ka={};Q(ka,{bashCommand:()=>ky,shCommand:()=>vy});async function xr(e,t,n,r){if(!r.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
542
+ `,stderr:"",exitCode:0}},y=async w=>{if(i!==null&&i>1)for(let b=0;b<w.length;b+=i){let x=w.slice(b,b+i),S=await Promise.all(x.map(g));for(let C of S)h+=C.stdout,p+=C.stderr,C.exitCode!==0&&(m=C.exitCode)}else for(let b of w){let x=await g(b);h+=x.stdout,p+=x.stderr,x.exitCode!==0&&(m=x.exitCode)}};if(n!==null){let w=f.map(b=>u.map(x=>x.replaceAll(n,b)));await y(w)}else if(s!==null){let w=[];for(let b=0;b<f.length;b+=s){let x=f.slice(b,b+s);w.push([...u,...x])}await y(w)}else{let w=[...u,...f],b=await g(w);h+=b.stdout,p+=b.stderr,m=b.exitCode}return{stdout:h,stderr:p,exitCode:m}}}});var Ca={};Q(Ca,{falseCommand:()=>Sy,trueCommand:()=>Ay});var Ay,Sy,Na=I(()=>{"use strict";Ay={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},Sy={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}}});var ep={};Q(ep,{clearCommand:()=>Ny});var Cy,Ny,tp=I(()=>{"use strict";ne();Cy={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},Ny={name:"clear",async execute(e,t){return F(e)?M(Cy):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}}});var ka={};Q(ka,{bashCommand:()=>ky,shCommand:()=>vy});async function xr(e,t,n,r){if(!r.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
543
543
  `,exitCode:1};let s=Zs(r.exportedEnv||{},{0:t,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")});n.forEach((a,l)=>{s[String(l+1)]=a});let i=e;if(i.startsWith("#!")){let a=i.indexOf(`
544
- `);a!==-1&&(i=i.slice(a+1))}return await r.exec(i,{env:s,cwd:r.cwd})}var np,ky,vy,va=I(()=>{"use strict";vn();ne();np={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).']},ky={name:"bash",async execute(e,t){if(U(e))return F(np);if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"bash",o=e.slice(3);return xr(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?xr(t.stdin,"bash",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return xr(i,n,r,t)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
545
- `,exitCode:127}}}},vy={name:"sh",async execute(e,t){if(U(e))return F({...np,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"sh",o=e.slice(3);return xr(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?xr(t.stdin,"sh",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return xr(i,n,r,t)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
546
- `,exitCode:127}}}}});function Ie(e){return!rp.has(e)}function Pe(e,t,n){Ie(t)&&(e[t]=n)}function cn(e,t){return Object.hasOwn(e,t)}var rp,iC,Rn=I(()=>{"use strict";rp=new Set(["__proto__","constructor","prototype"]),iC=new Set([...rp,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function Ia(e,t,n,r,s,i,o,a,l,c){switch(t){case"sort":return Array.isArray(e)?[[...e].sort(o)]:[null];case"sort_by":return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((f,h)=>{let p=s(f,n[0],r)[0],m=s(h,n[0],r)[0];return o(p,m)})];case"bsearch":{if(!Array.isArray(e)){let f=e===null?"null":typeof e=="object"?"object":typeof e;throw new Error(`${f} (${JSON.stringify(e)}) cannot be searched from`)}return n.length===0?[null]:s(e,n[0],r).map(f=>{let h=0,p=e.length;for(;h<p;){let m=h+p>>>1;o(e[m],f)<0?h=m+1:p=m}return h<e.length&&o(e[h],f)===0?h:-h-1})}case"unique_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let h of e){let p=s(h,n[0],r)[0],m=JSON.stringify(p);u.has(m)||u.set(m,{item:h,key:p})}let f=[...u.values()];return f.sort((h,p)=>o(h.key,p.key)),[f.map(h=>h.item)]}case"group_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let f of e){let h=JSON.stringify(s(f,n[0],r)[0]);u.has(h)||u.set(h,[]),u.get(h)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)>0?u:f)]:[null];case"max_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let h=s(u,n[0],r)[0],p=s(f,n[0],r)[0];return o(h,p)>0?u:f})];case"min":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)<0?u:f)]:[null];case"min_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let h=s(u,n[0],r)[0],p=s(f,n[0],r)[0];return o(h,p)<0?u:f})];case"add":{let u=f=>{let h=f.filter(p=>p!==null);return h.length===0?null:h.every(p=>typeof p=="number")?h.reduce((p,m)=>p+m,0):h.every(p=>typeof p=="string")?h.join(""):h.every(p=>Array.isArray(p))?h.flat():h.every(p=>p&&typeof p=="object"&&!Array.isArray(p))?Zs(...h):null};if(n.length>=1){let f=s(e,n[0],r);return[u(f)]}return Array.isArray(e)?[u(e)]:[null]}case"any":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(s(f,n[1],r).some(a))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(e)?[e.some(u=>a(s(u,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(a)]:[!1]}case"all":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(!s(f,n[1],r).some(a))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(e)?[e.every(u=>a(s(u,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(a)]:[!0]}case"select":return n.length===0?[e]:s(e,n[0],r).some(a)?[e]:[];case"map":return n.length===0||!Array.isArray(e)?[null]:[e.flatMap(f=>s(f,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(e))return[e.flatMap(u=>s(u,n[0],r))];if(e&&typeof e=="object"){let u=Object.create(null);for(let[f,h]of Object.entries(e)){if(!Ie(f))continue;let p=s(h,n[0],r);p.length>0&&Pe(u,f,p[0])}return[u]}return[null]}case"has":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(e)&&typeof f=="number"?[f>=0&&f<e.length]:e&&typeof e=="object"&&typeof f=="string"?[cn(e,f)]:[!1]}case"in":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(f)&&typeof e=="number"?[e>=0&&e<f.length]:f&&typeof f=="object"&&typeof e=="string"?[cn(f,e)]:[!1]}case"contains":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(e,u[0])]}case"inside":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(u[0],e)]}default:return null}}var sp=I(()=>{"use strict";vn();Rn()});function Ra(e,t,n,r,s,i,o,a){switch(t){case"first":if(n.length>0)try{let l=i(e,n[0],r);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof a)throw l;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case"last":if(n.length>0){let l=s(e,n[0],r);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case"nth":{if(n.length<1)return[null];let l=s(e,n[0],r);if(n.length>1){for(let u of l)if(u<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(e,n[1],r)}catch(u){if(u instanceof a)throw u;c=[]}return l.flatMap(u=>{let f=u;return f<c.length?[c[f]]:[]})}return Array.isArray(e)?l.flatMap(c=>{let u=c;if(u<0)throw new Error("nth doesn't support negative indices");return u<e.length?[e[u]]:[null]}):[null]}case"range":{if(n.length===0)return[];let l=s(e,n[0],r);if(n.length===1){let h=[];for(let p of l){let m=p;for(let d=0;d<m;d++)h.push(d)}return h}let c=s(e,n[1],r);if(n.length===2){let h=[];for(let p of l)for(let m of c){let d=p,g=m;for(let y=d;y<g;y++)h.push(y)}return h}let u=s(e,n[2],r),f=[];for(let h of l)for(let p of c)for(let m of u){let d=h,g=p,y=m;if(y!==0)if(y>0)for(let w=d;w<g;w+=y)f.push(w);else for(let w=d;w>g;w+=y)f.push(w)}return f}case"limit":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(e,n[1],r)}catch(h){if(h instanceof a)throw h;f=[]}return f.slice(0,u)});case"isempty":{if(n.length<1)return[!0];try{return[i(e,n[0],r).length===0]}catch(l){if(l instanceof a)throw l;return[!0]}}case"isvalid":{if(n.length<1)return[!0];try{return[s(e,n[0],r).length>0]}catch(l){if(l instanceof a)throw l;return[!1]}}case"skip":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("skip doesn't support negative count");return s(e,n[1],r).slice(u)});case"until":{if(n.length<2)return[e];let l=e,c=r.limits.maxIterations;for(let u=0;u<c;u++){if(s(l,n[0],r).some(o))return[l];let h=s(l,n[1],r);if(h.length===0)return[l];l=h[0]}throw new a(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u&&s(c,n[0],r).some(o);f++){l.push(c);let p=s(c,n[1],r);if(p.length===0)break;c=p[0]}if(l.length>=u)throw new a(`jq while: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(n.length===0)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u;f++){l.push(c);let h=s(c,n[0],r);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new a(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var ip=I(()=>{"use strict"});function Oa(e,t,n,r,s){switch(t){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof e!="number")return[null];let i=new Date(e*1e3),o=i.getUTCFullYear(),a=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),h=i.getUTCDay(),p=Date.UTC(o,0,1),m=Math.floor((i.getTime()-p)/(1440*60*1e3));return[[o,a,l,c,u,f,h,m]]}case"mktime":{if(!Array.isArray(e))throw new Error("mktime requires parsed datetime inputs");let[i,o,a,l=0,c=0,u=0]=e;if(typeof i!="number"||typeof o!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,o,a??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strftime/1 requires a string format");let a;if(typeof e=="number")a=new Date(e*1e3);else if(Array.isArray(e)){let[h,p,m,d=0,g=0,y=0]=e;if(typeof h!="number"||typeof p!="number")throw new Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(h,p,m??1,d??0,g??0,y??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(h,p=2)=>String(h).padStart(p,"0");return[o.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,u(a.getUTCMonth()+1)).replace(/%d/g,u(a.getUTCDate())).replace(/%H/g,u(a.getUTCHours())).replace(/%M/g,u(a.getUTCMinutes())).replace(/%S/g,u(a.getUTCSeconds())).replace(/%A/g,l[a.getUTCDay()]).replace(/%B/g,c[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(n.length===0)return[null];if(typeof e!="string")throw new Error("strptime/1 requires a string input");let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strptime/1 requires a string format");if(o==="%Y-%m-%dT%H:%M:%SZ"){let l=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(l){let[,c,u,f,h,p,m]=l.map(Number),d=new Date(Date.UTC(c,u-1,f,h,p,m)),g=d.getUTCDay(),y=Date.UTC(c,0,1),w=Math.floor((d.getTime()-y)/(1440*60*1e3));return[[c,u-1,f,h,p,m,g,w]]}}let a=new Date(e);if(!Number.isNaN(a.getTime())){let l=a.getUTCFullYear(),c=a.getUTCMonth(),u=a.getUTCDate(),f=a.getUTCHours(),h=a.getUTCMinutes(),p=a.getUTCSeconds(),m=a.getUTCDay(),d=Date.UTC(l,0,1),g=Math.floor((a.getTime()-d)/(1440*60*1e3));return[[l,c,u,f,h,p,m,g]]}throw new Error(`Cannot parse date: ${e}`)}case"fromdate":{if(typeof e!="string")throw new Error("fromdate requires a string input");let i=new Date(e);if(Number.isNaN(i.getTime()))throw new Error(`date "${e}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof e!="number")throw new Error("todate requires a number input");return[new Date(e*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}var op=I(()=>{"use strict"});function qt(e){return e!==!1&&e!==null}function Er(e,t){return JSON.stringify(e)===JSON.stringify(t)}function is(e,t){return typeof e=="number"&&typeof t=="number"?e-t:typeof e=="string"&&typeof t=="string"?e.localeCompare(t):0}function $a(e,t){let n={...e};for(let r of Object.keys(t))Ie(r)&&(cn(n,r)&&n[r]&&typeof n[r]=="object"&&!Array.isArray(n[r])&&t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])?Pe(n,r,$a(n[r],t[r])):Pe(n,r,t[r]));return n}function Ar(e,t=3e3){let n=0,r=e;for(;n<t;)if(Array.isArray(r)){if(r.length===0)return n+1;r=r[0],n++}else if(r!==null&&typeof r=="object"){let s=Object.keys(r);if(s.length===0)return n+1;r=r[s[0]],n++}else return n;return n}function ci(e,t){let n=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,r=n(e),s=n(t);if(r!==s)return r-s;if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="string"&&typeof t=="string")return e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return(e?1:0)-(t?1:0);if(Array.isArray(e)&&Array.isArray(t)){for(let i=0;i<Math.min(e.length,t.length);i++){let o=ci(e[i],t[i]);if(o!==0)return o}return e.length-t.length}if(e&&t&&typeof e=="object"&&typeof t=="object"){let i=e,o=t,a=Object.keys(i).sort(),l=Object.keys(o).sort();for(let c=0;c<Math.min(a.length,l.length);c++){let u=a[c].localeCompare(l[c]);if(u!==0)return u}if(a.length!==l.length)return a.length-l.length;for(let c of a){let u=ci(i[c],o[c]);if(u!==0)return u}}return 0}function ui(e,t){if(Er(e,t))return!0;if(typeof e=="string"&&typeof t=="string")return e.includes(t);if(Array.isArray(e)&&Array.isArray(t))return t.every(n=>e.some(r=>ui(r,n)));if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let n=e,r=t;return Object.keys(r).every(s=>cn(n,s)&&ui(n[s],r[s]))}return!1}var fi=I(()=>{"use strict";Rn()});function Ta(e,t,n){switch(t){case"@base64":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"utf-8").toString("base64")]:[btoa(e)]:[null];case"@base64d":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"base64").toString("utf-8")]:[atob(e)]:[null];case"@uri":return typeof e=="string"?[encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof e=="string"?[decodeURIComponent(e)]:[null];case"@csv":return Array.isArray(e)?[e.map(s=>{if(s===null)return"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="number")return String(s);let i=String(s);return i.includes(",")||i.includes('"')||i.includes(`
547
- `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(e)?[e.map(r=>String(r??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let r=n??Iy;return Ar(e,r+1)>r?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[null];case"@sh":return typeof e=="string"?[`'${e.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof e=="string"?[e]:e==null?[""]:[String(e)];default:return null}}var Iy,ap=I(()=>{"use strict";fi();Iy=2e3});function Pa(e,t,n,r,s,i){switch(t){case"index":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){if(a===""&&e==="")return null;let l=e.indexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let c=0;c<=e.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(e[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=e.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){let l=e.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let l=e.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(e[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=e.length-1;l>=0;l--)if(i(e[l],a))return l;return null}return null});case"indices":return n.length===0?[[]]:s(e,n[0],r).map(a=>{let l=[];if(typeof e=="string"&&typeof a=="string"){let c=e.indexOf(a);for(;c!==-1;)l.push(c),c=e.indexOf(a,c+1)}else if(Array.isArray(e))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=e.length;u++)l.push(u);else for(let u=0;u<=e.length-c;u++){let f=!0;for(let h=0;h<c;h++)if(!i(e[u+h],a[h])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<e.length;c++)i(e[c],a)&&l.push(c);return l});default:return null}}var lp=I(()=>{"use strict"});function Da(e,t,n,r,s){switch(t){case"fabs":case"abs":return typeof e=="number"?[Math.abs(e)]:typeof e=="string"?[e]:[null];case"exp10":return typeof e=="number"?[10**e]:[null];case"exp2":return typeof e=="number"?[2**e]:[null];case"pow":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.hypot(e,i)]}case"fma":{if(typeof e!="number"||n.length<2)return[null];let i=s(e,n[0],r)[0],o=s(e,n[1],r)[0];return[e*i+o]}case"copysign":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.sign(i)*Math.abs(e)]}case"drem":case"remainder":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e-Math.round(e/i)*i]}case"fdim":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(0,e-i)]}case"fmax":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(e,i)]}case"fmin":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.min(e,i)]}case"ldexp":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"scalbn":case"scalbln":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"nearbyint":return typeof e=="number"?[Math.round(e)]:[null];case"logb":return typeof e=="number"?[Math.floor(Math.log2(Math.abs(e)))]:[null];case"significand":if(typeof e=="number"){let i=Math.floor(Math.log2(Math.abs(e)));return[e/2**i]}return[null];case"frexp":if(typeof e=="number"){if(e===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**i,i]]}return[null];case"modf":if(typeof e=="number"){let i=Math.trunc(e);return[[e-i,i]]}return[null];default:return null}}var cp=I(()=>{"use strict"});function La(e,t,n,r,s,i,o,a){switch(t){case"recurse":{if(n.length===0){let p=[],m=d=>{if(p.push(d),Array.isArray(d))for(let g of d)m(g);else if(d&&typeof d=="object")for(let g of Object.keys(d))m(d[g])};return m(e),p}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,h=p=>{if(f++>u||c&&!s(p,c,r).some(i))return;l.push(p);let m=s(p,n[0],r);for(let d of m)d!=null&&h(d)};return h(e),l}case"recurse_down":return a(e,"recurse",n,r);case"walk":{if(n.length===0)return[e];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let p=Object.create(null);for(let[m,d]of Object.entries(u))Ie(m)&&Pe(p,m,c(d));f=p}else f=u;return s(f,n[0],r)[0]};return[c(e)]}case"transpose":{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let l=Math.max(...e.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(e.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(n.length>0){let f=s(e,n[0],r)[0];if(!Array.isArray(e)||f<0)return[];if(f===0)return[[]];let h=[],p=(m,d)=>{if(d===f){h.push([...m]);return}for(let g of e)m.push(g),p(m,d+1),m.pop()};return p([],0),h}if(!Array.isArray(e))return[];if(e.length===0)return[[]];for(let u of e)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===e.length){l.push([...f]);return}let h=e[u];for(let p of h)f.push(p),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let l=r.currentPath;if(l.length===0)return[];let c=n.length>0?s(e,n[0],r)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[e];let f=l.slice(0,u);return[o(r.root,f)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let l=r.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var up=I(()=>{"use strict";Rn()});function _a(e,t,n,r,s){switch(t){case"keys":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e)]:[null];case"length":return typeof e=="string"?[e.length]:Array.isArray(e)?[e.length]:e&&typeof e=="object"?[Object.keys(e).length]:e===null?[0]:typeof e=="number"?[Math.abs(e)]:[null];case"utf8bytelength":{if(typeof e=="string")return[new TextEncoder().encode(e).length];let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":return e&&typeof e=="object"&&!Array.isArray(e)?[Object.entries(e).map(([i,o])=>({key:i,value:o}))]:[null];case"from_entries":if(Array.isArray(e)){let i=Object.create(null);for(let o of e)if(o&&typeof o=="object"){let a=o,l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;if(l!==void 0){let u=String(l);Ie(u)&&Pe(i,u,c)}}return[i]}return[null];case"with_entries":{if(n.length===0)return[e];if(e&&typeof e=="object"&&!Array.isArray(e)){let o=Object.entries(e).map(([l,c])=>({key:l,value:c})).flatMap(l=>s(l,n[0],r)),a=Object.create(null);for(let l of o)if(l&&typeof l=="object"){let c=l,u=c.key??c.name??c.k,f=c.value??c.v;if(u!==void 0){let h=String(u);Ie(h)&&Pe(a,h,f)}}return[a]}return[null]}case"reverse":return Array.isArray(e)?[[...e].reverse()]:typeof e=="string"?[e.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(e)?(n.length>0?s(e,n[0],r):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return e.flat(a)}):[null];case"unique":if(Array.isArray(e)){let i=new Set,o=[];for(let a of e){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??Ry;return Ar(e,i+1)>i?[null]:[JSON.stringify(e)]}case"fromjson":{if(typeof e=="string"){let i=e.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(e)]}catch{throw new Error(`Invalid JSON: ${e}`)}}return[e]}case"tostring":return typeof e=="string"?[e]:[JSON.stringify(e)];case"tonumber":if(typeof e=="number")return[e];if(typeof e=="string"){let i=Number(e);if(Number.isNaN(i))throw new Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof e} cannot be parsed as a number`);case"toboolean":{if(typeof e=="boolean")return[e];if(typeof e=="string"){if(e==="true")return[!0];if(e==="false")return[!1];throw new Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,{}]);else for(let u of c)o(a[u],[...l,u])}};return o(e,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[e];let i=s(e,n[0],r),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:{});let u=o;for(let h=0;h<l.length-1;h++){let p=l[h],m=l[h+1];if(Array.isArray(u)&&typeof p=="number"){for(;u.length<=p;)u.push(null);u[p]===null&&(u[p]=typeof m=="number"?[]:{}),u=u[p]}else if(u&&typeof u=="object"&&!Array.isArray(u)){let d=String(p);if(!Ie(d))continue;let g=u;(g[d]===null||g[d]===void 0)&&Pe(g,d,typeof m=="number"?[]:{}),u=g[d]}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else if(u&&typeof u=="object"&&!Array.isArray(u)){let h=String(f);Ie(h)&&Pe(u,h,c)}}return[o]}case"truncate_stream":{let i=typeof e=="number"?Math.floor(e):0;if(n.length===0)return[];let o=[],a=s(e,n[0],r);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var Ry,fp=I(()=>{"use strict";Rn();fi();Ry=2e3});function Ma(e,t,n,r,s,i,o,a,l,c){switch(t){case"getpath":{if(n.length===0)return[null];let u=s(e,n[0],r),f=[];for(let h of u){let p=h,m=e;for(let d of p){if(m==null){m=null;break}if(Array.isArray(m)&&typeof d=="number")m=m[d];else if(typeof m=="object"&&typeof d=="string")m=m[d];else{m=null;break}}f.push(m)}return f}case"setpath":{if(n.length<2)return[null];let f=s(e,n[0],r)[0],p=s(e,n[1],r)[0];return[o(e,f,p)]}case"delpaths":{if(n.length===0)return[e];let f=s(e,n[0],r)[0],h=e;for(let p of f.sort((m,d)=>d.length-m.length))h=a(h,p);return[h]}case"path":{if(n.length===0)return[[]];let u=[];return c(e,n[0],r,[],u),u}case"del":return n.length===0?[e]:[l(e,n[0],r)];case"pick":{if(n.length===0)return[null];let u=[];for(let h of n)c(e,h,r,[],u);let f=null;for(let h of u){for(let m of h)if(typeof m=="number"&&m<0)throw new Error("Out of bounds negative array index");let p=e;for(let m of h){if(p==null)break;if(Array.isArray(p)&&typeof m=="number")p=p[m];else if(typeof p=="object"&&typeof m=="string")p=p[m];else{p=null;break}}f=o(f,h,p)}return[f]}case"paths":{let u=[],f=(h,p)=>{if(h&&typeof h=="object")if(Array.isArray(h))for(let m=0;m<h.length;m++)u.push([...p,m]),f(h[m],[...p,m]);else for(let m of Object.keys(h))u.push([...p,m]),f(h[m],[...p,m])};return f(e,[]),n.length>0?u.filter(h=>{let p=e;for(let d of h)if(Array.isArray(p)&&typeof d=="number")p=p[d];else if(p&&typeof p=="object"&&typeof d=="string")p=p[d];else return!1;return s(p,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(h,p)=>{if(h===null||typeof h!="object")u.push(p);else if(Array.isArray(h))for(let m=0;m<h.length;m++)f(h[m],[...p,m]);else for(let m of Object.keys(h))f(h[m],[...p,m])};return f(e,[]),u}default:return null}}var hp=I(()=>{"use strict"});function Fa(e,t,n,r,s,i){switch(t){case"IN":{if(n.length===0)return[!1];if(n.length===1){let c=s(e,n[0],r);for(let u of c)if(i(e,u))return[!0];return[!1]}let o=s(e,n[0],r),a=s(e,n[1],r),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(n.length===0)return[{}];if(n.length===1){let l=s(e,n[0],r),c=Object.create(null);for(let u of l){let f=String(u);Ie(f)&&Pe(c,f,u)}return[c]}if(n.length===2){let l=s(e,n[0],r),c=Object.create(null);for(let u of l){let f=s(u,n[1],r);if(f.length>0){let h=String(f[0]);Ie(h)&&Pe(c,h,u)}}return[c]}let o=s(e,n[0],r),a=Object.create(null);for(let l of o){let c=s(l,n[1],r),u=s(l,n[2],r);if(c.length>0&&u.length>0){let f=String(c[0]);Ie(f)&&Pe(a,f,u[0])}}return[a]}case"JOIN":{if(n.length<2)return[null];let o=s(e,n[0],r)[0];if(!o||typeof o!="object"||Array.isArray(o))return[null];let a=o;if(!Array.isArray(e))return[null];let l=[];for(let c of e){let u=s(c,n[1],r),f=u.length>0?String(u[0]):"",h=cn(a,f)?a[f]:null;l.push([c,h])}return[l]}default:return null}}var pp=I(()=>{"use strict";Rn()});function Ua(e,t,n,r,s){switch(t){case"join":{if(!Array.isArray(e))return[null];let i=n.length>0?s(e,n[0],r):[""];for(let o of e)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>e.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);return[e.split(o)]}case"splits":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"g";return V(o,a.includes("g")?a:`${a}g`).split(e)}catch{return[]}}case"scan":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[...V(o,a.includes("g")?a:`${a}g`).matchAll(e)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[V(o,a).test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=V(o,`${a}d`).exec(e);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,h)=>({offset:u?.[h+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=V(o,a).match(e);return!c||!c.groups?[{}]:[c.groups]}catch{return[null]}}case"sub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"";return[V(a,c).replace(e,l)]}catch{return[e]}}case"gsub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[V(a,u).replace(e,l)]}catch{return[e]}}case"ascii_downcase":return typeof e=="string"?[e.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof e=="string"?[e.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return[e.startsWith(o)?e.slice(o.length):e]}case"rtrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return o===""?[e]:[e.endsWith(o)?e.slice(0,-o.length):e]}case"trimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);if(o==="")return[e];let a=e;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof e=="string")return[e.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof e=="string")return[e.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof e=="string")return[e.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.startsWith(String(i[0]))]}case"endswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.endsWith(String(i[0]))]}case"ascii":return typeof e=="string"&&e.length>0?[e.charCodeAt(0)]:[null];case"explode":return typeof e=="string"?[Array.from(e).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(e))throw new Error("implode input must be an array");return[e.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var dp=I(()=>{"use strict";Me()});function Wa(e,t){switch(t){case"type":return e===null?["null"]:Array.isArray(e)?["array"]:typeof e=="boolean"?["boolean"]:typeof e=="number"?["number"]:typeof e=="string"?["string"]:typeof e=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof e=="number"&&!Number.isFinite(e)];case"isnan":return[typeof e=="number"&&Number.isNaN(e)];case"isnormal":return[typeof e=="number"&&Number.isFinite(e)&&e!==0];case"isfinite":return[typeof e=="number"&&Number.isFinite(e)];case"numbers":return typeof e=="number"?[e]:[];case"strings":return typeof e=="string"?[e]:[];case"booleans":return typeof e=="boolean"?[e]:[];case"nulls":return e===null?[e]:[];case"arrays":return Array.isArray(e)?[e]:[];case"objects":return e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"iterables":return Array.isArray(e)||e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"scalars":return!Array.isArray(e)&&!(e&&typeof e=="object")?[e]:[];case"values":return e===null?[]:[e];case"not":return e===!1||e===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var mp=I(()=>{"use strict"});var gp=I(()=>{"use strict";sp();ip();op();ap();lp();cp();up();fp();hp();pp();dp();mp()});function hi(e,t,n){if(t.length===0)return n;let[r,...s]=t;if(typeof r=="number"){if(e&&typeof e=="object"&&!Array.isArray(e))throw new Error("Cannot index object with number");if(r>536870911)throw new Error("Array index too large");if(r<0)throw new Error("Out of bounds negative array index");let l=Array.isArray(e)?[...e]:[];for(;l.length<=r;)l.push(null);return l[r]=hi(l[r],s,n),l}if(Array.isArray(e))throw new Error("Cannot index array with string");if(!Ie(r))return e??{};let i=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{},o=Object.hasOwn(i,r)?i[r]:void 0;return Pe(i,r,hi(o,s,n)),i}function pi(e,t){if(t.length===0)return null;if(t.length===1){let s=t[0];if(Array.isArray(e)&&typeof s=="number"){let i=[...e];return i.splice(s,1),i}if(e&&typeof e=="object"&&!Array.isArray(e)){let i=String(s);if(!Ie(i))return e;let o={...e};return delete o[i],o}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n=="number"){let s=[...e];return s[n]=pi(s[n],r),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s=String(n);if(!Ie(s))return e;let i={...e};return Object.hasOwn(i,s)&&Pe(i,s,pi(i[s],r)),i}return e}var yp=I(()=>{"use strict";Rn()});function Ty(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??Oy,maxDepth:e?.limits?.maxDepth??xp},env:e?.env}}function gi(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels}}function os(e,t,n){switch(t.type){case"var":return gi(e,t.name,n);case"array":{if(!Array.isArray(n))return null;let r=e;for(let s=0;s<t.elements.length;s++){let i=t.elements[s],o=s<n.length?n[s]:null,a=os(r,i,o);if(a===null)return null;r=a}return r}case"object":{if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,s=e;for(let i of t.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=G(n,i.key,e);if(c.length===0)return null;o=String(c[0])}let a=cn(r,o)?r[o]:null;i.keyVar&&(s=gi(s,i.keyVar,a));let l=os(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function Py(e,t){let n=e;for(let r of t)if(n&&typeof n=="object")n=n[r];else return;return n}function On(e){if(e.type==="Identity")return[];if(e.type==="Field"){let t=e.base?On(e.base):[];return t===null?null:[...t,e.name]}if(e.type==="Index"&&e.index.type==="Literal"){let t=e.base?On(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n=="number"||typeof n=="string"?[...t,n]:null}if(e.type==="Pipe"){let t=On(e.left);return t===null?null:Ba(t,e.right)}if(e.type==="Call"){if(e.name==="parent"||e.name==="root")return null;if(e.name==="first"&&e.args.length===0)return[0];if(e.name==="last"&&e.args.length===0)return[-1]}return null}function Ba(e,t){if(t.type==="Call"){if(t.name==="parent"){let n=1;if(t.args.length>0&&t.args[0].type==="Literal"){let r=t.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let r=-n-1;return e.slice(0,Math.min(r,e.length))}}if(t.name==="root")return[]}if(t.type==="Field"){let n=On(t);if(n!==null)return[...e,...n]}if(t.type==="Index"&&t.index.type==="Literal"){let n=On(t);if(n!==null)return[...e,...n]}if(t.type==="Pipe"){let n=Ba(e,t.left);return n===null?null:Ba(n,t.right)}return t.type==="Identity"?e:null}function wp(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...G(e,t.left,n))}catch(s){if(s instanceof re)throw s;if(r.length>0)return r;throw new Error("evaluation failed")}try{r.push(...G(e,t.right,n))}catch(s){if(s instanceof re)throw s;return r}return r}return G(e,t,n)}function G(e,t,n){let r=n&&"vars"in n?n:Ty(n);switch(r.root===void 0&&(r={...r,root:e,currentPath:[]}),t.type){case"Identity":return[e];case"Field":return(t.base?G(e,t.base,r):[e]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i[t.name];return[a===void 0?null:a]}if(i===null)return[null];let o=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${o} with string "${t.name}"`)});case"Index":return(t.base?G(e,t.base,r):[e]).flatMap(i=>G(i,t.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}return typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)?[i[a]]:[null]}));case"Slice":return(t.base?G(e,t.base,r):[e]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=t.start?G(e,t.start,r):[0],l=t.end?G(e,t.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=c,h=u,p=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),m=Number.isNaN(h)?o:Number.isInteger(h)?h:Math.ceil(h),d=bp(p,o),g=bp(m,o);return Array.isArray(i),i.slice(d,g)}))});case"Iterate":return(t.base?G(e,t.base,r):[e]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=G(e,t.left,r),i=On(t.left),o=[];for(let a of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};o.push(...G(a,t.right,l))}else o.push(...G(a,t.right,r))}catch(l){throw l instanceof Sr?l.withPrependedResults(o):l}return o}case"Comma":{let s=G(e,t.left,r),i=G(e,t.right,r);return[...s,...i]}case"Literal":return[t.value];case"Array":return t.elements?[G(e,t.elements,r)]:[[]];case"Object":{let s=[{}];for(let i of t.entries){let o=typeof i.key=="string"?[i.key]:G(e,i.key,r),a=G(e,i.value,r),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}if(!Ie(u)){for(let f of a)l.push({...c});continue}for(let f of a){let h={...c};Pe(h,u,f),l.push(h)}}s.length=0,s.push(...l)}return s}case"Paren":return G(e,t.expr,r);case"BinaryOp":return _y(e,t.op,t.left,t.right,r);case"UnaryOp":return G(e,t.operand,r).map(i=>{if(t.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return t.op==="not"?!qt(i):null});case"Cond":return G(e,t.cond,r).flatMap(i=>{if(qt(i))return G(e,t.then,r);for(let o of t.elifs)if(G(e,o.cond,r).some(qt))return G(e,o.then,r);return t.else?G(e,t.else,r):[e]});case"Try":try{return G(e,t.body,r)}catch(s){if(t.catch){let i=s instanceof mi?s.value:s instanceof Error?s.message:String(s);return G(i,t.catch,r)}return[]}case"Call":return Ep(e,t.name,t.args,r);case"VarBind":return G(e,t.value,r).flatMap(i=>{let o=null,a=[];t.pattern?a.push(t.pattern):t.name&&a.push({type:"var",name:t.name}),t.alternatives&&a.push(...t.alternatives);for(let l of a)if(o=os(r,l,i),o!==null)break;return o===null?[]:G(e,t.body,o)});case"VarRef":{if(t.name==="$ENV")return[r.env?wt(r.env):{}];let s=r.vars.get(t.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(e),s}case"Optional":try{return G(e,t.expr,r)}catch{return[]}case"StringInterp":return[t.parts.map(i=>typeof i=="string"?i:G(e,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[Dy(e,t.path,t.op,t.value,r)];case"Reduce":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],o=r.limits.maxDepth??xp;for(let a of s){let l;if(t.pattern){if(l=os(r,t.pattern,a),l===null)continue}else l=gi(r,t.varName,a);if(i=G(i,t.update,l)[0],Ar(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],o=[];for(let a of s)try{let l;if(t.pattern){if(l=os(r,t.pattern,a),l===null)continue}else l=gi(r,t.varName,a);if(i=G(i,t.update,l)[0],t.extract){let c=G(i,t.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof Sr?l.withPrependedResults(o):l}return o}case"Label":try{return G(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(s){if(s instanceof Sr&&s.label===t.name)return s.partialResults;throw s}case"Break":throw new Sr(t.name);case"Def":{let s=new Map(r.funcs??[]),i=`${t.name}/${t.params.length}`;s.set(i,{params:t.params,body:t.funcBody,closure:new Map(r.funcs??[])});let o={...r,funcs:s};return G(e,t.body,o)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function bp(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function Dy(e,t,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return G(l,r,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(!Ie(c.name))return l;if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let h={...f},p=Object.hasOwn(h,c.name)?h[c.name]:void 0;return Pe(h,c.name,u(p)),h}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l},h=Object.hasOwn(f,c.name)?f[c.name]:void 0;return Pe(f,c.name,u(h)),f}return l}case"Index":{let h=G(e,c.index,s)[0];if(typeof h=="number"&&Number.isNaN(h))throw new Error("Cannot set array element at NaN index");if(typeof h=="number"&&!Number.isInteger(h)&&(h=Math.trunc(h)),c.base)return o(l,c.base,p=>{if(typeof h=="number"&&Array.isArray(p)){let m=[...p],d=h<0?m.length+h:h;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(typeof h=="string"&&p&&typeof p=="object"&&!Array.isArray(p)){if(!Ie(h))return p;let m={...p},d=Object.hasOwn(m,h)?m[h]:void 0;return Pe(m,h,u(d)),m}return p});if(typeof h=="number"){if(h>536870911)throw new Error("Array index too large");if(h<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let m=[...l],d=h<0?m.length+h:h;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(l==null){let m=[];for(;m.length<=h;)m.push(null);return m[h]=u(null),m}return l}if(typeof h=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!Ie(h))return l;let p={...l},m=Object.hasOwn(p,h)?p[h]:void 0;return Pe(p,h,u(m)),p}return l}case"Iterate":{let f=h=>{if(Array.isArray(h))return h.map(p=>u(p));if(h&&typeof h=="object"){let p=Object.create(null);for(let[m,d]of Object.entries(h))Ie(m)&&Pe(p,m,u(d));return p}return h};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,h=>h);return o(f,c.right,u)}default:return u(l)}}return o(e,t,l=>{if(n==="|=")return i(l,l);let c=G(e,r,s);return i(l,c[0]??null)})}function Ly(e,t,n){function r(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(!Ie(o.name))return i;if(o.base){let l=G(i,o.base,n)[0],c=r(l,{type:"Field",name:o.name},a);return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l={...i};return Pe(l,o.name,a),l}return i}case"Index":{if(o.base){let u=G(i,o.base,n)[0],f=r(u,{type:"Index",index:o.index},a);return r(i,o.base,f)}let c=G(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u={...i};return Pe(u,c,a),u}return i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(!Ie(o.name))return i;if(o.base){let l=G(i,o.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(o.name))return i;let l={...i};return delete l[o.name],l}return i}case"Index":{if(o.base){let u=G(i,o.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return r(i,o.base,f)}let c=G(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u={...i};return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?{}:i;case"Pipe":{let u=function(p,m,d){switch(m.type){case"Identity":return d;case"Field":{if(!Ie(m.name))return p;if(p&&typeof p=="object"&&!Array.isArray(p)){let g={...p};return Pe(g,m.name,d),g}return p}case"Index":{let y=G(e,m.index,n)[0];if(typeof y=="number"&&Array.isArray(p)){let w=[...p],b=y<0?w.length+y:y;return b>=0&&b<w.length&&(w[b]=d),w}if(typeof y=="string"&&p&&typeof p=="object"&&!Array.isArray(p)){if(!Ie(y))return p;let w={...p};return Pe(w,y,d),w}return p}case"Pipe":{let g=G(p,m.left,n)[0],y=u(g,m.right,d);return u(p,m.left,y)}default:return p}};var a=u;let l=o.left,c=o.right,f=G(i,l,n)[0];if(f==null)return i;let h=s(f,c);return u(i,l,h)}default:return i}}return s(e,t)}function _y(e,t,n,r,s){if(t==="and")return G(e,n,s).flatMap(l=>qt(l)?G(e,r,s).map(u=>qt(u)):[!1]);if(t==="or")return G(e,n,s).flatMap(l=>qt(l)?[!0]:G(e,r,s).map(u=>qt(u)));if(t==="//"){let l=G(e,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:G(e,r,s)}let i=G(e,n,s),o=G(e,r,s);return i.flatMap(a=>o.map(l=>{switch(t){case"+":return a===null?l:l===null?a: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)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}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)?$a(a,l):null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return Er(a,l);case"!=":return!Er(a,l);case"<":return is(a,l)<0;case"<=":return is(a,l)<=0;case">":return is(a,l)>0;case">=":return is(a,l)>=0;default:return null}}))}function Ep(e,t,n,r){let s=$y.get(t);if(s)return typeof e=="number"?[s(e)]:[null];let i=Da(e,t,n,r,G);if(i!==null)return i;let o=Ua(e,t,n,r,G);if(o!==null)return o;let a=Oa(e,t,n,r,G);if(a!==null)return a;let l=Ta(e,t,r.limits.maxDepth);if(l!==null)return l;let c=Wa(e,t);if(c!==null)return c;let u=_a(e,t,n,r,G);if(u!==null)return u;let f=Ia(e,t,n,r,G,wp,ci,qt,ui,re);if(f!==null)return f;let h=Ma(e,t,n,r,G,qt,hi,pi,Ly,di);if(h!==null)return h;let p=Pa(e,t,n,r,G,Er);if(p!==null)return p;let m=Ra(e,t,n,r,G,wp,qt,re);if(m!==null)return m;let d=La(e,t,n,r,G,qt,Py,Ep);if(d!==null)return d;let g=Fa(e,t,n,r,G,Er);if(g!==null)return g;switch(t){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let y=n.length>0?G(e,n[0],r)[0]:e;throw new mi(y)}case"env":return[r.env?wt(r.env):{}];case"debug":return[e];case"input_line_number":return[1];default:{let y=`${t}/${n.length}`,w=r.funcs?.get(y);if(w){let b=w.closure??r.funcs??new Map,x=new Map(b);x.set(y,w);for(let C=0;C<w.params.length;C++){let $=w.params[C],M=n[C];if(M){let _=G(e,M,r),B;if(_.length===0)B={type:"Call",name:"empty",args:[]};else if(_.length===1)B={type:"Literal",value:_[0]};else{B={type:"Literal",value:_[_.length-1]};for(let v=_.length-2;v>=0;v--)B={type:"Comma",left:{type:"Literal",value:_[v]},right:B}}x.set(`${$}/0`,{params:[],body:B})}}let S={...r,funcs:x};return G(e,w.body,S)}throw new Error(`Unknown function: ${t}`)}}}function di(e,t,n,r,s){if(t.type==="Comma"){let a=t;di(e,a.left,n,r,s),di(e,a.right,n,r,s);return}let i=On(t);if(i!==null){s.push([...r,...i]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let a=0;a<e.length;a++)s.push([...r,a]);else if(e&&typeof e=="object")for(let a of Object.keys(e))s.push([...r,a]);return}if(t.type==="Recurse"){let a=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(e,[]);return}if(t.type==="Pipe"){let a=On(t.left);if(a!==null){let l=G(e,t.left,n);for(let c of l)di(c,t.right,n,[...r,...a],s);return}}G(e,t,n).length>0&&s.push(r)}var Sr,mi,Oy,xp,$y,Ap=I(()=>{"use strict";vn();xe();gp();yp();Rn();fi();Sr=class e extends Error{label;partialResults;constructor(t,n=[]){super(`break ${t}`),this.label=t,this.partialResults=n,this.name="BreakError"}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},mi=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},Oy=1e4,xp=2e3,$y=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function Sp(e){let t=[],n=0,r=(c=0)=>e[n+c],s=()=>e[n++],i=()=>n>=e.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=n,u=s();if(!(u===" "||u===" "||u===`
544
+ `);a!==-1&&(i=i.slice(a+1))}return await r.exec(i,{env:s,cwd:r.cwd})}var np,ky,vy,va=I(()=>{"use strict";vn();ne();np={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).']},ky={name:"bash",async execute(e,t){if(F(e))return M(np);if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"bash",o=e.slice(3);return xr(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?xr(t.stdin,"bash",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return xr(i,n,r,t)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
545
+ `,exitCode:127}}}},vy={name:"sh",async execute(e,t){if(F(e))return M({...np,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"sh",o=e.slice(3);return xr(s,i,o,t)}if(e.length===0)return t.stdin?.trim()?xr(t.stdin,"sh",[],t):{stdout:"",stderr:"",exitCode:0};let n=e[0],r=e.slice(1);try{let s=t.fs.resolvePath(t.cwd,n),i=await t.fs.readFile(s);return xr(i,n,r,t)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
546
+ `,exitCode:127}}}}});function Ie(e){return!rp.has(e)}function Pe(e,t,n){Ie(t)&&(e[t]=n)}function cn(e,t){return Object.hasOwn(e,t)}var rp,iC,On=I(()=>{"use strict";rp=new Set(["__proto__","constructor","prototype"]),iC=new Set([...rp,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function Ia(e,t,n,r,s,i,o,a,l,c){switch(t){case"sort":return Array.isArray(e)?[[...e].sort(o)]:[null];case"sort_by":return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((f,h)=>{let p=s(f,n[0],r)[0],m=s(h,n[0],r)[0];return o(p,m)})];case"bsearch":{if(!Array.isArray(e)){let f=e===null?"null":typeof e=="object"?"object":typeof e;throw new Error(`${f} (${JSON.stringify(e)}) cannot be searched from`)}return n.length===0?[null]:s(e,n[0],r).map(f=>{let h=0,p=e.length;for(;h<p;){let m=h+p>>>1;o(e[m],f)<0?h=m+1:p=m}return h<e.length&&o(e[h],f)===0?h:-h-1})}case"unique_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let h of e){let p=s(h,n[0],r)[0],m=JSON.stringify(p);u.has(m)||u.set(m,{item:h,key:p})}let f=[...u.values()];return f.sort((h,p)=>o(h.key,p.key)),[f.map(h=>h.item)]}case"group_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let f of e){let h=JSON.stringify(s(f,n[0],r)[0]);u.has(h)||u.set(h,[]),u.get(h)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)>0?u:f)]:[null];case"max_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let h=s(u,n[0],r)[0],p=s(f,n[0],r)[0];return o(h,p)>0?u:f})];case"min":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>o(u,f)<0?u:f)]:[null];case"min_by":return!Array.isArray(e)||e.length===0||n.length===0?[null]:[e.reduce((u,f)=>{let h=s(u,n[0],r)[0],p=s(f,n[0],r)[0];return o(h,p)<0?u:f})];case"add":{let u=f=>{let h=f.filter(p=>p!==null);return h.length===0?null:h.every(p=>typeof p=="number")?h.reduce((p,m)=>p+m,0):h.every(p=>typeof p=="string")?h.join(""):h.every(p=>Array.isArray(p))?h.flat():h.every(p=>p&&typeof p=="object"&&!Array.isArray(p))?Zs(...h):null};if(n.length>=1){let f=s(e,n[0],r);return[u(f)]}return Array.isArray(e)?[u(e)]:[null]}case"any":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(s(f,n[1],r).some(a))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(e)?[e.some(u=>a(s(u,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(a)]:[!1]}case"all":{if(n.length>=2){try{let u=i(e,n[0],r);for(let f of u)if(!s(f,n[1],r).some(a))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(e)?[e.every(u=>a(s(u,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(a)]:[!0]}case"select":return n.length===0?[e]:s(e,n[0],r).some(a)?[e]:[];case"map":return n.length===0||!Array.isArray(e)?[null]:[e.flatMap(f=>s(f,n[0],r))];case"map_values":{if(n.length===0)return[null];if(Array.isArray(e))return[e.flatMap(u=>s(u,n[0],r))];if(e&&typeof e=="object"){let u=Object.create(null);for(let[f,h]of Object.entries(e)){if(!Ie(f))continue;let p=s(h,n[0],r);p.length>0&&Pe(u,f,p[0])}return[u]}return[null]}case"has":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(e)&&typeof f=="number"?[f>=0&&f<e.length]:e&&typeof e=="object"&&typeof f=="string"?[cn(e,f)]:[!1]}case"in":{if(n.length===0)return[!1];let f=s(e,n[0],r)[0];return Array.isArray(f)&&typeof e=="number"?[e>=0&&e<f.length]:f&&typeof f=="object"&&typeof e=="string"?[cn(f,e)]:[!1]}case"contains":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(e,u[0])]}case"inside":{if(n.length===0)return[!1];let u=s(e,n[0],r);return[l(u[0],e)]}default:return null}}var sp=I(()=>{"use strict";vn();On()});function Oa(e,t,n,r,s,i,o,a){switch(t){case"first":if(n.length>0)try{let l=i(e,n[0],r);return l.length>0?[l[0]]:[]}catch(l){if(l instanceof a)throw l;return[]}return Array.isArray(e)&&e.length>0?[e[0]]:[null];case"last":if(n.length>0){let l=s(e,n[0],r);return l.length>0?[l[l.length-1]]:[]}return Array.isArray(e)&&e.length>0?[e[e.length-1]]:[null];case"nth":{if(n.length<1)return[null];let l=s(e,n[0],r);if(n.length>1){for(let u of l)if(u<0)throw new Error("nth doesn't support negative indices");let c;try{c=i(e,n[1],r)}catch(u){if(u instanceof a)throw u;c=[]}return l.flatMap(u=>{let f=u;return f<c.length?[c[f]]:[]})}return Array.isArray(e)?l.flatMap(c=>{let u=c;if(u<0)throw new Error("nth doesn't support negative indices");return u<e.length?[e[u]]:[null]}):[null]}case"range":{if(n.length===0)return[];let l=s(e,n[0],r);if(n.length===1){let h=[];for(let p of l){let m=p;for(let d=0;d<m;d++)h.push(d)}return h}let c=s(e,n[1],r);if(n.length===2){let h=[];for(let p of l)for(let m of c){let d=p,g=m;for(let y=d;y<g;y++)h.push(y)}return h}let u=s(e,n[2],r),f=[];for(let h of l)for(let p of c)for(let m of u){let d=h,g=p,y=m;if(y!==0)if(y>0)for(let w=d;w<g;w+=y)f.push(w);else for(let w=d;w>g;w+=y)f.push(w)}return f}case"limit":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(e,n[1],r)}catch(h){if(h instanceof a)throw h;f=[]}return f.slice(0,u)});case"isempty":{if(n.length<1)return[!0];try{return[i(e,n[0],r).length===0]}catch(l){if(l instanceof a)throw l;return[!0]}}case"isvalid":{if(n.length<1)return[!0];try{return[s(e,n[0],r).length>0]}catch(l){if(l instanceof a)throw l;return[!1]}}case"skip":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("skip doesn't support negative count");return s(e,n[1],r).slice(u)});case"until":{if(n.length<2)return[e];let l=e,c=r.limits.maxIterations;for(let u=0;u<c;u++){if(s(l,n[0],r).some(o))return[l];let h=s(l,n[1],r);if(h.length===0)return[l];l=h[0]}throw new a(`jq until: too many iterations (${c}), increase executionLimits.maxJqIterations`,"iterations")}case"while":{if(n.length<2)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u&&s(c,n[0],r).some(o);f++){l.push(c);let p=s(c,n[1],r);if(p.length===0)break;c=p[0]}if(l.length>=u)throw new a(`jq while: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}case"repeat":{if(n.length===0)return[e];let l=[],c=e,u=r.limits.maxIterations;for(let f=0;f<u;f++){l.push(c);let h=s(c,n[0],r);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new a(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var ip=I(()=>{"use strict"});function Ra(e,t,n,r,s){switch(t){case"now":return[Date.now()/1e3];case"gmtime":{if(typeof e!="number")return[null];let i=new Date(e*1e3),o=i.getUTCFullYear(),a=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),h=i.getUTCDay(),p=Date.UTC(o,0,1),m=Math.floor((i.getTime()-p)/(1440*60*1e3));return[[o,a,l,c,u,f,h,m]]}case"mktime":{if(!Array.isArray(e))throw new Error("mktime requires parsed datetime inputs");let[i,o,a,l=0,c=0,u=0]=e;if(typeof i!="number"||typeof o!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,o,a??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strftime/1 requires a string format");let a;if(typeof e=="number")a=new Date(e*1e3);else if(Array.isArray(e)){let[h,p,m,d=0,g=0,y=0]=e;if(typeof h!="number"||typeof p!="number")throw new Error("strftime/1 requires parsed datetime inputs");a=new Date(Date.UTC(h,p,m??1,d??0,g??0,y??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(h,p=2)=>String(h).padStart(p,"0");return[o.replace(/%Y/g,String(a.getUTCFullYear())).replace(/%m/g,u(a.getUTCMonth()+1)).replace(/%d/g,u(a.getUTCDate())).replace(/%H/g,u(a.getUTCHours())).replace(/%M/g,u(a.getUTCMinutes())).replace(/%S/g,u(a.getUTCSeconds())).replace(/%A/g,l[a.getUTCDay()]).replace(/%B/g,c[a.getUTCMonth()]).replace(/%Z/g,"UTC").replace(/%%/g,"%")]}case"strptime":{if(n.length===0)return[null];if(typeof e!="string")throw new Error("strptime/1 requires a string input");let o=s(e,n[0],r)[0];if(typeof o!="string")throw new Error("strptime/1 requires a string format");if(o==="%Y-%m-%dT%H:%M:%SZ"){let l=e.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z$/);if(l){let[,c,u,f,h,p,m]=l.map(Number),d=new Date(Date.UTC(c,u-1,f,h,p,m)),g=d.getUTCDay(),y=Date.UTC(c,0,1),w=Math.floor((d.getTime()-y)/(1440*60*1e3));return[[c,u-1,f,h,p,m,g,w]]}}let a=new Date(e);if(!Number.isNaN(a.getTime())){let l=a.getUTCFullYear(),c=a.getUTCMonth(),u=a.getUTCDate(),f=a.getUTCHours(),h=a.getUTCMinutes(),p=a.getUTCSeconds(),m=a.getUTCDay(),d=Date.UTC(l,0,1),g=Math.floor((a.getTime()-d)/(1440*60*1e3));return[[l,c,u,f,h,p,m,g]]}throw new Error(`Cannot parse date: ${e}`)}case"fromdate":{if(typeof e!="string")throw new Error("fromdate requires a string input");let i=new Date(e);if(Number.isNaN(i.getTime()))throw new Error(`date "${e}" does not match format "%Y-%m-%dT%H:%M:%SZ"`);return[Math.floor(i.getTime()/1e3)]}case"todate":{if(typeof e!="number")throw new Error("todate requires a number input");return[new Date(e*1e3).toISOString().replace(/\.\d{3}Z$/,"Z")]}default:return null}}var op=I(()=>{"use strict"});function qt(e){return e!==!1&&e!==null}function Er(e,t){return JSON.stringify(e)===JSON.stringify(t)}function is(e,t){return typeof e=="number"&&typeof t=="number"?e-t:typeof e=="string"&&typeof t=="string"?e.localeCompare(t):0}function $a(e,t){let n={...e};for(let r of Object.keys(t))Ie(r)&&(cn(n,r)&&n[r]&&typeof n[r]=="object"&&!Array.isArray(n[r])&&t[r]&&typeof t[r]=="object"&&!Array.isArray(t[r])?Pe(n,r,$a(n[r],t[r])):Pe(n,r,t[r]));return n}function Ar(e,t=3e3){let n=0,r=e;for(;n<t;)if(Array.isArray(r)){if(r.length===0)return n+1;r=r[0],n++}else if(r!==null&&typeof r=="object"){let s=Object.keys(r);if(s.length===0)return n+1;r=r[s[0]],n++}else return n;return n}function ci(e,t){let n=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,r=n(e),s=n(t);if(r!==s)return r-s;if(typeof e=="number"&&typeof t=="number")return e-t;if(typeof e=="string"&&typeof t=="string")return e.localeCompare(t);if(typeof e=="boolean"&&typeof t=="boolean")return(e?1:0)-(t?1:0);if(Array.isArray(e)&&Array.isArray(t)){for(let i=0;i<Math.min(e.length,t.length);i++){let o=ci(e[i],t[i]);if(o!==0)return o}return e.length-t.length}if(e&&t&&typeof e=="object"&&typeof t=="object"){let i=e,o=t,a=Object.keys(i).sort(),l=Object.keys(o).sort();for(let c=0;c<Math.min(a.length,l.length);c++){let u=a[c].localeCompare(l[c]);if(u!==0)return u}if(a.length!==l.length)return a.length-l.length;for(let c of a){let u=ci(i[c],o[c]);if(u!==0)return u}}return 0}function ui(e,t){if(Er(e,t))return!0;if(typeof e=="string"&&typeof t=="string")return e.includes(t);if(Array.isArray(e)&&Array.isArray(t))return t.every(n=>e.some(r=>ui(r,n)));if(e&&t&&typeof e=="object"&&typeof t=="object"&&!Array.isArray(e)&&!Array.isArray(t)){let n=e,r=t;return Object.keys(r).every(s=>cn(n,s)&&ui(n[s],r[s]))}return!1}var fi=I(()=>{"use strict";On()});function Ta(e,t,n){switch(t){case"@base64":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"utf-8").toString("base64")]:[btoa(e)]:[null];case"@base64d":return typeof e=="string"?typeof Buffer<"u"?[Buffer.from(e,"base64").toString("utf-8")]:[atob(e)]:[null];case"@uri":return typeof e=="string"?[encodeURIComponent(e).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")]:[null];case"@urid":return typeof e=="string"?[decodeURIComponent(e)]:[null];case"@csv":return Array.isArray(e)?[e.map(s=>{if(s===null)return"";if(typeof s=="boolean")return s?"true":"false";if(typeof s=="number")return String(s);let i=String(s);return i.includes(",")||i.includes('"')||i.includes(`
547
+ `)||i.includes("\r")?`"${i.replace(/"/g,'""')}"`:i}).join(",")]:[null];case"@tsv":return Array.isArray(e)?[e.map(r=>String(r??"").replace(/\t/g,"\\t").replace(/\n/g,"\\n")).join(" ")]:[null];case"@json":{let r=n??Iy;return Ar(e,r+1)>r?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")]:[null];case"@sh":return typeof e=="string"?[`'${e.replace(/'/g,"'\\''")}'`]:[null];case"@text":return typeof e=="string"?[e]:e==null?[""]:[String(e)];default:return null}}var Iy,ap=I(()=>{"use strict";fi();Iy=2e3});function Pa(e,t,n,r,s,i){switch(t){case"index":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){if(a===""&&e==="")return null;let l=e.indexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let c=0;c<=e.length-a.length;c++){let u=!0;for(let f=0;f<a.length;f++)if(!i(e[c+f],a[f])){u=!1;break}if(u)return c}return null}let l=e.findIndex(c=>i(c,a));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(e,n[0],r).map(a=>{if(typeof e=="string"&&typeof a=="string"){let l=e.lastIndexOf(a);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(a)){for(let l=e.length-a.length;l>=0;l--){let c=!0;for(let u=0;u<a.length;u++)if(!i(e[l+u],a[u])){c=!1;break}if(c)return l}return null}for(let l=e.length-1;l>=0;l--)if(i(e[l],a))return l;return null}return null});case"indices":return n.length===0?[[]]:s(e,n[0],r).map(a=>{let l=[];if(typeof e=="string"&&typeof a=="string"){let c=e.indexOf(a);for(;c!==-1;)l.push(c),c=e.indexOf(a,c+1)}else if(Array.isArray(e))if(Array.isArray(a)){let c=a.length;if(c===0)for(let u=0;u<=e.length;u++)l.push(u);else for(let u=0;u<=e.length-c;u++){let f=!0;for(let h=0;h<c;h++)if(!i(e[u+h],a[h])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<e.length;c++)i(e[c],a)&&l.push(c);return l});default:return null}}var lp=I(()=>{"use strict"});function Da(e,t,n,r,s){switch(t){case"fabs":case"abs":return typeof e=="number"?[Math.abs(e)]:typeof e=="string"?[e]:[null];case"exp10":return typeof e=="number"?[10**e]:[null];case"exp2":return typeof e=="number"?[2**e]:[null];case"pow":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[a**l]}case"atan2":{if(n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=i[0],l=o[0];return typeof a!="number"||typeof l!="number"?[null]:[Math.atan2(a,l)]}case"hypot":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.hypot(e,i)]}case"fma":{if(typeof e!="number"||n.length<2)return[null];let i=s(e,n[0],r)[0],o=s(e,n[1],r)[0];return[e*i+o]}case"copysign":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.sign(i)*Math.abs(e)]}case"drem":case"remainder":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e-Math.round(e/i)*i]}case"fdim":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(0,e-i)]}case"fmax":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.max(e,i)]}case"fmin":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[Math.min(e,i)]}case"ldexp":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"scalbn":case"scalbln":{if(typeof e!="number"||n.length===0)return[null];let i=s(e,n[0],r)[0];return[e*2**i]}case"nearbyint":return typeof e=="number"?[Math.round(e)]:[null];case"logb":return typeof e=="number"?[Math.floor(Math.log2(Math.abs(e)))]:[null];case"significand":if(typeof e=="number"){let i=Math.floor(Math.log2(Math.abs(e)));return[e/2**i]}return[null];case"frexp":if(typeof e=="number"){if(e===0)return[[0,0]];let i=Math.floor(Math.log2(Math.abs(e)))+1;return[[e/2**i,i]]}return[null];case"modf":if(typeof e=="number"){let i=Math.trunc(e);return[[e-i,i]]}return[null];default:return null}}var cp=I(()=>{"use strict"});function La(e,t,n,r,s,i,o,a){switch(t){case"recurse":{if(n.length===0){let p=[],m=d=>{if(p.push(d),Array.isArray(d))for(let g of d)m(g);else if(d&&typeof d=="object")for(let g of Object.keys(d))m(d[g])};return m(e),p}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,h=p=>{if(f++>u||c&&!s(p,c,r).some(i))return;l.push(p);let m=s(p,n[0],r);for(let d of m)d!=null&&h(d)};return h(e),l}case"recurse_down":return a(e,"recurse",n,r);case"walk":{if(n.length===0)return[e];let l=new WeakSet,c=u=>{if(u&&typeof u=="object"){if(l.has(u))return u;l.add(u)}let f;if(Array.isArray(u))f=u.map(c);else if(u&&typeof u=="object"){let p=Object.create(null);for(let[m,d]of Object.entries(u))Ie(m)&&Pe(p,m,c(d));f=p}else f=u;return s(f,n[0],r)[0]};return[c(e)]}case"transpose":{if(!Array.isArray(e))return[null];if(e.length===0)return[[]];let l=Math.max(...e.map(u=>Array.isArray(u)?u.length:0)),c=[];for(let u=0;u<l;u++)c.push(e.map(f=>Array.isArray(f)?f[u]:null));return[c]}case"combinations":{if(n.length>0){let f=s(e,n[0],r)[0];if(!Array.isArray(e)||f<0)return[];if(f===0)return[[]];let h=[],p=(m,d)=>{if(d===f){h.push([...m]);return}for(let g of e)m.push(g),p(m,d+1),m.pop()};return p([],0),h}if(!Array.isArray(e))return[];if(e.length===0)return[[]];for(let u of e)if(!Array.isArray(u))return[];let l=[],c=(u,f)=>{if(u===e.length){l.push([...f]);return}let h=e[u];for(let p of h)f.push(p),c(u+1,f),f.pop()};return c(0,[]),l}case"parent":{if(r.root===void 0||r.currentPath===void 0)return[];let l=r.currentPath;if(l.length===0)return[];let c=n.length>0?s(e,n[0],r)[0]:1;if(c>=0){if(c>l.length)return[];let u=l.slice(0,l.length-c);return[o(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[e];let f=l.slice(0,u);return[o(r.root,f)]}}case"parents":{if(r.root===void 0||r.currentPath===void 0)return[[]];let l=r.currentPath,c=[];for(let u=l.length-1;u>=0;u--)c.push(o(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var up=I(()=>{"use strict";On()});function _a(e,t,n,r,s){switch(t){case"keys":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((i,o)=>o)]:e&&typeof e=="object"?[Object.keys(e)]:[null];case"length":return typeof e=="string"?[e.length]:Array.isArray(e)?[e.length]:e&&typeof e=="object"?[Object.keys(e).length]:e===null?[0]:typeof e=="number"?[Math.abs(e)]:[null];case"utf8bytelength":{if(typeof e=="string")return[new TextEncoder().encode(e).length];let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) only strings have UTF-8 byte length`)}case"to_entries":return e&&typeof e=="object"&&!Array.isArray(e)?[Object.entries(e).map(([i,o])=>({key:i,value:o}))]:[null];case"from_entries":if(Array.isArray(e)){let i=Object.create(null);for(let o of e)if(o&&typeof o=="object"){let a=o,l=a.key??a.Key??a.name??a.Name??a.k,c=a.value??a.Value??a.v;if(l!==void 0){let u=String(l);Ie(u)&&Pe(i,u,c)}}return[i]}return[null];case"with_entries":{if(n.length===0)return[e];if(e&&typeof e=="object"&&!Array.isArray(e)){let o=Object.entries(e).map(([l,c])=>({key:l,value:c})).flatMap(l=>s(l,n[0],r)),a=Object.create(null);for(let l of o)if(l&&typeof l=="object"){let c=l,u=c.key??c.name??c.k,f=c.value??c.v;if(u!==void 0){let h=String(u);Ie(h)&&Pe(a,h,f)}}return[a]}return[null]}case"reverse":return Array.isArray(e)?[[...e].reverse()]:typeof e=="string"?[e.split("").reverse().join("")]:[null];case"flatten":return Array.isArray(e)?(n.length>0?s(e,n[0],r):[Number.POSITIVE_INFINITY]).map(o=>{let a=o;if(a<0)throw new Error("flatten depth must not be negative");return e.flat(a)}):[null];case"unique":if(Array.isArray(e)){let i=new Set,o=[];for(let a of e){let l=JSON.stringify(a);i.has(l)||(i.add(l),o.push(a))}return[o]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??Oy;return Ar(e,i+1)>i?[null]:[JSON.stringify(e)]}case"fromjson":{if(typeof e=="string"){let i=e.trim().toLowerCase();if(i==="nan")return[Number.NaN];if(i==="inf"||i==="infinity")return[Number.POSITIVE_INFINITY];if(i==="-inf"||i==="-infinity")return[Number.NEGATIVE_INFINITY];try{return[JSON.parse(e)]}catch{throw new Error(`Invalid JSON: ${e}`)}}return[e]}case"tostring":return typeof e=="string"?[e]:[JSON.stringify(e)];case"tonumber":if(typeof e=="number")return[e];if(typeof e=="string"){let i=Number(e);if(Number.isNaN(i))throw new Error(`${JSON.stringify(e)} cannot be parsed as a number`);return[i]}throw new Error(`${typeof e} cannot be parsed as a number`);case"toboolean":{if(typeof e=="boolean")return[e];if(typeof e=="string"){if(e==="true")return[!0];if(e==="false")return[!1];throw new Error(`string (${JSON.stringify(e)}) cannot be parsed as a boolean`)}let i=e===null?"null":Array.isArray(e)?"array":typeof e,o=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${o}) cannot be parsed as a boolean`)}case"tostream":{let i=[],o=(a,l)=>{if(a===null||typeof a!="object")i.push([l,a]);else if(Array.isArray(a))if(a.length===0)i.push([l,[]]);else for(let c=0;c<a.length;c++)o(a[c],[...l,c]);else{let c=Object.keys(a);if(c.length===0)i.push([l,{}]);else for(let u of c)o(a[u],[...l,u])}};return o(e,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[e];let i=s(e,n[0],r),o=null;for(let a of i){if(!Array.isArray(a)||a.length===1&&Array.isArray(a[0])&&a[0].length===0||a.length!==2)continue;let[l,c]=a;if(!Array.isArray(l))continue;if(l.length===0){o=c;continue}o===null&&(o=typeof l[0]=="number"?[]:{});let u=o;for(let h=0;h<l.length-1;h++){let p=l[h],m=l[h+1];if(Array.isArray(u)&&typeof p=="number"){for(;u.length<=p;)u.push(null);u[p]===null&&(u[p]=typeof m=="number"?[]:{}),u=u[p]}else if(u&&typeof u=="object"&&!Array.isArray(u)){let d=String(p);if(!Ie(d))continue;let g=u;(g[d]===null||g[d]===void 0)&&Pe(g,d,typeof m=="number"?[]:{}),u=g[d]}}let f=l[l.length-1];if(Array.isArray(u)&&typeof f=="number"){for(;u.length<=f;)u.push(null);u[f]=c}else if(u&&typeof u=="object"&&!Array.isArray(u)){let h=String(f);Ie(h)&&Pe(u,h,c)}}return[o]}case"truncate_stream":{let i=typeof e=="number"?Math.floor(e):0;if(n.length===0)return[];let o=[],a=s(e,n[0],r);for(let l of a)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&o.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&o.push([c.slice(i),u])}}return o}default:return null}}var Oy,fp=I(()=>{"use strict";On();fi();Oy=2e3});function Ma(e,t,n,r,s,i,o,a,l,c){switch(t){case"getpath":{if(n.length===0)return[null];let u=s(e,n[0],r),f=[];for(let h of u){let p=h,m=e;for(let d of p){if(m==null){m=null;break}if(Array.isArray(m)&&typeof d=="number")m=m[d];else if(typeof m=="object"&&typeof d=="string"){let g=m;if(!Object.hasOwn(g,d)){m=null;break}m=g[d]}else{m=null;break}}f.push(m)}return f}case"setpath":{if(n.length<2)return[null];let f=s(e,n[0],r)[0],p=s(e,n[1],r)[0];return[o(e,f,p)]}case"delpaths":{if(n.length===0)return[e];let f=s(e,n[0],r)[0],h=e;for(let p of f.sort((m,d)=>d.length-m.length))h=a(h,p);return[h]}case"path":{if(n.length===0)return[[]];let u=[];return c(e,n[0],r,[],u),u}case"del":return n.length===0?[e]:[l(e,n[0],r)];case"pick":{if(n.length===0)return[null];let u=[];for(let h of n)c(e,h,r,[],u);let f=null;for(let h of u){for(let m of h)if(typeof m=="number"&&m<0)throw new Error("Out of bounds negative array index");let p=e;for(let m of h){if(p==null)break;if(Array.isArray(p)&&typeof m=="number")p=p[m];else if(typeof p=="object"&&typeof m=="string"){let d=p;if(!Object.hasOwn(d,m)){p=null;break}p=d[m]}else{p=null;break}}f=o(f,h,p)}return[f]}case"paths":{let u=[],f=(h,p)=>{if(h&&typeof h=="object")if(Array.isArray(h))for(let m=0;m<h.length;m++)u.push([...p,m]),f(h[m],[...p,m]);else for(let m of Object.keys(h))u.push([...p,m]),f(h[m],[...p,m])};return f(e,[]),n.length>0?u.filter(h=>{let p=e;for(let d of h)if(Array.isArray(p)&&typeof d=="number")p=p[d];else if(p&&typeof p=="object"&&typeof d=="string"){let g=p;if(!Object.hasOwn(g,d))return!1;p=g[d]}else return!1;return s(p,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(h,p)=>{if(h===null||typeof h!="object")u.push(p);else if(Array.isArray(h))for(let m=0;m<h.length;m++)f(h[m],[...p,m]);else for(let m of Object.keys(h))f(h[m],[...p,m])};return f(e,[]),u}default:return null}}var hp=I(()=>{"use strict"});function Fa(e,t,n,r,s,i){switch(t){case"IN":{if(n.length===0)return[!1];if(n.length===1){let c=s(e,n[0],r);for(let u of c)if(i(e,u))return[!0];return[!1]}let o=s(e,n[0],r),a=s(e,n[1],r),l=new Set(a.map(c=>JSON.stringify(c)));for(let c of o)if(l.has(JSON.stringify(c)))return[!0];return[!1]}case"INDEX":{if(n.length===0)return[{}];if(n.length===1){let l=s(e,n[0],r),c=Object.create(null);for(let u of l){let f=String(u);Ie(f)&&Pe(c,f,u)}return[c]}if(n.length===2){let l=s(e,n[0],r),c=Object.create(null);for(let u of l){let f=s(u,n[1],r);if(f.length>0){let h=String(f[0]);Ie(h)&&Pe(c,h,u)}}return[c]}let o=s(e,n[0],r),a=Object.create(null);for(let l of o){let c=s(l,n[1],r),u=s(l,n[2],r);if(c.length>0&&u.length>0){let f=String(c[0]);Ie(f)&&Pe(a,f,u[0])}}return[a]}case"JOIN":{if(n.length<2)return[null];let o=s(e,n[0],r)[0];if(!o||typeof o!="object"||Array.isArray(o))return[null];let a=o;if(!Array.isArray(e))return[null];let l=[];for(let c of e){let u=s(c,n[1],r),f=u.length>0?String(u[0]):"",h=cn(a,f)?a[f]:null;l.push([c,h])}return[l]}default:return null}}var pp=I(()=>{"use strict";On()});function Ua(e,t,n,r,s){switch(t){case"join":{if(!Array.isArray(e))return[null];let i=n.length>0?s(e,n[0],r):[""];for(let o of e)if(Array.isArray(o)||o!==null&&typeof o=="object")throw new Error("cannot join: contains arrays or objects");return i.map(o=>e.map(a=>a===null?"":typeof a=="string"?a:String(a)).join(String(o)))}case"split":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);return[e.split(o)]}case"splits":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"g";return V(o,a.includes("g")?a:`${a}g`).split(e)}catch{return[]}}case"scan":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[...V(o,a.includes("g")?a:`${a}g`).matchAll(e)].map(u=>u.length>1?u.slice(1):u[0])}catch{return[]}}case"test":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"";return[V(o,a).test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=V(o,`${a}d`).exec(e);if(!c)return[];let u=c.indices;return[{offset:c.index,length:c[0].length,string:c[0],captures:c.slice(1).map((f,h)=>({offset:u?.[h+1]?.[0]??null,length:f?.length??0,string:f??"",name:null}))}]}catch{return[null]}}case"capture":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),o=String(i[0]);try{let a=n.length>1?String(s(e,n[1],r)[0]):"",c=V(o,a).match(e);return!c||!c.groups?[{}]:[c.groups]}catch{return[null]}}case"sub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"";return[V(a,c).replace(e,l)]}catch{return[e]}}case"gsub":{if(typeof e!="string"||n.length<2)return[null];let i=s(e,n[0],r),o=s(e,n[1],r),a=String(i[0]),l=String(o[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[V(a,u).replace(e,l)]}catch{return[e]}}case"ascii_downcase":return typeof e=="string"?[e.replace(/[A-Z]/g,i=>String.fromCharCode(i.charCodeAt(0)+32))]:[null];case"ascii_upcase":return typeof e=="string"?[e.replace(/[a-z]/g,i=>String.fromCharCode(i.charCodeAt(0)-32))]:[null];case"ltrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return[e.startsWith(o)?e.slice(o.length):e]}case"rtrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);return o===""?[e]:[e.endsWith(o)?e.slice(0,-o.length):e]}case"trimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),o=String(i[0]);if(o==="")return[e];let a=e;return a.startsWith(o)&&(a=a.slice(o.length)),a.endsWith(o)&&(a=a.slice(0,-o.length)),[a]}case"trim":if(typeof e=="string")return[e.trim()];throw new Error("trim input must be a string");case"ltrim":if(typeof e=="string")return[e.trimStart()];throw new Error("trim input must be a string");case"rtrim":if(typeof e=="string")return[e.trimEnd()];throw new Error("trim input must be a string");case"startswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.startsWith(String(i[0]))]}case"endswith":{if(typeof e!="string"||n.length===0)return[!1];let i=s(e,n[0],r);return[e.endsWith(String(i[0]))]}case"ascii":return typeof e=="string"&&e.length>0?[e.charCodeAt(0)]:[null];case"explode":return typeof e=="string"?[Array.from(e).map(i=>i.codePointAt(0))]:[null];case"implode":if(!Array.isArray(e))throw new Error("implode input must be an array");return[e.map(a=>{if(typeof a=="string")throw new Error(`string (${JSON.stringify(a)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof a!="number"||Number.isNaN(a))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(a);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var dp=I(()=>{"use strict";Me()});function Wa(e,t){switch(t){case"type":return e===null?["null"]:Array.isArray(e)?["array"]:typeof e=="boolean"?["boolean"]:typeof e=="number"?["number"]:typeof e=="string"?["string"]:typeof e=="object"?["object"]:["null"];case"infinite":return[Number.POSITIVE_INFINITY];case"nan":return[Number.NaN];case"isinfinite":return[typeof e=="number"&&!Number.isFinite(e)];case"isnan":return[typeof e=="number"&&Number.isNaN(e)];case"isnormal":return[typeof e=="number"&&Number.isFinite(e)&&e!==0];case"isfinite":return[typeof e=="number"&&Number.isFinite(e)];case"numbers":return typeof e=="number"?[e]:[];case"strings":return typeof e=="string"?[e]:[];case"booleans":return typeof e=="boolean"?[e]:[];case"nulls":return e===null?[e]:[];case"arrays":return Array.isArray(e)?[e]:[];case"objects":return e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"iterables":return Array.isArray(e)||e&&typeof e=="object"&&!Array.isArray(e)?[e]:[];case"scalars":return!Array.isArray(e)&&!(e&&typeof e=="object")?[e]:[];case"values":return e===null?[]:[e];case"not":return e===!1||e===null?[!0]:[!1];case"null":return[null];case"true":return[!0];case"false":return[!1];case"empty":return[];default:return null}}var mp=I(()=>{"use strict"});var gp=I(()=>{"use strict";sp();ip();op();ap();lp();cp();up();fp();hp();pp();dp();mp()});function hi(e,t,n){if(t.length===0)return n;let[r,...s]=t;if(typeof r=="number"){if(e&&typeof e=="object"&&!Array.isArray(e))throw new Error("Cannot index object with number");if(r>536870911)throw new Error("Array index too large");if(r<0)throw new Error("Out of bounds negative array index");let l=Array.isArray(e)?[...e]:[];for(;l.length<=r;)l.push(null);return l[r]=hi(l[r],s,n),l}if(Array.isArray(e))throw new Error("Cannot index array with string");if(!Ie(r))return e??{};let i=e&&typeof e=="object"&&!Array.isArray(e)?{...e}:{},o=Object.hasOwn(i,r)?i[r]:void 0;return Pe(i,r,hi(o,s,n)),i}function pi(e,t){if(t.length===0)return null;if(t.length===1){let s=t[0];if(Array.isArray(e)&&typeof s=="number"){let i=[...e];return i.splice(s,1),i}if(e&&typeof e=="object"&&!Array.isArray(e)){let i=String(s);if(!Ie(i))return e;let o={...e};return delete o[i],o}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n=="number"){let s=[...e];return s[n]=pi(s[n],r),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s=String(n);if(!Ie(s))return e;let i={...e};return Object.hasOwn(i,s)&&Pe(i,s,pi(i[s],r)),i}return e}var yp=I(()=>{"use strict";On()});function Ty(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??Ry,maxDepth:e?.limits?.maxDepth??xp},env:e?.env}}function gi(e,t,n){let r=new Map(e.vars);return r.set(t,n),{vars:r,limits:e.limits,env:e.env,root:e.root,currentPath:e.currentPath,funcs:e.funcs,labels:e.labels}}function os(e,t,n){switch(t.type){case"var":return gi(e,t.name,n);case"array":{if(!Array.isArray(n))return null;let r=e;for(let s=0;s<t.elements.length;s++){let i=t.elements[s],o=s<n.length?n[s]:null,a=os(r,i,o);if(a===null)return null;r=a}return r}case"object":{if(n===null||typeof n!="object"||Array.isArray(n))return null;let r=n,s=e;for(let i of t.fields){let o;if(typeof i.key=="string")o=i.key;else{let c=G(n,i.key,e);if(c.length===0)return null;o=String(c[0])}let a=cn(r,o)?r[o]:null;i.keyVar&&(s=gi(s,i.keyVar,a));let l=os(s,i.pattern,a);if(l===null)return null;s=l}return s}}}function Py(e,t){let n=e;for(let r of t)if(n&&typeof n=="object")if(Array.isArray(n))if(typeof r=="number")n=n[r];else return;else{let s=n;if(typeof r=="string"&&Object.hasOwn(s,r))n=s[r];else return}else return;return n}function Rn(e){if(e.type==="Identity")return[];if(e.type==="Field"){let t=e.base?Rn(e.base):[];return t===null?null:[...t,e.name]}if(e.type==="Index"&&e.index.type==="Literal"){let t=e.base?Rn(e.base):[];if(t===null)return null;let n=e.index.value;return typeof n=="number"||typeof n=="string"?[...t,n]:null}if(e.type==="Pipe"){let t=Rn(e.left);return t===null?null:Ba(t,e.right)}if(e.type==="Call"){if(e.name==="parent"||e.name==="root")return null;if(e.name==="first"&&e.args.length===0)return[0];if(e.name==="last"&&e.args.length===0)return[-1]}return null}function Ba(e,t){if(t.type==="Call"){if(t.name==="parent"){let n=1;if(t.args.length>0&&t.args[0].type==="Literal"){let r=t.args[0].value;typeof r=="number"&&(n=r)}if(n>=0)return e.slice(0,Math.max(0,e.length-n));{let r=-n-1;return e.slice(0,Math.min(r,e.length))}}if(t.name==="root")return[]}if(t.type==="Field"){let n=Rn(t);if(n!==null)return[...e,...n]}if(t.type==="Index"&&t.index.type==="Literal"){let n=Rn(t);if(n!==null)return[...e,...n]}if(t.type==="Pipe"){let n=Ba(e,t.left);return n===null?null:Ba(n,t.right)}return t.type==="Identity"?e:null}function wp(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...G(e,t.left,n))}catch(s){if(s instanceof re)throw s;if(r.length>0)return r;throw new Error("evaluation failed")}try{r.push(...G(e,t.right,n))}catch(s){if(s instanceof re)throw s;return r}return r}return G(e,t,n)}function G(e,t,n){let r=n&&"vars"in n?n:Ty(n);switch(r.root===void 0&&(r={...r,root:e,currentPath:[]}),t.type){case"Identity":return[e];case"Field":return(t.base?G(e,t.base,r):[e]).flatMap(i=>{if(i&&typeof i=="object"&&!Array.isArray(i)){let a=i;if(!Object.hasOwn(a,t.name))return[null];let l=a[t.name];return[l===void 0?null:l]}if(i===null)return[null];let o=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${o} with string "${t.name}"`)});case"Index":return(t.base?G(e,t.base,r):[e]).flatMap(i=>G(i,t.index,r).flatMap(a=>{if(typeof a=="number"&&Array.isArray(i)){if(Number.isNaN(a))return[null];let l=Math.trunc(a),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof a=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let l=i;return Object.hasOwn(l,a)?[l[a]]:[null]}return[null]}));case"Slice":return(t.base?G(e,t.base,r):[e]).flatMap(i=>{if(i===null)return[null];if(!Array.isArray(i)&&typeof i!="string")throw new Error(`Cannot slice ${typeof i} (${JSON.stringify(i)})`);let o=i.length,a=t.start?G(e,t.start,r):[0],l=t.end?G(e,t.end,r):[o];return a.flatMap(c=>l.map(u=>{let f=c,h=u,p=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),m=Number.isNaN(h)?o:Number.isInteger(h)?h:Math.ceil(h),d=bp(p,o),g=bp(m,o);return Array.isArray(i),i.slice(d,g)}))});case"Iterate":return(t.base?G(e,t.base,r):[e]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=G(e,t.left,r),i=Rn(t.left),o=[];for(let a of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};o.push(...G(a,t.right,l))}else o.push(...G(a,t.right,r))}catch(l){throw l instanceof Sr?l.withPrependedResults(o):l}return o}case"Comma":{let s=G(e,t.left,r),i=G(e,t.right,r);return[...s,...i]}case"Literal":return[t.value];case"Array":return t.elements?[G(e,t.elements,r)]:[[]];case"Object":{let s=[{}];for(let i of t.entries){let o=typeof i.key=="string"?[i.key]:G(e,i.key,r),a=G(e,i.value,r),l=[];for(let c of s)for(let u of o){if(typeof u!="string"){let f=u===null?"null":Array.isArray(u)?"array":typeof u;throw new Error(`Cannot use ${f} (${JSON.stringify(u)}) as object key`)}if(!Ie(u)){for(let f of a)l.push({...c});continue}for(let f of a){let h={...c};Pe(h,u,f),l.push(h)}}s.length=0,s.push(...l)}return s}case"Paren":return G(e,t.expr,r);case"BinaryOp":return _y(e,t.op,t.left,t.right,r);case"UnaryOp":return G(e,t.operand,r).map(i=>{if(t.op==="-"){if(typeof i=="number")return-i;if(typeof i=="string"){let o=a=>a.length>5?`"${a.slice(0,3)}...`:JSON.stringify(a);throw new Error(`string (${o(i)}) cannot be negated`)}return null}return t.op==="not"?!qt(i):null});case"Cond":return G(e,t.cond,r).flatMap(i=>{if(qt(i))return G(e,t.then,r);for(let o of t.elifs)if(G(e,o.cond,r).some(qt))return G(e,o.then,r);return t.else?G(e,t.else,r):[e]});case"Try":try{return G(e,t.body,r)}catch(s){if(t.catch){let i=s instanceof mi?s.value:s instanceof Error?s.message:String(s);return G(i,t.catch,r)}return[]}case"Call":return Ep(e,t.name,t.args,r);case"VarBind":return G(e,t.value,r).flatMap(i=>{let o=null,a=[];t.pattern?a.push(t.pattern):t.name&&a.push({type:"var",name:t.name}),t.alternatives&&a.push(...t.alternatives);for(let l of a)if(o=os(r,l,i),o!==null)break;return o===null?[]:G(e,t.body,o)});case"VarRef":{if(t.name==="$ENV")return[r.env?wt(r.env):{}];let s=r.vars.get(t.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(e),s}case"Optional":try{return G(e,t.expr,r)}catch{return[]}case"StringInterp":return[t.parts.map(i=>typeof i=="string"?i:G(e,i,r).map(a=>typeof a=="string"?a:JSON.stringify(a)).join("")).join("")];case"UpdateOp":return[Dy(e,t.path,t.op,t.value,r)];case"Reduce":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],o=r.limits.maxDepth??xp;for(let a of s){let l;if(t.pattern){if(l=os(r,t.pattern,a),l===null)continue}else l=gi(r,t.varName,a);if(i=G(i,t.update,l)[0],Ar(i,o+1)>o)return[null]}return[i]}case"Foreach":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],o=[];for(let a of s)try{let l;if(t.pattern){if(l=os(r,t.pattern,a),l===null)continue}else l=gi(r,t.varName,a);if(i=G(i,t.update,l)[0],t.extract){let c=G(i,t.extract,l);o.push(...c)}else o.push(i)}catch(l){throw l instanceof Sr?l.withPrependedResults(o):l}return o}case"Label":try{return G(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(s){if(s instanceof Sr&&s.label===t.name)return s.partialResults;throw s}case"Break":throw new Sr(t.name);case"Def":{let s=new Map(r.funcs??[]),i=`${t.name}/${t.params.length}`;s.set(i,{params:t.params,body:t.funcBody,closure:new Map(r.funcs??[])});let o={...r,funcs:s};return G(e,t.body,o)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function bp(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function Dy(e,t,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return G(l,r,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(!Ie(c.name))return l;if(c.base)return o(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let h={...f},p=Object.hasOwn(h,c.name)?h[c.name]:void 0;return Pe(h,c.name,u(p)),h}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f={...l},h=Object.hasOwn(f,c.name)?f[c.name]:void 0;return Pe(f,c.name,u(h)),f}return l}case"Index":{let h=G(e,c.index,s)[0];if(typeof h=="number"&&Number.isNaN(h))throw new Error("Cannot set array element at NaN index");if(typeof h=="number"&&!Number.isInteger(h)&&(h=Math.trunc(h)),c.base)return o(l,c.base,p=>{if(typeof h=="number"&&Array.isArray(p)){let m=[...p],d=h<0?m.length+h:h;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(typeof h=="string"&&p&&typeof p=="object"&&!Array.isArray(p)){if(!Ie(h))return p;let m={...p},d=Object.hasOwn(m,h)?m[h]:void 0;return Pe(m,h,u(d)),m}return p});if(typeof h=="number"){if(h>536870911)throw new Error("Array index too large");if(h<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let m=[...l],d=h<0?m.length+h:h;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(l==null){let m=[];for(;m.length<=h;)m.push(null);return m[h]=u(null),m}return l}if(typeof h=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!Ie(h))return l;let p={...l},m=Object.hasOwn(p,h)?p[h]:void 0;return Pe(p,h,u(m)),p}return l}case"Iterate":{let f=h=>{if(Array.isArray(h))return h.map(p=>u(p));if(h&&typeof h=="object"){let p=Object.create(null);for(let[m,d]of Object.entries(h))Ie(m)&&Pe(p,m,u(d));return p}return h};return c.base?o(l,c.base,f):f(l)}case"Pipe":{let f=o(l,c.left,h=>h);return o(f,c.right,u)}default:return u(l)}}return o(e,t,l=>{if(n==="|=")return i(l,l);let c=G(e,r,s);return i(l,c[0]??null)})}function Ly(e,t,n){function r(i,o,a){switch(o.type){case"Identity":return a;case"Field":{if(!Ie(o.name))return i;if(o.base){let l=G(i,o.base,n)[0],c=r(l,{type:"Field",name:o.name},a);return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l={...i};return Pe(l,o.name,a),l}return i}case"Index":{if(o.base){let u=G(i,o.base,n)[0],f=r(u,{type:"Index",index:o.index},a);return r(i,o.base,f)}let c=G(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&(u[f]=a),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u={...i};return Pe(u,c,a),u}return i}default:return i}}function s(i,o){switch(o.type){case"Identity":return null;case"Field":{if(!Ie(o.name))return i;if(o.base){let l=G(i,o.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:o.name});return r(i,o.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(o.name))return i;let l={...i};return delete l[o.name],l}return i}case"Index":{if(o.base){let u=G(i,o.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:o.index});return r(i,o.base,f)}let c=G(e,o.index,n)[0];if(typeof c=="number"&&Array.isArray(i)){let u=[...i],f=c<0?u.length+c:c;return f>=0&&f<u.length&&u.splice(f,1),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u={...i};return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?{}:i;case"Pipe":{let u=function(p,m,d){switch(m.type){case"Identity":return d;case"Field":{if(!Ie(m.name))return p;if(p&&typeof p=="object"&&!Array.isArray(p)){let g={...p};return Pe(g,m.name,d),g}return p}case"Index":{let y=G(e,m.index,n)[0];if(typeof y=="number"&&Array.isArray(p)){let w=[...p],b=y<0?w.length+y:y;return b>=0&&b<w.length&&(w[b]=d),w}if(typeof y=="string"&&p&&typeof p=="object"&&!Array.isArray(p)){if(!Ie(y))return p;let w={...p};return Pe(w,y,d),w}return p}case"Pipe":{let g=G(p,m.left,n)[0],y=u(g,m.right,d);return u(p,m.left,y)}default:return p}};var a=u;let l=o.left,c=o.right,f=G(i,l,n)[0];if(f==null)return i;let h=s(f,c);return u(i,l,h)}default:return i}}return s(e,t)}function _y(e,t,n,r,s){if(t==="and")return G(e,n,s).flatMap(l=>qt(l)?G(e,r,s).map(u=>qt(u)):[!1]);if(t==="or")return G(e,n,s).flatMap(l=>qt(l)?[!0]:G(e,r,s).map(u=>qt(u)));if(t==="//"){let l=G(e,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:G(e,r,s)}let i=G(e,n,s),o=G(e,r,s);return i.flatMap(a=>o.map(l=>{switch(t){case"+":return a===null?l:l===null?a: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)))}if(typeof a=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(a)}) and string (${c(l)}) cannot be subtracted`)}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)?$a(a,l):null;case"/":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided because the divisor is zero`);return a/l}return typeof a=="string"&&typeof l=="string"?a.split(l):null;case"%":if(typeof a=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${a}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(a)&&!Number.isNaN(a)?!Number.isFinite(l)&&!Number.isNaN(l)&&a<0&&l>0?-1:0:a%l}return null;case"==":return Er(a,l);case"!=":return!Er(a,l);case"<":return is(a,l)<0;case"<=":return is(a,l)<=0;case">":return is(a,l)>0;case">=":return is(a,l)>=0;default:return null}}))}function Ep(e,t,n,r){let s=$y.get(t);if(s)return typeof e=="number"?[s(e)]:[null];let i=Da(e,t,n,r,G);if(i!==null)return i;let o=Ua(e,t,n,r,G);if(o!==null)return o;let a=Ra(e,t,n,r,G);if(a!==null)return a;let l=Ta(e,t,r.limits.maxDepth);if(l!==null)return l;let c=Wa(e,t);if(c!==null)return c;let u=_a(e,t,n,r,G);if(u!==null)return u;let f=Ia(e,t,n,r,G,wp,ci,qt,ui,re);if(f!==null)return f;let h=Ma(e,t,n,r,G,qt,hi,pi,Ly,di);if(h!==null)return h;let p=Pa(e,t,n,r,G,Er);if(p!==null)return p;let m=Oa(e,t,n,r,G,wp,qt,re);if(m!==null)return m;let d=La(e,t,n,r,G,qt,Py,Ep);if(d!==null)return d;let g=Fa(e,t,n,r,G,Er);if(g!==null)return g;switch(t){case"builtins":return[["add/0","all/0","all/1","all/2","any/0","any/1","any/2","arrays/0","ascii/0","ascii_downcase/0","ascii_upcase/0","booleans/0","bsearch/1","builtins/0","combinations/0","combinations/1","contains/1","debug/0","del/1","delpaths/1","empty/0","env/0","error/0","error/1","explode/0","first/0","first/1","flatten/0","flatten/1","floor/0","from_entries/0","fromdate/0","fromjson/0","getpath/1","gmtime/0","group_by/1","gsub/2","gsub/3","has/1","implode/0","IN/1","IN/2","INDEX/1","INDEX/2","index/1","indices/1","infinite/0","inside/1","isempty/1","isnan/0","isnormal/0","isvalid/1","iterables/0","join/1","keys/0","keys_unsorted/0","last/0","last/1","length/0","limit/2","ltrimstr/1","map/1","map_values/1","match/1","match/2","max/0","max_by/1","min/0","min_by/1","mktime/0","modulemeta/1","nan/0","not/0","nth/1","nth/2","null/0","nulls/0","numbers/0","objects/0","path/1","paths/0","paths/1","pick/1","range/1","range/2","range/3","recurse/0","recurse/1","recurse_down/0","repeat/1","reverse/0","rindex/1","rtrimstr/1","scalars/0","scan/1","scan/2","select/1","setpath/2","skip/2","sort/0","sort_by/1","split/1","splits/1","splits/2","sqrt/0","startswith/1","strftime/1","strings/0","strptime/1","sub/2","sub/3","test/1","test/2","to_entries/0","toboolean/0","todate/0","tojson/0","tostream/0","fromstream/1","truncate_stream/1","tonumber/0","tostring/0","transpose/0","trim/0","ltrim/0","rtrim/0","type/0","unique/0","unique_by/1","until/2","utf8bytelength/0","values/0","walk/1","while/2","with_entries/1"]];case"error":{let y=n.length>0?G(e,n[0],r)[0]:e;throw new mi(y)}case"env":return[r.env?wt(r.env):{}];case"debug":return[e];case"input_line_number":return[1];default:{let y=`${t}/${n.length}`,w=r.funcs?.get(y);if(w){let b=w.closure??r.funcs??new Map,x=new Map(b);x.set(y,w);for(let C=0;C<w.params.length;C++){let R=w.params[C],U=n[C];if(U){let L=G(e,U,r),B;if(L.length===0)B={type:"Call",name:"empty",args:[]};else if(L.length===1)B={type:"Literal",value:L[0]};else{B={type:"Literal",value:L[L.length-1]};for(let v=L.length-2;v>=0;v--)B={type:"Comma",left:{type:"Literal",value:L[v]},right:B}}x.set(`${R}/0`,{params:[],body:B})}}let S={...r,funcs:x};return G(e,w.body,S)}throw new Error(`Unknown function: ${t}`)}}}function di(e,t,n,r,s){if(t.type==="Comma"){let a=t;di(e,a.left,n,r,s),di(e,a.right,n,r,s);return}let i=Rn(t);if(i!==null){s.push([...r,...i]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let a=0;a<e.length;a++)s.push([...r,a]);else if(e&&typeof e=="object")for(let a of Object.keys(e))s.push([...r,a]);return}if(t.type==="Recurse"){let a=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)a(l[u],[...c,u]);else for(let u of Object.keys(l))a(l[u],[...c,u])};a(e,[]);return}if(t.type==="Pipe"){let a=Rn(t.left);if(a!==null){let l=G(e,t.left,n);for(let c of l)di(c,t.right,n,[...r,...a],s);return}}G(e,t,n).length>0&&s.push(r)}var Sr,mi,Ry,xp,$y,Ap=I(()=>{"use strict";vn();xe();gp();yp();On();fi();Sr=class e extends Error{label;partialResults;constructor(t,n=[]){super(`break ${t}`),this.label=t,this.partialResults=n,this.name="BreakError"}withPrependedResults(t){return new e(this.label,[...t,...this.partialResults])}},mi=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},Ry=1e4,xp=2e3,$y=new Map([["floor",Math.floor],["ceil",Math.ceil],["round",Math.round],["sqrt",Math.sqrt],["log",Math.log],["log10",Math.log10],["log2",Math.log2],["exp",Math.exp],["sin",Math.sin],["cos",Math.cos],["tan",Math.tan],["asin",Math.asin],["acos",Math.acos],["atan",Math.atan],["sinh",Math.sinh],["cosh",Math.cosh],["tanh",Math.tanh],["asinh",Math.asinh],["acosh",Math.acosh],["atanh",Math.atanh],["cbrt",Math.cbrt],["expm1",Math.expm1],["log1p",Math.log1p],["trunc",Math.trunc]])});function Sp(e){let t=[],n=0,r=(c=0)=>e[n+c],s=()=>e[n++],i=()=>n>=e.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=n,u=s();if(!(u===" "||u===" "||u===`
548
548
  `||u==="\r")){if(u==="#"){for(;!i()&&r()!==`
549
549
  `;)s();continue}if(u==="."&&r()==="."){s(),t.push({type:"DOTDOT",pos:c});continue}if(u==="="&&r()==="="){s(),t.push({type:"EQ",pos:c});continue}if(u==="!"&&r()==="="){s(),t.push({type:"NE",pos:c});continue}if(u==="<"&&r()==="="){s(),t.push({type:"LE",pos:c});continue}if(u===">"&&r()==="="){s(),t.push({type:"GE",pos:c});continue}if(u==="/"&&r()==="/"){s(),r()==="="?(s(),t.push({type:"UPDATE_ALT",pos:c})):t.push({type:"ALT",pos:c});continue}if(u==="+"&&r()==="="){s(),t.push({type:"UPDATE_ADD",pos:c});continue}if(u==="-"&&r()==="="){s(),t.push({type:"UPDATE_SUB",pos:c});continue}if(u==="*"&&r()==="="){s(),t.push({type:"UPDATE_MUL",pos:c});continue}if(u==="/"&&r()==="="){s(),t.push({type:"UPDATE_DIV",pos:c});continue}if(u==="%"&&r()==="="){s(),t.push({type:"UPDATE_MOD",pos:c});continue}if(u==="="&&r()!=="="){t.push({type:"ASSIGN",pos:c});continue}if(u==="."){t.push({type:"DOT",pos:c});continue}if(u==="|"){r()==="="?(s(),t.push({type:"UPDATE_PIPE",pos:c})):t.push({type:"PIPE",pos:c});continue}if(u===","){t.push({type:"COMMA",pos:c});continue}if(u===":"){t.push({type:"COLON",pos:c});continue}if(u===";"){t.push({type:"SEMICOLON",pos:c});continue}if(u==="("){t.push({type:"LPAREN",pos:c});continue}if(u===")"){t.push({type:"RPAREN",pos:c});continue}if(u==="["){t.push({type:"LBRACKET",pos:c});continue}if(u==="]"){t.push({type:"RBRACKET",pos:c});continue}if(u==="{"){t.push({type:"LBRACE",pos:c});continue}if(u==="}"){t.push({type:"RBRACE",pos:c});continue}if(u==="?"){t.push({type:"QUESTION",pos:c});continue}if(u==="+"){t.push({type:"PLUS",pos:c});continue}if(u==="-"){t.push({type:"MINUS",pos:c});continue}if(u==="*"){t.push({type:"STAR",pos:c});continue}if(u==="/"){t.push({type:"SLASH",pos:c});continue}if(u==="%"){t.push({type:"PERCENT",pos:c});continue}if(u==="<"){t.push({type:"LT",pos:c});continue}if(u===">"){t.push({type:"GT",pos:c});continue}if(o(u)){let f=u;for(;!i()&&(o(r())||r()==="."||r()==="e"||r()==="E");)(r()==="e"||r()==="E")&&(e[n+1]==="+"||e[n+1]==="-")&&(f+=s()),f+=s();t.push({type:"NUMBER",value:Number(f),pos:c});continue}if(u==='"'){let f="";for(;!i()&&r()!=='"';)if(r()==="\\"){if(s(),i())break;let h=s();switch(h){case"n":f+=`
550
550
  `;break;case"r":f+="\r";break;case"t":f+=" ";break;case"\\":f+="\\";break;case'"':f+='"';break;case"(":f+="\\(";break;default:f+=h}}else f+=s();i()||s(),t.push({type:"STRING",value:f,pos:c});continue}if(a(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(r());)f+=s();let h=My.get(f);h?t.push({type:h,pos:c}):t.push({type:"IDENT",value:f,pos:c});continue}throw new Error(`Unexpected character '${u}' at position ${c}`)}}return t.push({type:"EOF",pos:n}),t}function Cp(e){let t=Sp(e);return new Ha(t).parse()}var My,Ha,Np=I(()=>{"use strict";My=new Map([["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"],["label","LABEL"],["break","BREAK"],["def","DEF"]]);Ha=class e{tokens;pos=0;constructor(t){this.tokens=t}peek(t=0){return this.tokens[this.pos+t]??{type:"EOF",pos:-1}}advance(){return this.tokens[this.pos++]}check(t){return this.peek().type===t}match(...t){for(let n of t)if(this.check(n))return this.advance();return null}expect(t,n){if(!this.check(t))throw new Error(`${n} at position ${this.peek().pos}, got ${this.peek().type}`);return this.advance()}parse(){let t=this.parseExpr();if(!this.check("EOF"))throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`);return t}parseExpr(){return this.parsePipe()}parsePattern(){if(this.match("LBRACKET")){let r=[];if(!this.check("RBRACKET"))for(r.push(this.parsePattern());this.match("COMMA")&&!this.check("RBRACKET");)r.push(this.parsePattern());return this.expect("RBRACKET","Expected ']' after array pattern"),{type:"array",elements:r}}if(this.match("LBRACE")){let r=[];if(!this.check("RBRACE"))for(r.push(this.parsePatternField());this.match("COMMA")&&!this.check("RBRACE");)r.push(this.parsePatternField());return this.expect("RBRACE","Expected '}' after object pattern"),{type:"object",fields:r}}let t=this.expect("IDENT","Expected variable name in pattern"),n=t.value;if(!n.startsWith("$"))throw new Error(`Variable name must start with $ at position ${t.pos}`);return{type:"var",name:n}}parsePatternField(){if(this.match("LPAREN")){let n=this.parseExpr();this.expect("RPAREN","Expected ')' after computed key"),this.expect("COLON","Expected ':' after computed key");let r=this.parsePattern();return{key:n,pattern:r}}let t=this.peek();if(t.type==="IDENT"){let n=t.value;if(n.startsWith("$")){if(this.advance(),this.match("COLON")){let r=this.parsePattern();return{key:n.slice(1),pattern:r,keyVar:n}}return{key:n.slice(1),pattern:{type:"var",name:n}}}if(this.advance(),this.match("COLON")){let r=this.parsePattern();return{key:n,pattern:r}}return{key:n,pattern:{type:"var",name:`$${n}`}}}throw new Error(`Expected field name in object pattern at position ${t.pos}`)}parsePipe(){let t=this.parseComma();for(;this.match("PIPE");){let n=this.parseComma();t={type:"Pipe",left:t,right:n}}return t}parseComma(){let t=this.parseVarBind();for(;this.match("COMMA");){let n=this.parseVarBind();t={type:"Comma",left:t,right:n}}return t}parseVarBind(){let t=this.parseUpdate();if(this.match("AS")){let n=this.parsePattern(),r=[];for(;this.check("QUESTION")&&this.peekAhead(1)?.type==="ALT";)this.advance(),this.advance(),r.push(this.parsePattern());this.expect("PIPE","Expected '|' after variable binding");let s=this.parseExpr();return n.type==="var"&&r.length===0?{type:"VarBind",name:n.name,value:t,body:s}:{type:"VarBind",name:n.type==="var"?n.name:"",value:t,body:s,pattern:n.type!=="var"?n:void 0,alternatives:r.length>0?r:void 0}}return t}peekAhead(t){let n=this.pos+t;return n<this.tokens.length?this.tokens[n]:void 0}parseUpdate(){let t=this.parseAlt(),n=new Map([["ASSIGN","="],["UPDATE_ADD","+="],["UPDATE_SUB","-="],["UPDATE_MUL","*="],["UPDATE_DIV","/="],["UPDATE_MOD","%="],["UPDATE_ALT","//="],["UPDATE_PIPE","|="]]),r=this.match("ASSIGN","UPDATE_ADD","UPDATE_SUB","UPDATE_MUL","UPDATE_DIV","UPDATE_MOD","UPDATE_ALT","UPDATE_PIPE");if(r){let s=this.parseVarBind(),i=n.get(r.type);if(i)return{type:"UpdateOp",op:i,path:t,value:s}}return t}parseAlt(){let t=this.parseOr();for(;this.match("ALT");){let n=this.parseOr();t={type:"BinaryOp",op:"//",left:t,right:n}}return t}parseOr(){let t=this.parseAnd();for(;this.match("OR");){let n=this.parseAnd();t={type:"BinaryOp",op:"or",left:t,right:n}}return t}parseAnd(){let t=this.parseNot();for(;this.match("AND");){let n=this.parseNot();t={type:"BinaryOp",op:"and",left:t,right:n}}return t}parseNot(){return this.parseComparison()}parseComparison(){let t=this.parseAddSub(),n=new Map([["EQ","=="],["NE","!="],["LT","<"],["LE","<="],["GT",">"],["GE",">="]]),r=this.match("EQ","NE","LT","LE","GT","GE");if(r){let s=n.get(r.type);if(s){let i=this.parseAddSub();t={type:"BinaryOp",op:s,left:t,right:i}}}return t}parseAddSub(){let t=this.parseMulDiv();for(;;)if(this.match("PLUS")){let n=this.parseMulDiv();t={type:"BinaryOp",op:"+",left:t,right:n}}else if(this.match("MINUS")){let n=this.parseMulDiv();t={type:"BinaryOp",op:"-",left:t,right:n}}else break;return t}parseMulDiv(){let t=this.parseUnary();for(;;)if(this.match("STAR")){let n=this.parseUnary();t={type:"BinaryOp",op:"*",left:t,right:n}}else if(this.match("SLASH")){let n=this.parseUnary();t={type:"BinaryOp",op:"/",left:t,right:n}}else if(this.match("PERCENT")){let n=this.parseUnary();t={type:"BinaryOp",op:"%",left:t,right:n}}else break;return t}parseUnary(){return this.match("MINUS")?{type:"UnaryOp",op:"-",operand:this.parseUnary()}:this.parsePostfix()}parsePostfix(){let t=this.parsePrimary();for(;;)if(this.match("QUESTION"))t={type:"Optional",expr:t};else if(this.check("DOT")&&(this.peek(1).type==="IDENT"||this.peek(1).type==="STRING"))this.advance(),t={type:"Field",name:this.advance().value,base:t};else if(this.check("LBRACKET"))if(this.advance(),this.match("RBRACKET"))t={type:"Iterate",base:t};else if(this.check("COLON")){this.advance();let n=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),t={type:"Slice",end:n,base:t}}else{let n=this.parseExpr();if(this.match("COLON")){let r=this.check("RBRACKET")?void 0:this.parseExpr();this.expect("RBRACKET","Expected ']'"),t={type:"Slice",start:n,end:r,base:t}}else this.expect("RBRACKET","Expected ']'"),t={type:"Index",index:n,base:t}}else break;return t}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 n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:n}}let t=this.parseExpr();if(this.match("COLON")){let n=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:t,end:n}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:t}}return this.check("IDENT")||this.check("STRING")?{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 n=this.advance().value;return n.includes("\\(")?this.parseStringInterpolation(n):{type:"Literal",value:n}}if(this.match("LBRACKET")){if(this.match("RBRACKET"))return{type:"Array"};let t=this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Array",elements:t}}if(this.match("LBRACE"))return this.parseObjectConstruction();if(this.match("LPAREN")){let t=this.parseExpr();return this.expect("RPAREN","Expected ')'"),{type:"Paren",expr:t}}if(this.match("IF"))return this.parseIf();if(this.match("TRY")){let t=this.parsePostfix(),n;return this.match("CATCH")&&(n=this.parsePostfix()),{type:"Try",body:t,catch:n}}if(this.match("REDUCE")){let t=this.parseAddSub();this.expect("AS","Expected 'as' after reduce expression");let n=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let r=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr();this.expect("RPAREN","Expected ')' after update expression");let i=n.type==="var"?n.name:"";return{type:"Reduce",expr:t,varName:i,init:r,update:s,pattern:n.type!=="var"?n:void 0}}if(this.match("FOREACH")){let t=this.parseAddSub();this.expect("AS","Expected 'as' after foreach expression");let n=this.parsePattern();this.expect("LPAREN","Expected '(' after variable");let r=this.parseExpr();this.expect("SEMICOLON","Expected ';' after init expression");let s=this.parseExpr(),i;this.match("SEMICOLON")&&(i=this.parseExpr()),this.expect("RPAREN","Expected ')' after expressions");let o=n.type==="var"?n.name:"";return{type:"Foreach",expr:t,varName:o,init:r,update:s,extract:i,pattern:n.type!=="var"?n:void 0}}if(this.match("LABEL")){let t=this.expect("IDENT","Expected label name (e.g., $out)"),n=t.value;if(!n.startsWith("$"))throw new Error(`Label name must start with $ at position ${t.pos}`);this.expect("PIPE","Expected '|' after label name");let r=this.parseExpr();return{type:"Label",name:n,body:r}}if(this.match("BREAK")){let t=this.expect("IDENT","Expected label name to break to"),n=t.value;if(!n.startsWith("$"))throw new Error(`Break label must start with $ at position ${t.pos}`);return{type:"Break",name:n}}if(this.match("DEF")){let n=this.expect("IDENT","Expected function name after def").value,r=[];if(this.match("LPAREN")){if(!this.check("RPAREN")){let o=this.expect("IDENT","Expected parameter name");for(r.push(o.value);this.match("SEMICOLON");){let a=this.expect("IDENT","Expected parameter name");r.push(a.value)}}this.expect("RPAREN","Expected ')' after parameters")}this.expect("COLON","Expected ':' after function name");let s=this.parseExpr();this.expect("SEMICOLON","Expected ';' after function body");let i=this.parseExpr();return{type:"Def",name:n,params:r,funcBody:s,body:i}}if(this.match("NOT"))return{type:"Call",name:"not",args:[]};if(this.check("IDENT")){let n=this.advance().value;if(n.startsWith("$"))return{type:"VarRef",name:n};if(this.match("LPAREN")){let r=[];if(!this.check("RPAREN"))for(r.push(this.parseExpr());this.match("SEMICOLON");)r.push(this.parseExpr());return this.expect("RPAREN","Expected ')'"),{type:"Call",name:n,args:r}}return{type:"Call",name:n,args:[]}}throw new Error(`Unexpected token ${this.peek().type} at position ${this.peek().pos}`)}parseObjectConstruction(){let t=[];if(!this.check("RBRACE"))do{let n,r;if(this.match("LPAREN"))n=this.parseExpr(),this.expect("RPAREN","Expected ')'"),this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else if(this.check("IDENT")){let s=this.advance().value;this.match("COLON")?(n=s,r=this.parseObjectValue()):(n=s,r={type:"Field",name:s})}else if(this.check("STRING"))n=this.advance().value,this.expect("COLON","Expected ':'"),r=this.parseObjectValue();else throw new Error(`Expected object key at position ${this.peek().pos}`);t.push({key:n,value:r})}while(this.match("COMMA"));return this.expect("RBRACE","Expected '}'"),{type:"Object",entries:t}}parseObjectValue(){let t=this.parseVarBind();for(;this.match("PIPE");){let n=this.parseVarBind();t={type:"Pipe",left:t,right:n}}return t}parseIf(){let t=this.parseExpr();this.expect("THEN","Expected 'then'");let n=this.parseExpr(),r=[];for(;this.match("ELIF");){let i=this.parseExpr();this.expect("THEN","Expected 'then' after elif");let o=this.parseExpr();r.push({cond:i,then:o})}let s;return this.match("ELSE")&&(s=this.parseExpr()),this.expect("END","Expected 'end'"),{type:"Cond",cond:t,then:n,elifs:r,else:s}}parseStringInterpolation(t){let n=[],r="",s=0;for(;s<t.length;)if(t[s]==="\\"&&t[s+1]==="("){r&&(n.push(r),r=""),s+=2;let i=1,o="";for(;s<t.length&&i>0;)t[s]==="("?i++:t[s]===")"&&i--,i>0&&(o+=t[s]),s++;let a=Sp(o),l=new e(a);n.push(l.parse())}else r+=t[s],s++;return r&&n.push(r),{type:"StringInterp",parts:n}}}});var kp=I(()=>{"use strict";Ap();Np()});var Ip={};Q(Ip,{jqCommand:()=>Uy});function vp(e){let t=[],n=0,r=e.length;for(;n<r;){for(;n<r&&/\s/.test(e[n]);)n++;if(n>=r)break;let s=n,i=e[n];if(i==="{"||i==="["){let o=i,a=i==="{"?"}":"]",l=1,c=!1,u=!1;for(n++;n<r&&l>0;){let f=e[n];u?u=!1:f==="\\"?u=!0:f==='"'?c=!c:c||(f===o?l++:f===a&&l--),n++}if(l!==0)throw new Error(`Unexpected end of JSON input at position ${n} (unclosed ${o})`);t.push(JSON.parse(e.slice(s,n)))}else if(i==='"'){let o=!1;for(n++;n<r;){let a=e[n];if(o)o=!1;else if(a==="\\")o=!0;else if(a==='"'){n++;break}n++}t.push(JSON.parse(e.slice(s,n)))}else if(i==="-"||i>="0"&&i<="9"){for(;n<r&&/[\d.eE+-]/.test(e[n]);)n++;t.push(JSON.parse(e.slice(s,n)))}else if(e.slice(n,n+4)==="true")t.push(!0),n+=4;else if(e.slice(n,n+5)==="false")t.push(!1),n+=5;else if(e.slice(n,n+4)==="null")t.push(null),n+=4;else{let o=e.slice(n,n+10);throw new Error(`Invalid JSON at position ${s}: unexpected '${o.split(/\s/)[0]}'`)}}return t}function as(e,t,n,r,s,i=0){if(e===null||e===void 0)return"null";if(typeof e=="boolean")return String(e);if(typeof e=="number")return Number.isFinite(e)?String(e):"null";if(typeof e=="string")return n?e:JSON.stringify(e);let o=s?" ":" ";if(Array.isArray(e))return e.length===0?"[]":t?`[${e.map(l=>as(l,!0,!1,r,s)).join(",")}]`:`[
@@ -553,22 +553,22 @@ ${e.map(l=>o.repeat(i+1)+as(l,!1,!1,r,s,i+1)).join(`,
553
553
  ${o.repeat(i)}]`;if(typeof e=="object"){let a=Object.keys(e);return r&&(a=a.sort()),a.length===0?"{}":t?`{${a.map(c=>`${JSON.stringify(c)}:${as(e[c],!0,!1,r,s)}`).join(",")}}`:`{
554
554
  ${a.map(c=>{let u=as(e[c],!1,!1,r,s,i+1);return`${o.repeat(i+1)}${JSON.stringify(c)}: ${u}`}).join(`,
555
555
  `)}
556
- ${o.repeat(i)}}`}return String(e)}var Fy,Uy,Rp=I(()=>{"use strict";xe();Hn();ne();kp();Fy={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"]};Uy={name:"jq",async execute(e,t){if(U(e))return F(Fy);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=".",f=!1,h=[];for(let m=0;m<e.length;m++){let d=e[m];if(d==="-r"||d==="--raw-output")n=!0;else if(d==="-c"||d==="--compact-output")r=!0;else if(d==="-e"||d==="--exit-status")s=!0;else if(d==="-s"||d==="--slurp")i=!0;else if(d==="-n"||d==="--null-input")o=!0;else if(d==="-j"||d==="--join-output")a=!0;else if(!(d==="-a"||d==="--ascii")){if(d==="-S"||d==="--sort-keys")l=!0;else if(!(d==="-C"||d==="--color")){if(!(d==="-M"||d==="--monochrome"))if(d==="--tab")c=!0;else if(d==="-")h.push("-");else{if(d.startsWith("--"))return X("jq",d);if(d.startsWith("-")){for(let g of d.slice(1))if(g==="r")n=!0;else if(g==="c")r=!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 X("jq",`-${g}`)}}}else f?h.push(d):(u=d,f=!0)}}}}let p=[];if(!o)if(h.length===0||h.length===1&&h[0]==="-")p.push({source:"stdin",content:t.stdin});else{let m=await Bn(t,h,{cmdName:"jq",stopOnError:!0});if(m.exitCode!==0)return{stdout:"",stderr:m.stderr,exitCode:2};p=m.files.map(d=>({source:d.filename||"stdin",content:d.content}))}try{let m=Cp(u),d=[],g={limits:t.limits?{maxIterations:t.limits.maxJqIterations}:void 0,env:t.env};if(o)d=G(null,m,g);else if(i){let S=[];for(let{content:C}of p){let $=C.trim();$&&S.push(...vp($))}d=G(S,m,g)}else for(let{content:S}of p){let C=S.trim();if(!C)continue;let $=vp(C);for(let M of $)d.push(...G(M,m,g))}let y=d.map(S=>as(S,r,n,l,c)),w=a?"":`
556
+ ${o.repeat(i)}}`}return String(e)}var Fy,Uy,Op=I(()=>{"use strict";xe();Hn();ne();kp();Fy={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"]};Uy={name:"jq",async execute(e,t){if(F(e))return M(Fy);let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=".",f=!1,h=[];for(let m=0;m<e.length;m++){let d=e[m];if(d==="-r"||d==="--raw-output")n=!0;else if(d==="-c"||d==="--compact-output")r=!0;else if(d==="-e"||d==="--exit-status")s=!0;else if(d==="-s"||d==="--slurp")i=!0;else if(d==="-n"||d==="--null-input")o=!0;else if(d==="-j"||d==="--join-output")a=!0;else if(!(d==="-a"||d==="--ascii")){if(d==="-S"||d==="--sort-keys")l=!0;else if(!(d==="-C"||d==="--color")){if(!(d==="-M"||d==="--monochrome"))if(d==="--tab")c=!0;else if(d==="-")h.push("-");else{if(d.startsWith("--"))return X("jq",d);if(d.startsWith("-")){for(let g of d.slice(1))if(g==="r")n=!0;else if(g==="c")r=!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 X("jq",`-${g}`)}}}else f?h.push(d):(u=d,f=!0)}}}}let p=[];if(!o)if(h.length===0||h.length===1&&h[0]==="-")p.push({source:"stdin",content:t.stdin});else{let m=await Bn(t,h,{cmdName:"jq",stopOnError:!0});if(m.exitCode!==0)return{stdout:"",stderr:m.stderr,exitCode:2};p=m.files.map(d=>({source:d.filename||"stdin",content:d.content}))}try{let m=Cp(u),d=[],g={limits:t.limits?{maxIterations:t.limits.maxJqIterations}:void 0,env:t.env};if(o)d=G(null,m,g);else if(i){let S=[];for(let{content:C}of p){let R=C.trim();R&&S.push(...vp(R))}d=G(S,m,g)}else for(let{content:S}of p){let C=S.trim();if(!C)continue;let R=vp(C);for(let U of R)d.push(...G(U,m,g))}let y=d.map(S=>as(S,r,n,l,c)),w=a?"":`
557
557
  `,b=y.join(w),x=s&&(d.length===0||d.every(S=>S==null||S===!1))?1:0;return{stdout:b?a?b:`${b}
558
558
  `:"",stderr:"",exitCode:x}}catch(m){if(m instanceof re)return{stdout:"",stderr:`jq: ${m.message}
559
559
  `,exitCode:re.EXIT_CODE};let d=m.message;return d.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${d}
560
560
  `,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${d}
561
- `,exitCode:5}}}}});var $p={};Q($p,{base64Command:()=>Hy});async function Op(e,t,n){if(t.length===0||t.length===1&&t[0]==="-")return{ok:!0,data:Uint8Array.from(e.stdin,a=>a.charCodeAt(0))};let r=[];for(let a of t){if(a==="-"){r.push(Uint8Array.from(e.stdin,l=>l.charCodeAt(0)));continue}try{let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFileBuffer(l);r.push(c)}catch{return{ok:!1,error:{stdout:"",stderr:`${n}: ${a}: No such file or directory
562
- `,exitCode:1}}}}let s=r.reduce((a,l)=>a+l.length,0),i=new Uint8Array(s),o=0;for(let a of r)i.set(a,o),o+=a.length;return{ok:!0,data:i}}var Wy,By,Hy,Tp=I(()=>{"use strict";qe();ne();Wy={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"]},By={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};Hy={name:"base64",async execute(e,t){if(U(e))return F(Wy);let n=we("base64",e,By);if(!n.ok)return n.error;let r=n.result.flags.decode,s=n.result.flags.wrap,i=n.result.positional;try{if(r){let l=await Op(t,i,"base64");if(!l.ok)return l.error;let u=String.fromCharCode(...l.data).replace(/\s/g,"");return{stdout:atob(u),stderr:"",exitCode:0}}let o=await Op(t,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(`
561
+ `,exitCode:5}}}}});var $p={};Q($p,{base64Command:()=>Hy});async function Rp(e,t,n){if(t.length===0||t.length===1&&t[0]==="-")return{ok:!0,data:Uint8Array.from(e.stdin,a=>a.charCodeAt(0))};let r=[];for(let a of t){if(a==="-"){r.push(Uint8Array.from(e.stdin,l=>l.charCodeAt(0)));continue}try{let l=e.fs.resolvePath(e.cwd,a),c=await e.fs.readFileBuffer(l);r.push(c)}catch{return{ok:!1,error:{stdout:"",stderr:`${n}: ${a}: No such file or directory
562
+ `,exitCode:1}}}}let s=r.reduce((a,l)=>a+l.length,0),i=new Uint8Array(s),o=0;for(let a of r)i.set(a,o),o+=a.length;return{ok:!0,data:i}}var Wy,By,Hy,Tp=I(()=>{"use strict";qe();ne();Wy={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"]},By={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}};Hy={name:"base64",async execute(e,t){if(F(e))return M(Wy);let n=we("base64",e,By);if(!n.ok)return n.error;let r=n.result.flags.decode,s=n.result.flags.wrap,i=n.result.positional;try{if(r){let l=await Rp(t,i,"base64");if(!l.ok)return l.error;let u=String.fromCharCode(...l.data).replace(/\s/g,"");return{stdout:atob(u),stderr:"",exitCode:0}}let o=await Rp(t,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(`
563
563
  `)+(a.length>0?`
564
564
  `:"")}return{stdout:a,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`base64: invalid input
565
- `,exitCode:1}}}}});var Dp={};Q(Dp,{diffCommand:()=>Gy});import*as Pp from"diff";var zy,jy,Gy,Lp=I(()=>{"use strict";qe();ne();zy={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"]},jy={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"}},Gy={name:"diff",async execute(e,t){if(U(e))return F(zy);let n=we("diff",e,jy);if(!n.ok)return n.error;let r=n.result.flags.brief,s=n.result.flags.reportSame,i=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
565
+ `,exitCode:1}}}}});var Dp={};Q(Dp,{diffCommand:()=>Gy});import*as Pp from"diff";var zy,jy,Gy,Lp=I(()=>{"use strict";qe();ne();zy={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"]},jy={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"}},Gy={name:"diff",async execute(e,t){if(F(e))return M(zy);let n=we("diff",e,jy);if(!n.ok)return n.error;let r=n.result.flags.brief,s=n.result.flags.reportSame,i=n.result.flags.ignoreCase,o=n.result.positional;if(n.result.flags.unified,o.length<2)return{stdout:"",stderr:`diff: missing operand
566
566
  `,exitCode:2};let a,l,[c,u]=o;try{a=c==="-"?t.stdin:await t.fs.readFile(t.fs.resolvePath(t.cwd,c))}catch{return{stdout:"",stderr:`diff: ${c}: No such file or directory
567
567
  `,exitCode:2}}try{l=u==="-"?t.stdin:await t.fs.readFile(t.fs.resolvePath(t.cwd,u))}catch{return{stdout:"",stderr:`diff: ${u}: No such file or directory
568
568
  `,exitCode:2}}let f=a,h=l;return i&&(f=f.toLowerCase(),h=h.toLowerCase()),f===h?s?{stdout:`Files ${c} and ${u} are identical
569
569
  `,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:r?{stdout:`Files ${c} and ${u} differ
570
570
  `,stderr:"",exitCode:1}:{stdout:Pp.createTwoFilesPatch(c,u,a,l,"","",{context:3}),stderr:"",exitCode:1}}}});var _p={};Q(_p,{dateCommand:()=>Xy});function ht(e,t=2){return String(e).padStart(t,"0")}function Qy(e){let t=-e.getTimezoneOffset();return`${t>=0?"+":"-"}${ht(Math.floor(Math.abs(t)/60))}${ht(Math.abs(t)%60)}`}function yi(e,t,n){let r=n?{Y:e.getUTCFullYear(),m:e.getUTCMonth(),D:e.getUTCDate(),H:e.getUTCHours(),M:e.getUTCMinutes(),S:e.getUTCSeconds(),w:e.getUTCDay()}:{Y:e.getFullYear(),m:e.getMonth(),D:e.getDate(),H:e.getHours(),M:e.getMinutes(),S:e.getSeconds(),w:e.getDay()},s="",i=0;for(;i<t.length;){if(t[i]==="%"&&i+1<t.length){let o=t[++i];switch(o){case"%":s+="%";break;case"a":s+=qy[r.w];break;case"b":case"h":s+=Zy[r.m];break;case"d":s+=ht(r.D);break;case"e":s+=String(r.D).padStart(2," ");break;case"F":s+=`${r.Y}-${ht(r.m+1)}-${ht(r.D)}`;break;case"H":s+=ht(r.H);break;case"I":s+=ht(r.H%12||12);break;case"m":s+=ht(r.m+1);break;case"M":s+=ht(r.M);break;case"n":s+=`
571
- `;break;case"p":s+=r.H<12?"AM":"PM";break;case"P":s+=r.H<12?"am":"pm";break;case"R":s+=`${ht(r.H)}:${ht(r.M)}`;break;case"s":s+=Math.floor(e.getTime()/1e3);break;case"S":s+=ht(r.S);break;case"t":s+=" ";break;case"T":s+=`${ht(r.H)}:${ht(r.M)}:${ht(r.S)}`;break;case"u":s+=r.w||7;break;case"w":s+=r.w;break;case"y":s+=ht(r.Y%100);break;case"Y":s+=r.Y;break;case"z":s+=n?"+0000":Qy(e);break;case"Z":s+=n?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:s+=`%${o}`}}else s+=t[i];i++}return s}function Ky(e){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t;if(/^\d+$/.test(e))return new Date(Number.parseInt(e,10)*1e3);let n=e.toLowerCase();return n==="now"||n==="today"?new Date:n==="yesterday"?new Date(Date.now()-864e5):n==="tomorrow"?new Date(Date.now()+864e5):null}var Vy,qy,Zy,Xy,Mp=I(()=>{"use strict";ne();Vy={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"]},qy=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Zy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];Xy={name:"date",async execute(e,t){if(U(e))return F(Vy);let n=!1,r=null,s=null,i=!1,o=!1;for(let c=0;c<e.length;c++){let u=e[c];if(u==="-u"||u==="--utc")n=!0;else if(u==="-d"||u==="--date")r=e[++c]??"";else if(u.startsWith("--date="))r=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 X("date",u);if(u.startsWith("-"))for(let f of u.slice(1))if(f==="u")n=!0;else if(f==="I")i=!0;else if(f==="R")o=!0;else return X("date",`-${f}`)}}let a=r!==null?Ky(r):new Date;if(!a)return{stdout:"",stderr:`date: invalid date '${r}'
571
+ `;break;case"p":s+=r.H<12?"AM":"PM";break;case"P":s+=r.H<12?"am":"pm";break;case"R":s+=`${ht(r.H)}:${ht(r.M)}`;break;case"s":s+=Math.floor(e.getTime()/1e3);break;case"S":s+=ht(r.S);break;case"t":s+=" ";break;case"T":s+=`${ht(r.H)}:${ht(r.M)}:${ht(r.S)}`;break;case"u":s+=r.w||7;break;case"w":s+=r.w;break;case"y":s+=ht(r.Y%100);break;case"Y":s+=r.Y;break;case"z":s+=n?"+0000":Qy(e);break;case"Z":s+=n?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:s+=`%${o}`}}else s+=t[i];i++}return s}function Ky(e){let t=new Date(e);if(!Number.isNaN(t.getTime()))return t;if(/^\d+$/.test(e))return new Date(Number.parseInt(e,10)*1e3);let n=e.toLowerCase();return n==="now"||n==="today"?new Date:n==="yesterday"?new Date(Date.now()-864e5):n==="tomorrow"?new Date(Date.now()+864e5):null}var Vy,qy,Zy,Xy,Mp=I(()=>{"use strict";ne();Vy={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"]},qy=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Zy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];Xy={name:"date",async execute(e,t){if(F(e))return M(Vy);let n=!1,r=null,s=null,i=!1,o=!1;for(let c=0;c<e.length;c++){let u=e[c];if(u==="-u"||u==="--utc")n=!0;else if(u==="-d"||u==="--date")r=e[++c]??"";else if(u.startsWith("--date="))r=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 X("date",u);if(u.startsWith("-"))for(let f of u.slice(1))if(f==="u")n=!0;else if(f==="I")i=!0;else if(f==="R")o=!0;else return X("date",`-${f}`)}}let a=r!==null?Ky(r):new Date;if(!a)return{stdout:"",stderr:`date: invalid date '${r}'
572
572
  `,exitCode:1};let l;return s?l=yi(a,s,n):i?l=yi(a,"%Y-%m-%dT%H:%M:%S%z",n):o?l=yi(a,"%a, %d %b %Y %H:%M:%S %z",n):l=yi(a,"%a %b %e %H:%M:%S %Z %Y",n),{stdout:`${l}
573
573
  `,stderr:"",exitCode:0}}}});var Fp={};Q(Fp,{sleepCommand:()=>e9});function Jy(e){let t=e.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!t)return null;let n=parseFloat(t[1]);switch(t[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var Yy,e9,Up=I(()=>{"use strict";ne();Yy={name:"sleep",summary:"delay for a specified amount of time",usage:"sleep NUMBER[SUFFIX]",description:`Pause for NUMBER seconds. SUFFIX may be:
574
574
  s - seconds (default)
@@ -576,7 +576,7 @@ ${o.repeat(i)}}`}return String(e)}var Fy,Uy,Rp=I(()=>{"use strict";xe();Hn();ne(
576
576
  h - hours
577
577
  d - days
578
578
 
579
- NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};e9={name:"sleep",async execute(e,t){if(U(e))return F(Yy);if(e.length===0)return{stdout:"",stderr:`sleep: missing operand
579
+ NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};e9={name:"sleep",async execute(e,t){if(F(e))return M(Yy);if(e.length===0)return{stdout:"",stderr:`sleep: missing operand
580
580
  `,exitCode:1};let n=0;for(let r of e){let s=Jy(r);if(s===null)return{stdout:"",stderr:`sleep: invalid time interval '${r}'
581
581
  `,exitCode:1};n+=s}return t.sleep?await t.sleep(n):await new Promise(r=>setTimeout(r,n)),{stdout:"",stderr:"",exitCode:0}}}});var Wp={};Q(Wp,{timeoutCommand:()=>r9});function n9(e){let t=e.match(/^(\d+\.?\d*)(s|m|h|d)?$/);if(!t)return null;let n=parseFloat(t[1]);switch(t[2]||"s"){case"s":return n*1e3;case"m":return n*60*1e3;case"h":return n*60*60*1e3;case"d":return n*24*60*60*1e3;default:return null}}var t9,r9,Bp=I(()=>{"use strict";ne();t9={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.
582
582
 
@@ -584,7 +584,7 @@ DURATION is a number with optional suffix:
584
584
  s - seconds (default)
585
585
  m - minutes
586
586
  h - hours
587
- 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"]};r9={name:"timeout",async execute(e,t){if(U(e))return F(t9);let n=!1,r=0;for(let h=0;h<e.length;h++){let p=e[h];if(p==="--preserve-status")n=!0,r=h+1;else if(p==="--foreground")r=h+1;else if(p==="-k"||p==="--kill-after")h++,r=h+1;else if(p.startsWith("--kill-after="))r=h+1;else if(p==="-s"||p==="--signal")h++,r=h+1;else if(p.startsWith("--signal="))r=h+1;else{if(p.startsWith("--")&&p!=="--")return X("timeout",p);if(p.startsWith("-")&&p.length>1&&p!=="--")if(p.startsWith("-k"))r=h+1;else if(p.startsWith("-s"))r=h+1;else return X("timeout",p);else{r=h;break}}}let s=e.slice(r);if(s.length===0)return{stdout:"",stderr:`timeout: missing operand
587
+ 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"]};r9={name:"timeout",async execute(e,t){if(F(e))return M(t9);let n=!1,r=0;for(let h=0;h<e.length;h++){let p=e[h];if(p==="--preserve-status")n=!0,r=h+1;else if(p==="--foreground")r=h+1;else if(p==="-k"||p==="--kill-after")h++,r=h+1;else if(p.startsWith("--kill-after="))r=h+1;else if(p==="-s"||p==="--signal")h++,r=h+1;else if(p.startsWith("--signal="))r=h+1;else{if(p.startsWith("--")&&p!=="--")return X("timeout",p);if(p.startsWith("-")&&p.length>1&&p!=="--")if(p.startsWith("-k"))r=h+1;else if(p.startsWith("-s"))r=h+1;else return X("timeout",p);else{r=h;break}}}let s=e.slice(r);if(s.length===0)return{stdout:"",stderr:`timeout: missing operand
588
588
  `,exitCode:1};let i=s[0],o=n9(i);if(o===null)return{stdout:"",stderr:`timeout: invalid time interval '${i}'
589
589
  `,exitCode:1};let a=s.slice(1);if(a.length===0)return{stdout:"",stderr:`timeout: missing operand
590
590
  `,exitCode:1};if(!t.exec)return{stdout:"",stderr:`timeout: exec not available
@@ -608,26 +608,26 @@ sys 0.00
608
608
  `:"",stderr:"",exitCode:0}}}});var Vp={};Q(Vp,{exprCommand:()=>a9});function l9(e){if(e.length===1)return e[0];let t=0;function n(){let c=r();for(;t<e.length&&e[t]==="|";){t++;let u=r();if(c!=="0"&&c!=="")return c;c=u}return c}function r(){let c=s();for(;t<e.length&&e[t]==="&";){t++;let u=s();(c==="0"||c===""||u==="0"||u==="")&&(c="0")}return c}function s(){let c=i();for(;t<e.length;){let u=e[t];if(["=","!=","<",">","<=",">="].includes(u)){t++;let f=i(),h=parseInt(c,10),p=parseInt(f,10),m=!Number.isNaN(h)&&!Number.isNaN(p),d;u==="="?d=m?h===p:c===f:u==="!="?d=m?h!==p:c!==f:u==="<"?d=m?h<p:c<f:u===">"?d=m?h>p:c>f:u==="<="?d=m?h<=p:c<=f:d=m?h>=p:c>=f,c=d?"1":"0"}else break}return c}function i(){let c=o();for(;t<e.length;){let u=e[t];if(u==="+"||u==="-"){t++;let f=o(),h=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(h)||Number.isNaN(p))throw new Error("non-integer argument");c=String(u==="+"?h+p:h-p)}else break}return c}function o(){let c=a();for(;t<e.length;){let u=e[t];if(u==="*"||u==="/"||u==="%"){t++;let f=a(),h=parseInt(c,10),p=parseInt(f,10);if(Number.isNaN(h)||Number.isNaN(p))throw new Error("non-integer argument");if((u==="/"||u==="%")&&p===0)throw new Error("division by zero");u==="*"?c=String(h*p):u==="/"?c=String(Math.trunc(h/p)):c=String(h%p)}else break}return c}function a(){let c=l();for(;t<e.length&&e[t]===":";){t++;let u=l(),h=V(`^${u}`).match(c);h?c=h[1]!==void 0?h[1]:String(h[0].length):c="0"}return c}function l(){if(t>=e.length)throw new Error("syntax error");let c=e[t];if(c==="match"){t++;let u=l(),f=l(),p=V(f).match(u);return p?p[1]!==void 0?p[1]:String(p[0].length):"0"}if(c==="substr"){t++;let u=l(),f=parseInt(l(),10),h=parseInt(l(),10);if(Number.isNaN(f)||Number.isNaN(h))throw new Error("non-integer argument");return u.substring(f-1,f-1+h)}if(c==="index"){t++;let u=l(),f=l();for(let h=0;h<u.length;h++)if(f.includes(u[h]))return String(h+1);return"0"}if(c==="length"){t++;let u=l();return String(u.length)}if(c==="("){t++;let u=n();if(t>=e.length||e[t]!==")")throw new Error("syntax error");return t++,u}return t++,c}return n()}var a9,qp=I(()=>{"use strict";Me();a9={name:"expr",async execute(e,t){if(e.length===0)return{stdout:"",stderr:`expr: missing operand
609
609
  `,exitCode:2};try{let n=l9(e),r=n==="0"||n===""?1:0;return{stdout:`${n}
610
610
  `,stderr:"",exitCode:r}}catch(n){return{stdout:"",stderr:`expr: ${n.message}
611
- `,exitCode:2}}}}});function u9(e){function t(p,m){return p<<m|p>>>32-m}let n=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]),r=[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=e.length*8,i=(e.length%64<56?56:120)-e.length%64,o=new Uint8Array(e.length+i+8);o.set(e),o[e.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 m=new Uint32Array(16);for(let b=0;b<16;b++)m[b]=a.getUint32(p+b*4,!0);let d=l,g=c,y=u,w=f;for(let b=0;b<64;b++){let x,S;b<16?(x=g&y|~g&w,S=b):b<32?(x=w&g|~w&y,S=(5*b+1)%16):b<48?(x=g^y^w,S=(3*b+5)%16):(x=y^(g|~w),S=7*b%16),x=x+d+n[b]+m[S]>>>0,d=w,w=y,y=g,g=g+t(x,r[b])>>>0}l=l+d>>>0,c=c+g>>>0,u=u+y>>>0,f=f+w>>>0}let h=new Uint8Array(16);return new DataView(h.buffer).setUint32(0,l,!0),new DataView(h.buffer).setUint32(4,c,!0),new DataView(h.buffer).setUint32(8,u,!0),new DataView(h.buffer).setUint32(12,f,!0),Array.from(h).map(p=>p.toString(16).padStart(2,"0")).join("")}async function Zp(e,t){if(e==="md5")return u9(t);let n=c9.get(e);if(!n)throw new Error(`Unknown algorithm: ${e}`);let r=await globalThis.crypto.subtle.digest(n,new Uint8Array(t).buffer);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}function Cr(e,t,n){let r={name:e,summary:n,usage:`${e} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:e,async execute(s,i){if(U(s))return F(r);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 X(e,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return Uint8Array.from(i.stdin,h=>h.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,h="";for(let p of a){let m=p==="-"?i.stdin:await i.fs.readFile(i.fs.resolvePath(i.cwd,p)).catch(()=>null);if(m===null)return{stdout:"",stderr:`${e}: ${p}: No such file or directory
611
+ `,exitCode:2}}}}});function u9(e){function t(p,m){return p<<m|p>>>32-m}let n=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]),r=[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=e.length*8,i=(e.length%64<56?56:120)-e.length%64,o=new Uint8Array(e.length+i+8);o.set(e),o[e.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 m=new Uint32Array(16);for(let b=0;b<16;b++)m[b]=a.getUint32(p+b*4,!0);let d=l,g=c,y=u,w=f;for(let b=0;b<64;b++){let x,S;b<16?(x=g&y|~g&w,S=b):b<32?(x=w&g|~w&y,S=(5*b+1)%16):b<48?(x=g^y^w,S=(3*b+5)%16):(x=y^(g|~w),S=7*b%16),x=x+d+n[b]+m[S]>>>0,d=w,w=y,y=g,g=g+t(x,r[b])>>>0}l=l+d>>>0,c=c+g>>>0,u=u+y>>>0,f=f+w>>>0}let h=new Uint8Array(16);return new DataView(h.buffer).setUint32(0,l,!0),new DataView(h.buffer).setUint32(4,c,!0),new DataView(h.buffer).setUint32(8,u,!0),new DataView(h.buffer).setUint32(12,f,!0),Array.from(h).map(p=>p.toString(16).padStart(2,"0")).join("")}async function Zp(e,t){if(e==="md5")return u9(t);let n=c9.get(e);if(!n)throw new Error(`Unknown algorithm: ${e}`);let r=await globalThis.crypto.subtle.digest(n,new Uint8Array(t).buffer);return Array.from(new Uint8Array(r)).map(s=>s.toString(16).padStart(2,"0")).join("")}function Cr(e,t,n){let r={name:e,summary:n,usage:`${e} [OPTION]... [FILE]...`,options:["-c, --check read checksums from FILEs and check them"," --help display this help and exit"]};return{name:e,async execute(s,i){if(F(s))return M(r);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 X(e,f);a.push(f)}a.length===0&&a.push("-");let l=async f=>{if(f==="-")return Uint8Array.from(i.stdin,h=>h.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(o){let f=0,h="";for(let p of a){let m=p==="-"?i.stdin:await i.fs.readFile(i.fs.resolvePath(i.cwd,p)).catch(()=>null);if(m===null)return{stdout:"",stderr:`${e}: ${p}: No such file or directory
612
612
  `,exitCode:1};for(let d of m.split(`
613
613
  `)){let g=d.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!g)continue;let[,y,w]=g,b=await l(w);if(b===null){h+=`${w}: FAILED open or read
614
614
  `,f++;continue}let x=await Zp(t,b)===y.toLowerCase();h+=`${w}: ${x?"OK":"FAILED"}
615
615
  `,x||f++}}return f>0&&(h+=`${e}: WARNING: ${f} computed checksum${f>1?"s":""} did NOT match
616
616
  `),{stdout:h,stderr:"",exitCode:f>0?1:0}}let c="",u=0;for(let f of a){let h=await l(f);if(h===null){c+=`${e}: ${f}: No such file or directory
617
617
  `,u=1;continue}c+=`${await Zp(t,h)} ${f}
618
- `}return{stdout:c,stderr:"",exitCode:u}}}}var c9,wi=I(()=>{"use strict";ne();c9=new Map([["sha1","SHA-1"],["sha256","SHA-256"]])});var Qp={};Q(Qp,{md5sumCommand:()=>f9});var f9,Kp=I(()=>{"use strict";wi();f9=Cr("md5sum","md5","compute MD5 message digest")});var Xp={};Q(Xp,{sha1sumCommand:()=>h9});var h9,Yp=I(()=>{"use strict";wi();h9=Cr("sha1sum","sha1","compute SHA1 message digest")});var Jp={};Q(Jp,{sha256sumCommand:()=>p9});var p9,ed=I(()=>{"use strict";wi();p9=Cr("sha256sum","sha256","compute SHA256 message digest")});var td=$s(za=>{za.read=function(e,t,n,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,c=l>>1,u=-7,f=n?s-1:0,h=n?-1:1,p=e[t+f];for(f+=h,i=p&(1<<-u)-1,p>>=-u,u+=a;u>0;i=i*256+e[t+f],f+=h,u-=8);for(o=i&(1<<-u)-1,i>>=-u,u+=r;u>0;o=o*256+e[t+f],f+=h,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,r),i=i-c}return(p?-1:1)*o*Math.pow(2,i-r)};za.write=function(e,t,n,r,s,i){var o,a,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,h=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,m=r?1:-1,d=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?t+=h/l:t+=h*Math.pow(2,1-f),t*l>=2&&(o++,l/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(t*l-1)*Math.pow(2,s),o=o+f):(a=t*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;e[n+p]=a&255,p+=m,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;e[n+p]=o&255,p+=m,o/=256,c-=8);e[n+p-m]|=d*128}});function nd(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):m9(e);case"utf-16le":return g9(e);case"ascii":return y9(e);case"latin1":case"iso-8859-1":return w9(e);case"windows-1252":return b9(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function m9(e){let t="",n=0;for(;n<e.length;){let r=e[n++];if(r<128)t+=String.fromCharCode(r);else if(r<224){let s=e[n++]&63;t+=String.fromCharCode((r&31)<<6|s)}else if(r<240){let s=e[n++]&63,i=e[n++]&63;t+=String.fromCharCode((r&15)<<12|s<<6|i)}else{let s=e[n++]&63,i=e[n++]&63,o=e[n++]&63,a=(r&7)<<18|s<<12|i<<6|o;a-=65536,t+=String.fromCharCode(55296+(a>>10&1023),56320+(a&1023))}}return t}function g9(e){let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function y9(e){return String.fromCharCode(...e.map(t=>t&127))}function w9(e){return String.fromCharCode(...e)}function b9(e){let t="";for(let n of e)n>=128&&n<=159&&ja[n]?t+=ja[n]:t+=String.fromCharCode(n);return t}var ja,d9,rd=I(()=>{ja={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"},d9={};for(let[e,t]of Object.entries(ja))d9[t]=Number.parseInt(e)});function Nt(e){return new DataView(e.buffer,e.byteOffset)}var sd,id,Ge,Nr,Ze,od,ad,ld,kt,ls=I(()=>{sd=eu(td(),1);rd();id={len:1,get(e,t){return Nt(e).getUint8(t)},put(e,t,n){return Nt(e).setUint8(t,n),t+1}},Ge={len:2,get(e,t){return Nt(e).getUint16(t,!0)},put(e,t,n){return Nt(e).setUint16(t,n,!0),t+2}},Nr={len:2,get(e,t){return Nt(e).getUint16(t)},put(e,t,n){return Nt(e).setUint16(t,n),t+2}},Ze={len:4,get(e,t){return Nt(e).getUint32(t,!0)},put(e,t,n){return Nt(e).setUint32(t,n,!0),t+4}},od={len:4,get(e,t){return Nt(e).getUint32(t)},put(e,t,n){return Nt(e).setUint32(t,n),t+4}},ad={len:4,get(e,t){return Nt(e).getInt32(t)},put(e,t,n){return Nt(e).setInt32(t,n),t+4}},ld={len:8,get(e,t){return Nt(e).getBigUint64(t,!0)},put(e,t,n){return Nt(e).setBigUint64(t,n,!0),t+8}},kt=class{constructor(t,n){this.len=t,this.encoding=n}get(t,n=0){let r=t.subarray(n,n+this.len);return nd(r,this.encoding)}}});var E9,Ue,Vn,cs=I(()=>{E9="End-Of-Stream",Ue=class extends Error{constructor(){super(E9),this.name="EndOfStreamError"}},Vn=class extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}});var cd=I(()=>{});var qn,bi=I(()=>{cs();qn=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(t,n=!1){let r=await this.read(t,n);return this.peekQueue.push(t.subarray(0,r)),r}async read(t,n=!1){if(t.length===0)return 0;let r=this.readFromPeekBuffer(t);if(this.endOfStream||(r+=await this.readRemainderFromStream(t.subarray(r),n)),r===0&&!n)throw new Ue;return r}readFromPeekBuffer(t){let n=t.length,r=0;for(;this.peekQueue.length>0&&n>0;){let s=this.peekQueue.pop();if(!s)throw new Error("peekData should be defined");let i=Math.min(s.length,n);t.set(s.subarray(0,i),r),r+=i,n-=i,i<s.length&&this.peekQueue.push(s.subarray(i))}return r}async readRemainderFromStream(t,n){let r=0;for(;r<t.length&&!this.endOfStream;){if(this.interrupted)throw new Vn;let s=await this.readFromStream(t.subarray(r),n);if(s===0)break;r+=s}if(!n&&r<t.length)throw new Ue;return r}}});var ud=I(()=>{cs();cd();bi()});var xi,fd=I(()=>{bi();xi=class extends qn{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var us,Ga=I(()=>{fd();us=class extends xi{async readFromStream(t,n){if(t.length===0)return 0;let r=await this.reader.read(new Uint8Array(t.length),{min:n?void 0:t.length});return r.done&&(this.endOfStream=r.done),r.value?(t.set(r.value),r.value.length):0}}});var kr,Va=I(()=>{cs();bi();kr=class extends qn{constructor(t){super(),this.reader=t,this.buffer=null}writeChunk(t,n){let r=Math.min(n.length,t.length);return t.set(n.subarray(0,r)),r<n.length?this.buffer=n.subarray(r):this.buffer=null,r}async readFromStream(t,n){if(t.length===0)return 0;let r=0;for(this.buffer&&(r+=this.writeChunk(t,this.buffer));r<t.length&&!this.endOfStream;){let s=await this.reader.read();if(s.done){this.endOfStream=!0;break}s.value&&(r+=this.writeChunk(t.subarray(r),s.value))}if(!n&&r===0&&this.endOfStream)throw new Ue;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function qa(e){try{let t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new kr(t):new us(t)}catch(t){if(t instanceof TypeError)return new kr(e.getReader());throw t}}var hd=I(()=>{Ga();Va()});var Zn=I(()=>{cs();ud();Ga();Va();hd()});var xn,fs=I(()=>{Zn();xn=class{constructor(t){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=t?.onClose,t?.abortSignal&&t.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(t,n=this.position){let r=new Uint8Array(t.len);if(await this.readBuffer(r,{position:n})<t.len)throw new Ue;return t.get(r,0)}async peekToken(t,n=this.position){let r=new Uint8Array(t.len);if(await this.peekBuffer(r,{position:n})<t.len)throw new Ue;return t.get(r,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new Ue;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new Ue;return t.get(this.numBuffer,0)}async ignore(t){if(this.fileInfo.size!==void 0){let n=this.fileInfo.size-this.position;if(t>n)return this.position+=n,n}return this.position+=t,t}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(t,n){if(!this.supportsRandomAccess()&&n&&n.position!==void 0&&n.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:t.length,position:this.position,...n}}abort(){return Promise.resolve()}}});var S9,Ei,pd=I(()=>{fs();Zn();S9=256e3,Ei=class extends xn{constructor(t,n){super(n),this.streamReader=t,this.fileInfo=n?.fileInfo??{}}async readBuffer(t,n){let r=this.normalizeOptions(t,n),s=r.position-this.position;if(s>0)return await this.ignore(s),this.readBuffer(t,n);if(s<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(r.length===0)return 0;let i=await this.streamReader.read(t.subarray(0,r.length),r.mayBeLess);if(this.position+=i,(!n||!n.mayBeLess)&&i<r.length)throw new Ue;return i}async peekBuffer(t,n){let r=this.normalizeOptions(t,n),s=0;if(r.position){let i=r.position-this.position;if(i>0){let o=new Uint8Array(r.length+i);return s=await this.peekBuffer(o,{mayBeLess:r.mayBeLess}),t.set(o.subarray(i)),s-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(r.length>0){try{s=await this.streamReader.peek(t.subarray(0,r.length),r.mayBeLess)}catch(i){if(n?.mayBeLess&&i instanceof Ue)return 0;throw i}if(!r.mayBeLess&&s<r.length)throw new Ue}return s}async ignore(t){let n=Math.min(S9,t),r=new Uint8Array(n),s=0;for(;s<t;){let i=t-s,o=await this.readBuffer(r,{length:Math.min(n,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 Ai,dd=I(()=>{Zn();fs();Ai=class extends xn{constructor(t,n){super(n),this.uint8Array=t,this.fileInfo={...n?.fileInfo??{},size:t.length}}async readBuffer(t,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(t,n);return this.position+=r,r}async peekBuffer(t,n){let r=this.normalizeOptions(t,n),s=Math.min(this.uint8Array.length-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new Ue;return t.set(this.uint8Array.subarray(r.position,r.position+s)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}});var Si,md=I(()=>{Zn();fs();Si=class extends xn{constructor(t,n){super(n),this.blob=t,this.fileInfo={...n?.fileInfo??{},size:t.size,mimeType:t.type}}async readBuffer(t,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(t,n);return this.position+=r,r}async peekBuffer(t,n){let r=this.normalizeOptions(t,n),s=Math.min(this.blob.size-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new Ue;let i=await this.blob.slice(r.position,r.position+s).arrayBuffer();return t.set(new Uint8Array(i)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}});function gd(e,t){let n=qa(e),r=t??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new Ei(n,r)}function yd(e,t){return new Ai(e,t)}function wd(e,t){return new Si(e,t)}var bd=I(()=>{Zn();pd();dd();md();Zn();fs()});var Ed=$s((uk,xd)=>{var vr=1e3,Ir=vr*60,Rr=Ir*60,Qn=Rr*24,N9=Qn*7,k9=Qn*365.25;xd.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return v9(e);if(n==="number"&&isFinite(e))return t.long?R9(e):I9(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function v9(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*k9;case"weeks":case"week":case"w":return n*N9;case"days":case"day":case"d":return n*Qn;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Rr;case"minutes":case"minute":case"mins":case"min":case"m":return n*Ir;case"seconds":case"second":case"secs":case"sec":case"s":return n*vr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function I9(e){var t=Math.abs(e);return t>=Qn?Math.round(e/Qn)+"d":t>=Rr?Math.round(e/Rr)+"h":t>=Ir?Math.round(e/Ir)+"m":t>=vr?Math.round(e/vr)+"s":e+"ms"}function R9(e){var t=Math.abs(e);return t>=Qn?Ci(e,t,Qn,"day"):t>=Rr?Ci(e,t,Rr,"hour"):t>=Ir?Ci(e,t,Ir,"minute"):t>=vr?Ci(e,t,vr,"second"):e+" ms"}function Ci(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}});var Sd=$s((fk,Ad)=>{function O9(e){n.debug=n,n.default=n,n.coerce=l,n.disable=o,n.enable=s,n.enabled=a,n.humanize=Ed(),n.destroy=c,Object.keys(e).forEach(u=>{n[u]=e[u]}),n.names=[],n.skips=[],n.formatters={};function t(u){let f=0;for(let h=0;h<u.length;h++)f=(f<<5)-f+u.charCodeAt(h),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(u){let f,h=null,p,m;function d(...g){if(!d.enabled)return;let y=d,w=Number(new Date),b=w-(f||w);y.diff=b,y.prev=f,y.curr=w,f=w,g[0]=n.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let x=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(C,$)=>{if(C==="%%")return"%";x++;let M=n.formatters[$];if(typeof M=="function"){let _=g[x];C=M.call(y,_),g.splice(x,1),x--}return C}),n.formatArgs.call(y,g),(y.log||n.log).apply(y,g)}return d.namespace=u,d.useColors=n.useColors(),d.color=n.selectColor(u),d.extend=r,d.destroy=n.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(p!==n.namespaces&&(p=n.namespaces,m=n.enabled(u)),m),set:g=>{h=g}}),typeof n.init=="function"&&n.init(d),d}function r(u,f){let h=n(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function s(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];let f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let h of f)h[0]==="-"?n.skips.push(h.slice(1)):n.names.push(h)}function i(u,f){let h=0,p=0,m=-1,d=0;for(;h<u.length;)if(p<f.length&&(f[p]===u[h]||f[p]==="*"))f[p]==="*"?(m=p,d=h,p++):(h++,p++);else if(m!==-1)p=m+1,d++,h=d;else return!1;for(;p<f.length&&f[p]==="*";)p++;return p===f.length}function o(){let u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function a(u){for(let f of n.skips)if(i(u,f))return!1;for(let f of n.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 n.enable(n.load()),n}Ad.exports=O9});var Cd=$s((vt,Ni)=>{vt.formatArgs=T9;vt.save=P9;vt.load=D9;vt.useColors=$9;vt.storage=L9();vt.destroy=(()=>{let e=!1;return()=>{e||(e=!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`."))}})();vt.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 $9(){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 e;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&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function T9(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ni.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let n=0,r=0;e[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(n++,s==="%c"&&(r=n))}),e.splice(r,0,t)}vt.log=console.debug||console.log||(()=>{});function P9(e){try{e?vt.storage.setItem("debug",e):vt.storage.removeItem("debug")}catch{}}function D9(){let e;try{e=vt.storage.getItem("debug")||vt.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function L9(){try{return localStorage}catch{}}Ni.exports=Sd()(vt);var{formatters:_9}=Ni.exports;_9.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Kn,Za,Nd,kd,vd,Id=I(()=>{ls();Kn={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Za={get(e){return{signature:Ze.get(e,0),compressedSize:Ze.get(e,8),uncompressedSize:Ze.get(e,12)}},len:16},Nd={get(e){let t=Ge.get(e,6);return{signature:Ze.get(e,0),minVersion:Ge.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,8),compressedSize:Ze.get(e,18),uncompressedSize:Ze.get(e,22),filenameLength:Ge.get(e,26),extraFieldLength:Ge.get(e,28),filename:null}},len:30},kd={get(e){return{signature:Ze.get(e,0),nrOfThisDisk:Ge.get(e,4),nrOfThisDiskWithTheStart:Ge.get(e,6),nrOfEntriesOnThisDisk:Ge.get(e,8),nrOfEntriesOfSize:Ge.get(e,10),sizeOfCd:Ze.get(e,12),offsetOfStartOfCd:Ze.get(e,16),zipFileCommentLength:Ge.get(e,20)}},len:22},vd={get(e){let t=Ge.get(e,8);return{signature:Ze.get(e,0),minVersion:Ge.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,10),compressedSize:Ze.get(e,20),uncompressedSize:Ze.get(e,24),filenameLength:Ge.get(e,28),extraFieldLength:Ge.get(e,30),fileCommentLength:Ge.get(e,32),relativeOffsetOfLocalHeader:Ze.get(e,42),filename:null}},len:46}});function Od(e){let t=new Uint8Array(Ze.len);return Ze.put(t,0,e),t}function F9(e,t){let n=e.length,r=t.length;if(r>n)return-1;for(let s=0;s<=n-r;s++){let i=!0;for(let o=0;o<r;o++)if(e[s+o]!==t[o]){i=!1;break}if(i)return s}return-1}function U9(e){let t=e.reduce((s,i)=>s+i.length,0),n=new Uint8Array(t),r=0;for(let s of e)n.set(s,r),r+=s.length;return n}var Rd,un,Qa,M9,ki,hs,$d=I(()=>{ls();Rd=eu(Cd(),1);Id();un=(0,Rd.default)("tokenizer:inflate"),Qa=256*1024,M9=Od(Kn.DataDescriptor),ki=Od(Kn.EndOfCentralDirectory),hs=class e{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(Qa)}async isZip(){return await this.peekSignature()===Kn.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Ze)}async findEndOfCentralDirectoryLocator(){let t=this.tokenizer,n=Math.min(16*1024,t.fileInfo.size),r=this.syncBuffer.subarray(0,n);await this.tokenizer.readBuffer(r,{position:t.fileInfo.size-n});for(let s=r.length-4;s>=0;s--)if(r[s]===ki[0]&&r[s+1]===ki[1]&&r[s+2]===ki[2]&&r[s+3]===ki[3])return t.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){un("Cannot reading central-directory without random-read support");return}un("Reading central-directory...");let t=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){un("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(kd,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken(vd);if(o.signature!==Kn.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new kt(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),un(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(t),s}this.tokenizer.setPosition(t)}async unzip(t){let n=await this.readCentralDirectory();if(n)return this.iterateOverCentralDirectory(n,t);let r=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=t(s);r=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=Qa;un("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===Qa;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=F9(this.syncBuffer.subarray(0,l),M9);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)}un(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,U9(a),i.handler)}else i.handler?(un(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(un(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(un(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(Za)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Za.len}`)}while(!r)}async iterateOverCentralDirectory(t,n){for(let r of t){let s=n(r);if(s.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(t,n,r){if(t.compressedMethod===0)return r(n);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);un(`Decompress filename=${t.filename}, compressed-size=${n.length}`);let s=await e.decompressDeflateRaw(n);return r(s)}static async decompressDeflateRaw(t){let n=new ReadableStream({start(i){i.enqueue(t),i.close()}}),r=new DecompressionStream("deflate-raw"),s=n.pipeThrough(r);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 t=await this.tokenizer.peekToken(Ze);if(t===Kn.LocalFileHeader){let n=await this.tokenizer.readToken(Nd);return n.filename=await this.tokenizer.readToken(new kt(n.filenameLength,"utf-8")),n}if(t===Kn.CentralFileHeader)return!1;throw t===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var ps,Td=I(()=>{ps=class{constructor(t){this.tokenizer=t}inflate(){let t=this.tokenizer;return new ReadableStream({async pull(n){let r=new Uint8Array(1024),s=await t.readBuffer(r,{mayBeLess:!0});if(s===0){n.close();return}n.enqueue(r.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var Pd=I(()=>{$d();Td()});function Ka(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}var Ek,Ak,Sk,Dd=I(()=>{Ek={utf8:new globalThis.TextDecoder("utf8")},Ak=new globalThis.TextEncoder,Sk=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});function Ld(e,t){if(t==="utf-16le"){let n=[];for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);n.push(s&255,s>>8&255)}return n}if(t==="utf-16be"){let n=[];for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);n.push(s>>8&255,s&255)}return n}return[...e].map(n=>n.charCodeAt(0))}function _d(e,t=0){let n=Number.parseInt(new kt(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let s=t;s<t+148;s++)r+=e[s];for(let s=t+156;s<t+512;s++)r+=e[s];return n===r}var Md,Fd=I(()=>{ls();Md={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}});var Ud,Wd,Bd=I(()=>{Ud=["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"],Wd=["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 Hd(e,t){return new Ja(t).fromBuffer(e)}function Ya(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};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:e};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:e};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:e};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:e};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:e};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 fn(e,t,n){n={offset:0,...n};for(let[r,s]of t.entries())if(n.mask){if(s!==(n.mask[r]&e[r+n.offset]))return!1}else if(s!==e[r+n.offset])return!1;return!0}var Xa,Ja,Tk,Pk,zd=I(()=>{ls();bd();Pd();Dd();Fd();Bd();Xa=4100;Ja=class{constructor(t){this.options={mpegOffsetTolerance:0,...t},this.detectors=[...t?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:t?.signal}}async fromTokenizer(t){let n=t.position;for(let r of this.detectors){let s=await r.detect(t);if(s)return s;if(n!==t.position)return}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);let n=t instanceof Uint8Array?t:new Uint8Array(t);if(n?.length>1)return this.fromTokenizer(yd(n,this.tokenizerOptions))}async fromBlob(t){let n=wd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(t){let n=gd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(t,n){let{sampleSize:r=Xa}=n,s,i,o=t.getReader({mode:"byob"});try{let{value:c,done:u}=await o.read(new Uint8Array(r));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof Ue))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=t.pipeThrough(a);return l.fileType=s,l}check(t,n){return fn(this.buffer,t,n)}checkString(t,n){return this.check(Ld(t,n?.encoding),n)}detectConfident=async t=>{if(this.buffer=new Uint8Array(Xa),t.fileInfo.size===void 0&&(t.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=t,await t.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 t.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(t);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 r=new ps(t).inflate(),s=!0;try{let i;try{i=await this.fromStream(r)}catch{s=!1}if(i&&i.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{s&&await r.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 t.ignore(6);let n=await t.readToken(Md);return t.position+n>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(n),this.fromTokenizer(t))}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 n;return await new hs(t).unzip(r=>{switch(r.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(s){let i=new TextDecoder("utf-8").decode(s).trim();n=Ya(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}"`)&&(n=Ya(a))}else{i=i.slice(0,Math.max(0,o));let a=i.lastIndexOf('"'),l=i.slice(Math.max(0,a+1));n=Ya(l)}},stop:!0};default:return/classes\d*\.dex/.test(r.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(r=>{if(!(r instanceof Ue))throw r}),n??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let n=new Uint8Array(8);return await t.readBuffer(n),fn(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:fn(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:fn(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:fn(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:fn(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:fn(n,[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 n=await this.readTiffHeader(!1);if(n)return n}if(this.check([77,77])){let n=await this.readTiffHeader(!0);if(n)return n}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function n(){let a=await t.peekNumber(id),l=128,c=0;for(;(a&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await t.readBuffer(u),u}async function r(){let a=await n(),l=await n();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:Ka(u),len:Ka(f)}}async function s(a){for(;a>0;){let l=await r();if(l.id===17026)return(await t.readToken(new kt(l.len))).replaceAll(/\00.*$/g,"");await t.ignore(l.len),--a}}let i=await r();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 n=new kt(4,"latin1").get(this.buffer,2);if(n.match("^d*")&&n>=1e3&&n<=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 t.ignore(8),await t.readToken(new kt(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
618
+ `}return{stdout:c,stderr:"",exitCode:u}}}}var c9,wi=I(()=>{"use strict";ne();c9=new Map([["sha1","SHA-1"],["sha256","SHA-256"]])});var Qp={};Q(Qp,{md5sumCommand:()=>f9});var f9,Kp=I(()=>{"use strict";wi();f9=Cr("md5sum","md5","compute MD5 message digest")});var Xp={};Q(Xp,{sha1sumCommand:()=>h9});var h9,Yp=I(()=>{"use strict";wi();h9=Cr("sha1sum","sha1","compute SHA1 message digest")});var Jp={};Q(Jp,{sha256sumCommand:()=>p9});var p9,ed=I(()=>{"use strict";wi();p9=Cr("sha256sum","sha256","compute SHA256 message digest")});var td=$s(za=>{za.read=function(e,t,n,r,s){var i,o,a=s*8-r-1,l=(1<<a)-1,c=l>>1,u=-7,f=n?s-1:0,h=n?-1:1,p=e[t+f];for(f+=h,i=p&(1<<-u)-1,p>>=-u,u+=a;u>0;i=i*256+e[t+f],f+=h,u-=8);for(o=i&(1<<-u)-1,i>>=-u,u+=r;u>0;o=o*256+e[t+f],f+=h,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,r),i=i-c}return(p?-1:1)*o*Math.pow(2,i-r)};za.write=function(e,t,n,r,s,i){var o,a,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,h=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:i-1,m=r?1:-1,d=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+f>=1?t+=h/l:t+=h*Math.pow(2,1-f),t*l>=2&&(o++,l/=2),o+f>=u?(a=0,o=u):o+f>=1?(a=(t*l-1)*Math.pow(2,s),o=o+f):(a=t*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;e[n+p]=a&255,p+=m,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;e[n+p]=o&255,p+=m,o/=256,c-=8);e[n+p-m]|=d*128}});function nd(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):m9(e);case"utf-16le":return g9(e);case"ascii":return y9(e);case"latin1":case"iso-8859-1":return w9(e);case"windows-1252":return b9(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function m9(e){let t="",n=0;for(;n<e.length;){let r=e[n++];if(r<128)t+=String.fromCharCode(r);else if(r<224){let s=e[n++]&63;t+=String.fromCharCode((r&31)<<6|s)}else if(r<240){let s=e[n++]&63,i=e[n++]&63;t+=String.fromCharCode((r&15)<<12|s<<6|i)}else{let s=e[n++]&63,i=e[n++]&63,o=e[n++]&63,a=(r&7)<<18|s<<12|i<<6|o;a-=65536,t+=String.fromCharCode(55296+(a>>10&1023),56320+(a&1023))}}return t}function g9(e){let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function y9(e){return String.fromCharCode(...e.map(t=>t&127))}function w9(e){return String.fromCharCode(...e)}function b9(e){let t="";for(let n of e)n>=128&&n<=159&&ja[n]?t+=ja[n]:t+=String.fromCharCode(n);return t}var ja,d9,rd=I(()=>{ja={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"},d9={};for(let[e,t]of Object.entries(ja))d9[t]=Number.parseInt(e)});function Nt(e){return new DataView(e.buffer,e.byteOffset)}var sd,id,Ge,Nr,Ze,od,ad,ld,kt,ls=I(()=>{sd=eu(td(),1);rd();id={len:1,get(e,t){return Nt(e).getUint8(t)},put(e,t,n){return Nt(e).setUint8(t,n),t+1}},Ge={len:2,get(e,t){return Nt(e).getUint16(t,!0)},put(e,t,n){return Nt(e).setUint16(t,n,!0),t+2}},Nr={len:2,get(e,t){return Nt(e).getUint16(t)},put(e,t,n){return Nt(e).setUint16(t,n),t+2}},Ze={len:4,get(e,t){return Nt(e).getUint32(t,!0)},put(e,t,n){return Nt(e).setUint32(t,n,!0),t+4}},od={len:4,get(e,t){return Nt(e).getUint32(t)},put(e,t,n){return Nt(e).setUint32(t,n),t+4}},ad={len:4,get(e,t){return Nt(e).getInt32(t)},put(e,t,n){return Nt(e).setInt32(t,n),t+4}},ld={len:8,get(e,t){return Nt(e).getBigUint64(t,!0)},put(e,t,n){return Nt(e).setBigUint64(t,n,!0),t+8}},kt=class{constructor(t,n){this.len=t,this.encoding=n}get(t,n=0){let r=t.subarray(n,n+this.len);return nd(r,this.encoding)}}});var E9,Ue,Vn,cs=I(()=>{E9="End-Of-Stream",Ue=class extends Error{constructor(){super(E9),this.name="EndOfStreamError"}},Vn=class extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}});var cd=I(()=>{});var qn,bi=I(()=>{cs();qn=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(t,n=!1){let r=await this.read(t,n);return this.peekQueue.push(t.subarray(0,r)),r}async read(t,n=!1){if(t.length===0)return 0;let r=this.readFromPeekBuffer(t);if(this.endOfStream||(r+=await this.readRemainderFromStream(t.subarray(r),n)),r===0&&!n)throw new Ue;return r}readFromPeekBuffer(t){let n=t.length,r=0;for(;this.peekQueue.length>0&&n>0;){let s=this.peekQueue.pop();if(!s)throw new Error("peekData should be defined");let i=Math.min(s.length,n);t.set(s.subarray(0,i),r),r+=i,n-=i,i<s.length&&this.peekQueue.push(s.subarray(i))}return r}async readRemainderFromStream(t,n){let r=0;for(;r<t.length&&!this.endOfStream;){if(this.interrupted)throw new Vn;let s=await this.readFromStream(t.subarray(r),n);if(s===0)break;r+=s}if(!n&&r<t.length)throw new Ue;return r}}});var ud=I(()=>{cs();cd();bi()});var xi,fd=I(()=>{bi();xi=class extends qn{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var us,Ga=I(()=>{fd();us=class extends xi{async readFromStream(t,n){if(t.length===0)return 0;let r=await this.reader.read(new Uint8Array(t.length),{min:n?void 0:t.length});return r.done&&(this.endOfStream=r.done),r.value?(t.set(r.value),r.value.length):0}}});var kr,Va=I(()=>{cs();bi();kr=class extends qn{constructor(t){super(),this.reader=t,this.buffer=null}writeChunk(t,n){let r=Math.min(n.length,t.length);return t.set(n.subarray(0,r)),r<n.length?this.buffer=n.subarray(r):this.buffer=null,r}async readFromStream(t,n){if(t.length===0)return 0;let r=0;for(this.buffer&&(r+=this.writeChunk(t,this.buffer));r<t.length&&!this.endOfStream;){let s=await this.reader.read();if(s.done){this.endOfStream=!0;break}s.value&&(r+=this.writeChunk(t.subarray(r),s.value))}if(!n&&r===0&&this.endOfStream)throw new Ue;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function qa(e){try{let t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new kr(t):new us(t)}catch(t){if(t instanceof TypeError)return new kr(e.getReader());throw t}}var hd=I(()=>{Ga();Va()});var Zn=I(()=>{cs();ud();Ga();Va();hd()});var xn,fs=I(()=>{Zn();xn=class{constructor(t){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=t?.onClose,t?.abortSignal&&t.abortSignal.addEventListener("abort",()=>{this.abort()})}async readToken(t,n=this.position){let r=new Uint8Array(t.len);if(await this.readBuffer(r,{position:n})<t.len)throw new Ue;return t.get(r,0)}async peekToken(t,n=this.position){let r=new Uint8Array(t.len);if(await this.peekBuffer(r,{position:n})<t.len)throw new Ue;return t.get(r,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new Ue;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new Ue;return t.get(this.numBuffer,0)}async ignore(t){if(this.fileInfo.size!==void 0){let n=this.fileInfo.size-this.position;if(t>n)return this.position+=n,n}return this.position+=t,t}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(t,n){if(!this.supportsRandomAccess()&&n&&n.position!==void 0&&n.position<this.position)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:t.length,position:this.position,...n}}abort(){return Promise.resolve()}}});var S9,Ei,pd=I(()=>{fs();Zn();S9=256e3,Ei=class extends xn{constructor(t,n){super(n),this.streamReader=t,this.fileInfo=n?.fileInfo??{}}async readBuffer(t,n){let r=this.normalizeOptions(t,n),s=r.position-this.position;if(s>0)return await this.ignore(s),this.readBuffer(t,n);if(s<0)throw new Error("`options.position` must be equal or greater than `tokenizer.position`");if(r.length===0)return 0;let i=await this.streamReader.read(t.subarray(0,r.length),r.mayBeLess);if(this.position+=i,(!n||!n.mayBeLess)&&i<r.length)throw new Ue;return i}async peekBuffer(t,n){let r=this.normalizeOptions(t,n),s=0;if(r.position){let i=r.position-this.position;if(i>0){let o=new Uint8Array(r.length+i);return s=await this.peekBuffer(o,{mayBeLess:r.mayBeLess}),t.set(o.subarray(i)),s-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}if(r.length>0){try{s=await this.streamReader.peek(t.subarray(0,r.length),r.mayBeLess)}catch(i){if(n?.mayBeLess&&i instanceof Ue)return 0;throw i}if(!r.mayBeLess&&s<r.length)throw new Ue}return s}async ignore(t){let n=Math.min(S9,t),r=new Uint8Array(n),s=0;for(;s<t;){let i=t-s,o=await this.readBuffer(r,{length:Math.min(n,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 Ai,dd=I(()=>{Zn();fs();Ai=class extends xn{constructor(t,n){super(n),this.uint8Array=t,this.fileInfo={...n?.fileInfo??{},size:t.length}}async readBuffer(t,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(t,n);return this.position+=r,r}async peekBuffer(t,n){let r=this.normalizeOptions(t,n),s=Math.min(this.uint8Array.length-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new Ue;return t.set(this.uint8Array.subarray(r.position,r.position+s)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}});var Si,md=I(()=>{Zn();fs();Si=class extends xn{constructor(t,n){super(n),this.blob=t,this.fileInfo={...n?.fileInfo??{},size:t.size,mimeType:t.type}}async readBuffer(t,n){n?.position&&(this.position=n.position);let r=await this.peekBuffer(t,n);return this.position+=r,r}async peekBuffer(t,n){let r=this.normalizeOptions(t,n),s=Math.min(this.blob.size-r.position,r.length);if(!r.mayBeLess&&s<r.length)throw new Ue;let i=await this.blob.slice(r.position,r.position+s).arrayBuffer();return t.set(new Uint8Array(i)),s}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(t){this.position=t}}});function gd(e,t){let n=qa(e),r=t??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new Ei(n,r)}function yd(e,t){return new Ai(e,t)}function wd(e,t){return new Si(e,t)}var bd=I(()=>{Zn();pd();dd();md();Zn();fs()});var Ed=$s((uk,xd)=>{var vr=1e3,Ir=vr*60,Or=Ir*60,Qn=Or*24,N9=Qn*7,k9=Qn*365.25;xd.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return v9(e);if(n==="number"&&isFinite(e))return t.long?O9(e):I9(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function v9(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*k9;case"weeks":case"week":case"w":return n*N9;case"days":case"day":case"d":return n*Qn;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Or;case"minutes":case"minute":case"mins":case"min":case"m":return n*Ir;case"seconds":case"second":case"secs":case"sec":case"s":return n*vr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function I9(e){var t=Math.abs(e);return t>=Qn?Math.round(e/Qn)+"d":t>=Or?Math.round(e/Or)+"h":t>=Ir?Math.round(e/Ir)+"m":t>=vr?Math.round(e/vr)+"s":e+"ms"}function O9(e){var t=Math.abs(e);return t>=Qn?Ci(e,t,Qn,"day"):t>=Or?Ci(e,t,Or,"hour"):t>=Ir?Ci(e,t,Ir,"minute"):t>=vr?Ci(e,t,vr,"second"):e+" ms"}function Ci(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}});var Sd=$s((fk,Ad)=>{function R9(e){n.debug=n,n.default=n,n.coerce=l,n.disable=o,n.enable=s,n.enabled=a,n.humanize=Ed(),n.destroy=c,Object.keys(e).forEach(u=>{n[u]=e[u]}),n.names=[],n.skips=[],n.formatters={};function t(u){let f=0;for(let h=0;h<u.length;h++)f=(f<<5)-f+u.charCodeAt(h),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(u){let f,h=null,p,m;function d(...g){if(!d.enabled)return;let y=d,w=Number(new Date),b=w-(f||w);y.diff=b,y.prev=f,y.curr=w,f=w,g[0]=n.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let x=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(C,R)=>{if(C==="%%")return"%";x++;let U=n.formatters[R];if(typeof U=="function"){let L=g[x];C=U.call(y,L),g.splice(x,1),x--}return C}),n.formatArgs.call(y,g),(y.log||n.log).apply(y,g)}return d.namespace=u,d.useColors=n.useColors(),d.color=n.selectColor(u),d.extend=r,d.destroy=n.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(p!==n.namespaces&&(p=n.namespaces,m=n.enabled(u)),m),set:g=>{h=g}}),typeof n.init=="function"&&n.init(d),d}function r(u,f){let h=n(this.namespace+(typeof f>"u"?":":f)+u);return h.log=this.log,h}function s(u){n.save(u),n.namespaces=u,n.names=[],n.skips=[];let f=(typeof u=="string"?u:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(let h of f)h[0]==="-"?n.skips.push(h.slice(1)):n.names.push(h)}function i(u,f){let h=0,p=0,m=-1,d=0;for(;h<u.length;)if(p<f.length&&(f[p]===u[h]||f[p]==="*"))f[p]==="*"?(m=p,d=h,p++):(h++,p++);else if(m!==-1)p=m+1,d++,h=d;else return!1;for(;p<f.length&&f[p]==="*";)p++;return p===f.length}function o(){let u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function a(u){for(let f of n.skips)if(i(u,f))return!1;for(let f of n.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 n.enable(n.load()),n}Ad.exports=R9});var Cd=$s((vt,Ni)=>{vt.formatArgs=T9;vt.save=P9;vt.load=D9;vt.useColors=$9;vt.storage=L9();vt.destroy=(()=>{let e=!1;return()=>{e||(e=!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`."))}})();vt.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 $9(){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 e;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&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function T9(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ni.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let n=0,r=0;e[0].replace(/%[a-zA-Z%]/g,s=>{s!=="%%"&&(n++,s==="%c"&&(r=n))}),e.splice(r,0,t)}vt.log=console.debug||console.log||(()=>{});function P9(e){try{e?vt.storage.setItem("debug",e):vt.storage.removeItem("debug")}catch{}}function D9(){let e;try{e=vt.storage.getItem("debug")||vt.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function L9(){try{return localStorage}catch{}}Ni.exports=Sd()(vt);var{formatters:_9}=Ni.exports;_9.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var Kn,Za,Nd,kd,vd,Id=I(()=>{ls();Kn={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},Za={get(e){return{signature:Ze.get(e,0),compressedSize:Ze.get(e,8),uncompressedSize:Ze.get(e,12)}},len:16},Nd={get(e){let t=Ge.get(e,6);return{signature:Ze.get(e,0),minVersion:Ge.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,8),compressedSize:Ze.get(e,18),uncompressedSize:Ze.get(e,22),filenameLength:Ge.get(e,26),extraFieldLength:Ge.get(e,28),filename:null}},len:30},kd={get(e){return{signature:Ze.get(e,0),nrOfThisDisk:Ge.get(e,4),nrOfThisDiskWithTheStart:Ge.get(e,6),nrOfEntriesOnThisDisk:Ge.get(e,8),nrOfEntriesOfSize:Ge.get(e,10),sizeOfCd:Ze.get(e,12),offsetOfStartOfCd:Ze.get(e,16),zipFileCommentLength:Ge.get(e,20)}},len:22},vd={get(e){let t=Ge.get(e,8);return{signature:Ze.get(e,0),minVersion:Ge.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,10),compressedSize:Ze.get(e,20),uncompressedSize:Ze.get(e,24),filenameLength:Ge.get(e,28),extraFieldLength:Ge.get(e,30),fileCommentLength:Ge.get(e,32),relativeOffsetOfLocalHeader:Ze.get(e,42),filename:null}},len:46}});function Rd(e){let t=new Uint8Array(Ze.len);return Ze.put(t,0,e),t}function F9(e,t){let n=e.length,r=t.length;if(r>n)return-1;for(let s=0;s<=n-r;s++){let i=!0;for(let o=0;o<r;o++)if(e[s+o]!==t[o]){i=!1;break}if(i)return s}return-1}function U9(e){let t=e.reduce((s,i)=>s+i.length,0),n=new Uint8Array(t),r=0;for(let s of e)n.set(s,r),r+=s.length;return n}var Od,un,Qa,M9,ki,hs,$d=I(()=>{ls();Od=eu(Cd(),1);Id();un=(0,Od.default)("tokenizer:inflate"),Qa=256*1024,M9=Rd(Kn.DataDescriptor),ki=Rd(Kn.EndOfCentralDirectory),hs=class e{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(Qa)}async isZip(){return await this.peekSignature()===Kn.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Ze)}async findEndOfCentralDirectoryLocator(){let t=this.tokenizer,n=Math.min(16*1024,t.fileInfo.size),r=this.syncBuffer.subarray(0,n);await this.tokenizer.readBuffer(r,{position:t.fileInfo.size-n});for(let s=r.length-4;s>=0;s--)if(r[s]===ki[0]&&r[s+1]===ki[1]&&r[s+2]===ki[2]&&r[s+3]===ki[3])return t.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){un("Cannot reading central-directory without random-read support");return}un("Reading central-directory...");let t=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){un("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(kd,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let o=await this.tokenizer.readToken(vd);if(o.signature!==Kn.CentralFileHeader)throw new Error("Expected Central-File-Header signature");o.filename=await this.tokenizer.readToken(new kt(o.filenameLength,"utf-8")),await this.tokenizer.ignore(o.extraFieldLength),await this.tokenizer.ignore(o.fileCommentLength),s.push(o),un(`Add central-directory file-entry: n=${i+1}/${s.length}: filename=${s[i].filename}`)}return this.tokenizer.setPosition(t),s}this.tokenizer.setPosition(t)}async unzip(t){let n=await this.readCentralDirectory();if(n)return this.iterateOverCentralDirectory(n,t);let r=!1;do{let s=await this.readLocalFileHeader();if(!s)break;let i=t(s);r=!!i.stop;let o;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let a=[],l=Qa;un("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===Qa;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=F9(this.syncBuffer.subarray(0,l),M9);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)}un(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,U9(a),i.handler)}else i.handler?(un(`Reading compressed-file-data: ${s.compressedSize} bytes`),o=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(o),await this.inflate(s,o,i.handler)):(un(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(un(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(Za)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-Za.len}`)}while(!r)}async iterateOverCentralDirectory(t,n){for(let r of t){let s=n(r);if(s.handler){this.tokenizer.setPosition(r.relativeOffsetOfLocalHeader);let i=await this.readLocalFileHeader();if(i){await this.tokenizer.ignore(i.extraFieldLength);let o=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(o),await this.inflate(i,o,s.handler)}}if(s.stop)break}}async inflate(t,n,r){if(t.compressedMethod===0)return r(n);if(t.compressedMethod!==8)throw new Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);un(`Decompress filename=${t.filename}, compressed-size=${n.length}`);let s=await e.decompressDeflateRaw(n);return r(s)}static async decompressDeflateRaw(t){let n=new ReadableStream({start(i){i.enqueue(t),i.close()}}),r=new DecompressionStream("deflate-raw"),s=n.pipeThrough(r);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 t=await this.tokenizer.peekToken(Ze);if(t===Kn.LocalFileHeader){let n=await this.tokenizer.readToken(Nd);return n.filename=await this.tokenizer.readToken(new kt(n.filenameLength,"utf-8")),n}if(t===Kn.CentralFileHeader)return!1;throw t===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var ps,Td=I(()=>{ps=class{constructor(t){this.tokenizer=t}inflate(){let t=this.tokenizer;return new ReadableStream({async pull(n){let r=new Uint8Array(1024),s=await t.readBuffer(r,{mayBeLess:!0});if(s===0){n.close();return}n.enqueue(r.subarray(0,s))}}).pipeThrough(new DecompressionStream("gzip"))}}});var Pd=I(()=>{$d();Td()});function Ka(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}var Ek,Ak,Sk,Dd=I(()=>{Ek={utf8:new globalThis.TextDecoder("utf8")},Ak=new globalThis.TextEncoder,Sk=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});function Ld(e,t){if(t==="utf-16le"){let n=[];for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);n.push(s&255,s>>8&255)}return n}if(t==="utf-16be"){let n=[];for(let r=0;r<e.length;r++){let s=e.charCodeAt(r);n.push(s>>8&255,s&255)}return n}return[...e].map(n=>n.charCodeAt(0))}function _d(e,t=0){let n=Number.parseInt(new kt(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let s=t;s<t+148;s++)r+=e[s];for(let s=t+156;s<t+512;s++)r+=e[s];return n===r}var Md,Fd=I(()=>{ls();Md={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}});var Ud,Wd,Bd=I(()=>{Ud=["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"],Wd=["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 Hd(e,t){return new Ja(t).fromBuffer(e)}function Ya(e){switch(e=e.toLowerCase(),e){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};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:e};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:e};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:e};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:e};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:e};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 fn(e,t,n){n={offset:0,...n};for(let[r,s]of t.entries())if(n.mask){if(s!==(n.mask[r]&e[r+n.offset]))return!1}else if(s!==e[r+n.offset])return!1;return!0}var Xa,Ja,Tk,Pk,zd=I(()=>{ls();bd();Pd();Dd();Fd();Bd();Xa=4100;Ja=class{constructor(t){this.options={mpegOffsetTolerance:0,...t},this.detectors=[...t?.customDetectors??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:t?.signal}}async fromTokenizer(t){let n=t.position;for(let r of this.detectors){let s=await r.detect(t);if(s)return s;if(n!==t.position)return}}async fromBuffer(t){if(!(t instanceof Uint8Array||t instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof t}\``);let n=t instanceof Uint8Array?t:new Uint8Array(t);if(n?.length>1)return this.fromTokenizer(yd(n,this.tokenizerOptions))}async fromBlob(t){let n=wd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(t){let n=gd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(t,n){let{sampleSize:r=Xa}=n,s,i,o=t.getReader({mode:"byob"});try{let{value:c,done:u}=await o.read(new Uint8Array(r));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof Ue))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=t.pipeThrough(a);return l.fileType=s,l}check(t,n){return fn(this.buffer,t,n)}checkString(t,n){return this.check(Ld(t,n?.encoding),n)}detectConfident=async t=>{if(this.buffer=new Uint8Array(Xa),t.fileInfo.size===void 0&&(t.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=t,await t.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 t.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(t);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 r=new ps(t).inflate(),s=!0;try{let i;try{i=await this.fromStream(r)}catch{s=!1}if(i&&i.ext==="tar")return{ext:"tar.gz",mime:"application/gzip"}}finally{s&&await r.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 t.ignore(6);let n=await t.readToken(Md);return t.position+n>t.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await t.ignore(n),this.fromTokenizer(t))}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 n;return await new hs(t).unzip(r=>{switch(r.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(s){let i=new TextDecoder("utf-8").decode(s).trim();n=Ya(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}"`)&&(n=Ya(a))}else{i=i.slice(0,Math.max(0,o));let a=i.lastIndexOf('"'),l=i.slice(Math.max(0,a+1));n=Ya(l)}},stop:!0};default:return/classes\d*\.dex/.test(r.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}).catch(r=>{if(!(r instanceof Ue))throw r}),n??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await t.ignore(28);let n=new Uint8Array(8);return await t.readBuffer(n),fn(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:fn(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:fn(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:fn(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:fn(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:fn(n,[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 n=await this.readTiffHeader(!1);if(n)return n}if(this.check([77,77])){let n=await this.readTiffHeader(!0);if(n)return n}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function n(){let a=await t.peekNumber(id),l=128,c=0;for(;(a&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await t.readBuffer(u),u}async function r(){let a=await n(),l=await n();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:Ka(u),len:Ka(f)}}async function s(a){for(;a>0;){let l=await r();if(l.id===17026)return(await t.readToken(new kt(l.len))).replaceAll(/\00.*$/g,"");await t.ignore(l.len),--a}}let i=await r();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 n=new kt(4,"latin1").get(this.buffer,2);if(n.match("^d*")&&n>=1e3&&n<=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 t.ignore(8),await t.readToken(new kt(13,"ascii"))==="debian-binary"?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"};if(this.checkString("WEBVTT")&&[`
619
619
  `,"\r"," "," ","\0"].some(n=>this.checkString(n,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){await t.ignore(8);async function n(){return{length:await t.readToken(ad),type:await t.readToken(new kt(4,"latin1"))}}do{let r=await n();if(r.length<0)return;switch(r.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await t.ignore(r.length+4)}}while(t.position+8<t.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 n=new kt(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(n){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 n.startsWith("3g")?n.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.checkString(`REGEDIT4\r
620
620
  `))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 n(){let r=new Uint8Array(16);return await t.readBuffer(r),{id:r,size:Number(await t.readToken(ld))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let r=await n(),s=r.size-24;if(fn(r.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 t.readBuffer(i),fn(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(fn(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 t.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 t.ignore(20),await t.readToken(new kt(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 t.peekBuffer(this.buffer,{length:Math.min(256,t.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 n=new DataView(this.buffer.buffer).getUint32(12,!0);if(n>12&&this.buffer.length>=n+16)try{let r=new TextDecoder().decode(this.buffer.subarray(16,n+16));if(JSON.parse(r).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 t.peekBuffer(this.buffer,{length:Math.min(512,t.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})&&_d(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let n="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:n})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:n})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
621
621
  `,{offset:2,encoding:n})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async t=>{if(this.buffer=new Uint8Array(Xa),await t.peekBuffer(this.buffer,{length:Math.min(8,t.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 t.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,t.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let n=0;n<=this.options.mpegOffsetTolerance;++n){let r=this.scanMpeg(n);if(r)return r}};async readTiffTag(t){let n=await this.tokenizer.readToken(t?Nr:Ge);switch(this.tokenizer.ignore(10),n){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(t){let n=await this.tokenizer.readToken(t?Nr:Ge);for(let r=0;r<n;++r){let s=await this.readTiffTag(t);if(s)return s}}async readTiffHeader(t){let n=(t?Nr:Ge).get(this.buffer,2),r=(t?od:Ze).get(this.buffer,4);if(n===42){if(r>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(r>=8){let i=(t?Nr:Ge).get(this.buffer,8),o=(t?Nr:Ge).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(r),await this.readTiffIFD(t)??{ext:"tif",mime:"image/tiff"}}if(n===43)return{ext:"tif",mime:"image/tiff"}}scanMpeg(t){if(this.check([255,224],{offset:t,mask:[255,224]})){if(this.check([16],{offset:t+1,mask:[22]}))return this.check([8],{offset:t+1,mask:[8]})?{ext:"aac",mime:"audio/aac"}:{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:t+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:t+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:t+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}},Tk=new Set(Ud),Pk=new Set(Wd)});var jd={};Q(jd,{fileCommand:()=>q9});function z9(e,t){let n=H9.get(e);if(n)return n;let[r,s]=t.split("/"),i=s?.split("+")[0]?.replace(/-/g," ")||e;switch(r){case"image":return`${i.toUpperCase()} image data`;case"audio":return`${i.toUpperCase()} audio`;case"video":return`${i.toUpperCase()} video`;case"font":return`${i} font`;case"model":return`${i} 3D model`;case"application":return s?.includes("zip")||s?.includes("compressed")?`${i} archive data`:s?.includes("executable")?`${i} executable`:`${e.toUpperCase()} data`;default:return`${e.toUpperCase()} data`}}function j9(e){let t=e.split("/").pop()||e;if(t.startsWith(".")&&!t.includes(".",1))return t;let n=t.lastIndexOf(".");return n===-1||n===0?"":t.slice(n).toLowerCase()}function G9(e,t){if(e.startsWith("#!")){let c=e.split(`
622
622
  `)[0];return c.includes("python")?{description:"Python script, ASCII text executable",mime:"text/x-python"}:c.includes("node")||c.includes("bun")||c.includes("deno")?{description:"JavaScript script, ASCII text executable",mime:"text/javascript"}:c.includes("bash")?{description:"Bourne-Again shell script, ASCII text executable",mime:"text/x-shellscript"}:c.includes("sh")?{description:"POSIX shell script, ASCII text executable",mime:"text/x-shellscript"}:c.includes("ruby")?{description:"Ruby script, ASCII text executable",mime:"text/x-ruby"}:c.includes("perl")?{description:"Perl script, ASCII text executable",mime:"text/x-perl"}:{description:"script, ASCII text executable",mime:"text/plain"}}let n=e.trimStart();if(n.startsWith("<?xml"))return{description:"XML document",mime:"application/xml"};if(n.startsWith("<!DOCTYPE html")||n.toLowerCase().startsWith("<html"))return{description:"HTML document",mime:"text/html"};let r=e.includes(`\r
623
- `),s=e.includes("\r")&&!r,i="";r?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let o=j9(t),a=o?B9.get(o):void 0;if(a)return a.mime.startsWith("text/")&&i?{description:`${a.description}${i}`,mime:a.mime}:a;let l=!1;for(let c=0;c<Math.min(e.length,8192);c++)if(e.charCodeAt(c)>127){l=!0;break}return l?{description:`UTF-8 Unicode text${i}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${i}`,mime:"text/plain"}}async function V9(e,t){if(t.length===0)return{description:"empty",mime:"inode/x-empty"};let n=await Hd(t);if(n)return{description:z9(n.ext,n.mime),mime:n.mime};let r=new TextDecoder("utf-8",{fatal:!1}).decode(t);return G9(r,e)}var W9,B9,H9,q9,Gd=I(()=>{"use strict";zd();ne();W9={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"]},B9=new Map([[".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"}]]),H9=new Map([["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"]]);q9={name:"file",async execute(e,t){if(U(e))return F(W9);let n=!1,r=!1,s=[];for(let a of e)if(a.startsWith("--")){if(a==="--brief")n=!0;else if(a==="--mime"||a==="--mime-type")r=!0;else if(a!=="--dereference")return X("file",a)}else if(a.startsWith("-")&&a!=="-"){for(let l of a.slice(1))if(l==="b")n=!0;else if(l==="i")r=!0;else if(l!=="L")return X("file",`-${l}`)}else s.push(a);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
623
+ `),s=e.includes("\r")&&!r,i="";r?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let o=j9(t),a=o?B9.get(o):void 0;if(a)return a.mime.startsWith("text/")&&i?{description:`${a.description}${i}`,mime:a.mime}:a;let l=!1;for(let c=0;c<Math.min(e.length,8192);c++)if(e.charCodeAt(c)>127){l=!0;break}return l?{description:`UTF-8 Unicode text${i}`,mime:"text/plain; charset=utf-8"}:{description:`ASCII text${i}`,mime:"text/plain"}}async function V9(e,t){if(t.length===0)return{description:"empty",mime:"inode/x-empty"};let n=await Hd(t);if(n)return{description:z9(n.ext,n.mime),mime:n.mime};let r=new TextDecoder("utf-8",{fatal:!1}).decode(t);return G9(r,e)}var W9,B9,H9,q9,Gd=I(()=>{"use strict";zd();ne();W9={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"]},B9=new Map([[".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"}]]),H9=new Map([["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"]]);q9={name:"file",async execute(e,t){if(F(e))return M(W9);let n=!1,r=!1,s=[];for(let a of e)if(a.startsWith("--")){if(a==="--brief")n=!0;else if(a==="--mime"||a==="--mime-type")r=!0;else if(a!=="--dereference")return X("file",a)}else if(a.startsWith("-")&&a!=="-"){for(let l of a.slice(1))if(l==="b")n=!0;else if(l==="i")r=!0;else if(l!=="L")return X("file",`-${l}`)}else s.push(a);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
624
624
  `,exitCode:1};let i="",o=0;for(let a of s)try{let l=t.fs.resolvePath(t.cwd,a);if((await t.fs.stat(l)).isDirectory){let p=r?"inode/directory":"directory";i+=n?`${p}
625
625
  `:`${a}: ${p}
626
626
  `;continue}let u=await t.fs.readFileBuffer(l),f=await V9(a,u),h=r?f.mime:f.description;i+=n?`${h}
627
627
  `:`${a}: ${h}
628
628
  `}catch{i+=n?`cannot open
629
629
  `:`${a}: cannot open (No such file or directory)
630
- `,o=1}return{stdout:i,stderr:"",exitCode:o}}}});var Vd={};Q(Vd,{htmlToMarkdownCommand:()=>K9});import Z9 from"turndown";var Q9,K9,qd=I(()=>{"use strict";ne();Q9={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"]},K9={name:"html-to-markdown",async execute(e,t){if(U(e))return F(Q9);let n="-",r="```",s="---",i="atx",o=[];for(let l=0;l<e.length;l++){let c=e[l];if(c==="-b"||c==="--bullet")n=e[++l]??"-";else if(c.startsWith("--bullet="))n=c.slice(9);else if(c==="-c"||c==="--code")r=e[++l]??"```";else if(c.startsWith("--code="))r=c.slice(7);else if(c==="-r"||c==="--hr")s=e[++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 X("html-to-markdown",c);if(c.startsWith("-"))return X("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=t.stdin;else try{let l=t.fs.resolvePath(t.cwd,o[0]);a=await t.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
630
+ `,o=1}return{stdout:i,stderr:"",exitCode:o}}}});var Vd={};Q(Vd,{htmlToMarkdownCommand:()=>K9});import Z9 from"turndown";var Q9,K9,qd=I(()=>{"use strict";ne();Q9={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"]},K9={name:"html-to-markdown",async execute(e,t){if(F(e))return M(Q9);let n="-",r="```",s="---",i="atx",o=[];for(let l=0;l<e.length;l++){let c=e[l];if(c==="-b"||c==="--bullet")n=e[++l]??"-";else if(c.startsWith("--bullet="))n=c.slice(9);else if(c==="-c"||c==="--code")r=e[++l]??"```";else if(c.startsWith("--code="))r=c.slice(7);else if(c==="-r"||c==="--hr")s=e[++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 X("html-to-markdown",c);if(c.startsWith("-"))return X("html-to-markdown",c);o.push(c)}}let a;if(o.length===0||o.length===1&&o[0]==="-")a=t.stdin;else try{let l=t.fs.resolvePath(t.cwd,o[0]);a=await t.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
631
631
  `,exitCode:1}}if(!a.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new Z9({bulletListMarker:n,codeBlockStyle:"fenced",fence:r,hr:s,headingStyle:i});return l.remove(["script","style","footer"]),{stdout:`${l.turndown(a).trim()}
632
632
  `,stderr:"",exitCode:0}}catch(l){return{stdout:"",stderr:`html-to-markdown: conversion error: ${l.message}
633
633
  `,exitCode:1}}}}});var Zd={};Q(Zd,{helpCommand:()=>J9});function Y9(e){let t=[],n=new Set(e);t.push(`Available commands:
@@ -644,7 +644,7 @@ Options:
644
644
 
645
645
  If a command name is provided, shows help for that command.
646
646
  Otherwise, lists all available commands.
647
- `,stderr:"",exitCode:0};if(e.length>0&&t.exec){let r=e[0];return t.exec(`${r} --help`,{cwd:t.cwd})}let n=t.getRegisteredCommands?.()??[];return{stdout:Y9(n),stderr:"",exitCode:0}}}});var Kd={};Q(Kd,{whichCommand:()=>n5});var e5,t5,n5,Xd=I(()=>{"use strict";qe();ne();e5={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"]},t5={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},n5={name:"which",async execute(e,t){if(U(e))return F(e5);let n=we("which",e,t5);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.silent,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:"",exitCode:1};let a=(t.env.get("PATH")||"/usr/bin:/bin").split(":"),l="",c=!0;for(let u of i){let f=!1;for(let h of a){if(!h)continue;let p=`${h}/${u}`;if(await t.fs.exists(p)&&(f=!0,s||(l+=`${p}
647
+ `,stderr:"",exitCode:0};if(e.length>0&&t.exec){let r=e[0];return t.exec(`${r} --help`,{cwd:t.cwd})}let n=t.getRegisteredCommands?.()??[];return{stdout:Y9(n),stderr:"",exitCode:0}}}});var Kd={};Q(Kd,{whichCommand:()=>n5});var e5,t5,n5,Xd=I(()=>{"use strict";qe();ne();e5={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"]},t5={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},n5={name:"which",async execute(e,t){if(F(e))return M(e5);let n=we("which",e,t5);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.silent,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:"",exitCode:1};let a=(t.env.get("PATH")||"/usr/bin:/bin").split(":"),l="",c=!0;for(let u of i){let f=!1;for(let h of a){if(!h)continue;let p=`${h}/${u}`;if(await t.fs.exists(p)&&(f=!0,s||(l+=`${p}
648
648
  `),!r))break}f||(c=!1)}return{stdout:l,stderr:"",exitCode:c?0:1}}}});var Yd={};Q(Yd,{tac:()=>s5});async function r5(e,t){if(e.length>0&&e[0]!=="-"){let s=e[0].startsWith("/")?e[0]:`${t.cwd}/${e[0]}`;try{let o=(await t.fs.readFile(s)).split(`
649
649
  `);o[o.length-1]===""&&o.pop();let a=o.reverse();return{stdout:a.length>0?`${a.join(`
650
650
  `)}
@@ -678,8 +678,8 @@ Otherwise, lists all available commands.
678
678
  `,exitCode:1}}}if(!vi(s))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
679
679
  `,exitCode:1};try{return tl(s),n.verbose?{stdout:"",stderr:`${t}: OK
680
680
  `,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(i){let o=i instanceof Error?i.message:"invalid";return{stdout:"",stderr:`${r}: ${t}: ${o}
681
- `,exitCode:1}}}async function nl(e,t,n){let r=n==="zcat"?p5:n==="gunzip"?h5:f5;if(U(e))return F(r);let s=we(n,e,d5);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,o=s.result.positional,a=n==="gunzip"||n==="zcat"||i.decompress||i.uncompress,l=n==="zcat"||i.stdout||i.toStdout;if(i.list){o.length===0&&(o=["-"]);let h=` compressed uncompressed ratio uncompressed_name
682
- `,p="",m=0;for(let d of o){let g=await g5(t,d,i,n);h+=g.stdout,p+=g.stderr,g.exitCode!==0&&(m=g.exitCode)}return{stdout:h,stderr:p,exitCode:m}}if(i.test){o.length===0&&(o=["-"]);let h="",p="",m=0;for(let d of o){let g=await y5(t,d,i,n);h+=g.stdout,p+=g.stderr,g.exitCode!==0&&(m=g.exitCode)}return{stdout:h,stderr:p,exitCode:m}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let h of o){let p=await c0(t,h,i,n,a,l);c+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var f5,h5,p5,d5,w5,b5,x5,Ri=I(()=>{"use strict";qe();ne();f5={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
681
+ `,exitCode:1}}}async function nl(e,t,n){let r=n==="zcat"?p5:n==="gunzip"?h5:f5;if(F(e))return M(r);let s=we(n,e,d5);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,o=s.result.positional,a=n==="gunzip"||n==="zcat"||i.decompress||i.uncompress,l=n==="zcat"||i.stdout||i.toStdout;if(i.list){o.length===0&&(o=["-"]);let h=` compressed uncompressed ratio uncompressed_name
682
+ `,p="",m=0;for(let d of o){let g=await g5(t,d,i,n);h+=g.stdout,p+=g.stderr,g.exitCode!==0&&(m=g.exitCode)}return{stdout:h,stderr:p,exitCode:m}}if(i.test){o.length===0&&(o=["-"]);let h="",p="",m=0;for(let d of o){let g=await y5(t,d,i,n);h+=g.stdout,p+=g.stderr,g.exitCode!==0&&(m=g.exitCode)}return{stdout:h,stderr:p,exitCode:m}}o.length===0&&(o=["-"]);let c="",u="",f=0;for(let h of o){let p=await c0(t,h,i,n,a,l);c+=p.stdout,u+=p.stderr,p.exitCode!==0&&(f=p.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var f5,h5,p5,d5,w5,b5,x5,Oi=I(()=>{"use strict";qe();ne();f5={name:"gzip",summary:"compress or expand files",usage:"gzip [OPTION]... [FILE]...",description:`Compress FILEs (by default, in-place).
683
683
 
684
684
  When no FILE is given, or when FILE is -, read from standard input.
685
685
 
@@ -707,17 +707,17 @@ ${i}\r
707
707
  \r
708
708
  `),e.headOnly?e.includeHeaders||e.verbose||(r+=`HTTP/1.1 ${t.status} ${t.statusText}\r
709
709
  `,r+=ol(t.headers),r+=`\r
710
- `):r+=t.body,e.writeOut&&(r+=al(e.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),r}var N5,b0=I(()=>{"use strict";Mt();ne();il();p0();m0();y0();N5={name:"curl",async execute(e,t){if(U(e))return F(h0);let n=d0(e);if("exitCode"in n)return n;let r=n;if(!r.url)return{stdout:"",stderr:`curl: no URL specified
710
+ `):r+=t.body,e.writeOut&&(r+=al(e.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),r}var N5,b0=I(()=>{"use strict";Mt();ne();il();p0();m0();y0();N5={name:"curl",async execute(e,t){if(F(e))return M(h0);let n=d0(e);if("exitCode"in n)return n;let r=n;if(!r.url)return{stdout:"",stderr:`curl: no URL specified
711
711
  `,exitCode:2};if(!t.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
712
712
  `,exitCode:1};let s=r.url;s.match(/^https?:\/\//)||(s=`https://${s}`);try{let{body:i,contentType:o}=await E5(r,t),a=A5(r,o),l=await t.fetch(s,{method:r.method,headers:Object.keys(a).length>0?a:void 0,body:i,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs});if(await S5(r,l.headers,t),r.failSilently&&l.status>=400)return{stdout:"",stderr:r.showError||!r.silent?`curl: (22) The requested URL returned error: ${l.status}
713
713
  `:"",exitCode:22};let c=C5(r,l,s);if(r.outputFile||r.useRemoteName){let u=r.outputFile||g0(s),f=t.fs.resolvePath(t.cwd,u);await t.fs.writeFile(f,r.headOnly?"":l.body),r.verbose||(c=""),r.writeOut&&(c=al(r.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:c,stderr:"",exitCode:0}}catch(i){let o=Fe(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:!r.silent||r.showError?`curl: (${a}) ${o}
714
- `:"",exitCode:a}}}}});function ds(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function O0(){let{pid:e,ppid:t,uid:n,gid:r}=ds();return`Name: bash
714
+ `:"",exitCode:a}}}}});function ds(){return{pid:process.pid,ppid:process.ppid,uid:process.getuid?.()??1e3,gid:process.getgid?.()??1e3}}function R0(){let{pid:e,ppid:t,uid:n,gid:r}=ds();return`Name: bash
715
715
  State: R (running)
716
716
  Pid: ${e}
717
717
  PPid: ${t}
718
718
  Uid: ${n} ${n} ${n} ${n}
719
719
  Gid: ${r} ${r} ${r} ${r}
720
- `}var I0,R0,fl=I(()=>{"use strict";I0="5.1.0(1)-release",R0="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT"});function P0(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let n=e.slice(t[0].length);if(n===""||n==="+")return!0;if(n[0]==="["){let r=0,s=0;for(;s<n.length;s++)if(n[s]==="[")r++;else if(n[s]==="]"&&(r--,r===0))break;if(r!==0||s>=n.length)return!1;let i=n.slice(s+1);return i===""||i==="+"}return!1}function D0(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r==="[")t++;else if(r==="]")t--;else{if(t===0&&r==="=")return n;if(t===0&&r==="+"&&e[n+1]==="=")return n+1}}return-1}function z5(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function L0(e){return e===" "||e===" "||e===`
720
+ `}var I0,O0,fl=I(()=>{"use strict";I0="5.1.0(1)-release",O0="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT"});function P0(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return!1;let n=e.slice(t[0].length);if(n===""||n==="+")return!0;if(n[0]==="["){let r=0,s=0;for(;s<n.length;s++)if(n[s]==="[")r++;else if(n[s]==="]"&&(r--,r===0))break;if(r!==0||s>=n.length)return!1;let i=n.slice(s+1);return i===""||i==="+"}return!1}function D0(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r==="[")t++;else if(r==="]")t--;else{if(t===0&&r==="=")return n;if(t===0&&r==="+"&&e[n+1]==="=")return n+1}}return-1}function z5(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function L0(e){return e===" "||e===" "||e===`
721
721
  `||e===";"||e==="&"||e==="|"||e==="("||e===")"||e==="<"||e===">"}var E,$n,T0,W5,B5,H5,Ti,Tn=I(()=>{"use strict";(function(e){e.EOF="EOF",e.NEWLINE="NEWLINE",e.SEMICOLON="SEMICOLON",e.AMP="AMP",e.PIPE="PIPE",e.PIPE_AMP="PIPE_AMP",e.AND_AND="AND_AND",e.OR_OR="OR_OR",e.BANG="BANG",e.LESS="LESS",e.GREAT="GREAT",e.DLESS="DLESS",e.DGREAT="DGREAT",e.LESSAND="LESSAND",e.GREATAND="GREATAND",e.LESSGREAT="LESSGREAT",e.DLESSDASH="DLESSDASH",e.CLOBBER="CLOBBER",e.TLESS="TLESS",e.AND_GREAT="AND_GREAT",e.AND_DGREAT="AND_DGREAT",e.LPAREN="LPAREN",e.RPAREN="RPAREN",e.LBRACE="LBRACE",e.RBRACE="RBRACE",e.DSEMI="DSEMI",e.SEMI_AND="SEMI_AND",e.SEMI_SEMI_AND="SEMI_SEMI_AND",e.DBRACK_START="DBRACK_START",e.DBRACK_END="DBRACK_END",e.DPAREN_START="DPAREN_START",e.DPAREN_END="DPAREN_END",e.IF="IF",e.THEN="THEN",e.ELSE="ELSE",e.ELIF="ELIF",e.FI="FI",e.FOR="FOR",e.WHILE="WHILE",e.UNTIL="UNTIL",e.DO="DO",e.DONE="DONE",e.CASE="CASE",e.ESAC="ESAC",e.IN="IN",e.FUNCTION="FUNCTION",e.SELECT="SELECT",e.TIME="TIME",e.COPROC="COPROC",e.WORD="WORD",e.NAME="NAME",e.NUMBER="NUMBER",e.ASSIGNMENT_WORD="ASSIGNMENT_WORD",e.FD_VARIABLE="FD_VARIABLE",e.COMMENT="COMMENT",e.HEREDOC_CONTENT="HEREDOC_CONTENT"})(E||(E={}));$n=class extends Error{line;column;constructor(t,n,r){super(`line ${n}: ${t}`),this.line=n,this.column=r,this.name="LexerError"}},T0=new Map([["if",E.IF],["then",E.THEN],["else",E.ELSE],["elif",E.ELIF],["fi",E.FI],["for",E.FOR],["while",E.WHILE],["until",E.UNTIL],["do",E.DO],["done",E.DONE],["case",E.CASE],["esac",E.ESAC],["in",E.IN],["function",E.FUNCTION],["select",E.SELECT],["time",E.TIME],["coproc",E.COPROC]]);W5=[[";",";","&",E.SEMI_SEMI_AND],["<","<","<",E.TLESS],["&",">",">",E.AND_DGREAT]],B5=[["[","[",E.DBRACK_START],["]","]",E.DBRACK_END],["(","(",E.DPAREN_START],[")",")",E.DPAREN_END],["&","&",E.AND_AND],["|","|",E.OR_OR],[";",";",E.DSEMI],[";","&",E.SEMI_AND],["|","&",E.PIPE_AMP],[">",">",E.DGREAT],["<","&",E.LESSAND],[">","&",E.GREATAND],["<",">",E.LESSGREAT],[">","|",E.CLOBBER],["&",">",E.AND_GREAT]],H5=new Map([["|",E.PIPE],["&",E.AMP],[";",E.SEMICOLON],["(",E.LPAREN],[")",E.RPAREN],["<",E.LESS],[">",E.GREAT]]);Ti=class{input;pos=0;line=1;column=1;tokens=[];pendingHeredocs=[];dparenDepth=0;constructor(t){this.input=t}tokenize(){let n=this.input.length,r=this.tokens,s=this.pendingHeredocs;for(;this.pos<n;){if(s.length>0&&r.length>0&&r[r.length-1].type===E.NEWLINE){this.readHeredocContent();continue}if(this.skipWhitespace(),this.pos>=n)break;let i=this.nextToken();i&&r.push(i)}return r.push({type:E.EOF,value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),r}skipWhitespace(){let t=this.input,n=t.length,r=this.pos,s=this.column,i=this.line;for(;r<n;){let o=t[r];if(o===" "||o===" ")r++,s++;else if(o==="\\"&&t[r+1]===`
722
722
  `)r+=2,i++,s=1;else break}this.pos=r,this.column=s,this.line=i}nextToken(){let t=this.input,n=this.pos,r=this.line,s=this.column,i=t[n],o=t[n+1],a=t[n+2];if(i==="#"&&this.dparenDepth===0)return this.readComment(n,r,s);if(i===`
723
723
  `)return this.pos=n+1,this.line++,this.column=1,{type:E.NEWLINE,value:`
@@ -733,13 +733,13 @@ Gid: ${r} ${r} ${r} ${r}
733
733
  `||b===";"||b==="&"||b==="|"||b==="("||b===")"||b==="<"||b===">")break}if(b==="$"&&o+1<i&&s[o+1]==="'"&&!p&&!m){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(b==="$"&&o+1<i&&s[o+1]==='"'&&!p&&!m){o++,l++,m=!0,f=!0,u===""&&(d=!0),o++,l++;continue}if(b==="'"&&!m){if(p)if(p=!1,!d||g)u+=b;else{let x=o+1<i?s[o+1]:"";x&&!L0(x)&&x!=="'"&&(x==='"'?(g=!0,u+=b,h=!1,f=!1):(g=!0,u+=b))}else p=!0,d&&!g?(h=!0,f=!0):u+=b;o++,l++;continue}if(b==='"'&&!p){if(m)if(m=!1,!d||g)u+=b;else{let x=o+1<i?s[o+1]:"";x&&!L0(x)&&x!=='"'&&(x==="'"?(g=!0,u+=b,h=!1,f=!1):(g=!0,u+=b))}else m=!0,d&&!g?f=!0:u+=b;o++,l++;continue}if(b==="\\"&&!p&&o+1<i){let x=s[o+1];if(x===`
734
734
  `){o+=2,c++,l=1;continue}if(m){if(x==='"'||x==="\\"||x==="$"||x==="`"||x===`
735
735
  `){if(x===`
736
- `){o+=2,l=1,c++;continue}u+=b+x,o+=2,l+=2;continue}}else{x==="\\"||x==='"'||x==="'"||x==="`"||x==="*"||x==="?"||x==="["||x==="]"||x==="("||x===")"||x==="$"||x==="-"||x==="."||x==="^"||x==="+"||x==="{"||x==="}"?u+=b+x:u+=x,o+=2,l+=2;continue}}if(b==="$"&&o+1<i&&s[o+1]==="("&&!p){u+=b,o++,l++,u+=s[o],o++,l++;let x=1,S=!1,C=!1,$=0,M=!1,_="",B=s[o]==="("&&!this.dollarDparenIsSubshell(o);for(;x>0&&o<i;){let v=s[o];if(u+=v,S)v==="'"&&(S=!1);else if(C)v==="\\"&&o+1<i?(u+=s[o+1],o++,l++):v==='"'&&(C=!1);else if(v==="'")S=!0,_="";else if(v==='"')C=!0,_="";else if(v==="\\"&&o+1<i)u+=s[o+1],o++,l++,_="";else if(v==="$"&&o+1<i&&s[o+1]==="{"){o++,l++,u+=s[o],o++,l++;let k=1,T=!1,R=!1;for(;k>0&&o<i;){let O=s[o];if(O==="\\"&&o+1<i&&!T){u+=O,o++,l++,u+=s[o],o++,l++;continue}u+=O,T?O==="'"&&(T=!1):R?O==='"'&&(R=!1):O==="'"?T=!0:O==='"'?R=!0:O==="{"?k++:O==="}"&&k--,O===`
737
- `?(c++,l=0):l++,o++}_="";continue}else if(v==="#"&&!B&&(_===""||/\s/.test(s[o-1]||""))){for(;o+1<i&&s[o+1]!==`
738
- `;)o++,l++,u+=s[o];_=""}else/[a-zA-Z_]/.test(v)?_+=v:(_==="case"?($++,M=!1):_==="in"&&$>0?M=!0:_==="esac"&&$>0&&($--,M=!1),_="",v==="("?o>0&&s[o-1]==="$"?x++:M||x++:v===")"?M?M=!1:x--:v===";"&&$>0&&o+1<i&&s[o+1]===";"&&(M=!0));v===`
739
- `&&(c++,l=0,_=""),o++,l++}continue}if(b==="$"&&o+1<i&&s[o+1]==="["&&!p){u+=b,o++,l++,u+=s[o],o++,l++;let x=1;for(;x>0&&o<i;){let S=s[o];u+=S,S==="["?x++:S==="]"?x--:S===`
740
- `&&(c++,l=0),o++,l++}continue}if(b==="$"&&o+1<i&&s[o+1]==="{"&&!p){u+=b,o++,l++,u+=s[o],o++,l++;let x=1,S=!1,C=!1,$=c,M=l,_=c,B=l;for(;x>0&&o<i;){let v=s[o];if(v==="\\"&&o+1<i&&s[o+1]===`
741
- `){o+=2,c++,l=1;continue}if(v==="\\"&&o+1<i&&!S){u+=v,o++,l++,u+=s[o],o++,l++;continue}u+=v,S?v==="'"&&(S=!1):C?v==='"'&&(C=!1):v==="'"?(S=!0,$=c,M=l):v==='"'?(C=!0,_=c,B=l):v==="{"?x++:v==="}"&&x--,v===`
742
- `&&(c++,l=0),o++,l++}if(S)throw new $n("unexpected EOF while looking for matching `''",$,M);if(C)throw new $n("unexpected EOF while looking for matching `\"'",_,B);continue}if(b==="$"&&o+1<i&&!p){let x=s[o+1];if(x==="#"||x==="?"||x==="$"||x==="!"||x==="@"||x==="*"||x==="-"||x>="0"&&x<="9"){u+=b+x,o+=2,l+=2;continue}}if(b==="`"&&!p){for(u+=b,o++,l++;o<i&&s[o]!=="`";){let x=s[o];u+=x,x==="\\"&&o+1<i&&(u+=s[o+1],o++,l++),x===`
736
+ `){o+=2,l=1,c++;continue}u+=b+x,o+=2,l+=2;continue}}else{x==="\\"||x==='"'||x==="'"||x==="`"||x==="*"||x==="?"||x==="["||x==="]"||x==="("||x===")"||x==="$"||x==="-"||x==="."||x==="^"||x==="+"||x==="{"||x==="}"?u+=b+x:u+=x,o+=2,l+=2;continue}}if(b==="$"&&o+1<i&&s[o+1]==="("&&!p){u+=b,o++,l++,u+=s[o],o++,l++;let x=1,S=!1,C=!1,R=0,U=!1,L="",B=s[o]==="("&&!this.dollarDparenIsSubshell(o);for(;x>0&&o<i;){let v=s[o];if(u+=v,S)v==="'"&&(S=!1);else if(C)v==="\\"&&o+1<i?(u+=s[o+1],o++,l++):v==='"'&&(C=!1);else if(v==="'")S=!0,L="";else if(v==='"')C=!0,L="";else if(v==="\\"&&o+1<i)u+=s[o+1],o++,l++,L="";else if(v==="$"&&o+1<i&&s[o+1]==="{"){o++,l++,u+=s[o],o++,l++;let k=1,T=!1,O=!1;for(;k>0&&o<i;){let $=s[o];if($==="\\"&&o+1<i&&!T){u+=$,o++,l++,u+=s[o],o++,l++;continue}u+=$,T?$==="'"&&(T=!1):O?$==='"'&&(O=!1):$==="'"?T=!0:$==='"'?O=!0:$==="{"?k++:$==="}"&&k--,$===`
737
+ `?(c++,l=0):l++,o++}L="";continue}else if(v==="#"&&!B&&(L===""||/\s/.test(s[o-1]||""))){for(;o+1<i&&s[o+1]!==`
738
+ `;)o++,l++,u+=s[o];L=""}else/[a-zA-Z_]/.test(v)?L+=v:(L==="case"?(R++,U=!1):L==="in"&&R>0?U=!0:L==="esac"&&R>0&&(R--,U=!1),L="",v==="("?o>0&&s[o-1]==="$"?x++:U||x++:v===")"?U?U=!1:x--:v===";"&&R>0&&o+1<i&&s[o+1]===";"&&(U=!0));v===`
739
+ `&&(c++,l=0,L=""),o++,l++}continue}if(b==="$"&&o+1<i&&s[o+1]==="["&&!p){u+=b,o++,l++,u+=s[o],o++,l++;let x=1;for(;x>0&&o<i;){let S=s[o];u+=S,S==="["?x++:S==="]"?x--:S===`
740
+ `&&(c++,l=0),o++,l++}continue}if(b==="$"&&o+1<i&&s[o+1]==="{"&&!p){u+=b,o++,l++,u+=s[o],o++,l++;let x=1,S=!1,C=!1,R=c,U=l,L=c,B=l;for(;x>0&&o<i;){let v=s[o];if(v==="\\"&&o+1<i&&s[o+1]===`
741
+ `){o+=2,c++,l=1;continue}if(v==="\\"&&o+1<i&&!S){u+=v,o++,l++,u+=s[o],o++,l++;continue}u+=v,S?v==="'"&&(S=!1):C?v==='"'&&(C=!1):v==="'"?(S=!0,R=c,U=l):v==='"'?(C=!0,L=c,B=l):v==="{"?x++:v==="}"&&x--,v===`
742
+ `&&(c++,l=0),o++,l++}if(S)throw new $n("unexpected EOF while looking for matching `''",R,U);if(C)throw new $n("unexpected EOF while looking for matching `\"'",L,B);continue}if(b==="$"&&o+1<i&&!p){let x=s[o+1];if(x==="#"||x==="?"||x==="$"||x==="!"||x==="@"||x==="*"||x==="-"||x>="0"&&x<="9"){u+=b+x,o+=2,l+=2;continue}}if(b==="`"&&!p){for(u+=b,o++,l++;o<i&&s[o]!=="`";){let x=s[o];u+=x,x==="\\"&&o+1<i&&(u+=s[o+1],o++,l++),x===`
743
743
  `&&(c++,l=0),o++,l++}o<i&&(u+=s[o],o++,l++);continue}u+=b,o++,b===`
744
744
  `?(c++,l=1):l++}if(this.pos=o,this.column=l,this.line=c,g&&d&&(u=s[t]+u,f=!1,h=!1),p||m){let b=p?"'":'"';throw new $n(`unexpected EOF while looking for matching \`${b}'`,n,r)}if(!d&&u.length>=2){if(u[0]==="'"&&u[u.length-1]==="'"){let b=u.slice(1,-1);!b.includes("'")&&!b.includes('"')&&(u=b,f=!0,h=!0)}else if(u[0]==='"'&&u[u.length-1]==='"'){let b=u.slice(1,-1),x=!1;for(let S=0;S<b.length;S++){if(b[S]==='"'){x=!0;break}b[S]==="\\"&&S+1<b.length&&S++}x||(u=b,f=!0,h=!1)}}if(u==="")return{type:E.WORD,value:"",start:t,end:o,line:n,column:r,quoted:f,singleQuoted:h};let w=T0.get(u);if(!f&&w!==void 0)return{type:w,value:u,start:t,end:o,line:n,column:r};if(!d){let b=D0(u);if(b>0&&P0(u.slice(0,b)))return{type:E.ASSIGNMENT_WORD,value:u,start:t,end:o,line:n,column:r,quoted:f,singleQuoted:h}}return/^[0-9]+$/.test(u)?{type:E.NUMBER,value:u,start:t,end:o,line:n,column:r}:z5(u)?{type:E.NAME,value:u,start:t,end:o,line:n,column:r,quoted:f,singleQuoted:h}:{type:E.WORD,value:u,start:t,end:o,line:n,column:r,quoted:f,singleQuoted:h}}readHeredocContent(){for(;this.pendingHeredocs.length>0;){let t=this.pendingHeredocs.shift();if(!t)break;let n=this.pos,r=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]!==`
745
745
  `;)a+=this.input[this.pos],this.pos++,this.column++;if((t.stripTabs?a.replace(/^\t+/,""):a)===t.delimiter){this.pos<this.input.length&&this.input[this.pos]===`
@@ -757,35 +757,35 @@ Gid: ${r} ${r} ${r} ${r}
757
757
  `);)h=!0,f++;if(h&&f<r&&n[f]===")"||l)return!0}if(i===0)return!1;s++;continue}s++}return!1}dparenClosesWithSpacedParens(t){let n=this.input,r=n.length,s=t,i=2,o=!1,a=!1;for(;s<r&&i>0;){let l=n[s];if(o){l==="'"&&(o=!1),s++;continue}if(a){if(l==="\\"){s+=2;continue}l==='"'&&(a=!1),s++;continue}if(l==="'"){o=!0,s++;continue}if(l==='"'){a=!0,s++;continue}if(l==="\\"){s+=2;continue}if(l==="("){i++,s++;continue}if(l===")"){if(i--,i===1){let c=s+1;if(c<r&&n[c]===")")return!1;let u=c,f=!1;for(;u<r&&(n[u]===" "||n[u]===" "||n[u]===`
758
758
  `);)f=!0,u++;if(f&&u<r&&n[u]===")")return!0}if(i===0)return!1;s++;continue}if(i===1&&(l==="|"&&s+1<r&&n[s+1]==="|"||l==="&"&&s+1<r&&n[s+1]==="&"||l==="|"&&s+1<r&&n[s+1]!=="|"))return!0;s++}return!1}}});var ml,gl,_0,M0,F0,U0,lt,Yn=I(()=>{"use strict";Tn();ml=1e6,gl=1e5,_0=1e6,M0=new Set([E.LESS,E.GREAT,E.DLESS,E.DGREAT,E.LESSAND,E.GREATAND,E.LESSGREAT,E.DLESSDASH,E.CLOBBER,E.TLESS,E.AND_GREAT,E.AND_DGREAT]),F0=new Set([E.LESS,E.GREAT,E.DLESS,E.DGREAT,E.LESSAND,E.GREATAND,E.LESSGREAT,E.DLESSDASH,E.CLOBBER,E.TLESS]),U0=new Set([E.LESS,E.GREAT,E.DLESS,E.DGREAT,E.LESSAND,E.GREATAND,E.LESSGREAT,E.DLESSDASH,E.CLOBBER,E.TLESS,E.AND_GREAT,E.AND_DGREAT]),lt=class extends Error{line;column;token;constructor(t,n,r,s=void 0){super(`Parse error at ${n}:${r}: ${t}`),this.line=n,this.column=r,this.token=s,this.name="ParseException"}}});var q,Jn=I(()=>{"use strict";q={script(e){return{type:"Script",statements:e}},statement(e,t=[],n=!1,r,s){let i={type:"Statement",pipelines:e,operators:t,background:n};return r&&(i.deferredError=r),s!==void 0&&(i.sourceText=s),i},pipeline(e,t=!1,n=!1,r=!1,s){return{type:"Pipeline",commands:e,negated:t,timed:n,timePosix:r,pipeStderr:s}},simpleCommand(e,t=[],n=[],r=[]){return{type:"SimpleCommand",name:e,args:t,assignments:n,redirections:r}},word(e){return{type:"Word",parts:e}},literal(e){return{type:"Literal",value:e}},singleQuoted(e){return{type:"SingleQuoted",value:e}},doubleQuoted(e){return{type:"DoubleQuoted",parts:e}},escaped(e){return{type:"Escaped",value:e}},parameterExpansion(e,t=null){return{type:"ParameterExpansion",parameter:e,operation:t}},commandSubstitution(e,t=!1){return{type:"CommandSubstitution",body:e,legacy:t}},arithmeticExpansion(e){return{type:"ArithmeticExpansion",expression:e}},assignment(e,t,n=!1,r=null){return{type:"Assignment",name:e,value:t,append:n,array:r}},redirection(e,t,n=null,r){let s={type:"Redirection",fd:n,operator:e,target:t};return r&&(s.fdVariable=r),s},hereDoc(e,t,n=!1,r=!1){return{type:"HereDoc",delimiter:e,content:t,stripTabs:n,quoted:r}},ifNode(e,t=null,n=[]){return{type:"If",clauses:e,elseBody:t,redirections:n}},forNode(e,t,n,r=[]){return{type:"For",variable:e,words:t,body:n,redirections:r}},whileNode(e,t,n=[]){return{type:"While",condition:e,body:t,redirections:n}},untilNode(e,t,n=[]){return{type:"Until",condition:e,body:t,redirections:n}},caseNode(e,t,n=[]){return{type:"Case",word:e,items:t,redirections:n}},caseItem(e,t,n=";;"){return{type:"CaseItem",patterns:e,body:t,terminator:n}},subshell(e,t=[]){return{type:"Subshell",body:e,redirections:t}},group(e,t=[]){return{type:"Group",body:e,redirections:t}},functionDef(e,t,n=[],r){return{type:"FunctionDef",name:e,body:t,redirections:n,sourceFile:r}},conditionalCommand(e,t=[],n){return{type:"ConditionalCommand",expression:e,redirections:t,line:n}},arithmeticCommand(e,t=[],n){return{type:"ArithmeticCommand",expression:e,redirections:t,line:n}}}});function We(e,t){for(;t<e.length;){if(e[t]==="\\"&&e[t+1]===`
759
759
  `){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}function ms(e){if(e.includes("#")){let[t,n]=e.split("#"),r=Number.parseInt(t,10);if(r<2||r>64)return Number.NaN;if(r<=36)return Number.parseInt(n,r);let s=0;for(let i of n){let o;if(/[0-9]/.test(i))o=i.charCodeAt(0)-48;else if(/[a-z]/.test(i))o=i.charCodeAt(0)-97+10;else if(/[A-Z]/.test(i))o=i.charCodeAt(0)-65+36;else if(i==="@")o=62;else if(i==="_")o=63;else return Number.NaN;if(o>=r)return Number.NaN;s=s*r+o}return s}return e.startsWith("0x")||e.startsWith("0X")?Number.parseInt(e.slice(2),16):e.startsWith("0")&&e.length>1&&/^[0-9]+$/.test(e)?/[89]/.test(e)?Number.NaN:Number.parseInt(e,8):Number.parseInt(e,10)}function W0(e,t,n,r){if(n.slice(r,r+3)!=="$((")return null;let s=r+3,i=1,o=s;for(;s<n.length-1&&i>0;)n[s]==="("&&n[s+1]==="("?(i++,s+=2):n[s]===")"&&n[s+1]===")"?(i--,i>0&&(s+=2)):s++;let a=n.slice(o,s),{expr:l}=e(t,a,0);return s+=2,{expr:{type:"ArithNested",expression:l},pos:s}}function B0(e,t){if(e.slice(t,t+2)!=="$'")return null;let n=t+2,r="";for(;n<e.length&&e[n]!=="'";)if(e[n]==="\\"&&n+1<e.length){let i=e[n+1];switch(i){case"n":r+=`
760
- `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case"'":r+="'";break;default:r+=i}n+=2}else r+=e[n],n++;e[n]==="'"&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}function H0(e,t){if(e.slice(t,t+2)!=='$"')return null;let n=t+2,r="";for(;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]==='"'&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}var Pi,z0=I(()=>{"use strict";Pi=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function j5(e){let t="",n=0;for(;n<e.length;)if(e[n]==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function Ae(e,t){let n=j5(t),{expr:r,pos:s}=Ut(e,n,0),i=We(n,s);if(i<n.length){let o=t.slice(i).trim();if(o)return{type:"ArithmeticExpression",originalText:t,expression:{type:"ArithSyntaxError",errorToken:o,message:`${o}: syntax error: invalid arithmetic operator (error token is "${o}")`}}}return{type:"ArithmeticExpression",expression:r,originalText:t}}function It(e,t){return{expr:{type:"ArithSyntaxError",errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function Rt(e,t){return We(e,t)>=e.length}function Ut(e,t,n){return G5(e,t,n)}function G5(e,t,n){let{expr:r,pos:s}=gs(e,t,n);for(s=We(t,s);t[s]===",";){if(s++,Rt(t,s))return It(",",s);let{expr:o,pos:a}=gs(e,t,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=We(t,a)}return{expr:r,pos:s}}function gs(e,t,n){let{expr:r,pos:s}=V5(e,t,n);if(s=We(t,s),t[s]==="?"){s++;let{expr:i,pos:o}=Ut(e,t,s);if(s=We(t,o),t[s]===":"){s++;let{expr:a,pos:l}=Ut(e,t,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:a},pos:l}}}return{expr:r,pos:s}}function V5(e,t,n){let{expr:r,pos:s}=j0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="||";){if(s+=2,Rt(t,s))return It("||",s);let{expr:o,pos:a}=j0(e,t,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=a}return{expr:r,pos:s}}function j0(e,t,n){let{expr:r,pos:s}=G0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="&&";){if(s+=2,Rt(t,s))return It("&&",s);let{expr:o,pos:a}=G0(e,t,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=a}return{expr:r,pos:s}}function G0(e,t,n){let{expr:r,pos:s}=V0(e,t,n);for(;s=We(t,s),t[s]==="|"&&t[s+1]!=="|";){if(s++,Rt(t,s))return It("|",s);let{expr:o,pos:a}=V0(e,t,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=a}return{expr:r,pos:s}}function V0(e,t,n){let{expr:r,pos:s}=q0(e,t,n);for(;s=We(t,s),t[s]==="^";){if(s++,Rt(t,s))return It("^",s);let{expr:o,pos:a}=q0(e,t,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=a}return{expr:r,pos:s}}function q0(e,t,n){let{expr:r,pos:s}=Z0(e,t,n);for(;s=We(t,s),t[s]==="&"&&t[s+1]!=="&";){if(s++,Rt(t,s))return It("&",s);let{expr:o,pos:a}=Z0(e,t,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=a}return{expr:r,pos:s}}function Z0(e,t,n){let{expr:r,pos:s}=Q0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="=="||t.slice(s,s+2)==="!=";){let i=t.slice(s,s+2);if(s+=2,Rt(t,s))return It(i,s);let{expr:o,pos:a}=Q0(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Q0(e,t,n){let{expr:r,pos:s}=yl(e,t,n);for(;;)if(s=We(t,s),t.slice(s,s+2)==="<="||t.slice(s,s+2)===">="){let i=t.slice(s,s+2);if(s+=2,Rt(t,s))return It(i,s);let{expr:o,pos:a}=yl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else if(t[s]==="<"||t[s]===">"){let i=t[s];if(s++,Rt(t,s))return It(i,s);let{expr:o,pos:a}=yl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function yl(e,t,n){let{expr:r,pos:s}=K0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="<<"||t.slice(s,s+2)===">>";){let i=t.slice(s,s+2);if(s+=2,Rt(t,s))return It(i,s);let{expr:o,pos:a}=K0(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function K0(e,t,n){let{expr:r,pos:s}=X0(e,t,n);for(;s=We(t,s),(t[s]==="+"||t[s]==="-")&&t[s+1]!==t[s];){let i=t[s];if(s++,Rt(t,s))return It(i,s);let{expr:o,pos:a}=X0(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function X0(e,t,n){let{expr:r,pos:s}=Di(e,t,n);for(;;)if(s=We(t,s),t[s]==="*"&&t[s+1]!=="*"){if(s++,Rt(t,s))return It("*",s);let{expr:o,pos:a}=Di(e,t,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=a}else if(t[s]==="/"||t[s]==="%"){let i=t[s];if(s++,Rt(t,s))return It(i,s);let{expr:o,pos:a}=Di(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function Di(e,t,n){let{expr:r,pos:s}=wl(e,t,n),i=We(t,s);if(t.slice(i,i+2)==="**"){if(i+=2,Rt(t,i))return It("**",i);let{expr:a,pos:l}=Di(e,t,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:a},pos:l}}return{expr:r,pos:s}}function wl(e,t,n){let r=We(t,n);if(t.slice(r,r+2)==="++"||t.slice(r,r+2)==="--"){let s=t.slice(r,r+2);r+=2;let{expr:i,pos:o}=wl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(t[r]==="+"||t[r]==="-"||t[r]==="!"||t[r]==="~"){let s=t[r];r++;let{expr:i,pos:o}=wl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return Z5(e,t,r)}function q5(e,t){let n=e[t];return n==="$"||n==="`"}function Z5(e,t,n){let{expr:r,pos:s}=Y0(e,t,n,!1),i=[r];for(;q5(t,s);){let{expr:a,pos:l}=Y0(e,t,s,!0);i.push(a),s=l}i.length>1&&(r={type:"ArithConcat",parts:i});let o;if(t[s]==="["&&r.type==="ArithConcat"){s++;let{expr:a,pos:l}=Ut(e,t,s);o=a,s=l,t[s]==="]"&&s++}if(o&&r.type==="ArithConcat"&&(r={type:"ArithDynamicElement",nameExpr:r,subscript:o},o=void 0),s=We(t,s),r.type==="ArithConcat"||r.type==="ArithVariable"||r.type==="ArithDynamicElement"){for(let a of Pi)if(t.slice(s,s+a.length)===a&&t.slice(s,s+a.length+1)!=="=="){s+=a.length;let{expr:l,pos:c}=gs(e,t,s);return r.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r.nameExpr,subscript:r.subscript,value:l},pos:c}:r.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r,value:l},pos:c}:{expr:{type:"ArithAssignment",operator:a,variable:r.name,value:l},pos:c}}}if(t.slice(s,s+2)==="++"||t.slice(s,s+2)==="--"){let a=t.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:a,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function Y0(e,t,n,r=!1){let s=We(t,n),i=W0(Ut,e,t,s);if(i)return i;let o=B0(t,s);if(o)return o;let a=H0(t,s);if(a)return a;if(t.slice(s,s+2)==="$("&&t[s+2]!=="("){s+=2;let c=1,u=s;for(;s<t.length&&c>0;)t[s]==="("?c++:t[s]===")"&&c--,c>0&&s++;let f=t.slice(u,s);return s++,{expr:{type:"ArithCommandSubst",command:f},pos:s}}if(t[s]==="`"){s++;let c=s;for(;s<t.length&&t[s]!=="`";)s++;let u=t.slice(c,s);return t[s]==="`"&&s++,{expr:{type:"ArithCommandSubst",command:u},pos:s}}if(t[s]==="("){s++;let{expr:c,pos:u}=Ut(e,t,s);return s=We(t,u),t[s]===")"&&s++,{expr:{type:"ArithGroup",expression:c},pos:s}}if(t[s]==="'"){s++;let c="";for(;s<t.length&&t[s]!=="'";)c+=t[s],s++;t[s]==="'"&&s++;let u=Number.parseInt(c,10);return{expr:{type:"ArithSingleQuote",content:c,value:Number.isNaN(u)?0:u},pos:s}}if(t[s]==='"'){s++;let c="";for(;s<t.length&&t[s]!=='"';)t[s]==="\\"&&s+1<t.length?(c+=t[s+1],s+=2):(c+=t[s],s++);t[s]==='"'&&s++;let u=c.trim();if(!u)return{expr:{type:"ArithNumber",value:0},pos:s};let{expr:f}=Ut(e,u,0);return{expr:f,pos:s}}if(/[0-9]/.test(t[s])){let c="",u=!1,f=!1;for(;s<t.length;){let p=t[s];if(u)if(/[0-9a-zA-Z@_]/.test(p))c+=p,s++;else break;else if(p==="#")u=!0,c+=p,s++;else if(c==="0"&&(p==="x"||p==="X")&&s+1<t.length&&/[0-9a-fA-F]/.test(t[s+1]))f=!0,c+=p,s++;else if(f&&/[0-9a-fA-F]/.test(p))c+=p,s++;else if(!f&&/[0-9]/.test(p))c+=p,s++;else break}if(s<t.length&&/[a-zA-Z_]/.test(t[s])){let p=c;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)p+=t[s],s++;return{expr:{type:"ArithSyntaxError",errorToken:p,message:`${p}: value too great for base (error token is "${p}")`},pos:s}}if(t[s]==="."&&/[0-9]/.test(t[s+1]))throw new $e(`${c}.${t[s+1]}...: syntax error: invalid arithmetic operator`);if(t[s]==="["){let p=t.slice(s).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:p},pos:t.length}}return{expr:{type:"ArithNumber",value:ms(c)},pos:s}}if(t[s]==="$"&&t[s+1]==="{"){let c=s+2,u=1,f=c;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;let h=t.slice(c,f),p=f+1;if(t[p]==="#"){let m=p+1;for(;m<t.length&&/[0-9a-zA-Z@_]/.test(t[m]);)m++;let d=t.slice(p+1,m);return{expr:{type:"ArithDynamicBase",baseExpr:h,value:d},pos:m}}if(/[0-9]/.test(t[p])||t[p]==="x"||t[p]==="X"){let m=p;if(t[p]==="x"||t[p]==="X")for(m++;m<t.length&&/[0-9a-fA-F]/.test(t[m]);)m++;else for(;m<t.length&&/[0-9]/.test(t[m]);)m++;let d=t.slice(p,m);return{expr:{type:"ArithDynamicNumber",prefix:h,suffix:d},pos:m}}return s=p,{expr:{type:"ArithBracedExpansion",content:h},pos:s}}if(t[s]==="$"&&s+1<t.length&&/[0-9]/.test(t[s+1])){s++;let c="";for(;s<t.length&&/[0-9]/.test(t[s]);)c+=t[s],s++;return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:!0},pos:s}}if(t[s]==="$"&&s+1<t.length&&/[*@#?\-!$]/.test(t[s+1])){let c=t[s+1];return s+=2,{expr:{type:"ArithSpecialVar",name:c},pos:s}}let l=!1;if(t[s]==="$"&&s+1<t.length&&/[a-zA-Z_]/.test(t[s+1])&&(l=!0,s++),s<t.length&&/[a-zA-Z_]/.test(t[s])){let c="";for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)c+=t[s],s++;if(t[s]==="["&&!r){s++;let u;if(t[s]==="'"||t[s]==='"'){let h=t[s];for(s++,u="";s<t.length&&t[s]!==h;)u+=t[s],s++;t[s]===h&&s++,s=We(t,s),t[s]==="]"&&s++}let f;if(u===void 0){let{expr:h,pos:p}=Ut(e,t,s);f=h,s=p,t[s]==="]"&&s++}if(s=We(t,s),t[s]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:s};if(!r){for(let h of Pi)if(t.slice(s,s+h.length)===h&&t.slice(s,s+h.length+1)!=="=="){s+=h.length;let{expr:p,pos:m}=gs(e,t,s);return{expr:{type:"ArithAssignment",operator:h,variable:c,subscript:f,stringKey:u,value:p},pos:m}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:s}}if(s=We(t,s),!r){for(let u of Pi)if(t.slice(s,s+u.length)===u&&t.slice(s,s+u.length+1)!=="=="){s+=u.length;let{expr:f,pos:h}=gs(e,t,s);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:h}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:l},pos:s}}if(t[s]==="#"){let c=s+1;for(;c<t.length&&t[c]!==`
760
+ `;break;case"t":r+=" ";break;case"r":r+="\r";break;case"\\":r+="\\";break;case"'":r+="'";break;default:r+=i}n+=2}else r+=e[n],n++;e[n]==="'"&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}function H0(e,t){if(e.slice(t,t+2)!=='$"')return null;let n=t+2,r="";for(;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?(r+=e[n+1],n+=2):(r+=e[n],n++);e[n]==='"'&&n++;let s=Number.parseInt(r,10);return{expr:{type:"ArithNumber",value:Number.isNaN(s)?0:s},pos:n}}var Pi,z0=I(()=>{"use strict";Pi=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function j5(e){let t="",n=0;for(;n<e.length;)if(e[n]==='"'){for(n++;n<e.length&&e[n]!=='"';)e[n]==="\\"&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);n<e.length&&n++}else t+=e[n],n++;return t}function Ae(e,t){let n=j5(t),{expr:r,pos:s}=Ut(e,n,0),i=We(n,s);if(i<n.length){let o=t.slice(i).trim();if(o)return{type:"ArithmeticExpression",originalText:t,expression:{type:"ArithSyntaxError",errorToken:o,message:`${o}: syntax error: invalid arithmetic operator (error token is "${o}")`}}}return{type:"ArithmeticExpression",expression:r,originalText:t}}function It(e,t){return{expr:{type:"ArithSyntaxError",errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function Ot(e,t){return We(e,t)>=e.length}function Ut(e,t,n){return G5(e,t,n)}function G5(e,t,n){let{expr:r,pos:s}=gs(e,t,n);for(s=We(t,s);t[s]===",";){if(s++,Ot(t,s))return It(",",s);let{expr:o,pos:a}=gs(e,t,s);r={type:"ArithBinary",operator:",",left:r,right:o},s=We(t,a)}return{expr:r,pos:s}}function gs(e,t,n){let{expr:r,pos:s}=V5(e,t,n);if(s=We(t,s),t[s]==="?"){s++;let{expr:i,pos:o}=Ut(e,t,s);if(s=We(t,o),t[s]===":"){s++;let{expr:a,pos:l}=Ut(e,t,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:a},pos:l}}}return{expr:r,pos:s}}function V5(e,t,n){let{expr:r,pos:s}=j0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="||";){if(s+=2,Ot(t,s))return It("||",s);let{expr:o,pos:a}=j0(e,t,s);r={type:"ArithBinary",operator:"||",left:r,right:o},s=a}return{expr:r,pos:s}}function j0(e,t,n){let{expr:r,pos:s}=G0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="&&";){if(s+=2,Ot(t,s))return It("&&",s);let{expr:o,pos:a}=G0(e,t,s);r={type:"ArithBinary",operator:"&&",left:r,right:o},s=a}return{expr:r,pos:s}}function G0(e,t,n){let{expr:r,pos:s}=V0(e,t,n);for(;s=We(t,s),t[s]==="|"&&t[s+1]!=="|";){if(s++,Ot(t,s))return It("|",s);let{expr:o,pos:a}=V0(e,t,s);r={type:"ArithBinary",operator:"|",left:r,right:o},s=a}return{expr:r,pos:s}}function V0(e,t,n){let{expr:r,pos:s}=q0(e,t,n);for(;s=We(t,s),t[s]==="^";){if(s++,Ot(t,s))return It("^",s);let{expr:o,pos:a}=q0(e,t,s);r={type:"ArithBinary",operator:"^",left:r,right:o},s=a}return{expr:r,pos:s}}function q0(e,t,n){let{expr:r,pos:s}=Z0(e,t,n);for(;s=We(t,s),t[s]==="&"&&t[s+1]!=="&";){if(s++,Ot(t,s))return It("&",s);let{expr:o,pos:a}=Z0(e,t,s);r={type:"ArithBinary",operator:"&",left:r,right:o},s=a}return{expr:r,pos:s}}function Z0(e,t,n){let{expr:r,pos:s}=Q0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="=="||t.slice(s,s+2)==="!=";){let i=t.slice(s,s+2);if(s+=2,Ot(t,s))return It(i,s);let{expr:o,pos:a}=Q0(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function Q0(e,t,n){let{expr:r,pos:s}=yl(e,t,n);for(;;)if(s=We(t,s),t.slice(s,s+2)==="<="||t.slice(s,s+2)===">="){let i=t.slice(s,s+2);if(s+=2,Ot(t,s))return It(i,s);let{expr:o,pos:a}=yl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else if(t[s]==="<"||t[s]===">"){let i=t[s];if(s++,Ot(t,s))return It(i,s);let{expr:o,pos:a}=yl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function yl(e,t,n){let{expr:r,pos:s}=K0(e,t,n);for(;s=We(t,s),t.slice(s,s+2)==="<<"||t.slice(s,s+2)===">>";){let i=t.slice(s,s+2);if(s+=2,Ot(t,s))return It(i,s);let{expr:o,pos:a}=K0(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function K0(e,t,n){let{expr:r,pos:s}=X0(e,t,n);for(;s=We(t,s),(t[s]==="+"||t[s]==="-")&&t[s+1]!==t[s];){let i=t[s];if(s++,Ot(t,s))return It(i,s);let{expr:o,pos:a}=X0(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}return{expr:r,pos:s}}function X0(e,t,n){let{expr:r,pos:s}=Di(e,t,n);for(;;)if(s=We(t,s),t[s]==="*"&&t[s+1]!=="*"){if(s++,Ot(t,s))return It("*",s);let{expr:o,pos:a}=Di(e,t,s);r={type:"ArithBinary",operator:"*",left:r,right:o},s=a}else if(t[s]==="/"||t[s]==="%"){let i=t[s];if(s++,Ot(t,s))return It(i,s);let{expr:o,pos:a}=Di(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:o},s=a}else break;return{expr:r,pos:s}}function Di(e,t,n){let{expr:r,pos:s}=wl(e,t,n),i=We(t,s);if(t.slice(i,i+2)==="**"){if(i+=2,Ot(t,i))return It("**",i);let{expr:a,pos:l}=Di(e,t,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:a},pos:l}}return{expr:r,pos:s}}function wl(e,t,n){let r=We(t,n);if(t.slice(r,r+2)==="++"||t.slice(r,r+2)==="--"){let s=t.slice(r,r+2);r+=2;let{expr:i,pos:o}=wl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}if(t[r]==="+"||t[r]==="-"||t[r]==="!"||t[r]==="~"){let s=t[r];r++;let{expr:i,pos:o}=wl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:o}}return Z5(e,t,r)}function q5(e,t){let n=e[t];return n==="$"||n==="`"}function Z5(e,t,n){let{expr:r,pos:s}=Y0(e,t,n,!1),i=[r];for(;q5(t,s);){let{expr:a,pos:l}=Y0(e,t,s,!0);i.push(a),s=l}i.length>1&&(r={type:"ArithConcat",parts:i});let o;if(t[s]==="["&&r.type==="ArithConcat"){s++;let{expr:a,pos:l}=Ut(e,t,s);o=a,s=l,t[s]==="]"&&s++}if(o&&r.type==="ArithConcat"&&(r={type:"ArithDynamicElement",nameExpr:r,subscript:o},o=void 0),s=We(t,s),r.type==="ArithConcat"||r.type==="ArithVariable"||r.type==="ArithDynamicElement"){for(let a of Pi)if(t.slice(s,s+a.length)===a&&t.slice(s,s+a.length+1)!=="=="){s+=a.length;let{expr:l,pos:c}=gs(e,t,s);return r.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r.nameExpr,subscript:r.subscript,value:l},pos:c}:r.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:a,target:r,value:l},pos:c}:{expr:{type:"ArithAssignment",operator:a,variable:r.name,value:l},pos:c}}}if(t.slice(s,s+2)==="++"||t.slice(s,s+2)==="--"){let a=t.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:a,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function Y0(e,t,n,r=!1){let s=We(t,n),i=W0(Ut,e,t,s);if(i)return i;let o=B0(t,s);if(o)return o;let a=H0(t,s);if(a)return a;if(t.slice(s,s+2)==="$("&&t[s+2]!=="("){s+=2;let c=1,u=s;for(;s<t.length&&c>0;)t[s]==="("?c++:t[s]===")"&&c--,c>0&&s++;let f=t.slice(u,s);return s++,{expr:{type:"ArithCommandSubst",command:f},pos:s}}if(t[s]==="`"){s++;let c=s;for(;s<t.length&&t[s]!=="`";)s++;let u=t.slice(c,s);return t[s]==="`"&&s++,{expr:{type:"ArithCommandSubst",command:u},pos:s}}if(t[s]==="("){s++;let{expr:c,pos:u}=Ut(e,t,s);return s=We(t,u),t[s]===")"&&s++,{expr:{type:"ArithGroup",expression:c},pos:s}}if(t[s]==="'"){s++;let c="";for(;s<t.length&&t[s]!=="'";)c+=t[s],s++;t[s]==="'"&&s++;let u=Number.parseInt(c,10);return{expr:{type:"ArithSingleQuote",content:c,value:Number.isNaN(u)?0:u},pos:s}}if(t[s]==='"'){s++;let c="";for(;s<t.length&&t[s]!=='"';)t[s]==="\\"&&s+1<t.length?(c+=t[s+1],s+=2):(c+=t[s],s++);t[s]==='"'&&s++;let u=c.trim();if(!u)return{expr:{type:"ArithNumber",value:0},pos:s};let{expr:f}=Ut(e,u,0);return{expr:f,pos:s}}if(/[0-9]/.test(t[s])){let c="",u=!1,f=!1;for(;s<t.length;){let p=t[s];if(u)if(/[0-9a-zA-Z@_]/.test(p))c+=p,s++;else break;else if(p==="#")u=!0,c+=p,s++;else if(c==="0"&&(p==="x"||p==="X")&&s+1<t.length&&/[0-9a-fA-F]/.test(t[s+1]))f=!0,c+=p,s++;else if(f&&/[0-9a-fA-F]/.test(p))c+=p,s++;else if(!f&&/[0-9]/.test(p))c+=p,s++;else break}if(s<t.length&&/[a-zA-Z_]/.test(t[s])){let p=c;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)p+=t[s],s++;return{expr:{type:"ArithSyntaxError",errorToken:p,message:`${p}: value too great for base (error token is "${p}")`},pos:s}}if(t[s]==="."&&/[0-9]/.test(t[s+1]))throw new $e(`${c}.${t[s+1]}...: syntax error: invalid arithmetic operator`);if(t[s]==="["){let p=t.slice(s).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:p},pos:t.length}}return{expr:{type:"ArithNumber",value:ms(c)},pos:s}}if(t[s]==="$"&&t[s+1]==="{"){let c=s+2,u=1,f=c;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;let h=t.slice(c,f),p=f+1;if(t[p]==="#"){let m=p+1;for(;m<t.length&&/[0-9a-zA-Z@_]/.test(t[m]);)m++;let d=t.slice(p+1,m);return{expr:{type:"ArithDynamicBase",baseExpr:h,value:d},pos:m}}if(/[0-9]/.test(t[p])||t[p]==="x"||t[p]==="X"){let m=p;if(t[p]==="x"||t[p]==="X")for(m++;m<t.length&&/[0-9a-fA-F]/.test(t[m]);)m++;else for(;m<t.length&&/[0-9]/.test(t[m]);)m++;let d=t.slice(p,m);return{expr:{type:"ArithDynamicNumber",prefix:h,suffix:d},pos:m}}return s=p,{expr:{type:"ArithBracedExpansion",content:h},pos:s}}if(t[s]==="$"&&s+1<t.length&&/[0-9]/.test(t[s+1])){s++;let c="";for(;s<t.length&&/[0-9]/.test(t[s]);)c+=t[s],s++;return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:!0},pos:s}}if(t[s]==="$"&&s+1<t.length&&/[*@#?\-!$]/.test(t[s+1])){let c=t[s+1];return s+=2,{expr:{type:"ArithSpecialVar",name:c},pos:s}}let l=!1;if(t[s]==="$"&&s+1<t.length&&/[a-zA-Z_]/.test(t[s+1])&&(l=!0,s++),s<t.length&&/[a-zA-Z_]/.test(t[s])){let c="";for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)c+=t[s],s++;if(t[s]==="["&&!r){s++;let u;if(t[s]==="'"||t[s]==='"'){let h=t[s];for(s++,u="";s<t.length&&t[s]!==h;)u+=t[s],s++;t[s]===h&&s++,s=We(t,s),t[s]==="]"&&s++}let f;if(u===void 0){let{expr:h,pos:p}=Ut(e,t,s);f=h,s=p,t[s]==="]"&&s++}if(s=We(t,s),t[s]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:s};if(!r){for(let h of Pi)if(t.slice(s,s+h.length)===h&&t.slice(s,s+h.length+1)!=="=="){s+=h.length;let{expr:p,pos:m}=gs(e,t,s);return{expr:{type:"ArithAssignment",operator:h,variable:c,subscript:f,stringKey:u,value:p},pos:m}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:s}}if(s=We(t,s),!r){for(let u of Pi)if(t.slice(s,s+u.length)===u&&t.slice(s,s+u.length+1)!=="=="){s+=u.length;let{expr:f,pos:h}=gs(e,t,s);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:h}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:l},pos:s}}if(t[s]==="#"){let c=s+1;for(;c<t.length&&t[c]!==`
761
761
  `;)c++;let u=t.slice(s,c).trim()||"#";return{expr:{type:"ArithSyntaxError",errorToken:u,message:`${u}: syntax error: invalid arithmetic operator (error token is "${u}")`},pos:t.length}}return{expr:{type:"ArithNumber",value:0},pos:s}}var pt=I(()=>{"use strict";xe();z0()});function Q5(e){let t="",n=0;for(;n<e.length;){let r=e[n];if(r<128){t+=String.fromCharCode(r),n++;continue}if((r&224)===192){if(n+1<e.length&&(e[n+1]&192)===128&&r>=194){let s=(r&31)<<6|e[n+1]&63;t+=String.fromCharCode(s),n+=2;continue}t+=String.fromCharCode(r),n++;continue}if((r&240)===224){if(n+2<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128){if(r===224&&e[n+1]<160){t+=String.fromCharCode(r),n++;continue}let s=(r&15)<<12|(e[n+1]&63)<<6|e[n+2]&63;if(s>=55296&&s<=57343){t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(s),n+=3;continue}t+=String.fromCharCode(r),n++;continue}if((r&248)===240&&r<=244){if(n+3<e.length&&(e[n+1]&192)===128&&(e[n+2]&192)===128&&(e[n+3]&192)===128){if(r===240&&e[n+1]<144){t+=String.fromCharCode(r),n++;continue}let s=(r&7)<<18|(e[n+1]&63)<<12|(e[n+2]&63)<<6|e[n+3]&63;if(s>1114111){t+=String.fromCharCode(r),n++;continue}t+=String.fromCodePoint(s),n+=4;continue}t+=String.fromCharCode(r),n++;continue}t+=String.fromCharCode(r),n++}return t}function tm(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function bl(e,t,n,r,s){let i=1,o=n+1;for(;o<t.length&&i>0;)t[o]===r?i++:t[o]===s&&i--,i>0&&o++;return i===0?o:-1}function er(e,t,n){let r=n,s=1;for(;r<t.length&&s>0;){let i=t[r];if(i==="\\"&&r+1<t.length){r+=2;continue}if(i==="'"){let o=t.indexOf("'",r+1);if(o!==-1){r=o+1;continue}}if(i==='"'){for(r++;r<t.length&&t[r]!=='"';)t[r]==="\\"&&r+1<t.length?r+=2:r++;r<t.length&&r++;continue}i==="{"?s++:i==="}"&&s--,s>0&&r++}return r}function nm(e,t,n){let r=n,s=!1;for(;r<t.length;){let i=t[r];if(i==="/"&&s||i==="}")break;if(i==="'"){let o=t.indexOf("'",r+1);if(o!==-1){r=o+1,s=!0;continue}}if(i==='"'){for(r++;r<t.length&&t[r]!=='"';)t[r]==="\\"&&r+1<t.length?r+=2:r++;r<t.length&&r++,s=!0;continue}i==="\\"?(r+=2,s=!0):(r++,s=!0)}return r}function rm(e,t,n){let r=n,s="";for(;r<t.length;){let i=t[r];if(i==="*"||i==="?")s+=i,r++;else if(i==="["){let o=K5(t,r);o===-1?(s+=i,r++):(s+=t.slice(r,o+1),r=o+1)}else break}return{pattern:s,endIndex:r}}function K5(e,t){let n=t+1;for(n<e.length&&e[n]==="^"&&n++,n<e.length&&e[n]==="]"&&n++;n<e.length;){let r=e[n];if(r==="\\"&&n+1<e.length){let s=e[n+1];if(s==='"'||s==="'")return-1;n+=2;continue}if(r==="]")return n;if(r==='"'||r==="$"||r==="`")return-1;if(r==="'"){let s=e.indexOf("'",n+1);if(s!==-1){n=s+1;continue}}if(r==="["&&n+1<e.length&&e[n+1]===":"){let s=e.indexOf(":]",n+2);if(s!==-1){n=s+2;continue}}if(r==="["&&n+1<e.length&&(e[n+1]==="."||e[n+1]==="=")){let i=`${e[n+1]}]`,o=e.indexOf(i,n+2);if(o!==-1){n=o+2;continue}}n++}return-1}function sm(e,t,n){let r="",s=n;for(;s<t.length&&t[s]!=="'";){let i=t[s];if(i==="\\"&&s+1<t.length)switch(t[s+1]){case"n":r+=`
762
- `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=[],l=s;for(;l+1<t.length&&t[l]==="\\"&&t[l+1]==="x";){let c=t.slice(l+2,l+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)a.push(u),l+=2+c.length;else break}a.length>0?(r+=Q5(a),s=l):(r+="\\x",s+=2);break}case"u":{let a=t.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"c":{if(s+2<t.length){let l=t[s+2].charCodeAt(0)&31;r+=String.fromCharCode(l),s+=3}else r+="\\c",s+=2;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<t.length&&l<s+4&&/[0-7]/.test(t[l]);)a+=t[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<t.length&&t[s]==="'"&&s++,{part:q.literal(r),endIndex:s}}function xl(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ae(e,n)}function em(e){let t=[],n="",r=0;for(let s=0;s<e.length;s++){let i=e[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(t.push(n),n=""):n+=i}return t.push(n),t}function im(e,t,n,r){let s=bl(e,t,n,"{","}");if(s===-1)return null;let i=t.slice(n+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(",")&&r?{part:{type:"BraceExpansion",items:em(i).map(u=>({type:"Word",word:q.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:em(i).map(u=>({type:"Word",word:q.word([q.literal(u)])}))},endIndex:s+1}:null}function El(e,t){let n="";for(let r of t.parts)switch(r.type){case"Literal":n+=r.value;break;case"SingleQuoted":n+=`'${r.value}'`;break;case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;case"TildeExpansion":n+="~",r.user&&(n+=r.user);break;case"BraceExpansion":{n+="{";let s=[];for(let i of r.items)if(i.type==="Range"){let o=i.startStr??String(i.start),a=i.endStr??String(i.end);i.step!==void 0?s.push(`${o}..${a}..${i.step}`):s.push(`${o}..${a}`)}else s.push(El(e,i.word));s.length===1&&r.items[0].type==="Range"?n+=s[0]:n+=s.join(","),n+="}";break}default:n+=r.type}return n}function om(e,t){return{[E.LESS]:"<",[E.GREAT]:">",[E.DGREAT]:">>",[E.LESSAND]:"<&",[E.GREATAND]:">&",[E.LESSGREAT]:"<>",[E.CLOBBER]:">|",[E.TLESS]:"<<<",[E.AND_GREAT]:"&>",[E.AND_DGREAT]:"&>>",[E.DLESS]:"<",[E.DLESSDASH]:"<"}[t]||">"}var Al=I(()=>{"use strict";Jn();pt();Tn()});function Li(e){let t=e.current(),n=t.type;if(n===E.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:F0.has(r.type)}if(n===E.FD_VARIABLE){let r=e.peek(1);return U0.has(r.type)}return M0.has(n)}function _i(e){let t=null,n;e.check(E.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(E.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),s=om(e,r.type);if(r.type===E.DLESS||r.type===E.DLESSDASH)return X5(e,s,t,r.type===E.DLESSDASH);e.isWord()||e.error("Expected redirection target");let i=e.parseWord();return q.redirection(s,i,t,n)}function X5(e,t,n,r){e.isWord()||e.error("Expected here-document delimiter");let s=e.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=q.redirection(r?"<<-":"<<",q.hereDoc(i,q.word([]),r,o),n);return e.addPendingHeredoc(a,i,r,o),a}function lm(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(E.ASSIGNMENT_WORD)||Li(e);)e.checkIterationLimit(),e.check(E.ASSIGNMENT_WORD)?n.push(Y5(e)):i.push(_i(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(E.DBRACK_START)||e.check(E.DPAREN_START))){let a=e.advance();r=q.word([q.literal(a.value)])}for(;(!e.isStatementEnd()||e.check(E.RBRACE))&&!e.check(E.PIPE,E.PIPE_AMP);)if(e.checkIterationLimit(),Li(e))i.push(_i(e));else if(e.check(E.RBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(E.LBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(E.DBRACK_END)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.isWord())s.push(e.parseWord());else if(e.check(E.ASSIGNMENT_WORD)){let a=e.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||e.check(E.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||e.expect(E.LPAREN);let h=Sl(e);e.expect(E.RPAREN);let p=h.map(d=>El(e,d)),m=`${f}=(${p.join(" ")})`;s.push(e.parseWordFromString(m,!1,!1))}else s.push(e.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(e.check(E.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=q.simpleCommand(r,s,n,i);return o.line=t,o}function Y5(e){let t=e.expect(E.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,h=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${n}`),i=n.slice(h,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&e.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=Sl(e);e.expect(E.RPAREN);let h=i!==void 0?`${s}[${i}]`:s;return q.assignment(h,null,a,f)}if(l===""&&e.check(E.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let h=Sl(e);e.expect(E.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return q.assignment(p,null,a,h)}}let c=l?e.parseWordFromString(l,t.quoted,t.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return q.assignment(u,c,a,null)}function Sl(e){let t=[];for(e.skipNewlines();!e.check(E.RPAREN,E.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):J5.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var J5,cm=I(()=>{"use strict";Jn();Tn();Yn();Al();J5=new Set([E.AMP,E.PIPE,E.PIPE_AMP,E.SEMICOLON,E.AND_AND,E.OR_OR,E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND])});function Cl(e,t){e.expect(E.IF);let n=[],r=e.parseCompoundList();e.expect(E.THEN);let s=e.parseCompoundList();if(s.length===0){let a=e.check(E.FI)?"fi":e.check(E.ELSE)?"else":e.check(E.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${a}'`)}for(n.push({condition:r,body:s});e.check(E.ELIF);){e.advance();let a=e.parseCompoundList();e.expect(E.THEN);let l=e.parseCompoundList();if(l.length===0){let c=e.check(E.FI)?"fi":e.check(E.ELSE)?"else":e.check(E.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${c}'`)}n.push({condition:a,body:l})}let i=null;e.check(E.ELSE)&&(e.advance(),i=e.parseCompoundList(),i.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(E.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.ifNode(n,i,o)}function Nl(e,t){let n=e.expect(E.FOR);if(e.check(E.DPAREN_START))return tw(e,t,n.line);e.isWord()||e.error("Expected variable name in for loop");let s=e.advance().value,i=null;if(e.skipNewlines(),e.check(E.IN))for(e.advance(),i=[];!e.check(E.SEMICOLON,E.NEWLINE,E.DO,E.EOF)&&e.isWord();)i.push(e.parseWord());e.check(E.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(E.DO);let o=e.parseCompoundList();e.expect(E.DONE);let a=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.forNode(s,i,o,a)}function tw(e,t,n){e.expect(E.DPAREN_START);let r=null,s=null,i=null,o=["","",""],a=0,l=0;for(;!e.check(E.DPAREN_END,E.EOF);){let f=e.advance();if(f.type===E.SEMICOLON&&l===0){if(a++,a>2)break}else f.value==="("&&l++,f.value===")"&&l--,o[a]+=f.value}e.expect(E.DPAREN_END),o[0].trim()&&(r=Ae(e,o[0].trim())),o[1].trim()&&(s=Ae(e,o[1].trim())),o[2].trim()&&(i=Ae(e,o[2].trim())),e.skipNewlines(),e.check(E.SEMICOLON)&&e.advance(),e.skipNewlines();let c;e.check(E.LBRACE)?(e.advance(),c=e.parseCompoundList(),e.expect(E.RBRACE)):(e.expect(E.DO),c=e.parseCompoundList(),e.expect(E.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:"CStyleFor",init:r,condition:s,update:i,body:c,redirections:u,line:n}}function kl(e,t){e.expect(E.WHILE);let n=e.parseCompoundList();e.expect(E.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(E.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.whileNode(n,r,s)}function vl(e,t){e.expect(E.UNTIL);let n=e.parseCompoundList();e.expect(E.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(E.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.untilNode(n,r,s)}function Il(e,t){e.expect(E.CASE),e.isWord()||e.error("Expected word after 'case'");let n=e.parseWord();e.skipNewlines(),e.expect(E.IN),e.skipNewlines();let r=[];for(;!e.check(E.ESAC,E.EOF);){e.checkIterationLimit();let i=e.getPos(),o=nw(e);if(o&&r.push(o),e.skipNewlines(),e.getPos()===i&&!o)break}e.expect(E.ESAC);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.caseNode(n,r,s)}function nw(e){e.check(E.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(E.PIPE));)e.advance();if(t.length===0)return null;e.expect(E.RPAREN),e.skipNewlines();let n=[];for(;!e.check(E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND,E.ESAC,E.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===E.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(E.LPAREN)&&e.peek(1).type===E.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let s=e.getPos(),i=e.parseStatement();if(i&&n.push(i),e.skipSeparators(!1),e.getPos()===s&&!i)break}let r=";;";return e.check(E.DSEMI)?(e.advance(),r=";;"):e.check(E.SEMI_AND)?(e.advance(),r=";&"):e.check(E.SEMI_SEMI_AND)&&(e.advance(),r=";;&"),q.caseItem(t,n,r)}function Rl(e,t){e.expect(E.LPAREN);let n=e.parseCompoundList();e.expect(E.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.subshell(n,r)}function Ol(e,t){e.expect(E.LBRACE);let n=e.parseCompoundList();e.expect(E.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.group(n,r)}var um=I(()=>{"use strict";Jn();pt();Tn()});function fm(e){return e.isWord()||e.check(E.LBRACE)||e.check(E.RBRACE)||e.check(E.ASSIGNMENT_WORD)}function hm(e){if(e.check(E.BANG)&&e.peek(1).type===E.LPAREN){e.advance(),e.advance();let t=1,n="!(";for(;t>0&&!e.check(E.EOF);)if(e.check(E.LPAREN))t++,n+="(",e.advance();else if(e.check(E.RPAREN))t--,t>0&&(n+=")"),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(E.PIPE))n+="|",e.advance();else break;return n+=")",e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function Tl(e){return e.skipNewlines(),ow(e)}function ow(e){let t=pm(e);for(e.skipNewlines();e.check(E.OR_OR);){e.advance(),e.skipNewlines();let n=pm(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function pm(e){let t=$l(e);for(e.skipNewlines();e.check(E.AND_AND);){e.advance(),e.skipNewlines();let n=$l(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function $l(e){return e.skipNewlines(),e.check(E.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:$l(e)}):aw(e)}function aw(e){if(e.check(E.LPAREN)){e.advance();let t=Tl(e);return e.expect(E.RPAREN),{type:"CondGroup",expression:t}}if(fm(e)){let t=e.current(),n=t.value;if(sw.includes(n)&&!t.quoted){if(e.advance(),e.check(E.DBRACK_END)&&e.error(`Expected operand after ${n}`),fm(e)){let i=e.parseWordNoBraceExpansion();return{type:"CondUnary",operator:n,operand:i}}let s=e.current();e.error(`unexpected argument \`${s.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&iw.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=lw(e):s==="=="||s==="!="?i=hm(e):i=e.parseWordNoBraceExpansion(),{type:"CondBinary",operator:s,left:r,right:i}}if(e.check(E.LESS)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:"<",left:r,right:s}}if(e.check(E.GREAT)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:">",left:r,right:s}}if(e.isWord()&&e.current().value==="="){e.advance();let s=hm(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function lw(e){let t=[],n=0,r=-1,s=e.getInput(),i=()=>e.check(E.DBRACK_END)||e.check(E.AND_AND)||e.check(E.OR_OR)||e.check(E.NEWLINE)||e.check(E.EOF);for(;!i();){let o=e.current(),a=r>=0&&o.start>r;if(n===0&&a)break;if(n>0&&a){let l=s.slice(r,o.start);t.push({type:"Literal",value:l})}if(e.isWord()||e.check(E.ASSIGNMENT_WORD)){let l=e.parseWordForRegex();t.push(...l.parts),r=e.peek(-1).end}else if(e.check(E.LPAREN)){let l=e.advance();t.push({type:"Literal",value:"("}),n++,r=l.end}else if(e.check(E.DPAREN_START)){let l=e.advance();t.push({type:"Literal",value:"(("}),n+=2,r=l.end}else if(e.check(E.DPAREN_END))if(n>=2){let l=e.advance();t.push({type:"Literal",value:"))"}),n-=2,r=l.end}else{if(n===1)break;break}else if(e.check(E.RPAREN))if(n>0){let l=e.advance();t.push({type:"Literal",value:")"}),n--,r=l.end}else break;else if(e.check(E.PIPE)){let l=e.advance();t.push({type:"Literal",value:"|"}),r=l.end}else if(e.check(E.SEMICOLON))if(n>0){let l=e.advance();t.push({type:"Literal",value:";"}),r=l.end}else break;else if(n>0&&e.check(E.LESS)){let l=e.advance();t.push({type:"Literal",value:"<"}),r=l.end}else if(n>0&&e.check(E.GREAT)){let l=e.advance();t.push({type:"Literal",value:">"}),r=l.end}else if(n>0&&e.check(E.DGREAT)){let l=e.advance();t.push({type:"Literal",value:">>"}),r=l.end}else if(n>0&&e.check(E.DLESS)){let l=e.advance();t.push({type:"Literal",value:"<<"}),r=l.end}else if(n>0&&e.check(E.LESSAND)){let l=e.advance();t.push({type:"Literal",value:"<&"}),r=l.end}else if(n>0&&e.check(E.GREATAND)){let l=e.advance();t.push({type:"Literal",value:">&"}),r=l.end}else if(n>0&&e.check(E.LESSGREAT)){let l=e.advance();t.push({type:"Literal",value:"<>"}),r=l.end}else if(n>0&&e.check(E.CLOBBER)){let l=e.advance();t.push({type:"Literal",value:">|"}),r=l.end}else if(n>0&&e.check(E.TLESS)){let l=e.advance();t.push({type:"Literal",value:"<<<"}),r=l.end}else if(n>0&&e.check(E.AMP)){let l=e.advance();t.push({type:"Literal",value:"&"}),r=l.end}else if(n>0&&e.check(E.LBRACE)){let l=e.advance();t.push({type:"Literal",value:"{"}),r=l.end}else if(n>0&&e.check(E.RBRACE)){let l=e.advance();t.push({type:"Literal",value:"}"}),r=l.end}else break}return t.length===0&&e.error("Expected regex pattern after =~"),{type:"Word",parts:t}}var sw,iw,dm=I(()=>{"use strict";Tn();sw=["-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"],iw=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function uw(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if("@*+?!".includes(s)&&r+1<e.length&&e[r+1]==="("){r++,n++,r++;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function fw(e,t,n){let r=n+1,s=t[r];if("@*#?$!-0123456789".includes(s))return{part:q.parameterExpansion(s),endIndex:r+1};let i="";for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)i+=t[r],r++;return{part:q.parameterExpansion(i),endIndex:r}}function hw(e,t,n,r=!1){let s=n+2,i=!1;t[s]==="!"&&(i=!0,s++);let o=!1;t[s]==="#"&&!/[}:#%/^,]/.test(t[s+1]||"}")&&(o=!0,s++);let a="",l=t[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(t[s+1]||""))a=l,s++;else for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)a+=t[s],s++;if(t[s]==="["){let u=bl(e,t,s,"[","]");if(a+=t.slice(s,u+1),s=u+1,t[s]==="["){let f=1,h=s;for(;h<t.length&&f>0;)t[h]==="{"?f++:t[h]==="}"&&f--,f>0&&h++;let p=t.slice(n+2,h);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:p}),endIndex:h+1}}}if(a===""&&!i&&!o&&t[s]!=="}"){let u=1,f=s;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;if(u>0)throw new lt("unexpected EOF while looking for matching '}'",0,0);let h=t.slice(n+2,f);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:h}),endIndex:f+1}}let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pl(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(t[s]==="*"||t[s]==="@"&&!/[QPaAEKkuUL]/.test(t[s+1]||"")){let f=t[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pl(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(o)if(t[s]===":")for(c={type:"LengthSliceError"};s<t.length&&t[s]!=="}";)s++;else t[s]!=="}"&&/[-+=?]/.test(t[s])?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):t[s]==="/"?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<t.length&&t[s]!=="}"){let u=Pl(e,t,s,a,r);c=u.operation,s=u.endIndex}if(s<t.length&&t[s]!=="}"){let u=t[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<t.length&&t[f]!=="}";)f++;let h=t.slice(n,f+1);e.error(`\${${h.slice(2,-1)}}: bad substitution`)}}for(;s<t.length&&t[s]!=="}";)s++;if(s>=t.length)throw new lt("unexpected EOF while looking for matching '}'",0,0);return{part:q.parameterExpansion(a,c),endIndex:s+1}}function Pl(e,t,n,r,s=!1){let i=n,o=t[i],a=t[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let y=er(e,t,i),w=t.slice(i,y),b=Pn(e,w,!1,!1,!0,!1,s,!1,!1,!0),x=q.word(b.length>0?b:[q.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:x,checkEmpty:!0},endIndex:y};if(l==="=")return{operation:{type:"AssignDefault",word:x,checkEmpty:!0},endIndex:y};if(l==="?")return{operation:{type:"ErrorIfUnset",word:x,checkEmpty:!0},endIndex:y};if(l==="+")return{operation:{type:"UseAlternative",word:x,checkEmpty:!0},endIndex:y}}i++;let c=er(e,t,i),u=t.slice(i,c),f=-1,h=0,p=0;for(let g=0;g<u.length;g++){let y=u[g];if(y==="("||y==="[")h++;else if(y===")"||y==="]")h--;else if(y==="?"&&h===0)p++;else if(y===":"&&h===0)if(p>0)p--;else{f=g;break}}let m=f>=0?u.slice(0,f):u,d=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:xl(e,m),length:d!==null?xl(e,d):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=er(e,t,i),c=t.slice(i,l),u=Pn(e,c,!1,!1,!0,!1,s,!1,!1,!0),f=q.word(u.length>0?u:[q.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=er(e,t,i),f=t.slice(i,u),h=Pn(e,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:q.word(h.length>0?h:[q.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;t[i]==="#"?(c="start",i++):t[i]==="%"&&(c="end",i++);let u;c!==null&&(t[i]==="/"||t[i]==="}")?u=i:u=nm(e,t,i);let f=t.slice(i,u),h=Pn(e,f,!1,!1,!1),p=q.word(h.length>0?h:[q.literal("")]),m=null,d=u;if(t[u]==="/"){let g=u+1,y=er(e,t,g),w=t.slice(g,y),b=Pn(e,w,!1,!1,!1);m=q.word(b.length>0?b:[q.literal("")]),d=y}return{operation:{type:"PatternReplacement",pattern:p,replacement:m,all:l,anchor:c},endIndex:d}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=er(e,t,i),f=t.slice(i,u),h=f?q.word([q.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:h},endIndex:u}}return o==="@"&&/[QPaAEKkuUL]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function Dl(e,t,n,r=!1){let s=n+1;if(s>=t.length)return{part:q.literal("$"),endIndex:s};let i=t[s];if(i==="("&&t[s+1]==="(")return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(i==="["){let o=1,a=s+1;for(;a<t.length&&o>0;)t[a]==="["?o++:t[a]==="]"&&o--,o>0&&a++;if(o===0){let l=t.slice(s+1,a),c=Ae(e,l);return{part:q.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?e.parseCommandSubstitution(t,n):i==="{"?hw(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?fw(e,t,n):{part:q.literal("$"),endIndex:s}}function mm(e,t){let n=[],r=0,s="",i=()=>{s&&(n.push(q.literal(s)),s="")};for(;r<t.length;){let o=t[r];if(o==="\\"&&r+1<t.length){let a=t[r+1];if(a==="$"||a==="`"||a==='"'||a==="\\"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=Dl(e,t,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=e.parseBacktickSubstitution(t,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function pw(e,t,n){let r=[],s=n,i="",o=()=>{i&&(r.push(q.literal(i)),i="")};for(;s<t.length&&t[s]!=='"';){let a=t[s];if(a==="\\"&&s+1<t.length){let l=t[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=Dl(e,t,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:q.doubleQuoted(r),endIndex:s}}function Pn(e,t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1){if(r)return[q.singleQuoted(t)];if(n){let m=mm(e,t);return[q.doubleQuoted(m)]}if(t.length>=2&&t[0]==='"'&&t[t.length-1]==='"'){let m=t.slice(1,-1),d=!1;for(let g=0;g<m.length;g++){if(m[g]==='"'){d=!0;break}m[g]==="\\"&&g+1<m.length&&g++}if(!d){let g=mm(e,m);return[q.doubleQuoted(g)]}}let u=[],f=0,h="",p=()=>{h&&(u.push(q.literal(h)),h="")};for(;f<t.length;){let m=t[f];if(m==="\\"&&f+1<t.length){let d=t[f+1];if(l){p(),u.push(q.escaped(d)),f+=2;continue}let g=i?d==="$"||d==="`"||d===`
762
+ `,s+=2;break;case"t":r+=" ",s+=2;break;case"r":r+="\r",s+=2;break;case"\\":r+="\\",s+=2;break;case"'":r+="'",s+=2;break;case'"':r+='"',s+=2;break;case"a":r+="\x07",s+=2;break;case"b":r+="\b",s+=2;break;case"e":case"E":r+="\x1B",s+=2;break;case"f":r+="\f",s+=2;break;case"v":r+="\v",s+=2;break;case"x":{let a=[],l=s;for(;l+1<t.length&&t[l]==="\\"&&t[l+1]==="x";){let c=t.slice(l+2,l+4),u=parseInt(c,16);if(!Number.isNaN(u)&&c.length>0)a.push(u),l+=2+c.length;else break}a.length>0?(r+=Q5(a),s=l):(r+="\\x",s+=2);break}case"u":{let a=t.slice(s+2,s+6),l=parseInt(a,16);Number.isNaN(l)?(r+="\\u",s+=2):(r+=String.fromCharCode(l),s+=6);break}case"c":{if(s+2<t.length){let l=t[s+2].charCodeAt(0)&31;r+=String.fromCharCode(l),s+=3}else r+="\\c",s+=2;break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":{let a="",l=s+1;for(;l<t.length&&l<s+4&&/[0-7]/.test(t[l]);)a+=t[l],l++;let c=parseInt(a,8);r+=String.fromCharCode(c),s=l;break}default:r+=i,s++}else r+=i,s++}return s<t.length&&t[s]==="'"&&s++,{part:q.literal(r),endIndex:s}}function xl(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ae(e,n)}function em(e){let t=[],n="",r=0;for(let s=0;s<e.length;s++){let i=e[s];i==="{"?(r++,n+=i):i==="}"?(r--,n+=i):i===","&&r===0?(t.push(n),n=""):n+=i}return t.push(n),t}function im(e,t,n,r){let s=bl(e,t,n,"{","}");if(s===-1)return null;let i=t.slice(n+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(",")&&r?{part:{type:"BraceExpansion",items:em(i).map(u=>({type:"Word",word:q.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:em(i).map(u=>({type:"Word",word:q.word([q.literal(u)])}))},endIndex:s+1}:null}function El(e,t){let n="";for(let r of t.parts)switch(r.type){case"Literal":n+=r.value;break;case"SingleQuoted":n+=`'${r.value}'`;break;case"Escaped":n+=r.value;break;case"DoubleQuoted":n+='"';for(let s of r.parts)s.type==="Literal"||s.type==="Escaped"?n+=s.value:s.type==="ParameterExpansion"&&(n+=`\${${s.parameter}}`);n+='"';break;case"ParameterExpansion":n+=`\${${r.parameter}}`;break;case"Glob":n+=r.pattern;break;case"TildeExpansion":n+="~",r.user&&(n+=r.user);break;case"BraceExpansion":{n+="{";let s=[];for(let i of r.items)if(i.type==="Range"){let o=i.startStr??String(i.start),a=i.endStr??String(i.end);i.step!==void 0?s.push(`${o}..${a}..${i.step}`):s.push(`${o}..${a}`)}else s.push(El(e,i.word));s.length===1&&r.items[0].type==="Range"?n+=s[0]:n+=s.join(","),n+="}";break}default:n+=r.type}return n}function om(e,t){return{[E.LESS]:"<",[E.GREAT]:">",[E.DGREAT]:">>",[E.LESSAND]:"<&",[E.GREATAND]:">&",[E.LESSGREAT]:"<>",[E.CLOBBER]:">|",[E.TLESS]:"<<<",[E.AND_GREAT]:"&>",[E.AND_DGREAT]:"&>>",[E.DLESS]:"<",[E.DLESSDASH]:"<"}[t]||">"}var Al=I(()=>{"use strict";Jn();pt();Tn()});function Li(e){let t=e.current(),n=t.type;if(n===E.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:F0.has(r.type)}if(n===E.FD_VARIABLE){let r=e.peek(1);return U0.has(r.type)}return M0.has(n)}function _i(e){let t=null,n;e.check(E.NUMBER)?t=Number.parseInt(e.advance().value,10):e.check(E.FD_VARIABLE)&&(n=e.advance().value);let r=e.advance(),s=om(e,r.type);if(r.type===E.DLESS||r.type===E.DLESSDASH)return X5(e,s,t,r.type===E.DLESSDASH);e.isWord()||e.error("Expected redirection target");let i=e.parseWord();return q.redirection(s,i,t,n)}function X5(e,t,n,r){e.isWord()||e.error("Expected here-document delimiter");let s=e.advance(),i=s.value,o=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let a=q.redirection(r?"<<-":"<<",q.hereDoc(i,q.word([]),r,o),n);return e.addPendingHeredoc(a,i,r,o),a}function lm(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(E.ASSIGNMENT_WORD)||Li(e);)e.checkIterationLimit(),e.check(E.ASSIGNMENT_WORD)?n.push(Y5(e)):i.push(_i(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(E.DBRACK_START)||e.check(E.DPAREN_START))){let a=e.advance();r=q.word([q.literal(a.value)])}for(;(!e.isStatementEnd()||e.check(E.RBRACE))&&!e.check(E.PIPE,E.PIPE_AMP);)if(e.checkIterationLimit(),Li(e))i.push(_i(e));else if(e.check(E.RBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(E.LBRACE)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.check(E.DBRACK_END)){let a=e.advance();s.push(e.parseWordFromString(a.value,!1,!1))}else if(e.isWord())s.push(e.parseWord());else if(e.check(E.ASSIGNMENT_WORD)){let a=e.advance(),l=a.value,c=l.endsWith("="),u=l.endsWith("=(");if((c||u)&&(u||e.check(E.LPAREN))){let f=u?l.slice(0,-2):l.slice(0,-1);u||e.expect(E.LPAREN);let h=Sl(e);e.expect(E.RPAREN);let p=h.map(d=>El(e,d)),m=`${f}=(${p.join(" ")})`;s.push(e.parseWordFromString(m,!1,!1))}else s.push(e.parseWordFromString(l,a.quoted,a.singleQuoted))}else if(e.check(E.LPAREN))e.error("syntax error near unexpected token `('");else break;let o=q.simpleCommand(r,s,n,i);return o.line=t,o}function Y5(e){let t=e.expect(E.ASSIGNMENT_WORD),n=t.value,r=n.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);r||e.error(`Invalid assignment: ${n}`);let s=r[0],i,o=s.length;if(n[o]==="["){let f=0,h=o+1;for(;o<n.length;o++)if(n[o]==="[")f++;else if(n[o]==="]"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${n}`),i=n.slice(h,o),o++}let a=n[o]==="+";a&&o++,n[o]!=="="&&e.error(`Invalid assignment: ${n}`),o++;let l=n.slice(o);if(l==="("){let f=Sl(e);e.expect(E.RPAREN);let h=i!==void 0?`${s}[${i}]`:s;return q.assignment(h,null,a,f)}if(l===""&&e.check(E.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let h=Sl(e);e.expect(E.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return q.assignment(p,null,a,h)}}let c=l?e.parseWordFromString(l,t.quoted,t.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return q.assignment(u,c,a,null)}function Sl(e){let t=[];for(e.skipNewlines();!e.check(E.RPAREN,E.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):J5.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var J5,cm=I(()=>{"use strict";Jn();Tn();Yn();Al();J5=new Set([E.AMP,E.PIPE,E.PIPE_AMP,E.SEMICOLON,E.AND_AND,E.OR_OR,E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND])});function Cl(e,t){e.expect(E.IF);let n=[],r=e.parseCompoundList();e.expect(E.THEN);let s=e.parseCompoundList();if(s.length===0){let a=e.check(E.FI)?"fi":e.check(E.ELSE)?"else":e.check(E.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${a}'`)}for(n.push({condition:r,body:s});e.check(E.ELIF);){e.advance();let a=e.parseCompoundList();e.expect(E.THEN);let l=e.parseCompoundList();if(l.length===0){let c=e.check(E.FI)?"fi":e.check(E.ELSE)?"else":e.check(E.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${c}'`)}n.push({condition:a,body:l})}let i=null;e.check(E.ELSE)&&(e.advance(),i=e.parseCompoundList(),i.length===0&&e.error("syntax error near unexpected token `fi'")),e.expect(E.FI);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.ifNode(n,i,o)}function Nl(e,t){let n=e.expect(E.FOR);if(e.check(E.DPAREN_START))return tw(e,t,n.line);e.isWord()||e.error("Expected variable name in for loop");let s=e.advance().value,i=null;if(e.skipNewlines(),e.check(E.IN))for(e.advance(),i=[];!e.check(E.SEMICOLON,E.NEWLINE,E.DO,E.EOF)&&e.isWord();)i.push(e.parseWord());e.check(E.SEMICOLON)&&e.advance(),e.skipNewlines(),e.expect(E.DO);let o=e.parseCompoundList();e.expect(E.DONE);let a=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.forNode(s,i,o,a)}function tw(e,t,n){e.expect(E.DPAREN_START);let r=null,s=null,i=null,o=["","",""],a=0,l=0;for(;!e.check(E.DPAREN_END,E.EOF);){let f=e.advance();if(f.type===E.SEMICOLON&&l===0){if(a++,a>2)break}else f.value==="("&&l++,f.value===")"&&l--,o[a]+=f.value}e.expect(E.DPAREN_END),o[0].trim()&&(r=Ae(e,o[0].trim())),o[1].trim()&&(s=Ae(e,o[1].trim())),o[2].trim()&&(i=Ae(e,o[2].trim())),e.skipNewlines(),e.check(E.SEMICOLON)&&e.advance(),e.skipNewlines();let c;e.check(E.LBRACE)?(e.advance(),c=e.parseCompoundList(),e.expect(E.RBRACE)):(e.expect(E.DO),c=e.parseCompoundList(),e.expect(E.DONE));let u=t?.skipRedirections?[]:e.parseOptionalRedirections();return{type:"CStyleFor",init:r,condition:s,update:i,body:c,redirections:u,line:n}}function kl(e,t){e.expect(E.WHILE);let n=e.parseCompoundList();e.expect(E.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(E.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.whileNode(n,r,s)}function vl(e,t){e.expect(E.UNTIL);let n=e.parseCompoundList();e.expect(E.DO);let r=e.parseCompoundList();r.length===0&&e.error("syntax error near unexpected token `done'"),e.expect(E.DONE);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.untilNode(n,r,s)}function Il(e,t){e.expect(E.CASE),e.isWord()||e.error("Expected word after 'case'");let n=e.parseWord();e.skipNewlines(),e.expect(E.IN),e.skipNewlines();let r=[];for(;!e.check(E.ESAC,E.EOF);){e.checkIterationLimit();let i=e.getPos(),o=nw(e);if(o&&r.push(o),e.skipNewlines(),e.getPos()===i&&!o)break}e.expect(E.ESAC);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.caseNode(n,r,s)}function nw(e){e.check(E.LPAREN)&&e.advance();let t=[];for(;e.isWord()&&(t.push(e.parseWord()),e.check(E.PIPE));)e.advance();if(t.length===0)return null;e.expect(E.RPAREN),e.skipNewlines();let n=[];for(;!e.check(E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND,E.ESAC,E.EOF);){e.checkIterationLimit(),e.isWord()&&e.peek(1).type===E.RPAREN&&e.error("syntax error near unexpected token `)'"),e.check(E.LPAREN)&&e.peek(1).type===E.WORD&&e.error(`syntax error near unexpected token \`${e.peek(1).value}'`);let s=e.getPos(),i=e.parseStatement();if(i&&n.push(i),e.skipSeparators(!1),e.getPos()===s&&!i)break}let r=";;";return e.check(E.DSEMI)?(e.advance(),r=";;"):e.check(E.SEMI_AND)?(e.advance(),r=";&"):e.check(E.SEMI_SEMI_AND)&&(e.advance(),r=";;&"),q.caseItem(t,n,r)}function Ol(e,t){e.expect(E.LPAREN);let n=e.parseCompoundList();e.expect(E.RPAREN);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.subshell(n,r)}function Rl(e,t){e.expect(E.LBRACE);let n=e.parseCompoundList();e.expect(E.RBRACE);let r=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.group(n,r)}var um=I(()=>{"use strict";Jn();pt();Tn()});function fm(e){return e.isWord()||e.check(E.LBRACE)||e.check(E.RBRACE)||e.check(E.ASSIGNMENT_WORD)}function hm(e){if(e.check(E.BANG)&&e.peek(1).type===E.LPAREN){e.advance(),e.advance();let t=1,n="!(";for(;t>0&&!e.check(E.EOF);)if(e.check(E.LPAREN))t++,n+="(",e.advance();else if(e.check(E.RPAREN))t--,t>0&&(n+=")"),e.advance();else if(e.isWord())n+=e.advance().value;else if(e.check(E.PIPE))n+="|",e.advance();else break;return n+=")",e.parseWordFromString(n,!1,!1,!1,!1,!0)}return e.parseWordNoBraceExpansion()}function Tl(e){return e.skipNewlines(),ow(e)}function ow(e){let t=pm(e);for(e.skipNewlines();e.check(E.OR_OR);){e.advance(),e.skipNewlines();let n=pm(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function pm(e){let t=$l(e);for(e.skipNewlines();e.check(E.AND_AND);){e.advance(),e.skipNewlines();let n=$l(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function $l(e){return e.skipNewlines(),e.check(E.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:$l(e)}):aw(e)}function aw(e){if(e.check(E.LPAREN)){e.advance();let t=Tl(e);return e.expect(E.RPAREN),{type:"CondGroup",expression:t}}if(fm(e)){let t=e.current(),n=t.value;if(sw.includes(n)&&!t.quoted){if(e.advance(),e.check(E.DBRACK_END)&&e.error(`Expected operand after ${n}`),fm(e)){let i=e.parseWordNoBraceExpansion();return{type:"CondUnary",operator:n,operand:i}}let s=e.current();e.error(`unexpected argument \`${s.value}' to conditional unary operator`)}let r=e.parseWordNoBraceExpansion();if(e.isWord()&&iw.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=lw(e):s==="=="||s==="!="?i=hm(e):i=e.parseWordNoBraceExpansion(),{type:"CondBinary",operator:s,left:r,right:i}}if(e.check(E.LESS)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:"<",left:r,right:s}}if(e.check(E.GREAT)){e.advance();let s=e.parseWordNoBraceExpansion();return{type:"CondBinary",operator:">",left:r,right:s}}if(e.isWord()&&e.current().value==="="){e.advance();let s=hm(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function lw(e){let t=[],n=0,r=-1,s=e.getInput(),i=()=>e.check(E.DBRACK_END)||e.check(E.AND_AND)||e.check(E.OR_OR)||e.check(E.NEWLINE)||e.check(E.EOF);for(;!i();){let o=e.current(),a=r>=0&&o.start>r;if(n===0&&a)break;if(n>0&&a){let l=s.slice(r,o.start);t.push({type:"Literal",value:l})}if(e.isWord()||e.check(E.ASSIGNMENT_WORD)){let l=e.parseWordForRegex();t.push(...l.parts),r=e.peek(-1).end}else if(e.check(E.LPAREN)){let l=e.advance();t.push({type:"Literal",value:"("}),n++,r=l.end}else if(e.check(E.DPAREN_START)){let l=e.advance();t.push({type:"Literal",value:"(("}),n+=2,r=l.end}else if(e.check(E.DPAREN_END))if(n>=2){let l=e.advance();t.push({type:"Literal",value:"))"}),n-=2,r=l.end}else{if(n===1)break;break}else if(e.check(E.RPAREN))if(n>0){let l=e.advance();t.push({type:"Literal",value:")"}),n--,r=l.end}else break;else if(e.check(E.PIPE)){let l=e.advance();t.push({type:"Literal",value:"|"}),r=l.end}else if(e.check(E.SEMICOLON))if(n>0){let l=e.advance();t.push({type:"Literal",value:";"}),r=l.end}else break;else if(n>0&&e.check(E.LESS)){let l=e.advance();t.push({type:"Literal",value:"<"}),r=l.end}else if(n>0&&e.check(E.GREAT)){let l=e.advance();t.push({type:"Literal",value:">"}),r=l.end}else if(n>0&&e.check(E.DGREAT)){let l=e.advance();t.push({type:"Literal",value:">>"}),r=l.end}else if(n>0&&e.check(E.DLESS)){let l=e.advance();t.push({type:"Literal",value:"<<"}),r=l.end}else if(n>0&&e.check(E.LESSAND)){let l=e.advance();t.push({type:"Literal",value:"<&"}),r=l.end}else if(n>0&&e.check(E.GREATAND)){let l=e.advance();t.push({type:"Literal",value:">&"}),r=l.end}else if(n>0&&e.check(E.LESSGREAT)){let l=e.advance();t.push({type:"Literal",value:"<>"}),r=l.end}else if(n>0&&e.check(E.CLOBBER)){let l=e.advance();t.push({type:"Literal",value:">|"}),r=l.end}else if(n>0&&e.check(E.TLESS)){let l=e.advance();t.push({type:"Literal",value:"<<<"}),r=l.end}else if(n>0&&e.check(E.AMP)){let l=e.advance();t.push({type:"Literal",value:"&"}),r=l.end}else if(n>0&&e.check(E.LBRACE)){let l=e.advance();t.push({type:"Literal",value:"{"}),r=l.end}else if(n>0&&e.check(E.RBRACE)){let l=e.advance();t.push({type:"Literal",value:"}"}),r=l.end}else break}return t.length===0&&e.error("Expected regex pattern after =~"),{type:"Word",parts:t}}var sw,iw,dm=I(()=>{"use strict";Tn();sw=["-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"],iw=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function uw(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if("@*+?!".includes(s)&&r+1<e.length&&e[r+1]==="("){r++,n++,r++;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function fw(e,t,n){let r=n+1,s=t[r];if("@*#?$!-0123456789".includes(s))return{part:q.parameterExpansion(s),endIndex:r+1};let i="";for(;r<t.length&&/[a-zA-Z0-9_]/.test(t[r]);)i+=t[r],r++;return{part:q.parameterExpansion(i),endIndex:r}}function hw(e,t,n,r=!1){let s=n+2,i=!1;t[s]==="!"&&(i=!0,s++);let o=!1;t[s]==="#"&&!/[}:#%/^,]/.test(t[s+1]||"}")&&(o=!0,s++);let a="",l=t[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(t[s+1]||""))a=l,s++;else for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)a+=t[s],s++;if(t[s]==="["){let u=bl(e,t,s,"[","]");if(a+=t.slice(s,u+1),s=u+1,t[s]==="["){let f=1,h=s;for(;h<t.length&&f>0;)t[h]==="{"?f++:t[h]==="}"&&f--,f>0&&h++;let p=t.slice(n+2,h);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:p}),endIndex:h+1}}}if(a===""&&!i&&!o&&t[s]!=="}"){let u=1,f=s;for(;f<t.length&&u>0;)t[f]==="{"?u++:t[f]==="}"&&u--,u>0&&f++;if(u>0)throw new lt("unexpected EOF while looking for matching '}'",0,0);let h=t.slice(n+2,f);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:h}),endIndex:f+1}}let c=null;if(i){let u=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pl(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},a="";else if(t[s]==="*"||t[s]==="@"&&!/[QPaAEKkuUL]/.test(t[s+1]||"")){let f=t[s];s++,c={type:"VarNamePrefix",prefix:a,star:f==="*"},a=""}else if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Pl(e,t,s,a,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(o)if(t[s]===":")for(c={type:"LengthSliceError"};s<t.length&&t[s]!=="}";)s++;else t[s]!=="}"&&/[-+=?]/.test(t[s])?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):t[s]==="/"?e.error(`\${#${a}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<t.length&&t[s]!=="}"){let u=Pl(e,t,s,a,r);c=u.operation,s=u.endIndex}if(s<t.length&&t[s]!=="}"){let u=t[s];if(!/[:\-+=?#%/^,@[]/.test(u)){let f=s;for(;f<t.length&&t[f]!=="}";)f++;let h=t.slice(n,f+1);e.error(`\${${h.slice(2,-1)}}: bad substitution`)}}for(;s<t.length&&t[s]!=="}";)s++;if(s>=t.length)throw new lt("unexpected EOF while looking for matching '}'",0,0);return{part:q.parameterExpansion(a,c),endIndex:s+1}}function Pl(e,t,n,r,s=!1){let i=n,o=t[i],a=t[i+1]||"";if(o===":"){let l=a;if("-=?+".includes(l)){i+=2;let y=er(e,t,i),w=t.slice(i,y),b=Pn(e,w,!1,!1,!0,!1,s,!1,!1,!0),x=q.word(b.length>0?b:[q.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:x,checkEmpty:!0},endIndex:y};if(l==="=")return{operation:{type:"AssignDefault",word:x,checkEmpty:!0},endIndex:y};if(l==="?")return{operation:{type:"ErrorIfUnset",word:x,checkEmpty:!0},endIndex:y};if(l==="+")return{operation:{type:"UseAlternative",word:x,checkEmpty:!0},endIndex:y}}i++;let c=er(e,t,i),u=t.slice(i,c),f=-1,h=0,p=0;for(let g=0;g<u.length;g++){let y=u[g];if(y==="("||y==="[")h++;else if(y===")"||y==="]")h--;else if(y==="?"&&h===0)p++;else if(y===":"&&h===0)if(p>0)p--;else{f=g;break}}let m=f>=0?u.slice(0,f):u,d=f>=0?u.slice(f+1):null;return{operation:{type:"Substring",offset:xl(e,m),length:d!==null?xl(e,d):null},endIndex:c}}if("-=?+".includes(o)){i++;let l=er(e,t,i),c=t.slice(i,l),u=Pn(e,c,!1,!1,!0,!1,s,!1,!1,!0),f=q.word(u.length>0?u:[q.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=er(e,t,i),f=t.slice(i,u),h=Pn(e,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:q.word(h.length>0?h:[q.literal("")]),side:c,greedy:l},endIndex:u}}if(o==="/"){let l=a==="/";i+=l?2:1;let c=null;t[i]==="#"?(c="start",i++):t[i]==="%"&&(c="end",i++);let u;c!==null&&(t[i]==="/"||t[i]==="}")?u=i:u=nm(e,t,i);let f=t.slice(i,u),h=Pn(e,f,!1,!1,!1),p=q.word(h.length>0?h:[q.literal("")]),m=null,d=u;if(t[u]==="/"){let g=u+1,y=er(e,t,g),w=t.slice(g,y),b=Pn(e,w,!1,!1,!1);m=q.word(b.length>0?b:[q.literal("")]),d=y}return{operation:{type:"PatternReplacement",pattern:p,replacement:m,all:l,anchor:c},endIndex:d}}if(o==="^"||o===","){let l=a===o,c=o==="^"?"upper":"lower";i+=l?2:1;let u=er(e,t,i),f=t.slice(i,u),h=f?q.word([q.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:h},endIndex:u}}return o==="@"&&/[QPaAEKkuUL]/.test(a)?{operation:{type:"Transform",operator:a},endIndex:i+2}:{operation:null,endIndex:i}}function Dl(e,t,n,r=!1){let s=n+1;if(s>=t.length)return{part:q.literal("$"),endIndex:s};let i=t[s];if(i==="("&&t[s+1]==="(")return e.isDollarDparenSubshell(t,n)?e.parseCommandSubstitution(t,n):e.parseArithmeticExpansion(t,n);if(i==="["){let o=1,a=s+1;for(;a<t.length&&o>0;)t[a]==="["?o++:t[a]==="]"&&o--,o>0&&a++;if(o===0){let l=t.slice(s+1,a),c=Ae(e,l);return{part:q.arithmeticExpansion(c),endIndex:a+1}}}return i==="("?e.parseCommandSubstitution(t,n):i==="{"?hw(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?fw(e,t,n):{part:q.literal("$"),endIndex:s}}function mm(e,t){let n=[],r=0,s="",i=()=>{s&&(n.push(q.literal(s)),s="")};for(;r<t.length;){let o=t[r];if(o==="\\"&&r+1<t.length){let a=t[r+1];if(a==="$"||a==="`"||a==='"'||a==="\\"){s+=a,r+=2;continue}s+=o,r++;continue}if(o==="$"){i();let{part:a,endIndex:l}=Dl(e,t,r,!0);a&&n.push(a),r=l;continue}if(o==="`"){i();let{part:a,endIndex:l}=e.parseBacktickSubstitution(t,r,!0);n.push(a),r=l;continue}s+=o,r++}return i(),n}function pw(e,t,n){let r=[],s=n,i="",o=()=>{i&&(r.push(q.literal(i)),i="")};for(;s<t.length&&t[s]!=='"';){let a=t[s];if(a==="\\"&&s+1<t.length){let l=t[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=a,s++;continue}if(a==="$"){o();let{part:l,endIndex:c}=Dl(e,t,s,!0);l&&r.push(l),s=c;continue}if(a==="`"){o();let{part:l,endIndex:c}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=c;continue}i+=a,s++}return o(),{part:q.doubleQuoted(r),endIndex:s}}function Pn(e,t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1){if(r)return[q.singleQuoted(t)];if(n){let m=mm(e,t);return[q.doubleQuoted(m)]}if(t.length>=2&&t[0]==='"'&&t[t.length-1]==='"'){let m=t.slice(1,-1),d=!1;for(let g=0;g<m.length;g++){if(m[g]==='"'){d=!0;break}m[g]==="\\"&&g+1<m.length&&g++}if(!d){let g=mm(e,m);return[q.doubleQuoted(g)]}}let u=[],f=0,h="",p=()=>{h&&(u.push(q.literal(h)),h="")};for(;f<t.length;){let m=t[f];if(m==="\\"&&f+1<t.length){let d=t[f+1];if(l){p(),u.push(q.escaped(d)),f+=2;continue}let g=i?d==="$"||d==="`"||d===`
763
763
  `:d==="$"||d==="`"||d==='"'||d==="'"||d===`
764
764
  `||c&&d==="}",y=o?"*?[]\\".includes(d):"*?[]\\(){}.^+".includes(d);g?h+=d:y?(p(),u.push(q.escaped(d))):h+=`\\${d}`,f+=2;continue}if(m==="'"&&!o&&!i){p();let d=t.indexOf("'",f+1);if(d===-1){h+=t.slice(f);break}u.push(q.singleQuoted(t.slice(f+1,d))),f=d+1;continue}if(m==='"'&&!i){p();let{part:d,endIndex:g}=pw(e,t,f+1);u.push(d),f=g+1;continue}if(m==="$"&&t[f+1]==="'"){p();let{part:d,endIndex:g}=sm(e,t,f+2);u.push(d),f=g;continue}if(m==="$"){p();let{part:d,endIndex:g}=Dl(e,t,f);d&&u.push(d),f=g;continue}if(m==="`"){p();let{part:d,endIndex:g}=e.parseBacktickSubstitution(t,f);u.push(d),f=g;continue}if(m==="~"){let d=f>0?t[f-1]:"";if(f===0||d==="="||s&&d===":"){let y=tm(e,t,f),w=t[y];if(w===void 0||w==="/"||w===":"){p();let b=t.slice(f+1,y)||null;u.push({type:"TildeExpansion",user:b}),f=y;continue}}}if("@*+?!".includes(m)&&f+1<t.length&&t[f+1]==="("){let d=uw(t,f+1);if(d!==-1){p();let g=t.slice(f,d+1);u.push({type:"Glob",pattern:g}),f=d+1;continue}}if(m==="*"||m==="?"||m==="["){p();let{pattern:d,endIndex:g}=rm(e,t,f);u.push({type:"Glob",pattern:d}),f=g;continue}if(m==="{"&&!s&&!a){let d=im(e,t,f,Pn);if(d){p(),u.push(d.part),f=d.endIndex;continue}}h+=m,f++}return p(),u}var gm=I(()=>{"use strict";Jn();pt();Yn();Al()});function ym(e,t){let n=e.length,r=t+3,s=2,i=!1,o=!1;for(;r<n&&s>0;){let a=e[r];if(i){a==="'"&&(i=!1),r++;continue}if(o){if(a==="\\"){r+=2;continue}a==='"'&&(o=!1),r++;continue}if(a==="'"){i=!0,r++;continue}if(a==='"'){o=!0,r++;continue}if(a==="\\"){r+=2;continue}if(a==="("){s++,r++;continue}if(a===")"){if(s--,s===1){let l=r+1;return!(l<n&&e[l]===")")}if(s===0)return!1;r++;continue}if(s===1&&(a==="|"&&r+1<n&&e[r+1]==="|"||a==="&"&&r+1<n&&e[r+1]==="&"||a==="|"&&r+1<n&&e[r+1]!=="|"))return!0;r++}return!1}function wm(e,t,n,r){let s=t+2,i=1,o=s,a=!1,l=!1,c=0,u=!1,f="";for(;o<e.length&&i>0;){let d=e[o];a?d==="'"&&(a=!1):l?d==="\\"&&o+1<e.length?o++:d==='"'&&(l=!1):d==="'"?(a=!0,f=""):d==='"'?(l=!0,f=""):d==="\\"&&o+1<e.length?(o++,f=""):/[a-zA-Z_]/.test(d)?f+=d:(f==="case"?(c++,u=!1):f==="in"&&c>0?u=!0:f==="esac"&&c>0&&(c--,u=!1),f="",d==="("?o>0&&e[o-1]==="$"?i++:u||i++:d===")"?u?u=!1:i--:d===";"&&c>0&&o+1<e.length&&e[o+1]===";"&&(u=!0)),i>0&&o++}i>0&&r("unexpected EOF while looking for matching `)'");let h=e.slice(s,o),m=n().parse(h);return{part:q.commandSubstitution(m,!1),endIndex:o+1}}function bm(e,t,n,r,s){let o=t+1,a="";for(;o<e.length&&e[o]!=="`";)if(e[o]==="\\"){let u=e[o+1];u==="$"||u==="`"||u==="\\"||u===`
765
765
  `||n&&u==='"'?(u!==`
766
- `&&(a+=u),o+=2):(a+=e[o],o++)}else a+=e[o],o++;o>=e.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(a);return{part:q.commandSubstitution(c,!0),endIndex:o+1}}var xm=I(()=>{"use strict";Jn()});function hn(e){return new ce().parse(e)}var ce,Qe=I(()=>{"use strict";Jn();pt();cm();um();dm();gm();Tn();xm();Yn();Yn();ce=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>_0)throw new lt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(t){if(t.length>ml)throw new lt(`Input too large: ${t.length} bytes exceeds limit of ${ml}`,1,1);this._input=t;let n=new Ti(t);if(this.tokens=n.tokenize(),this.tokens.length>gl)throw new lt(`Too many tokens: ${this.tokens.length} exceeds limit of ${gl}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(t=0){return this.tokens[this.pos+t]||this.tokens[this.tokens.length-1]}advance(){let t=this.current();return this.pos<this.tokens.length-1&&this.pos++,t}getPos(){return this.pos}check(t,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===t||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(t,n){if(this.check(t))return this.advance();let r=this.current();throw new lt(n||`Expected ${t}, got ${r.type}`,r.line,r.column,r)}error(t){let n=this.current();throw new lt(t,n.line,n.column,n)}skipNewlines(){for(;this.check(E.NEWLINE,E.COMMENT);)this.check(E.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(E.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(E.SEMICOLON,E.COMMENT)){this.advance();continue}if(t&&this.check(E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,n,r,s){this.pendingHeredocs.push({redirect:t,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(E.HEREDOC_CONTENT)){let n=this.advance(),r;t.quoted?r=q.word([q.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),t.redirect.target=q.hereDoc(t.delimiter,r,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(E.EOF,E.NEWLINE,E.SEMICOLON,E.AMP,E.AND_AND,E.OR_OR,E.RPAREN,E.RBRACE,E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===E.WORD||t===E.NAME||t===E.NUMBER||t===E.ASSIGNMENT_WORD||t===E.IF||t===E.FOR||t===E.WHILE||t===E.UNTIL||t===E.CASE||t===E.LPAREN||t===E.LBRACE||t===E.DPAREN_START||t===E.DBRACK_START||t===E.FUNCTION||t===E.BANG||t===E.TIME||t===E.IN||t===E.LESS||t===E.GREAT||t===E.DLESS||t===E.DGREAT||t===E.LESSAND||t===E.GREATAND||t===E.LESSGREAT||t===E.DLESSDASH||t===E.CLOBBER||t===E.TLESS||t===E.AND_GREAT||t===E.AND_DGREAT}parseScript(){let t=[],r=0;for(this.skipNewlines();!this.check(E.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){t.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&t.push(o),this.skipSeparators(!1),this.check(E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(E.EOF)&&this.advance()}return q.script(t)}checkUnexpectedToken(){let t=this.current().type,n=this.current().value;if((t===E.DO||t===E.DONE||t===E.THEN||t===E.ELSE||t===E.ELIF||t===E.FI||t===E.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),t===E.RBRACE||t===E.RPAREN){let r=`syntax error near unexpected token \`${n}'`;return this.advance(),q.statement([q.pipeline([q.simpleCommand(null,[],[],[])])],[],!1,{message:r,token:n})}return(t===E.DSEMI||t===E.SEMI_AND||t===E.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),t===E.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`),(t===E.PIPE||t===E.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${n}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,n=[],r=[],s=!1,i=this.parsePipeline();for(n.push(i);this.check(E.AND_AND,E.OR_OR);){let l=this.advance();r.push(l.type===E.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();n.push(c)}this.check(E.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:t,a=this._input.slice(t,o);return q.statement(n,r,s,void 0,a)}parsePipeline(){let t=!1,n=!1;this.check(E.TIME)&&(this.advance(),t=!0,this.check(E.WORD,E.NAME)&&this.current().value==="-p"&&(this.advance(),n=!0));let r=0;for(;this.check(E.BANG);)this.advance(),r++;let s=r%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(E.PIPE,E.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===E.PIPE_AMP);let c=this.parseCommand();i.push(c)}return q.pipeline(i,s,t,n,o.length>0?o:void 0)}parseCommand(){return this.check(E.IF)?Cl(this):this.check(E.FOR)?Nl(this):this.check(E.WHILE)?kl(this):this.check(E.UNTIL)?vl(this):this.check(E.CASE)?Il(this):this.check(E.LPAREN)?Rl(this):this.check(E.LBRACE)?Ol(this):this.check(E.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(E.DBRACK_START)?this.parseConditionalCommand():this.check(E.FUNCTION)?this.parseFunctionDef():this.check(E.NAME,E.WORD)&&this.peek(1).type===E.LPAREN&&this.peek(2).type===E.RPAREN?this.parseFunctionDef():lm(this)}dparenClosesWithSpacedParens(){let t=1,n=1;for(;n<this.tokens.length-this.pos;){let r=this.peek(n);if(r.type===E.EOF)return!1;if(r.type===E.DPAREN_START||r.type===E.LPAREN)t++;else if(r.type===E.DPAREN_END){if(t-=2,t<=0)return!1}else if(r.type===E.RPAREN&&(t--,t===0&&this.peek(n+1).type===E.RPAREN))return!0;n++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(E.RPAREN),this.expect(E.RPAREN);let n=this.parseOptionalRedirections(),r=q.subshell(t,[]);return q.subshell([q.statement([q.pipeline([r],!1,!1,!1)])],n)}isWord(){let t=this.current().type;return t===E.WORD||t===E.NAME||t===E.NUMBER||t===E.IF||t===E.FOR||t===E.WHILE||t===E.UNTIL||t===E.CASE||t===E.FUNCTION||t===E.ELSE||t===E.ELIF||t===E.FI||t===E.THEN||t===E.DO||t===E.DONE||t===E.ESAC||t===E.IN||t===E.SELECT||t===E.TIME||t===E.COPROC||t===E.BANG}parseWord(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted)}parseWordNoBraceExpansion(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0)}parseWordForRegex(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0,!0)}parseWordFromString(t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1){let l=Pn(this,t,n,r,s,i,!1,o,a);return q.word(l)}parseCommandSubstitution(t,n){return wm(t,n,()=>new e,r=>this.error(r))}parseBacktickSubstitution(t,n,r=!1){return bm(t,n,r,()=>new e,s=>this.error(s))}isDollarDparenSubshell(t,n){return ym(t,n)}parseArithmeticExpansion(t,n){let r=n+3,s=1,i=0,o=r;for(;o<t.length-1&&s>0;)t[o]==="$"&&t[o+1]==="("?t[o+2]==="("?(s++,o+=3):(i++,o+=2):t[o]==="("&&t[o+1]==="("?(s++,o+=2):t[o]===")"&&t[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):t[o]==="("?(i++,o++):(t[o]===")"&&i>0&&i--,o++);let a=t.slice(r,o),l=this.parseArithmeticExpression(a);return{part:q.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let t=this.expect(E.DPAREN_START),n="",r=1,s=0,i=!1,o=!1;for(;r>0&&!this.check(E.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(E.RPAREN)){r--,o=!0,this.advance();continue}if(this.check(E.DPAREN_END)){r--,o=!0;continue}n+=")";continue}if(this.check(E.DPAREN_START))r++,n+="((",this.advance();else if(this.check(E.DPAREN_END))s>=2?(s-=2,n+="))",this.advance()):s===1?(s--,n+=")",i=!0,this.advance()):(r--,o=!0,r>0&&(n+="))"),this.advance());else if(this.check(E.LPAREN))s++,n+="(",this.advance();else if(this.check(E.RPAREN))s>0&&s--,n+=")",this.advance();else{let c=this.current().value,u=n.length>0?n[n.length-1]:"";n.length>0&&!n.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(n))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(n+=" "),n+=c,this.advance()}}o||this.expect(E.DPAREN_END);let a=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return q.arithmeticCommand(a,l,t.line)}parseConditionalCommand(){let t=this.expect(E.DBRACK_START),n=Tl(this);this.expect(E.DBRACK_END);let r=this.parseOptionalRedirections();return q.conditionalCommand(n,r,t.line)}parseFunctionDef(){let t;if(this.check(E.FUNCTION)){if(this.advance(),this.check(E.NAME)||this.check(E.WORD))t=this.advance().value;else{let s=this.current();throw new lt("Expected function name",s.line,s.column,s)}this.check(E.LPAREN)&&(this.advance(),this.expect(E.RPAREN))}else t=this.advance().value,t.includes("$")&&this.error(`\`${t}': not a valid identifier`),this.expect(E.LPAREN),this.expect(E.RPAREN);this.skipNewlines();let n=this.parseCompoundCommandBody({forFunctionBody:!0}),r=this.parseOptionalRedirections();return q.functionDef(t,n,r)}parseCompoundCommandBody(t){let n=t?.forFunctionBody;if(this.check(E.LBRACE))return Ol(this,{skipRedirections:n});if(this.check(E.LPAREN))return Rl(this,{skipRedirections:n});if(this.check(E.IF))return Cl(this,{skipRedirections:n});if(this.check(E.FOR))return Nl(this,{skipRedirections:n});if(this.check(E.WHILE))return kl(this,{skipRedirections:n});if(this.check(E.UNTIL))return vl(this,{skipRedirections:n});if(this.check(E.CASE))return Il(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let t=[];for(this.skipNewlines();!this.check(E.EOF,E.FI,E.ELSE,E.ELIF,E.THEN,E.DO,E.DONE,E.ESAC,E.RPAREN,E.RBRACE,E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,r=this.parseStatement();if(r&&t.push(r),this.skipSeparators(),this.pos===n&&!r)break}return t}parseOptionalRedirections(){let t=[];for(;Li(this);){this.checkIterationLimit();let n=this.pos;if(t.push(_i(this)),this.pos===n)break}return t}parseArithmeticExpression(t){return Ae(this,t)}}});function _l(e){return gw.get(e)??""}function km(e){let t=[],n="",r=0;for(;r<e.length;){let s=e[r];if(s==="["){for(n+=s,r++,r<e.length&&(e[r]==="!"||e[r]==="^")&&(n+=e[r],r++),r<e.length&&e[r]==="]"&&(n+=e[r],r++);r<e.length&&e[r]!=="]";){if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let i=e.indexOf(":]",r+2);if(i!==-1){n+=e.slice(r,i+2),r=i+2;continue}}if(e[r]==="\\"&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]==="]"&&(n+=e[r],r++)}else s===":"?(n!==""&&t.push(n),n="",r++):s==="\\"&&r+1<e.length?(n+=s+e[r+1],r+=2):(n+=s,r++)}return n!==""&&t.push(n),t}function vm(e){let t="^";for(let n=0;n<e.length;n++){let r=e[n];if(r==="*")t+="[^/]*";else if(r==="?")t+="[^/]";else if(r==="["){let s=n+1,i="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(i+="^",s++),s<e.length&&e[s]==="]"&&(i+="\\]",s++);let o=s;for(;o<e.length;){if(e[o]==="\\"&&o+1<e.length){o+=2;continue}if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let l=e.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(e[o]==="]")break;o++}let a=s;for(;s<e.length&&e[s]!=="]";){if(e[s]==="["&&s+1<e.length&&e[s+1]===":"){let l=e.indexOf(":]",s+2);if(l!==-1){let c=e.slice(s+2,l),u=_l(c);i+=u,s=l+2;continue}}if(e[s]==="\\"&&s+1<e.length){i+=`\\${e[s+1]}`,s+=2;continue}if(e[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=e[s];s++}i+="]",t+=i,n=s}else if(r==="\\"&&n+1<e.length){let s=e[n+1];/[.+^${}()|\\*?[\]]/.test(s)?t+=`\\${s}`:t+=s,n++}else/[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+="$",V(t)}function Ml(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function Fl(e){let t=[],n="",r=0,s=!1,i=0;for(;i<e.length;){let o=e[i];if(o==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=o,i++;continue}if(o==="\\"){n+=o,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}o==="("?(r++,n+=o):o===")"?(r--,n+=o):o==="|"&&r===0?(t.push(n),n=""):n+=o,i++}return t.push(n),t}var gw,Im=I(()=>{"use strict";Me();gw=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9a-fA-F"]])});var Dn,Mi=I(()=>{"use strict";xe();Me();or();Im();Dn=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(t,n,r,s){this.fs=t,this.cwd=n,typeof s=="boolean"?(this.globstar=s,this.maxOps=1e5):s?(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0,this.maxOps=s.maxGlobOperations??1e5):this.maxOps=1e5;let i=r?.get("GLOBIGNORE");i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=km(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new re(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(n=>{let r=n.split("/").pop()||n;if((this.hasGlobignore||this.globskipdots)&&(r==="."||r===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(n,s))return!1}return!0})}matchGlobignorePattern(t,n){return vm(n).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,n){let r=t.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<t.length;o++){let a=s[o];a===null?i.push(t[o]):a.length>0?i.push(...a):i.push(t[o])}return i}async expand(t){let n;if(t.includes("**")&&this.globstar&&this.isGlobstarValid(t))n=await this.expandRecursive(t);else{let r=t.replace(/\*\*+/g,"*");n=await this.expandSimple(r)}return this.filterGlobignore(n)}isGlobstarValid(t){let n=t.split("/");for(let r of n)if(r.includes("**")&&r!=="**")return!1;return!0}hasGlobChars(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandSimple(t){let n=t.startsWith("/"),r=t.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<r.length;c++)if(this.hasGlobChars(r[c])){s=c;break}if(s===-1)return[t];let i,o;if(s===0)n?(i="/",o="/"):(i=this.cwd,o="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=r.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(t,n,r){if(this.checkOpsLimit(),r.length===0)return[n];let[s,...i]=r,o=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let h=a.some(m=>m.name==="."),p=a.some(m=>m.name==="..");h||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),p||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h.name,s)){let p=t==="/"?`/${h.name}`:`${t}/${h.name}`,m;n===""?m=h.name:n==="/"?m=`/${h.name}`:m=`${n}/${h.name}`,i.length===0?l.push(Promise.resolve([m])):h.isDirectory&&l.push(this.expandSegments(p,m,i))}let f=await Promise.all(l);for(let h of f)o.push(...h)}else{this.checkOpsLimit();let a=await this.fs.readdir(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h,s)){let p=t==="/"?`/${h}`:`${t}/${h}`,m;n===""?m=h:n==="/"?m=`/${h}`:m=`${n}/${h}`,i.length===0?l.push(Promise.resolve([m])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(p)).isDirectory)return this.expandSegments(p,m,i)}catch(d){if(d instanceof re)throw d}return[]})())}let f=await Promise.all(l);for(let h of f)o.push(...h)}}catch(a){if(a instanceof re)throw a}return o}async expandRecursive(t){let n=[],r=t.indexOf("**"),s=t.slice(0,r).replace(/\/$/,"")||".",o=t.slice(r+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,n),[...new Set(n)].sort()):(await this.walkDirectory(s,o,n),n.sort())}async walkDirectoryMultiGlobstar(t,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,t);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&o.push(u)}let a=t==="."?n:`${t}/${n}`,l=await this.expandRecursive(a);r.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{this.checkOpsLimit();let o=await this.fs.readdir(s),a=[];for(let u of o){let f=t==="."?u:`${t}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&a.push(f)}catch(p){if(p instanceof re)throw p}}let l=t==="."?n:`${t}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,n,r)))}}}catch(i){if(i instanceof re)throw i}}async walkDirectory(t,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=t==="."?l.name:`${t}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.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,n,r)))}}else{this.checkOpsLimit();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 h=t==="."?f:`${t}/${f}`,p=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let m=await this.fs.stat(p);return{name:f,path:h,isDirectory:m.isDirectory}}catch(m){if(m instanceof re)throw m;return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.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,n,r)))}}}catch(i){if(i instanceof re)throw i}}matchPattern(t,n){return this.patternToRegex(n).test(t)}patternToRegex(t){let n=this.patternToRegexStr(t);return V(`^${n}$`)}patternToRegexStr(t){let n="",r=!1;for(let s=0;s<t.length;s++){if(t.slice(s,s+13)==="\0QUOTE_START\0"){r=!0,s+=12;continue}if(t.slice(s,s+11)==="\0QUOTE_END\0"){r=!1,s+=10;continue}let i=t[s];if(r){/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<t.length&&t[s+1]==="("){let o=Ml(t,s+1);if(o!==-1){let a=t.slice(s+2,o),l=Fl(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")n+=`(?:${u})`;else if(i==="*")n+=`(?:${u})*`;else if(i==="+")n+=`(?:${u})+`;else if(i==="?")n+=`(?:${u})?`;else if(i==="!")if(o<t.length-1){let h=l.map(m=>this.computePatternLength(m));if(h.every(m=>m!==null)&&h.every(m=>m===h[0])&&h[0]!==null){let m=h[0];if(m===0)n+="(?:.+)";else{let d=[];m>0&&d.push(`.{0,${m-1}}`),d.push(`.{${m+1},}`),d.push(`(?!(?:${u})).{${m}}`),n+=`(?:${d.join("|")})`}}else n+=`(?:(?!(?:${u})).)*?`}else n+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let o=s+1,a="[";o<t.length&&(t[o]==="^"||t[o]==="!")&&(a+="^",o++),o<t.length&&t[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<t.length;){if(t[l]==="\\"&&l+1<t.length){l+=2;continue}if(t[l]==="["&&l+1<t.length&&t[l+1]===":"){let u=t.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(t[l]==="]")break;l++}let c=o;for(;o<t.length&&t[o]!=="]";){if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let u=t.indexOf(":]",o+2);if(u!==-1){let f=t.slice(o+2,u),h=_l(f);a+=h,o=u+2;continue}}if(t[o]==="\\"&&o+1<t.length){a+=`\\${t[o+1]}`,o+=2;continue}if(t[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=t[o];o++}a+="]",n+=a,s=o}else if(i==="\\"&&s+1<t.length){let o=t[s+1];/[.+^${}()|\\*?[\]]/.test(o)?n+=`\\${o}`:n+=o,s++}else/[.+^${}()|]/.test(i)?n+=`\\${i}`:n+=i}return n}computePatternLength(t){let n=0,r=0,s=!1;for(;r<t.length;){if(t.slice(r,r+13)==="\0QUOTE_START\0"){s=!0,r+=13;continue}if(t.slice(r,r+11)==="\0QUOTE_END\0"){s=!1,r+=11;continue}let i=t[r];if(s){n+=1,r++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&r+1<t.length&&t[r+1]==="("){let o=Ml(t,r+1);if(o!==-1){if(i==="@"){let a=t.slice(r+2,o),c=Fl(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let o=t.indexOf("]",r+1);if(o!==-1){n+=1,r=o+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function Ul(e){for(let t=0;t<e.length;t++){if(e[t]==="\\"){t++;continue}if(e[t]==="$"){let n=e[t+1];if(n==="{"||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function yw(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function Rm(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n||n.length===0)return!1;for(let r of n)if(r.type!=="DoubleQuoted"&&r.type!=="SingleQuoted")return!1;return!0}function ys(e){let t=!1,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1;for(let l of e){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(t=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),yw(l)&&(t=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&Ul(l.pattern)&&(i=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var Fi=I(()=>{"use strict"});function Ke(e,t){let n=`${t}_`,r=[];for(let s of e.state.env.keys())if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function pn(e,t){let n=`${t}_`;for(let r of e.state.env.keys())r.startsWith(n)&&e.state.env.delete(r)}function Jt(e,t){let n=`${t}_`,r=`${t}__length`,s=[];for(let i of e.state.env.keys())if(i!==r&&i.startsWith(n)){let o=i.slice(n.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function Ui(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Wl(e){if(e.parts.length<2)return null;let t=e.parts[0],n=e.parts[1];if(t.type!=="Glob"||!t.pattern.startsWith("["))return null;let r,s=n,i=1;if(n.type==="Literal"&&n.value.startsWith("]")){let f=n.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))r=t.pattern.slice(1);else if(f===""){if(e.parts.length<3)return null;let h=e.parts[2];if(h.type!=="Literal"||!h.value.startsWith("=")&&!h.value.startsWith("+="))return null;r=t.pattern.slice(1),s=h,i=2}else return null}else if(t.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(e.parts.length<3)return null;let f=e.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(n.type==="SingleQuoted")r=n.value;else{r="";for(let h of n.parts)(h.type==="Literal"||h.type==="Escaped")&&(r+=h.value)}s=f,i=2}else if(t.pattern.endsWith("]")){if(n.type!=="Literal"||!n.value.startsWith("=")&&!n.value.startsWith("+="))return null;r=t.pattern.slice(1,-1)}else return null;r=Ui(r);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<e.parts.length;f++){let h=e.parts[f];h.type==="BraceExpansion"?l.push({type:"Literal",value:ww(h)}):l.push(h)}return{key:r,valueParts:l,append:a}}function ww(e){return`{${e.items.map(n=>{if(n.type==="Range"){let r=n.startStr??String(n.start),s=n.endStr??String(n.end),i=`${r}..${s}`;return n.step&&(i+=`..${n.step}`),i}return $r(n.word)}).join(",")}}`}function $r(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value;break;case"Glob":t+=n.pattern;break;case"SingleQuoted":t+=n.value;break;case"DoubleQuoted":for(let r of n.parts)(r.type==="Literal"||r.type==="Escaped")&&(t+=r.value);break;case"Escaped":t+=n.value;break;case"BraceExpansion":t+="{",t+=n.items.map(r=>r.type==="Range"?`${r.startStr}..${r.endStr}${r.step?`..${r.step}`:""}`:$r(r.word)).join(","),t+="}";break;case"TildeExpansion":t+="~",n.user&&(t+=n.user);break}return t}var Zt=I(()=>{"use strict"});function tt(e){return e.get("IFS")??`
766
+ `&&(a+=u),o+=2):(a+=e[o],o++)}else a+=e[o],o++;o>=e.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(a);return{part:q.commandSubstitution(c,!0),endIndex:o+1}}var xm=I(()=>{"use strict";Jn()});function hn(e){return new ce().parse(e)}var ce,Qe=I(()=>{"use strict";Jn();pt();cm();um();dm();gm();Tn();xm();Yn();Yn();ce=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>_0)throw new lt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}parse(t){if(t.length>ml)throw new lt(`Input too large: ${t.length} bytes exceeds limit of ${ml}`,1,1);this._input=t;let n=new Ti(t);if(this.tokens=n.tokenize(),this.tokens.length>gl)throw new lt(`Too many tokens: ${this.tokens.length} exceeds limit of ${gl}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(t=0){return this.tokens[this.pos+t]||this.tokens[this.tokens.length-1]}advance(){let t=this.current();return this.pos<this.tokens.length-1&&this.pos++,t}getPos(){return this.pos}check(t,n,r,s,...i){let o=this.tokens[this.pos]?.type;return o===t||n!==void 0&&o===n||r!==void 0&&o===r||s!==void 0&&o===s?!0:i.length>0?i.includes(o):!1}expect(t,n){if(this.check(t))return this.advance();let r=this.current();throw new lt(n||`Expected ${t}, got ${r.type}`,r.line,r.column,r)}error(t){let n=this.current();throw new lt(t,n.line,n.column,n)}skipNewlines(){for(;this.check(E.NEWLINE,E.COMMENT);)this.check(E.NEWLINE)?(this.advance(),this.processHeredocs()):this.advance()}skipSeparators(t=!0){for(;;){if(this.check(E.NEWLINE)){this.advance(),this.processHeredocs();continue}if(this.check(E.SEMICOLON,E.COMMENT)){this.advance();continue}if(t&&this.check(E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)){this.advance();continue}break}}addPendingHeredoc(t,n,r,s){this.pendingHeredocs.push({redirect:t,delimiter:n,stripTabs:r,quoted:s})}processHeredocs(){for(let t of this.pendingHeredocs)if(this.check(E.HEREDOC_CONTENT)){let n=this.advance(),r;t.quoted?r=q.word([q.literal(n.value)]):r=this.parseWordFromString(n.value,!1,!1,!1,!0),t.redirect.target=q.hereDoc(t.delimiter,r,t.stripTabs,t.quoted)}this.pendingHeredocs=[]}isStatementEnd(){return this.check(E.EOF,E.NEWLINE,E.SEMICOLON,E.AMP,E.AND_AND,E.OR_OR,E.RPAREN,E.RBRACE,E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)}isCommandStart(){let t=this.current().type;return t===E.WORD||t===E.NAME||t===E.NUMBER||t===E.ASSIGNMENT_WORD||t===E.IF||t===E.FOR||t===E.WHILE||t===E.UNTIL||t===E.CASE||t===E.LPAREN||t===E.LBRACE||t===E.DPAREN_START||t===E.DBRACK_START||t===E.FUNCTION||t===E.BANG||t===E.TIME||t===E.IN||t===E.LESS||t===E.GREAT||t===E.DLESS||t===E.DGREAT||t===E.LESSAND||t===E.GREATAND||t===E.LESSGREAT||t===E.DLESSDASH||t===E.CLOBBER||t===E.TLESS||t===E.AND_GREAT||t===E.AND_DGREAT}parseScript(){let t=[],r=0;for(this.skipNewlines();!this.check(E.EOF);){r++,r>1e4&&this.error("Parser stuck: too many iterations (>10000)");let s=this.checkUnexpectedToken();if(s){t.push(s),this.skipSeparators(!1);continue}let i=this.pos,o=this.parseStatement();o&&t.push(o),this.skipSeparators(!1),this.check(E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${this.current().value}'`),this.pos===i&&!this.check(E.EOF)&&this.advance()}return q.script(t)}checkUnexpectedToken(){let t=this.current().type,n=this.current().value;if((t===E.DO||t===E.DONE||t===E.THEN||t===E.ELSE||t===E.ELIF||t===E.FI||t===E.ESAC)&&this.error(`syntax error near unexpected token \`${n}'`),t===E.RBRACE||t===E.RPAREN){let r=`syntax error near unexpected token \`${n}'`;return this.advance(),q.statement([q.pipeline([q.simpleCommand(null,[],[],[])])],[],!1,{message:r,token:n})}return(t===E.DSEMI||t===E.SEMI_AND||t===E.SEMI_SEMI_AND)&&this.error(`syntax error near unexpected token \`${n}'`),t===E.SEMICOLON&&this.error(`syntax error near unexpected token \`${n}'`),(t===E.PIPE||t===E.PIPE_AMP)&&this.error(`syntax error near unexpected token \`${n}'`),null}parseStatement(){if(this.skipNewlines(),!this.isCommandStart())return null;let t=this.current().start,n=[],r=[],s=!1,i=this.parsePipeline();for(n.push(i);this.check(E.AND_AND,E.OR_OR);){let l=this.advance();r.push(l.type===E.AND_AND?"&&":"||"),this.skipNewlines();let c=this.parsePipeline();n.push(c)}this.check(E.AMP)&&(this.advance(),s=!0);let o=this.pos>0?this.tokens[this.pos-1].end:t,a=this._input.slice(t,o);return q.statement(n,r,s,void 0,a)}parsePipeline(){let t=!1,n=!1;this.check(E.TIME)&&(this.advance(),t=!0,this.check(E.WORD,E.NAME)&&this.current().value==="-p"&&(this.advance(),n=!0));let r=0;for(;this.check(E.BANG);)this.advance(),r++;let s=r%2===1,i=[],o=[],a=this.parseCommand();for(i.push(a);this.check(E.PIPE,E.PIPE_AMP);){let l=this.advance();this.skipNewlines(),o.push(l.type===E.PIPE_AMP);let c=this.parseCommand();i.push(c)}return q.pipeline(i,s,t,n,o.length>0?o:void 0)}parseCommand(){return this.check(E.IF)?Cl(this):this.check(E.FOR)?Nl(this):this.check(E.WHILE)?kl(this):this.check(E.UNTIL)?vl(this):this.check(E.CASE)?Il(this):this.check(E.LPAREN)?Ol(this):this.check(E.LBRACE)?Rl(this):this.check(E.DPAREN_START)?this.dparenClosesWithSpacedParens()?this.parseNestedSubshellsFromDparen():this.parseArithmeticCommand():this.check(E.DBRACK_START)?this.parseConditionalCommand():this.check(E.FUNCTION)?this.parseFunctionDef():this.check(E.NAME,E.WORD)&&this.peek(1).type===E.LPAREN&&this.peek(2).type===E.RPAREN?this.parseFunctionDef():lm(this)}dparenClosesWithSpacedParens(){let t=1,n=1;for(;n<this.tokens.length-this.pos;){let r=this.peek(n);if(r.type===E.EOF)return!1;if(r.type===E.DPAREN_START||r.type===E.LPAREN)t++;else if(r.type===E.DPAREN_END){if(t-=2,t<=0)return!1}else if(r.type===E.RPAREN&&(t--,t===0&&this.peek(n+1).type===E.RPAREN))return!0;n++}return!1}parseNestedSubshellsFromDparen(){this.advance();let t=this.parseCompoundList();this.expect(E.RPAREN),this.expect(E.RPAREN);let n=this.parseOptionalRedirections(),r=q.subshell(t,[]);return q.subshell([q.statement([q.pipeline([r],!1,!1,!1)])],n)}isWord(){let t=this.current().type;return t===E.WORD||t===E.NAME||t===E.NUMBER||t===E.IF||t===E.FOR||t===E.WHILE||t===E.UNTIL||t===E.CASE||t===E.FUNCTION||t===E.ELSE||t===E.ELIF||t===E.FI||t===E.THEN||t===E.DO||t===E.DONE||t===E.ESAC||t===E.IN||t===E.SELECT||t===E.TIME||t===E.COPROC||t===E.BANG}parseWord(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted)}parseWordNoBraceExpansion(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0)}parseWordForRegex(){let t=this.advance();return this.parseWordFromString(t.value,t.quoted,t.singleQuoted,!1,!1,!0,!0)}parseWordFromString(t,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1){let l=Pn(this,t,n,r,s,i,!1,o,a);return q.word(l)}parseCommandSubstitution(t,n){return wm(t,n,()=>new e,r=>this.error(r))}parseBacktickSubstitution(t,n,r=!1){return bm(t,n,r,()=>new e,s=>this.error(s))}isDollarDparenSubshell(t,n){return ym(t,n)}parseArithmeticExpansion(t,n){let r=n+3,s=1,i=0,o=r;for(;o<t.length-1&&s>0;)t[o]==="$"&&t[o+1]==="("?t[o+2]==="("?(s++,o+=3):(i++,o+=2):t[o]==="("&&t[o+1]==="("?(s++,o+=2):t[o]===")"&&t[o+1]===")"?i>0?(i--,o++):(s--,s>0&&(o+=2)):t[o]==="("?(i++,o++):(t[o]===")"&&i>0&&i--,o++);let a=t.slice(r,o),l=this.parseArithmeticExpression(a);return{part:q.arithmeticExpansion(l),endIndex:o+2}}parseArithmeticCommand(){let t=this.expect(E.DPAREN_START),n="",r=1,s=0,i=!1,o=!1;for(;r>0&&!this.check(E.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(E.RPAREN)){r--,o=!0,this.advance();continue}if(this.check(E.DPAREN_END)){r--,o=!0;continue}n+=")";continue}if(this.check(E.DPAREN_START))r++,n+="((",this.advance();else if(this.check(E.DPAREN_END))s>=2?(s-=2,n+="))",this.advance()):s===1?(s--,n+=")",i=!0,this.advance()):(r--,o=!0,r>0&&(n+="))"),this.advance());else if(this.check(E.LPAREN))s++,n+="(",this.advance();else if(this.check(E.RPAREN))s>0&&s--,n+=")",this.advance();else{let c=this.current().value,u=n.length>0?n[n.length-1]:"";n.length>0&&!n.endsWith(" ")&&!(c==="="&&/[|&^+\-*/%<>]$/.test(n))&&!(c==="<"&&u==="<")&&!(c===">"&&u===">")&&(n+=" "),n+=c,this.advance()}}o||this.expect(E.DPAREN_END);let a=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return q.arithmeticCommand(a,l,t.line)}parseConditionalCommand(){let t=this.expect(E.DBRACK_START),n=Tl(this);this.expect(E.DBRACK_END);let r=this.parseOptionalRedirections();return q.conditionalCommand(n,r,t.line)}parseFunctionDef(){let t;if(this.check(E.FUNCTION)){if(this.advance(),this.check(E.NAME)||this.check(E.WORD))t=this.advance().value;else{let s=this.current();throw new lt("Expected function name",s.line,s.column,s)}this.check(E.LPAREN)&&(this.advance(),this.expect(E.RPAREN))}else t=this.advance().value,t.includes("$")&&this.error(`\`${t}': not a valid identifier`),this.expect(E.LPAREN),this.expect(E.RPAREN);this.skipNewlines();let n=this.parseCompoundCommandBody({forFunctionBody:!0}),r=this.parseOptionalRedirections();return q.functionDef(t,n,r)}parseCompoundCommandBody(t){let n=t?.forFunctionBody;if(this.check(E.LBRACE))return Rl(this,{skipRedirections:n});if(this.check(E.LPAREN))return Ol(this,{skipRedirections:n});if(this.check(E.IF))return Cl(this,{skipRedirections:n});if(this.check(E.FOR))return Nl(this,{skipRedirections:n});if(this.check(E.WHILE))return kl(this,{skipRedirections:n});if(this.check(E.UNTIL))return vl(this,{skipRedirections:n});if(this.check(E.CASE))return Il(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let t=[];for(this.skipNewlines();!this.check(E.EOF,E.FI,E.ELSE,E.ELIF,E.THEN,E.DO,E.DONE,E.ESAC,E.RPAREN,E.RBRACE,E.DSEMI,E.SEMI_AND,E.SEMI_SEMI_AND)&&this.isCommandStart();){this.checkIterationLimit();let n=this.pos,r=this.parseStatement();if(r&&t.push(r),this.skipSeparators(),this.pos===n&&!r)break}return t}parseOptionalRedirections(){let t=[];for(;Li(this);){this.checkIterationLimit();let n=this.pos;if(t.push(_i(this)),this.pos===n)break}return t}parseArithmeticExpression(t){return Ae(this,t)}}});function _l(e){return gw.get(e)??""}function km(e){let t=[],n="",r=0;for(;r<e.length;){let s=e[r];if(s==="["){for(n+=s,r++,r<e.length&&(e[r]==="!"||e[r]==="^")&&(n+=e[r],r++),r<e.length&&e[r]==="]"&&(n+=e[r],r++);r<e.length&&e[r]!=="]";){if(e[r]==="["&&r+1<e.length&&e[r+1]===":"){let i=e.indexOf(":]",r+2);if(i!==-1){n+=e.slice(r,i+2),r=i+2;continue}}if(e[r]==="\\"&&r+1<e.length){n+=e[r]+e[r+1],r+=2;continue}n+=e[r],r++}r<e.length&&e[r]==="]"&&(n+=e[r],r++)}else s===":"?(n!==""&&t.push(n),n="",r++):s==="\\"&&r+1<e.length?(n+=s+e[r+1],r+=2):(n+=s,r++)}return n!==""&&t.push(n),t}function vm(e){let t="^";for(let n=0;n<e.length;n++){let r=e[n];if(r==="*")t+="[^/]*";else if(r==="?")t+="[^/]";else if(r==="["){let s=n+1,i="[";s<e.length&&(e[s]==="^"||e[s]==="!")&&(i+="^",s++),s<e.length&&e[s]==="]"&&(i+="\\]",s++);let o=s;for(;o<e.length;){if(e[o]==="\\"&&o+1<e.length){o+=2;continue}if(e[o]==="["&&o+1<e.length&&e[o+1]===":"){let l=e.indexOf(":]",o+2);if(l!==-1){o=l+2;continue}}if(e[o]==="]")break;o++}let a=s;for(;s<e.length&&e[s]!=="]";){if(e[s]==="["&&s+1<e.length&&e[s+1]===":"){let l=e.indexOf(":]",s+2);if(l!==-1){let c=e.slice(s+2,l),u=_l(c);i+=u,s=l+2;continue}}if(e[s]==="\\"&&s+1<e.length){i+=`\\${e[s+1]}`,s+=2;continue}if(e[s]==="-"){let l=s===a,c=s+1===o;l||c?i+="\\-":i+="-"}else i+=e[s];s++}i+="]",t+=i,n=s}else if(r==="\\"&&n+1<e.length){let s=e[n+1];/[.+^${}()|\\*?[\]]/.test(s)?t+=`\\${s}`:t+=s,n++}else/[.+^${}()|]/.test(r)?t+=`\\${r}`:t+=r}return t+="$",V(t)}function Ml(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function Fl(e){let t=[],n="",r=0,s=!1,i=0;for(;i<e.length;){let o=e[i];if(o==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(o==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=o,i++;continue}if(o==="\\"){n+=o,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}o==="("?(r++,n+=o):o===")"?(r--,n+=o):o==="|"&&r===0?(t.push(n),n=""):n+=o,i++}return t.push(n),t}var gw,Im=I(()=>{"use strict";Me();gw=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9a-fA-F"]])});var Dn,Mi=I(()=>{"use strict";xe();Me();or();Im();Dn=class{fs;cwd;globignorePatterns=[];hasGlobignore=!1;globstar=!1;nullglob=!1;failglob=!1;dotglob=!1;extglob=!1;globskipdots=!0;ops={count:0};maxOps;constructor(t,n,r,s){this.fs=t,this.cwd=n,typeof s=="boolean"?(this.globstar=s,this.maxOps=1e5):s?(this.globstar=s.globstar??!1,this.nullglob=s.nullglob??!1,this.failglob=s.failglob??!1,this.dotglob=s.dotglob??!1,this.extglob=s.extglob??!1,this.globskipdots=s.globskipdots??!0,this.maxOps=s.maxGlobOperations??1e5):this.maxOps=1e5;let i=r?.get("GLOBIGNORE");i!==void 0&&i!==""&&(this.hasGlobignore=!0,this.globignorePatterns=km(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new re(`Glob operation limit exceeded (${this.maxOps})`,"glob_operations")}hasNullglob(){return this.nullglob}hasFailglob(){return this.failglob}filterGlobignore(t){return!this.hasGlobignore&&!this.globskipdots?t:t.filter(n=>{let r=n.split("/").pop()||n;if((this.hasGlobignore||this.globskipdots)&&(r==="."||r===".."))return!1;if(this.hasGlobignore){for(let s of this.globignorePatterns)if(this.matchGlobignorePattern(n,s))return!1}return!0})}matchGlobignorePattern(t,n){return vm(n).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,n){let r=t.map((o,a)=>(n?.[a]??!1)||!this.isGlobPattern(o)?null:this.expand(o)),s=await Promise.all(r.map(o=>o||Promise.resolve(null))),i=[];for(let o=0;o<t.length;o++){let a=s[o];a===null?i.push(t[o]):a.length>0?i.push(...a):i.push(t[o])}return i}async expand(t){let n;if(t.includes("**")&&this.globstar&&this.isGlobstarValid(t))n=await this.expandRecursive(t);else{let r=t.replace(/\*\*+/g,"*");n=await this.expandSimple(r)}return this.filterGlobignore(n)}isGlobstarValid(t){let n=t.split("/");for(let r of n)if(r.includes("**")&&r!=="**")return!1;return!0}hasGlobChars(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandSimple(t){let n=t.startsWith("/"),r=t.split("/").filter(c=>c!==""),s=-1;for(let c=0;c<r.length;c++)if(this.hasGlobChars(r[c])){s=c;break}if(s===-1)return[t];let i,o;if(s===0)n?(i="/",o="/"):(i=this.cwd,o="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,o=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),o=c.join("/"))}let a=r.slice(s);return(await this.expandSegments(i,o,a)).sort()}async expandSegments(t,n,r){if(this.checkOpsLimit(),r.length===0)return[n];let[s,...i]=r,o=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let a=await this.fs.readdirWithFileTypes(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let h=a.some(m=>m.name==="."),p=a.some(m=>m.name==="..");h||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),p||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let h of c)if(!(h.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h.name,s)){let p=t==="/"?`/${h.name}`:`${t}/${h.name}`,m;n===""?m=h.name:n==="/"?m=`/${h.name}`:m=`${n}/${h.name}`,i.length===0?l.push(Promise.resolve([m])):h.isDirectory&&l.push(this.expandSegments(p,m,i))}let f=await Promise.all(l);for(let h of f)o.push(...h)}else{this.checkOpsLimit();let a=await this.fs.readdir(t),l=[],c=[...a],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(a.includes(".")||c.push("."),a.includes("..")||c.push(".."));for(let h of c)if(!(h.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(h,s)){let p=t==="/"?`/${h}`:`${t}/${h}`,m;n===""?m=h:n==="/"?m=`/${h}`:m=`${n}/${h}`,i.length===0?l.push(Promise.resolve([m])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(p)).isDirectory)return this.expandSegments(p,m,i)}catch(d){if(d instanceof re)throw d}return[]})())}let f=await Promise.all(l);for(let h of f)o.push(...h)}}catch(a){if(a instanceof re)throw a}return o}async expandRecursive(t){let n=[],r=t.indexOf("**"),s=t.slice(0,r).replace(/\/$/,"")||".",o=t.slice(r+2).replace(/^\//,"");return o.includes("**")&&this.isGlobstarValid(o)?(await this.walkDirectoryMultiGlobstar(s,o,n),[...new Set(n)].sort()):(await this.walkDirectory(s,o,n),n.sort())}async walkDirectoryMultiGlobstar(t,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,t);try{this.checkOpsLimit();let i=this.fs.readdirWithFileTypes?await this.fs.readdirWithFileTypes(s):null;if(i){let o=[];for(let c of i){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&o.push(u)}let a=t==="."?n:`${t}/${n}`,l=await this.expandRecursive(a);r.push(...l);for(let c=0;c<o.length;c+=100){let u=o.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{this.checkOpsLimit();let o=await this.fs.readdir(s),a=[];for(let u of o){let f=t==="."?u:`${t}/${u}`,h=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory&&a.push(f)}catch(p){if(p instanceof re)throw p}}let l=t==="."?n:`${t}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<a.length;u+=100){let f=a.slice(u,u+100);await Promise.all(f.map(h=>this.walkDirectoryMultiGlobstar(h,n,r)))}}}catch(i){if(i instanceof re)throw i}}async walkDirectory(t,n,r){this.checkOpsLimit();let s=this.fs.resolvePath(this.cwd,t);try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let i=await this.fs.readdirWithFileTypes(s),o=[],a=[];for(let l of i){let c=t==="."?l.name:`${t}/${l.name}`;l.isDirectory?a.push(c):n&&this.matchPattern(l.name,n)&&o.push(c)}r.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,n,r)))}}else{this.checkOpsLimit();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 h=t==="."?f:`${t}/${f}`,p=this.fs.resolvePath(this.cwd,h);try{this.checkOpsLimit();let m=await this.fs.stat(p);return{name:f,path:h,isDirectory:m.isDirectory}}catch(m){if(m instanceof re)throw m;return null}}));o.push(...u.filter(f=>f!==null))}for(let l of o)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.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,n,r)))}}}catch(i){if(i instanceof re)throw i}}matchPattern(t,n){return this.patternToRegex(n).test(t)}patternToRegex(t){let n=this.patternToRegexStr(t);return V(`^${n}$`)}patternToRegexStr(t){let n="",r=!1;for(let s=0;s<t.length;s++){if(t.slice(s,s+13)==="\0QUOTE_START\0"){r=!0,s+=12;continue}if(t.slice(s,s+11)==="\0QUOTE_END\0"){r=!1,s+=10;continue}let i=t[s];if(r){/[.+^${}()|\\*?[\]]/.test(i)?n+=`\\${i}`:n+=i;continue}if(this.extglob&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<t.length&&t[s+1]==="("){let o=Ml(t,s+1);if(o!==-1){let a=t.slice(s+2,o),l=Fl(a),c=l.map(f=>this.patternToRegexStr(f)),u=c.length>0?c.join("|"):"(?:)";if(i==="@")n+=`(?:${u})`;else if(i==="*")n+=`(?:${u})*`;else if(i==="+")n+=`(?:${u})+`;else if(i==="?")n+=`(?:${u})?`;else if(i==="!")if(o<t.length-1){let h=l.map(m=>this.computePatternLength(m));if(h.every(m=>m!==null)&&h.every(m=>m===h[0])&&h[0]!==null){let m=h[0];if(m===0)n+="(?:.+)";else{let d=[];m>0&&d.push(`.{0,${m-1}}`),d.push(`.{${m+1},}`),d.push(`(?!(?:${u})).{${m}}`),n+=`(?:${d.join("|")})`}}else n+=`(?:(?!(?:${u})).)*?`}else n+=`(?!(?:${u})$).*`;s=o;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let o=s+1,a="[";o<t.length&&(t[o]==="^"||t[o]==="!")&&(a+="^",o++),o<t.length&&t[o]==="]"&&(a+="\\]",o++);let l=o;for(;l<t.length;){if(t[l]==="\\"&&l+1<t.length){l+=2;continue}if(t[l]==="["&&l+1<t.length&&t[l+1]===":"){let u=t.indexOf(":]",l+2);if(u!==-1){l=u+2;continue}}if(t[l]==="]")break;l++}let c=o;for(;o<t.length&&t[o]!=="]";){if(t[o]==="["&&o+1<t.length&&t[o+1]===":"){let u=t.indexOf(":]",o+2);if(u!==-1){let f=t.slice(o+2,u),h=_l(f);a+=h,o=u+2;continue}}if(t[o]==="\\"&&o+1<t.length){a+=`\\${t[o+1]}`,o+=2;continue}if(t[o]==="-"){let u=o===c,f=o+1===l;u||f?a+="\\-":a+="-"}else a+=t[o];o++}a+="]",n+=a,s=o}else if(i==="\\"&&s+1<t.length){let o=t[s+1];/[.+^${}()|\\*?[\]]/.test(o)?n+=`\\${o}`:n+=o,s++}else/[.+^${}()|]/.test(i)?n+=`\\${i}`:n+=i}return n}computePatternLength(t){let n=0,r=0,s=!1;for(;r<t.length;){if(t.slice(r,r+13)==="\0QUOTE_START\0"){s=!0,r+=13;continue}if(t.slice(r,r+11)==="\0QUOTE_END\0"){s=!1,r+=11;continue}let i=t[r];if(s){n+=1,r++;continue}if((i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&r+1<t.length&&t[r+1]==="("){let o=Ml(t,r+1);if(o!==-1){if(i==="@"){let a=t.slice(r+2,o),c=Fl(a).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=o+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let o=t.indexOf("]",r+1);if(o!==-1){n+=1,r=o+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function Ul(e){for(let t=0;t<e.length;t++){if(e[t]==="\\"){t++;continue}if(e[t]==="$"){let n=e[t+1];if(n==="{"||n&&/[a-zA-Z_]/.test(n))return!0}}return!1}function yw(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n)return!1;for(let r of n)if(r.type==="DoubleQuoted"||r.type==="SingleQuoted")return!0;return!1}function Om(e){if(!e.operation)return!1;let t=e.operation,n;if((t.type==="DefaultValue"||t.type==="AssignDefault"||t.type==="UseAlternative"||t.type==="ErrorIfUnset")&&(n=t.word?.parts),!n||n.length===0)return!1;for(let r of n)if(r.type!=="DoubleQuoted"&&r.type!=="SingleQuoted")return!1;return!0}function ys(e){let t=!1,n=!1,r=!1,s=!1,i=!1,o=!1,a=!1;for(let l of e){if((l.type==="SingleQuoted"||l.type==="DoubleQuoted")&&(t=!0,l.type==="DoubleQuoted"))for(let c of l.parts)c.type==="ParameterExpansion"&&(c.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/)&&(!c.operation||c.operation.type==="PatternRemoval"||c.operation.type==="PatternReplacement")&&(s=!0),(c.operation?.type==="VarNamePrefix"||c.operation?.type==="ArrayKeys")&&(o=!0),c.operation?.type==="Indirection"&&(a=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),yw(l)&&(t=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(o=!0),l.operation?.type==="Indirection"&&(a=!0)),l.type==="Glob"&&Ul(l.pattern)&&(i=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:o,hasIndirection:a}}var Fi=I(()=>{"use strict"});function Ke(e,t){let n=`${t}_`,r=[];for(let s of e.state.env.keys())if(s.startsWith(n)){let i=s.slice(n.length),o=Number.parseInt(i,10);!Number.isNaN(o)&&String(o)===i&&r.push(o)}return r.sort((s,i)=>s-i)}function pn(e,t){let n=`${t}_`;for(let r of e.state.env.keys())r.startsWith(n)&&e.state.env.delete(r)}function Jt(e,t){let n=`${t}_`,r=`${t}__length`,s=[];for(let i of e.state.env.keys())if(i!==r&&i.startsWith(n)){let o=i.slice(n.length);if(o.startsWith("_length"))continue;s.push(o)}return s.sort()}function Ui(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Wl(e){if(e.parts.length<2)return null;let t=e.parts[0],n=e.parts[1];if(t.type!=="Glob"||!t.pattern.startsWith("["))return null;let r,s=n,i=1;if(n.type==="Literal"&&n.value.startsWith("]")){let f=n.value.slice(1);if(f.startsWith("+=")||f.startsWith("="))r=t.pattern.slice(1);else if(f===""){if(e.parts.length<3)return null;let h=e.parts[2];if(h.type!=="Literal"||!h.value.startsWith("=")&&!h.value.startsWith("+="))return null;r=t.pattern.slice(1),s=h,i=2}else return null}else if(t.pattern==="["&&(n.type==="DoubleQuoted"||n.type==="SingleQuoted")){if(e.parts.length<3)return null;let f=e.parts[2];if(f.type!=="Literal"||!f.value.startsWith("]=")&&!f.value.startsWith("]+="))return null;if(n.type==="SingleQuoted")r=n.value;else{r="";for(let h of n.parts)(h.type==="Literal"||h.type==="Escaped")&&(r+=h.value)}s=f,i=2}else if(t.pattern.endsWith("]")){if(n.type!=="Literal"||!n.value.startsWith("=")&&!n.value.startsWith("+="))return null;r=t.pattern.slice(1,-1)}else return null;r=Ui(r);let o;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?o=s.value.slice(1):o=s.value;let a=o.startsWith("+=");if(!a&&!o.startsWith("="))return null;let l=[],c=a?2:1,u=o.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<e.parts.length;f++){let h=e.parts[f];h.type==="BraceExpansion"?l.push({type:"Literal",value:ww(h)}):l.push(h)}return{key:r,valueParts:l,append:a}}function ww(e){return`{${e.items.map(n=>{if(n.type==="Range"){let r=n.startStr??String(n.start),s=n.endStr??String(n.end),i=`${r}..${s}`;return n.step&&(i+=`..${n.step}`),i}return $r(n.word)}).join(",")}}`}function $r(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value;break;case"Glob":t+=n.pattern;break;case"SingleQuoted":t+=n.value;break;case"DoubleQuoted":for(let r of n.parts)(r.type==="Literal"||r.type==="Escaped")&&(t+=r.value);break;case"Escaped":t+=n.value;break;case"BraceExpansion":t+="{",t+=n.items.map(r=>r.type==="Range"?`${r.startStr}..${r.endStr}${r.step?`..${r.step}`:""}`:$r(r.word)).join(","),t+="}";break;case"TildeExpansion":t+="~",n.user&&(t+=n.user);break}return t}var Zt=I(()=>{"use strict"});function tt(e){return e.get("IFS")??`
767
767
  `}function ct(e){return e.get("IFS")===""}function Wi(e){let t=tt(e);if(t==="")return!0;for(let n of t)if(n!==" "&&n!==" "&&n!==`
768
- `)return!1;return!0}function Om(e){return e.split("").map(t=>/[\\^$.*+?()[\]{}|-]/.test(t)?`\\${t}`:t===" "?"\\t":t===`
768
+ `)return!1;return!0}function Rm(e){return e.split("").map(t=>/[\\^$.*+?()[\]{}|-]/.test(t)?`\\${t}`:t===" "?"\\t":t===`
769
769
  `?"\\n":t).join("")}function fe(e){let t=e.get("IFS");return t===void 0?" ":t[0]||""}function xw(e){return bw.includes(e)}function Bl(e){let t=new Set,n=new Set;for(let r of e)xw(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function Hl(e,t,n,r){if(t==="")return e===""?{words:[],wordStarts:[]}:{words:[e],wordStarts:[0]};let{whitespace:s,nonWhitespace:i}=Bl(t),o=[],a=[],l=0;for(;l<e.length&&s.has(e[l]);)l++;if(l>=e.length)return{words:[],wordStarts:[]};if(i.has(e[l]))for(o.push(""),a.push(l),l++;l<e.length&&s.has(e[l]);)l++;for(;l<e.length&&!(n!==void 0&&o.length>=n);){let c=l;for(a.push(c);l<e.length;){let u=e[l];if(!r&&u==="\\"){l++,l<e.length&&l++;continue}if(s.has(u)||i.has(u))break;l++}if(o.push(e.substring(c,l)),l>=e.length)break;for(;l<e.length&&s.has(e[l]);)l++;if(l<e.length&&i.has(e[l])){for(l++;l<e.length&&s.has(e[l]);)l++;for(;l<e.length&&i.has(e[l])&&!(n!==void 0&&o.length>=n);)for(o.push(""),a.push(l),l++;l<e.length&&s.has(e[l]);)l++}}return{words:o,wordStarts:a}}function Bi(e,t){if(t==="")return{words:e?[e]:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};if(e==="")return{words:[],hadLeadingDelimiter:!1,hadTrailingDelimiter:!1};let{whitespace:n,nonWhitespace:r}=Bl(t),s=[],i=0,o=!1,a=!1,l=i;for(;i<e.length&&n.has(e[i]);)i++;if(i>l&&(o=!0),i>=e.length)return{words:[],hadLeadingDelimiter:!0,hadTrailingDelimiter:!0};if(r.has(e[i]))for(s.push(""),i++;i<e.length&&n.has(e[i]);)i++;for(;i<e.length;){let c=i;for(;i<e.length;){let f=e[i];if(n.has(f)||r.has(f))break;i++}if(s.push(e.substring(c,i)),i>=e.length){a=!1;break}let u=i;for(;i<e.length&&n.has(e[i]);)i++;if(i<e.length&&r.has(e[i])){for(i++;i<e.length&&n.has(e[i]);)i++;for(;i<e.length&&r.has(e[i]);)for(s.push(""),i++;i<e.length&&n.has(e[i]);)i++}i>=e.length&&i>u&&(a=!0)}return{words:s,hadLeadingDelimiter:o,hadTrailingDelimiter:a}}function Le(e,t){return Bi(e,t).words}function Ew(e,t){for(let n of e)if(t.has(n))return!0;return!1}function $m(e,t,n){if(t==="")return e;let{whitespace:r,nonWhitespace:s}=Bl(t),i=e.length;for(;i>0&&r.has(e[i-1]);){if(!n&&i>=2){let a=0,l=i-2;for(;l>=0&&e[l]==="\\";)a++,l--;if(a%2===1)break}i--}let o=e.substring(0,i);if(o.length>=1&&s.has(o[o.length-1])){if(!n&&o.length>=2){let l=0,c=o.length-2;for(;c>=0&&o[c]==="\\";)l++,c--;if(l%2===1)return o}let a=o.substring(0,o.length-1);if(!Ew(a,s))return a}return o}var bw,Wt=I(()=>{"use strict";bw=`
770
770
  `});function Te(e,t){return e.state.namerefs?.has(t)??!1}function En(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function Tm(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Pm(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function Dm(e,t){return e.state.invalidNamerefs?.has(t)??!1}function zl(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function Hi(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let s=n[1],i=Array.from(e.state.env.keys()).some(a=>a.startsWith(`${s}_`)&&!a.includes("__")),o=e.state.associativeArrays?.has(s)??!1;return i||o}return Array.from(e.state.env.keys()).some(s=>s.startsWith(`${t}_`)&&!s.includes("__"))?!0:e.state.env.has(t)}function xt(e,t,n=100){if(!Te(e,t)||Dm(e,t))return t;let r=new Set,s=t;for(;n-- >0;){if(r.has(s))return;if(r.add(s),!Te(e,s))return s;let i=e.state.env.get(s);if(i===void 0||i===""||!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(i))return s;s=i}}function tr(e,t){if(Te(e,t))return e.state.env.get(t)}function Lm(e,t,n,r=100){if(!Te(e,t)||Dm(e,t))return t;let s=new Set,i=t;for(;r-- >0;){if(s.has(i))return;if(s.add(i),!Te(e,i))return i;let o=e.state.env.get(i);if(o===void 0||o==="")return n!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&Hi(e,n)?i:null:i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(o))return i;i=o}}var en=I(()=>{"use strict"});function Aw(e,t){let n=t.replace(/\$\{([a-zA-Z_][a-zA-Z0-9_]*)\}/g,(r,s)=>e.state.env.get(s)??"");return n=n.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(r,s)=>e.state.env.get(s)??""),n}function ae(e,t){return t==="FUNCNAME"?(e.state.funcNameStack??[]).map((i,o)=>[o,i]):t==="BASH_LINENO"?(e.state.callLineStack??[]).map((i,o)=>[o,String(i)]):t==="BASH_SOURCE"?(e.state.sourceStack??[]).map((i,o)=>[o,i]):e.state.associativeArrays?.has(t)?Jt(e,t).map(i=>[i,e.state.env.get(`${t}_${i}`)??""]):Ke(e,t).map(s=>[s,e.state.env.get(`${t}_${s}`)??""])}function An(e,t){return t==="FUNCNAME"?(e.state.funcNameStack?.length??0)>0:t==="BASH_LINENO"?(e.state.callLineStack?.length??0)>0:t==="BASH_SOURCE"?(e.state.sourceStack?.length??0)>0:e.state.associativeArrays?.has(t)?Jt(e,t).length>0:Ke(e,t).length>0}async function Se(e,t,n=!0,r=!1){switch(t){case"?":return String(e.state.lastExitCode);case"$":return String(process.pid);case"#":return e.state.env.get("#")||"0";case"@":return e.state.env.get("@")||"";case"_":return e.state.lastArg;case"-":{let o="";return o+="h",e.state.options.errexit&&(o+="e"),e.state.options.noglob&&(o+="f"),e.state.options.nounset&&(o+="u"),e.state.options.verbose&&(o+="v"),e.state.options.xtrace&&(o+="x"),o+="B",e.state.options.noclobber&&(o+="C"),o+="s",o}case"*":{let o=Number.parseInt(e.state.env.get("#")||"0",10);if(o===0)return"";let a=[];for(let l=1;l<=o;l++)a.push(e.state.env.get(String(l))||"");return a.join(fe(e.state.env))}case"0":return e.state.env.get("0")||"bash";case"PWD":return e.state.env.get("PWD")??"";case"OLDPWD":return e.state.env.get("OLDPWD")??"";case"PPID":{let{ppid:o}=ds();return String(o)}case"UID":{let{uid:o}=ds();return String(o)}case"EUID":return String(process.geteuid?.()??ds().uid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-e.state.startTime)/1e3));case"BASH_VERSION":return I0;case"!":return String(e.state.lastBackgroundPid);case"BASHPID":return String(e.state.bashPid);case"LINENO":return String(e.state.currentLine);case"FUNCNAME":{let o=e.state.funcNameStack?.[0];if(o!==void 0)return o;if(n&&e.state.options.nounset)throw new gt("FUNCNAME");return""}case"BASH_LINENO":{let o=e.state.callLineStack?.[0];if(o!==void 0)return String(o);if(n&&e.state.options.nounset)throw new gt("BASH_LINENO");return""}case"BASH_SOURCE":{let o=e.state.sourceStack?.[0];if(o!==void 0)return o;if(n&&e.state.options.nounset)throw new gt("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new yt(`\${${t}}`);let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let o=s[1],a=s[2];if(Te(e,o)){let f=xt(e,o);if(f&&f!==o){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return"";o=f}}if(a==="@"||a==="*"){let f=ae(e,o);if(f.length>0)return f.map(([,p])=>p).join(" ");let h=e.state.env.get(o);return h!==void 0?h:""}if(o==="FUNCNAME"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?e.state.funcNameStack?.[f]??"":""}if(o==="BASH_LINENO"){let f=Number.parseInt(a,10);if(!Number.isNaN(f)&&f>=0){let h=e.state.callLineStack?.[f];return h!==void 0?String(h):""}return""}if(o==="BASH_SOURCE"){let f=Number.parseInt(a,10);return!Number.isNaN(f)&&f>=0?e.state.sourceStack?.[f]??"":""}if(e.state.associativeArrays?.has(o)){let f=Ui(a);f=Aw(e,f);let h=e.state.env.get(`${o}_${f}`);if(h===void 0&&n&&e.state.options.nounset)throw new gt(`${o}[${a}]`);return h||""}let c;if(/^-?\d+$/.test(a))c=Number.parseInt(a,10);else try{let f=new ce,h=Ae(f,a);c=await J(e,h.expression)}catch{let f=e.state.env.get(a);c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=ae(e,o),h=e.state.currentLine;if(f.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${h}: ${o}: bad array subscript
771
771
  `,"";let m=Math.max(...f.map(([g])=>typeof g=="number"?g:0))+1+c;return m<0?(e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${h}: ${o}: bad array subscript
772
- `,""):e.state.env.get(`${o}_${m}`)||""}let u=e.state.env.get(`${o}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(o);if(f!==void 0)return f}if(n&&e.state.options.nounset)throw new gt(`${o}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let o=e.state.env.get(t);if(o===void 0&&n&&e.state.options.nounset)throw new gt(t);return o||""}if(Te(e,t)){let o=xt(e,t);if(o===void 0)return"";if(o!==t)return await Se(e,o,n,r);let a=e.state.env.get(t);if((a===void 0||a==="")&&n&&e.state.options.nounset)throw new gt(t);return a||""}let i=e.state.env.get(t);if(i!==void 0)return e.state.tempEnvBindings?.some(o=>o.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),i;if(An(e,t)){let o=e.state.env.get(`${t}_0`);return o!==void 0?o:""}if(n&&e.state.options.nounset)throw new gt(t);return""}async function dn(e,t){if(new Set(["?","$","#","_","-","0","PPID","UID","EUID","RANDOM","SECONDS","BASH_VERSION","!","BASHPID","LINENO"]).has(t))return!0;if(t==="@"||t==="*")return Number.parseInt(e.state.env.get("#")||"0",10)>0;if(t==="PWD"||t==="OLDPWD")return e.state.env.has(t);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let s=r[1],i=r[2];if(Te(e,s)){let l=xt(e,s);if(l&&l!==s){if(l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;s=l}}if(i==="@"||i==="*")return ae(e,s).length>0?!0:e.state.env.has(s);if(e.state.associativeArrays?.has(s)){let l=Ui(i);return e.state.env.has(`${s}_${l}`)}let a;if(/^-?\d+$/.test(i))a=Number.parseInt(i,10);else try{let l=new ce,c=Ae(l,i);a=await J(e,c.expression)}catch{let l=e.state.env.get(i);a=l?Number.parseInt(l,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let l=ae(e,s);if(l.length===0)return!1;let u=Math.max(...l.map(([f])=>typeof f=="number"?f:0))+1+a;return u<0?!1:e.state.env.has(`${s}_${u}`)}return e.state.env.has(`${s}_${a}`)}if(Te(e,t)){let s=xt(e,t);return s===void 0||s===t?e.state.env.has(t):dn(e,s)}return!!(e.state.env.has(t)||An(e,t))}var Ot=I(()=>{"use strict";pt();Qe();fl();Et();xe();Zt();Wt();en()});async function _m(e,t){let n="",r=0;for(;r<t.length;){if(t[r]==="$"){if(t[r+1]==="{"){let s=1,i=r+2;for(;i<t.length&&s>0;)t[i]==="{"?s++:t[i]==="}"&&s--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]==="("){let s=1,i=r+2;for(;i<t.length&&s>0;)t[i]==="("?s++:t[i]===")"&&s--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await Se(e,i);n+=o,r=s;continue}if(/[0-9]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[0-9]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await Se(e,i);n+=o,r=s;continue}if(/[*@#?\-!$]/.test(t[r+1]||"")){let s=t[r+1],i=await Se(e,s);n+=i,r+=2;continue}}if(t[r]==='"'){for(n+='"',r++;r<t.length&&t[r]!=='"';)if(t[r]==="$"&&/[a-zA-Z_]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await Se(e,i);n+=o,r=s}else t[r]==="\\"?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+='"',r++);continue}n+=t[r],r++}return n}async function jl(e,t){let n=t,r=t.startsWith('"')&&t.endsWith('"'),s=t.startsWith("'")&&t.endsWith("'");if((r||s)&&(n=t.slice(1,-1)),s)return n;let i="",o=0;for(;o<n.length;)if(n[o]==="$")if(n[o+1]==="("){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="("&&n[l-1]==="$"||n[l]==="("?a++:n[l]===")"&&a--,l++;let c=n.slice(o+2,l-1);if(e.execFn){let u=await e.execFn(c);i+=u.stdout.replace(/\n+$/,""),u.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+u.stderr)}o=l}else if(n[o+1]==="{"){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="{"?a++:n[l]==="}"&&a--,l++;let c=n.slice(o+2,l-1),u=await Se(e,c);i+=u,o=l}else if(/[a-zA-Z_]/.test(n[o+1]||"")){let a=o+1;for(;a<n.length&&/[a-zA-Z0-9_]/.test(n[a]);)a++;let l=n.slice(o+1,a),c=await Se(e,l);i+=c,o=a}else i+=n[o],o++;else if(n[o]==="`"){let a=o+1;for(;a<n.length&&n[a]!=="`";)a++;let l=n.slice(o+1,a);if(e.execFn){let c=await e.execFn(l);i+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}o=a+1}else i+=n[o],o++;return i}var Mm=I(()=>{"use strict";Ot()});function Sw(e,t,n,r,s){let i=n??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,h=String(Math.abs(u)).padStart(l,"0");return f?`-${h}`:h}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<zi;u+=o,f++)a.push(c(u));else for(let u=e,f=0;u>=t&&f<zi;u-=o,f++)a.push(c(u));return a}function Cw(e,t,n){let r=n??1;r===0&&(r=1);let s=e.charCodeAt(0),i=t.charCodeAt(0),o=Math.abs(r),a=e>="A"&&e<="Z",l=e>="a"&&e<="z",c=t>="A"&&t<="Z",u=t>="a"&&t<="z";if(a&&u||l&&c){let h=n!==void 0?`..${n}`:"";throw new pr(`{${e}..${t}${h}}: invalid sequence`)}let f=[];if(s<=i)for(let h=s,p=0;h<=i&&p<zi;h+=o,p++)f.push(String.fromCharCode(h));else for(let h=s,p=0;h>=i&&p<zi;h-=o,p++)f.push(String.fromCharCode(h));return f}function Gl(e,t,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:Sw(e,t,n,r,s),literal:`{${e}..${t}${i}}`}:typeof e=="string"&&typeof t=="string"?{expanded:Cw(e,t,n),literal:`{${e}..${t}${i}}`}:{expanded:null,literal:`{${e}..${t}${i}}`}}var zi,Fm=I(()=>{"use strict";xe();zi=1e4});function Um(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!=="SimpleCommand")return null;let s=r;if(s.name!==null||s.args.length!==0||s.assignments.length!==0||s.redirections.length!==1)return null;let i=s.redirections[0];return i.operator!=="<"||i.target.type!=="Word"?null:{target:i.target}}var Wm=I(()=>{"use strict"});function mn(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function Vl(e){let t="",n=0;for(;n<e.length;)e[n]==="\\"&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function $t(e){return e.replace(/([*?[\]\\()|])/g,"\\$1")}function Tr(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}var Pr=I(()=>{"use strict"});function be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Dr=I(()=>{"use strict"});function me(e,t,n=!1){let r="",s=0;for(;s<e.length;){let i=e[s];if(n&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<e.length&&e[s+1]==="("){let o=Nw(e,s+1);if(o!==-1){let a=e.slice(s+2,o),c=kw(a).map(f=>me(f,t,n)),u=c.length>0?c.join("|"):"(?:)";i==="@"?r+=`(?:${u})`:i==="*"?r+=`(?:${u})*`:i==="+"?r+=`(?:${u})+`:i==="?"?r+=`(?:${u})?`:i==="!"&&(r+=`(?!(?:${u})$).*`),s=o+1;continue}}if(i==="\\")if(s+1<e.length){let o=e[s+1];/[\\^$.|+(){}[\]*?]/.test(o)?r+=`\\${o}`:r+=o,s+=2}else r+="\\\\",s++;else if(i==="*")r+=t?".*":".*?",s++;else if(i==="?")r+=".",s++;else if(i==="["){let o=vw(e,s);if(o===-1)r+="\\[",s++;else{let a=e.slice(s+1,o);r+=Iw(a),s=o+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function Nw(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function kw(e){let t=[],n="",r=0,s=0;for(;s<e.length;){let i=e[s];if(i==="\\"){n+=i,s+1<e.length?(n+=e[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(t.push(n),n=""):n+=i,s++}return t.push(n),t}function vw(e,t){let n=t+1;for(n<e.length&&e[n]==="^"&&n++,n<e.length&&e[n]==="]"&&n++;n<e.length;){if(e[n]==="\\"&&n+1<e.length){n+=2;continue}if(e[n]==="]")return n;if(e[n]==="'"){let r=e.indexOf("'",n+1);if(r!==-1){n=r+1;continue}}if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let r=e.indexOf(":]",n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function Iw(e){let t="[",n=0;for((e[0]==="^"||e[0]==="!")&&(t+="^",n++);n<e.length;){if(e[n]==="'"){let s=e.indexOf("'",n+1);if(s!==-1){let i=e.slice(n+1,s);for(let o of i)o==="\\"?t+="\\\\":o==="]"?t+="\\]":o==="^"&&t==="["?t+="\\^":t+=o;n=s+1;continue}}if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let s=e.indexOf(":]",n+2);if(s!==-1){let i=e.slice(n+2,s);t+=Ow(i),n=s+2;continue}}let r=e[n];r==="\\"?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+="\\\\",n++):r==="-"&&n>0&&n<e.length-1?(t+="-",n++):r==="^"&&n===0?(t+="^",n++):(r==="]"&&n===0?t+="\\]":t+=r,n++)}return t+="]",t}function Ow(e){return Rw.get(e)??""}var Rw,Lr=I(()=>{"use strict";Rw=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]])});function Sn(e,t,n,r){if(n==="prefix")return V(`^${t}`,"s").replace(e,"");let s=V(`${t}$`,"s");if(r)return s.replace(e,"");for(let i=e.length;i>=0;i--){let o=e.slice(i);if(s.test(o))return e.slice(0,i)}return e}function _r(e,t){let n=Array.from(e.state.env.keys()),r=new Set,s=e.state.associativeArrays??new Set,i=new Set;for(let a of n){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l&&i.add(l[1]);let c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&i.add(c[1])}let o=a=>{for(let l of s){let c=`${l}_`;if(a.startsWith(c)&&a!==l)return!0}return!1};for(let a of n)if(a.startsWith(t))if(a.includes("__")){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);l?.[1].startsWith(t)&&r.add(l[1])}else if(/_\d+$/.test(a)){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l?.[1].startsWith(t)&&r.add(l[1])}else o(a)||r.add(a);return[...r].sort()}var nr=I(()=>{"use strict";Me()});function $w(e,t){let n=(i,o=2)=>String(i).padStart(o,"0");if(e===""){let i=n(t.getHours()),o=n(t.getMinutes()),a=n(t.getSeconds());return`${i}:${o}:${a}`}let r="",s=0;for(;s<e.length;)if(e[s]==="%"){if(s+1>=e.length){r+="%",s++;continue}let i=e[s+1];switch(i){case"H":r+=n(t.getHours());break;case"M":r+=n(t.getMinutes());break;case"S":r+=n(t.getSeconds());break;case"d":r+=n(t.getDate());break;case"m":r+=n(t.getMonth()+1);break;case"Y":r+=t.getFullYear();break;case"y":r+=n(t.getFullYear()%100);break;case"I":{let o=t.getHours()%12;o===0&&(o=12),r+=n(o);break}case"p":r+=t.getHours()<12?"AM":"PM";break;case"P":r+=t.getHours()<12?"am":"pm";break;case"%":r+="%";break;case"a":{r+=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()];break}case"b":{r+=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()];break}default:r+=`%${i}`}s+=2}else r+=e[s],s++;return r}function ws(e,t){let n="",r=0,s=e.state.env.get("USER")||e.state.env.get("LOGNAME")||"user",i=e.state.env.get("HOSTNAME")||"localhost",o=i.split(".")[0],a=e.state.env.get("PWD")||"/",l=e.state.env.get("HOME")||"/",c=a.startsWith(l)?`~${a.slice(l.length)}`:a,u=a.split("/").pop()||a,f=new Date,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],p=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=e.state.env.get("__COMMAND_NUMBER")||"1";for(;r<t.length;){let d=t[r];if(d==="\\"){if(r+1>=t.length){n+="\\",r++;continue}let g=t[r+1];if(g>="0"&&g<="7"){let y="",w=r+1;for(;w<t.length&&w<r+4&&t[w]>="0"&&t[w]<="7";)y+=t[w],w++;let b=Number.parseInt(y,8)%256;n+=String.fromCharCode(b),r=w;continue}switch(g){case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"e":n+="\x1B",r+=2;break;case"n":n+=`
772
+ `,""):e.state.env.get(`${o}_${m}`)||""}let u=e.state.env.get(`${o}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(o);if(f!==void 0)return f}if(n&&e.state.options.nounset)throw new gt(`${o}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let o=e.state.env.get(t);if(o===void 0&&n&&e.state.options.nounset)throw new gt(t);return o||""}if(Te(e,t)){let o=xt(e,t);if(o===void 0)return"";if(o!==t)return await Se(e,o,n,r);let a=e.state.env.get(t);if((a===void 0||a==="")&&n&&e.state.options.nounset)throw new gt(t);return a||""}let i=e.state.env.get(t);if(i!==void 0)return e.state.tempEnvBindings?.some(o=>o.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),i;if(An(e,t)){let o=e.state.env.get(`${t}_0`);return o!==void 0?o:""}if(n&&e.state.options.nounset)throw new gt(t);return""}async function dn(e,t){if(new Set(["?","$","#","_","-","0","PPID","UID","EUID","RANDOM","SECONDS","BASH_VERSION","!","BASHPID","LINENO"]).has(t))return!0;if(t==="@"||t==="*")return Number.parseInt(e.state.env.get("#")||"0",10)>0;if(t==="PWD"||t==="OLDPWD")return e.state.env.has(t);let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(r){let s=r[1],i=r[2];if(Te(e,s)){let l=xt(e,s);if(l&&l!==s){if(l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;s=l}}if(i==="@"||i==="*")return ae(e,s).length>0?!0:e.state.env.has(s);if(e.state.associativeArrays?.has(s)){let l=Ui(i);return e.state.env.has(`${s}_${l}`)}let a;if(/^-?\d+$/.test(i))a=Number.parseInt(i,10);else try{let l=new ce,c=Ae(l,i);a=await J(e,c.expression)}catch{let l=e.state.env.get(i);a=l?Number.parseInt(l,10):0,Number.isNaN(a)&&(a=0)}if(a<0){let l=ae(e,s);if(l.length===0)return!1;let u=Math.max(...l.map(([f])=>typeof f=="number"?f:0))+1+a;return u<0?!1:e.state.env.has(`${s}_${u}`)}return e.state.env.has(`${s}_${a}`)}if(Te(e,t)){let s=xt(e,t);return s===void 0||s===t?e.state.env.has(t):dn(e,s)}return!!(e.state.env.has(t)||An(e,t))}var Rt=I(()=>{"use strict";pt();Qe();fl();Et();xe();Zt();Wt();en()});async function _m(e,t){let n="",r=0;for(;r<t.length;){if(t[r]==="$"){if(t[r+1]==="{"){let s=1,i=r+2;for(;i<t.length&&s>0;)t[i]==="{"?s++:t[i]==="}"&&s--,i++;n+=t.slice(r,i),r=i;continue}if(t[r+1]==="("){let s=1,i=r+2;for(;i<t.length&&s>0;)t[i]==="("?s++:t[i]===")"&&s--,i++;n+=t.slice(r,i),r=i;continue}if(/[a-zA-Z_]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await Se(e,i);n+=o,r=s;continue}if(/[0-9]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[0-9]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await Se(e,i);n+=o,r=s;continue}if(/[*@#?\-!$]/.test(t[r+1]||"")){let s=t[r+1],i=await Se(e,s);n+=i,r+=2;continue}}if(t[r]==='"'){for(n+='"',r++;r<t.length&&t[r]!=='"';)if(t[r]==="$"&&/[a-zA-Z_]/.test(t[r+1]||"")){let s=r+1;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)s++;let i=t.slice(r+1,s),o=await Se(e,i);n+=o,r=s}else t[r]==="\\"?(n+=t[r],r++,r<t.length&&(n+=t[r],r++)):(n+=t[r],r++);r<t.length&&(n+='"',r++);continue}n+=t[r],r++}return n}async function jl(e,t){let n=t,r=t.startsWith('"')&&t.endsWith('"'),s=t.startsWith("'")&&t.endsWith("'");if((r||s)&&(n=t.slice(1,-1)),s)return n;let i="",o=0;for(;o<n.length;)if(n[o]==="$")if(n[o+1]==="("){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="("&&n[l-1]==="$"||n[l]==="("?a++:n[l]===")"&&a--,l++;let c=n.slice(o+2,l-1);if(e.execFn){let u=await e.execFn(c);i+=u.stdout.replace(/\n+$/,""),u.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+u.stderr)}o=l}else if(n[o+1]==="{"){let a=1,l=o+2;for(;l<n.length&&a>0;)n[l]==="{"?a++:n[l]==="}"&&a--,l++;let c=n.slice(o+2,l-1),u=await Se(e,c);i+=u,o=l}else if(/[a-zA-Z_]/.test(n[o+1]||"")){let a=o+1;for(;a<n.length&&/[a-zA-Z0-9_]/.test(n[a]);)a++;let l=n.slice(o+1,a),c=await Se(e,l);i+=c,o=a}else i+=n[o],o++;else if(n[o]==="`"){let a=o+1;for(;a<n.length&&n[a]!=="`";)a++;let l=n.slice(o+1,a);if(e.execFn){let c=await e.execFn(l);i+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}o=a+1}else i+=n[o],o++;return i}var Mm=I(()=>{"use strict";Rt()});function Sw(e,t,n,r,s){let i=n??1;i===0&&(i=1);let o=Math.abs(i),a=[],l=0;r?.match(/^-?0\d/)&&(l=Math.max(l,r.replace(/^-/,"").length)),s?.match(/^-?0\d/)&&(l=Math.max(l,s.replace(/^-/,"").length));let c=u=>{if(l>0){let f=u<0,h=String(Math.abs(u)).padStart(l,"0");return f?`-${h}`:h}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<zi;u+=o,f++)a.push(c(u));else for(let u=e,f=0;u>=t&&f<zi;u-=o,f++)a.push(c(u));return a}function Cw(e,t,n){let r=n??1;r===0&&(r=1);let s=e.charCodeAt(0),i=t.charCodeAt(0),o=Math.abs(r),a=e>="A"&&e<="Z",l=e>="a"&&e<="z",c=t>="A"&&t<="Z",u=t>="a"&&t<="z";if(a&&u||l&&c){let h=n!==void 0?`..${n}`:"";throw new pr(`{${e}..${t}${h}}: invalid sequence`)}let f=[];if(s<=i)for(let h=s,p=0;h<=i&&p<zi;h+=o,p++)f.push(String.fromCharCode(h));else for(let h=s,p=0;h>=i&&p<zi;h-=o,p++)f.push(String.fromCharCode(h));return f}function Gl(e,t,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:Sw(e,t,n,r,s),literal:`{${e}..${t}${i}}`}:typeof e=="string"&&typeof t=="string"?{expanded:Cw(e,t,n),literal:`{${e}..${t}${i}}`}:{expanded:null,literal:`{${e}..${t}${i}}`}}var zi,Fm=I(()=>{"use strict";xe();zi=1e4});function Um(e){if(e.statements.length!==1)return null;let t=e.statements[0];if(t.operators.length!==0||t.pipelines.length!==1)return null;let n=t.pipelines[0];if(n.negated||n.commands.length!==1)return null;let r=n.commands[0];if(r.type!=="SimpleCommand")return null;let s=r;if(s.name!==null||s.args.length!==0||s.assignments.length!==0||s.redirections.length!==1)return null;let i=s.redirections[0];return i.operator!=="<"||i.target.type!=="Word"?null:{target:i.target}}var Wm=I(()=>{"use strict"});function mn(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function Vl(e){let t="",n=0;for(;n<e.length;)e[n]==="\\"&&n+1<e.length?(t+=e[n+1],n+=2):(t+=e[n],n++);return t}function $t(e){return e.replace(/([*?[\]\\()|])/g,"\\$1")}function Tr(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}var Pr=I(()=>{"use strict"});function be(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Dr=I(()=>{"use strict"});function me(e,t,n=!1){let r="",s=0;for(;s<e.length;){let i=e[s];if(n&&(i==="@"||i==="*"||i==="+"||i==="?"||i==="!")&&s+1<e.length&&e[s+1]==="("){let o=Nw(e,s+1);if(o!==-1){let a=e.slice(s+2,o),c=kw(a).map(f=>me(f,t,n)),u=c.length>0?c.join("|"):"(?:)";i==="@"?r+=`(?:${u})`:i==="*"?r+=`(?:${u})*`:i==="+"?r+=`(?:${u})+`:i==="?"?r+=`(?:${u})?`:i==="!"&&(r+=`(?!(?:${u})$).*`),s=o+1;continue}}if(i==="\\")if(s+1<e.length){let o=e[s+1];/[\\^$.|+(){}[\]*?]/.test(o)?r+=`\\${o}`:r+=o,s+=2}else r+="\\\\",s++;else if(i==="*")r+=t?".*":".*?",s++;else if(i==="?")r+=".",s++;else if(i==="["){let o=vw(e,s);if(o===-1)r+="\\[",s++;else{let a=e.slice(s+1,o);r+=Iw(a),s=o+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function Nw(e,t){let n=1,r=t+1;for(;r<e.length&&n>0;){let s=e[r];if(s==="\\"){r+=2;continue}if(s==="(")n++;else if(s===")"&&(n--,n===0))return r;r++}return-1}function kw(e){let t=[],n="",r=0,s=0;for(;s<e.length;){let i=e[s];if(i==="\\"){n+=i,s+1<e.length?(n+=e[s+1],s+=2):s++;continue}i==="("?(r++,n+=i):i===")"?(r--,n+=i):i==="|"&&r===0?(t.push(n),n=""):n+=i,s++}return t.push(n),t}function vw(e,t){let n=t+1;for(n<e.length&&e[n]==="^"&&n++,n<e.length&&e[n]==="]"&&n++;n<e.length;){if(e[n]==="\\"&&n+1<e.length){n+=2;continue}if(e[n]==="]")return n;if(e[n]==="'"){let r=e.indexOf("'",n+1);if(r!==-1){n=r+1;continue}}if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let r=e.indexOf(":]",n+2);if(r!==-1){n=r+2;continue}}n++}return-1}function Iw(e){let t="[",n=0;for((e[0]==="^"||e[0]==="!")&&(t+="^",n++);n<e.length;){if(e[n]==="'"){let s=e.indexOf("'",n+1);if(s!==-1){let i=e.slice(n+1,s);for(let o of i)o==="\\"?t+="\\\\":o==="]"?t+="\\]":o==="^"&&t==="["?t+="\\^":t+=o;n=s+1;continue}}if(e[n]==="["&&n+1<e.length&&e[n+1]===":"){let s=e.indexOf(":]",n+2);if(s!==-1){let i=e.slice(n+2,s);t+=Rw(i),n=s+2;continue}}let r=e[n];r==="\\"?n+1<e.length?(t+=`\\${e[n+1]}`,n+=2):(t+="\\\\",n++):r==="-"&&n>0&&n<e.length-1?(t+="-",n++):r==="^"&&n===0?(t+="^",n++):(r==="]"&&n===0?t+="\\]":t+=r,n++)}return t+="]",t}function Rw(e){return Ow.get(e)??""}var Ow,Lr=I(()=>{"use strict";Ow=new Map([["alnum","a-zA-Z0-9"],["alpha","a-zA-Z"],["ascii","\\x00-\\x7F"],["blank"," \\t"],["cntrl","\\x00-\\x1F\\x7F"],["digit","0-9"],["graph","!-~"],["lower","a-z"],["print"," -~"],["punct","!-/:-@\\[-`{-~"],["space"," \\t\\n\\r\\f\\v"],["upper","A-Z"],["word","a-zA-Z0-9_"],["xdigit","0-9A-Fa-f"]])});function Sn(e,t,n,r){if(n==="prefix")return V(`^${t}`,"s").replace(e,"");let s=V(`${t}$`,"s");if(r)return s.replace(e,"");for(let i=e.length;i>=0;i--){let o=e.slice(i);if(s.test(o))return e.slice(0,i)}return e}function _r(e,t){let n=Array.from(e.state.env.keys()),r=new Set,s=e.state.associativeArrays??new Set,i=new Set;for(let a of n){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l&&i.add(l[1]);let c=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&i.add(c[1])}let o=a=>{for(let l of s){let c=`${l}_`;if(a.startsWith(c)&&a!==l)return!0}return!1};for(let a of n)if(a.startsWith(t))if(a.includes("__")){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);l?.[1].startsWith(t)&&r.add(l[1])}else if(/_\d+$/.test(a)){let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l?.[1].startsWith(t)&&r.add(l[1])}else o(a)||r.add(a);return[...r].sort()}var nr=I(()=>{"use strict";Me()});function $w(e,t){let n=(i,o=2)=>String(i).padStart(o,"0");if(e===""){let i=n(t.getHours()),o=n(t.getMinutes()),a=n(t.getSeconds());return`${i}:${o}:${a}`}let r="",s=0;for(;s<e.length;)if(e[s]==="%"){if(s+1>=e.length){r+="%",s++;continue}let i=e[s+1];switch(i){case"H":r+=n(t.getHours());break;case"M":r+=n(t.getMinutes());break;case"S":r+=n(t.getSeconds());break;case"d":r+=n(t.getDate());break;case"m":r+=n(t.getMonth()+1);break;case"Y":r+=t.getFullYear();break;case"y":r+=n(t.getFullYear()%100);break;case"I":{let o=t.getHours()%12;o===0&&(o=12),r+=n(o);break}case"p":r+=t.getHours()<12?"AM":"PM";break;case"P":r+=t.getHours()<12?"am":"pm";break;case"%":r+="%";break;case"a":{r+=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][t.getDay()];break}case"b":{r+=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()];break}default:r+=`%${i}`}s+=2}else r+=e[s],s++;return r}function ws(e,t){let n="",r=0,s=e.state.env.get("USER")||e.state.env.get("LOGNAME")||"user",i=e.state.env.get("HOSTNAME")||"localhost",o=i.split(".")[0],a=e.state.env.get("PWD")||"/",l=e.state.env.get("HOME")||"/",c=a.startsWith(l)?`~${a.slice(l.length)}`:a,u=a.split("/").pop()||a,f=new Date,h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],p=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=e.state.env.get("__COMMAND_NUMBER")||"1";for(;r<t.length;){let d=t[r];if(d==="\\"){if(r+1>=t.length){n+="\\",r++;continue}let g=t[r+1];if(g>="0"&&g<="7"){let y="",w=r+1;for(;w<t.length&&w<r+4&&t[w]>="0"&&t[w]<="7";)y+=t[w],w++;let b=Number.parseInt(y,8)%256;n+=String.fromCharCode(b),r=w;continue}switch(g){case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"e":n+="\x1B",r+=2;break;case"n":n+=`
773
773
  `,r+=2;break;case"r":n+="\r",r+=2;break;case"$":n+="$",r+=2;break;case"[":case"]":r+=2;break;case"u":n+=s,r+=2;break;case"h":n+=o,r+=2;break;case"H":n+=i,r+=2;break;case"w":n+=c,r+=2;break;case"W":n+=u,r+=2;break;case"d":{let y=String(f.getDate()).padStart(2," ");n+=`${h[f.getDay()]} ${p[f.getMonth()]} ${y}`,r+=2;break}case"t":{let y=String(f.getHours()).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0"),b=String(f.getSeconds()).padStart(2,"0");n+=`${y}:${w}:${b}`,r+=2;break}case"T":{let y=f.getHours()%12;y===0&&(y=12);let w=String(y).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),x=String(f.getSeconds()).padStart(2,"0");n+=`${w}:${b}:${x}`,r+=2;break}case"@":{let y=f.getHours()%12;y===0&&(y=12);let w=String(y).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),x=f.getHours()<12?"AM":"PM";n+=`${w}:${b} ${x}`,r+=2;break}case"A":{let y=String(f.getHours()).padStart(2,"0"),w=String(f.getMinutes()).padStart(2,"0");n+=`${y}:${w}`,r+=2;break}case"D":if(r+2<t.length&&t[r+2]==="{"){let y=t.indexOf("}",r+3);if(y!==-1){let w=t.slice(r+3,y);n+=$w(w,f),r=y+1}else n+="\\D",r+=2}else n+="\\D",r+=2;break;case"s":n+="bash",r+=2;break;case"v":n+="5.0",r+=2;break;case"V":n+="5.0.0",r+=2;break;case"j":n+="0",r+=2;break;case"l":n+="tty",r+=2;break;case"#":n+=m,r+=2;break;case"!":n+=m,r+=2;break;case"x":n+="\\x",r+=2;break;default:n+=`\\${g}`,r+=2}}else n+=d,r++}return n}var ql=I(()=>{"use strict"});function Ln(e){if(e==="")return"''";if(/[\n\r\t\x00-\x1f\x7f']/.test(e)){let n="$'";for(let r of e)switch(r){case"'":n+="\\'";break;case"\\":n+="\\\\";break;case`
774
774
  `:n+="\\n";break;case"\r":n+="\\r";break;case" ":n+="\\t";break;default:{let s=r.charCodeAt(0);s<32||s===127?n+=`\\${s.toString(8).padStart(3,"0")}`:n+=r}}return`${n}'`}return`'${e}'`}var Zl=I(()=>{"use strict"});function Tt(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function gn(e,t){return e.state.readonlyVars?.has(t)??!1}function rt(e,t,n="bash"){if(gn(e,t)){let r=`${n}: ${t}: readonly variable
775
775
  `;throw new pe(1,"",r)}return null}function tn(e,t){let n=e.state.exportedVars?.has(t)??!1;if(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(t),e.state.localScopes.length>0&&e.state.localScopes[e.state.localScopes.length-1].has(t)&&!n){for(e.state.localExportedVars||(e.state.localExportedVars=[]);e.state.localExportedVars.length<e.state.localScopes.length;)e.state.localExportedVars.push(new Set);e.state.localExportedVars[e.state.localExportedVars.length-1].add(t)}}function ji(e,t){e.state.exportedVars?.delete(t)}var _n=I(()=>{"use strict";xe()});function Mn(e,t){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t))return"";let n="",r=e.state.env.has(`${t}__length`)||Array.from(e.state.env.keys()).some(i=>i.startsWith(`${t}_`)&&/^[0-9]+$/.test(i.slice(t.length+1))),s=e.state.associativeArrays?.has(t)??!1;return r&&!s&&(n+="a"),s&&(n+="A"),e.state.integerVars?.has(t)&&(n+="i"),Te(e,t)&&(n+="n"),gn(e,t)&&(n+="r"),e.state.exportedVars?.has(t)&&(n+="x"),n}var Gi=I(()=>{"use strict";en();_n()});async function Bm(e,t,n,r){return(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function Hm(e,t,n,r,s){if((r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let o=await s(e,n.word.parts,r.inDoubleQuotes),a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let[,l,c]=a,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let h=new ce,p=Ae(h,c);u=await J(e,p.expression)}catch{let h=e.state.env.get(c);u=h?Number.parseInt(h,10):0}Number.isNaN(u)&&(u=0)}e.state.env.set(`${l}_${u}`,o);let f=Number.parseInt(e.state.env.get(`${l}__length`)||"0",10);u>=f&&e.state.env.set(`${l}__length`,String(u+1))}else e.state.env.set(t,o);return o}return r.effectiveValue}async function zm(e,t,n,r,s){if(r.isUnset||n.checkEmpty&&r.isEmpty){let o=n.word?await s(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new pe(1,"",`bash: ${o}
776
776
  `)}return r.effectiveValue}async function jm(e,t,n,r){return!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):""}async function Gm(e,t,n,r,s){let i="",o=e.state.shoptOptions.extglob;if(n.pattern)for(let l of n.pattern.parts)if(l.type==="Glob")i+=me(l.pattern,n.greedy,o);else if(l.type==="Literal")i+=me(l.value,n.greedy,o);else if(l.type==="SingleQuoted"||l.type==="Escaped")i+=be(l.value);else if(l.type==="DoubleQuoted"){let c=await r(e,l.parts);i+=be(c)}else if(l.type==="ParameterExpansion"){let c=await s(e,l);i+=me(c,n.greedy,o)}else{let c=await s(e,l);i+=be(c)}if(n.side==="prefix")return V(`^${i}`,"s").replace(t,"");let a=V(`${i}$`,"s");if(n.greedy)return a.replace(t,"");for(let l=t.length;l>=0;l--){let c=t.slice(l);if(a.test(c))return t.slice(0,l)}return t}async function Vm(e,t,n,r,s){let i="",o=e.state.shoptOptions.extglob;if(n.pattern)for(let c of n.pattern.parts)if(c.type==="Glob")i+=me(c.pattern,!0,o);else if(c.type==="Literal")i+=me(c.value,!0,o);else if(c.type==="SingleQuoted"||c.type==="Escaped")i+=be(c.value);else if(c.type==="DoubleQuoted"){let u=await r(e,c.parts);i+=be(u)}else if(c.type==="ParameterExpansion"){let u=await s(e,c);i+=me(u,!0,o)}else{let u=await s(e,c);i+=be(u)}let a=n.replacement?await r(e,n.replacement.parts):"";if(n.anchor==="start"?i=`^${i}`:n.anchor==="end"&&(i=`${i}$`),i==="")return t;let l=n.all?"gs":"s";try{let c=V(i,l);if(n.all){let u="",f=0,h=c.exec(t);for(;h!==null&&!(h[0].length===0&&h.index===t.length);)u+=t.slice(f,h.index)+a,f=h.index+h[0].length,h[0].length===0&&f++,h=c.exec(t);return u+=t.slice(f),u}return c.replace(t,a)}catch{return t}}function qm(e,t,n){let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let s=r[1],i=ae(e,s);return i.length>0?String(i.length):e.state.env.get(s)!==void 0?"1":"0"}if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)&&An(e,t)){if(t==="FUNCNAME"){let i=e.state.funcNameStack?.[0]||"";return String([...i].length)}if(t==="BASH_LINENO"){let i=e.state.callLineStack?.[0];return String(i!==void 0?[...String(i)].length:0)}let s=e.state.env.get(`${t}_0`)||"";return String([...s].length)}return String([...n].length)}async function Zm(e,t,n,r){let s=await J(e,r.offset.expression),i=r.length?await J(e,r.length.expression):void 0;if(t==="@"||t==="*"){let c=Number.parseInt(e.state.env.get("#")||"0",10),u=[];for(let m=1;m<=c;m++)u.push(e.state.env.get(String(m))||"");let f=e.state.env.get("0")||"bash",h,p;if(s<=0)if(h=[f,...u],s<0){if(p=h.length+s,p<0)return""}else p=0;else h=u,p=s-1;if(p<0||p>=h.length)return"";if(i!==void 0){let m=i<0?h.length+i:p+i;return h.slice(p,Math.max(p,m)).join(" ")}return h.slice(p).join(" ")}let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(o){let c=o[1];if(e.state.associativeArrays?.has(c))throw new pe(1,"",`bash: \${${c}[@]: 0: 3}: bad substitution
777
777
  `);let u=ae(e,c),f=0;if(s<0){if(u.length>0){let h=u[u.length-1][0],m=(typeof h=="number"?h:0)+1+s;if(m<0||(f=u.findIndex(([d])=>typeof d=="number"&&d>=m),f<0))return""}}else if(f=u.findIndex(([h])=>typeof h=="number"&&h>=s),f<0)return"";if(i!==void 0){if(i<0)throw new $e(`${o[1]}[@]: substring expression < 0`);return u.slice(f,f+i).map(([,h])=>h).join(" ")}return u.slice(f).map(([,h])=>h).join(" ")}let a=[...n],l=s;if(l<0&&(l=Math.max(0,a.length+l)),i!==void 0){if(i<0){let c=a.length+i;return a.slice(l,Math.max(l,c)).join("")}return a.slice(l,l+i).join("")}return a.slice(l).join("")}async function Qm(e,t,n,r,s){if(n.pattern){let i=e.state.shoptOptions.extglob,o="";for(let f of n.pattern.parts)if(f.type==="Glob")o+=me(f.pattern,!0,i);else if(f.type==="Literal")o+=me(f.value,!0,i);else if(f.type==="SingleQuoted"||f.type==="Escaped")o+=be(f.value);else if(f.type==="DoubleQuoted"){let h=await r(e,f.parts);o+=be(h)}else if(f.type==="ParameterExpansion"){let h=await s(e,f);o+=me(h,!0,i)}let a=V(`^(?:${o})$`),l=n.direction==="upper"?f=>f.toUpperCase():f=>f.toLowerCase(),c="",u=!1;for(let f of t)!n.all&&u?c+=f:a.test(f)?(c+=l(f),u=!0):c+=f;return c}return n.direction==="upper"?n.all?t.toUpperCase():t.charAt(0).toUpperCase()+t.slice(1):n.all?t.toLowerCase():t.charAt(0).toLowerCase()+t.slice(1)}function Km(e,t,n,r,s){let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(i&&s.operator==="Q")return ae(e,i[1]).map(([,c])=>Ln(c)).join(" ");if(i&&s.operator==="a")return Mn(e,i[1]);let o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(o&&s.operator==="a")return Mn(e,o[1]);switch(s.operator){case"Q":return r?"":Ln(n);case"P":return ws(e,n);case"a":return Mn(e,t);case"A":return r?"":`${t}=${Ln(n)}`;case"E":return n.replace(/\\([\\abefnrtv'"?])/g,(a,l)=>{switch(l){case"\\":return"\\";case"a":return"\x07";case"b":return"\b";case"e":return"\x1B";case"f":return"\f";case"n":return`
778
- `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return l}});case"K":case"k":return r?"":Ln(n);case"u":return n.charAt(0).toUpperCase()+n.slice(1);case"U":return n.toUpperCase();case"L":return n.toLowerCase();default:return n}}async function Xm(e,t,n,r,s,i,o=!1){if(Te(e,t))return tr(e,t)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new yt(`\${!${t}}`)}let l=n;if(a&&(l===""||l.includes(" ")))throw new yt(`\${!${t}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new yt(`\${!${t}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(e,u,o)}return await Se(e,l)}function Ym(e,t){let r=ae(e,t.array).map(([s])=>String(s));return t.star?r.join(fe(e.state.env)):r.join(" ")}function Jm(e,t){let n=_r(e,t.prefix);return t.star?n.join(fe(e.state.env)):n.join(" ")}function e2(e,t,n,r){let s=Number.parseInt(e.state.env.get("#")||"0",10),i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t==="*")return{isEmpty:s===0,effectiveValue:n};if(t==="@")return{isEmpty:s===0||s===1&&e.state.env.get("1")==="",effectiveValue:n};if(i){let[,o,a]=i,l=ae(e,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=fe(e.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:r?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:n==="",effectiveValue:n}}var t2=I(()=>{"use strict";pt();Qe();Me();Et();xe();Wt();en();Dr();Lr();nr();ql();Zl();Ot();Gi()});function n2(e){let t=0;for(;t<e.length;){let n=e[t];if(n==="\\"&&t+1<e.length){t+=2;continue}if(n==="'"){let r=e.indexOf("'",t+1);if(r!==-1){t=r+1;continue}}if(n==="$"&&t+1<e.length&&e[t+1]==="("||n==="`")return!0;t++}return!1}function r2(e,t){let n=1,r=t,s=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r];if(o==="\\"&&!s&&r+1<e.length){r+=2;continue}if(o==="'"&&!i){s=!s,r++;continue}if(o==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(o==="(")n++;else if(o===")"&&(n--,n===0))return r}r++}return-1}async function Vi(e,t){let n=new ce,r;try{r=n.parse(t)}catch{return""}let s=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let i=new Map(e.state.env),o=e.state.cwd,a=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let l=await e.executeScript(r),c=l.exitCode;return e.state.env=i,e.state.cwd=o,e.state.suppressVerbose=a,e.state.lastExitCode=c,e.state.env.set("?",String(c)),l.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+l.stderr),e.state.bashPid=s,l.stdout.replace(/\n+$/,"")}catch(l){if(e.state.env=i,e.state.cwd=o,e.state.bashPid=s,e.state.suppressVerbose=a,l instanceof re)throw l;return l instanceof pe?(e.state.lastExitCode=l.exitCode,e.state.env.set("?",String(l.exitCode)),l.stdout?.replace(/\n+$/,"")??""):""}}function Ql(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=$t(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=Tw(e,a);n+=$t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}function Tw(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}async function s2(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=$t(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=await Pw(e,a);n+=$t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=r2(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}async function Pw(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=r2(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}var i2=I(()=>{"use strict";Qe();xe();Pr()});function o2(e,t){if(!t.startsWith("~"))return t;let n=e.state.env.get("HOME")!==void 0?e.state.env.get("HOME"):"/home/user";if(t==="~"||t.startsWith("~/"))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let s=t.slice(1,r),i=t.slice(r);return i!==""&&!i.startsWith("/")?t:s==="root"?`/root${i}`:t}var a2=I(()=>{"use strict"});async function Dw(e,t,n,r){let s="";for(let i of t.parts)if(i.type==="Glob")s+=me(i.pattern,!0,e.state.shoptOptions.extglob);else if(i.type==="Literal")s+=me(i.value,!0,e.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=be(i.value);else if(i.type==="DoubleQuoted"){let o=await n(e,i.parts);s+=be(o)}else if(i.type==="ParameterExpansion"){let o=await r(e,i);s+=me(o,!0,e.state.shoptOptions.extglob)}else{let o=await r(e,i);s+=be(o)}return s}async function l2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=ae(e,a),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env.get(a);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h="";c.pattern&&(h=await Dw(e,c.pattern,n,r));let p=c.replacement?await n(e,c.replacement.parts):"",m=h;c.anchor==="start"?m=`^${h}`:c.anchor==="end"&&(m=`${h}$`);let d=[];try{let g=V(m,c.all?"g":"");for(let y of f)d.push(g.replace(y,p))}catch{d.push(...f)}if(l){let g=fe(e.state.env);return{values:[d.join(g)],quoted:!0}}return{values:d,quoted:!0}}async function c2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=ae(e,a),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env.get(a);d!==void 0&&f.push(d)}if(f.length===0)return{values:[],quoted:!0};let h="",p=e.state.shoptOptions.extglob;if(c.pattern)for(let d of c.pattern.parts)if(d.type==="Glob")h+=me(d.pattern,c.greedy,p);else if(d.type==="Literal")h+=me(d.value,c.greedy,p);else if(d.type==="SingleQuoted"||d.type==="Escaped")h+=be(d.value);else if(d.type==="DoubleQuoted"){let g=await n(e,d.parts);h+=be(g)}else if(d.type==="ParameterExpansion"){let g=await r(e,d);h+=me(g,c.greedy,p)}else{let g=await r(e,d);h+=be(g)}let m=[];for(let d of f)m.push(Sn(d,h,c.side,c.greedy));if(l){let d=fe(e.state.env);return{values:[m.join(d)],quoted:!0}}return{values:m,quoted:!0}}var u2=I(()=>{"use strict";Me();Wt();Dr();Lr();nr();Ot()});async function f2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="DefaultValue"&&n.parts[0].operation?.type!=="UseAlternative"&&n.parts[0].operation?.type!=="AssignDefault")return null;let r=n.parts[0],s=r.operation,i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=ae(e,l),u=c.length>0||e.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,p])=>p===""),h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(h&&f):o=!u||h&&f,!o){if(c.length>0){let m=c.map(([,d])=>d);if(a){let d=fe(e.state.env);return{values:[m.join(d)],quoted:!0}}return{values:m,quoted:!0}}let p=e.state.env.get(l);return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await dn(e,l),u=await Se(e,l),f=u==="",h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(h&&f):o=!c||h&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){c=h[1],u=h[2]==="*";break}}if(c){let f=ae(e,c);if(f.length>0){let p=f.map(([,m])=>m);if(u||a){let m=fe(e.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}let h=e.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function h2(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],o=-1,a="",l=!1,c=null;for(let d=0;d<i.parts.length;d++){let g=i.parts[d];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let y=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(y){o=d,a=y[1],l=y[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let d=0;d<o;d++)u+=await r(e,i.parts[d]);let f="";for(let d=o+1;d<i.parts.length;d++)f+=await r(e,i.parts[d]);let h=ae(e,a),p=h.map(([,d])=>d);if(h.length===0){let d=e.state.env.get(a);if(d!==void 0)p=[d];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let d=c,g="",y=e.state.shoptOptions.extglob;if(d.pattern)for(let w of d.pattern.parts)if(w.type==="Glob")g+=me(w.pattern,d.greedy,y);else if(w.type==="Literal")g+=me(w.value,d.greedy,y);else if(w.type==="SingleQuoted"||w.type==="Escaped")g+=be(w.value);else if(w.type==="DoubleQuoted"){let b=await s(e,w.parts);g+=be(b)}else if(w.type==="ParameterExpansion"){let b=await r(e,w);g+=me(b,d.greedy,y)}else{let b=await r(e,w);g+=be(b)}p=p.map(w=>Sn(w,g,d.side,d.greedy))}else if(c?.type==="PatternReplacement"){let d=c,g="";if(d.pattern)for(let b of d.pattern.parts)if(b.type==="Glob")g+=me(b.pattern,!0,e.state.shoptOptions.extglob);else if(b.type==="Literal")g+=me(b.value,!0,e.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")g+=be(b.value);else if(b.type==="DoubleQuoted"){let x=await s(e,b.parts);g+=be(x)}else if(b.type==="ParameterExpansion"){let x=await r(e,b);g+=me(x,!0,e.state.shoptOptions.extglob)}else{let x=await r(e,b);g+=be(x)}let y=d.replacement?await s(e,d.replacement.parts):"",w=g;d.anchor==="start"?w=`^${g}`:d.anchor==="end"&&(w=`${g}$`);try{let b=V(w,d.all?"g":"");p=p.map(x=>b.replace(x,y))}catch{}}if(l){let d=fe(e.state.env);return{values:[u+p.join(d)+f],quoted:!0}}return p.length===1?{values:[u+p[0]+f],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+f],quoted:!0}}async function p2(e,t,n,r){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o="",a=!1;for(let p=0;p<s.parts.length;p++){let m=s.parts[p];if(m.type==="ParameterExpansion"&&!m.operation){let d=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(d){i=p,o=d[1],a=d[2]==="*";break}}}if(i===-1)return null;let l="";for(let p=0;p<i;p++)l+=await r(e,s.parts[p]);let c="";for(let p=i+1;p<s.parts.length;p++)c+=await r(e,s.parts[p]);let u=ae(e,o),f=u.map(([,p])=>p);if(u.length===0){let p=e.state.env.get(o);if(p!==void 0)return{values:[l+p+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let m=l+c;return{values:m?[m]:[],quoted:!0}}if(a){let p=fe(e.state.env);return{values:[l+f.join(p)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var d2=I(()=>{"use strict";Me();Wt();Dr();Lr();nr();Ot()});async function m2(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="Substring")return null;let s=r.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(e.state.associativeArrays?.has(o))throw new pe(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
779
- `);let c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=ae(e,o),h=0;if(c<0){if(f.length>0){let m=f[f.length-1][0],g=(typeof m=="number"?m:0)+1+c;if(g<0)return{values:[],quoted:!0};h=f.findIndex(([y])=>typeof y=="number"&&y>=g),h<0&&(h=f.length)}}else h=f.findIndex(([m])=>typeof m=="number"&&m>=c),h<0&&(h=f.length);let p;if(u!==void 0){if(u<0)throw new $e(`${o}[@]: substring expression < 0`);p=f.slice(h,h+u).map(([,m])=>m)}else p=f.slice(h).map(([,m])=>m);if(p.length===0)return{values:[],quoted:!0};if(a){let m=fe(e.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}function g2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="Transform")return null;let r=n.parts[0],s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=r.operation,l=ae(e,i);if(l.length===0){let f=e.state.env.get(i);if(f!==void 0){let h;switch(a.operator){case"a":h="";break;case"P":h=ws(e,f);break;case"Q":h=Ln(f);break;default:h=f}return{values:[h],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=Mn(e,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>ws(e,f));break;case"Q":u=l.map(([,f])=>Ln(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=fe(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var y2=I(()=>{"use strict";xe();Wt();ql();Zl();Ot();Gi()});function w2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion")return null;let r=n.parts[0];if(r.operation)return null;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(Te(e,i)){let l=tr(e,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=ae(e,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=e.state.env.get(i);return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function b2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation)return null;let s=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!Te(e,s))return null;let i=tr(e,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=ae(e,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=e.state.env.get(a);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var x2=I(()=>{"use strict";en();Ot()});async function E2(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await Se(e,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let m=Number.parseInt(e.state.env.get("#")||"0",10),d=[];for(let g=1;g<=m;g++)d.push(e.state.env.get(String(g))||"");return l==="*"?{values:[d.join(fe(e.state.env))],quoted:!0}:{values:d,quoted:!0}}return null}let u=c[1],f=c[2]==="*",h=ae(e,u);if(a.innerOp){if(a.innerOp.type==="Substring")return Lw(e,h,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return _w(e,h,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let d=Mn(e,u),g=h.map(()=>d);return f?{values:[g.join(fe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let m=[];for(let[,d]of h){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},y=e.state.env.get("_indirect_elem_");e.state.env.set("_indirect_elem_",d);try{let w=await r(e,g,!0);m.push(w)}finally{y!==void 0?e.state.env.set("_indirect_elem_",y):e.state.env.delete("_indirect_elem_")}}return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(h.length>0){let m=h.map(([,d])=>d);return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let p=e.state.env.get(u);return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}async function Lw(e,t,n,r,s){let i=s.offset?await J(e,s.offset.expression):0,o=s.length?await J(e,s.length.expression):void 0,a=0;if(i<0){if(t.length>0){let u=t[t.length-1][0],h=(typeof u=="number"?u:0)+1+i;if(h<0)return{values:[],quoted:!0};if(a=t.findIndex(([p])=>typeof p=="number"&&p>=h),a<0)return{values:[],quoted:!0}}}else if(a=t.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new $e(`${n}[@]: substring expression < 0`);l=t.slice(a,a+o)}else l=t.slice(a);let c=l.map(([,u])=>u);return r?{values:[c.join(fe(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function _w(e,t,n,r,s,i){let o=s.checkEmpty??!1,a=t.map(([,u])=>u),l=t.length===0,c=t.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:r?{values:[a.join(fe(e.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(e,s.word.parts,!0);return e.state.env.set(`${n}_0`,f),e.state.env.set(`${n}__length`,"1"),{values:[f],quoted:!0}}return r?{values:[a.join(fe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}return r?{values:[a.join(fe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}async function A2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="UseAlternative"&&t[0].operation?.type!=="DefaultValue")return null;let n=t[0],r=n.operation,s=r?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await Se(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await dn(e,n.parameter),u=await Se(e,n.parameter)==="",f=r.checkEmpty??!1,h;if(r.type==="UseAlternative"?h=c&&!(f&&u):h=!c||f&&u,h){let p=l[1],m=l[2]==="*",d=ae(e,p);if(d.length>0){let y=d.map(([,w])=>w);return m?{values:[y.join(fe(e.state.env))],quoted:!0}:{values:y,quoted:!0}}let g=e.state.env.get(p);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function S2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="Indirection")return null;let n=t[0],s=n.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await Se(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await Se(e,n.parameter),f=await dn(e,n.parameter),h=u==="",p=s.checkEmpty??!1,m;if(s.type==="UseAlternative"?m=f&&!(p&&h):m=!f||p&&h,m){let d=c[1],g=c[2]==="*",y=ae(e,d);if(y.length>0){let b=y.map(([,x])=>x);return g?{values:[b.join(fe(e.state.env))],quoted:!0}:{values:b,quoted:!0}}let w=e.state.env.get(d);return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var C2=I(()=>{"use strict";Et();xe();Wt();Ot();Gi()});function N2(e){let t=Number.parseInt(e.state.env.get("#")||"0",10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||"");return n}async function k2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let w=0;w<s.parts.length;w++){let b=s.parts[w];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=w,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=Number.parseInt(e.state.env.get("#")||"0",10),h=[];for(let w=1;w<=f;w++)h.push(e.state.env.get(String(w))||"");let p=e.state.env.get("0")||"bash",m;if(c<=0){let w=[p,...h],b=w.length+c;if(b<0)m=[];else{let x=c<0?b:0;if(u!==void 0){let S=u<0?w.length+u:x+u;m=w.slice(x,Math.max(x,S))}else m=w.slice(x)}}else{let w=c-1;if(w>=h.length)m=[];else if(u!==void 0){let b=u<0?h.length+u:w+u;m=h.slice(w,Math.max(w,b))}else m=h.slice(w)}let d="";for(let w=0;w<i;w++)d+=await r(e,s.parts[w]);let g="";for(let w=i+1;w<s.parts.length;w++)g+=await r(e,s.parts[w]);if(m.length===0){let w=d+g;return{values:w?[w]:[],quoted:!0}}if(o){let w=fe(e.state.env);return{values:[d+m.join(w)+g],quoted:!0}}return m.length===1?{values:[d+m[0]+g],quoted:!0}:{values:[d+m[0],...m.slice(1,-1),m[m.length-1]+g],quoted:!0}}async function v2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let w=s.parts[y];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternReplacement"){i=y,o=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=N2(e),u="";for(let y=0;y<i;y++)u+=await n(e,s.parts[y]);let f="";for(let y=i+1;y<s.parts.length;y++)f+=await n(e,s.parts[y]);if(c.length===0){let y=u+f;return{values:y?[y]:[],quoted:!0}}let h="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")h+=me(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")h+=me(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")h+=be(y.value);else if(y.type==="DoubleQuoted"){let w=await r(e,y.parts);h+=be(w)}else if(y.type==="ParameterExpansion"){let w=await n(e,y);h+=me(w,!0,e.state.shoptOptions.extglob)}else{let w=await n(e,y);h+=be(w)}let p=l.replacement?await r(e,l.replacement.parts):"",m=h;l.anchor==="start"?m=`^${h}`:l.anchor==="end"&&(m=`${h}$`);let d=[];try{let y=V(m,l.all?"g":"");for(let w of c)d.push(y.replace(w,p))}catch{d.push(...c)}if(o){let y=fe(e.state.env);return{values:[u+d.join(y)+f],quoted:!0}}return d.length===1?{values:[u+d[0]+f],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+f],quoted:!0}}async function I2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let y=s.parts[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){i=g,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=N2(e),u="";for(let g=0;g<i;g++)u+=await n(e,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await n(e,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let h="",p=e.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")h+=me(g.pattern,l.greedy,p);else if(g.type==="Literal")h+=me(g.value,l.greedy,p);else if(g.type==="SingleQuoted"||g.type==="Escaped")h+=be(g.value);else if(g.type==="DoubleQuoted"){let y=await r(e,g.parts);h+=be(y)}else if(g.type==="ParameterExpansion"){let y=await n(e,g);h+=me(y,l.greedy,p)}else{let y=await n(e,g);h+=be(y)}let m=[];for(let g of c)m.push(Sn(g,h,l.side,l.greedy));if(o){let g=fe(e.state.env);return{values:[u+m.join(g)+f],quoted:!0}}return m.length===1?{values:[u+m[0]+f],quoted:!0}:{values:[u+m[0],...m.slice(1,-1),m[m.length-1]+f],quoted:!0}}async function R2(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0],s=-1,i=!1;for(let h=0;h<r.parts.length;h++){let p=r.parts[h];if(p.type==="ParameterExpansion"&&(p.parameter==="@"||p.parameter==="*")){s=h,i=p.parameter==="*";break}}if(s===-1)return null;let o=r.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(e.state.env.get("#")||"0",10),l="";for(let h=0;h<s;h++)l+=await n(e,r.parts[h]);let c="";for(let h=s+1;h<r.parts.length;h++)c+=await n(e,r.parts[h]);if(a===0){if(i)return{values:[l+c],quoted:!0};let h=l+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=a;h++)u.push(e.state.env.get(String(h))||"");if(i){let h=fe(e.state.env);return{values:[l+u.join(h)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var O2=I(()=>{"use strict";Me();Wt();Dr();Lr();nr()});function Mw(e){return new Dn(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations})}async function qi(e,t){if(e.state.options.noglob)return t;let n=Mw(e),r=[];for(let s of t)if(mn(s,e.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new an(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function $2(e,t,n,r){let s=-1,i="",o=!1;for(let w=0;w<t.length;w++){let b=t[w];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let x=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(x){s=w,i=x[1],o=x[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=ae(e,i),u=c.map(([,w])=>w);if(c.length===0){let w=e.state.env.get(i);w!==void 0&&(u=[w])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")f+=me(w.pattern,!0,e.state.shoptOptions.extglob);else if(w.type==="Literal")f+=me(w.value,!0,e.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")f+=be(w.value);else if(w.type==="DoubleQuoted"){let b=await n(e,w.parts);f+=be(b)}else if(w.type==="ParameterExpansion"){let b=await r(e,w);f+=me(b,!0,e.state.shoptOptions.extglob)}else{let b=await r(e,w);f+=be(b)}let h=l.replacement?await n(e,l.replacement.parts):"",p=f;l.anchor==="start"?p=`^${f}`:l.anchor==="end"&&(p=`${f}$`);let m=[];try{let w=V(p,l.all?"g":"");for(let b of u)m.push(w.replace(b,h))}catch{m.push(...u)}let d=tt(e.state.env),g=ct(e.state.env);if(o){let w=fe(e.state.env),b=m.join(w);return g?{values:b?[b]:[],quoted:!1}:{values:Le(b,d),quoted:!1}}if(g)return{values:m,quoted:!1};let y=[];for(let w of m)w===""?y.push(""):y.push(...Le(w,d));return{values:y,quoted:!1}}async function T2(e,t,n,r){let s=-1,i="",o=!1;for(let y=0;y<t.length;y++){let w=t[y];if(w.type==="ParameterExpansion"&&w.operation?.type==="PatternRemoval"){let b=w.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=y,i=b[1],o=b[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=ae(e,i),u=c.map(([,y])=>y);if(c.length===0){let y=e.state.env.get(i);y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="",h=e.state.shoptOptions.extglob;if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=me(y.pattern,l.greedy,h);else if(y.type==="Literal")f+=me(y.value,l.greedy,h);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=be(y.value);else if(y.type==="DoubleQuoted"){let w=await n(e,y.parts);f+=be(w)}else if(y.type==="ParameterExpansion"){let w=await r(e,y);f+=me(w,l.greedy,h)}else{let w=await r(e,y);f+=be(w)}let p=[];for(let y of u)p.push(Sn(y,f,l.side,l.greedy));let m=tt(e.state.env),d=ct(e.state.env);if(o){let y=fe(e.state.env),w=p.join(y);return d?{values:w?[w]:[],quoted:!1}:{values:Le(w,m),quoted:!1}}if(d)return{values:p,quoted:!1};let g=[];for(let y of p)y===""?g.push(""):g.push(...Le(y,m));return{values:g,quoted:!1}}async function P2(e,t,n,r){let s=-1,i=!1;for(let g=0;g<t.length;g++){let y=t[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){s=g,i=y.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=Number.parseInt(e.state.env.get("#")||"0",10),c=[];for(let g=1;g<=l;g++)c.push(e.state.env.get(String(g))||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=e.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=me(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=me(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=be(g.value);else if(g.type==="DoubleQuoted"){let y=await n(e,g.parts);u+=be(y)}else if(g.type==="ParameterExpansion"){let y=await r(e,g);u+=me(y,a.greedy,f)}else{let y=await r(e,g);u+=be(y)}let h=[];for(let g of c)h.push(Sn(g,u,a.side,a.greedy));let p=tt(e.state.env),m=ct(e.state.env);if(i){let g=fe(e.state.env),y=h.join(g);return m?{values:y?[y]:[],quoted:!1}:{values:Le(y,p),quoted:!1}}if(m)return{values:h,quoted:!1};let d=[];for(let g of h)g===""?d.push(""):d.push(...Le(g,p));return{values:d,quoted:!1}}async function D2(e,t,n,r){let s=-1,i=!1;for(let b=0;b<t.length;b++){let x=t[b];if(x.type==="ParameterExpansion"&&(x.parameter==="@"||x.parameter==="*")&&x.operation?.type==="Substring"){s=b,i=x.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=a.offset?await n(e,a.offset.expression):0,c=a.length?await n(e,a.length.expression):void 0,u=Number.parseInt(e.state.env.get("#")||"0",10),f=[];for(let b=1;b<=u;b++)f.push(e.state.env.get(String(b))||"");let h=e.state.env.get("0")||"bash",p;if(l<=0){let b=[h,...f],x=b.length+l;if(x<0)p=[];else{let S=l<0?x:0;if(c!==void 0){let C=c<0?b.length+c:S+c;p=b.slice(S,Math.max(S,C))}else p=b.slice(S)}}else{let b=l-1;if(b>=f.length)p=[];else if(c!==void 0){let x=c<0?f.length+c:b+c;p=f.slice(b,Math.max(b,x))}else p=f.slice(b)}let m="";for(let b=0;b<s;b++)m+=await r(e,t[b]);let d="";for(let b=s+1;b<t.length;b++)d+=await r(e,t[b]);let g=tt(e.state.env),y=ct(e.state.env);if(p.length===0){let b=m+d;return b?y?{values:[b],quoted:!1}:{values:Le(b,g),quoted:!1}:{values:[],quoted:!1}}let w;if(i){let b=fe(e.state.env),x=m+p.join(b)+d;y?w=x?[x]:[]:w=Le(x,g)}else if(y)p.length===1?w=[m+p[0]+d]:w=[m+p[0],...p.slice(1,-1),p[p.length-1]+d];else{w=[];for(let b=0;b<p.length;b++){let x=p[b];if(b===0&&(x=m+x),b===p.length-1&&(x=x+d),x==="")w.push("");else{let S=Le(x,g);w.push(...S)}}}return{values:await qi(e,w),quoted:!1}}async function L2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].parameter!=="@"&&t[0].parameter!=="*"||t[0].operation)return null;let n=t[0].parameter==="*",r=Number.parseInt(e.state.env.get("#")||"0",10);if(r===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=r;c++)s.push(e.state.env.get(String(c))||"");let i=tt(e.state.env),o=ct(e.state.env),a=Wi(e.state.env),l;if(n)if(o)l=s.filter(c=>c!=="");else{let c=fe(e.state.env),u=s.join(c);l=Le(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=Le(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=Le(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await qi(e,l),quoted:!1}}async function _2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],s=n[2]==="*",i=ae(e,r),o;if(i.length===0){let f=e.state.env.get(r);if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=tt(e.state.env),l=ct(e.state.env),c=Wi(e.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=fe(e.state.env),h=o.join(f);u=Le(h,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let h=Le(f,a);u.push(...h)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let h=Le(f,a);u.push(...h)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await qi(e,u),quoted:!1}}function M2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=_r(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=tt(e.state.env),i=ct(e.state.env),o;if(n.star)if(i)o=r;else{let a=fe(e.state.env),l=r.join(a);o=Le(l,s)}else if(i)o=r;else{o=[];for(let a of r){let l=Le(a,s);o.push(...l)}}return{values:o,quoted:!1}}function F2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="ArrayKeys")return null;let n=t[0].operation,s=ae(e,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=tt(e.state.env),o=ct(e.state.env),a;if(n.star)if(o)a=s;else{let l=fe(e.state.env),c=s.join(l);a=Le(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=Le(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function U2(e,t,n){let r=-1;for(let h=0;h<t.length;h++){let p=t[h];if(p.type==="ParameterExpansion"&&(p.parameter==="@"||p.parameter==="*")&&!p.operation){r=h;break}}if(r===-1||t.length<=1)return null;let s=Number.parseInt(e.state.env.get("#")||"0",10),i=[];for(let h=1;h<=s;h++)i.push(e.state.env.get(String(h))||"");let o="";for(let h=0;h<r;h++)o+=await n(e,t[h]);let a="";for(let h=r+1;h<t.length;h++)a+=await n(e,t[h]);let l=tt(e.state.env),c=ct(e.state.env),u=Wi(e.state.env);if(s===0){let h=o+a;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let p=0;p<i.length;p++){let m=i[p];p===0&&(m=o+m),p===i.length-1&&(m=m+a),h.push(m)}if(c)f=h.filter(p=>p!=="");else if(u){f=[];for(let p of h){if(p==="")continue;let m=Le(p,l);f.push(...m)}}else{f=[];for(let p of h)if(p==="")f.push("");else{let m=Le(p,l);f.push(...m)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await qi(e,f),quoted:!1}}var W2=I(()=>{"use strict";Me();Mi();xe();Wt();Dr();Pr();Lr();nr();Ot()});async function z2(e,t,n){let r=t.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=ys(r),h=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(h&&h.length>1)return Fw(e,h,s);let p=await Uw(e,r,a,c,u,n);if(p!==null)return p;let m=await Bw(e,r,n);if(m!==null)return m;let d=await Hw(e,r,n);if(d!==null)return d;let g=await jw(e,r,n.expandPart);if(g!==null)return H2(e,g);if((i||o||l)&&!ct(e.state.env)){let w=tt(e.state.env),b=n.buildIfsCharClassPattern(w),x=await n.smartWordSplit(e,r,w,b,n.expandPart);return H2(e,x)}let y=await n.expandWordAsync(e,t);return Gw(e,t,r,y,s,n.expandWordForGlobbing)}async function Fw(e,t,n){let r=[];for(let s of t)if(!(!n&&s===""))if(!n&&!e.state.options.noglob&&mn(s,e.state.shoptOptions.extglob)){let i=await Zi(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function Uw(e,t,n,r,s,i){if(n){let o=w2(e,t);if(o!==null)return o}{let o=b2(e,t);if(o!==null)return o}{let o=await f2(e,t);if(o!==null)return o}{let o=await h2(e,t,n,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await p2(e,t,n,i.expandPart);if(o!==null)return o}{let o=await m2(e,t,i.evaluateArithmetic);if(o!==null)return o}{let o=g2(e,t);if(o!==null)return o}{let o=await l2(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await c2(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let o=Ww(e,t);if(o!==null)return o}{let o=await E2(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await A2(e,t);if(o!==null)return o}{let o=await S2(e,t);if(o!==null)return o}return null}function Ww(e,t){let n=t[0];if(n.type!=="DoubleQuoted")return null;if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="VarNamePrefix"){let r=n.parts[0].operation,s=_r(e,r.prefix);return r.star?{values:[s.join(fe(e.state.env))],quoted:!0}:{values:s,quoted:!0}}if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="ArrayKeys"){let r=n.parts[0].operation,i=ae(e,r.array).map(([o])=>String(o));return r.star?{values:[i.join(fe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function Bw(e,t,n){{let r=await k2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await v2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await I2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await R2(e,t,n.expandPart);if(r!==null)return r}return null}async function Hw(e,t,n){{let r=await $2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await T2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await P2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await D2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await L2(e,t);if(r!==null)return r}{let r=await _2(e,t);if(r!==null)return r}{let r=M2(e,t);if(r!==null)return r}{let r=F2(e,t);if(r!==null)return r}{let r=await U2(e,t,n.expandPart);if(r!==null)return r}return null}function B2(e){if(e.type!=="DoubleQuoted")return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!=="ParameterExpansion"||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:"array",name:r[1],atIndex:t,isStar:r[2]==="*"};if(n.parameter==="@"||n.parameter==="*")return{type:"positional",atIndex:t,isStar:n.parameter==="*"}}return null}async function zw(e,t,n,r){let s="";for(let a=0;a<n.atIndex;a++)s+=await r(e,t.parts[a]);let i="";for(let a=n.atIndex+1;a<t.parts.length;a++)i+=await r(e,t.parts[a]);let o;if(n.type==="array"){if(o=ae(e,n.name).map(([,l])=>l),o.length===0){let l=e.state.env.get(n.name);l!==void 0&&(o=[l])}}else{let a=Number.parseInt(e.state.env.get("#")||"0",10);o=[];for(let l=1;l<=a;l++)o.push(e.state.env.get(String(l))||"")}if(n.isStar){let a=fe(e.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function jw(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(B2(l)){r=!0;break}if(!r)return null;let s=tt(e.state.env),i=ct(e.state.env),o=[];for(let l of t){let c=B2(l);if(c&&l.type==="DoubleQuoted"){let u=await zw(e,l,c,n);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(e,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Le(u,s);o.push(f)}}else{let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Le(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function H2(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(mn(r,e.state.shoptOptions.extglob)){let s=await Zi(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function Zi(e,t){let n=new Dn(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new an(t);return n.hasNullglob()?[]:[t]}async function Gw(e,t,n,r,s,i){let o=n.some(a=>a.type==="Glob");if(!e.state.options.noglob&&o){let a=await i(e,t);if(mn(a,e.state.shoptOptions.extglob)){let c=await Zi(e,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=Vl(r);if(!ct(e.state.env)){let c=tt(e.state.env);return{values:Le(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!e.state.options.noglob&&mn(r,e.state.shoptOptions.extglob)){let a=await i(e,t);if(mn(a,e.state.shoptOptions.extglob)){let l=await Zi(e,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=Vl(r);if(!ct(e.state.env)){let l=tt(e.state.env);return{values:Le(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[r],quoted:s}}var j2=I(()=>{"use strict";Mi();xe();Wt();Fi();u2();d2();y2();x2();Pr();C2();nr();O2();W2();Ot()});async function V2(e,t){let n=t.operation;if(!n||n.type!=="DefaultValue"&&n.type!=="AssignDefault"&&n.type!=="UseAlternative")return null;let r=n.word;if(!r||r.parts.length===0)return null;let s=await dn(e,t.parameter),o=await Se(e,t.parameter,!1)==="",a=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?r.parts:null}function Vw(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function qw(e,t){if(t.type!=="ParameterExpansion")return null;let n=await V2(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>Vw(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function Zw(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?Ul(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&Rm(e))}async function q2(e,t,n,r,s){if(t.length===1&&t[0].type==="ParameterExpansion"){let h=t[0],p=await V2(e,h);if(p&&p.length>0&&p.length>1&&p.some(d=>d.type==="DoubleQuoted"||d.type==="SingleQuoted")&&p.some(d=>d.type==="Literal"||d.type==="ParameterExpansion"||d.type==="CommandSubstitution"||d.type==="ArithmeticExpansion"))return G2(e,p,n,r,s)}let i=[],o=!1;for(let h of t){let p=Zw(h),m=h.type==="DoubleQuoted"||h.type==="SingleQuoted",d=p?await qw(e,h):null,g=await s(e,h);i.push({value:g,isSplittable:p,isQuoted:m,mixedDefaultParts:d??void 0}),p&&(o=!0)}if(!o){let h=i.map(p=>p.value).join("");return h?[h]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let h of i)if(!h.isSplittable)u?h.isQuoted&&h.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):h.value!==""?(l!==""&&a.push(l),l=h.value,u=!1,f=!1):(l+=h.value,f=!1):(l+=h.value,f=h.isQuoted&&h.value==="");else if(h.mixedDefaultParts){let p=await G2(e,h.mixedDefaultParts,n,r,s);if(p.length!==0)if(p.length===1)l+=p[0],c=!0;else{l+=p[0],a.push(l),c=!0;for(let m=1;m<p.length-1;m++)a.push(p[m]);l=p[p.length-1]}u=!1,f=!1}else{let{words:p,hadLeadingDelimiter:m,hadTrailingDelimiter:d}=Bi(h.value,n);if(f&&m&&l===""&&(a.push(""),c=!0),p.length===0)d&&(u=!0);else if(p.length===1)l+=p[0],c=!0,u=d;else{l+=p[0],a.push(l),c=!0;for(let g=1;g<p.length-1;g++)a.push(p[g]);l=p[p.length-1],u=d}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function Qw(e,t){return e.length>0&&t.includes(e[0])}async function G2(e,t,n,r,s){let i=[];for(let u of t){let h=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),p=await s(e,u);i.push({value:p,isSplittable:h})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{Qw(u.value,n)&&a!==""&&(o.push(a),a="",l=!0);let{words:h,hadTrailingDelimiter:p}=Bi(u.value,n);if(h.length===0)p&&(c=!0);else if(h.length===1)a+=h[0],l=!0,c=p;else{a+=h[0],o.push(a),l=!0;for(let m=1;m<h.length-1;m++)o.push(h[m]);a=h[h.length-1],c=p}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var Z2=I(()=>{"use strict";Ot();Wt();Fi()});function Q2(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function K2(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var X2=I(()=>{"use strict"});var tc={};Q(tc,{escapeGlobChars:()=>$t,escapeRegexChars:()=>Tr,expandRedirectTarget:()=>Es,expandWord:()=>se,expandWordForPattern:()=>Jl,expandWordForRegex:()=>Yl,expandWordWithGlob:()=>rn,getArrayElements:()=>ae,getVariable:()=>Se,hasQuotedMultiValueAt:()=>xs,isArray:()=>An,isWordFullyQuoted:()=>Xl});function bs(e,t,n){if(e.length>t)throw new re(`${n}: string length limit exceeded (${t} bytes)`,"string_length")}async function nn(e,t,n=!1){let r=[];for(let s of t)r.push(await Bt(e,s,n));return r.join("")}function Kw(e){return K2(e)}function Xl(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!Kw(t))return!1;return!0}function Xw(e,t,n=!1){let r=Q2(t);if(r!==null)return r;switch(t.type){case"TildeExpansion":return n?t.user===null?"~":`~${t.user}`:t.user===null?e.state.env.get("HOME")??"/home/user":t.user==="root"?"/root":`~${t.user}`;case"Glob":return Ql(e,t.pattern);default:return null}}async function se(e,t){return ec(e,t)}async function Yl(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped")n.push(`\\${r.value}`);else if(r.type==="SingleQuoted")n.push(r.value);else if(r.type==="DoubleQuoted"){let s=await nn(e,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await Bt(e,r);n.push(Tr(s))}else n.push(await Bt(e,r));return n.join("")}async function Jl(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped"){let s=r.value;"()|*?[]".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="SingleQuoted")n.push($t(r.value));else if(r.type==="DoubleQuoted"){let s=await nn(e,r.parts);n.push($t(s))}else n.push(await Bt(e,r));return n.join("")}async function Y2(e,t){let n=[];for(let r of t.parts)if(r.type==="SingleQuoted")n.push($t(r.value));else if(r.type==="Escaped"){let s=r.value;"*?[]\\()|".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="DoubleQuoted"){let s=await nn(e,r.parts);n.push($t(s))}else r.type==="Glob"?n2(r.pattern)?n.push(await s2(e,r.pattern)):n.push(Ql(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await Bt(e,r));return n.join("")}function Ki(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&Ki(t.parts))return!0;return!1}async function J2(e,t,n={count:0}){if(n.count>Kl)return[[]];let r=[[]];for(let s of t)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=Gl(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)n.count++,i.push(h);else{o=!0,a=f.literal;break}}else{let f=await J2(e,u.word.parts,n);for(let h of f){n.count++;let p=[];for(let m of h)typeof m=="string"?p.push(m):p.push(await Bt(e,m));i.push(p.join(""))}}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>Yw||n.count>Kl)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>Kl)return c.length>0?c:r;c.push([...u,f])}r=c}else for(let i of r)n.count++,i.push(s);return r}async function e6(e,t){let n=t.parts;if(!Ki(n))return[await se(e,t)];let r=await J2(e,n),s=[];for(let i of r){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await Bt(e,a));s.push(o2(e,o.join("")))}return s}function Jw(){return{expandWordAsync:ec,expandWordForGlobbing:Y2,expandWordWithBracesAsync:e6,expandWordPartsAsync:nn,expandPart:Bt,expandParameterAsync:Qi,hasBraceExpansion:Ki,evaluateArithmetic:J,buildIfsCharClassPattern:Om,smartWordSplit:q2}}async function rn(e,t){return z2(e,t,Jw())}function eb(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function xs(e,t){if(Number.parseInt(e.state.env.get("#")||"0",10)<2)return!1;function r(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return r(t.parts)}async function Es(e,t){if(xs(e,t))return{error:`bash: $@: ambiguous redirect
778
+ `;case"r":return"\r";case"t":return" ";case"v":return"\v";case"'":return"'";case'"':return'"';case"?":return"?";default:return l}});case"K":case"k":return r?"":Ln(n);case"u":return n.charAt(0).toUpperCase()+n.slice(1);case"U":return n.toUpperCase();case"L":return n.toLowerCase();default:return n}}async function Xm(e,t,n,r,s,i,o=!1){if(Te(e,t))return tr(e,t)||"";let a=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new yt(`\${!${t}}`)}let l=n;if(a&&(l===""||l.includes(" ")))throw new yt(`\${!${t}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new yt(`\${!${t}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(e,u,o)}return await Se(e,l)}function Ym(e,t){let r=ae(e,t.array).map(([s])=>String(s));return t.star?r.join(fe(e.state.env)):r.join(" ")}function Jm(e,t){let n=_r(e,t.prefix);return t.star?n.join(fe(e.state.env)):n.join(" ")}function e2(e,t,n,r){let s=Number.parseInt(e.state.env.get("#")||"0",10),i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(t==="*")return{isEmpty:s===0,effectiveValue:n};if(t==="@")return{isEmpty:s===0||s===1&&e.state.env.get("1")==="",effectiveValue:n};if(i){let[,o,a]=i,l=ae(e,o);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(a==="*"){let c=fe(e.state.env),u=l.map(([,f])=>f).join(c);return{isEmpty:r?u==="":!1,effectiveValue:u}}return{isEmpty:l.length===1&&l.every(([,c])=>c===""),effectiveValue:l.map(([,c])=>c).join(" ")}}return{isEmpty:n==="",effectiveValue:n}}var t2=I(()=>{"use strict";pt();Qe();Me();Et();xe();Wt();en();Dr();Lr();nr();ql();Zl();Rt();Gi()});function n2(e){let t=0;for(;t<e.length;){let n=e[t];if(n==="\\"&&t+1<e.length){t+=2;continue}if(n==="'"){let r=e.indexOf("'",t+1);if(r!==-1){t=r+1;continue}}if(n==="$"&&t+1<e.length&&e[t+1]==="("||n==="`")return!0;t++}return!1}function r2(e,t){let n=1,r=t,s=!1,i=!1;for(;r<e.length&&n>0;){let o=e[r];if(o==="\\"&&!s&&r+1<e.length){r+=2;continue}if(o==="'"&&!i){s=!s,r++;continue}if(o==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(o==="(")n++;else if(o===")"&&(n--,n===0))return r}r++}return-1}async function Vi(e,t){let n=new ce,r;try{r=n.parse(t)}catch{return""}let s=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let i=new Map(e.state.env),o=e.state.cwd,a=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let l=await e.executeScript(r),c=l.exitCode;return e.state.env=i,e.state.cwd=o,e.state.suppressVerbose=a,e.state.lastExitCode=c,e.state.env.set("?",String(c)),l.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+l.stderr),e.state.bashPid=s,l.stdout.replace(/\n+$/,"")}catch(l){if(e.state.env=i,e.state.cwd=o,e.state.bashPid=s,e.state.suppressVerbose=a,l instanceof re)throw l;return l instanceof pe?(e.state.lastExitCode=l.exitCode,e.state.env.set("?",String(l.exitCode)),l.stdout?.replace(/\n+$/,"")??""):""}}function Ql(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=$t(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=Tw(e,a);n+=$t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}function Tw(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}async function s2(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="'"){let i=t.indexOf("'",r+1);if(i!==-1){let o=t.slice(r+1,i);n+=$t(o),r=i+1;continue}}if(s==='"'){let i=-1,o=r+1;for(;o<t.length;){if(t[o]==="\\"){o+=2;continue}if(t[o]==='"'){i=o;break}o++}if(i!==-1){let a=t.slice(r+1,i),l=await Pw(e,a);n+=$t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=r2(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}async function Pw(e,t){let n="",r=0;for(;r<t.length;){let s=t[r];if(s==="\\"&&r+1<t.length){let i=t[r+1];if(i==="$"||i==="`"||i==="\\"||i==='"'){n+=i,r+=2;continue}n+=s,r++;continue}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=r2(t,r+2);if(i!==-1){let o=t.slice(r+2,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let o=t.slice(r+1,i),a=await Vi(e,o);n+=a,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let o=t.indexOf("}",r+2);if(o!==-1){let a=t.slice(r+2,o);n+=e.state.env.get(a)??"",r=o+1;continue}}else if(/[a-zA-Z_]/.test(i)){let o=r+1;for(;o<t.length&&/[a-zA-Z0-9_]/.test(t[o]);)o++;let a=t.slice(r+1,o);n+=e.state.env.get(a)??"",r=o;continue}}n+=s,r++}return n}var i2=I(()=>{"use strict";Qe();xe();Pr()});function o2(e,t){if(!t.startsWith("~"))return t;let n=e.state.env.get("HOME")!==void 0?e.state.env.get("HOME"):"/home/user";if(t==="~"||t.startsWith("~/"))return n+t.slice(1);let r=1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;let s=t.slice(1,r),i=t.slice(r);return i!==""&&!i.startsWith("/")?t:s==="root"?`/root${i}`:t}var a2=I(()=>{"use strict"});async function Dw(e,t,n,r){let s="";for(let i of t.parts)if(i.type==="Glob")s+=me(i.pattern,!0,e.state.shoptOptions.extglob);else if(i.type==="Literal")s+=me(i.value,!0,e.state.shoptOptions.extglob);else if(i.type==="SingleQuoted"||i.type==="Escaped")s+=be(i.value);else if(i.type==="DoubleQuoted"){let o=await n(e,i.parts);s+=be(o)}else if(i.type==="ParameterExpansion"){let o=await r(e,i);s+=me(o,!0,e.state.shoptOptions.extglob)}else{let o=await r(e,i);s+=be(o)}return s}async function l2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternReplacement")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=ae(e,a),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env.get(a);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let h="";c.pattern&&(h=await Dw(e,c.pattern,n,r));let p=c.replacement?await n(e,c.replacement.parts):"",m=h;c.anchor==="start"?m=`^${h}`:c.anchor==="end"&&(m=`${h}$`);let d=[];try{let g=V(m,c.all?"g":"");for(let y of f)d.push(g.replace(y,p))}catch{d.push(...f)}if(l){let g=fe(e.state.env);return{values:[d.join(g)],quoted:!0}}return{values:d,quoted:!0}}async function c2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0];if(s.parts.length!==1||s.parts[0].type!=="ParameterExpansion"||s.parts[0].operation?.type!=="PatternRemoval")return null;let i=s.parts[0],o=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!o)return null;let a=o[1],l=o[2]==="*",c=i.operation,u=ae(e,a),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env.get(a);d!==void 0&&f.push(d)}if(f.length===0)return{values:[],quoted:!0};let h="",p=e.state.shoptOptions.extglob;if(c.pattern)for(let d of c.pattern.parts)if(d.type==="Glob")h+=me(d.pattern,c.greedy,p);else if(d.type==="Literal")h+=me(d.value,c.greedy,p);else if(d.type==="SingleQuoted"||d.type==="Escaped")h+=be(d.value);else if(d.type==="DoubleQuoted"){let g=await n(e,d.parts);h+=be(g)}else if(d.type==="ParameterExpansion"){let g=await r(e,d);h+=me(g,c.greedy,p)}else{let g=await r(e,d);h+=be(g)}let m=[];for(let d of f)m.push(Sn(d,h,c.side,c.greedy));if(l){let d=fe(e.state.env);return{values:[m.join(d)],quoted:!0}}return{values:m,quoted:!0}}var u2=I(()=>{"use strict";Me();Wt();Dr();Lr();nr();Rt()});async function f2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="DefaultValue"&&n.parts[0].operation?.type!=="UseAlternative"&&n.parts[0].operation?.type!=="AssignDefault")return null;let r=n.parts[0],s=r.operation,i=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/),o,a=!1;if(i){let l=i[1];a=i[2]==="*";let c=ae(e,l),u=c.length>0||e.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,p])=>p===""),h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=u&&!(h&&f):o=!u||h&&f,!o){if(c.length>0){let m=c.map(([,d])=>d);if(a){let d=fe(e.state.env);return{values:[m.join(d)],quoted:!0}}return{values:m,quoted:!0}}let p=e.state.env.get(l);return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await dn(e,l),u=await Se(e,l),f=u==="",h=s.checkEmpty??!1;if(s.type==="UseAlternative"?o=c&&!(h&&f):o=!c||h&&f,!o)return{values:[u],quoted:!0}}if(o&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let h=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(h){c=h[1],u=h[2]==="*";break}}if(c){let f=ae(e,c);if(f.length>0){let p=f.map(([,m])=>m);if(u||a){let m=fe(e.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}let h=e.state.env.get(c);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}return null}async function h2(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],o=-1,a="",l=!1,c=null;for(let d=0;d<i.parts.length;d++){let g=i.parts[d];if(g.type==="ParameterExpansion"&&(g.operation?.type==="PatternRemoval"||g.operation?.type==="PatternReplacement")){let y=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(y){o=d,a=y[1],l=y[2]==="*",c=g.operation;break}}}if(o===-1||o===0&&o===i.parts.length-1)return null;let u="";for(let d=0;d<o;d++)u+=await r(e,i.parts[d]);let f="";for(let d=o+1;d<i.parts.length;d++)f+=await r(e,i.parts[d]);let h=ae(e,a),p=h.map(([,d])=>d);if(h.length===0){let d=e.state.env.get(a);if(d!==void 0)p=[d];else{if(l)return{values:[u+f],quoted:!0};let g=u+f;return{values:g?[g]:[],quoted:!0}}}if(c?.type==="PatternRemoval"){let d=c,g="",y=e.state.shoptOptions.extglob;if(d.pattern)for(let w of d.pattern.parts)if(w.type==="Glob")g+=me(w.pattern,d.greedy,y);else if(w.type==="Literal")g+=me(w.value,d.greedy,y);else if(w.type==="SingleQuoted"||w.type==="Escaped")g+=be(w.value);else if(w.type==="DoubleQuoted"){let b=await s(e,w.parts);g+=be(b)}else if(w.type==="ParameterExpansion"){let b=await r(e,w);g+=me(b,d.greedy,y)}else{let b=await r(e,w);g+=be(b)}p=p.map(w=>Sn(w,g,d.side,d.greedy))}else if(c?.type==="PatternReplacement"){let d=c,g="";if(d.pattern)for(let b of d.pattern.parts)if(b.type==="Glob")g+=me(b.pattern,!0,e.state.shoptOptions.extglob);else if(b.type==="Literal")g+=me(b.value,!0,e.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")g+=be(b.value);else if(b.type==="DoubleQuoted"){let x=await s(e,b.parts);g+=be(x)}else if(b.type==="ParameterExpansion"){let x=await r(e,b);g+=me(x,!0,e.state.shoptOptions.extglob)}else{let x=await r(e,b);g+=be(x)}let y=d.replacement?await s(e,d.replacement.parts):"",w=g;d.anchor==="start"?w=`^${g}`:d.anchor==="end"&&(w=`${g}$`);try{let b=V(w,d.all?"g":"");p=p.map(x=>b.replace(x,y))}catch{}}if(l){let d=fe(e.state.env);return{values:[u+p.join(d)+f],quoted:!0}}return p.length===1?{values:[u+p[0]+f],quoted:!0}:{values:[u+p[0],...p.slice(1,-1),p[p.length-1]+f],quoted:!0}}async function p2(e,t,n,r){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o="",a=!1;for(let p=0;p<s.parts.length;p++){let m=s.parts[p];if(m.type==="ParameterExpansion"&&!m.operation){let d=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(d){i=p,o=d[1],a=d[2]==="*";break}}}if(i===-1)return null;let l="";for(let p=0;p<i;p++)l+=await r(e,s.parts[p]);let c="";for(let p=i+1;p<s.parts.length;p++)c+=await r(e,s.parts[p]);let u=ae(e,o),f=u.map(([,p])=>p);if(u.length===0){let p=e.state.env.get(o);if(p!==void 0)return{values:[l+p+c],quoted:!0};if(a)return{values:[l+c],quoted:!0};let m=l+c;return{values:m?[m]:[],quoted:!0}}if(a){let p=fe(e.state.env);return{values:[l+f.join(p)+c],quoted:!0}}return f.length===1?{values:[l+f[0]+c],quoted:!0}:{values:[l+f[0],...f.slice(1,-1),f[f.length-1]+c],quoted:!0}}var d2=I(()=>{"use strict";Me();Wt();Dr();Lr();nr();Rt()});async function m2(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0];if(r.parts.length!==1||r.parts[0].type!=="ParameterExpansion"||r.parts[0].operation?.type!=="Substring")return null;let s=r.parts[0],i=s.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!i)return null;let o=i[1],a=i[2]==="*",l=s.operation;if(e.state.associativeArrays?.has(o))throw new pe(1,"",`bash: \${${o}[@]: 0: 3}: bad substitution
779
+ `);let c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=ae(e,o),h=0;if(c<0){if(f.length>0){let m=f[f.length-1][0],g=(typeof m=="number"?m:0)+1+c;if(g<0)return{values:[],quoted:!0};h=f.findIndex(([y])=>typeof y=="number"&&y>=g),h<0&&(h=f.length)}}else h=f.findIndex(([m])=>typeof m=="number"&&m>=c),h<0&&(h=f.length);let p;if(u!==void 0){if(u<0)throw new $e(`${o}[@]: substring expression < 0`);p=f.slice(h,h+u).map(([,m])=>m)}else p=f.slice(h).map(([,m])=>m);if(p.length===0)return{values:[],quoted:!0};if(a){let m=fe(e.state.env);return{values:[p.join(m)],quoted:!0}}return{values:p,quoted:!0}}function g2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation?.type!=="Transform")return null;let r=n.parts[0],s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!s)return null;let i=s[1],o=s[2]==="*",a=r.operation,l=ae(e,i);if(l.length===0){let f=e.state.env.get(i);if(f!==void 0){let h;switch(a.operator){case"a":h="";break;case"P":h=ws(e,f);break;case"Q":h=Ln(f);break;default:h=f}return{values:[h],quoted:!0}}return o?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=Mn(e,i),u;switch(a.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>ws(e,f));break;case"Q":u=l.map(([,f])=>Ln(f));break;case"u":u=l.map(([,f])=>f.charAt(0).toUpperCase()+f.slice(1));break;case"U":u=l.map(([,f])=>f.toUpperCase());break;case"L":u=l.map(([,f])=>f.toLowerCase());break;default:u=l.map(([,f])=>f)}if(o){let f=fe(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var y2=I(()=>{"use strict";xe();Wt();ql();Zl();Rt();Gi()});function w2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion")return null;let r=n.parts[0];if(r.operation)return null;let s=r.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!s)return null;let i=s[1];if(Te(e,i)){let l=tr(e,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let o=ae(e,i);if(o.length>0)return{values:o.map(([,l])=>l),quoted:!0};let a=e.state.env.get(i);return a!==void 0?{values:[a],quoted:!0}:{values:[],quoted:!0}}function b2(e,t){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let n=t[0];if(n.parts.length!==1||n.parts[0].type!=="ParameterExpansion"||n.parts[0].operation)return null;let s=n.parts[0].parameter;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)||!Te(e,s))return null;let i=tr(e,s);if(!i)return null;let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!o)return null;let a=o[1],l=ae(e,a);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=e.state.env.get(a);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var x2=I(()=>{"use strict";en();Rt()});async function E2(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],a=o.operation,l=await Se(e,o.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!a.innerOp&&(l==="@"||l==="*")){let m=Number.parseInt(e.state.env.get("#")||"0",10),d=[];for(let g=1;g<=m;g++)d.push(e.state.env.get(String(g))||"");return l==="*"?{values:[d.join(fe(e.state.env))],quoted:!0}:{values:d,quoted:!0}}return null}let u=c[1],f=c[2]==="*",h=ae(e,u);if(a.innerOp){if(a.innerOp.type==="Substring")return Lw(e,h,u,f,a.innerOp);if(a.innerOp.type==="DefaultValue"||a.innerOp.type==="UseAlternative"||a.innerOp.type==="AssignDefault"||a.innerOp.type==="ErrorIfUnset")return _w(e,h,u,f,a.innerOp,s);if(a.innerOp.type==="Transform"&&a.innerOp.operator==="a"){let d=Mn(e,u),g=h.map(()=>d);return f?{values:[g.join(fe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let m=[];for(let[,d]of h){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:a.innerOp},y=e.state.env.get("_indirect_elem_");e.state.env.set("_indirect_elem_",d);try{let w=await r(e,g,!0);m.push(w)}finally{y!==void 0?e.state.env.set("_indirect_elem_",y):e.state.env.delete("_indirect_elem_")}}return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(h.length>0){let m=h.map(([,d])=>d);return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let p=e.state.env.get(u);return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}async function Lw(e,t,n,r,s){let i=s.offset?await J(e,s.offset.expression):0,o=s.length?await J(e,s.length.expression):void 0,a=0;if(i<0){if(t.length>0){let u=t[t.length-1][0],h=(typeof u=="number"?u:0)+1+i;if(h<0)return{values:[],quoted:!0};if(a=t.findIndex(([p])=>typeof p=="number"&&p>=h),a<0)return{values:[],quoted:!0}}}else if(a=t.findIndex(([u])=>typeof u=="number"&&u>=i),a<0)return{values:[],quoted:!0};let l;if(o!==void 0){if(o<0)throw new $e(`${n}[@]: substring expression < 0`);l=t.slice(a,a+o)}else l=t.slice(a);let c=l.map(([,u])=>u);return r?{values:[c.join(fe(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function _w(e,t,n,r,s,i){let o=s.checkEmpty??!1,a=t.map(([,u])=>u),l=t.length===0,c=t.length===0;if(s.type==="UseAlternative")return!c&&!(o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||o&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:r?{values:[a.join(fe(e.state.env))],quoted:!0}:{values:a,quoted:!0};if(s.type==="AssignDefault"){if((c||o&&l)&&s.word){let f=await i(e,s.word.parts,!0);return e.state.env.set(`${n}_0`,f),e.state.env.set(`${n}__length`,"1"),{values:[f],quoted:!0}}return r?{values:[a.join(fe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}return r?{values:[a.join(fe(e.state.env))],quoted:!0}:{values:a,quoted:!0}}async function A2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="UseAlternative"&&t[0].operation?.type!=="DefaultValue")return null;let n=t[0],r=n.operation,s=r?.word;if(!s||s.parts.length!==1||s.parts[0].type!=="DoubleQuoted")return null;let i=s.parts[0];if(i.parts.length!==1||i.parts[0].type!=="ParameterExpansion"||i.parts[0].operation?.type!=="Indirection")return null;let o=i.parts[0],l=(await Se(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await dn(e,n.parameter),u=await Se(e,n.parameter)==="",f=r.checkEmpty??!1,h;if(r.type==="UseAlternative"?h=c&&!(f&&u):h=!c||f&&u,h){let p=l[1],m=l[2]==="*",d=ae(e,p);if(d.length>0){let y=d.map(([,w])=>w);return m?{values:[y.join(fe(e.state.env))],quoted:!0}:{values:y,quoted:!0}}let g=e.state.env.get(p);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function S2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="Indirection")return null;let n=t[0],s=n.operation.innerOp;if(!s||s.type!=="UseAlternative"&&s.type!=="DefaultValue")return null;let i=s.word;if(!i||i.parts.length!==1||i.parts[0].type!=="DoubleQuoted")return null;let o=i.parts[0];if(o.parts.length!==1||o.parts[0].type!=="ParameterExpansion"||o.parts[0].operation?.type!=="Indirection")return null;let a=o.parts[0],c=(await Se(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await Se(e,n.parameter),f=await dn(e,n.parameter),h=u==="",p=s.checkEmpty??!1,m;if(s.type==="UseAlternative"?m=f&&!(p&&h):m=!f||p&&h,m){let d=c[1],g=c[2]==="*",y=ae(e,d);if(y.length>0){let b=y.map(([,x])=>x);return g?{values:[b.join(fe(e.state.env))],quoted:!0}:{values:b,quoted:!0}}let w=e.state.env.get(d);return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var C2=I(()=>{"use strict";Et();xe();Wt();Rt();Gi()});function N2(e){let t=Number.parseInt(e.state.env.get("#")||"0",10),n=[];for(let r=1;r<=t;r++)n.push(e.state.env.get(String(r))||"");return n}async function k2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let w=0;w<s.parts.length;w++){let b=s.parts[w];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=w,o=b.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=l.offset?await n(e,l.offset.expression):0,u=l.length?await n(e,l.length.expression):void 0,f=Number.parseInt(e.state.env.get("#")||"0",10),h=[];for(let w=1;w<=f;w++)h.push(e.state.env.get(String(w))||"");let p=e.state.env.get("0")||"bash",m;if(c<=0){let w=[p,...h],b=w.length+c;if(b<0)m=[];else{let x=c<0?b:0;if(u!==void 0){let S=u<0?w.length+u:x+u;m=w.slice(x,Math.max(x,S))}else m=w.slice(x)}}else{let w=c-1;if(w>=h.length)m=[];else if(u!==void 0){let b=u<0?h.length+u:w+u;m=h.slice(w,Math.max(w,b))}else m=h.slice(w)}let d="";for(let w=0;w<i;w++)d+=await r(e,s.parts[w]);let g="";for(let w=i+1;w<s.parts.length;w++)g+=await r(e,s.parts[w]);if(m.length===0){let w=d+g;return{values:w?[w]:[],quoted:!0}}if(o){let w=fe(e.state.env);return{values:[d+m.join(w)+g],quoted:!0}}return m.length===1?{values:[d+m[0]+g],quoted:!0}:{values:[d+m[0],...m.slice(1,-1),m[m.length-1]+g],quoted:!0}}async function v2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let y=0;y<s.parts.length;y++){let w=s.parts[y];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternReplacement"){i=y,o=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=N2(e),u="";for(let y=0;y<i;y++)u+=await n(e,s.parts[y]);let f="";for(let y=i+1;y<s.parts.length;y++)f+=await n(e,s.parts[y]);if(c.length===0){let y=u+f;return{values:y?[y]:[],quoted:!0}}let h="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")h+=me(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")h+=me(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")h+=be(y.value);else if(y.type==="DoubleQuoted"){let w=await r(e,y.parts);h+=be(w)}else if(y.type==="ParameterExpansion"){let w=await n(e,y);h+=me(w,!0,e.state.shoptOptions.extglob)}else{let w=await n(e,y);h+=be(w)}let p=l.replacement?await r(e,l.replacement.parts):"",m=h;l.anchor==="start"?m=`^${h}`:l.anchor==="end"&&(m=`${h}$`);let d=[];try{let y=V(m,l.all?"g":"");for(let w of c)d.push(y.replace(w,p))}catch{d.push(...c)}if(o){let y=fe(e.state.env);return{values:[u+d.join(y)+f],quoted:!0}}return d.length===1?{values:[u+d[0]+f],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+f],quoted:!0}}async function I2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,o=!1;for(let g=0;g<s.parts.length;g++){let y=s.parts[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){i=g,o=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=N2(e),u="";for(let g=0;g<i;g++)u+=await n(e,s.parts[g]);let f="";for(let g=i+1;g<s.parts.length;g++)f+=await n(e,s.parts[g]);if(c.length===0){let g=u+f;return{values:g?[g]:[],quoted:!0}}let h="",p=e.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")h+=me(g.pattern,l.greedy,p);else if(g.type==="Literal")h+=me(g.value,l.greedy,p);else if(g.type==="SingleQuoted"||g.type==="Escaped")h+=be(g.value);else if(g.type==="DoubleQuoted"){let y=await r(e,g.parts);h+=be(y)}else if(g.type==="ParameterExpansion"){let y=await n(e,g);h+=me(y,l.greedy,p)}else{let y=await n(e,g);h+=be(y)}let m=[];for(let g of c)m.push(Sn(g,h,l.side,l.greedy));if(o){let g=fe(e.state.env);return{values:[u+m.join(g)+f],quoted:!0}}return m.length===1?{values:[u+m[0]+f],quoted:!0}:{values:[u+m[0],...m.slice(1,-1),m[m.length-1]+f],quoted:!0}}async function O2(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0],s=-1,i=!1;for(let h=0;h<r.parts.length;h++){let p=r.parts[h];if(p.type==="ParameterExpansion"&&(p.parameter==="@"||p.parameter==="*")){s=h,i=p.parameter==="*";break}}if(s===-1)return null;let o=r.parts[s];if(o.type==="ParameterExpansion"&&o.operation)return null;let a=Number.parseInt(e.state.env.get("#")||"0",10),l="";for(let h=0;h<s;h++)l+=await n(e,r.parts[h]);let c="";for(let h=s+1;h<r.parts.length;h++)c+=await n(e,r.parts[h]);if(a===0){if(i)return{values:[l+c],quoted:!0};let h=l+c;return{values:h?[h]:[],quoted:!0}}let u=[];for(let h=1;h<=a;h++)u.push(e.state.env.get(String(h))||"");if(i){let h=fe(e.state.env);return{values:[l+u.join(h)+c],quoted:!0}}return u.length===1?{values:[l+u[0]+c],quoted:!0}:{values:[l+u[0],...u.slice(1,-1),u[u.length-1]+c],quoted:!0}}var R2=I(()=>{"use strict";Me();Wt();Dr();Lr();nr()});function Mw(e){return new Dn(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations})}async function qi(e,t){if(e.state.options.noglob)return t;let n=Mw(e),r=[];for(let s of t)if(mn(s,e.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new an(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function $2(e,t,n,r){let s=-1,i="",o=!1;for(let w=0;w<t.length;w++){let b=t[w];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let x=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(x){s=w,i=x[1],o=x[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=ae(e,i),u=c.map(([,w])=>w);if(c.length===0){let w=e.state.env.get(i);w!==void 0&&(u=[w])}if(u.length===0)return{values:[],quoted:!1};let f="";if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")f+=me(w.pattern,!0,e.state.shoptOptions.extglob);else if(w.type==="Literal")f+=me(w.value,!0,e.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")f+=be(w.value);else if(w.type==="DoubleQuoted"){let b=await n(e,w.parts);f+=be(b)}else if(w.type==="ParameterExpansion"){let b=await r(e,w);f+=me(b,!0,e.state.shoptOptions.extglob)}else{let b=await r(e,w);f+=be(b)}let h=l.replacement?await n(e,l.replacement.parts):"",p=f;l.anchor==="start"?p=`^${f}`:l.anchor==="end"&&(p=`${f}$`);let m=[];try{let w=V(p,l.all?"g":"");for(let b of u)m.push(w.replace(b,h))}catch{m.push(...u)}let d=tt(e.state.env),g=ct(e.state.env);if(o){let w=fe(e.state.env),b=m.join(w);return g?{values:b?[b]:[],quoted:!1}:{values:Le(b,d),quoted:!1}}if(g)return{values:m,quoted:!1};let y=[];for(let w of m)w===""?y.push(""):y.push(...Le(w,d));return{values:y,quoted:!1}}async function T2(e,t,n,r){let s=-1,i="",o=!1;for(let y=0;y<t.length;y++){let w=t[y];if(w.type==="ParameterExpansion"&&w.operation?.type==="PatternRemoval"){let b=w.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=y,i=b[1],o=b[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=ae(e,i),u=c.map(([,y])=>y);if(c.length===0){let y=e.state.env.get(i);y!==void 0&&(u=[y])}if(u.length===0)return{values:[],quoted:!1};let f="",h=e.state.shoptOptions.extglob;if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=me(y.pattern,l.greedy,h);else if(y.type==="Literal")f+=me(y.value,l.greedy,h);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=be(y.value);else if(y.type==="DoubleQuoted"){let w=await n(e,y.parts);f+=be(w)}else if(y.type==="ParameterExpansion"){let w=await r(e,y);f+=me(w,l.greedy,h)}else{let w=await r(e,y);f+=be(w)}let p=[];for(let y of u)p.push(Sn(y,f,l.side,l.greedy));let m=tt(e.state.env),d=ct(e.state.env);if(o){let y=fe(e.state.env),w=p.join(y);return d?{values:w?[w]:[],quoted:!1}:{values:Le(w,m),quoted:!1}}if(d)return{values:p,quoted:!1};let g=[];for(let y of p)y===""?g.push(""):g.push(...Le(y,m));return{values:g,quoted:!1}}async function P2(e,t,n,r){let s=-1,i=!1;for(let g=0;g<t.length;g++){let y=t[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){s=g,i=y.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=Number.parseInt(e.state.env.get("#")||"0",10),c=[];for(let g=1;g<=l;g++)c.push(e.state.env.get(String(g))||"");if(c.length===0)return{values:[],quoted:!1};let u="",f=e.state.shoptOptions.extglob;if(a.pattern)for(let g of a.pattern.parts)if(g.type==="Glob")u+=me(g.pattern,a.greedy,f);else if(g.type==="Literal")u+=me(g.value,a.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=be(g.value);else if(g.type==="DoubleQuoted"){let y=await n(e,g.parts);u+=be(y)}else if(g.type==="ParameterExpansion"){let y=await r(e,g);u+=me(y,a.greedy,f)}else{let y=await r(e,g);u+=be(y)}let h=[];for(let g of c)h.push(Sn(g,u,a.side,a.greedy));let p=tt(e.state.env),m=ct(e.state.env);if(i){let g=fe(e.state.env),y=h.join(g);return m?{values:y?[y]:[],quoted:!1}:{values:Le(y,p),quoted:!1}}if(m)return{values:h,quoted:!1};let d=[];for(let g of h)g===""?d.push(""):d.push(...Le(g,p));return{values:d,quoted:!1}}async function D2(e,t,n,r){let s=-1,i=!1;for(let b=0;b<t.length;b++){let x=t[b];if(x.type==="ParameterExpansion"&&(x.parameter==="@"||x.parameter==="*")&&x.operation?.type==="Substring"){s=b,i=x.parameter==="*";break}}if(s===-1)return null;let a=t[s].operation,l=a.offset?await n(e,a.offset.expression):0,c=a.length?await n(e,a.length.expression):void 0,u=Number.parseInt(e.state.env.get("#")||"0",10),f=[];for(let b=1;b<=u;b++)f.push(e.state.env.get(String(b))||"");let h=e.state.env.get("0")||"bash",p;if(l<=0){let b=[h,...f],x=b.length+l;if(x<0)p=[];else{let S=l<0?x:0;if(c!==void 0){let C=c<0?b.length+c:S+c;p=b.slice(S,Math.max(S,C))}else p=b.slice(S)}}else{let b=l-1;if(b>=f.length)p=[];else if(c!==void 0){let x=c<0?f.length+c:b+c;p=f.slice(b,Math.max(b,x))}else p=f.slice(b)}let m="";for(let b=0;b<s;b++)m+=await r(e,t[b]);let d="";for(let b=s+1;b<t.length;b++)d+=await r(e,t[b]);let g=tt(e.state.env),y=ct(e.state.env);if(p.length===0){let b=m+d;return b?y?{values:[b],quoted:!1}:{values:Le(b,g),quoted:!1}:{values:[],quoted:!1}}let w;if(i){let b=fe(e.state.env),x=m+p.join(b)+d;y?w=x?[x]:[]:w=Le(x,g)}else if(y)p.length===1?w=[m+p[0]+d]:w=[m+p[0],...p.slice(1,-1),p[p.length-1]+d];else{w=[];for(let b=0;b<p.length;b++){let x=p[b];if(b===0&&(x=m+x),b===p.length-1&&(x=x+d),x==="")w.push("");else{let S=Le(x,g);w.push(...S)}}}return{values:await qi(e,w),quoted:!1}}async function L2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].parameter!=="@"&&t[0].parameter!=="*"||t[0].operation)return null;let n=t[0].parameter==="*",r=Number.parseInt(e.state.env.get("#")||"0",10);if(r===0)return{values:[],quoted:!1};let s=[];for(let c=1;c<=r;c++)s.push(e.state.env.get(String(c))||"");let i=tt(e.state.env),o=ct(e.state.env),a=Wi(e.state.env),l;if(n)if(o)l=s.filter(c=>c!=="");else{let c=fe(e.state.env),u=s.join(c);l=Le(u,i)}else if(o)l=s.filter(c=>c!=="");else if(a){l=[];for(let c of s){if(c==="")continue;let u=Le(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=Le(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await qi(e,l),quoted:!1}}async function _2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation)return null;let n=t[0].parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!n)return null;let r=n[1],s=n[2]==="*",i=ae(e,r),o;if(i.length===0){let f=e.state.env.get(r);if(f!==void 0)o=[f];else return{values:[],quoted:!1}}else o=i.map(([,f])=>f);let a=tt(e.state.env),l=ct(e.state.env),c=Wi(e.state.env),u;if(s)if(l)u=o.filter(f=>f!=="");else{let f=fe(e.state.env),h=o.join(f);u=Le(h,a)}else if(l)u=o.filter(f=>f!=="");else if(c){u=[];for(let f of o){if(f==="")continue;let h=Le(f,a);u.push(...h)}}else{u=[];for(let f of o)if(f==="")u.push("");else{let h=Le(f,a);u.push(...h)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await qi(e,u),quoted:!1}}function M2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=_r(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=tt(e.state.env),i=ct(e.state.env),o;if(n.star)if(i)o=r;else{let a=fe(e.state.env),l=r.join(a);o=Le(l,s)}else if(i)o=r;else{o=[];for(let a of r){let l=Le(a,s);o.push(...l)}}return{values:o,quoted:!1}}function F2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="ArrayKeys")return null;let n=t[0].operation,s=ae(e,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=tt(e.state.env),o=ct(e.state.env),a;if(n.star)if(o)a=s;else{let l=fe(e.state.env),c=s.join(l);a=Le(c,i)}else if(o)a=s;else{a=[];for(let l of s){let c=Le(l,i);a.push(...c)}}return{values:a,quoted:!1}}async function U2(e,t,n){let r=-1;for(let h=0;h<t.length;h++){let p=t[h];if(p.type==="ParameterExpansion"&&(p.parameter==="@"||p.parameter==="*")&&!p.operation){r=h;break}}if(r===-1||t.length<=1)return null;let s=Number.parseInt(e.state.env.get("#")||"0",10),i=[];for(let h=1;h<=s;h++)i.push(e.state.env.get(String(h))||"");let o="";for(let h=0;h<r;h++)o+=await n(e,t[h]);let a="";for(let h=r+1;h<t.length;h++)a+=await n(e,t[h]);let l=tt(e.state.env),c=ct(e.state.env),u=Wi(e.state.env);if(s===0){let h=o+a;return{values:h?[h]:[],quoted:!1}}let f;{let h=[];for(let p=0;p<i.length;p++){let m=i[p];p===0&&(m=o+m),p===i.length-1&&(m=m+a),h.push(m)}if(c)f=h.filter(p=>p!=="");else if(u){f=[];for(let p of h){if(p==="")continue;let m=Le(p,l);f.push(...m)}}else{f=[];for(let p of h)if(p==="")f.push("");else{let m=Le(p,l);f.push(...m)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await qi(e,f),quoted:!1}}var W2=I(()=>{"use strict";Me();Mi();xe();Wt();Dr();Pr();Lr();nr();Rt()});async function z2(e,t,n){let r=t.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:o,hasArrayAtExpansion:a,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=ys(r),h=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(h&&h.length>1)return Fw(e,h,s);let p=await Uw(e,r,a,c,u,n);if(p!==null)return p;let m=await Bw(e,r,n);if(m!==null)return m;let d=await Hw(e,r,n);if(d!==null)return d;let g=await jw(e,r,n.expandPart);if(g!==null)return H2(e,g);if((i||o||l)&&!ct(e.state.env)){let w=tt(e.state.env),b=n.buildIfsCharClassPattern(w),x=await n.smartWordSplit(e,r,w,b,n.expandPart);return H2(e,x)}let y=await n.expandWordAsync(e,t);return Gw(e,t,r,y,s,n.expandWordForGlobbing)}async function Fw(e,t,n){let r=[];for(let s of t)if(!(!n&&s===""))if(!n&&!e.state.options.noglob&&mn(s,e.state.shoptOptions.extglob)){let i=await Zi(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function Uw(e,t,n,r,s,i){if(n){let o=w2(e,t);if(o!==null)return o}{let o=b2(e,t);if(o!==null)return o}{let o=await f2(e,t);if(o!==null)return o}{let o=await h2(e,t,n,i.expandPart,i.expandWordPartsAsync);if(o!==null)return o}{let o=await p2(e,t,n,i.expandPart);if(o!==null)return o}{let o=await m2(e,t,i.evaluateArithmetic);if(o!==null)return o}{let o=g2(e,t);if(o!==null)return o}{let o=await l2(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}{let o=await c2(e,t,i.expandWordPartsAsync,i.expandPart);if(o!==null)return o}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let o=Ww(e,t);if(o!==null)return o}{let o=await E2(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(o!==null)return o}{let o=await A2(e,t);if(o!==null)return o}{let o=await S2(e,t);if(o!==null)return o}return null}function Ww(e,t){let n=t[0];if(n.type!=="DoubleQuoted")return null;if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="VarNamePrefix"){let r=n.parts[0].operation,s=_r(e,r.prefix);return r.star?{values:[s.join(fe(e.state.env))],quoted:!0}:{values:s,quoted:!0}}if(n.parts.length===1&&n.parts[0].type==="ParameterExpansion"&&n.parts[0].operation?.type==="ArrayKeys"){let r=n.parts[0].operation,i=ae(e,r.array).map(([o])=>String(o));return r.star?{values:[i.join(fe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function Bw(e,t,n){{let r=await k2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await v2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await I2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await O2(e,t,n.expandPart);if(r!==null)return r}return null}async function Hw(e,t,n){{let r=await $2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await T2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await P2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await D2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await L2(e,t);if(r!==null)return r}{let r=await _2(e,t);if(r!==null)return r}{let r=M2(e,t);if(r!==null)return r}{let r=F2(e,t);if(r!==null)return r}{let r=await U2(e,t,n.expandPart);if(r!==null)return r}return null}function B2(e){if(e.type!=="DoubleQuoted")return null;for(let t=0;t<e.parts.length;t++){let n=e.parts[t];if(n.type!=="ParameterExpansion"||n.operation)continue;let r=n.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(r)return{type:"array",name:r[1],atIndex:t,isStar:r[2]==="*"};if(n.parameter==="@"||n.parameter==="*")return{type:"positional",atIndex:t,isStar:n.parameter==="*"}}return null}async function zw(e,t,n,r){let s="";for(let a=0;a<n.atIndex;a++)s+=await r(e,t.parts[a]);let i="";for(let a=n.atIndex+1;a<t.parts.length;a++)i+=await r(e,t.parts[a]);let o;if(n.type==="array"){if(o=ae(e,n.name).map(([,l])=>l),o.length===0){let l=e.state.env.get(n.name);l!==void 0&&(o=[l])}}else{let a=Number.parseInt(e.state.env.get("#")||"0",10);o=[];for(let l=1;l<=a;l++)o.push(e.state.env.get(String(l))||"")}if(n.isStar){let a=fe(e.state.env),l=o.join(a);return[s+l+i]}if(o.length===0){let a=s+i;return a?[a]:[]}return o.length===1?[s+o[0]+i]:[s+o[0],...o.slice(1,-1),o[o.length-1]+i]}async function jw(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(B2(l)){r=!0;break}if(!r)return null;let s=tt(e.state.env),i=ct(e.state.env),o=[];for(let l of t){let c=B2(l);if(c&&l.type==="DoubleQuoted"){let u=await zw(e,l,c,n);o.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(e,l);o.push([u])}else if(l.type==="Literal")o.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Le(u,s);o.push(f)}}else{let u=await n(e,l);if(i)o.push(u?[u]:[]);else{let f=Le(u,s);o.push(f)}}}let a=[];for(let l of o)if(l.length!==0)if(a.length===0)a.push(...l);else{let c=a.length-1;a[c]=a[c]+l[0];for(let u=1;u<l.length;u++)a.push(l[u])}return a}async function H2(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(mn(r,e.state.shoptOptions.extglob)){let s=await Zi(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function Zi(e,t){let n=new Dn(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),r=await n.expand(t);if(r.length>0)return r;if(n.hasFailglob())throw new an(t);return n.hasNullglob()?[]:[t]}async function Gw(e,t,n,r,s,i){let o=n.some(a=>a.type==="Glob");if(!e.state.options.noglob&&o){let a=await i(e,t);if(mn(a,e.state.shoptOptions.extglob)){let c=await Zi(e,a);if(c.length>0&&c[0]!==a)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=Vl(r);if(!ct(e.state.env)){let c=tt(e.state.env);return{values:Le(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!e.state.options.noglob&&mn(r,e.state.shoptOptions.extglob)){let a=await i(e,t);if(mn(a,e.state.shoptOptions.extglob)){let l=await Zi(e,a);if(l.length>0&&l[0]!==a)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(o&&!s){let a=Vl(r);if(!ct(e.state.env)){let l=tt(e.state.env);return{values:Le(a,l),quoted:!1}}return{values:[a],quoted:!1}}return{values:[r],quoted:s}}var j2=I(()=>{"use strict";Mi();xe();Wt();Fi();u2();d2();y2();x2();Pr();C2();nr();R2();W2();Rt()});async function V2(e,t){let n=t.operation;if(!n||n.type!=="DefaultValue"&&n.type!=="AssignDefault"&&n.type!=="UseAlternative")return null;let r=n.word;if(!r||r.parts.length===0)return null;let s=await dn(e,t.parameter),o=await Se(e,t.parameter,!1)==="",a=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(a&&o):l=!s||a&&o,l?r.parts:null}function Vw(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function qw(e,t){if(t.type!=="ParameterExpansion")return null;let n=await V2(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>Vw(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function Zw(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?Ul(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&Om(e))}async function q2(e,t,n,r,s){if(t.length===1&&t[0].type==="ParameterExpansion"){let h=t[0],p=await V2(e,h);if(p&&p.length>0&&p.length>1&&p.some(d=>d.type==="DoubleQuoted"||d.type==="SingleQuoted")&&p.some(d=>d.type==="Literal"||d.type==="ParameterExpansion"||d.type==="CommandSubstitution"||d.type==="ArithmeticExpansion"))return G2(e,p,n,r,s)}let i=[],o=!1;for(let h of t){let p=Zw(h),m=h.type==="DoubleQuoted"||h.type==="SingleQuoted",d=p?await qw(e,h):null,g=await s(e,h);i.push({value:g,isSplittable:p,isQuoted:m,mixedDefaultParts:d??void 0}),p&&(o=!0)}if(!o){let h=i.map(p=>p.value).join("");return h?[h]:[]}let a=[],l="",c=!1,u=!1,f=!1;for(let h of i)if(!h.isSplittable)u?h.isQuoted&&h.value===""?(l!==""&&a.push(l),a.push(""),c=!0,l="",u=!1,f=!0):h.value!==""?(l!==""&&a.push(l),l=h.value,u=!1,f=!1):(l+=h.value,f=!1):(l+=h.value,f=h.isQuoted&&h.value==="");else if(h.mixedDefaultParts){let p=await G2(e,h.mixedDefaultParts,n,r,s);if(p.length!==0)if(p.length===1)l+=p[0],c=!0;else{l+=p[0],a.push(l),c=!0;for(let m=1;m<p.length-1;m++)a.push(p[m]);l=p[p.length-1]}u=!1,f=!1}else{let{words:p,hadLeadingDelimiter:m,hadTrailingDelimiter:d}=Bi(h.value,n);if(f&&m&&l===""&&(a.push(""),c=!0),p.length===0)d&&(u=!0);else if(p.length===1)l+=p[0],c=!0,u=d;else{l+=p[0],a.push(l),c=!0;for(let g=1;g<p.length-1;g++)a.push(p[g]);l=p[p.length-1],u=d}f=!1}return l!==""?a.push(l):a.length===0&&c&&a.push(""),a}function Qw(e,t){return e.length>0&&t.includes(e[0])}async function G2(e,t,n,r,s){let i=[];for(let u of t){let h=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),p=await s(e,u);i.push({value:p,isSplittable:h})}let o=[],a="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(a!==""&&o.push(a),a=u.value,c=!1):a+=u.value;else{Qw(u.value,n)&&a!==""&&(o.push(a),a="",l=!0);let{words:h,hadTrailingDelimiter:p}=Bi(u.value,n);if(h.length===0)p&&(c=!0);else if(h.length===1)a+=h[0],l=!0,c=p;else{a+=h[0],o.push(a),l=!0;for(let m=1;m<h.length-1;m++)o.push(h[m]);a=h[h.length-1],c=p}}return a!==""?o.push(a):o.length===0&&l&&o.push(""),o}var Z2=I(()=>{"use strict";Rt();Wt();Fi()});function Q2(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function K2(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var X2=I(()=>{"use strict"});var tc={};Q(tc,{escapeGlobChars:()=>$t,escapeRegexChars:()=>Tr,expandRedirectTarget:()=>Es,expandWord:()=>se,expandWordForPattern:()=>Jl,expandWordForRegex:()=>Yl,expandWordWithGlob:()=>rn,getArrayElements:()=>ae,getVariable:()=>Se,hasQuotedMultiValueAt:()=>xs,isArray:()=>An,isWordFullyQuoted:()=>Xl});function bs(e,t,n){if(e.length>t)throw new re(`${n}: string length limit exceeded (${t} bytes)`,"string_length")}async function nn(e,t,n=!1){let r=[];for(let s of t)r.push(await Bt(e,s,n));return r.join("")}function Kw(e){return K2(e)}function Xl(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!Kw(t))return!1;return!0}function Xw(e,t,n=!1){let r=Q2(t);if(r!==null)return r;switch(t.type){case"TildeExpansion":return n?t.user===null?"~":`~${t.user}`:t.user===null?e.state.env.get("HOME")??"/home/user":t.user==="root"?"/root":`~${t.user}`;case"Glob":return Ql(e,t.pattern);default:return null}}async function se(e,t){return ec(e,t)}async function Yl(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped")n.push(`\\${r.value}`);else if(r.type==="SingleQuoted")n.push(r.value);else if(r.type==="DoubleQuoted"){let s=await nn(e,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await Bt(e,r);n.push(Tr(s))}else n.push(await Bt(e,r));return n.join("")}async function Jl(e,t){let n=[];for(let r of t.parts)if(r.type==="Escaped"){let s=r.value;"()|*?[]".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="SingleQuoted")n.push($t(r.value));else if(r.type==="DoubleQuoted"){let s=await nn(e,r.parts);n.push($t(s))}else n.push(await Bt(e,r));return n.join("")}async function Y2(e,t){let n=[];for(let r of t.parts)if(r.type==="SingleQuoted")n.push($t(r.value));else if(r.type==="Escaped"){let s=r.value;"*?[]\\()|".includes(s)?n.push(`\\${s}`):n.push(s)}else if(r.type==="DoubleQuoted"){let s=await nn(e,r.parts);n.push($t(s))}else r.type==="Glob"?n2(r.pattern)?n.push(await s2(e,r.pattern)):n.push(Ql(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await Bt(e,r));return n.join("")}function Ki(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&Ki(t.parts))return!0;return!1}async function J2(e,t,n={count:0}){if(n.count>Kl)return[[]];let r=[[]];for(let s of t)if(s.type==="BraceExpansion"){let i=[],o=!1,a="";for(let u of s.items)if(u.type==="Range"){let f=Gl(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let h of f.expanded)n.count++,i.push(h);else{o=!0,a=f.literal;break}}else{let f=await J2(e,u.word.parts,n);for(let h of f){n.count++;let p=[];for(let m of h)typeof m=="string"?p.push(m):p.push(await Bt(e,m));i.push(p.join(""))}}if(o){for(let u of r)n.count++,u.push(a);continue}if(r.length*i.length>Yw||n.count>Kl)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>Kl)return c.length>0?c:r;c.push([...u,f])}r=c}else for(let i of r)n.count++,i.push(s);return r}async function e6(e,t){let n=t.parts;if(!Ki(n))return[await se(e,t)];let r=await J2(e,n),s=[];for(let i of r){let o=[];for(let a of i)typeof a=="string"?o.push(a):o.push(await Bt(e,a));s.push(o2(e,o.join("")))}return s}function Jw(){return{expandWordAsync:ec,expandWordForGlobbing:Y2,expandWordWithBracesAsync:e6,expandWordPartsAsync:nn,expandPart:Bt,expandParameterAsync:Qi,hasBraceExpansion:Ki,evaluateArithmetic:J,buildIfsCharClassPattern:Rm,smartWordSplit:q2}}async function rn(e,t){return z2(e,t,Jw())}function eb(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function xs(e,t){if(Number.parseInt(e.state.env.get("#")||"0",10)<2)return!1;function r(s){for(let i of s)if(i.type==="DoubleQuoted"){for(let o of i.parts)if(o.type==="ParameterExpansion"&&o.parameter==="@"&&!o.operation)return!0}return!1}return r(t.parts)}async function Es(e,t){if(xs(e,t))return{error:`bash: $@: ambiguous redirect
780
780
  `};let n=t.parts,{hasQuoted:r}=ys(n);if(Ki(n)&&(await e6(e,t)).length>1)return{error:`bash: ${n.map(p=>p.type==="Literal"?p.value:p.type==="BraceExpansion"?`{${p.items.map(d=>{if(d.type==="Range"){let g=d.step?`..${d.step}`:"";return`${d.startStr??d.start}..${d.endStr??d.end}${g}`}return d.word.parts.map(g=>g.type==="Literal"?g.value:"").join("")}).join(",")}}`:"").join("")}: ambiguous redirect
781
781
  `};let s=await ec(e,t),{hasParamExpansion:i,hasCommandSub:o}=ys(n);if((i||o)&&!r&&!ct(e.state.env)){let f=tt(e.state.env);if(Le(s,f).length>1)return{error:`bash: $${eb(n)}: ambiguous redirect
782
782
  `}}if(r||e.state.options.noglob)return{target:s};let l=await Y2(e,t);if(!mn(l,e.state.shoptOptions.extglob))return{target:s};let c=new Dn(e.fs,e.state.cwd,e.state.env,{globstar:e.state.shoptOptions.globstar,nullglob:e.state.shoptOptions.nullglob,failglob:e.state.shoptOptions.failglob,dotglob:e.state.shoptOptions.dotglob,extglob:e.state.shoptOptions.extglob,globskipdots:e.state.shoptOptions.globskipdots,maxGlobOperations:e.limits.maxGlobOperations}),u=await c.expand(l);return u.length===0?c.hasFailglob()?{error:`bash: no match: ${s}
783
783
  `}:{target:s}:u.length===1?{target:u[0]}:{error:`bash: ${s}: ambiguous redirect
784
- `}}async function ec(e,t){let n=t.parts,r=n.length;if(r===1){let o=await Bt(e,n[0]);return bs(o,e.limits.maxStringLength,"word expansion"),o}let s=[];for(let o=0;o<r;o++)s.push(await Bt(e,n[o]));let i=s.join("");return bs(i,e.limits.maxStringLength,"word expansion"),i}async function Bt(e,t,n=!1){if(t.type==="ParameterExpansion")return Qi(e,t,n);let r=Xw(e,t,n);if(r!==null)return r;switch(t.type){case"DoubleQuoted":{let s=[];for(let i of t.parts)s.push(await Bt(e,i,!0));return s.join("")}case"CommandSubstitution":{let s=Um(t.body);if(s)try{let h=await se(e,s.target),p=h.startsWith("/")?h:`${e.state.cwd}/${h}`,m=await e.fs.readFile(p);e.state.lastExitCode=0,e.state.env.set("?","0");let d=m.replace(/\n+$/,"");return bs(d,e.limits.maxStringLength,"command substitution"),d}catch(h){if(h instanceof re)throw h;return e.state.lastExitCode=1,e.state.env.set("?","1"),""}let i=e.substitutionDepth??0,o=e.limits.maxSubstitutionDepth;if(i>=o)throw new re(`Command substitution nesting limit exceeded (${o})`,"substitution_depth");let a=e.substitutionDepth;e.substitutionDepth=i+1;let l=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let c=new Map(e.state.env),u=e.state.cwd,f=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let h=await e.executeScript(t.body),p=h.exitCode;e.state.env=c,e.state.cwd=u,e.state.suppressVerbose=f,e.state.lastExitCode=p,e.state.env.set("?",String(p)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+h.stderr),e.state.bashPid=l,e.substitutionDepth=a;let m=h.stdout.replace(/\n+$/,"");return bs(m,e.limits.maxStringLength,"command substitution"),m}catch(h){if(e.state.env=c,e.state.cwd=u,e.state.bashPid=l,e.substitutionDepth=a,e.state.suppressVerbose=f,h instanceof re)throw h;if(h instanceof pe){e.state.lastExitCode=h.exitCode,e.state.env.set("?",String(h.exitCode)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+h.stderr);let p=h.stdout.replace(/\n+$/,"");return bs(p,e.limits.maxStringLength,"command substitution"),p}throw h}}case"ArithmeticExpansion":{let s=t.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let o=await _m(e,s),a=new ce,l=Ae(a,o);return String(await J(e,l.expression,!0))}return String(await J(e,t.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of t.items)if(i.type==="Range"){let o=Gl(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(await se(e,i.word));return s.join(" ")}default:return""}}async function Qi(e,t,n=!1){let{parameter:r}=t,{operation:s}=t,i=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,h,p]=i;if(e.state.associativeArrays?.has(h)||p.includes("$(")||p.includes("`")||p.includes("${")){let d=await jl(e,p);r=`${h}[${d}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&Te(e,r)){let h=xt(e,r);if(h&&h!==r){let p=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(p){let[,m,d]=p;if(e.state.associativeArrays?.has(m)||d.includes("$(")||d.includes("`")||d.includes("${")){let y=await jl(e,d);r=`${m}[${y}]`}}}}let o=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),a=await Se(e,r,!o);if(!s)return a;let l=!await dn(e,r),{isEmpty:c,effectiveValue:u}=e2(e,r,a,n),f={value:a,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:n};switch(s.type){case"DefaultValue":return Bm(e,s,f,nn);case"AssignDefault":return Hm(e,r,s,f,nn);case"ErrorIfUnset":return zm(e,r,s,f,nn);case"UseAlternative":return jm(e,s,f,nn);case"PatternRemoval":return Gm(e,a,s,nn,Bt);case"PatternReplacement":return Vm(e,a,s,nn,Bt);case"Length":return qm(e,r,a);case"LengthSliceError":throw new yt(r);case"BadSubstitution":throw new yt(s.text);case"Substring":return Zm(e,r,a,s);case"CaseModification":return Qm(e,a,s,nn,Qi);case"Transform":return Km(e,r,a,l,s);case"Indirection":return Xm(e,r,a,l,s,Qi,n);case"ArrayKeys":return Ym(e,s);case"VarNamePrefix":return Jm(e,s);default:return a}}var Yw,Kl,At=I(()=>{"use strict";pt();Qe();Mi();Et();xe();Fi();Mm();Fm();Wm();Pr();t2();i2();a2();Ot();j2();Z2();Wt();en();X2();Pr();Ot();Yw=1e4,Kl=1e5});function tb(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":if(t===0)throw new $e("division by 0");return Math.trunc(e/t);case"%":if(t===0)throw new $e("division by 0");return e%t;case"**":if(t<0)throw new $e("exponent less than 0");return e**t;case"<<":return e<<t;case">>":return e>>t;case"<":return e<t?1:0;case"<=":return e<=t?1:0;case">":return e>t?1:0;case">=":return e>=t?1:0;case"==":return e===t?1:0;case"!=":return e!==t?1:0;case"&":return e&t;case"|":return e|t;case"^":return e^t;case",":return t;default:return 0}}function t6(e,t,n){switch(n){case"=":return t;case"+=":return e+t;case"-=":return e-t;case"*=":return e*t;case"/=":return t!==0?Math.trunc(e/t):0;case"%=":return t!==0?e%t:0;case"<<=":return e<<t;case">>=":return e>>t;case"&=":return e&t;case"|=":return e|t;case"^=":return e^t;default:return t}}function nb(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return e===0?1:0;case"~":return~e;default:return e}}async function rb(e,t){let n=e.state.env.get(t);if(n!==void 0)return n;let r=e.state.env.get(`${t}_0`);return r!==void 0?r:await Se(e,t)}function sb(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\d+$/.test(e.trim()))return t;let n=e.trim();if(!n)return 0;try{let r=new ce,{expr:s,pos:i}=Ut(r,n,0);if(i<n.length){let o=n.slice(i).trim().split(/\s+/)[0];throw new $e(`${n}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:t||0}catch(r){if(r instanceof $e)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new $e(`${n}: syntax error in expression (error token is "${s}")`)}}async function nc(e,t){if(!t)return 0;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(t.trim()))return n;let r=t.trim();if(!r)return 0;let s=new ce,{expr:i,pos:o}=Ut(s,r,0);if(o<r.length){let a=r.slice(o).trim(),l=a.split(/\s+/)[0]||a;throw new $e(`syntax error in expression (error token is "${l}")`,"","")}return await J(e,i)}async function rc(e,t,n=new Set){if(n.has(t))return 0;n.add(t);let r=await rb(e,t);if(!r)return 0;let s=Number.parseInt(r,10);if(!Number.isNaN(s)&&/^-?\d+$/.test(r.trim()))return s;let i=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return await rc(e,i,n);let o=new ce,{expr:a,pos:l}=Ut(o,i,0);if(l<i.length){let c=i.slice(l).trim(),u=c.split(/\s+/)[0]||c;throw new $e(`${i}: syntax error in expression (error token is "${u}")`)}return await J(e,a)}async function Xi(e,t){if(t.startsWith("#")){let f=t.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let m=h[1],d=ae(e,m);return String(d.length)}let p=e.state.env.get(f)||"";return String(p.length)}if(t.startsWith("!")){let f=t.slice(1),h=e.state.env.get(f)||"";return e.state.env.get(h)||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let h=t.indexOf(f);h>0&&(r===-1||h<r)&&(r=h,s=f)}if(r===-1)return await Se(e,t);let i=t.slice(0,r),o=t.slice(r+s.length),a=e.state.env.get(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?(e.state.env.set(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||""}}async function J(e,t,n=!1){switch(t.type){case"ArithNumber":if(Number.isNaN(t.value))throw new $e("value too great for base");return t.value;case"ArithVariable":return await rc(e,t.name);case"ArithSpecialVar":{let s=(await Se(e,t.name)).trim();if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s))return i;let o=new ce,{expr:a}=Ut(o,s,0);return await J(e,a)}case"ArithNested":return await J(e,t.expression);case"ArithCommandSubst":{if(e.execFn){let r=await e.execFn(t.command);r.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+r.stderr);let s=r.stdout.trim();return Number.parseInt(s,10)||0}return 0}case"ArithBracedExpansion":{let r=await Xi(e,t.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=await Xi(e,t.baseExpr),s=Number.parseInt(r,10);if(s<2||s>64)return 0;let i=`${s}#${t.value}`;return ms(i)}case"ArithDynamicNumber":{let s=await Xi(e,t.prefix)+t.suffix;return ms(s)}case"ArithArrayElement":{let r=e.state.associativeArrays?.has(t.array),s=async i=>{let o=e.state.env.get(i);return o!==void 0?await nc(e,o):0};if(t.stringKey!==void 0)return await s(`${t.array}_${t.stringKey}`);if(r&&t.index?.type==="ArithVariable"&&!t.index.hasDollarPrefix)return await s(`${t.array}_${t.index.name}`);if(r&&t.index?.type==="ArithVariable"&&t.index.hasDollarPrefix){let i=await Se(e,t.index.name);return await s(`${t.array}_${i}`)}if(t.index){let i=await J(e,t.index,n);if(i<0){let l=ae(e,t.array),c=e.state.currentLine;if(l.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
784
+ `}}async function ec(e,t){let n=t.parts,r=n.length;if(r===1){let o=await Bt(e,n[0]);return bs(o,e.limits.maxStringLength,"word expansion"),o}let s=[];for(let o=0;o<r;o++)s.push(await Bt(e,n[o]));let i=s.join("");return bs(i,e.limits.maxStringLength,"word expansion"),i}async function Bt(e,t,n=!1){if(t.type==="ParameterExpansion")return Qi(e,t,n);let r=Xw(e,t,n);if(r!==null)return r;switch(t.type){case"DoubleQuoted":{let s=[];for(let i of t.parts)s.push(await Bt(e,i,!0));return s.join("")}case"CommandSubstitution":{let s=Um(t.body);if(s)try{let h=await se(e,s.target),p=h.startsWith("/")?h:`${e.state.cwd}/${h}`,m=await e.fs.readFile(p);e.state.lastExitCode=0,e.state.env.set("?","0");let d=m.replace(/\n+$/,"");return bs(d,e.limits.maxStringLength,"command substitution"),d}catch(h){if(h instanceof re)throw h;return e.state.lastExitCode=1,e.state.env.set("?","1"),""}let i=e.substitutionDepth??0,o=e.limits.maxSubstitutionDepth;if(i>=o)throw new re(`Command substitution nesting limit exceeded (${o})`,"substitution_depth");let a=e.substitutionDepth;e.substitutionDepth=i+1;let l=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let c=new Map(e.state.env),u=e.state.cwd,f=e.state.suppressVerbose;e.state.suppressVerbose=!0;try{let h=await e.executeScript(t.body),p=h.exitCode;e.state.env=c,e.state.cwd=u,e.state.suppressVerbose=f,e.state.lastExitCode=p,e.state.env.set("?",String(p)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+h.stderr),e.state.bashPid=l,e.substitutionDepth=a;let m=h.stdout.replace(/\n+$/,"");return bs(m,e.limits.maxStringLength,"command substitution"),m}catch(h){if(e.state.env=c,e.state.cwd=u,e.state.bashPid=l,e.substitutionDepth=a,e.state.suppressVerbose=f,h instanceof re)throw h;if(h instanceof pe){e.state.lastExitCode=h.exitCode,e.state.env.set("?",String(h.exitCode)),h.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+h.stderr);let p=h.stdout.replace(/\n+$/,"");return bs(p,e.limits.maxStringLength,"command substitution"),p}throw h}}case"ArithmeticExpansion":{let s=t.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let o=await _m(e,s),a=new ce,l=Ae(a,o);return String(await J(e,l.expression,!0))}return String(await J(e,t.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of t.items)if(i.type==="Range"){let o=Gl(i.start,i.end,i.step,i.startStr,i.endStr);if(o.expanded)s.push(...o.expanded);else return o.literal}else s.push(await se(e,i.word));return s.join(" ")}default:return""}}async function Qi(e,t,n=!1){let{parameter:r}=t,{operation:s}=t,i=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,h,p]=i;if(e.state.associativeArrays?.has(h)||p.includes("$(")||p.includes("`")||p.includes("${")){let d=await jl(e,p);r=`${h}[${d}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&Te(e,r)){let h=xt(e,r);if(h&&h!==r){let p=h.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(p){let[,m,d]=p;if(e.state.associativeArrays?.has(m)||d.includes("$(")||d.includes("`")||d.includes("${")){let y=await jl(e,d);r=`${m}[${y}]`}}}}let o=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),a=await Se(e,r,!o);if(!s)return a;let l=!await dn(e,r),{isEmpty:c,effectiveValue:u}=e2(e,r,a,n),f={value:a,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:n};switch(s.type){case"DefaultValue":return Bm(e,s,f,nn);case"AssignDefault":return Hm(e,r,s,f,nn);case"ErrorIfUnset":return zm(e,r,s,f,nn);case"UseAlternative":return jm(e,s,f,nn);case"PatternRemoval":return Gm(e,a,s,nn,Bt);case"PatternReplacement":return Vm(e,a,s,nn,Bt);case"Length":return qm(e,r,a);case"LengthSliceError":throw new yt(r);case"BadSubstitution":throw new yt(s.text);case"Substring":return Zm(e,r,a,s);case"CaseModification":return Qm(e,a,s,nn,Qi);case"Transform":return Km(e,r,a,l,s);case"Indirection":return Xm(e,r,a,l,s,Qi,n);case"ArrayKeys":return Ym(e,s);case"VarNamePrefix":return Jm(e,s);default:return a}}var Yw,Kl,At=I(()=>{"use strict";pt();Qe();Mi();Et();xe();Fi();Mm();Fm();Wm();Pr();t2();i2();a2();Rt();j2();Z2();Wt();en();X2();Pr();Rt();Yw=1e4,Kl=1e5});function tb(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":if(t===0)throw new $e("division by 0");return Math.trunc(e/t);case"%":if(t===0)throw new $e("division by 0");return e%t;case"**":if(t<0)throw new $e("exponent less than 0");return e**t;case"<<":return e<<t;case">>":return e>>t;case"<":return e<t?1:0;case"<=":return e<=t?1:0;case">":return e>t?1:0;case">=":return e>=t?1:0;case"==":return e===t?1:0;case"!=":return e!==t?1:0;case"&":return e&t;case"|":return e|t;case"^":return e^t;case",":return t;default:return 0}}function t6(e,t,n){switch(n){case"=":return t;case"+=":return e+t;case"-=":return e-t;case"*=":return e*t;case"/=":return t!==0?Math.trunc(e/t):0;case"%=":return t!==0?e%t:0;case"<<=":return e<<t;case">>=":return e>>t;case"&=":return e&t;case"|=":return e|t;case"^=":return e^t;default:return t}}function nb(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return e===0?1:0;case"~":return~e;default:return e}}async function rb(e,t){let n=e.state.env.get(t);if(n!==void 0)return n;let r=e.state.env.get(`${t}_0`);return r!==void 0?r:await Se(e,t)}function sb(e){if(!e)return 0;let t=Number.parseInt(e,10);if(!Number.isNaN(t)&&/^-?\d+$/.test(e.trim()))return t;let n=e.trim();if(!n)return 0;try{let r=new ce,{expr:s,pos:i}=Ut(r,n,0);if(i<n.length){let o=n.slice(i).trim().split(/\s+/)[0];throw new $e(`${n}: syntax error in expression (error token is "${o}")`)}return s.type==="ArithNumber"?s.value:t||0}catch(r){if(r instanceof $e)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new $e(`${n}: syntax error in expression (error token is "${s}")`)}}async function nc(e,t){if(!t)return 0;let n=Number.parseInt(t,10);if(!Number.isNaN(n)&&/^-?\d+$/.test(t.trim()))return n;let r=t.trim();if(!r)return 0;let s=new ce,{expr:i,pos:o}=Ut(s,r,0);if(o<r.length){let a=r.slice(o).trim(),l=a.split(/\s+/)[0]||a;throw new $e(`syntax error in expression (error token is "${l}")`,"","")}return await J(e,i)}async function rc(e,t,n=new Set){if(n.has(t))return 0;n.add(t);let r=await rb(e,t);if(!r)return 0;let s=Number.parseInt(r,10);if(!Number.isNaN(s)&&/^-?\d+$/.test(r.trim()))return s;let i=r.trim();if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i))return await rc(e,i,n);let o=new ce,{expr:a,pos:l}=Ut(o,i,0);if(l<i.length){let c=i.slice(l).trim(),u=c.split(/\s+/)[0]||c;throw new $e(`${i}: syntax error in expression (error token is "${u}")`)}return await J(e,a)}async function Xi(e,t){if(t.startsWith("#")){let f=t.slice(1),h=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(h){let m=h[1],d=ae(e,m);return String(d.length)}let p=e.state.env.get(f)||"";return String(p.length)}if(t.startsWith("!")){let f=t.slice(1),h=e.state.env.get(f)||"";return e.state.env.get(h)||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let h=t.indexOf(f);h>0&&(r===-1||h<r)&&(r=h,s=f)}if(r===-1)return await Se(e,t);let i=t.slice(0,r),o=t.slice(r+s.length),a=e.state.env.get(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?(e.state.env.set(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||""}}async function J(e,t,n=!1){switch(t.type){case"ArithNumber":if(Number.isNaN(t.value))throw new $e("value too great for base");return t.value;case"ArithVariable":return await rc(e,t.name);case"ArithSpecialVar":{let s=(await Se(e,t.name)).trim();if(!s)return 0;let i=Number.parseInt(s,10);if(!Number.isNaN(i)&&/^-?\d+$/.test(s))return i;let o=new ce,{expr:a}=Ut(o,s,0);return await J(e,a)}case"ArithNested":return await J(e,t.expression);case"ArithCommandSubst":{if(e.execFn){let r=await e.execFn(t.command);r.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+r.stderr);let s=r.stdout.trim();return Number.parseInt(s,10)||0}return 0}case"ArithBracedExpansion":{let r=await Xi(e,t.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=await Xi(e,t.baseExpr),s=Number.parseInt(r,10);if(s<2||s>64)return 0;let i=`${s}#${t.value}`;return ms(i)}case"ArithDynamicNumber":{let s=await Xi(e,t.prefix)+t.suffix;return ms(s)}case"ArithArrayElement":{let r=e.state.associativeArrays?.has(t.array),s=async i=>{let o=e.state.env.get(i);return o!==void 0?await nc(e,o):0};if(t.stringKey!==void 0)return await s(`${t.array}_${t.stringKey}`);if(r&&t.index?.type==="ArithVariable"&&!t.index.hasDollarPrefix)return await s(`${t.array}_${t.index.name}`);if(r&&t.index?.type==="ArithVariable"&&t.index.hasDollarPrefix){let i=await Se(e,t.index.name);return await s(`${t.array}_${i}`)}if(t.index){let i=await J(e,t.index,n);if(i<0){let l=ae(e,t.array),c=e.state.currentLine;if(l.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
785
785
  `,0;let f=Math.max(...l.map(([h])=>typeof h=="number"?h:0))+1+i;if(f<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${c}: ${t.array}: bad array subscript
786
- `,0;i=f}let o=`${t.array}_${i}`,a=e.state.env.get(o);if(a!==void 0)return nc(e,a);if(i===0){let l=e.state.env.get(t.array);if(l!==void 0)return nc(e,l)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new gt(`${t.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new $e("double subscript","","");case"ArithNumberSubscript":throw new $e(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new $e(t.message,"","",!0);case"ArithSingleQuote":{if(n)throw new $e(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value}case"ArithBinary":{if(t.operator==="||")return await J(e,t.left,n)||await J(e,t.right,n)?1:0;if(t.operator==="&&")return await J(e,t.left,n)&&await J(e,t.right,n)?1:0;let r=await J(e,t.left,n),s=await J(e,t.right,n);return tb(r,s,t.operator)}case"ArithUnary":{let r=await J(e,t.operand,n);if(t.operator==="++"||t.operator==="--"){if(t.operand.type==="ArithVariable"){let s=t.operand.name,i=Number.parseInt(await Se(e,s),10)||0,o=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(o)),t.prefix?o:i}if(t.operand.type==="ArithArrayElement"){let s=t.operand.array,i=e.state.associativeArrays?.has(s),o;if(t.operand.stringKey!==void 0)o=`${s}_${t.operand.stringKey}`;else if(i&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)o=`${s}_${t.operand.index.name}`;else if(i&&t.operand.index?.type==="ArithVariable"&&t.operand.index.hasDollarPrefix){let c=await Se(e,t.operand.index.name);o=`${s}_${c}`}else if(t.operand.index){let c=await J(e,t.operand.index,n);o=`${s}_${c}`}else return r;let a=Number.parseInt(e.state.env.get(o)||"0",10)||0,l=t.operator==="++"?a+1:a-1;return e.state.env.set(o,String(l)),t.prefix?l:a}if(t.operand.type==="ArithConcat"){let s="";for(let i of t.operand.parts)s+=await Mr(e,i,n);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,o=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(o)),t.prefix?o:i}}if(t.operand.type==="ArithDynamicElement"){let s="";if(t.operand.nameExpr.type==="ArithConcat")for(let i of t.operand.nameExpr.parts)s+=await Mr(e,i,n);else t.operand.nameExpr.type==="ArithVariable"&&(s=t.operand.nameExpr.hasDollarPrefix?await Se(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=await J(e,t.operand.subscript,n),o=`${s}_${i}`,a=Number.parseInt(e.state.env.get(o)||"0",10)||0,l=t.operator==="++"?a+1:a-1;return e.state.env.set(o,String(l)),t.prefix?l:a}}return r}return nb(r,t.operator)}case"ArithTernary":return await J(e,t.condition,n)?await J(e,t.consequent,n):await J(e,t.alternate,n);case"ArithAssignment":{let r=t.variable,s=r;if(t.stringKey!==void 0)s=`${r}_${t.stringKey}`;else if(t.subscript){let l=e.state.associativeArrays?.has(r);if(l&&t.subscript.type==="ArithVariable"&&!t.subscript.hasDollarPrefix)s=`${r}_${t.subscript.name}`;else if(l&&t.subscript.type==="ArithVariable"&&t.subscript.hasDollarPrefix){let c=await Se(e,t.subscript.name);s=`${r}_${c||"\\"}`}else if(l){let c=await J(e,t.subscript,n);s=`${r}_${c}`}else{let c=await J(e,t.subscript,n);if(c<0){let u=ae(e,r);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}s=`${r}_${c}`}}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,o=await J(e,t.value,n),a=t6(i,o,t.operator);return e.state.env.set(s,String(a)),a}case"ArithGroup":return await J(e,t.expression,n);case"ArithConcat":{let r="";for(let s of t.parts)r+=await Mr(e,s,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await rc(e,r):Number.parseInt(r,10)||0}case"ArithDynamicAssignment":{let r="";if(t.target.type==="ArithConcat")for(let l of t.target.parts)r+=await Mr(e,l,n);else t.target.type==="ArithVariable"&&(r=t.target.hasDollarPrefix?await Se(e,t.target.name):t.target.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=r;if(t.subscript){let l=await J(e,t.subscript,n);s=`${r}_${l}`}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,o=await J(e,t.value,n),a=t6(i,o,t.operator);return e.state.env.set(s,String(a)),a}case"ArithDynamicElement":{let r="";if(t.nameExpr.type==="ArithConcat")for(let a of t.nameExpr.parts)r+=await Mr(e,a,n);else t.nameExpr.type==="ArithVariable"&&(r=t.nameExpr.hasDollarPrefix?await Se(e,t.nameExpr.name):t.nameExpr.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=await J(e,t.subscript,n),i=`${r}_${s}`,o=e.state.env.get(i);return o!==void 0?sb(o):0}default:return 0}}async function Mr(e,t,n=!1){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await J(e,t,n));case"ArithVariable":return t.hasDollarPrefix?await Se(e,t.name):t.name;case"ArithSpecialVar":return await Se(e,t.name);case"ArithBracedExpansion":return await Xi(e,t.content);case"ArithCommandSubst":return e.execFn?(await e.execFn(t.command)).stdout.trim():"0";case"ArithConcat":{let r="";for(let s of t.parts)r+=await Mr(e,s,n);return r}default:return String(await J(e,t,n))}}var Et=I(()=>{"use strict";pt();Qe();xe();At()});var ll=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(nu(),tu))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(su(),ru))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(pu(),hu))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(yu(),gu))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(bu(),wu))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(Su(),Au))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Nu(),Cu))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(vu(),ku))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Ru(),Iu))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>($u(),Ou))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Pu(),Tu))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(_u(),Lu))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(Fu(),Mu))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(Wu(),Uu))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(ju(),zu))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(Vu(),Gu))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(Qu(),Zu))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(Yu(),Xu))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(js(),zs))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(js(),zs))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(js(),zs))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(zf(),Hf))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(e1(),Jf))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(T1(),$1))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(H1(),B1))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(j1(),z1))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(V1(),G1))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(Z1(),q1))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(X1(),K1))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(eh(),J1))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(nh(),th))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(ih(),sh))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(lh(),ah))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(fh(),uh))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(mh(),dh))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(bh(),wh))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Ah(),Eh))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Nh(),Ch))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(vh(),kh))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Rh(),Ih))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(Fh(),Mh))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(Wh(),Uh))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(Hh(),Bh))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(Gh(),jh))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(Zh(),qh))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Ea(),xa))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Ea(),xa))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Sa(),Aa))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Sa(),Aa))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(Xh(),Kh))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(Jh(),Yh))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Na(),Ca))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Na(),Ca))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(tp(),ep))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(va(),ka))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(va(),ka))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Rp(),Ip))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Tp(),$p))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Lp(),Dp))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Mp(),_p))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(Up(),Fp))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(Bp(),Wp))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(zp(),Hp))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Gp(),jp))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(qp(),Vp))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(Kp(),Qp))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(Yp(),Xp))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(ed(),Jp))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(Gd(),jd))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(qd(),Vd))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(Qd(),Zd))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(Xd(),Kd))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(Jd(),Yd))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(t0(),e0))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(r0(),n0))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(i0(),s0))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Ri(),Ii))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Ri(),Ii))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Ri(),Ii))).zcatCommand}],k5=[],E0=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(b0(),w0))).curlCommand}],x0=new Map;function cl(e){return{name:e.name,async execute(t,n){let r=x0.get(e.name);return r||(r=await e.load(),x0.set(e.name,r)),r.execute(t,n)}}}function v5(){return ll.map(e=>e.name)}function I5(){return E0.map(e=>e.name)}function A0(e){return(e?ll.filter(n=>e.includes(n.name)):ll).map(cl)}function S0(){return E0.map(cl)}function C0(){return k5.map(cl)}function N0(e){return"load"in e&&typeof e.load=="function"}function R5(e,t){return{name:e,execute:t}}function k0(e){let t=null;return{name:e.name,async execute(n,r){return t||(t=await e.load()),t.execute(n,r)}}}var O5=new TextEncoder,$5=new TextDecoder;function ul(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),n=>n.charCodeAt(0));if(t==="hex"){let n=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)n[r/2]=parseInt(e.slice(r,r+2),16);return n}return t==="binary"||t==="latin1"?Uint8Array.from(e,n=>n.charCodeAt(0)):O5.encode(e)}function v0(e,t){return t==="base64"?btoa(String.fromCharCode(...e)):t==="hex"?Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join(""):t==="binary"||t==="latin1"?String.fromCharCode(...e):$5.decode(e)}function Oi(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var $i=new TextEncoder;function T5(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function at(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Xn=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[n,r]of Object.entries(t))T5(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(t){if(!t||t==="/")return"/";let n=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(i=>i&&i!=="."),s=[];for(let i of r)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(t){let n=this.dirname(t);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,n,r,s){at(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Oi(r),a=ul(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(t,n){let r=await this.readFileBuffer(t),s=Oi(n);return v0(r,s)}async readFileBuffer(t){at(t,"open");let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return r.content instanceof Uint8Array?r.content:$i.encode(r.content)}async writeFile(t,n,r){this.writeFileSync(t,n,r)}async appendFile(t,n,r){at(t,"append");let s=this.normalizePath(t),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=Oi(r),a=ul(n,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:$i.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(t,n,r)}async exists(t){if(t.includes("\0"))return!1;try{let n=this.resolvePathWithSymlinks(t);return this.data.has(n)}catch{return!1}}async stat(t){at(t,"stat");let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=$i.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(t){at(t,"lstat");let n=this.resolveIntermediateSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=$i.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(t,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}resolveIntermediateSymlinks(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(s),s=this.resolveSymlink(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(s),s=this.resolveSymlink(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return s}async mkdir(t,n){this.mkdirSync(t,n)}mkdirSync(t,n){at(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){at(t,"scandir");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);s.add(n),n=this.resolveSymlink(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,n){at(t,"rm");let r=this.normalizePath(t),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(t,n,r){at(t,"cp"),at(n,"cp");let s=this.normalizePath(t),i=this.normalizePath(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);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,r)}}}async mv(t,n){await this.cp(t,n,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,n){if(n.startsWith("/"))return this.normalizePath(n);let r=t==="/"?`/${n}`:`${t}/${n}`;return this.normalizePath(r)}async chmod(t,n){at(t,"chmod");let r=this.normalizePath(t),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);s.mode=n}async symlink(t,n){at(n,"symlink");let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,n){at(t,"link"),at(n,"link");let r=this.normalizePath(t),s=this.normalizePath(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){at(t,"readlink");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){at(t,"realpath");let n=this.resolvePathWithSymlinks(t);if(!this.data.has(n))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return n}async utimes(t,n,r){at(t,"utimes");let s=this.normalizePath(t),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};fl();function P5(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function D5(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function L5(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function _5(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${R0}
786
+ `,0;i=f}let o=`${t.array}_${i}`,a=e.state.env.get(o);if(a!==void 0)return nc(e,a);if(i===0){let l=e.state.env.get(t.array);if(l!==void 0)return nc(e,l)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new gt(`${t.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new $e("double subscript","","");case"ArithNumberSubscript":throw new $e(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new $e(t.message,"","",!0);case"ArithSingleQuote":{if(n)throw new $e(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value}case"ArithBinary":{if(t.operator==="||")return await J(e,t.left,n)||await J(e,t.right,n)?1:0;if(t.operator==="&&")return await J(e,t.left,n)&&await J(e,t.right,n)?1:0;let r=await J(e,t.left,n),s=await J(e,t.right,n);return tb(r,s,t.operator)}case"ArithUnary":{let r=await J(e,t.operand,n);if(t.operator==="++"||t.operator==="--"){if(t.operand.type==="ArithVariable"){let s=t.operand.name,i=Number.parseInt(await Se(e,s),10)||0,o=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(o)),t.prefix?o:i}if(t.operand.type==="ArithArrayElement"){let s=t.operand.array,i=e.state.associativeArrays?.has(s),o;if(t.operand.stringKey!==void 0)o=`${s}_${t.operand.stringKey}`;else if(i&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)o=`${s}_${t.operand.index.name}`;else if(i&&t.operand.index?.type==="ArithVariable"&&t.operand.index.hasDollarPrefix){let c=await Se(e,t.operand.index.name);o=`${s}_${c}`}else if(t.operand.index){let c=await J(e,t.operand.index,n);o=`${s}_${c}`}else return r;let a=Number.parseInt(e.state.env.get(o)||"0",10)||0,l=t.operator==="++"?a+1:a-1;return e.state.env.set(o,String(l)),t.prefix?l:a}if(t.operand.type==="ArithConcat"){let s="";for(let i of t.operand.parts)s+=await Mr(e,i,n);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,o=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(o)),t.prefix?o:i}}if(t.operand.type==="ArithDynamicElement"){let s="";if(t.operand.nameExpr.type==="ArithConcat")for(let i of t.operand.nameExpr.parts)s+=await Mr(e,i,n);else t.operand.nameExpr.type==="ArithVariable"&&(s=t.operand.nameExpr.hasDollarPrefix?await Se(e,t.operand.nameExpr.name):t.operand.nameExpr.name);if(s&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)){let i=await J(e,t.operand.subscript,n),o=`${s}_${i}`,a=Number.parseInt(e.state.env.get(o)||"0",10)||0,l=t.operator==="++"?a+1:a-1;return e.state.env.set(o,String(l)),t.prefix?l:a}}return r}return nb(r,t.operator)}case"ArithTernary":return await J(e,t.condition,n)?await J(e,t.consequent,n):await J(e,t.alternate,n);case"ArithAssignment":{let r=t.variable,s=r;if(t.stringKey!==void 0)s=`${r}_${t.stringKey}`;else if(t.subscript){let l=e.state.associativeArrays?.has(r);if(l&&t.subscript.type==="ArithVariable"&&!t.subscript.hasDollarPrefix)s=`${r}_${t.subscript.name}`;else if(l&&t.subscript.type==="ArithVariable"&&t.subscript.hasDollarPrefix){let c=await Se(e,t.subscript.name);s=`${r}_${c||"\\"}`}else if(l){let c=await J(e,t.subscript,n);s=`${r}_${c}`}else{let c=await J(e,t.subscript,n);if(c<0){let u=ae(e,r);u.length>0&&(c=Math.max(...u.map(([h])=>typeof h=="number"?h:0))+1+c)}s=`${r}_${c}`}}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,o=await J(e,t.value,n),a=t6(i,o,t.operator);return e.state.env.set(s,String(a)),a}case"ArithGroup":return await J(e,t.expression,n);case"ArithConcat":{let r="";for(let s of t.parts)r+=await Mr(e,s,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await rc(e,r):Number.parseInt(r,10)||0}case"ArithDynamicAssignment":{let r="";if(t.target.type==="ArithConcat")for(let l of t.target.parts)r+=await Mr(e,l,n);else t.target.type==="ArithVariable"&&(r=t.target.hasDollarPrefix?await Se(e,t.target.name):t.target.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=r;if(t.subscript){let l=await J(e,t.subscript,n);s=`${r}_${l}`}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,o=await J(e,t.value,n),a=t6(i,o,t.operator);return e.state.env.set(s,String(a)),a}case"ArithDynamicElement":{let r="";if(t.nameExpr.type==="ArithConcat")for(let a of t.nameExpr.parts)r+=await Mr(e,a,n);else t.nameExpr.type==="ArithVariable"&&(r=t.nameExpr.hasDollarPrefix?await Se(e,t.nameExpr.name):t.nameExpr.name);if(!r||!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r))return 0;let s=await J(e,t.subscript,n),i=`${r}_${s}`,o=e.state.env.get(i);return o!==void 0?sb(o):0}default:return 0}}async function Mr(e,t,n=!1){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await J(e,t,n));case"ArithVariable":return t.hasDollarPrefix?await Se(e,t.name):t.name;case"ArithSpecialVar":return await Se(e,t.name);case"ArithBracedExpansion":return await Xi(e,t.content);case"ArithCommandSubst":return e.execFn?(await e.execFn(t.command)).stdout.trim():"0";case"ArithConcat":{let r="";for(let s of t.parts)r+=await Mr(e,s,n);return r}default:return String(await J(e,t,n))}}var Et=I(()=>{"use strict";pt();Qe();xe();At()});var ll=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(nu(),tu))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(su(),ru))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(pu(),hu))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(yu(),gu))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(bu(),wu))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(Su(),Au))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Nu(),Cu))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(vu(),ku))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Ou(),Iu))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>($u(),Ru))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Pu(),Tu))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(_u(),Lu))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(Fu(),Mu))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(Wu(),Uu))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(ju(),zu))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(Vu(),Gu))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(Qu(),Zu))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(Yu(),Xu))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(js(),zs))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(js(),zs))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(js(),zs))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(zf(),Hf))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(e1(),Jf))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(T1(),$1))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(H1(),B1))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(j1(),z1))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(V1(),G1))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(Z1(),q1))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(X1(),K1))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(eh(),J1))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(nh(),th))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(ih(),sh))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(lh(),ah))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(fh(),uh))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(mh(),dh))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(bh(),wh))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Ah(),Eh))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Nh(),Ch))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(vh(),kh))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Oh(),Ih))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(Fh(),Mh))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(Wh(),Uh))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(Hh(),Bh))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(Gh(),jh))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(Zh(),qh))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Ea(),xa))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Ea(),xa))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Sa(),Aa))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Sa(),Aa))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(Xh(),Kh))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(Jh(),Yh))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Na(),Ca))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Na(),Ca))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(tp(),ep))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(va(),ka))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(va(),ka))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Op(),Ip))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Tp(),$p))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Lp(),Dp))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(Mp(),_p))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(Up(),Fp))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(Bp(),Wp))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(zp(),Hp))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(Gp(),jp))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(qp(),Vp))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(Kp(),Qp))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(Yp(),Xp))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(ed(),Jp))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(Gd(),jd))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(qd(),Vd))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(Qd(),Zd))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(Xd(),Kd))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(Jd(),Yd))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(t0(),e0))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(r0(),n0))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(i0(),s0))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Oi(),Ii))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Oi(),Ii))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Oi(),Ii))).zcatCommand}],k5=[],E0=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(b0(),w0))).curlCommand}],x0=new Map;function cl(e){return{name:e.name,async execute(t,n){let r=x0.get(e.name);return r||(r=await e.load(),x0.set(e.name,r)),r.execute(t,n)}}}function v5(){return ll.map(e=>e.name)}function I5(){return E0.map(e=>e.name)}function A0(e){return(e?ll.filter(n=>e.includes(n.name)):ll).map(cl)}function S0(){return E0.map(cl)}function C0(){return k5.map(cl)}function N0(e){return"load"in e&&typeof e.load=="function"}function O5(e,t){return{name:e,execute:t}}function k0(e){let t=null;return{name:e.name,async execute(n,r){return t||(t=await e.load()),t.execute(n,r)}}}var R5=new TextEncoder,$5=new TextDecoder;function ul(e,t){if(e instanceof Uint8Array)return e;if(t==="base64")return Uint8Array.from(atob(e),n=>n.charCodeAt(0));if(t==="hex"){let n=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)n[r/2]=parseInt(e.slice(r,r+2),16);return n}return t==="binary"||t==="latin1"?Uint8Array.from(e,n=>n.charCodeAt(0)):R5.encode(e)}function v0(e,t){return t==="base64"?btoa(String.fromCharCode(...e)):t==="hex"?Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join(""):t==="binary"||t==="latin1"?String.fromCharCode(...e):$5.decode(e)}function Ri(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var $i=new TextEncoder;function T5(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function at(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var Xn=class{data=new Map;constructor(t){if(this.data.set("/",{type:"directory",mode:493,mtime:new Date}),t)for(let[n,r]of Object.entries(t))T5(r)?this.writeFileSync(n,r.content,void 0,{mode:r.mode,mtime:r.mtime}):this.writeFileSync(n,r)}normalizePath(t){if(!t||t==="/")return"/";let n=t.endsWith("/")&&t!=="/"?t.slice(0,-1):t;n.startsWith("/")||(n=`/${n}`);let r=n.split("/").filter(i=>i&&i!=="."),s=[];for(let i of r)i===".."?s.pop():s.push(i);return`/${s.join("/")}`||"/"}dirname(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.lastIndexOf("/");return r===0?"/":n.slice(0,r)}ensureParentDirs(t){let n=this.dirname(t);n!=="/"&&(this.data.has(n)||(this.ensureParentDirs(n),this.data.set(n,{type:"directory",mode:493,mtime:new Date})))}writeFileSync(t,n,r,s){at(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let o=Ri(r),a=ul(n,o);this.data.set(i,{type:"file",content:a,mode:s?.mode??420,mtime:s?.mtime??new Date})}async readFile(t,n){let r=await this.readFileBuffer(t),s=Ri(n);return v0(r,s)}async readFileBuffer(t){at(t,"open");let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, open '${t}'`);if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${t}'`);return r.content instanceof Uint8Array?r.content:$i.encode(r.content)}async writeFile(t,n,r){this.writeFileSync(t,n,r)}async appendFile(t,n,r){at(t,"append");let s=this.normalizePath(t),i=this.data.get(s);if(i&&i.type==="directory")throw new Error(`EISDIR: illegal operation on a directory, write '${t}'`);let o=Ri(r),a=ul(n,o);if(i?.type==="file"){let l=i.content instanceof Uint8Array?i.content:$i.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(t,n,r)}async exists(t){if(t.includes("\0"))return!1;try{let n=this.resolvePathWithSymlinks(t);return this.data.has(n)}catch{return!1}}async stat(t){at(t,"stat");let n=this.resolvePathWithSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, stat '${t}'`);let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=$i.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}async lstat(t){at(t,"lstat");let n=this.resolveIntermediateSymlinks(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, lstat '${t}'`);if(r.type==="symlink")return{isFile:!1,isDirectory:!1,isSymbolicLink:!0,mode:r.mode,size:r.target.length,mtime:r.mtime||new Date};let s=0;return r.type==="file"&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=$i.encode(r.content).length),{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:s,mtime:r.mtime||new Date}}resolveSymlink(t,n){if(n.startsWith("/"))return this.normalizePath(n);let r=this.dirname(t);return this.normalizePath(r==="/"?`/${n}`:`${r}/${n}`)}resolveIntermediateSymlinks(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.slice(1).split("/");if(r.length<=1)return n;let s="",i=new Set;for(let o=0;o<r.length-1;o++){let a=r[o];s=`${s}/${a}`;let l=this.data.get(s),c=0,u=40;for(;l&&l.type==="symlink"&&c<u;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`);i.add(s),s=this.resolveSymlink(s,l.target),l=this.data.get(s),c++}if(c>=u)throw new Error(`ELOOP: too many levels of symbolic links, lstat '${t}'`)}return`${s}/${r[r.length-1]}`}resolvePathWithSymlinks(t){let n=this.normalizePath(t);if(n==="/")return"/";let r=n.slice(1).split("/"),s="",i=new Set;for(let o of r){s=`${s}/${o}`;let a=this.data.get(s),l=0,c=40;for(;a&&a.type==="symlink"&&l<c;){if(i.has(s))throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`);i.add(s),s=this.resolveSymlink(s,a.target),a=this.data.get(s),l++}if(l>=c)throw new Error(`ELOOP: too many levels of symbolic links, open '${t}'`)}return s}async mkdir(t,n){this.mkdirSync(t,n)}mkdirSync(t,n){at(t,"mkdir");let r=this.normalizePath(t);if(this.data.has(r)){if(this.data.get(r)?.type==="file")throw new Error(`EEXIST: file already exists, mkdir '${t}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${t}'`);return}let s=this.dirname(r);if(s!=="/"&&!this.data.has(s))if(n?.recursive)this.mkdirSync(s,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${t}'`);this.data.set(r,{type:"directory",mode:493,mtime:new Date})}async readdir(t){return(await this.readdirWithFileTypes(t)).map(r=>r.name)}async readdirWithFileTypes(t){at(t,"scandir");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);let s=new Set;for(;r&&r.type==="symlink";){if(s.has(n))throw new Error(`ELOOP: too many levels of symbolic links, scandir '${t}'`);s.add(n),n=this.resolveSymlink(n,r.target),r=this.data.get(n)}if(!r)throw new Error(`ENOENT: no such file or directory, scandir '${t}'`);if(r.type!=="directory")throw new Error(`ENOTDIR: not a directory, scandir '${t}'`);let i=n==="/"?"/":`${n}/`,o=new Map;for(let[a,l]of this.data.entries())if(a!==n&&a.startsWith(i)){let c=a.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!o.has(u)&&o.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(o.values()).sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0)}async rm(t,n){at(t,"rm");let r=this.normalizePath(t),s=this.data.get(r);if(!s){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${t}'`)}if(s.type==="directory"){let i=await this.readdir(r);if(i.length>0){if(!n?.recursive)throw new Error(`ENOTEMPTY: directory not empty, rm '${t}'`);for(let o of i){let a=r==="/"?`/${o}`:`${r}/${o}`;await this.rm(a,n)}}}this.data.delete(r)}async cp(t,n,r){at(t,"cp"),at(n,"cp");let s=this.normalizePath(t),i=this.normalizePath(n),o=this.data.get(s);if(!o)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(o.type==="file")this.ensureParentDirs(i),this.data.set(i,{...o});else if(o.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);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,r)}}}async mv(t,n){await this.cp(t,n,{recursive:!0}),await this.rm(t,{recursive:!0})}getAllPaths(){return Array.from(this.data.keys())}resolvePath(t,n){if(n.startsWith("/"))return this.normalizePath(n);let r=t==="/"?`/${n}`:`${t}/${n}`;return this.normalizePath(r)}async chmod(t,n){at(t,"chmod");let r=this.normalizePath(t),s=this.data.get(r);if(!s)throw new Error(`ENOENT: no such file or directory, chmod '${t}'`);s.mode=n}async symlink(t,n){at(n,"symlink");let r=this.normalizePath(n);if(this.data.has(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureParentDirs(r),this.data.set(r,{type:"symlink",target:t,mode:511,mtime:new Date})}async link(t,n){at(t,"link"),at(n,"link");let r=this.normalizePath(t),s=this.normalizePath(n),i=this.data.get(r);if(!i)throw new Error(`ENOENT: no such file or directory, link '${t}'`);if(i.type!=="file")throw new Error(`EPERM: operation not permitted, link '${t}'`);if(this.data.has(s))throw new Error(`EEXIST: file already exists, link '${n}'`);this.ensureParentDirs(s),this.data.set(s,{type:"file",content:i.content,mode:i.mode,mtime:i.mtime})}async readlink(t){at(t,"readlink");let n=this.normalizePath(t),r=this.data.get(n);if(!r)throw new Error(`ENOENT: no such file or directory, readlink '${t}'`);if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${t}'`);return r.target}async realpath(t){at(t,"realpath");let n=this.resolvePathWithSymlinks(t);if(!this.data.has(n))throw new Error(`ENOENT: no such file or directory, realpath '${t}'`);return n}async utimes(t,n,r){at(t,"utimes");let s=this.normalizePath(t),i=this.resolvePathWithSymlinks(s),o=this.data.get(i);if(!o)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);o.mtime=r}};fl();function P5(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function D5(e,t){e.mkdirSync("/bin",{recursive:!0}),e.mkdirSync("/usr/bin",{recursive:!0}),t&&(e.mkdirSync("/home/user",{recursive:!0}),e.mkdirSync("/tmp",{recursive:!0}))}function L5(e){e.mkdirSync("/dev",{recursive:!0}),e.writeFileSync("/dev/null",""),e.writeFileSync("/dev/zero",new Uint8Array(0)),e.writeFileSync("/dev/stdin",""),e.writeFileSync("/dev/stdout",""),e.writeFileSync("/dev/stderr","")}function _5(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${O0}
787
787
  `),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
788
- `),e.writeFileSync("/proc/self/status",O0()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function $0(e,t){P5(e)&&(D5(e,t),L5(e),_5(e))}vn();xe();var M5=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],F5=["braceexpand","hashall","interactive-comments"];function hl(e){let t=[],n=[...F5.map(r=>({name:r,enabled:!0})),...M5.map(r=>({name:r,enabled:e[r]}))].sort((r,s)=>r.name.localeCompare(s.name));for(let r of n)r.enabled&&t.push(r.name);return t.join(":")}function Or(e){e.state.env.set("SHELLOPTS",hl(e.state.options))}var U5=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function pl(e){let t=[];for(let n of U5)e[n]&&t.push(n);return t.join(":")}function dl(e){e.state.env.set("BASHOPTS",pl(e.state.shoptOptions))}vn();Yn();Qe();Yn();var mw="BASH_ALIAS_";function Em(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Am(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Sm(e,t){return e.env.get(`${mw}${t}`)}function Ll(e,t,n){if(!t.name||!Em(t.name))return t;let r=Am(t.name);if(!r)return t;let s=Sm(e,r);if(!s||n.has(r))return t;try{n.add(r);let i=new ce,o=s,a=s.endsWith(" ");if(!a)for(let f of t.args){let h=Nm(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof lt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Cm(t,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Cm(t,s);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(Em(f)){let h=Am(f);if(h&&Sm(e,h)){let p={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Ll(e,p,n);m!==p&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw n.delete(r),i}}function Cm(e,t){let n=t;for(let o of e.args){let a=Nm(o);n+=` ${a}`}let r=new ce,s=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${n.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Nm(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${n.value}'`;break;case"DoubleQuoted":t+=`"${n.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${n.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${n.expression}))`;break;case"Glob":t+=n.pattern;break;default:break}return t}Et();At();Zt();async function n6(e,t){let n=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!n.endsWith(")"))return null;let s=r[1],i=[],o=!1,a="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let p of h)/^\s+$/.test(p)?(a||l)&&(i.push(a),a="",l=!1):p&&(a+=p)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=$r({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await rn(e,{type:"Word",parts:[u]});i.push(...h.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await se(e,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function r6(e,t){let n=-1,r=-1,s=!1;for(let d=0;d<t.parts.length;d++){let g=t.parts[d];if(g.type==="Literal"){let y=g.value.indexOf("+=");if(y!==-1){let b=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){n=d,r=y,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=d,r=y,s=!0;break}}let w=g.value.indexOf("=");if(w!==-1&&(w===0||g.value[w-1]!=="+")){let b=g.value.slice(0,w);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=d,r=w;break}}}}if(n===-1)return null;let i=t.parts.slice(0,n),o=t.parts[n];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(n+1),f="";for(let d of i)f+=await se(e,{type:"Word",parts:[d]});f+=l;let h={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},p=h.parts.length>0?await se(e,h):"";return`${f}${s?"+=":"="}${p}`}var ib=["tar","yq","xan","sqlite3","python3","python"];function s6(e){return ib.includes(e)}xe();xe();var de=Object.freeze({stdout:"",stderr:"",exitCode:0});function ge(e=""){return{stdout:e,stderr:"",exitCode:0}}function W(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function H(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function Xe(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Cn(e,t,n="",r=""){throw new re(e,t,n,r)}function sc(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new ln;return de}if(t.length>1)throw new pe(1,"",`bash: break: too many arguments
788
+ `),e.writeFileSync("/proc/self/status",R0()),e.writeFileSync("/proc/self/fd/0","/dev/stdin"),e.writeFileSync("/proc/self/fd/1","/dev/stdout"),e.writeFileSync("/proc/self/fd/2","/dev/stderr")}function $0(e,t){P5(e)&&(D5(e,t),L5(e),_5(e))}vn();xe();var M5=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],F5=["braceexpand","hashall","interactive-comments"];function hl(e){let t=[],n=[...F5.map(r=>({name:r,enabled:!0})),...M5.map(r=>({name:r,enabled:e[r]}))].sort((r,s)=>r.name.localeCompare(s.name));for(let r of n)r.enabled&&t.push(r.name);return t.join(":")}function Rr(e){e.state.env.set("SHELLOPTS",hl(e.state.options))}var U5=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function pl(e){let t=[];for(let n of U5)e[n]&&t.push(n);return t.join(":")}function dl(e){e.state.env.set("BASHOPTS",pl(e.state.shoptOptions))}vn();Yn();Qe();Yn();var mw="BASH_ALIAS_";function Em(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Am(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Sm(e,t){return e.env.get(`${mw}${t}`)}function Ll(e,t,n){if(!t.name||!Em(t.name))return t;let r=Am(t.name);if(!r)return t;let s=Sm(e,r);if(!s||n.has(r))return t;try{n.add(r);let i=new ce,o=s,a=s.endsWith(" ");if(!a)for(let f of t.args){let h=Nm(f);o+=` ${h}`}let l;try{l=i.parse(o)}catch(f){if(f instanceof lt)throw f;return t}if(l.statements.length!==1||l.statements[0].pipelines.length!==1||l.statements[0].pipelines[0].commands.length!==1)return Cm(t,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Cm(t,s);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(a&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(Em(f)){let h=Am(f);if(h&&Sm(e,h)){let p={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Ll(e,p,n);m!==p&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw n.delete(r),i}}function Cm(e,t){let n=t;for(let o of e.args){let a=Nm(o);n+=` ${a}`}let r=new ce,s=r.parseWordFromString("eval",!1,!1),i=r.parseWordFromString(`'${n.replace(/'/g,"'\\''")}'`,!1,!1);return{type:"SimpleCommand",name:s,args:[i],assignments:e.assignments,redirections:e.redirections,line:e.line}}function Nm(e){let t="";for(let n of e.parts)switch(n.type){case"Literal":t+=n.value.replace(/([\s"'$`\\*?[\]{}()<>|&;#!])/g,"\\$1");break;case"SingleQuoted":t+=`'${n.value}'`;break;case"DoubleQuoted":t+=`"${n.parts.map(r=>r.type==="Literal"?r.value:`$${r.type}`).join("")}"`;break;case"ParameterExpansion":t+=`\${${n.parameter}}`;break;case"CommandSubstitution":t+="$(...)";break;case"ArithmeticExpansion":t+=`$((${n.expression}))`;break;case"Glob":t+=n.pattern;break;default:break}return t}Et();At();Zt();async function n6(e,t){let n=t.parts.map(u=>u.type==="Literal"?u.value:"\0").join(""),r=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);if(!r||!n.endsWith(")"))return null;let s=r[1],i=[],o=!1,a="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!o){let h=f.indexOf("=(");h!==-1&&(o=!0,f=f.slice(h+2))}if(o){f.endsWith(")")&&(f=f.slice(0,-1));let h=f.split(/(\s+)/);for(let p of h)/^\s+$/.test(p)?(a||l)&&(i.push(a),a="",l=!1):p&&(a+=p)}}else if(o)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(a))a+=$r({type:"Word",parts:[u]});else{(a||l)&&(i.push(a),a="",l=!1);let h=await rn(e,{type:"Word",parts:[u]});i.push(...h.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await se(e,{type:"Word",parts:[u]});a+=f}(a||l)&&i.push(a);let c=i.map(u=>/^\[.+\]=/.test(u)?u:u===""?"''":/[\s"'\\$`!*?[\]{}|&;<>()]/.test(u)&&!u.startsWith("'")&&!u.startsWith('"')?`'${u.replace(/'/g,"'\\''")}'`:u);return`${s}=(${c.join(" ")})`}async function r6(e,t){let n=-1,r=-1,s=!1;for(let d=0;d<t.parts.length;d++){let g=t.parts[d];if(g.type==="Literal"){let y=g.value.indexOf("+=");if(y!==-1){let b=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){n=d,r=y,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=d,r=y,s=!0;break}}let w=g.value.indexOf("=");if(w!==-1&&(w===0||g.value[w-1]!=="+")){let b=g.value.slice(0,w);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=d,r=w;break}}}}if(n===-1)return null;let i=t.parts.slice(0,n),o=t.parts[n];if(o.type!=="Literal")return null;let a=s?2:1,l=o.value.slice(0,r),c=o.value.slice(r+a),u=t.parts.slice(n+1),f="";for(let d of i)f+=await se(e,{type:"Word",parts:[d]});f+=l;let h={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},p=h.parts.length>0?await se(e,h):"";return`${f}${s?"+=":"="}${p}`}var ib=["tar","yq","xan","sqlite3","python3","python"];function s6(e){return ib.includes(e)}xe();xe();var de=Object.freeze({stdout:"",stderr:"",exitCode:0});function ge(e=""){return{stdout:e,stderr:"",exitCode:0}}function W(e,t=1){return{stdout:"",stderr:e,exitCode:t}}function H(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function Xe(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function Cn(e,t,n="",r=""){throw new re(e,t,n,r)}function sc(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new ln;return de}if(t.length>1)throw new pe(1,"",`bash: break: too many arguments
789
789
  `);let n=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new pe(128,"",`bash: break: ${t[0]}: numeric argument required
790
790
  `);n=r}throw new ut(n)}async function ic(e,t){let n,r=!1,s=!1,i=0;for(;i<t.length;)if(t[i]==="--"){i++;break}else if(t[i]==="-L")s=!1,i++;else if(t[i]==="-P")s=!0,i++;else if(t[i].startsWith("-")&&t[i]!=="-")i++;else break;let o=t.slice(i);if(o.length===0||o[0]==="~"?n=e.state.env.get("HOME")||"/":o[0]==="-"?(n=e.state.previousDir,r=!0):n=o[0],!n.startsWith("/")&&!n.startsWith("./")&&!n.startsWith("../")&&n!=="."&&n!==".."){let f=e.state.env.get("CDPATH");if(f){let h=f.split(":").filter(p=>p);for(let p of h){let m=p.startsWith("/")?`${p}/${n}`:`${e.state.cwd}/${p}/${n}`;try{if((await e.fs.stat(m)).isDirectory){n=m,r=!0;break}}catch{}}}}let l=(n.startsWith("/")?n:`${e.state.cwd}/${n}`).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 e.fs.stat(c)).isDirectory)return W(`bash: cd: ${n}: Not a directory
791
791
  `)}catch{return W(`bash: cd: ${n}: No such file or directory
@@ -829,11 +829,11 @@ Gid: ${r} ${r} ${r} ${r}
829
829
  `,2);f=t[x]}else if(S==="-C"){if(x++,x>=t.length)return W(`compgen: -C: option requires an argument
830
830
  `,2);h=t[x]}else if(S==="-X"){if(x++,x>=t.length)return W(`compgen: -X: option requires an argument
831
831
  `,2);u=t[x]}else if(S==="-G"){if(x++,x>=t.length)return W(`compgen: -G: option requires an argument
832
- `,2)}else if(S==="--"){p.push(...t.slice(x+1));break}else S.startsWith("-")||p.push(S)}o=p[0]??null;let d=[];if(l){let x=await fc(e,o);d.push(...x)}if(c){let x=await x6(e,o);d.push(...x)}for(let x of n)if(x==="variable"){let S=Ab(e,o);d.push(...S)}else if(x==="export"){let S=Sb(e,o);d.push(...S)}else if(x==="function"){let S=Cb(e,o);d.push(...S)}else if(x==="builtin"){let S=Nb(o);d.push(...S)}else if(x==="keyword"){let S=kb(o);d.push(...S)}else if(x==="alias"){let S=vb(e,o);d.push(...S)}else if(x==="shopt"){let S=Ib(o);d.push(...S)}else if(x==="helptopic"){let S=Rb(o);d.push(...S)}else if(x==="directory"){let S=await fc(e,o);d.push(...S)}else if(x==="file"){let S=await x6(e,o);d.push(...S)}else if(x==="user"){let S=Ob(o);d.push(...S)}else if(x==="command"){let S=await $b(e,o);d.push(...S)}if(r!==null)try{let x=await Tb(e,r),S=Pb(e,x);for(let C of S)(o===null||C.startsWith(o))&&d.push(C)}catch{return H("","",1)}if(a){let x=await fc(e,o);for(let S of x)d.includes(S)||d.push(S)}let g="";if(f!==null){let x=e.state.functions.get(f);if(x){let S=new Map;S.set("COMP_WORDS__length",e.state.env.get("COMP_WORDS__length")),e.state.env.set("COMP_WORDS__length","0"),S.set("COMP_CWORD",e.state.env.get("COMP_CWORD")),e.state.env.set("COMP_CWORD","-1"),S.set("COMP_LINE",e.state.env.get("COMP_LINE")),e.state.env.set("COMP_LINE",""),S.set("COMP_POINT",e.state.env.get("COMP_POINT")),e.state.env.set("COMP_POINT","0");let C=new Map;for(let M of e.state.env.keys())(M==="COMPREPLY"||M.startsWith("COMPREPLY_")||M==="COMPREPLY__length")&&(C.set(M,e.state.env.get(M)),e.state.env.delete(M));let $=["compgen",p[0]??"",""];try{let M=await po(e,x,$,"");if(M.exitCode!==0)return Wr(e,S),Wr(e,C),H("",M.stderr,1);g=M.stdout;let _=Db(e);d.push(..._)}catch{return Wr(e,S),Wr(e,C),H("","",1)}Wr(e,S),Wr(e,C)}}if(h!==null)try{let x=hn(h),S=await e.executeScript(x);if(S.exitCode!==0)return H("",S.stderr,S.exitCode);if(S.stdout){let C=S.stdout.split(`
833
- `);for(let $ of C)$.length>0&&d.push($)}}catch(x){if(x.name==="ParseException")return W(`compgen: -C: ${x.message}
834
- `,2);throw x}let y=d;if(u!==null){let x=u.startsWith("!"),S=x?u.slice(1):u;y=d.filter(C=>{let $=Fr(C,S,!1,!0);return x?$:!$})}if(y.length===0&&o!==null)return H(g,"",1);let w=y.map(x=>`${s}${x}${i}`).join(`
832
+ `,2)}else if(S==="--"){p.push(...t.slice(x+1));break}else S.startsWith("-")||p.push(S)}o=p[0]??null;let d=[];if(l){let x=await fc(e,o);d.push(...x)}if(c){let x=await x6(e,o);d.push(...x)}for(let x of n)if(x==="variable"){let S=Ab(e,o);d.push(...S)}else if(x==="export"){let S=Sb(e,o);d.push(...S)}else if(x==="function"){let S=Cb(e,o);d.push(...S)}else if(x==="builtin"){let S=Nb(o);d.push(...S)}else if(x==="keyword"){let S=kb(o);d.push(...S)}else if(x==="alias"){let S=vb(e,o);d.push(...S)}else if(x==="shopt"){let S=Ib(o);d.push(...S)}else if(x==="helptopic"){let S=Ob(o);d.push(...S)}else if(x==="directory"){let S=await fc(e,o);d.push(...S)}else if(x==="file"){let S=await x6(e,o);d.push(...S)}else if(x==="user"){let S=Rb(o);d.push(...S)}else if(x==="command"){let S=await $b(e,o);d.push(...S)}if(r!==null)try{let x=await Tb(e,r),S=Pb(e,x);for(let C of S)(o===null||C.startsWith(o))&&d.push(C)}catch{return H("","",1)}if(a){let x=await fc(e,o);for(let S of x)d.includes(S)||d.push(S)}let g="";if(f!==null){let x=e.state.functions.get(f);if(x){let S=new Map;S.set("COMP_WORDS__length",e.state.env.get("COMP_WORDS__length")),e.state.env.set("COMP_WORDS__length","0"),S.set("COMP_CWORD",e.state.env.get("COMP_CWORD")),e.state.env.set("COMP_CWORD","-1"),S.set("COMP_LINE",e.state.env.get("COMP_LINE")),e.state.env.set("COMP_LINE",""),S.set("COMP_POINT",e.state.env.get("COMP_POINT")),e.state.env.set("COMP_POINT","0");let C=new Map;for(let U of e.state.env.keys())(U==="COMPREPLY"||U.startsWith("COMPREPLY_")||U==="COMPREPLY__length")&&(C.set(U,e.state.env.get(U)),e.state.env.delete(U));let R=["compgen",p[0]??"",""];try{let U=await po(e,x,R,"");if(U.exitCode!==0)return Wr(e,S),Wr(e,C),H("",U.stderr,1);g=U.stdout;let L=Db(e);d.push(...L)}catch{return Wr(e,S),Wr(e,C),H("","",1)}Wr(e,S),Wr(e,C)}}if(h!==null)try{let x=hn(h),S=await e.executeScript(x);if(S.exitCode!==0)return H("",S.stderr,S.exitCode);if(S.stdout){let C=S.stdout.split(`
833
+ `);for(let R of C)R.length>0&&d.push(R)}}catch(x){if(x.name==="ParseException")return W(`compgen: -C: ${x.message}
834
+ `,2);throw x}let y=d;if(u!==null){let x=u.startsWith("!"),S=x?u.slice(1):u;y=d.filter(C=>{let R=Fr(C,S,!1,!0);return x?R:!R})}if(y.length===0&&o!==null)return H(g,"",1);let w=y.map(x=>`${s}${x}${i}`).join(`
835
835
  `),b=g+(w?`${w}
836
- `:"");return ge(b)}function Ab(e,t){let n=new Set;for(let s of e.state.env.keys()){if(s.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(s)||s.endsWith("__length"))continue;let i=s.split("_")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?n.add(s):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&n.add(i)}let r=Array.from(n);return t!==null&&(r=r.filter(s=>s.startsWith(t))),r.sort()}function Sb(e,t){let n=e.state.exportedVars??new Set,r=Array.from(n);return t!==null&&(r=r.filter(s=>s.startsWith(t))),r=r.filter(s=>s.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(s)||s.endsWith("__length")?!1:e.state.env.has(s)),r.sort()}function Cb(e,t){let n=Array.from(e.state.functions.keys());return t!==null&&(n=n.filter(r=>r.startsWith(t))),n.sort()}function Nb(e){let t=[...hc];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function kb(e){let t=[...E6];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function vb(e,t){let n=[];for(let s of e.state.env.keys())if(s.startsWith("BASH_ALIAS_")){let i=s.slice(11);n.push(i)}let r=n;return t!==null&&(r=r.filter(s=>s.startsWith(t))),r.sort()}function Ib(e){let t=[...xb];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function Rb(e){let t=[...Eb];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}async function fc(e,t){let n=[];try{let r=e.state.cwd,s=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";s=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i){let a=`${r}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!s||o.startsWith(s)))if(t?.includes("/")){let c=t.lastIndexOf("/"),u=t.slice(0,c+1);n.push(u+o)}else n.push(o)}catch{}}}catch{}return n.sort()}async function x6(e,t){let n=[];try{let r=e.state.cwd,s=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";s=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i)if(!s||o.startsWith(s))if(t?.includes("/")){let a=t.lastIndexOf("/"),l=t.slice(0,a+1);n.push(l+o)}else n.push(o)}catch{}return n.sort()}function Ob(e){return["root","nobody"]}async function $b(e,t){let n=new Set;for(let i of hc)n.add(i);for(let i of e.state.functions.keys())n.add(i);for(let i of e.state.env.keys())i.startsWith("BASH_ALIAS_")&&n.add(i.slice(11));for(let i of E6)n.add(i);let r=e.state.env.get("PATH")??"/usr/bin:/bin";for(let i of r.split(":"))if(i)try{let o=await e.fs.readdir(i);for(let a of o)n.add(a)}catch{}let s=Array.from(n);return t!==null&&(s=s.filter(i=>i.startsWith(t))),s.sort()}async function Tb(e,t){let r=new ce().parseWordFromString(t,!1,!1);return await se(e,r)}function Pb(e,t){let n=e.state.env.get("IFS")??`
836
+ `:"");return ge(b)}function Ab(e,t){let n=new Set;for(let s of e.state.env.keys()){if(s.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(s)||s.endsWith("__length"))continue;let i=s.split("_")[0];/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)?n.add(s):i&&/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(i)&&e.state.env.has(`${i}__length`)&&n.add(i)}let r=Array.from(n);return t!==null&&(r=r.filter(s=>s.startsWith(t))),r.sort()}function Sb(e,t){let n=e.state.exportedVars??new Set,r=Array.from(n);return t!==null&&(r=r.filter(s=>s.startsWith(t))),r=r.filter(s=>s.includes("_")&&/^[a-zA-Z_][a-zA-Z0-9_]*_\d+$/.test(s)||s.endsWith("__length")?!1:e.state.env.has(s)),r.sort()}function Cb(e,t){let n=Array.from(e.state.functions.keys());return t!==null&&(n=n.filter(r=>r.startsWith(t))),n.sort()}function Nb(e){let t=[...hc];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function kb(e){let t=[...E6];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function vb(e,t){let n=[];for(let s of e.state.env.keys())if(s.startsWith("BASH_ALIAS_")){let i=s.slice(11);n.push(i)}let r=n;return t!==null&&(r=r.filter(s=>s.startsWith(t))),r.sort()}function Ib(e){let t=[...xb];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function Ob(e){let t=[...Eb];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}async function fc(e,t){let n=[];try{let r=e.state.cwd,s=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";s=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i){let a=`${r}/${o}`;try{if((await e.fs.stat(a)).isDirectory&&(!s||o.startsWith(s)))if(t?.includes("/")){let c=t.lastIndexOf("/"),u=t.slice(0,c+1);n.push(u+o)}else n.push(o)}catch{}}}catch{}return n.sort()}async function x6(e,t){let n=[];try{let r=e.state.cwd,s=t??"";if(t){let o=t.lastIndexOf("/");if(o!==-1){let a=t.slice(0,o)||"/";s=t.slice(o+1),a.startsWith("/")?r=a:r=`${e.state.cwd}/${a}`}}let i=await e.fs.readdir(r);for(let o of i)if(!s||o.startsWith(s))if(t?.includes("/")){let a=t.lastIndexOf("/"),l=t.slice(0,a+1);n.push(l+o)}else n.push(o)}catch{}return n.sort()}function Rb(e){return["root","nobody"]}async function $b(e,t){let n=new Set;for(let i of hc)n.add(i);for(let i of e.state.functions.keys())n.add(i);for(let i of e.state.env.keys())i.startsWith("BASH_ALIAS_")&&n.add(i.slice(11));for(let i of E6)n.add(i);let r=e.state.env.get("PATH")??"/usr/bin:/bin";for(let i of r.split(":"))if(i)try{let o=await e.fs.readdir(i);for(let a of o)n.add(a)}catch{}let s=Array.from(n);return t!==null&&(s=s.filter(i=>i.startsWith(t))),s.sort()}async function Tb(e,t){let r=new ce().parseWordFromString(t,!1,!1);return await se(e,r)}function Pb(e,t){let n=e.state.env.get("IFS")??`
837
837
  `;if(n.length===0)return[t];let r=new Set(n.split("")),s=[],i="",o=0;for(;o<t.length;){let a=t[o];if(a==="\\"&&o+1<t.length){let l=t[o+1];i+=l,o+=2}else r.has(a)?(i.length>0&&(s.push(i),i=""),o++):(i+=a,o++)}return i.length>0&&s.push(i),s}function Wr(e,t){for(let[n,r]of t)r===void 0?e.state.env.delete(n):e.state.env.set(n,r)}function Db(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let s=ae(e,"COMPREPLY");for(let[,i]of s)t.push(i)}else{let s=e.state.env.get("COMPREPLY");s!==void 0&&t.push(s)}return t}var Lb=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function mc(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let n=!1,r=!1,s=!1,i,o,a,l=[],c=[],u=[];for(let f=0;f<t.length;f++){let h=t[f];if(h==="-p")n=!0;else if(h==="-r")r=!0;else if(h==="-D")s=!0;else if(h==="-W"){if(f++,f>=t.length)return W(`complete: -W: option requires an argument
838
838
  `,2);i=t[f]}else if(h==="-F"){if(f++,f>=t.length)return W(`complete: -F: option requires an argument
839
839
  `,2);o=t[f]}else if(h==="-o"){if(f++,f>=t.length)return W(`complete: -o: option requires an argument
@@ -875,21 +875,21 @@ Gid: ${r} ${r} ${r} ${r}
875
875
  `}}return ge(t)}function v6(e){let t="",n=new Set;for(let s of e.state.env.keys()){if(s.startsWith("BASH_"))continue;if(s.endsWith("__length")){let o=s.slice(0,-8);e.state.associativeArrays?.has(o)||n.add(o);continue}let i=s.lastIndexOf("_");if(i>0){let o=s.slice(0,i),a=s.slice(i+1);/^\d+$/.test(a)&&(e.state.associativeArrays?.has(o)||n.add(o))}}let r=Array.from(n).sort();for(let s of r){let i=Ke(e,s);if(i.length===0)t+=`declare -a ${s}=()
876
876
  `;else{let o=i.map(a=>{let l=e.state.env.get(`${s}_${a}`)??"";return`[${a}]=${sr(l)}`});t+=`declare -a ${s}=(${o.join(" ")})
877
877
  `}}return ge(t)}function I6(e){let t="",n=new Set;for(let s of e.state.env.keys()){if(s.startsWith("BASH_"))continue;if(s.endsWith("__length")){let o=s.slice(0,-8);n.add(o);continue}let i=s.lastIndexOf("_");if(i>0){let o=s.slice(0,i),a=s.slice(i+1);if(/^\d+$/.test(a)||e.state.associativeArrays?.has(o)){n.add(o);continue}}n.add(s)}let r=Array.from(n).sort();for(let s of r){if(e.state.associativeArrays?.has(s)||Ke(e,s).length>0||e.state.env.has(`${s}__length`))continue;let a=e.state.env.get(s);a!==void 0&&(t+=`${s}=${mo(a)}
878
- `)}return ge(t)}function Ac(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function Ns(e,t){return e.state.integerVars?.has(t)??!1}function Sc(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function _b(e,t){return e.state.lowercaseVars?.has(t)??!1}function Cc(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function Mb(e,t){return e.state.uppercaseVars?.has(t)??!1}function Br(e,t,n){return _b(e,t)?n.toLowerCase():Mb(e,t)?n.toUpperCase():n}async function R6(e,t){try{let n=new ce,r=Ae(n,t),s=await J(e,r.expression);return String(s)}catch{return"0"}}function Fb(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let n=t[0],r=n.length;if(e[r]!=="[")return null;let s=0,i=r+1;for(;r<e.length;r++)if(e[r]==="[")s++;else if(e[r]==="]"&&(s--,s===0))break;if(s!==0)return null;let o=e.slice(i,r);if(r++,e[r]!=="=")return null;r++;let a=e.slice(r);return{name:n,indexExpr:o,value:a}}async function Nc(e,t){let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,h=!1,p=!1,m=!1,d=!1,g=!1,y=[];for(let _=0;_<t.length;_++){let B=t[_];if(B==="-a")n=!0;else if(B==="-A")r=!0;else if(B==="-r")s=!0;else if(B==="-x")i=!0;else if(B==="-p")o=!0;else if(B==="-n")a=!0;else if(B==="+n")l=!0;else if(B==="+a")c=!0;else if(B==="+x")u=!0;else if(B==="--"){y.push(...t.slice(_+1));break}else if(B.startsWith("+")){for(let v of B.slice(1))if(v==="n")l=!0;else if(v==="a")c=!0;else if(v==="x")u=!0;else if(v!=="r"){if(v!=="i"){if(!(v==="f"||v==="F"))return H("",`bash: typeset: +${v}: invalid option
878
+ `)}return ge(t)}function Ac(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function Ns(e,t){return e.state.integerVars?.has(t)??!1}function Sc(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function _b(e,t){return e.state.lowercaseVars?.has(t)??!1}function Cc(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function Mb(e,t){return e.state.uppercaseVars?.has(t)??!1}function Br(e,t,n){return _b(e,t)?n.toLowerCase():Mb(e,t)?n.toUpperCase():n}async function O6(e,t){try{let n=new ce,r=Ae(n,t),s=await J(e,r.expression);return String(s)}catch{return"0"}}function Fb(e){let t=e.match(/^[a-zA-Z_][a-zA-Z0-9_]*/);if(!t)return null;let n=t[0],r=n.length;if(e[r]!=="[")return null;let s=0,i=r+1;for(;r<e.length;r++)if(e[r]==="[")s++;else if(e[r]==="]"&&(s--,s===0))break;if(s!==0)return null;let o=e.slice(i,r);if(r++,e[r]!=="=")return null;r++;let a=e.slice(r);return{name:n,indexExpr:o,value:a}}async function Nc(e,t){let n=!1,r=!1,s=!1,i=!1,o=!1,a=!1,l=!1,c=!1,u=!1,f=!1,h=!1,p=!1,m=!1,d=!1,g=!1,y=[];for(let L=0;L<t.length;L++){let B=t[L];if(B==="-a")n=!0;else if(B==="-A")r=!0;else if(B==="-r")s=!0;else if(B==="-x")i=!0;else if(B==="-p")o=!0;else if(B==="-n")a=!0;else if(B==="+n")l=!0;else if(B==="+a")c=!0;else if(B==="+x")u=!0;else if(B==="--"){y.push(...t.slice(L+1));break}else if(B.startsWith("+")){for(let v of B.slice(1))if(v==="n")l=!0;else if(v==="a")c=!0;else if(v==="x")u=!0;else if(v!=="r"){if(v!=="i"){if(!(v==="f"||v==="F"))return H("",`bash: typeset: +${v}: invalid option
879
879
  `,2)}}}else if(B==="-i")f=!0;else if(B==="-l")h=!0;else if(B==="-u")p=!0;else if(B==="-f")m=!0;else if(B==="-F")d=!0;else if(B==="-g")g=!0;else if(B.startsWith("-"))for(let v of B.slice(1))if(v==="a")n=!0;else if(v==="A")r=!0;else if(v==="r")s=!0;else if(v==="x")i=!0;else if(v==="p")o=!0;else if(v==="n")a=!0;else if(v==="i")f=!0;else if(v==="l")h=!0;else if(v==="u")p=!0;else if(v==="f")m=!0;else if(v==="F")d=!0;else if(v==="g")g=!0;else return H("",`bash: typeset: -${v}: invalid option
880
- `,2);else y.push(B)}let b=e.state.localScopes.length>0&&!g,x=_=>{if(!b)return;let B=e.state.localScopes[e.state.localScopes.length-1];B.has(_)||B.set(_,e.state.env.get(_))},S=_=>{if(!b)return;let B=e.state.localScopes[e.state.localScopes.length-1];B.has(_)||B.set(_,e.state.env.get(_));let v=`${_}_`;for(let T of e.state.env.keys())T.startsWith(v)&&!T.includes("__")&&(B.has(T)||B.set(T,e.state.env.get(T)));let k=`${_}__length`;e.state.env.has(k)&&!B.has(k)&&B.set(k,e.state.env.get(k))},C=_=>{b&&Un(e,_)};if(d){if(y.length===0){let v=Array.from(e.state.functions.keys()).sort(),k="";for(let T of v)k+=`declare -f ${T}
881
- `;return ge(k)}let _=!0,B="";for(let v of y)e.state.functions.has(v)?B+=`${v}
882
- `:_=!1;return H(B,"",_?0:1)}if(m){if(y.length===0){let B="",v=Array.from(e.state.functions.keys()).sort();for(let k of v)B+=`${k} ()
880
+ `,2);else y.push(B)}let b=e.state.localScopes.length>0&&!g,x=L=>{if(!b)return;let B=e.state.localScopes[e.state.localScopes.length-1];B.has(L)||B.set(L,e.state.env.get(L))},S=L=>{if(!b)return;let B=e.state.localScopes[e.state.localScopes.length-1];B.has(L)||B.set(L,e.state.env.get(L));let v=`${L}_`;for(let T of e.state.env.keys())T.startsWith(v)&&!T.includes("__")&&(B.has(T)||B.set(T,e.state.env.get(T)));let k=`${L}__length`;e.state.env.has(k)&&!B.has(k)&&B.set(k,e.state.env.get(k))},C=L=>{b&&Un(e,L)};if(d){if(y.length===0){let v=Array.from(e.state.functions.keys()).sort(),k="";for(let T of v)k+=`declare -f ${T}
881
+ `;return ge(k)}let L=!0,B="";for(let v of y)e.state.functions.has(v)?B+=`${v}
882
+ `:L=!1;return H(B,"",L?0:1)}if(m){if(y.length===0){let B="",v=Array.from(e.state.functions.keys()).sort();for(let k of v)B+=`${k} ()
883
883
  {
884
884
  # function body
885
885
  }
886
- `;return ge(B)}let _=!0;for(let B of y)e.state.functions.has(B)||(_=!1);return H("","",_?0:1)}if(o&&y.length>0)return C6(e,y);if(o&&y.length===0)return N6(e,{filterExport:i,filterReadonly:s,filterNameref:a,filterIndexedArray:n,filterAssocArray:r});if(y.length===0&&r&&!o)return k6(e);if(y.length===0&&n&&!o)return v6(e);if(y.length===0&&!o)return I6(e);let $="",M=0;for(let _ of y){let B=_.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(B&&!c){let R=B[1],O=B[2];if(r&&Ke(e,R).length>0){$+=`bash: declare: ${R}: cannot convert indexed to associative array
887
- `,M=1;continue}if((n||!r&&!n)&&e.state.associativeArrays?.has(R)){$+=`bash: declare: ${R}: cannot convert associative to indexed array
888
- `,M=1;continue}if(S(R),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(R)),pn(e,R),e.state.env.delete(R),e.state.env.delete(`${R}__length`),r&&O.includes("[")){let L=co(O);for(let[ie,ue]of L){let te=Ve(e,ue);e.state.env.set(`${R}_${ie}`,te)}}else if(r){let L=yn(O);for(let ie=0;ie<L.length;ie+=2){let ue=L[ie],te=ie+1<L.length?Ve(e,L[ie+1]):"";e.state.env.set(`${R}_${ue}`,te)}}else{let L=yn(O);if(L.some(ue=>/^\[[^\]]+\]=/.test(ue))){let ue=0;for(let te of L){let z=te.match(/^\[([^\]]+)\]=(.*)$/);if(z){let ee=z[1],Ee=z[2],oe=Ve(e,Ee),ke;if(/^-?\d+$/.test(ee))ke=Number.parseInt(ee,10);else try{let j=new ce,ve=Ae(j,ee);ke=await J(e,ve.expression)}catch{ke=0}e.state.env.set(`${R}_${ke}`,oe),ue=ke+1}else{let ee=Ve(e,te);e.state.env.set(`${R}_${ue}`,ee),ue++}}}else{for(let ue=0;ue<L.length;ue++)e.state.env.set(`${R}_${ue}`,L[ue]);e.state.env.set(`${R}__length`,String(L.length))}}C(R),s&&Tt(e,R),i&&tn(e,R);continue}if(l){let R=_.includes("=")?_.slice(0,_.indexOf("=")):_;if(Tm(e,R),!_.includes("="))continue}if(u){let R=_.includes("=")?_.slice(0,_.indexOf("=")):_;if(ji(e,R),!_.includes("="))continue}let v=Fb(_);if(v){let{name:R,indexExpr:O,value:L}=v,ie=rt(e,R);if(ie)return ie;S(R);let ue;try{let z=new ce,ee=Ae(z,O);ue=await J(e,ee.expression)}catch{let z=parseInt(O,10);ue=Number.isNaN(z)?0:z}e.state.env.set(`${R}_${ue}`,L);let te=parseInt(e.state.env.get(`${R}__length`)??"0",10);ue>=te&&e.state.env.set(`${R}__length`,String(ue+1)),C(R),s&&Tt(e,R),i&&tn(e,R);continue}let k=_.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(k&&!c){let R=k[1],O=k[2],L=rt(e,R);if(L)return L;S(R);let ie=yn(O);if(e.state.associativeArrays?.has(R)){let ue=co(O);for(let[te,z]of ue){let ee=Ve(e,z);e.state.env.set(`${R}_${te}`,ee)}}else{let ue=Ke(e,R),te=0,z=e.state.env.get(R);ue.length===0&&z!==void 0?(e.state.env.set(`${R}_0`,z),e.state.env.delete(R),te=1):ue.length>0&&(te=Math.max(...ue)+1);for(let Ee=0;Ee<ie.length;Ee++)e.state.env.set(`${R}_${te+Ee}`,Ve(e,ie[Ee]));let ee=te+ie.length;e.state.env.set(`${R}__length`,String(ee))}C(R),s&&Tt(e,R),i&&tn(e,R);continue}let T=_.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(T){let R=T[1],O=Ve(e,T[2]),L=rt(e,R);if(L)return L;x(R),f&&Ac(e,R),h&&Sc(e,R),p&&Cc(e,R);let ue=Ke(e,R).length>0||e.state.associativeArrays?.has(R);if(Ns(e,R)){let te=e.state.env.get(R)??"0",z=parseInt(te,10)||0,ee=parseInt(await R6(e,O),10)||0;O=String(z+ee),e.state.env.set(R,O)}else if(ue){O=Br(e,R,O);let te=`${R}_0`,z=e.state.env.get(te)??"";e.state.env.set(te,z+O)}else{O=Br(e,R,O);let te=e.state.env.get(R)??"";e.state.env.set(R,te+O)}C(R),s&&Tt(e,R),i&&tn(e,R),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(R));continue}if(_.includes("=")){let R=_.indexOf("="),O=_.slice(0,R),L=_.slice(R+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(O)){$+=`bash: typeset: \`${O}': not a valid identifier
889
- `,M=1;continue}let ie=rt(e,O);if(ie)return ie;if(x(O),a){if(L!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(L)){$+=`bash: declare: \`${L}': invalid variable name for name reference
890
- `,M=1;continue}e.state.env.set(O,L),En(e,O),L!==""&&Hi(e,L)&&zl(e,O),C(O),s&&Tt(e,O),i&&tn(e,O);continue}if(f&&Ac(e,O),h&&Sc(e,O),p&&Cc(e,O),Ns(e,O)&&(L=await R6(e,L)),L=Br(e,O,L),Te(e,O)){let ue=xt(e,O);ue&&ue!==O?e.state.env.set(ue,L):e.state.env.set(O,L)}else e.state.env.set(O,L);C(O),s&&Tt(e,O),i&&tn(e,O),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(O))}else{let R=_;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(R)){$+=`bash: typeset: \`${R}': not a valid identifier
891
- `,M=1;continue}if(n||r?S(R):x(R),a){En(e,R);let L=e.state.env.get(R);L!==void 0&&L!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(L)?Pm(e,R):L&&Hi(e,L)&&zl(e,R),C(R),s&&Tt(e,R),i&&tn(e,R);continue}if(f&&Ac(e,R),h&&Sc(e,R),p&&Cc(e,R),r){if(Ke(e,R).length>0){$+=`bash: declare: ${R}: cannot convert indexed to associative array
892
- `,M=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(R)}let O=Array.from(e.state.env.keys()).some(L=>L.startsWith(`${R}_`)&&!L.startsWith(`${R}__length`));!e.state.env.has(R)&&!O&&(n||r?e.state.env.set(`${R}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(R))),C(R),s&&Tt(e,R),i&&tn(e,R)}}return H("",$,M)}async function kc(e,t){let n=!1,r=!1,s=!1,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="-a")n=!0;else if(a==="-A")r=!0;else if(a==="-p")s=!0;else if(a==="--"){i.push(...t.slice(o+1));break}else a.startsWith("-")||i.push(a)}if(i.length===0){let o="",a=Array.from(e.state.readonlyVars||[]).sort();for(let l of a){let c=e.state.env.get(l);if(c!==void 0){let u=c.replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -r ${l}="${u}"
886
+ `;return ge(B)}let L=!0;for(let B of y)e.state.functions.has(B)||(L=!1);return H("","",L?0:1)}if(o&&y.length>0)return C6(e,y);if(o&&y.length===0)return N6(e,{filterExport:i,filterReadonly:s,filterNameref:a,filterIndexedArray:n,filterAssocArray:r});if(y.length===0&&r&&!o)return k6(e);if(y.length===0&&n&&!o)return v6(e);if(y.length===0&&!o)return I6(e);let R="",U=0;for(let L of y){let B=L.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(B&&!c){let O=B[1],$=B[2];if(r&&Ke(e,O).length>0){R+=`bash: declare: ${O}: cannot convert indexed to associative array
887
+ `,U=1;continue}if((n||!r&&!n)&&e.state.associativeArrays?.has(O)){R+=`bash: declare: ${O}: cannot convert associative to indexed array
888
+ `,U=1;continue}if(S(O),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(O)),pn(e,O),e.state.env.delete(O),e.state.env.delete(`${O}__length`),r&&$.includes("[")){let _=co($);for(let[ie,ue]of _){let te=Ve(e,ue);e.state.env.set(`${O}_${ie}`,te)}}else if(r){let _=yn($);for(let ie=0;ie<_.length;ie+=2){let ue=_[ie],te=ie+1<_.length?Ve(e,_[ie+1]):"";e.state.env.set(`${O}_${ue}`,te)}}else{let _=yn($);if(_.some(ue=>/^\[[^\]]+\]=/.test(ue))){let ue=0;for(let te of _){let z=te.match(/^\[([^\]]+)\]=(.*)$/);if(z){let ee=z[1],Ee=z[2],oe=Ve(e,Ee),ke;if(/^-?\d+$/.test(ee))ke=Number.parseInt(ee,10);else try{let j=new ce,ve=Ae(j,ee);ke=await J(e,ve.expression)}catch{ke=0}e.state.env.set(`${O}_${ke}`,oe),ue=ke+1}else{let ee=Ve(e,te);e.state.env.set(`${O}_${ue}`,ee),ue++}}}else{for(let ue=0;ue<_.length;ue++)e.state.env.set(`${O}_${ue}`,_[ue]);e.state.env.set(`${O}__length`,String(_.length))}}C(O),s&&Tt(e,O),i&&tn(e,O);continue}if(l){let O=L.includes("=")?L.slice(0,L.indexOf("=")):L;if(Tm(e,O),!L.includes("="))continue}if(u){let O=L.includes("=")?L.slice(0,L.indexOf("=")):L;if(ji(e,O),!L.includes("="))continue}let v=Fb(L);if(v){let{name:O,indexExpr:$,value:_}=v,ie=rt(e,O);if(ie)return ie;S(O);let ue;try{let z=new ce,ee=Ae(z,$);ue=await J(e,ee.expression)}catch{let z=parseInt($,10);ue=Number.isNaN(z)?0:z}e.state.env.set(`${O}_${ue}`,_);let te=parseInt(e.state.env.get(`${O}__length`)??"0",10);ue>=te&&e.state.env.set(`${O}__length`,String(ue+1)),C(O),s&&Tt(e,O),i&&tn(e,O);continue}let k=L.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(k&&!c){let O=k[1],$=k[2],_=rt(e,O);if(_)return _;S(O);let ie=yn($);if(e.state.associativeArrays?.has(O)){let ue=co($);for(let[te,z]of ue){let ee=Ve(e,z);e.state.env.set(`${O}_${te}`,ee)}}else{let ue=Ke(e,O),te=0,z=e.state.env.get(O);ue.length===0&&z!==void 0?(e.state.env.set(`${O}_0`,z),e.state.env.delete(O),te=1):ue.length>0&&(te=Math.max(...ue)+1);for(let Ee=0;Ee<ie.length;Ee++)e.state.env.set(`${O}_${te+Ee}`,Ve(e,ie[Ee]));let ee=te+ie.length;e.state.env.set(`${O}__length`,String(ee))}C(O),s&&Tt(e,O),i&&tn(e,O);continue}let T=L.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(T){let O=T[1],$=Ve(e,T[2]),_=rt(e,O);if(_)return _;x(O),f&&Ac(e,O),h&&Sc(e,O),p&&Cc(e,O);let ue=Ke(e,O).length>0||e.state.associativeArrays?.has(O);if(Ns(e,O)){let te=e.state.env.get(O)??"0",z=parseInt(te,10)||0,ee=parseInt(await O6(e,$),10)||0;$=String(z+ee),e.state.env.set(O,$)}else if(ue){$=Br(e,O,$);let te=`${O}_0`,z=e.state.env.get(te)??"";e.state.env.set(te,z+$)}else{$=Br(e,O,$);let te=e.state.env.get(O)??"";e.state.env.set(O,te+$)}C(O),s&&Tt(e,O),i&&tn(e,O),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(O));continue}if(L.includes("=")){let O=L.indexOf("="),$=L.slice(0,O),_=L.slice(O+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test($)){R+=`bash: typeset: \`${$}': not a valid identifier
889
+ `,U=1;continue}let ie=rt(e,$);if(ie)return ie;if(x($),a){if(_!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(_)){R+=`bash: declare: \`${_}': invalid variable name for name reference
890
+ `,U=1;continue}e.state.env.set($,_),En(e,$),_!==""&&Hi(e,_)&&zl(e,$),C($),s&&Tt(e,$),i&&tn(e,$);continue}if(f&&Ac(e,$),h&&Sc(e,$),p&&Cc(e,$),Ns(e,$)&&(_=await O6(e,_)),_=Br(e,$,_),Te(e,$)){let ue=xt(e,$);ue&&ue!==$?e.state.env.set(ue,_):e.state.env.set($,_)}else e.state.env.set($,_);C($),s&&Tt(e,$),i&&tn(e,$),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add($))}else{let O=L;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(O)){R+=`bash: typeset: \`${O}': not a valid identifier
891
+ `,U=1;continue}if(n||r?S(O):x(O),a){En(e,O);let _=e.state.env.get(O);_!==void 0&&_!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(_)?Pm(e,O):_&&Hi(e,_)&&zl(e,O),C(O),s&&Tt(e,O),i&&tn(e,O);continue}if(f&&Ac(e,O),h&&Sc(e,O),p&&Cc(e,O),r){if(Ke(e,O).length>0){R+=`bash: declare: ${O}: cannot convert indexed to associative array
892
+ `,U=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(O)}let $=Array.from(e.state.env.keys()).some(_=>_.startsWith(`${O}_`)&&!_.startsWith(`${O}__length`));!e.state.env.has(O)&&!$&&(n||r?e.state.env.set(`${O}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(O))),C(O),s&&Tt(e,O),i&&tn(e,O)}}return H("",R,U)}async function kc(e,t){let n=!1,r=!1,s=!1,i=[];for(let o=0;o<t.length;o++){let a=t[o];if(a==="-a")n=!0;else if(a==="-A")r=!0;else if(a==="-p")s=!0;else if(a==="--"){i.push(...t.slice(o+1));break}else a.startsWith("-")||i.push(a)}if(i.length===0){let o="",a=Array.from(e.state.readonlyVars||[]).sort();for(let l of a){let c=e.state.env.get(l);if(c!==void 0){let u=c.replace(/\\/g,"\\\\").replace(/"/g,'\\"');o+=`declare -r ${l}="${u}"
893
893
  `}}return ge(o)}for(let o of i){let a=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(a){let f=a[1],h=a[2],p=rt(e,f);if(p)return p;let m=yn(h);if(e.state.associativeArrays?.has(f)){let d=co(h);for(let[g,y]of d){let w=Ve(e,y);e.state.env.set(`${f}_${g}`,w)}}else{let d=Ke(e,f),g=0,y=e.state.env.get(f);d.length===0&&y!==void 0?(e.state.env.set(`${f}_0`,y),e.state.env.delete(f),g=1):d.length>0&&(g=Math.max(...d)+1);for(let b=0;b<m.length;b++)e.state.env.set(`${f}_${g+b}`,Ve(e,m[b]));let w=g+m.length;e.state.env.set(`${f}__length`,String(w))}Tt(e,f);continue}let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(l){let f=l[1],h=Ve(e,l[2]),p=rt(e,f);if(p)return p;let m=e.state.env.get(f)??"";e.state.env.set(f,m+h),Tt(e,f);continue}let c=p6(o);if(c.value===void 0&&!c.isArray){Tt(e,c.name);continue}let u=await d6(e,c,{makeReadonly:!0});if(u)return u}return de}function vc(e){return e.state.directoryStack??=[],e.state.directoryStack}function ks(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function Ub(e){let t=e.split("/").filter(r=>r&&r!=="."),n=[];for(let r of t)r===".."?n.pop():n.push(r);return`/${n.join("/")}`}async function Ic(e,t){let n=vc(e),r;for(let a=0;a<t.length;a++){let l=t[a];if(l==="--"){if(a+1<t.length){if(r!==void 0)return W(`bash: pushd: too many arguments
894
894
  `,2);r=t[a+1],a++}}else{if(l.startsWith("-")&&l!=="-")return W(`bash: pushd: ${l}: invalid option
895
895
  `,2);if(r!==void 0)return W(`bash: pushd: too many arguments
@@ -897,12 +897,12 @@ Gid: ${r} ${r} ${r} ${r}
897
897
  `,1);let a=n[0];n[0]=n[1],n[1]=a,r=n[0]}let s;if(r.startsWith("/"))s=r;else if(r===".."){let a=e.state.cwd.split("/").filter(l=>l);a.pop(),s=`/${a.join("/")}`}else r==="."?s=e.state.cwd:r.startsWith("~")?s=(e.state.env.get("HOME")||"/")+r.slice(1):s=`${e.state.cwd}/${r}`;s=Ub(s);try{if(!(await e.fs.stat(s)).isDirectory)return W(`bash: pushd: ${r}: Not a directory
898
898
  `,1)}catch{return W(`bash: pushd: ${r}: No such file or directory
899
899
  `,1)}n.unshift(e.state.cwd),e.state.previousDir=e.state.cwd,e.state.cwd=s,e.state.env.set("PWD",s),e.state.env.set("OLDPWD",e.state.previousDir);let i=e.state.env.get("HOME")||"",o=`${[s,...n].map(a=>ks(a,i)).join(" ")}
900
- `;return ge(o)}function Rc(e,t){let n=vc(e);for(let o of t)if(o!=="--")return o.startsWith("-")&&o!=="-"?W(`bash: popd: ${o}: invalid option
900
+ `;return ge(o)}function Oc(e,t){let n=vc(e);for(let o of t)if(o!=="--")return o.startsWith("-")&&o!=="-"?W(`bash: popd: ${o}: invalid option
901
901
  `,2):W(`bash: popd: too many arguments
902
902
  `,2);if(n.length===0)return W(`bash: popd: directory stack empty
903
903
  `,1);let r=n.shift();if(!r)return W(`bash: popd: directory stack empty
904
904
  `,1);e.state.previousDir=e.state.cwd,e.state.cwd=r,e.state.env.set("PWD",r),e.state.env.set("OLDPWD",e.state.previousDir);let s=e.state.env.get("HOME")||"",i=`${[r,...n].map(o=>ks(o,s)).join(" ")}
905
- `;return ge(i)}function Oc(e,t){let n=vc(e),r=!1,s=!1,i=!1,o=!1;for(let u of t)if(u!=="--")if(u.startsWith("-"))for(let f of u.slice(1))if(f==="c")r=!0;else if(f==="l")s=!0;else if(f==="p")i=!0;else if(f==="v")i=!0,o=!0;else return W(`bash: dirs: -${f}: invalid option
905
+ `;return ge(i)}function Rc(e,t){let n=vc(e),r=!1,s=!1,i=!1,o=!1;for(let u of t)if(u!=="--")if(u.startsWith("-"))for(let f of u.slice(1))if(f==="c")r=!0;else if(f==="l")s=!0;else if(f==="p")i=!0;else if(f==="v")i=!0,o=!0;else return W(`bash: dirs: -${f}: invalid option
906
906
  `,2);else return W(`bash: dirs: too many arguments
907
907
  `,1);if(r)return e.state.directoryStack=[],de;let a=[e.state.cwd,...n],l=e.state.env.get("HOME")||"",c;return o?(c=a.map((u,f)=>{let h=s?u:ks(u,l);return` ${f} ${h}`}).join(`
908
908
  `),c+=`
@@ -934,7 +934,7 @@ eval: usage: eval [arg ...]
934
934
  `;for(let[,d]of e.state.hashTable)m+=` 1 ${d}
935
935
  `}return ge(m)}let u=!1,f="",p=(e.state.env.get("PATH")||"/usr/bin:/bin").split(":");for(let m of l){if(m.includes("/")){f+=`bash: hash: ${m}: cannot use / in name
936
936
  `,u=!0;continue}let d=!1;for(let g of p){if(!g)continue;let y=`${g}/${m}`;if(await e.fs.exists(y)){e.state.hashTable.set(m,y),d=!0;break}}d||(f+=`bash: hash: ${m}: not found
937
- `,u=!0)}return u?W(f,1):de}Me();var O6=new Map([[":",[": [arguments]",`Null command.
937
+ `,u=!0)}return u?W(f,1):de}Me();var R6=new Map([[":",[": [arguments]",`Null command.
938
938
  No effect; the command does nothing.
939
939
  Exit Status:
940
940
  Always succeeds.`]],[".",[". filename [arguments]",`Execute commands from a file in the current shell.
@@ -1279,9 +1279,9 @@ eval: usage: eval [arg ...]
1279
1279
  job specification, and reports its termination status.
1280
1280
  Exit Status:
1281
1281
  Returns the status of the last ID; fails if ID is invalid or an invalid
1282
- option is given.`]]]),$6=[...O6.keys()].sort();function Dc(e,t){let n=!1,r=[],s=0;for(;s<t.length;){let l=t[s];if(l==="--"){for(s++;s<t.length;)r.push(t[s]),s++;break}if(l.startsWith("-")&&l.length>1){for(let c=1;c<l.length;c++){let u=l[c];if(u==="s")n=!0;else return W(`bash: help: -${u}: invalid option
1282
+ option is given.`]]]),$6=[...R6.keys()].sort();function Dc(e,t){let n=!1,r=[],s=0;for(;s<t.length;){let l=t[s];if(l==="--"){for(s++;s<t.length;)r.push(t[s]),s++;break}if(l.startsWith("-")&&l.length>1){for(let c=1;c<l.length;c++){let u=l[c];if(u==="s")n=!0;else return W(`bash: help: -${u}: invalid option
1283
1283
  `,2)}s++}else r.push(l),s++}if(r.length===0)return Bb();let i="",o=!1,a="";for(let l of r){let c=Wb(l);if(c.length===0){a+=`bash: help: no help topics match \`${l}'. Try \`help help' or \`man -k ${l}' or \`info ${l}'.
1284
- `,o=!0;continue}for(let u of c){let f=O6.get(u);if(!f)continue;let[h,p]=f;n?i+=`${u}: ${h}
1284
+ `,o=!0;continue}for(let u of c){let f=R6.get(u);if(!f)continue;let[h,p]=f;n?i+=`${u}: ${h}
1285
1285
  `:i+=`${u}: ${h}
1286
1286
  ${p}
1287
1287
  `}}return{exitCode:o?1:0,stdout:i,stderr:a}}function Wb(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),n=V(`^${t}$`);return $6.filter(r=>n.test(r))}function Bb(){let e=[];e.push("just-bash shell builtins"),e.push("These shell commands are defined internally. Type `help' to see this list."),e.push("Type `help name' to find out more about the function `name'."),e.push("");let t=36,n=$6.slice(),r=Math.ceil(n.length/2);for(let s=0;s<r;s++){let i=n[s]||"",o=n[s+r]||"",a=i.padEnd(t);e.push(o?`${a}${o}`:i)}return ge(`${e.join(`
@@ -1291,19 +1291,19 @@ ${p}
1291
1291
  `)}return H("","",r===0?1:0)}pt();Qe();Et();Zt();en();_n();async function _c(e,t){if(e.state.localScopes.length===0)return W(`bash: local: can only be used in a function
1292
1292
  `);let n=e.state.localScopes[e.state.localScopes.length-1],r="",s=0,i=!1,o=!1,a=!1,l=[];for(let c of t)if(c==="-n")i=!0;else if(c==="-a")o=!0;else if(c==="-p")a=!0;else if(c.startsWith("-")&&!c.includes("="))for(let u of c.slice(1))u==="n"?i=!0:u==="a"?o=!0:u==="p"&&(a=!0);else l.push(c);if(l.length===0){let c="",u=Array.from(n.keys()).filter(f=>!f.includes("_")||!f.match(/_\d+$/)).filter(f=>!f.includes("__length")).sort();for(let f of u){let h=e.state.env.get(f);h!==void 0&&(c+=`${f}=${h}
1293
1293
  `)}return H(c,"",0)}for(let c of l){let u,f,h=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(h){u=h[1];let y=h[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1294
- `,s=1;continue}if(rt(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let x=`${u}_`;for(let S of e.state.env.keys())S.startsWith(x)&&!S.includes("__")&&(n.has(S)||n.set(S,e.state.env.get(S)))}let w=`${u}_`;for(let x of e.state.env.keys())x.startsWith(w)&&!x.includes("__")&&e.state.env.delete(x);let b=yn(y);for(let x=0;x<b.length;x++)e.state.env.set(`${u}_${x}`,b[x]);e.state.env.set(`${u}__length`,String(b.length)),Un(e,u),i&&En(e,u);continue}let p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(p){u=p[1];let y=p[2];if(rt(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let $=`${u}_`;for(let _ of e.state.env.keys())_.startsWith($)&&!_.includes("__")&&(n.has(_)||n.set(_,e.state.env.get(_)));let M=`${u}__length`;e.state.env.has(M)&&!n.has(M)&&n.set(M,e.state.env.get(M))}let w=yn(y),b=Ke(e,u),x=0,S=e.state.env.get(u);b.length===0&&S!==void 0?(e.state.env.set(`${u}_0`,S),e.state.env.delete(u),x=1):b.length>0&&(x=Math.max(...b)+1);for(let $=0;$<w.length;$++)e.state.env.set(`${u}_${x+$}`,Ve(e,w[$]));let C=x+w.length;e.state.env.set(`${u}__length`,String(C)),Un(e,u),i&&En(e,u);continue}let m=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){u=m[1];let y=Ve(e,m[2]);rt(e,u,"bash"),n.has(u)||n.set(u,e.state.env.get(u));let w=e.state.env.get(u)??"";e.state.env.set(u,w+y),Un(e,u),i&&En(e,u);continue}let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(d){u=d[1];let y=d[2],w=Ve(e,d[3]);if(rt(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let S=`${u}_`;for(let $ of e.state.env.keys())$.startsWith(S)&&!$.includes("__")&&(n.has($)||n.set($,e.state.env.get($)));let C=`${u}__length`;e.state.env.has(C)&&!n.has(C)&&n.set(C,e.state.env.get(C))}let b;try{let S=new ce,C=Ae(S,y);b=await J(e,C.expression)}catch{let S=parseInt(y,10);b=Number.isNaN(S)?0:S}e.state.env.set(`${u}_${b}`,w);let x=parseInt(e.state.env.get(`${u}__length`)??"0",10);b>=x&&e.state.env.set(`${u}__length`,String(b+1)),Un(e,u),i&&En(e,u);continue}if(c.includes("=")){let y=c.indexOf("=");u=c.slice(0,y),f=Ve(e,c.slice(y+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1294
+ `,s=1;continue}if(rt(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let x=`${u}_`;for(let S of e.state.env.keys())S.startsWith(x)&&!S.includes("__")&&(n.has(S)||n.set(S,e.state.env.get(S)))}let w=`${u}_`;for(let x of e.state.env.keys())x.startsWith(w)&&!x.includes("__")&&e.state.env.delete(x);let b=yn(y);for(let x=0;x<b.length;x++)e.state.env.set(`${u}_${x}`,b[x]);e.state.env.set(`${u}__length`,String(b.length)),Un(e,u),i&&En(e,u);continue}let p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(p){u=p[1];let y=p[2];if(rt(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let R=`${u}_`;for(let L of e.state.env.keys())L.startsWith(R)&&!L.includes("__")&&(n.has(L)||n.set(L,e.state.env.get(L)));let U=`${u}__length`;e.state.env.has(U)&&!n.has(U)&&n.set(U,e.state.env.get(U))}let w=yn(y),b=Ke(e,u),x=0,S=e.state.env.get(u);b.length===0&&S!==void 0?(e.state.env.set(`${u}_0`,S),e.state.env.delete(u),x=1):b.length>0&&(x=Math.max(...b)+1);for(let R=0;R<w.length;R++)e.state.env.set(`${u}_${x+R}`,Ve(e,w[R]));let C=x+w.length;e.state.env.set(`${u}__length`,String(C)),Un(e,u),i&&En(e,u);continue}let m=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){u=m[1];let y=Ve(e,m[2]);rt(e,u,"bash"),n.has(u)||n.set(u,e.state.env.get(u));let w=e.state.env.get(u)??"";e.state.env.set(u,w+y),Un(e,u),i&&En(e,u);continue}let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(d){u=d[1];let y=d[2],w=Ve(e,d[3]);if(rt(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let S=`${u}_`;for(let R of e.state.env.keys())R.startsWith(S)&&!R.includes("__")&&(n.has(R)||n.set(R,e.state.env.get(R)));let C=`${u}__length`;e.state.env.has(C)&&!n.has(C)&&n.set(C,e.state.env.get(C))}let b;try{let S=new ce,C=Ae(S,y);b=await J(e,C.expression)}catch{let S=parseInt(y,10);b=Number.isNaN(S)?0:S}e.state.env.set(`${u}_${b}`,w);let x=parseInt(e.state.env.get(`${u}__length`)??"0",10);b>=x&&e.state.env.set(`${u}__length`,String(b+1)),Un(e,u),i&&En(e,u);continue}if(c.includes("=")){let y=c.indexOf("=");u=c.slice(0,y),f=Ve(e,c.slice(y+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
1295
1295
  `,s=1;continue}let g=n.has(u);if(f!==void 0){let y=e.state.env.get(u);if(e.state.tempEnvBindings){let w=e.state.accessedTempEnvVars?.has(u),b=e.state.mutatedTempEnvVars?.has(u);if(!w&&!b)for(let x=e.state.tempEnvBindings.length-1;x>=0;x--){let S=e.state.tempEnvBindings[x];if(S.has(u)){y=S.get(u);break}}}m6(e,u,y)}if(!g){let y=e.state.env.get(u);if(e.state.tempEnvBindings)for(let w=e.state.tempEnvBindings.length-1;w>=0;w--){let b=e.state.tempEnvBindings[w];if(b.has(u)){y=b.get(u);break}}if(n.set(u,y),o){let w=`${u}_`;for(let x of e.state.env.keys())x.startsWith(w)&&!x.includes("__")&&(n.has(x)||n.set(x,e.state.env.get(x)));let b=`${u}__length`;e.state.env.has(b)&&!n.has(b)&&n.set(b,e.state.env.get(b))}}if(o&&f===void 0){let y=`${u}_`;for(let w of e.state.env.keys())w.startsWith(y)&&!w.includes("__")&&e.state.env.delete(w);e.state.env.set(`${u}__length`,"0")}else if(f!==void 0){if(rt(e,u,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){r+=`bash: local: \`${f}': invalid variable name for name reference
1296
1296
  `,s=1;continue}e.state.env.set(u,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(u))}else{let y=e.state.tempEnvBindings?.some(w=>w.has(u));!g&&!y&&e.state.env.delete(u)}Un(e,u),i&&En(e,u)}return H("",r,s)}Zt();function Mc(e,t,n){let r=`
1297
1297
  `,s=0,i=0,o=0,a=!1,l="MAPFILE",c=0;for(;c<t.length;){let w=t[c];w==="-d"&&c+1<t.length?(r=t[c+1]===""?"\0":t[c+1]||`
1298
1298
  `,c+=2):w==="-n"&&c+1<t.length?(s=Number.parseInt(t[c+1],10)||0,c+=2):w==="-O"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):w==="-s"&&c+1<t.length?(o=Number.parseInt(t[c+1],10)||0,c+=2):w==="-t"?(a=!0,c++):w==="-u"||w==="-C"||w==="-c"?c+=2:(w.startsWith("-")||(l=w),c++)}let u=n;!u&&e.state.groupStdin!==void 0&&(u=e.state.groupStdin);let f=[],h=u,p=0,m=0,d=e.limits?.maxArrayElements??1e5;for(;h.length>0;){let w=h.indexOf(r);if(w===-1){if(h.length>0){if(m<o)m++;else if(s===0||p<s){if(i+p>=d)return H("",`mapfile: array element limit exceeded (${d})
1299
1299
  `,1);let S=h,C=S.indexOf("\0");C!==-1&&(S=S.substring(0,C)),f.push(S),p++}}break}let b=h.substring(0,w),x=b.indexOf("\0");if(x!==-1&&(b=b.substring(0,x)),!a&&r!=="\0"&&(b+=r),h=h.substring(w+r.length),m<o){m++;continue}if(s>0&&p>=s)break;if(i+p>=d)return H("",`mapfile: array element limit exceeded (${d})
1300
1300
  `,1);f.push(b),p++}i===0&&pn(e,l);for(let w=0;w<f.length;w++)e.state.env.set(`${l}_${i+w}`,f[w]);let g=parseInt(e.state.env.get(`${l}__length`)||"0",10),y=i+f.length;return e.state.env.set(`${l}__length`,String(Math.max(g,y))),e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=""),H("","",0)}Zt();Wt();function zb(e){if(!e.startsWith("__rw__:"))return null;let t=e.slice(7),n=t.indexOf(":");if(n===-1)return null;let r=Number.parseInt(t.slice(0,n),10);if(Number.isNaN(r)||r<0)return null;let s=n+1,i=t.slice(s,s+r),o=s+r+1,a=t.slice(o),l=a.indexOf(":");if(l===-1)return null;let c=Number.parseInt(a.slice(0,l),10);if(Number.isNaN(c)||c<0)return null;let u=a.slice(l+1);return{path:i,position:c,content:u}}function jb(e,t,n){return`__rw__:${e.length}:${e}:${t}:${n}`}function Fc(e,t,n,r=-1){let s=!1,i=`
1301
- `,o="",a=-1,l=-1,c=null,u=-1,f=-1,h=[],p=0,m=!1,d=(v,k)=>{let T=1;for(;T<v.length;){let R=v[T];if(R==="r")s=!0,T++;else if(R==="s")T++;else{if(R==="d")return T+1<v.length?(i=v.substring(T+1),{nextArgIndex:k+1}):k+1<t.length?(i=t[k+1],{nextArgIndex:k+2}):{nextArgIndex:k+1};if(R==="n"){if(T+1<v.length){let O=v.substring(T+1);return a=Number.parseInt(O,10),(Number.isNaN(a)||a<0)&&(m=!0,a=0),{nextArgIndex:k+1}}else if(k+1<t.length)return a=Number.parseInt(t[k+1],10),(Number.isNaN(a)||a<0)&&(m=!0,a=0),{nextArgIndex:k+2};return{nextArgIndex:k+1}}else if(R==="N"){if(T+1<v.length){let O=v.substring(T+1);return l=Number.parseInt(O,10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:k+1}}else if(k+1<t.length)return l=Number.parseInt(t[k+1],10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:k+2};return{nextArgIndex:k+1}}else{if(R==="a")return T+1<v.length?(c=v.substring(T+1),{nextArgIndex:k+1}):k+1<t.length?(c=t[k+1],{nextArgIndex:k+2}):{nextArgIndex:k+1};if(R==="p")return T+1<v.length?(o=v.substring(T+1),{nextArgIndex:k+1}):k+1<t.length?(o=t[k+1],{nextArgIndex:k+2}):{nextArgIndex:k+1};if(R==="u"){if(T+1<v.length){let O=v.substring(T+1);return u=Number.parseInt(O,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:k+1}}else if(k+1<t.length)return u=Number.parseInt(t[k+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:k+2};return{nextArgIndex:k+1}}else if(R==="t"){if(T+1<v.length){let O=v.substring(T+1);return f=Number.parseFloat(O),Number.isNaN(f)&&(f=0),{nextArgIndex:k+1}}else if(k+1<t.length)return f=Number.parseFloat(t[k+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:k+2};return{nextArgIndex:k+1}}else if(R==="e"||R==="i"||R==="P"){if(R==="i"&&k+1<t.length)return{nextArgIndex:k+2};T++}else T++}}}return{nextArgIndex:k+1}};for(;p<t.length;){let v=t[p];if(v.startsWith("-")&&v.length>1&&v!=="--"){let k=d(v,p);if(k.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(k.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};p=k.nextArgIndex}else if(v==="--")for(p++;p<t.length;)h.push(t[p]),p++;else h.push(v),p++}if(m)return H("","",1);if(h.length===0&&c===null&&h.push("REPLY"),f===0){if(c)pn(e,c);else{for(let v of h)e.state.env.set(v,"");h.length===0&&e.state.env.set("REPLY","")}return H("","",0)}if(f<0&&f!==-1)return H("","",1);let g=n;u>=0?e.state.fileDescriptors?g=e.state.fileDescriptors.get(u)||"":g="":!g&&e.state.groupStdin!==void 0&&(g=e.state.groupStdin);let y=i===""?"\0":i,w="",b=0,x=!0,S=v=>{if(u>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(u,g.substring(v));else if(r>=0&&e.state.fileDescriptors){let k=e.state.fileDescriptors.get(r);if(k?.startsWith("__rw__:")){let T=zb(k);if(T){let R=T.position+v;e.state.fileDescriptors.set(r,jb(T.path,R,T.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=g.substring(v))};if(l>=0){let v=Math.min(l,g.length);w=g.substring(0,v),b=v,x=v>=l,S(b);let k=h[0]||"REPLY";e.state.env.set(k,w);for(let T=1;T<h.length;T++)e.state.env.set(h[T],"");return H("","",x?0:1)}else if(a>=0){let v=0,k=0,T=!1;for(;k<g.length&&v<a;){let R=g[k];if(R===y){b=k+1,T=!0;break}if(!s&&R==="\\"&&k+1<g.length){let O=g[k+1];if(O===y&&y===`
1302
- `){k+=2,b=k;continue}if(O===y){k+=2,v++,w+=O,b=k;continue}w+=O,k+=2,v++,b=k}else w+=R,k++,v++,b=k}x=v>=a||T,S(b)}else{b=0;let v=0;for(;v<g.length;){let k=g[v];if(k===y){b=v+y.length,x=!0;break}if(!s&&k==="\\"&&v+1<g.length){let T=g[v+1];if(T===`
1301
+ `,o="",a=-1,l=-1,c=null,u=-1,f=-1,h=[],p=0,m=!1,d=(v,k)=>{let T=1;for(;T<v.length;){let O=v[T];if(O==="r")s=!0,T++;else if(O==="s")T++;else{if(O==="d")return T+1<v.length?(i=v.substring(T+1),{nextArgIndex:k+1}):k+1<t.length?(i=t[k+1],{nextArgIndex:k+2}):{nextArgIndex:k+1};if(O==="n"){if(T+1<v.length){let $=v.substring(T+1);return a=Number.parseInt($,10),(Number.isNaN(a)||a<0)&&(m=!0,a=0),{nextArgIndex:k+1}}else if(k+1<t.length)return a=Number.parseInt(t[k+1],10),(Number.isNaN(a)||a<0)&&(m=!0,a=0),{nextArgIndex:k+2};return{nextArgIndex:k+1}}else if(O==="N"){if(T+1<v.length){let $=v.substring(T+1);return l=Number.parseInt($,10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:k+1}}else if(k+1<t.length)return l=Number.parseInt(t[k+1],10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:k+2};return{nextArgIndex:k+1}}else{if(O==="a")return T+1<v.length?(c=v.substring(T+1),{nextArgIndex:k+1}):k+1<t.length?(c=t[k+1],{nextArgIndex:k+2}):{nextArgIndex:k+1};if(O==="p")return T+1<v.length?(o=v.substring(T+1),{nextArgIndex:k+1}):k+1<t.length?(o=t[k+1],{nextArgIndex:k+2}):{nextArgIndex:k+1};if(O==="u"){if(T+1<v.length){let $=v.substring(T+1);return u=Number.parseInt($,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:k+1}}else if(k+1<t.length)return u=Number.parseInt(t[k+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:k+2};return{nextArgIndex:k+1}}else if(O==="t"){if(T+1<v.length){let $=v.substring(T+1);return f=Number.parseFloat($),Number.isNaN(f)&&(f=0),{nextArgIndex:k+1}}else if(k+1<t.length)return f=Number.parseFloat(t[k+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:k+2};return{nextArgIndex:k+1}}else if(O==="e"||O==="i"||O==="P"){if(O==="i"&&k+1<t.length)return{nextArgIndex:k+2};T++}else T++}}}return{nextArgIndex:k+1}};for(;p<t.length;){let v=t[p];if(v.startsWith("-")&&v.length>1&&v!=="--"){let k=d(v,p);if(k.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(k.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};p=k.nextArgIndex}else if(v==="--")for(p++;p<t.length;)h.push(t[p]),p++;else h.push(v),p++}if(m)return H("","",1);if(h.length===0&&c===null&&h.push("REPLY"),f===0){if(c)pn(e,c);else{for(let v of h)e.state.env.set(v,"");h.length===0&&e.state.env.set("REPLY","")}return H("","",0)}if(f<0&&f!==-1)return H("","",1);let g=n;u>=0?e.state.fileDescriptors?g=e.state.fileDescriptors.get(u)||"":g="":!g&&e.state.groupStdin!==void 0&&(g=e.state.groupStdin);let y=i===""?"\0":i,w="",b=0,x=!0,S=v=>{if(u>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(u,g.substring(v));else if(r>=0&&e.state.fileDescriptors){let k=e.state.fileDescriptors.get(r);if(k?.startsWith("__rw__:")){let T=zb(k);if(T){let O=T.position+v;e.state.fileDescriptors.set(r,jb(T.path,O,T.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=g.substring(v))};if(l>=0){let v=Math.min(l,g.length);w=g.substring(0,v),b=v,x=v>=l,S(b);let k=h[0]||"REPLY";e.state.env.set(k,w);for(let T=1;T<h.length;T++)e.state.env.set(h[T],"");return H("","",x?0:1)}else if(a>=0){let v=0,k=0,T=!1;for(;k<g.length&&v<a;){let O=g[k];if(O===y){b=k+1,T=!0;break}if(!s&&O==="\\"&&k+1<g.length){let $=g[k+1];if($===y&&y===`
1302
+ `){k+=2,b=k;continue}if($===y){k+=2,v++,w+=$,b=k;continue}w+=$,k+=2,v++,b=k}else w+=O,k++,v++,b=k}x=v>=a||T,S(b)}else{b=0;let v=0;for(;v<g.length;){let k=g[v];if(k===y){b=v+y.length,x=!0;break}if(!s&&k==="\\"&&v+1<g.length){let T=g[v+1];if(T===`
1303
1303
  `){v+=2;continue}if(T===y){w+=T,v+=2;continue}w+=k,w+=T,v+=2;continue}w+=k,v++}if(v>=g.length&&(x=!1,b=v,w.length===0&&g.length===0)){for(let k of h)e.state.env.set(k,"");return c&&pn(e,c),H("","",1)}S(b)}y===`
1304
1304
  `&&w.endsWith(`
1305
- `)&&(w=w.slice(0,-1));let C=v=>s?v:v.replace(/\\(.)/g,"$1");if(h.length===1&&h[0]==="REPLY")return e.state.env.set("REPLY",C(w)),H("","",x?0:1);let $=tt(e.state.env);if(c){let{words:v}=Hl(w,$,void 0,s),k=e.limits?.maxArrayElements??1e5;if(v.length>k)return H("",`read: array element limit exceeded (${k})
1306
- `,1);pn(e,c);for(let T=0;T<v.length;T++)e.state.env.set(`${c}_${T}`,C(v[T]));return H("","",x?0:1)}let M=h.length,{words:_,wordStarts:B}=Hl(w,$,M,s);for(let v=0;v<h.length;v++){let k=h[v];if(v<h.length-1)e.state.env.set(k,C(_[v]??""));else if(v<B.length){let T=w.substring(B[v]);T=$m(T,$,s),T=C(T),e.state.env.set(k,T)}else e.state.env.set(k,"")}return H("","",x?0:1)}xe();function Uc(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return W("bash: return: can only `return' from a function or sourced script\n");let n=e.state.lastExitCode;if(t.length>0){let r=t[0],s=Number.parseInt(r,10);if(r===""||Number.isNaN(s)||!/^-?\d+$/.test(r))return W(`bash: return: ${r}: numeric argument required
1305
+ `)&&(w=w.slice(0,-1));let C=v=>s?v:v.replace(/\\(.)/g,"$1");if(h.length===1&&h[0]==="REPLY")return e.state.env.set("REPLY",C(w)),H("","",x?0:1);let R=tt(e.state.env);if(c){let{words:v}=Hl(w,R,void 0,s),k=e.limits?.maxArrayElements??1e5;if(v.length>k)return H("",`read: array element limit exceeded (${k})
1306
+ `,1);pn(e,c);for(let T=0;T<v.length;T++)e.state.env.set(`${c}_${T}`,C(v[T]));return H("","",x?0:1)}let U=h.length,{words:L,wordStarts:B}=Hl(w,R,U,s);for(let v=0;v<h.length;v++){let k=h[v];if(v<h.length-1)e.state.env.set(k,C(L[v]??""));else if(v<B.length){let T=w.substring(B[v]);T=$m(T,R,s),T=C(T),e.state.env.set(k,T)}else e.state.env.set(k,"")}return H("","",x?0:1)}xe();function Uc(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return W("bash: return: can only `return' from a function or sourced script\n");let n=e.state.lastExitCode;if(t.length>0){let r=t[0],s=Number.parseInt(r,10);if(r===""||Number.isNaN(s)||!/^-?\d+$/.test(r))return W(`bash: return: ${r}: numeric argument required
1307
1307
  `,2);n=(s%256+256)%256}throw new it(n)}xe();Zt();var wo=`set: usage: set [-eux] [+eux] [-o option] [+o option]
1308
1308
  Options:
1309
1309
  -e Exit immediately if a command exits with non-zero status
@@ -1320,7 +1320,7 @@ Options:
1320
1320
  +o pipefail Disable pipefail
1321
1321
  -o xtrace Same as -x
1322
1322
  +o xtrace Disable xtrace
1323
- `,T6=new Map([["e","errexit"],["u","nounset"],["x","xtrace"],["v","verbose"],["f","noglob"],["C","noclobber"],["a","allexport"],["n","noexec"],["h",null],["b",null],["m",null],["B",null],["H",null],["P",null],["T",null],["E",null],["p",null]]),P6=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["noclobber","noclobber"],["noglob","noglob"],["allexport","allexport"],["noexec","noexec"],["posix","posix"],["vi","vi"],["emacs","emacs"],["notify",null],["monitor",null],["braceexpand",null],["histexpand",null],["physical",null],["functrace",null],["errtrace",null],["privileged",null],["hashall",null],["ignoreeof",null],["interactive-comments",null],["keyword",null],["onecmd",null]]),D6=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],L6=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function _6(e,t,n){t!==null&&(n&&(t==="vi"?e.state.options.emacs=!1:t==="emacs"&&(e.state.options.vi=!1)),e.state.options[t]=n,Or(e))}function Gb(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function Vb(e,t){let n=Ke(e,t);if(n.length===0)return`${t}=()`;let r=n.map(s=>{let i=e.state.env.get(`${t}_${s}`)??"";return`[${s}]=${sr(i)}`});return`${t}=(${r.join(" ")})`}function qb(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Zb(e,t){let n=Jt(e,t);if(n.length===0)return`${t}=()`;let r=n.map(s=>{let i=e.state.env.get(`${t}_${s}`)??"";return`[${qb(s)}]=${sr(i)}`});return`${t}=(${r.join(" ")} )`}function Qb(e){let t=new Set,n=e.state.associativeArrays??new Set;for(let r of e.state.env.keys()){let s=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(s){let i=s[1];n.has(i)||t.add(i)}}return t}function Kb(e){return e.state.associativeArrays??new Set}function Bc(e,t){if(t.includes("--help"))return ge(wo);if(t.length===0){let r=Qb(e),s=Kb(e),i=l=>{for(let c of s){let u=`${c}_`,f=`${c}__length`;if(l!==f&&l.startsWith(u)){if(l.slice(u.length).startsWith("_length"))continue;return!0}}return!1},o=[];for(let[l,c]of e.state.env){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)||r.has(l)||s.has(l))continue;let u=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(u&&r.has(u[1]))continue;let f=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&r.has(f[1])||i(l)||f&&s.has(f[1])||o.push([l,c])}let a=[];for(let[l,c]of o.sort(([u],[f])=>u<f?-1:u>f?1:0))a.push(`${l}=${mo(c)}`);for(let l of[...r].sort((c,u)=>c<u?-1:c>u?1:0))a.push(Vb(e,l));for(let l of[...s].sort((c,u)=>c<u?-1:c>u?1:0))a.push(Zb(e,l));return a.sort((l,c)=>{let u=l.split("=")[0],f=c.split("=")[0];return u<f?-1:u>f?1:0}),ge(a.length>0?`${a.join(`
1323
+ `,T6=new Map([["e","errexit"],["u","nounset"],["x","xtrace"],["v","verbose"],["f","noglob"],["C","noclobber"],["a","allexport"],["n","noexec"],["h",null],["b",null],["m",null],["B",null],["H",null],["P",null],["T",null],["E",null],["p",null]]),P6=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["noclobber","noclobber"],["noglob","noglob"],["allexport","allexport"],["noexec","noexec"],["posix","posix"],["vi","vi"],["emacs","emacs"],["notify",null],["monitor",null],["braceexpand",null],["histexpand",null],["physical",null],["functrace",null],["errtrace",null],["privileged",null],["hashall",null],["ignoreeof",null],["interactive-comments",null],["keyword",null],["onecmd",null]]),D6=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],L6=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function _6(e,t,n){t!==null&&(n&&(t==="vi"?e.state.options.emacs=!1:t==="emacs"&&(e.state.options.vi=!1)),e.state.options[t]=n,Rr(e))}function Gb(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function Vb(e,t){let n=Ke(e,t);if(n.length===0)return`${t}=()`;let r=n.map(s=>{let i=e.state.env.get(`${t}_${s}`)??"";return`[${s}]=${sr(i)}`});return`${t}=(${r.join(" ")})`}function qb(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Zb(e,t){let n=Jt(e,t);if(n.length===0)return`${t}=()`;let r=n.map(s=>{let i=e.state.env.get(`${t}_${s}`)??"";return`[${qb(s)}]=${sr(i)}`});return`${t}=(${r.join(" ")} )`}function Qb(e){let t=new Set,n=e.state.associativeArrays??new Set;for(let r of e.state.env.keys()){let s=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(s){let i=s[1];n.has(i)||t.add(i)}}return t}function Kb(e){return e.state.associativeArrays??new Set}function Bc(e,t){if(t.includes("--help"))return ge(wo);if(t.length===0){let r=Qb(e),s=Kb(e),i=l=>{for(let c of s){let u=`${c}_`,f=`${c}__length`;if(l!==f&&l.startsWith(u)){if(l.slice(u.length).startsWith("_length"))continue;return!0}}return!1},o=[];for(let[l,c]of e.state.env){if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(l)||r.has(l)||s.has(l))continue;let u=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_(\d+)$/);if(u&&r.has(u[1]))continue;let f=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);f&&r.has(f[1])||i(l)||f&&s.has(f[1])||o.push([l,c])}let a=[];for(let[l,c]of o.sort(([u],[f])=>u<f?-1:u>f?1:0))a.push(`${l}=${mo(c)}`);for(let l of[...r].sort((c,u)=>c<u?-1:c>u?1:0))a.push(Vb(e,l));for(let l of[...s].sort((c,u)=>c<u?-1:c>u?1:0))a.push(Zb(e,l));return a.sort((l,c)=>{let u=l.split("=")[0],f=c.split("=")[0];return u<f?-1:u>f?1:0}),ge(a.length>0?`${a.join(`
1324
1324
  `)}
1325
1325
  `:"")}let n=0;for(;n<t.length;){let r=t[n];if((r==="-o"||r==="+o")&&Gb(t,n)){let s=t[n+1];if(!P6.has(s)){let i=`bash: set: ${s}: invalid option name
1326
1326
  ${wo}`;if(e.state.options.posix)throw new Ft(1,"",i);return W(i)}_6(e,P6.get(s)??null,r==="-o"),n+=2;continue}if(r==="-o"){let s=D6.map(a=>`${a.padEnd(16)}${e.state.options[a]?"on":"off"}`),i=L6.map(a=>`${a.padEnd(16)}off`),o=[...s,...i].sort();return ge(`${o.join(`
@@ -1328,17 +1328,17 @@ ${wo}`;if(e.state.options.posix)throw new Ft(1,"",i);return W(i)}_6(e,P6.get(s)?
1328
1328
  `)}if(r==="+o"){let s=D6.map(a=>`set ${e.state.options[a]?"-o":"+o"} ${a}`),i=L6.map(a=>`set +o ${a}`),o=[...s,...i].sort();return ge(`${o.join(`
1329
1329
  `)}
1330
1330
  `)}if(r.length>1&&(r[0]==="-"||r[0]==="+")&&r[1]!=="-"){let s=r[0]==="-";for(let i=1;i<r.length;i++){let o=r[i];if(!T6.has(o)){let a=`bash: set: ${r[0]}${o}: invalid option
1331
- ${wo}`;if(e.state.options.posix)throw new Ft(1,"",a);return W(a)}_6(e,T6.get(o)??null,s)}n++;continue}if(r==="--")return Wc(e,t.slice(n+1)),de;if(r==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,Or(e),n+1<t.length)return Wc(e,t.slice(n+1)),de;n++;continue}if(r==="+"){n++;continue}if(r.startsWith("-")||r.startsWith("+")){let s=`bash: set: ${r}: invalid option
1331
+ ${wo}`;if(e.state.options.posix)throw new Ft(1,"",a);return W(a)}_6(e,T6.get(o)??null,s)}n++;continue}if(r==="--")return Wc(e,t.slice(n+1)),de;if(r==="-"){if(e.state.options.xtrace=!1,e.state.options.verbose=!1,Rr(e),n+1<t.length)return Wc(e,t.slice(n+1)),de;n++;continue}if(r==="+"){n++;continue}if(r.startsWith("-")||r.startsWith("+")){let s=`bash: set: ${r}: invalid option
1332
1332
  ${wo}`;if(e.state.options.posix)throw new Ft(1,"",s);return W(s)}return Wc(e,t.slice(n)),de}return de}function Wc(e,t){let n=1;for(;e.state.env.has(String(n));)e.state.env.delete(String(n)),n++;for(let r=0;r<t.length;r++)e.state.env.set(String(r+1),t[r]);e.state.env.set("#",String(t.length)),e.state.env.set("@",t.join(" ")),e.state.env.set("*",t.join(" "))}xe();function Hc(e,t){let n=1;if(t.length>0){let o=Number.parseInt(t[0],10);if(Number.isNaN(o)||o<0){let a=`bash: shift: ${t[0]}: numeric argument required
1333
1333
  `;if(e.state.options.posix)throw new Ft(1,"",a);return W(a)}n=o}let r=Number.parseInt(e.state.env.get("#")||"0",10);if(n>r){let o=`bash: shift: shift count out of range
1334
1334
  `;if(e.state.options.posix)throw new Ft(1,"",o);return W(o)}if(n===0)return de;let s=[];for(let o=1;o<=r;o++)s.push(e.state.env.get(String(o))||"");let i=s.slice(n);for(let o=1;o<=r;o++)e.state.env.delete(String(o));for(let o=0;o<i.length;o++)e.state.env.set(String(o+1),i[o]);return e.state.env.set("#",String(i.length)),e.state.env.set("@",i.join(" ")),de}Qe();xe();async function zc(e,t){let n=t;if(n.length>0&&n[0]==="--"&&(n=n.slice(1)),n.length===0)return H("",`bash: source: filename argument required
1335
1335
  `,2);let r=n[0],s=null,i=null;if(r.includes("/")){let c=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(c),s=c}catch{}}else{let u=(e.state.env.get("PATH")||"").split(":").filter(f=>f);for(let f of u){let h=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(h)).isDirectory)continue;i=await e.fs.readFile(h),s=h;break}catch{}}if(i===null){let f=e.fs.resolvePath(e.state.cwd,r);try{i=await e.fs.readFile(f),s=f}catch{}}}if(i===null)return W(`bash: ${r}: No such file or directory
1336
1336
  `);let o=new Map;if(n.length>1){for(let u=1;u<=9;u++)o.set(String(u),e.state.env.get(String(u)));o.set("#",e.state.env.get("#")),o.set("@",e.state.env.get("@"));let c=n.slice(1);e.state.env.set("#",String(c.length)),e.state.env.set("@",c.join(" "));for(let u=0;u<c.length&&u<9;u++)e.state.env.set(String(u+1),c[u]);for(let u=c.length+1;u<=9;u++)e.state.env.delete(String(u))}let a=e.state.currentSource,l=()=>{if(e.state.sourceDepth--,e.state.currentSource=a,n.length>1)for(let[c,u]of o)u===void 0?e.state.env.delete(c):e.state.env.set(c,u)};e.state.sourceDepth++,e.state.currentSource=r;try{let c=hn(i),u=await e.executeScript(c);return l(),u}catch(c){if(l(),c instanceof pe)throw c;if(c instanceof it)return H(c.stdout,c.stderr,c.exitCode);if(c.name==="ParseException")return W(`bash: ${r}: ${c.message}
1337
- `);throw c}}pt();Qe();Et();Ot();At();en();_n();function M6(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Xb(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function F6(e,t){if(Xb(t))return null;try{let n=new ce,r=Ae(n,t);return await J(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}function U6(e,t){if(e.state.localVarStack?.has(t)){let r=fo(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let s=e.state.localVarStack?.get(t);if(!s||s.length===0)uo(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),jc(e,t);else{let i=s[s.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),uo(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let s=e.state.localScopes[r];if(s.has(t)){let i=s.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),s.delete(t);let o=!1;for(let a=r-1;a>=0;a--)if(e.state.localScopes[a].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,a+1),o=!0;break}return o||uo(e,t),!0}}return!1}function jc(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(t)){let s=r.get(t);return s===void 0?e.state.env.delete(t):e.state.env.set(t,s),r.delete(t),!0}}return!1}async function W6(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let n=t.slice(1,-1),s=new ce().parseWordFromString(n,!0,!1);return se(e,s)}if(t.includes("$")){let r=new ce().parseWordFromString(t,!1,!1);return se(e,r)}return t}async function Gc(e,t){let n="both",r="",s=0;for(let i of t){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){e.state.functions.delete(i);continue}if(n==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let h=c[1],p=c[2];if(p==="@"||p==="*"){let b=ae(e,h);for(let[x]of b)e.state.env.delete(`${h}_${x}`);e.state.env.delete(h);continue}let m=e.state.associativeArrays?.has(h);if(m){let b=await W6(e,p);e.state.env.delete(`${h}_${b}`);continue}let d=An(e,h),g=e.state.declaredVars?.has(h);if((e.state.env.has(h)||g)&&!d&&!m){r+=`bash: unset: ${h}: not an array variable
1337
+ `);throw c}}pt();Qe();Et();Rt();At();en();_n();function M6(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function Xb(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function F6(e,t){if(Xb(t))return null;try{let n=new ce,r=Ae(n,t);return await J(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}function U6(e,t){if(e.state.localVarStack?.has(t)){let r=fo(e,t);if(r){r.value===void 0?e.state.env.delete(t):e.state.env.set(t,r.value);let s=e.state.localVarStack?.get(t);if(!s||s.length===0)uo(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),jc(e,t);else{let i=s[s.length-1];e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,i.scopeIndex+1)}return!0}return e.state.env.delete(t),uo(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,0),!0}for(let r=e.state.localScopes.length-1;r>=0;r--){let s=e.state.localScopes[r];if(s.has(t)){let i=s.get(t);i===void 0?e.state.env.delete(t):e.state.env.set(t,i),s.delete(t);let o=!1;for(let a=r-1;a>=0;a--)if(e.state.localScopes[a].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,a+1),o=!0;break}return o||uo(e,t),!0}}return!1}function jc(e,t){if(!e.state.tempEnvBindings||e.state.tempEnvBindings.length===0)return!1;for(let n=e.state.tempEnvBindings.length-1;n>=0;n--){let r=e.state.tempEnvBindings[n];if(r.has(t)){let s=r.get(t);return s===void 0?e.state.env.delete(t):e.state.env.set(t,s),r.delete(t),!0}}return!1}async function W6(e,t){if(t.startsWith("'")&&t.endsWith("'"))return t.slice(1,-1);if(t.startsWith('"')&&t.endsWith('"')){let n=t.slice(1,-1),s=new ce().parseWordFromString(n,!0,!1);return se(e,s)}if(t.includes("$")){let r=new ce().parseWordFromString(t,!1,!1);return se(e,r)}return t}async function Gc(e,t){let n="both",r="",s=0;for(let i of t){if(i==="-v"){n="variable";continue}if(i==="-f"){n="function";continue}if(n==="function"){e.state.functions.delete(i);continue}if(n==="variable"){let c=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(c){let h=c[1],p=c[2];if(p==="@"||p==="*"){let b=ae(e,h);for(let[x]of b)e.state.env.delete(`${h}_${x}`);e.state.env.delete(h);continue}let m=e.state.associativeArrays?.has(h);if(m){let b=await W6(e,p);e.state.env.delete(`${h}_${b}`);continue}let d=An(e,h),g=e.state.declaredVars?.has(h);if((e.state.env.has(h)||g)&&!d&&!m){r+=`bash: unset: ${h}: not an array variable
1338
1338
  `,s=1;continue}let w=await F6(e,p);if(w===null&&d){r+=`bash: unset: ${p}: not a valid identifier
1339
1339
  `,s=1;continue}if(w===null)continue;if(w<0){let b=ae(e,h),x=b.length,S=e.state.currentLine;if(x===0){r+=`bash: line ${S}: unset: [${w}]: bad array subscript
1340
1340
  `,s=1;continue}let C=x+w;if(C<0){r+=`bash: line ${S}: unset: [${w}]: bad array subscript
1341
- `,s=1;continue}let $=b[C][0];e.state.env.delete(`${h}_${$}`);continue}e.state.env.delete(`${h}_${w}`);continue}if(!M6(i)){r+=`bash: unset: \`${i}': not a valid identifier
1341
+ `,s=1;continue}let R=b[C][0];e.state.env.delete(`${h}_${R}`);continue}e.state.env.delete(`${h}_${w}`);continue}if(!M6(i)){r+=`bash: unset: \`${i}': not a valid identifier
1342
1342
  `,s=1;continue}let u=i;if(Te(e,i)){let h=xt(e,i);h&&h!==i&&(u=h)}if(gn(e,u)){r+=`bash: unset: ${u}: cannot unset: readonly variable
1343
1343
  `,s=1;continue}let f=Ur(e,u);if(f!==void 0&&f!==e.state.callDepth)U6(e,u);else if(e.state.fullyUnsetLocals?.has(u))e.state.env.delete(u);else if(f!==void 0){let h=e.state.accessedTempEnvVars?.has(u),p=e.state.mutatedTempEnvVars?.has(u);if((h||p)&&e.state.localVarStack?.has(u)){let m=fo(e,u);m?m.value===void 0?e.state.env.delete(u):e.state.env.set(u,m.value):e.state.env.delete(u)}else e.state.env.delete(u)}else jc(e,u)||e.state.env.delete(u);e.state.exportedVars?.delete(u);continue}let o=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let c=o[1],u=o[2];if(u==="@"||u==="*"){let d=ae(e,c);for(let[g]of d)e.state.env.delete(`${c}_${g}`);e.state.env.delete(c);continue}let f=e.state.associativeArrays?.has(c);if(f){let d=await W6(e,u);e.state.env.delete(`${c}_${d}`);continue}let h=An(e,c);if(e.state.env.has(c)&&!h&&!f){r+=`bash: unset: ${c}: not an array variable
1344
1344
  `,s=1;continue}let m=await F6(e,u);if(m===null&&h){r+=`bash: unset: ${u}: not a valid identifier
@@ -1358,27 +1358,27 @@ ${wo}`;if(e.state.options.posix)throw new Ft(1,"",s);return W(s)}return Wc(e,t.s
1358
1358
  `:"",stderr:u}}function ex(e,t,n,r,s,i){let o=new Map([["errexit","errexit"],["pipefail","pipefail"],["nounset","nounset"],["xtrace","xtrace"],["verbose","verbose"],["posix","posix"],["allexport","allexport"],["noclobber","noclobber"],["noglob","noglob"],["noexec","noexec"],["vi","vi"],["emacs","emacs"]]),a=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"],l=[...o.keys(),...a].sort();if(t.length===0){let h=[];for(let p of l){let m=a.includes(p),d=o.get(p),g=m||!d?!1:e.state.options[d];n&&!g||r&&g||h.push(s?`set ${g?"-o":"+o"} ${p}`:`${p} ${g?"on":"off"}`)}return{exitCode:0,stdout:h.length>0?`${h.join(`
1359
1359
  `)}
1360
1360
  `:"",stderr:""}}let c=!1,u="",f=[];for(let h of t){let p=o.has(h),m=a.includes(h);if(!p&&!m){u+=`shopt: ${h}: invalid option name
1361
- `,c=!0;continue}if(m){n||r||(i?c=!0:s?(f.push(`set +o ${h}`),c=!0):(f.push(`${h} off`),c=!0));continue}let d=o.get(h);if(d)if(n)d==="vi"?e.state.options.emacs=!1:d==="emacs"&&(e.state.options.vi=!1),e.state.options[d]=!0,Or(e);else if(r)e.state.options[d]=!1,Or(e);else{let g=e.state.options[d];i?g||(c=!0):s?(f.push(`set ${g?"-o":"+o"} ${h}`),g||(c=!0)):(f.push(`${h} ${g?"on":"off"}`),g||(c=!0))}}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`
1361
+ `,c=!0;continue}if(m){n||r||(i?c=!0:s?(f.push(`set +o ${h}`),c=!0):(f.push(`${h} off`),c=!0));continue}let d=o.get(h);if(d)if(n)d==="vi"?e.state.options.emacs=!1:d==="emacs"&&(e.state.options.vi=!1),e.state.options[d]=!0,Rr(e);else if(r)e.state.options[d]=!1,Rr(e);else{let g=e.state.options[d];i?g||(c=!0):s?(f.push(`set ${g?"-o":"+o"} ${h}`),g||(c=!0)):(f.push(`${h} ${g?"on":"off"}`),g||(c=!0))}}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`
1362
1362
  `)}
1363
- `:"",stderr:u}}async function H6(e,t,n){if(t.includes("/")){let o=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(o))return{error:"not_found",path:o};let a=o.split("/").pop()||t,l=e.commands.get(a);try{let c=await e.fs.stat(o);return c.isDirectory?{error:"permission_denied",path:o}:l?{cmd:l,path:o}:(c.mode&73)!==0?{script:!0,path:o}:{error:"permission_denied",path:o}}catch{return{error:"not_found",path:o}}}if(!n&&e.state.hashTable){let o=e.state.hashTable.get(t);if(o)if(await e.fs.exists(o)){let a=e.commands.get(t);if(a)return{cmd:a,path:o};try{let l=await e.fs.stat(o);if(!l.isDirectory&&(l.mode&73)!==0)return{script:!0,path:o}}catch{}}else e.state.hashTable.delete(t)}let s=(n??e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let o of s){if(!o)continue;let l=`${o.startsWith("/")?o:e.fs.resolvePath(e.state.cwd,o)}/${t}`;if(await e.fs.exists(l))try{let c=await e.fs.stat(l);if(c.isDirectory)continue;let u=(c.mode&73)!==0,f=e.commands.get(t),h=o==="/bin"||o==="/usr/bin";if(f&&h)return{cmd:f,path:l};if(u){if(f&&!h)return{script:!0,path:l};if(!f)return{script:!0,path:l}}}catch{}}if(!await e.fs.exists("/usr/bin")){let o=e.commands.get(t);if(o)return{cmd:o,path:`/usr/bin/${t}`}}return null}async function xo(e,t){let n=[];if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let o=await e.fs.stat(i);o.isDirectory||(o.mode&73)!==0&&n.push(t)}catch{}return n}let s=(e.state.env.get("PATH")||"/usr/bin:/bin").split(":");for(let i of s){if(!i)continue;let a=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}n.push(i.startsWith("/")?a:`${i}/${t}`)}}return n}Mt();async function V6(e,t,n,r){let s=!1,i=!1,o=!1,a=!1,l=!1,c=[];for(let d of t)if(d.startsWith("-")&&d.length>1)for(let g of d.slice(1))g==="t"?s=!0:g==="p"?i=!0:g==="P"?o=!0:g==="a"?a=!0:g==="f"&&(l=!0);else c.push(d);let u="",f="",h=0,p=!1,m=!1;for(let d of c){let g=!1;if(o){if(a){let C=await r(d);if(C.length>0){for(let $ of C)u+=`${$}
1363
+ `:"",stderr:u}}async function H6(e,t,n){if(t.includes("/")){let o=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(o))return{error:"not_found",path:o};let a=o.split("/").pop()||t,l=e.commands.get(a);try{let c=await e.fs.stat(o);return c.isDirectory?{error:"permission_denied",path:o}:l?{cmd:l,path:o}:(c.mode&73)!==0?{script:!0,path:o}:{error:"permission_denied",path:o}}catch{return{error:"not_found",path:o}}}if(!n&&e.state.hashTable){let o=e.state.hashTable.get(t);if(o)if(await e.fs.exists(o)){let a=e.commands.get(t);if(a)return{cmd:a,path:o};try{let l=await e.fs.stat(o);if(!l.isDirectory&&(l.mode&73)!==0)return{script:!0,path:o}}catch{}}else e.state.hashTable.delete(t)}let s=(n??e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let o of s){if(!o)continue;let l=`${o.startsWith("/")?o:e.fs.resolvePath(e.state.cwd,o)}/${t}`;if(await e.fs.exists(l))try{let c=await e.fs.stat(l);if(c.isDirectory)continue;let u=(c.mode&73)!==0,f=e.commands.get(t),h=o==="/bin"||o==="/usr/bin";if(f&&h)return{cmd:f,path:l};if(u){if(f&&!h)return{script:!0,path:l};if(!f)return{script:!0,path:l}}}catch{}}if(!await e.fs.exists("/usr/bin")){let o=e.commands.get(t);if(o)return{cmd:o,path:`/usr/bin/${t}`}}return null}async function xo(e,t){let n=[];if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let o=await e.fs.stat(i);o.isDirectory||(o.mode&73)!==0&&n.push(t)}catch{}return n}let s=(e.state.env.get("PATH")||"/usr/bin:/bin").split(":");for(let i of s){if(!i)continue;let a=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).isDirectory)continue}catch{continue}n.push(i.startsWith("/")?a:`${i}/${t}`)}}return n}Mt();async function V6(e,t,n,r){let s=!1,i=!1,o=!1,a=!1,l=!1,c=[];for(let d of t)if(d.startsWith("-")&&d.length>1)for(let g of d.slice(1))g==="t"?s=!0:g==="p"?i=!0:g==="P"?o=!0:g==="a"?a=!0:g==="f"&&(l=!0);else c.push(d);let u="",f="",h=0,p=!1,m=!1;for(let d of c){let g=!1;if(o){if(a){let C=await r(d);if(C.length>0){for(let R of C)u+=`${R}
1364
1364
  `;p=!0,g=!0}}else{let C=await n(d);C&&(u+=`${C}
1365
1365
  `,p=!0,g=!0)}g||(m=!0);continue}let y=!l&&e.state.functions.has(d);if(a&&y){if(!i)if(s)u+=`function
1366
- `;else{let C=e.state.functions.get(d),$=C?z6(d,C):`${d} is a function
1367
- `;u+=$}g=!0}let w=e.state.env.get(`BASH_ALIAS_${d}`);if(w!==void 0&&(a||!g)&&(i||(s?u+=`alias
1366
+ `;else{let C=e.state.functions.get(d),R=C?z6(d,C):`${d} is a function
1367
+ `;u+=R}g=!0}let w=e.state.env.get(`BASH_ALIAS_${d}`);if(w!==void 0&&(a||!g)&&(i||(s?u+=`alias
1368
1368
  `:u+=`${d} is aliased to \`${w}'
1369
1369
  `),g=!0,!a)||uc.has(d)&&(a||!g)&&(i||(s?u+=`keyword
1370
1370
  `:u+=`${d} is a shell keyword
1371
1371
  `),g=!0,!a))continue;if(!a&&y&&!g){if(!i)if(s)u+=`function
1372
- `;else{let C=e.state.functions.get(d),$=C?z6(d,C):`${d} is a function
1373
- `;u+=$}g=!0;continue}if(!(Cs.has(d)&&(a||!g)&&(i||(s?u+=`builtin
1372
+ `;else{let C=e.state.functions.get(d),R=C?z6(d,C):`${d} is a function
1373
+ `;u+=R}g=!0;continue}if(!(Cs.has(d)&&(a||!g)&&(i||(s?u+=`builtin
1374
1374
  `:u+=`${d} is a shell builtin
1375
- `),g=!0,!a))){if(a){let C=await r(d);for(let $ of C)i?u+=`${$}
1375
+ `),g=!0,!a))){if(a){let C=await r(d);for(let R of C)i?u+=`${R}
1376
1376
  `:s?u+=`file
1377
- `:u+=`${d} is ${$}
1377
+ `:u+=`${d} is ${R}
1378
1378
  `,p=!0,g=!0}else if(!g){let C=await n(d);C&&(i?u+=`${C}
1379
1379
  `:s?u+=`file
1380
1380
  `:u+=`${d} is ${C}
1381
- `,p=!0,g=!0)}if(!g&&(m=!0,!s&&!i)){let C=!0;if(d.includes("/")){let $=e.fs.resolvePath(e.state.cwd,d);await e.fs.exists($)&&(C=!1)}C&&(f+=`bash: type: ${d}: not found
1381
+ `,p=!0,g=!0)}if(!g&&(m=!0,!s&&!i)){let C=!0;if(d.includes("/")){let R=e.fs.resolvePath(e.state.cwd,d);await e.fs.exists(R)&&(C=!1)}C&&(f+=`bash: type: ${d}: not found
1382
1382
  `)}}}return i?h=m&&!p?1:0:h=m?1:0,H(u,f,h)}function z6(e,t){let n;return t.body.type==="Group"?n=t.body.body.map(s=>vs(s)).join("; "):n=vs(t.body),`${e} is a function
1383
1383
  ${e} ()
1384
1384
  {
@@ -1398,7 +1398,7 @@ ${e} ()
1398
1398
  `),o=1)}else if(e.commands.has(a)){let u=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":"),f=null;for(let h of u){if(!h)continue;let p=`${h}/${a}`;try{let m=await e.fs.stat(p);if(!m.isDirectory&&(m.mode&73)!==0){f=p;break}}catch{}}f||(f=`/usr/bin/${a}`),r?s+=`${a} is ${f}
1399
1399
  `:s+=`${f}
1400
1400
  `}else r&&(i+=`${a}: not found
1401
- `),o=1}return H(s,i,o)}async function Z6(e,t){if(t.includes("/")){let s=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(s)){try{let i=await e.fs.stat(s);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let s of r){if(!s)continue;let o=`${s.startsWith("/")?s:e.fs.resolvePath(e.state.cwd,s)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${s}/${t}`}}if(e.commands.has(t)){for(let s of r)if(s==="/usr/bin"||s==="/bin")return`${s}/${t}`;return`/usr/bin/${t}`}return null}async function Q6(e,t,n,r,s,i,o,a){let{ctx:l,runCommand:c}=e;if(t==="export")return Tc(l,n);if(t==="unset")return Gc(l,n);if(t==="exit")return $c(l,n);if(t==="local")return _c(l,n);if(t==="set")return Bc(l,n);if(t==="break")return sc(l,n);if(t==="continue")return yc(l,n);if(t==="return")return Uc(l,n);if(t==="eval"&&l.state.options.posix)return go(l,n,s);if(t==="shift")return Hc(l,n);if(t==="getopts")return yo(l,n);if(t==="compgen")return pc(l,n);if(t==="complete")return mc(l,n);if(t==="compopt")return gc(l,n);if(t==="pushd")return await Ic(l,n);if(t==="popd")return Rc(l,n);if(t==="dirs")return Oc(l,n);if(t==="source"||t===".")return zc(l,n);if(t==="read")return Fc(l,n,s,a);if(t==="mapfile"||t==="readarray")return Mc(l,n,s);if(t==="declare"||t==="typeset")return Nc(l,n);if(t==="readonly")return kc(l,n);if(!i){let u=l.state.functions.get(t);if(u)return po(l,u,n,s)}if(t==="eval")return go(l,n,s);if(t==="cd")return await ic(l,n);if(t===":"||t==="true")return de;if(t==="false")return Xe(!1);if(t==="let")return Lc(l,n);if(t==="command")return nx(e,n,s);if(t==="builtin")return rx(e,n,s);if(t==="shopt")return B6(l,n);if(t==="exec"){if(n.length===0)return de;let[u,...f]=n;return c(u,f,[],s,!1,!1,-1)}if(t==="wait")return de;if(t==="type")return await V6(l,n,u=>Z6(l,u),u=>xo(l,u));if(t==="hash")return Pc(l,n);if(t==="help")return Dc(l,n);if(t==="["||t==="test"){let u=n;if(t==="["){if(n[n.length-1]!=="]")return W("[: missing `]'\n",2);u=n.slice(0,-1)}return Ss(l,u)}return null}async function nx(e,t,n){let{ctx:r,runCommand:s}=e;if(t.length===0)return de;let i=!1,o=!1,a=!1,l=t;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let h of f.slice(1))h==="p"?i=!0:h==="V"?o=!0:h==="v"&&(a=!0);l=l.slice(1)}if(l.length===0)return de;if(a||o)return await q6(r,l,a,o);let[c,...u]=l;return s(c,u,[],n,!0,i,-1)}async function rx(e,t,n){let{runCommand:r}=e;if(t.length===0)return de;let s=t;if(s[0]==="--"&&(s=s.slice(1),s.length===0))return de;let i=s[0];if(!Cs.has(i))return W(`bash: builtin: ${i}: not a shell builtin
1401
+ `),o=1}return H(s,i,o)}async function Z6(e,t){if(t.includes("/")){let s=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(s)){try{let i=await e.fs.stat(s);if(i.isDirectory||!((i.mode&73)!==0))return null}catch{return null}return t}return null}let r=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let s of r){if(!s)continue;let o=`${s.startsWith("/")?s:e.fs.resolvePath(e.state.cwd,s)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}return`${s}/${t}`}}if(e.commands.has(t)){for(let s of r)if(s==="/usr/bin"||s==="/bin")return`${s}/${t}`;return`/usr/bin/${t}`}return null}async function Q6(e,t,n,r,s,i,o,a){let{ctx:l,runCommand:c}=e;if(t==="export")return Tc(l,n);if(t==="unset")return Gc(l,n);if(t==="exit")return $c(l,n);if(t==="local")return _c(l,n);if(t==="set")return Bc(l,n);if(t==="break")return sc(l,n);if(t==="continue")return yc(l,n);if(t==="return")return Uc(l,n);if(t==="eval"&&l.state.options.posix)return go(l,n,s);if(t==="shift")return Hc(l,n);if(t==="getopts")return yo(l,n);if(t==="compgen")return pc(l,n);if(t==="complete")return mc(l,n);if(t==="compopt")return gc(l,n);if(t==="pushd")return await Ic(l,n);if(t==="popd")return Oc(l,n);if(t==="dirs")return Rc(l,n);if(t==="source"||t===".")return zc(l,n);if(t==="read")return Fc(l,n,s,a);if(t==="mapfile"||t==="readarray")return Mc(l,n,s);if(t==="declare"||t==="typeset")return Nc(l,n);if(t==="readonly")return kc(l,n);if(!i){let u=l.state.functions.get(t);if(u)return po(l,u,n,s)}if(t==="eval")return go(l,n,s);if(t==="cd")return await ic(l,n);if(t===":"||t==="true")return de;if(t==="false")return Xe(!1);if(t==="let")return Lc(l,n);if(t==="command")return nx(e,n,s);if(t==="builtin")return rx(e,n,s);if(t==="shopt")return B6(l,n);if(t==="exec"){if(n.length===0)return de;let[u,...f]=n;return c(u,f,[],s,!1,!1,-1)}if(t==="wait")return de;if(t==="type")return await V6(l,n,u=>Z6(l,u),u=>xo(l,u));if(t==="hash")return Pc(l,n);if(t==="help")return Dc(l,n);if(t==="["||t==="test"){let u=n;if(t==="["){if(n[n.length-1]!=="]")return W("[: missing `]'\n",2);u=n.slice(0,-1)}return Ss(l,u)}return null}async function nx(e,t,n){let{ctx:r,runCommand:s}=e;if(t.length===0)return de;let i=!1,o=!1,a=!1,l=t;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let h of f.slice(1))h==="p"?i=!0:h==="V"?o=!0:h==="v"&&(a=!0);l=l.slice(1)}if(l.length===0)return de;if(a||o)return await q6(r,l,a,o);let[c,...u]=l;return s(c,u,[],n,!0,i,-1)}async function rx(e,t,n){let{runCommand:r}=e;if(t.length===0)return de;let s=t;if(s[0]==="--"&&(s=s.slice(1),s.length===0))return de;let i=s[0];if(!Cs.has(i))return W(`bash: builtin: ${i}: not a shell builtin
1402
1402
  `);let[,...o]=s;return r(i,o,[],n,!0,!1,-1)}async function K6(e,t,n,r,s){let{ctx:i,buildExportedEnv:o,executeUserScript:a}=e,c=await H6(i,t,s?"/usr/bin:/bin":void 0);if(!c)return s6(t)?W(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
1403
1403
  `,127):W(`bash: ${t}: command not found
1404
1404
  `,127);if("error"in c)return c.error==="permission_denied"?W(`bash: ${t}: Permission denied
@@ -1434,8 +1434,8 @@ sys 0m0.000s
1434
1434
  `,1)}}if(s=Math.max(...i.map(([a])=>typeof a=="number"?a:0))+1+s,s<0){let a=e.state.currentLine;return{index:0,error:H("",`bash: line ${a}: ${t}[${n}]: bad array subscript
1435
1435
  `,1)}}}return{index:s}}async function px(e,t,n,r,s,i){let o="",a=n,l=null;if(Te(e,n)){let f=Lm(e,n,r);if(f===void 0)return{continueToNext:!1,xtraceOutput:"",error:H("",`bash: ${n}: circular name reference
1436
1436
  `,1)};if(f===null)return{continueToNext:!0,xtraceOutput:""};a=f;let h=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);h&&(l={arrayName:h[1],subscriptExpr:h[2]},a=h[1])}if(gn(e,a)){if(t.name)return o+=`bash: ${a}: readonly variable
1437
- `,{continueToNext:!0,xtraceOutput:o};let f=rt(e,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(Ns(e,a))try{let f=new ce;if(s){let p=`(${e.state.env.get(a)||"0"}) + (${r})`,m=Ae(f,p);c=String(await J(e,m.expression))}else{let h=Ae(f,r);c=String(await J(e,h.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(At(),tc)),h=f(e,a)?`${a}_0`:a;c=s?(e.state.env.get(h)||"")+r:r}c=Br(e,a,c),o+=await ag(e,a,c);let u=a;if(l)u=await dx(e,l);else{let{isArray:f}=await Promise.resolve().then(()=>(At(),tc));f(e,a)&&(u=`${a}_0`)}return t.name?(i.set(u,e.state.env.get(u)),e.state.env.set(u,c)):(e.state.env.set(u,c),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(a)),e.state.tempEnvBindings?.some(f=>f.has(a))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function dx(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return ug(e,n,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new ce,a=Ae(o,r);i=await J(e,a.expression,!1)}catch{let o=e.state.env.get(r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=ae(e,n);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${n}_${i}`}Qe();xe();At();Mt();async function fg(e,t,n,r){let s=await wn(e,t.redirections);if(s)return s;let i=new Map(e.state.env),o=e.state.cwd,a={...e.state.options},l=e.state.localScopes,c=e.state.localVarStack,u=e.state.localVarDepth,f=e.state.fullyUnsetLocals;if(e.state.localScopes=l.map(C=>new Map(C)),c){e.state.localVarStack=new Map;for(let[C,$]of c.entries())e.state.localVarStack.set(C,$.map(M=>({...M})))}u&&(e.state.localVarDepth=new Map(u)),f&&(e.state.fullyUnsetLocals=new Map(f));let h=e.state.loopDepth,p=e.state.parentHasLoopContext;e.state.parentHasLoopContext=h>0,e.state.loopDepth=0;let m=e.state.lastArg,d=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let g=e.state.groupStdin;n&&(e.state.groupStdin=n);let y="",w="",b=0,x=()=>{e.state.env=i,e.state.cwd=o,e.state.options=a,e.state.localScopes=l,e.state.localVarStack=c,e.state.localVarDepth=u,e.state.fullyUnsetLocals=f,e.state.loopDepth=h,e.state.parentHasLoopContext=p,e.state.groupStdin=g,e.state.bashPid=d,e.state.lastArg=m};try{for(let C of t.body){let $=await r(C);y+=$.stdout,w+=$.stderr,b=$.exitCode}}catch(C){if(x(),C instanceof re)throw C;if(C instanceof ln){y+=C.stdout,w+=C.stderr;let M=H(y,w,0);return Be(e,M,t.redirections)}if(C instanceof ut||C instanceof ft){y+=C.stdout,w+=C.stderr;let M=H(y,w,0);return Be(e,M,t.redirections)}if(C instanceof pe){y+=C.stdout,w+=C.stderr;let M=H(y,w,C.exitCode);return Be(e,M,t.redirections)}if(C instanceof it){y+=C.stdout,w+=C.stderr;let M=H(y,w,C.exitCode);return Be(e,M,t.redirections)}if(C instanceof Ct){let M=H(y+C.stdout,w+C.stderr,C.exitCode);return Be(e,M,t.redirections)}let $=H(y,`${w}${Fe(C)}
1438
- `,1);return Be(e,$,t.redirections)}x();let S=H(y,w,b);return Be(e,S,t.redirections)}async function hg(e,t,n,r){let s="",i="",o=0,a=await ho(e,t.redirections);if(a)return a;let l=n;for(let f of t.redirections)if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let h=f.target,p=await se(e,h.content);h.stripTabs&&(p=p.split(`
1437
+ `,{continueToNext:!0,xtraceOutput:o};let f=rt(e,a);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(Ns(e,a))try{let f=new ce;if(s){let p=`(${e.state.env.get(a)||"0"}) + (${r})`,m=Ae(f,p);c=String(await J(e,m.expression))}else{let h=Ae(f,r);c=String(await J(e,h.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(At(),tc)),h=f(e,a)?`${a}_0`:a;c=s?(e.state.env.get(h)||"")+r:r}c=Br(e,a,c),o+=await ag(e,a,c);let u=a;if(l)u=await dx(e,l);else{let{isArray:f}=await Promise.resolve().then(()=>(At(),tc));f(e,a)&&(u=`${a}_0`)}return t.name?(i.set(u,e.state.env.get(u)),e.state.env.set(u,c)):(e.state.env.set(u,c),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(a)),e.state.tempEnvBindings?.some(f=>f.has(a))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(a))),{continueToNext:!1,xtraceOutput:o}}async function dx(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return ug(e,n,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let o=new ce,a=Ae(o,r);i=await J(e,a.expression,!1)}catch{let o=e.state.env.get(r);i=o?Number.parseInt(o,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let o=ae(e,n);o.length>0&&(i=Math.max(...o.map(l=>l[0]))+1+i)}return`${n}_${i}`}Qe();xe();At();Mt();async function fg(e,t,n,r){let s=await wn(e,t.redirections);if(s)return s;let i=new Map(e.state.env),o=e.state.cwd,a={...e.state.options},l=new Map(e.state.functions),c=e.state.localScopes,u=e.state.localVarStack,f=e.state.localVarDepth,h=e.state.fullyUnsetLocals;if(e.state.localScopes=c.map(R=>new Map(R)),u){e.state.localVarStack=new Map;for(let[R,U]of u.entries())e.state.localVarStack.set(R,U.map(L=>({...L})))}f&&(e.state.localVarDepth=new Map(f)),h&&(e.state.fullyUnsetLocals=new Map(h));let p=e.state.loopDepth,m=e.state.parentHasLoopContext;e.state.parentHasLoopContext=p>0,e.state.loopDepth=0;let d=e.state.lastArg,g=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let y=e.state.groupStdin;n&&(e.state.groupStdin=n);let w="",b="",x=0,S=()=>{e.state.env=i,e.state.cwd=o,e.state.options=a,e.state.functions=l,e.state.localScopes=c,e.state.localVarStack=u,e.state.localVarDepth=f,e.state.fullyUnsetLocals=h,e.state.loopDepth=p,e.state.parentHasLoopContext=m,e.state.groupStdin=y,e.state.bashPid=g,e.state.lastArg=d};try{for(let R of t.body){let U=await r(R);w+=U.stdout,b+=U.stderr,x=U.exitCode}}catch(R){if(S(),R instanceof re)throw R;if(R instanceof ln){w+=R.stdout,b+=R.stderr;let L=H(w,b,0);return Be(e,L,t.redirections)}if(R instanceof ut||R instanceof ft){w+=R.stdout,b+=R.stderr;let L=H(w,b,0);return Be(e,L,t.redirections)}if(R instanceof pe){w+=R.stdout,b+=R.stderr;let L=H(w,b,R.exitCode);return Be(e,L,t.redirections)}if(R instanceof it){w+=R.stdout,b+=R.stderr;let L=H(w,b,R.exitCode);return Be(e,L,t.redirections)}if(R instanceof Ct){let L=H(w+R.stdout,b+R.stderr,R.exitCode);return Be(e,L,t.redirections)}let U=H(w,`${b}${Fe(R)}
1438
+ `,1);return Be(e,U,t.redirections)}S();let C=H(w,b,x);return Be(e,C,t.redirections)}async function hg(e,t,n,r){let s="",i="",o=0,a=await ho(e,t.redirections);if(a)return a;let l=n;for(let f of t.redirections)if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let h=f.target,p=await se(e,h.content);h.stripTabs&&(p=p.split(`
1439
1439
  `).map(d=>d.replace(/^\t+/,"")).join(`
1440
1440
  `));let m=f.fd??0;m!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(m,p)):l=p}else if(f.operator==="<<<"&&f.target.type==="Word")l=`${await se(e,f.target)}
1441
1441
  `;else if(f.operator==="<"&&f.target.type==="Word")try{let h=await se(e,f.target),p=e.fs.resolvePath(e.state.cwd,h);l=await e.fs.readFile(p)}catch{let h=await se(e,f.target);return H("",`bash: ${h}: No such file or directory
@@ -1443,14 +1443,14 @@ sys 0m0.000s
1443
1443
  `,1)}e.state.groupStdin=c;let u=H(s,i,o);return Be(e,u,t.redirections)}async function pg(e,t,n,r,s){let i;try{i=await e.fs.readFile(t)}catch{return W(`bash: ${t}: No such file or directory
1444
1444
  `,127)}if(i.startsWith("#!")){let g=i.indexOf(`
1445
1445
  `);g!==-1&&(i=i.slice(g+1))}let o=new Map(e.state.env),a=e.state.cwd,l={...e.state.options},c=e.state.loopDepth,u=e.state.parentHasLoopContext,f=e.state.lastArg,h=e.state.bashPid,p=e.state.groupStdin,m=e.state.currentSource;e.state.parentHasLoopContext=c>0,e.state.loopDepth=0,e.state.bashPid=e.state.nextVirtualPid++,r&&(e.state.groupStdin=r),e.state.currentSource=t,e.state.env.set("0",t),e.state.env.set("#",String(n.length)),e.state.env.set("@",n.join(" ")),e.state.env.set("*",n.join(" "));for(let g=0;g<n.length&&g<9;g++)e.state.env.set(String(g+1),n[g]);for(let g=n.length+1;g<=9;g++)e.state.env.delete(String(g));let d=()=>{e.state.env=o,e.state.cwd=a,e.state.options=l,e.state.loopDepth=c,e.state.parentHasLoopContext=u,e.state.lastArg=f,e.state.bashPid=h,e.state.groupStdin=p,e.state.currentSource=m};try{let y=new ce().parse(i),w=await s(y);return d(),w}catch(g){if(d(),g instanceof pe||g instanceof re)throw g;if(g.name==="ParseException")return W(`bash: ${t}: ${g.message}
1446
- `);throw g}}var Rs=class{ctx;constructor(t,n){this.ctx={state:n,fs:t.fs,commands:t.commands,limits:t.limits,execFn:t.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:t.fetch,sleep:t.sleep,trace:t.trace}}buildExportedEnv(){let t=this.ctx.state.exportedVars,n=this.ctx.state.tempExportedVars,r=new Set;if(t)for(let i of t)r.add(i);if(n)for(let i of n)r.add(i);if(r.size===0)return Object.create(null);let s=Object.create(null);for(let i of r){let o=this.ctx.state.env.get(i);o!==void 0&&(s[i]=o)}return s}async executeScript(t){let n="",r="",s=0;for(let i of t.statements)try{let o=await this.executeStatement(i);n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}catch(o){if(o instanceof pe)throw o.prependOutput(n,r),o;if(o instanceof Ft)return n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof re)throw o;if(o instanceof Ct)return n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof gt)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof yt)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof $e){n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(o instanceof pr){n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(o instanceof ut||o instanceof ft){if(this.ctx.state.loopDepth>0)throw o.prependOutput(n,r),o;n+=o.stdout,r+=o.stderr;continue}throw o instanceof it&&o.prependOutput(n,r),o}return{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)}}async executeUserScript(t,n,r=""){return pg(this.ctx,t,n,r,s=>this.executeScript(s))}async executeStatement(t){if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Cn(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),t.deferredError)throw new lt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return de;this.ctx.state.errexitSafe=!1;let n="",r="";this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&(r+=`${t.sourceText}
1446
+ `);throw g}}var Os=class{ctx;constructor(t,n){this.ctx={state:n,fs:t.fs,commands:t.commands,limits:t.limits,execFn:t.exec,executeScript:this.executeScript.bind(this),executeStatement:this.executeStatement.bind(this),executeCommand:this.executeCommand.bind(this),fetch:t.fetch,sleep:t.sleep,trace:t.trace}}buildExportedEnv(){let t=this.ctx.state.exportedVars,n=this.ctx.state.tempExportedVars,r=new Set;if(t)for(let i of t)r.add(i);if(n)for(let i of n)r.add(i);if(r.size===0)return Object.create(null);let s=Object.create(null);for(let i of r){let o=this.ctx.state.env.get(i);o!==void 0&&(s[i]=o)}return s}async executeScript(t){let n="",r="",s=0;for(let i of t.statements)try{let o=await this.executeStatement(i);n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}catch(o){if(o instanceof pe)throw o.prependOutput(n,r),o;if(o instanceof Ft)return n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof re)throw o;if(o instanceof Ct)return n+=o.stdout,r+=o.stderr,s=o.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof gt)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof yt)return n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)};if(o instanceof $e){n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(o instanceof pr){n+=o.stdout,r+=o.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(o instanceof ut||o instanceof ft){if(this.ctx.state.loopDepth>0)throw o.prependOutput(n,r),o;n+=o.stdout,r+=o.stderr;continue}throw o instanceof it&&o.prependOutput(n,r),o}return{stdout:n,stderr:r,exitCode:s,env:wt(this.ctx.state.env)}}async executeUserScript(t,n,r=""){return pg(this.ctx,t,n,r,s=>this.executeScript(s))}async executeStatement(t){if(this.ctx.state.commandCount++,this.ctx.state.commandCount>this.ctx.limits.maxCommandCount&&Cn(`too many commands executed (>${this.ctx.limits.maxCommandCount}), increase executionLimits.maxCommandCount`,"commands"),t.deferredError)throw new lt(t.deferredError.message,t.line??1,1);if(this.ctx.state.options.noexec)return de;this.ctx.state.errexitSafe=!1;let n="",r="";this.ctx.state.options.verbose&&!this.ctx.state.suppressVerbose&&t.sourceText&&(r+=`${t.sourceText}
1447
1447
  `);let s=0,i=-1,o=!1;for(let c=0;c<t.pipelines.length;c++){let u=t.pipelines[c],f=c>0?t.operators[c-1]:null;if(f==="&&"&&s!==0||f==="||"&&s===0)continue;let h=await this.executePipeline(u);n+=h.stdout,r+=h.stderr,s=h.exitCode,i=c,o=u.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}let a=i<t.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=a||o||l,this.ctx.state.options.errexit&&s!==0&&i===t.pipelines.length-1&&!o&&!this.ctx.state.inCondition&&!l)throw new Ct(s,n,r);return H(n,r,s)}async executePipeline(t){return lg(this.ctx,t,(n,r)=>this.executeCommand(n,r))}async executeCommand(t,n){switch(t.type){case"SimpleCommand":return this.executeSimpleCommand(t,n);case"If":return X6(this.ctx,t);case"For":return Y6(this.ctx,t);case"CStyleFor":return J6(this.ctx,t);case"While":return eg(this.ctx,t,n);case"Until":return tg(this.ctx,t);case"Case":return ng(this.ctx,t);case"Subshell":return this.executeSubshell(t,n);case"Group":return this.executeGroup(t,n);case"FunctionDef":return b6(this.ctx,t);case"ArithmeticCommand":return this.executeArithmeticCommand(t);case"ConditionalCommand":return this.executeConditionalCommand(t);default:return de}}async executeSimpleCommand(t,n){try{return await this.executeSimpleCommandInner(t,n)}catch(r){if(r instanceof an)return W(r.stderr);throw r}}async executeSimpleCommandInner(t,n){if(t.line!==void 0&&(this.ctx.state.currentLine=t.line),this.ctx.state.shoptOptions.expand_aliases&&t.name){let x=t,S=100;for(;S>0;){let C=this.expandAlias(x);if(C===x)break;x=C,S--}this.aliasExpansionStack.clear(),x!==t&&(t=x)}this.ctx.state.expansionStderr="";let r=await cg(this.ctx,t);if(r.error)return r.error;let s=r.tempAssignments,i=r.xtraceOutput;if(!t.name){if(t.redirections.length>0){let S=await wn(this.ctx,t.redirections);if(S)return S;let C=H("",i,0);return Be(this.ctx,C,t.redirections)}this.ctx.state.lastArg="";let x=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",H("",x,this.ctx.state.lastExitCode)}let o=t.name&&Zc(t.name,["local","declare","typeset","export","readonly"]),a=Array.from(s.keys());if(a.length>0&&!o){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let x of a)this.ctx.state.tempExportedVars.add(x)}let l=await ho(this.ctx,t.redirections);if(l){for(let[x,S]of s)S===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,S);return l}let c=-1;for(let x of t.redirections){if((x.operator==="<<"||x.operator==="<<-")&&x.target.type==="HereDoc"){let S=x.target,C=await se(this.ctx,S.content);S.stripTabs&&(C=C.split(`
1448
- `).map(M=>M.replace(/^\t+/,"")).join(`
1449
- `));let $=x.fd??0;$!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set($,C)):n=C;continue}if(x.operator==="<<<"&&x.target.type==="Word"){n=`${await se(this.ctx,x.target)}
1450
- `;continue}if(x.operator==="<"&&x.target.type==="Word")try{let S=await se(this.ctx,x.target),C=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);n=await this.ctx.fs.readFile(C)}catch{let S=await se(this.ctx,x.target);for(let[C,$]of s)$===void 0?this.ctx.state.env.delete(C):this.ctx.state.env.set(C,$);return W(`bash: ${S}: No such file or directory
1451
- `)}if(x.operator==="<&"&&x.target.type==="Word"){let S=await se(this.ctx,x.target),C=Number.parseInt(S,10);if(!Number.isNaN(C)&&this.ctx.state.fileDescriptors){let $=this.ctx.state.fileDescriptors.get(C);if($!==void 0)if($.startsWith("__rw__:")){let M=rg($);M&&(n=M.content.slice(M.position),c=C)}else $.startsWith("__file__:")||$.startsWith("__file_append__:")||(n=$)}}}let u=await se(this.ctx,t.name),f=[],h=[];if(Zc(t.name,["local","declare","typeset","export","readonly"])&&(u==="local"||u==="declare"||u==="typeset"||u==="export"||u==="readonly"))for(let x of t.args){let S=await n6(this.ctx,x);if(S)f.push(S),h.push(!0);else{let C=await r6(this.ctx,x);if(C!==null)f.push(C),h.push(!0);else{let $=await rn(this.ctx,x);for(let M of $.values)f.push(M),h.push($.quoted)}}}else for(let x of t.args){let S=await rn(this.ctx,x);for(let C of S.values)f.push(C),h.push(S.quoted)}if(!u){if(t.name.parts.every(S=>S.type==="CommandSubstitution"||S.type==="ParameterExpansion"||S.type==="ArithmeticExpansion")){if(f.length>0){let S=f.shift();return h.shift(),await this.runCommand(S,f,h,n,!1,!1,c)}return H("","",this.ctx.state.lastExitCode)}return W(`bash: : command not found
1452
- `,127)}if(u==="exec"&&(f.length===0||f[0]==="--")){for(let x of t.redirections){if(x.target.type==="HereDoc"||x.fdVariable)continue;let S=await se(this.ctx,x.target),C=x.fd??(x.operator==="<"||x.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),x.operator){case">":case">|":{let $=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);await this.ctx.fs.writeFile($,"","utf8"),this.ctx.state.fileDescriptors.set(C,`__file__:${$}`);break}case">>":{let $=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);this.ctx.state.fileDescriptors.set(C,`__file_append__:${$}`);break}case"<":{let $=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);try{let M=await this.ctx.fs.readFile($);this.ctx.state.fileDescriptors.set(C,M)}catch{return W(`bash: ${S}: No such file or directory
1453
- `)}break}case"<>":{let $=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);try{let M=await this.ctx.fs.readFile($);this.ctx.state.fileDescriptors.set(C,`__rw__:${$.length}:${$}:0:${M}`)}catch{await this.ctx.fs.writeFile($,"","utf8"),this.ctx.state.fileDescriptors.set(C,`__rw__:${$.length}:${$}:0:`)}break}case">&":{if(S==="-")this.ctx.state.fileDescriptors.delete(C);else if(S.endsWith("-")){let $=S.slice(0,-1),M=Number.parseInt($,10);if(!Number.isNaN(M)){let _=this.ctx.state.fileDescriptors.get(M);_!==void 0?this.ctx.state.fileDescriptors.set(C,_):this.ctx.state.fileDescriptors.set(C,`__dupout__:${M}`),this.ctx.state.fileDescriptors.delete(M)}}else{let $=Number.parseInt(S,10);Number.isNaN($)||this.ctx.state.fileDescriptors.set(C,`__dupout__:${$}`)}break}case"<&":{if(S==="-")this.ctx.state.fileDescriptors.delete(C);else if(S.endsWith("-")){let $=S.slice(0,-1),M=Number.parseInt($,10);if(!Number.isNaN(M)){let _=this.ctx.state.fileDescriptors.get(M);_!==void 0?this.ctx.state.fileDescriptors.set(C,_):this.ctx.state.fileDescriptors.set(C,`__dupin__:${M}`),this.ctx.state.fileDescriptors.delete(M)}}else{let $=Number.parseInt(S,10);Number.isNaN($)||this.ctx.state.fileDescriptors.set(C,`__dupin__:${$}`)}break}}}for(let[x,S]of s)S===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,S);if(this.ctx.state.tempExportedVars)for(let x of s.keys())this.ctx.state.tempExportedVars.delete(x);return de}let m=await og(this.ctx,u,f);s.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(s)));let d,g=null;try{d=await this.runCommand(u,f,h,n,!1,!1,c)}catch(x){if(x instanceof ut||x instanceof ft)g=x,d=de;else throw x}let y=i+m;if(y&&(d={...d,stderr:y+d.stderr}),d=await Be(this.ctx,d,t.redirections),g)throw g;if(f.length>0){let x=f[f.length-1];if((u==="declare"||u==="local"||u==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(x)){let S=x.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);S&&(x=S[1])}this.ctx.state.lastArg=x}else this.ctx.state.lastArg=u;let w=y6(u)&&u!=="unset"&&u!=="eval";if(!this.ctx.state.options.posix||!w)for(let[x,S]of s)this.ctx.state.fullyUnsetLocals?.has(x)||(S===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,S));if(this.ctx.state.tempExportedVars)for(let x of s.keys())this.ctx.state.tempExportedVars.delete(x);return s.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(d={...d,stderr:this.ctx.state.expansionStderr+d.stderr},this.ctx.state.expansionStderr=""),d}async runCommand(t,n,r,s,i=!1,o=!1,a=-1){let l={ctx:this.ctx,runCommand:(u,f,h,p,m,d,g)=>this.runCommand(u,f,h,p,m,d,g),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(u,f,h)=>this.executeUserScript(u,f,h)},c=await Q6(l,t,n,r,s,i,o,a);return c!==null?c:K6(l,t,n,s,o)}aliasExpansionStack=new Set;expandAlias(t){return Ll(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return xo(this.ctx,t)}async executeSubshell(t,n=""){return fg(this.ctx,t,n,r=>this.executeStatement(r))}async executeGroup(t,n=""){return hg(this.ctx,t,n,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await wn(this.ctx,t.redirections);if(n)return n;try{let r=await J(this.ctx,t.expression.expression),s=Xe(r!==0);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),Be(this.ctx,s,t.redirections)}catch(r){let s=W(`bash: arithmetic expression: ${r.message}
1448
+ `).map(U=>U.replace(/^\t+/,"")).join(`
1449
+ `));let R=x.fd??0;R!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set(R,C)):n=C;continue}if(x.operator==="<<<"&&x.target.type==="Word"){n=`${await se(this.ctx,x.target)}
1450
+ `;continue}if(x.operator==="<"&&x.target.type==="Word")try{let S=await se(this.ctx,x.target),C=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);n=await this.ctx.fs.readFile(C)}catch{let S=await se(this.ctx,x.target);for(let[C,R]of s)R===void 0?this.ctx.state.env.delete(C):this.ctx.state.env.set(C,R);return W(`bash: ${S}: No such file or directory
1451
+ `)}if(x.operator==="<&"&&x.target.type==="Word"){let S=await se(this.ctx,x.target),C=Number.parseInt(S,10);if(!Number.isNaN(C)&&this.ctx.state.fileDescriptors){let R=this.ctx.state.fileDescriptors.get(C);if(R!==void 0)if(R.startsWith("__rw__:")){let U=rg(R);U&&(n=U.content.slice(U.position),c=C)}else R.startsWith("__file__:")||R.startsWith("__file_append__:")||(n=R)}}}let u=await se(this.ctx,t.name),f=[],h=[];if(Zc(t.name,["local","declare","typeset","export","readonly"])&&(u==="local"||u==="declare"||u==="typeset"||u==="export"||u==="readonly"))for(let x of t.args){let S=await n6(this.ctx,x);if(S)f.push(S),h.push(!0);else{let C=await r6(this.ctx,x);if(C!==null)f.push(C),h.push(!0);else{let R=await rn(this.ctx,x);for(let U of R.values)f.push(U),h.push(R.quoted)}}}else for(let x of t.args){let S=await rn(this.ctx,x);for(let C of S.values)f.push(C),h.push(S.quoted)}if(!u){if(t.name.parts.every(S=>S.type==="CommandSubstitution"||S.type==="ParameterExpansion"||S.type==="ArithmeticExpansion")){if(f.length>0){let S=f.shift();return h.shift(),await this.runCommand(S,f,h,n,!1,!1,c)}return H("","",this.ctx.state.lastExitCode)}return W(`bash: : command not found
1452
+ `,127)}if(u==="exec"&&(f.length===0||f[0]==="--")){for(let x of t.redirections){if(x.target.type==="HereDoc"||x.fdVariable)continue;let S=await se(this.ctx,x.target),C=x.fd??(x.operator==="<"||x.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),x.operator){case">":case">|":{let R=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);await this.ctx.fs.writeFile(R,"","utf8"),this.ctx.state.fileDescriptors.set(C,`__file__:${R}`);break}case">>":{let R=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);this.ctx.state.fileDescriptors.set(C,`__file_append__:${R}`);break}case"<":{let R=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);try{let U=await this.ctx.fs.readFile(R);this.ctx.state.fileDescriptors.set(C,U)}catch{return W(`bash: ${S}: No such file or directory
1453
+ `)}break}case"<>":{let R=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);try{let U=await this.ctx.fs.readFile(R);this.ctx.state.fileDescriptors.set(C,`__rw__:${R.length}:${R}:0:${U}`)}catch{await this.ctx.fs.writeFile(R,"","utf8"),this.ctx.state.fileDescriptors.set(C,`__rw__:${R.length}:${R}:0:`)}break}case">&":{if(S==="-")this.ctx.state.fileDescriptors.delete(C);else if(S.endsWith("-")){let R=S.slice(0,-1),U=Number.parseInt(R,10);if(!Number.isNaN(U)){let L=this.ctx.state.fileDescriptors.get(U);L!==void 0?this.ctx.state.fileDescriptors.set(C,L):this.ctx.state.fileDescriptors.set(C,`__dupout__:${U}`),this.ctx.state.fileDescriptors.delete(U)}}else{let R=Number.parseInt(S,10);Number.isNaN(R)||this.ctx.state.fileDescriptors.set(C,`__dupout__:${R}`)}break}case"<&":{if(S==="-")this.ctx.state.fileDescriptors.delete(C);else if(S.endsWith("-")){let R=S.slice(0,-1),U=Number.parseInt(R,10);if(!Number.isNaN(U)){let L=this.ctx.state.fileDescriptors.get(U);L!==void 0?this.ctx.state.fileDescriptors.set(C,L):this.ctx.state.fileDescriptors.set(C,`__dupin__:${U}`),this.ctx.state.fileDescriptors.delete(U)}}else{let R=Number.parseInt(S,10);Number.isNaN(R)||this.ctx.state.fileDescriptors.set(C,`__dupin__:${R}`)}break}}}for(let[x,S]of s)S===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,S);if(this.ctx.state.tempExportedVars)for(let x of s.keys())this.ctx.state.tempExportedVars.delete(x);return de}let m=await og(this.ctx,u,f);s.size>0&&(this.ctx.state.tempEnvBindings=this.ctx.state.tempEnvBindings||[],this.ctx.state.tempEnvBindings.push(new Map(s)));let d,g=null;try{d=await this.runCommand(u,f,h,n,!1,!1,c)}catch(x){if(x instanceof ut||x instanceof ft)g=x,d=de;else throw x}let y=i+m;if(y&&(d={...d,stderr:y+d.stderr}),d=await Be(this.ctx,d,t.redirections),g)throw g;if(f.length>0){let x=f[f.length-1];if((u==="declare"||u==="local"||u==="typeset")&&/^[a-zA-Z_][a-zA-Z0-9_]*=\(/.test(x)){let S=x.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\(/);S&&(x=S[1])}this.ctx.state.lastArg=x}else this.ctx.state.lastArg=u;let w=y6(u)&&u!=="unset"&&u!=="eval";if(!this.ctx.state.options.posix||!w)for(let[x,S]of s)this.ctx.state.fullyUnsetLocals?.has(x)||(S===void 0?this.ctx.state.env.delete(x):this.ctx.state.env.set(x,S));if(this.ctx.state.tempExportedVars)for(let x of s.keys())this.ctx.state.tempExportedVars.delete(x);return s.size>0&&this.ctx.state.tempEnvBindings&&this.ctx.state.tempEnvBindings.pop(),this.ctx.state.expansionStderr&&(d={...d,stderr:this.ctx.state.expansionStderr+d.stderr},this.ctx.state.expansionStderr=""),d}async runCommand(t,n,r,s,i=!1,o=!1,a=-1){let l={ctx:this.ctx,runCommand:(u,f,h,p,m,d,g)=>this.runCommand(u,f,h,p,m,d,g),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(u,f,h)=>this.executeUserScript(u,f,h)},c=await Q6(l,t,n,r,s,i,o,a);return c!==null?c:K6(l,t,n,s,o)}aliasExpansionStack=new Set;expandAlias(t){return Ll(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return xo(this.ctx,t)}async executeSubshell(t,n=""){return fg(this.ctx,t,n,r=>this.executeStatement(r))}async executeGroup(t,n=""){return hg(this.ctx,t,n,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await wn(this.ctx,t.redirections);if(n)return n;try{let r=await J(this.ctx,t.expression.expression),s=Xe(r!==0);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),Be(this.ctx,s,t.redirections)}catch(r){let s=W(`bash: arithmetic expression: ${r.message}
1454
1454
  `);return Be(this.ctx,s,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await wn(this.ctx,t.redirections);if(n)return n;try{let r=await Fn(this.ctx,t.expression),s=Xe(r);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),Be(this.ctx,s,t.redirections)}catch(r){let s=r instanceof $e?1:2,i=W(`bash: conditional expression: ${r.message}
1455
1455
  `,s);return Be(this.ctx,i,t.redirections)}}};var Pt={maxCallDepth:100,maxCommandCount:1e4,maxLoopIterations:1e4,maxAwkIterations:1e4,maxSedIterations:1e4,maxJqIterations:1e4,maxSqliteTimeoutMs:5e3,maxPythonTimeoutMs:3e4,maxGlobOperations:1e5,maxStringLength:10485760,maxArrayElements:1e5,maxHeredocSize:10485760,maxSubstitutionDepth:50};function dg(e){return e?{maxCallDepth:e.maxCallDepth??Pt.maxCallDepth,maxCommandCount:e.maxCommandCount??Pt.maxCommandCount,maxLoopIterations:e.maxLoopIterations??Pt.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??Pt.maxAwkIterations,maxSedIterations:e.maxSedIterations??Pt.maxSedIterations,maxJqIterations:e.maxJqIterations??Pt.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??Pt.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??Pt.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??Pt.maxGlobOperations,maxStringLength:e.maxStringLength??Pt.maxStringLength,maxArrayElements:e.maxArrayElements??Pt.maxArrayElements,maxHeredocSize:e.maxHeredocSize??Pt.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??Pt.maxSubstitutionDepth}:{...Pt}}function mg(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function mx(e){let t=mg(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function gx(e,t){let n=mg(e);if(!n)return!1;let r=mx(t);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function Qc(e,t){return!t||t.length===0?!1:t.some(n=>gx(e,n))}var Hr=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},zr=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},jr=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Ao=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}};var yx=20,wx=3e4,bx=["GET","HEAD"],xx=new Set(["GET","HEAD","OPTIONS"]),Ex=new Set([301,302,303,307,308]);function Kc(e){let t=e.maxRedirects??yx,n=e.timeoutMs??wx,r=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??bx;function s(a){if(!e.dangerouslyAllowFullInternetAccess&&!Qc(a,e.allowedUrlPrefixes??[]))throw new Hr(a)}function i(a){if(e.dangerouslyAllowFullInternetAccess)return;let l=a.toUpperCase();if(!r.includes(l))throw new Ao(l,r)}async function o(a,l={}){let c=l.method?.toUpperCase()??"GET";s(a),i(c);let u=a,f=0,h=l.followRedirects??!0,p=l.timeoutMs!==void 0?Math.min(l.timeoutMs,n):n;for(;;){let m=new AbortController,d=setTimeout(()=>m.abort(),p);try{let g={method:c,headers:l.headers,signal:m.signal,redirect:"manual"};l.body&&!xx.has(c)&&(g.body=l.body);let y=await fetch(u,g);if(Ex.has(y.status)&&h){let w=y.headers.get("location");if(!w)return await gg(y,u);let b=new URL(w,u).href;if(!e.dangerouslyAllowFullInternetAccess&&!Qc(b,e.allowedUrlPrefixes??[]))throw new jr(b);if(f++,f>t)throw new zr(t);u=b;continue}return await gg(y,u)}finally{clearTimeout(d)}}}return o}async function gg(e,t){let n=Object.create(null);return e.headers.forEach((r,s)=>{n[s.toLowerCase()]=r}),{status:e.status,statusText:e.statusText,headers:n,body:await e.text(),url:t}}Tn();Qe();function yg(){let e=[{prop:"Function",target:globalThis,violationType:"function_constructor",strategy:"throw",reason:"Function constructor allows arbitrary code execution"},{prop:"eval",target:globalThis,violationType:"eval",strategy:"throw",reason:"eval() allows arbitrary code execution"},{prop:"setTimeout",target:globalThis,violationType:"setTimeout",strategy:"throw",reason:"setTimeout with string argument allows code execution"},{prop:"setInterval",target:globalThis,violationType:"setInterval",strategy:"throw",reason:"setInterval with string argument allows code execution"},{prop:"setImmediate",target:globalThis,violationType:"setImmediate",strategy:"throw",reason:"setImmediate could be used to escape sandbox context"},{prop:"env",target:process,violationType:"process_env",strategy:"throw",reason:"process.env could leak sensitive environment variables"},{prop:"binding",target:process,violationType:"process_binding",strategy:"throw",reason:"process.binding provides access to native Node.js modules"},{prop:"_linkedBinding",target:process,violationType:"process_binding",strategy:"throw",reason:"process._linkedBinding provides access to native Node.js modules"},{prop:"dlopen",target:process,violationType:"process_dlopen",strategy:"throw",reason:"process.dlopen allows loading native addons"},{prop:"WeakRef",target:globalThis,violationType:"weak_ref",strategy:"throw",reason:"WeakRef could be used to leak references outside sandbox"},{prop:"FinalizationRegistry",target:globalThis,violationType:"finalization_registry",strategy:"throw",reason:"FinalizationRegistry could be used to leak references outside sandbox"},{prop:"Reflect",target:globalThis,violationType:"reflect",strategy:"freeze",reason:"Reflect provides introspection capabilities"},{prop:"Proxy",target:globalThis,violationType:"proxy",strategy:"throw",reason:"Proxy allows intercepting and modifying object behavior"},{prop:"WebAssembly",target:globalThis,violationType:"webassembly",strategy:"throw",reason:"WebAssembly allows executing arbitrary compiled code"}];try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(async()=>{}),violationType:"async_function_constructor",strategy:"throw",reason:"AsyncFunction constructor allows arbitrary async code execution"})}catch{}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&e.push({prop:"constructor",target:Object.getPrototypeOf(function*(){}),violationType:"generator_function_constructor",strategy:"throw",reason:"GeneratorFunction constructor allows arbitrary generator code execution"})}catch{}try{let t=Object.getPrototypeOf(async function*(){}).constructor;t&&t!==Function&&t!==Object.getPrototypeOf(async()=>{}).constructor&&e.push({prop:"constructor",target:Object.getPrototypeOf(async function*(){}),violationType:"async_generator_function_constructor",strategy:"throw",reason:"AsyncGeneratorFunction constructor allows arbitrary async generator code execution"})}catch{}return e.filter(t=>{try{return t.target[t.prop]!==void 0}catch{return!1}})}var So=!0;function wg(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var Yc=null;if(!So)try{let{createRequire:e}=await import("node:module");Yc=e(import.meta.url)("node:async_hooks").AsyncLocalStorage}catch(e){console.debug("[DefenseInDepthBox] AsyncLocalStorage not available, defense-in-depth disabled:",e instanceof Error?e.message:e)}var Ax=`
1456
1456
 
@@ -1458,13 +1458,13 @@ This is a defense-in-depth measure and indicates a bug in just-bash. Please repo
1458
1458
  `],["OSTYPE","linux-gnu"],["MACHTYPE","x86_64-pc-linux-gnu"],["HOSTTYPE","x86_64"],["HOSTNAME","localhost"],["PWD",r],["OLDPWD",r],["OPTIND","1"],...Object.entries(t.env??{})]);if(this.limits=dg({...t.executionLimits,...t.maxCallDepth!==void 0&&{maxCallDepth:t.maxCallDepth},...t.maxCommandCount!==void 0&&{maxCommandCount:t.maxCommandCount},...t.maxLoopIterations!==void 0&&{maxLoopIterations:t.maxLoopIterations}}),t.network&&(this.secureFetch=Kc(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.state={env:s,cwd:r,previousDir:"/home/user",functions:new Map,localScopes:[],callDepth:0,sourceDepth:0,commandCount:0,lastExitCode:0,lastArg:"",startTime:Date.now(),lastBackgroundPid:0,bashPid:process.pid,nextVirtualPid:process.pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",hl(this.state.options)),this.state.env.set("BASHOPTS",pl(this.state.shoptOptions)),$0(n,this.useDefaultLayout),r!=="/"&&n instanceof Xn)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let i of A0(t.commands))this.registerCommand(i);if(t.network)for(let i of S0())this.registerCommand(i);if(t.python)for(let i of C0())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)N0(i)?this.registerCommand(k0(i)):this.registerCommand(i)}registerCommand(t){this.commands.set(t.name,t);let n=this.fs;if(typeof n.writeFileSync=="function"){let r=`#!/bin/bash
1459
1459
  # Built-in command: ${t.name}
1460
1460
  `;try{n.writeFileSync(`/bin/${t.name}`,r)}catch{}try{n.writeFileSync(`/usr/bin/${t.name}`,r)}catch{}}}logResult(t){return this.logger&&(t.stdout&&this.logger.debug("stdout",{output:t.stdout}),t.stderr&&this.logger.info("stderr",{output:t.stderr}),this.logger.info("exit",{exitCode:t.exitCode})),t}async exec(t,n){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.
1461
- `,exitCode:1,env:Yt(this.state.env,n?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:Yt(this.state.env,n?.env)};this.logger?.info("exec",{command:t});let r=n?.cwd??this.state.cwd,s,i=r;if(n?.cwd)if(n.env&&"PWD"in n.env)s=n.env.PWD;else if(n?.env&&!("PWD"in n.env))try{s=await this.fs.realpath(r),i=s}catch{s=r}else s=r;let o=new Map(this.state.env);if(n?.env)for(let[f,h]of Object.entries(n.env))o.set(f,h);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable},l=t;n?.rawScript||(l=Nx(t));let u=(this.defenseInDepthConfig?Co.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let h=hn(l),p={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn},d=await new Rs(p,a).executeScript(h);return this.logResult(d)};return u?await u.run(f):await f()}catch(f){if(f instanceof pe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Yt(this.state.env,n?.env)});if(f instanceof Ft)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Yt(this.state.env,n?.env)});if(f instanceof $e)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Yt(this.state.env,n?.env)});if(f instanceof re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:re.EXIT_CODE,env:Yt(this.state.env,n?.env)});if(f instanceof Dt)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
1461
+ `,exitCode:1,env:Yt(this.state.env,n?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:Yt(this.state.env,n?.env)};this.logger?.info("exec",{command:t});let r=n?.cwd??this.state.cwd,s,i=r;if(n?.cwd)if(n.env&&"PWD"in n.env)s=n.env.PWD;else if(n?.env&&!("PWD"in n.env))try{s=await this.fs.realpath(r),i=s}catch{s=r}else s=r;let o=new Map(this.state.env);if(n?.env)for(let[f,h]of Object.entries(n.env))o.set(f,h);s!==void 0&&o.set("PWD",s);let a={...this.state,env:o,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable},l=t;n?.rawScript||(l=Nx(t));let u=(this.defenseInDepthConfig?Co.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let h=hn(l),p={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn},d=await new Os(p,a).executeScript(h);return this.logResult(d)};return u?await u.run(f):await f()}catch(f){if(f instanceof pe)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Yt(this.state.env,n?.env)});if(f instanceof Ft)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:Yt(this.state.env,n?.env)});if(f instanceof $e)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:Yt(this.state.env,n?.env)});if(f instanceof re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:re.EXIT_CODE,env:Yt(this.state.env,n?.env)});if(f instanceof Dt)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
1462
1462
  `,exitCode:1,env:Yt(this.state.env,n?.env)});if(f.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${f.message}
1463
1463
  `,exitCode:2,env:Yt(this.state.env,n?.env)});if(f instanceof $n)return this.logResult({stdout:"",stderr:`bash: ${f.message}
1464
1464
  `,exitCode:2,env:Yt(this.state.env,n?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${f.message}
1465
1465
  `,exitCode:1,env:Yt(this.state.env,n?.env)});throw f}finally{u?.deactivate()}}async readFile(t){return this.fs.readFile(this.fs.resolvePath(this.state.cwd,t))}async writeFile(t,n){return this.fs.writeFile(this.fs.resolvePath(this.state.cwd,t),n)}getCwd(){return this.state.cwd}getEnv(){return wt(this.state.env)}};function Nx(e){let t=e.split(`
1466
1466
  `),n=[],r=[];for(let s=0;s<t.length;s++){let i=t[s];if(r.length>0){let l=r[r.length-1];if((l.stripTabs?i.replace(/^\t+/,""):i)===l.delimiter){n.push(i.trimStart()),r.pop();continue}n.push(i);continue}let o=i.trimStart();n.push(o);let a=/<<(-?)\s*(['"]?)([\w-]+)\2/g;for(let l of o.matchAll(a)){let c=l[1]==="-",u=l[3];r.push({delimiter:u,stripTabs:c})}}return n.join(`
1467
- `)}export{Jc as Bash,Xn as InMemoryFs,Hr as NetworkAccessDeniedError,jr as RedirectNotAllowedError,zr as TooManyRedirectsError,R5 as defineCommand,v5 as getCommandNames,I5 as getNetworkCommandNames};
1467
+ `)}export{Jc as Bash,Xn as InMemoryFs,Hr as NetworkAccessDeniedError,jr as RedirectNotAllowedError,zr as TooManyRedirectsError,O5 as defineCommand,v5 as getCommandNames,I5 as getNetworkCommandNames};
1468
1468
  /*! Bundled license information:
1469
1469
 
1470
1470
  re2js/build/index.esm.js: