just-bash 2.11.4 → 2.11.5
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.
- package/dist/bin/chunks/chunk-LOJMXC4F.js +5 -0
- package/dist/bin/{shell/chunks/date-6VDN5QZ5.js → chunks/date-WUPBL2TL.js} +1 -1
- package/dist/bin/{shell/chunks/flag-coverage-WM63KT7D.js → chunks/flag-coverage-23SVOOPG.js} +1 -1
- package/dist/bin/just-bash.js +92 -92
- package/dist/bin/shell/chunks/chunk-LOJMXC4F.js +5 -0
- package/dist/bin/{chunks/date-6VDN5QZ5.js → shell/chunks/date-WUPBL2TL.js} +1 -1
- package/dist/bin/{chunks/flag-coverage-WM63KT7D.js → shell/chunks/flag-coverage-23SVOOPG.js} +1 -1
- package/dist/bin/shell/shell.js +63 -63
- package/dist/bundle/browser.js +150 -150
- package/dist/bundle/chunks/chunk-D7MEQ3VN.js +4 -0
- package/dist/bundle/chunks/{date-FT2P5UCQ.js → date-DD7FVA2V.js} +1 -1
- package/dist/bundle/chunks/{flag-coverage-H2IQM6DS.js → flag-coverage-YHMPSZHK.js} +1 -1
- package/dist/bundle/index.js +44 -44
- package/package.json +1 -1
- package/dist/bin/chunks/chunk-IY3BUFJK.js +0 -5
- package/dist/bin/shell/chunks/chunk-IY3BUFJK.js +0 -5
- package/dist/bundle/chunks/chunk-OCK72LWW.js +0 -4
package/dist/bundle/browser.js
CHANGED
|
@@ -28,13 +28,13 @@ Notes:
|
|
|
28
28
|
`),r=e.endsWith(`
|
|
29
29
|
`),s=r?n.slice(0,-1):n;return{content:s.map((a,o)=>`${String(t+o).padStart(6," ")} ${a}`).join(`
|
|
30
30
|
`)+(r?`
|
|
31
|
-
`:""),nextLineNumber:t+s.length}}var Y6,J6,e7,n7,xu=I(()=>{"use strict";Ze();Zn();se();Y6={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"]},J6={number:{short:"n",long:"number",type:"boolean"}},e7={name:"cat",async execute(e,t){if(U(e))return M(Y6);let n=be("cat",e,J6);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await qn(t,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),a="",o=1;for(let{content:l}of i.files)if(r){let c=t7(l,o);a+=c.content,o=c.nextLineNumber}else a+=l;return{stdout:a,stderr:i.stderr,exitCode:i.exitCode}}};n7={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0}});function js(e){return e instanceof pt||e instanceof ht||e instanceof ct}var
|
|
32
|
-
`),this.varName=t}},pe=class extends
|
|
33
|
-
`,this.fatal=s}},
|
|
34
|
-
`}},fn=class extends
|
|
35
|
-
`}},yr=class extends
|
|
36
|
-
`}},te=class extends
|
|
37
|
-
`}},pn=class extends
|
|
31
|
+
`:""),nextLineNumber:t+s.length}}var Y6,J6,e7,n7,xu=I(()=>{"use strict";Ze();Zn();se();Y6={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"]},J6={number:{short:"n",long:"number",type:"boolean"}},e7={name:"cat",async execute(e,t){if(U(e))return M(Y6);let n=be("cat",e,J6);if(!n.ok)return n.error;let r=n.result.flags.number,s=n.result.positional,i=await qn(t,s,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),a="",o=1;for(let{content:l}of i.files)if(r){let c=t7(l,o);a+=c.content,o=c.nextLineNumber}else a+=l;return{stdout:a,stderr:i.stderr,exitCode:i.exitCode}}};n7={name:"cat",flags:[{flag:"-n",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-e",type:"boolean"},{flag:"-t",type:"boolean"}],stdinType:"text",needsFiles:!0}});function js(e){return e instanceof pt||e instanceof ht||e instanceof ct}var gt,pt,ht,ct,vt,yt,pe,Re,wt,fn,yr,te,pn,Bt,ye=I(()=>{"use strict";gt=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}},pt=class extends gt{levels;name="BreakError";constructor(t=1,n="",r=""){super("break",n,r),this.levels=t}},ht=class extends gt{levels;name="ContinueError";constructor(t=1,n="",r=""){super("continue",n,r),this.levels=t}},ct=class extends gt{exitCode;name="ReturnError";constructor(t=0,n="",r=""){super("return",n,r),this.exitCode=t}},vt=class extends gt{exitCode;name="ErrexitError";constructor(t,n="",r=""){super(`errexit: command exited with status ${t}`,n,r),this.exitCode=t}},yt=class extends gt{varName;name="NounsetError";constructor(t,n=""){super(`${t}: unbound variable`,n,`bash: ${t}: unbound variable
|
|
32
|
+
`),this.varName=t}},pe=class extends gt{exitCode;name="ExitError";constructor(t,n="",r=""){super("exit",n,r),this.exitCode=t}},Re=class extends gt{name="ArithmeticError";fatal;constructor(t,n="",r="",s=!1){super(t,n,r),this.stderr=r||`bash: ${t}
|
|
33
|
+
`,this.fatal=s}},wt=class extends gt{name="BadSubstitutionError";constructor(t,n="",r=""){super(t,n,r),this.stderr=r||`bash: ${t}: bad substitution
|
|
34
|
+
`}},fn=class extends gt{name="GlobError";constructor(t,n="",r=""){super(`no match: ${t}`,n,r),this.stderr=r||`bash: no match: ${t}
|
|
35
|
+
`}},yr=class extends gt{name="BraceExpansionError";constructor(t,n="",r=""){super(t,n,r),this.stderr=r||`bash: ${t}
|
|
36
|
+
`}},te=class extends gt{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(t,n,r="",s=""){super(t,r,s),this.limitType=n,this.stderr=s||`bash: ${t}
|
|
37
|
+
`}},pn=class extends gt{name="SubshellExitError";constructor(t="",n=""){super("subshell exit",t,n)}};Bt=class extends gt{exitCode;name="PosixFatalError";constructor(t,n="",r=""){super("posix fatal error",n,r),this.exitCode=t}}});function Ue(e){return e instanceof Error?e.message:String(e)}var zt=I(()=>{"use strict"});function Gs(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 Eu(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 Vs(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length)switch(e[n+1]){case"n":t+=`
|
|
38
38
|
`,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 a=new TextDecoder("utf-8",{fatal:!0});t+=a.decode(new Uint8Array(s))}catch{for(let a of s)t+=String.fromCharCode(a)}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 Ma=I(()=>{"use strict"});function Cu(e,t,n){let r=new Date(t*1e3),s="",i=0;for(;i<e.length;)if(e[i]==="%"&&i+1<e.length){let a=e[i+1],o=s7(r,a,n);o!==null?(s+=o,i+=2):(s+=e[i],i++)}else s+=e[i],i++;return s}function r7(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??"",a=new Map([["Sun",0],["Mon",1],["Tue",2],["Wed",3],["Thu",4],["Fri",5],["Sat",6]]),o=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:a.get(o)??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 s7(e,t,n){let r=r7(e,n),s=(l,c=2)=>String(l).padStart(c,"0"),i=Nu(r.year,r.month,r.day),a=Au(r.year,r.month,r.day,r.weekday,0),o=Au(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(Su(r.year,r.month,r.day)%100);case"G":return String(Su(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`
|
|
39
39
|
`;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(a);case"V":return s(o7(r.year,r.month,r.day));case"w":return String(r.weekday);case"W":return s(o);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 i7(e,n);case"Z":return a7(e,n);case"%":return"%";default:return null}}function i7(e,t){if(!t){let a=-e.getTimezoneOffset(),o=a>=0?"+":"-",l=Math.floor(Math.abs(a)/60),c=Math.abs(a)%60;return`${o}${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 a7(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 Nu(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 a=0;a<t-1;a++)i+=r[a];return i}function Au(e,t,n,r,s){let i=Nu(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 o7(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 Su(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 ku=I(()=>{"use strict"});var Iu={};K(Iu,{flagsForFuzzing:()=>x7,printfCommand:()=>u7});import{sprintf as wr}from"sprintf-js";function l7(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 f7(e,t,n,r){let s="",i=0,a=0,o=!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,$=u[2]?parseInt(u[2],10):-1,O=u[3],F=u[0],R=t[n+a]||"";a++;let z;R===""||R==="-1"||R==="-2"?z=Math.floor(Date.now()/1e3):z=parseInt(R,10)||0;let k=Cu(O,z,r);if($>=0&&k.length>$&&(k=k.slice(0,$)),S!==0){let N=Math.abs(S);k.length<N&&(S<0?k=k.padEnd(N," "):k=k.padStart(N," "))}s+=k,i=c+F.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 p=!1;if(e[i]===".")if(i++,e[i]==="*")p=!0,i++;else for(;i<e.length&&/\d/.test(e[i]);)i++;i<e.length&&"hlL".includes(e[i])&&i++;let h=e[i]||"";i++;let d=e.slice(c,i);if(f){let S=parseInt(t[n+a]||"0",10);a++,d=d.replace("*",String(S))}if(p){let S=parseInt(t[n+a]||"0",10);a++,d=d.replace(".*",`.${S}`)}let g=t[n+a]||"";a++;let{value:w,parseError:y,parseErrMsg:b,stopped:x}=p7(d,h,g);if(s+=w,y&&(o=!0,b&&(l=b)),x)return{result:s,argsConsumed:a,error:o,errMsg:l,stopped:!0}}else s+=e[i],i++;return{result:s,argsConsumed:a,error:o,errMsg:l,stopped:!1}}function p7(e,t,n){let r=!1,s="";switch(t){case"d":case"i":{let i=qs(n);return r=Jt,r&&(s=`printf: ${n}: invalid number
|
|
40
40
|
`),{value:vu(e,i),parseError:r,parseErrMsg:s}}case"o":{let i=qs(n);return r=Jt,r&&(s=`printf: ${n}: invalid number
|
|
@@ -172,7 +172,7 @@ Options:
|
|
|
172
172
|
`)-1&&t.runes[2]===D.CODES.get(`
|
|
173
173
|
`)+1&&t.runes[3]===he.MAX_RUNE&&(t.runes=[],t.op=_.Op.ANY_CHAR_NOT_NL))}collapse(t,n){if(t.length===1)return t[0];let r=0;for(let o of t)r+=o.op===n?o.subs.length:1;let s=new Array(r).fill(null),i=0;for(let o of t)o.op===n?(s.splice(i,o.subs.length,...o.subs),i+=o.subs.length,this.reuse(o)):s[i++]=o;let a=this.newRegexp(n);if(a.subs=s,n===_.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let o=a;a=a.subs[0],this.reuse(o)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,s=0,i=null,a=0,o=0,l=0;for(let u=0;u<=r;u++){let f=null,p=0,h=0;if(u<r){let m=t[n+u];if(m.op===_.Op.CONCAT&&m.subs.length>0&&(m=m.subs[0]),m.op===_.Op.LITERAL&&(f=m.runes,p=m.runes.length,h=m.flags&Q.FOLD_CASE),h===o){let d=0;for(;d<a&&d<p&&i[d]===f[d];)d++;if(d>0){a=d;continue}}}if(u!==l)if(u===l+1)t[s++]=t[n+l];else{let m=this.newRegexp(_.Op.LITERAL);m.flags=o,m.runes=i.slice(0,a);for(let w=l;w<u;w++)t[n+w]=this.removeLeadingString(t[n+w],a),this.checkLimits(t[n+w]);let d=this.collapse(t.slice(n+l,n+u),_.Op.ALTERNATE),g=this.newRegexp(_.Op.CONCAT);g.subs=[m,d],t[s++]=g}l=u,i=f,a=p,o=h}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===_.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 p=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 h=this.collapse(t.slice(n+l,n+u),_.Op.ALTERNATE),m=this.newRegexp(_.Op.CONCAT);m.subs=[p,h],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 h=l+1;h<u;h++){let m=t[n+f],d=t[n+h];(m.op<d.op||m.op===d.op&&(m.runes!==null?m.runes.length:0)<(d.runes!==null?d.runes.length:0))&&(f=h)}let p=t[n+l];t[n+l]=t[n+f],t[n+f]=p;for(let h=l+1;h<u;h++)e.mergeCharClass(t[n+l],t[n+h]),this.reuse(t[n+h]);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===_.Op.EMPTY_MATCH&&t[n+u+1].op===_.Op.EMPTY_MATCH||(t[s++]=t[n+u]);return r=s,n=0,t.slice(n,r)}removeLeadingString(t,n){if(t.op===_.Op.CONCAT&&t.subs.length>0){let r=this.removeLeadingString(t.subs[0],n);if(t.subs[0]=r,r.op===_.Op.EMPTY_MATCH)switch(this.reuse(r),t.subs.length){case 0:case 1:t.op=_.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===_.Op.LITERAL&&(t.runes=t.runes.slice(n,t.runes.length),t.runes.length===0&&(t.op=_.Op.EMPTY_MATCH)),t}removeLeadingRegexp(t,n){if(t.op===_.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=_.Op.EMPTY_MATCH,t.subs=_.emptySubs();break}case 1:{let r=t;t=t.subs[0],this.reuse(r);break}}return t}return n&&this.reuse(t),this.newRegexp(_.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&Q.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,s=new Ya(this.wholeRegexp);for(;s.more();){let a=-1;e:switch(s.peek()){case D.CODES.get("("):if((this.flags&Q.PERL_X)!==0&&s.lookingAt("(?")){this.parsePerlFlags(s);break}this.op(_.Op.LEFT_PAREN).cap=++this.numCap,s.skip(1);break;case D.CODES.get("|"):this.parseVerticalBar(),s.skip(1);break;case D.CODES.get(")"):this.parseRightParen(),s.skip(1);break;case D.CODES.get("^"):(this.flags&Q.ONE_LINE)!==0?this.op(_.Op.BEGIN_TEXT):this.op(_.Op.BEGIN_LINE),s.skip(1);break;case D.CODES.get("$"):(this.flags&Q.ONE_LINE)!==0?this.op(_.Op.END_TEXT).flags|=Q.WAS_DOLLAR:this.op(_.Op.END_LINE),s.skip(1);break;case D.CODES.get("."):(this.flags&Q.DOT_NL)!==0?this.op(_.Op.ANY_CHAR):this.op(_.Op.ANY_CHAR_NOT_NL),s.skip(1);break;case D.CODES.get("["):this.parseClass(s);break;case D.CODES.get("*"):case D.CODES.get("+"):case D.CODES.get("?"):{a=s.pos();let o=null;switch(s.pop()){case D.CODES.get("*"):o=_.Op.STAR;break;case D.CODES.get("+"):o=_.Op.PLUS;break;case D.CODES.get("?"):o=_.Op.QUEST;break}this.repeat(o,n,r,a,s,t);break}case D.CODES.get("{"):{a=s.pos();let o=e.parseRepeat(s);if(o<0){s.rewindTo(a),this.literal(s.pop());break}n=o>>16,r=(o&he.MAX_BMP)<<16>>16,this.repeat(_.Op.REPEAT,n,r,a,s,t);break}case D.CODES.get("\\"):{let o=s.pos();if(s.skip(1),(this.flags&Q.PERL_X)!==0&&s.more())switch(s.pop()){case D.CODES.get("A"):this.op(_.Op.BEGIN_TEXT);break e;case D.CODES.get("b"):this.op(_.Op.WORD_BOUNDARY);break e;case D.CODES.get("B"):this.op(_.Op.NO_WORD_BOUNDARY);break e;case D.CODES.get("C"):throw new De(e.ERR_INVALID_ESCAPE,"\\C");case D.CODES.get("Q"):{let f=s.rest(),p=f.indexOf("\\E");p>=0&&(f=f.substring(0,p)),s.skipString(f),s.skipString("\\E");let h=0;for(;h<f.length;){let m=f.codePointAt(h);this.literal(m),h+=Ne.charCount(m)}break e}case D.CODES.get("z"):this.op(_.Op.END_TEXT);break e;default:s.rewindTo(o);break}let l=this.newRegexp(_.Op.CHAR_CLASS);if(l.flags=this.flags,s.lookingAt("\\p")||s.lookingAt("\\P")){let u=new hn;if(this.parseUnicodeClass(s,u)){l.runes=u.toArray(),this.push(l);break e}}let c=new hn;if(this.parsePerlClassEscape(s,c)){l.runes=c.toArray(),this.push(l);break e}s.rewindTo(o),this.reuse(l),this.literal(e.parseEscape(s));break}default:this.literal(s.pop());break}t=a}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 o=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(o,l);if(t.skipString(c),t.skip(o+1),!e.isValidCaptureName(c))throw new De(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,l+1));let u=this.op(_.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,a=!1;e:for(;t.more();){let o=t.pop();switch(o){case D.CODES.get("i"):s|=Q.FOLD_CASE,a=!0;break;case D.CODES.get("m"):s&=-17,a=!0;break;case D.CODES.get("s"):s|=Q.DOT_NL,a=!0;break;case D.CODES.get("U"):s|=Q.NON_GREEDY,a=!0;break;case D.CODES.get("-"):if(i<0)break e;i=-1,s=~s,a=!1;break;case D.CODES.get(":"):case D.CODES.get(")"):if(i<0){if(!a)break e;s=~s}o===D.CODES.get(":")&&this.op(_.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(_.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===_.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===_.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!==_.Op.LEFT_PAREN)throw new De(e.ERR_UNEXPECTED_PAREN,this.wholeRegexp);this.flags=r.flags,r.cap===0?this.push(n):(r.op=_.Op.CAPTURE,r.subs=[n],this.push(r))}parsePerlClassEscape(t,n){let r=t.pos();if((this.flags&Q.PERL_X)===0||!t.more()||t.pop()!==D.CODES.get("\\")||!t.more())return!1;t.pop();let s=t.from(r),i=bf.has(s)?bf.get(s):null;return i===null?!1:(n.appendGroup(i,(this.flags&Q.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 a=Df.has(i)?Df.get(i):null;if(a===null)throw new De(e.ERR_INVALID_CHAR_RANGE,i);return n.appendGroup(a,(this.flags&Q.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&Q.UNICODE_GROUPS)===0||!t.lookingAt("\\p")&&!t.lookingAt("\\P"))return!1;t.skip(1);let s=1,i=t.pop();if(i===D.CODES.get("P")&&(s=-1),!t.more())throw t.rewindTo(r),new De(e.ERR_INVALID_CHAR_RANGE,t.rest());i=t.pop();let a;if(i!==D.CODES.get("{"))a=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());a=u.substring(0,f),t.skipString(a),t.skip(1)}a.length!==0&&a.codePointAt(0)===D.CODES.get("^")&&(s=0-s,a=a.substring(1));let o=e.unicodeTable(a);if(o===null)throw new De(e.ERR_INVALID_CHAR_RANGE,t.from(r));let l=o.first,c=o.second;if((this.flags&Q.FOLD_CASE)===0||c===null)n.appendTableWithSign(l,s);else{let u=new hn().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(_.Op.CHAR_CLASS);r.flags=this.flags;let s=new hn,i=1;t.more()&&t.lookingAt("^")&&(i=-1,t.skip(1),(this.flags&Q.CLASS_NL)===0&&s.appendRange(D.CODES.get(`
|
|
174
174
|
`),D.CODES.get(`
|
|
175
|
-
`)));let a=!0;for(;!t.more()||t.peek()!==D.CODES.get("]")||a;){if(t.more()&&t.lookingAt("-")&&(this.flags&Q.PERL_X)===0&&!a){let u=t.rest();if(u==="-"||!u.startsWith("-]"))throw t.rewindTo(n),new De(e.ERR_INVALID_CHAR_RANGE,t.rest())}a=!1;let o=t.pos();if(t.lookingAt("[:")){if(this.parseNamedClass(t,s))continue;t.rewindTo(o)}if(this.parseUnicodeClass(t,s)||this.parsePerlClassEscape(t,s))continue;t.rewindTo(o);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(o))}(this.flags&Q.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)}},eo=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}},to=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,Q.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,Q.POSIX,!0)}static compileImpl(t,n,r){let s=Ja.parse(t,n),i=s.maxCap();s=Xa.simplify(s);let a=Qa.compileRegexp(s),o=new e(t,a,i,r),[l,c]=a.prefix();return o.prefixComplete=l,o.prefix=c,o.prefixUTF8=Ne.stringToUtf8ByteArray(o.prefix),o.prefix.length>0&&(o.prefixRune=o.prefix.codePointAt(0)),o.namedGroups=s.namedGroups,o}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 eo}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=rs.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(),a=!1;i?i.next!==null&&(i=rs.fromMachine(i),a=!0):(i=rs.fromRE2(this),a=!0),i.init(s);let o=i.match(t,n,r)?i.submatches():null;return this.put(i,a),o}match(t){return this.doExecute(Ge.fromUTF16(t),0,Q.UNANCHORED,0)!==null}matchWithGroup(t,n,r,s,i){return t instanceof Rn||(t=xr.utf16(t)),this.matchMachineInput(t,n,r,s,i)}matchMachineInput(t,n,r,s,i){if(n>r)return[!1,null];let a=t.isUTF16Encoding()?Ge.fromUTF16(t.asCharSequence(),0,r):Ge.fromUTF8(t.asBytes(),0,r),o=this.doExecute(a,n,s,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(t){return this.doExecute(Ge.fromUTF8(t),0,Q.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,a="",o=Ge.fromUTF16(t),l=0;for(;i<=t.length;){let c=this.doExecute(o,i,Q.UNANCHORED,2);if(c===null||c.length===0)break;a+=t.substring(s,c[0]),(c[1]>s||c[0]===0)&&(a+=n(t.substring(c[0],c[1])),l++),s=c[1];let u=o.step(i)&7;if(i+u>c[1]?i+=u:i+1>c[1]?i++:i=c[1],l>=r)break}return a+=t.substring(s),a}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 a=0,o=0,l=-1;for(;o<n&&a<=i;){let c=this.doExecute(t,a,Q.UNANCHORED,this.prog.numCap);if(c===null||c.length===0)break;let u=!0;if(c[1]===a){c[0]===l&&(u=!1);let f=t.step(a);f<0?a=i+1:a+=f&7}else a=c[1];l=c[1],u&&(s.push(r(this.pad(c))),o++)}return s}findUTF8(t){let n=this.doExecute(Ge.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:t.slice(n[0],n[1])}findUTF8Index(t){let n=this.doExecute(Ge.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:n.slice(0,2)}find(t){let n=this.doExecute(Ge.fromUTF16(t),0,Q.UNANCHORED,2);return n===null?"":t.substring(n[0],n[1])}findIndex(t){return this.doExecute(Ge.fromUTF16(t),0,Q.UNANCHORED,2)}findUTF8Submatch(t){let n=this.doExecute(Ge.fromUTF8(t),0,Q.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(Ge.fromUTF8(t),0,Q.UNANCHORED,this.prog.numCap))}findSubmatch(t){let n=this.doExecute(Ge.fromUTF16(t),0,Q.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(Ge.fromUTF16(t),0,Q.UNANCHORED,this.prog.numCap))}findAllUTF8(t,n){let r=this.allMatches(Ge.fromUTF8(t),n,s=>t.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(t,n){let r=this.allMatches(Ge.fromUTF8(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAll(t,n){let r=this.allMatches(Ge.fromUTF16(t),n,s=>t.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(t,n){let r=this.allMatches(Ge.fromUTF16(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(t,n){let r=this.allMatches(Ge.fromUTF8(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let a=0;a<i.length;a++)s[2*a]>=0&&(i[a]=t.slice(s[2*a],s[2*a+1]));return i});return r.length===0?null:r}findAllUTF8SubmatchIndex(t,n){let r=this.allMatches(Ge.fromUTF8(t),n);return r.length===0?null:r}findAllSubmatch(t,n){let r=this.allMatches(Ge.fromUTF16(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let a=0;a<i.length;a++)s[2*a]>=0&&(i[a]=t.substring(s[2*a],s[2*a+1]));return i});return r.length===0?null:r}findAllSubmatchIndex(t,n){let r=this.allMatches(Ge.fromUTF16(t),n);return r.length===0?null:r}},no=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 a=t[i];if(a==="\\"){if(i+1<s)switch(a=t[i+1],a){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(a);n+=t.substring(i+1,i+1+l),i+=l+1;continue}}}else if(a==="/"){n+="\\/",i+=1,r=!0;continue}else if(a==="("&&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 o=e.getUtf8CharSize(a);n+=t.substring(i,i+o),i+=o}return r?n:t}},Tn=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 no.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 ja("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH");let s=Q.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(s&=-129);let i=new e(t,n);return i.re2Input=to.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=xr.utf8(t)),new Ga(this,t)}split(t,n=0){let r=this.matcher(t),s=[],i=0,a=0;for(;r.find();){if(a===0&&r.end()===0){a=r.end();continue}if(n>0&&s.length===n-1)break;if(a===r.start()){if(n===0){i+=1,a=r.end();continue}}else for(;i>0;)s.push(""),i-=1;s.push(r.substring(a,r.start())),a=r.end()}if(n===0&&a!==r.inputLength()){for(;i>0;)s.push(""),i-=1;s.push(r.substring(a,r.inputLength()))}return(n!==0||s.length===0)&&s.push(r.substring(a,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 by(e){let t=0;return e.includes("i")&&(t|=Tn.CASE_INSENSITIVE),e.includes("m")&&(t|=Tn.MULTILINE),e.includes("s")&&(t|=Tn.DOTALL),t}function xy(e){return Tn.translateRegExp(e)}function V(e,t=""){return new ei(e,t)}var ei,Cn,Ff=I(()=>{"use strict";Lf();ei=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=xy(t),s=by(n);this._re2=Tn.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 a=i;a.index=n.start(0),a.input=t;let o=this._re2.namedGroups();if(o&&Object.keys(o).length>0){let l=Object.create(null);for(let[c,u]of Object.entries(o)){let f=n.group(u);f!==null&&(l[c]=f)}a.groups=l}return this._global&&(this._lastIndex=n.end(0),n.start(0)===n.end(0)&&this._lastIndex++),a}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,a=0,o=this._re2.groupCount(),l=this._re2.namedGroups();for(;s.find(a);){r.push(t.slice(i,s.start(0)));let c=[],u=s.group(0)??"";for(let f=1;f<=o;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[p,h]of Object.entries(l))f[p]=s.group(h)??"";c.push(f)}if(r.push(n(u,...c)),i=s.end(0),a=i,s.start(0)===s.end(0)&&a++,!this._global||a>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 a=[];a.push(n.group(0)??"");for(let l=1;l<=r;l++)a.push(n.group(l));let o=a;if(o.index=n.start(0),o.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)}o.groups=l}if(yield o,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}};Cn=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";Ff()});function xt(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,a=Mf.get(i);return a||(a=Ey(s,r.ignoreCase),Mf.set(i,a)),a.test(e)}function Ey(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 Mf,ro=I(()=>{"use strict";Me();Mf=new Map});function Uf(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 Ar(e,t,n={}){let{invertMatch:r=!1,showLineNumbers:s=!1,countOnly:i=!1,countMatches:a=!1,filename:o="",onlyMatching:l=!1,beforeContext:c=0,afterContext:u=0,maxCount:f=0,contextSeparator:p="--",showColumn:h=!1,vimgrep:m=!1,showByteOffset:d=!1,replace:g=null,passthru:w=!1,multiline:y=!1,kResetGroup:b}=n;if(y)return Ay(e,t,{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:a,filename:o,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:p,showColumn:h,showByteOffset:d,replace:g,kResetGroup:b});let x=e.split(`
|
|
175
|
+
`)));let a=!0;for(;!t.more()||t.peek()!==D.CODES.get("]")||a;){if(t.more()&&t.lookingAt("-")&&(this.flags&Q.PERL_X)===0&&!a){let u=t.rest();if(u==="-"||!u.startsWith("-]"))throw t.rewindTo(n),new De(e.ERR_INVALID_CHAR_RANGE,t.rest())}a=!1;let o=t.pos();if(t.lookingAt("[:")){if(this.parseNamedClass(t,s))continue;t.rewindTo(o)}if(this.parseUnicodeClass(t,s)||this.parsePerlClassEscape(t,s))continue;t.rewindTo(o);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(o))}(this.flags&Q.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)}},eo=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}},to=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,Q.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,Q.POSIX,!0)}static compileImpl(t,n,r){let s=Ja.parse(t,n),i=s.maxCap();s=Xa.simplify(s);let a=Qa.compileRegexp(s),o=new e(t,a,i,r),[l,c]=a.prefix();return o.prefixComplete=l,o.prefix=c,o.prefixUTF8=Ne.stringToUtf8ByteArray(o.prefix),o.prefix.length>0&&(o.prefixRune=o.prefix.codePointAt(0)),o.namedGroups=s.namedGroups,o}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 eo}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=rs.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(),a=!1;i?i.next!==null&&(i=rs.fromMachine(i),a=!0):(i=rs.fromRE2(this),a=!0),i.init(s);let o=i.match(t,n,r)?i.submatches():null;return this.put(i,a),o}match(t){return this.doExecute(Ge.fromUTF16(t),0,Q.UNANCHORED,0)!==null}matchWithGroup(t,n,r,s,i){return t instanceof Rn||(t=xr.utf16(t)),this.matchMachineInput(t,n,r,s,i)}matchMachineInput(t,n,r,s,i){if(n>r)return[!1,null];let a=t.isUTF16Encoding()?Ge.fromUTF16(t.asCharSequence(),0,r):Ge.fromUTF8(t.asBytes(),0,r),o=this.doExecute(a,n,s,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(t){return this.doExecute(Ge.fromUTF8(t),0,Q.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,a="",o=Ge.fromUTF16(t),l=0;for(;i<=t.length;){let c=this.doExecute(o,i,Q.UNANCHORED,2);if(c===null||c.length===0)break;a+=t.substring(s,c[0]),(c[1]>s||c[0]===0)&&(a+=n(t.substring(c[0],c[1])),l++),s=c[1];let u=o.step(i)&7;if(i+u>c[1]?i+=u:i+1>c[1]?i++:i=c[1],l>=r)break}return a+=t.substring(s),a}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 a=0,o=0,l=-1;for(;o<n&&a<=i;){let c=this.doExecute(t,a,Q.UNANCHORED,this.prog.numCap);if(c===null||c.length===0)break;let u=!0;if(c[1]===a){c[0]===l&&(u=!1);let f=t.step(a);f<0?a=i+1:a+=f&7}else a=c[1];l=c[1],u&&(s.push(r(this.pad(c))),o++)}return s}findUTF8(t){let n=this.doExecute(Ge.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:t.slice(n[0],n[1])}findUTF8Index(t){let n=this.doExecute(Ge.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:n.slice(0,2)}find(t){let n=this.doExecute(Ge.fromUTF16(t),0,Q.UNANCHORED,2);return n===null?"":t.substring(n[0],n[1])}findIndex(t){return this.doExecute(Ge.fromUTF16(t),0,Q.UNANCHORED,2)}findUTF8Submatch(t){let n=this.doExecute(Ge.fromUTF8(t),0,Q.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(Ge.fromUTF8(t),0,Q.UNANCHORED,this.prog.numCap))}findSubmatch(t){let n=this.doExecute(Ge.fromUTF16(t),0,Q.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(Ge.fromUTF16(t),0,Q.UNANCHORED,this.prog.numCap))}findAllUTF8(t,n){let r=this.allMatches(Ge.fromUTF8(t),n,s=>t.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(t,n){let r=this.allMatches(Ge.fromUTF8(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAll(t,n){let r=this.allMatches(Ge.fromUTF16(t),n,s=>t.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(t,n){let r=this.allMatches(Ge.fromUTF16(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(t,n){let r=this.allMatches(Ge.fromUTF8(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let a=0;a<i.length;a++)s[2*a]>=0&&(i[a]=t.slice(s[2*a],s[2*a+1]));return i});return r.length===0?null:r}findAllUTF8SubmatchIndex(t,n){let r=this.allMatches(Ge.fromUTF8(t),n);return r.length===0?null:r}findAllSubmatch(t,n){let r=this.allMatches(Ge.fromUTF16(t),n,s=>{let i=new Array(s.length/2|0).fill(null);for(let a=0;a<i.length;a++)s[2*a]>=0&&(i[a]=t.substring(s[2*a],s[2*a+1]));return i});return r.length===0?null:r}findAllSubmatchIndex(t,n){let r=this.allMatches(Ge.fromUTF16(t),n);return r.length===0?null:r}},no=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 a=t[i];if(a==="\\"){if(i+1<s)switch(a=t[i+1],a){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(a);n+=t.substring(i+1,i+1+l),i+=l+1;continue}}}else if(a==="/"){n+="\\/",i+=1,r=!0;continue}else if(a==="("&&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 o=e.getUtf8CharSize(a);n+=t.substring(i,i+o),i+=o}return r?n:t}},Tn=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 no.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 ja("Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH");let s=Q.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(s&=-129);let i=new e(t,n);return i.re2Input=to.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=xr.utf8(t)),new Ga(this,t)}split(t,n=0){let r=this.matcher(t),s=[],i=0,a=0;for(;r.find();){if(a===0&&r.end()===0){a=r.end();continue}if(n>0&&s.length===n-1)break;if(a===r.start()){if(n===0){i+=1,a=r.end();continue}}else for(;i>0;)s.push(""),i-=1;s.push(r.substring(a,r.start())),a=r.end()}if(n===0&&a!==r.inputLength()){for(;i>0;)s.push(""),i-=1;s.push(r.substring(a,r.inputLength()))}return(n!==0||s.length===0)&&s.push(r.substring(a,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 by(e){let t=0;return e.includes("i")&&(t|=Tn.CASE_INSENSITIVE),e.includes("m")&&(t|=Tn.MULTILINE),e.includes("s")&&(t|=Tn.DOTALL),t}function xy(e){return Tn.translateRegExp(e)}function V(e,t=""){return new ei(e,t)}var ei,Cn,Ff=I(()=>{"use strict";Lf();ei=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=xy(t),s=by(n);this._re2=Tn.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 a=i;a.index=n.start(0),a.input=t;let o=this._re2.namedGroups();if(o&&Object.keys(o).length>0){let l=Object.create(null);for(let[c,u]of Object.entries(o)){let f=n.group(u);f!==null&&(l[c]=f)}a.groups=l}return this._global&&(this._lastIndex=n.end(0),n.start(0)===n.end(0)&&this._lastIndex++),a}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,a=0,o=this._re2.groupCount(),l=this._re2.namedGroups();for(;s.find(a);){r.push(t.slice(i,s.start(0)));let c=[],u=s.group(0)??"";for(let f=1;f<=o;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[p,h]of Object.entries(l))f[p]=s.group(h)??"";c.push(f)}if(r.push(n(u,...c)),i=s.end(0),a=i,s.start(0)===s.end(0)&&a++,!this._global||a>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 a=[];a.push(n.group(0)??"");for(let l=1;l<=r;l++)a.push(n.group(l));let o=a;if(o.index=n.start(0),o.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)}o.groups=l}if(yield o,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}};Cn=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";Ff()});function bt(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,a=Mf.get(i);return a||(a=Ey(s,r.ignoreCase),Mf.set(i,a)),a.test(e)}function Ey(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 Mf,ro=I(()=>{"use strict";Me();Mf=new Map});function Uf(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 Ar(e,t,n={}){let{invertMatch:r=!1,showLineNumbers:s=!1,countOnly:i=!1,countMatches:a=!1,filename:o="",onlyMatching:l=!1,beforeContext:c=0,afterContext:u=0,maxCount:f=0,contextSeparator:p="--",showColumn:h=!1,vimgrep:m=!1,showByteOffset:d=!1,replace:g=null,passthru:w=!1,multiline:y=!1,kResetGroup:b}=n;if(y)return Ay(e,t,{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:a,filename:o,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:p,showColumn:h,showByteOffset:d,replace:g,kResetGroup:b});let x=e.split(`
|
|
176
176
|
`),S=x.length,$=S>0&&x[S-1]===""?S-1:S;if(i||a){let N=0,P=(a||l)&&!r;for(let T=0;T<$;T++)if(t.lastIndex=0,P)for(let L=t.exec(x[T]);L!==null;L=t.exec(x[T]))N++,L[0].length===0&&t.lastIndex++;else t.test(x[T])!==r&&N++;return{output:`${o?`${o}:${N}`:String(N)}
|
|
177
177
|
`,matched:N>0,matchCount:N}}if(c===0&&u===0&&!w){let N=[],P=!1,v=0,T=0;for(let L=0;L<$&&!(f>0&&v>=f);L++){let ue=x[L];if(t.lastIndex=0,t.test(ue)!==r)if(P=!0,v++,l){t.lastIndex=0;for(let ee=t.exec(ue);ee!==null;ee=t.exec(ue)){let H=b!==void 0?ee[b]??"":ee[0],X=g!==null?Uf(g,ee):H,Ee=o?`${o}:`:"";d&&(Ee+=`${T+ee.index}:`),s&&(Ee+=`${L+1}:`),h&&(Ee+=`${ee.index+1}:`),N.push(Ee+X),ee[0].length===0&&t.lastIndex++}}else if(m){t.lastIndex=0;for(let ee=t.exec(ue);ee!==null;ee=t.exec(ue)){let H=o?`${o}:`:"";d&&(H+=`${T+ee.index}:`),s&&(H+=`${L+1}:`),h&&(H+=`${ee.index+1}:`),N.push(H+ue),ee[0].length===0&&t.lastIndex++}}else{t.lastIndex=0;let ee=t.exec(ue),H=ee?ee.index+1:1,X=ue;g!==null&&(t.lastIndex=0,X=t.replace(ue,(...ae)=>{if(ae[0].length===0)return"";let j=ae,ve=ae[ae.length-1];return typeof ve=="object"&&ve!==null?(j.groups=ve,j.input=ae[ae.length-2],j.index=ae[ae.length-3]):(j.input=ae[ae.length-1],j.index=ae[ae.length-2]),Uf(g,j)}));let Ee=o?`${o}:`:"";d&&(Ee+=`${T+(ee?ee.index:0)}:`),s&&(Ee+=`${L+1}:`),h&&(Ee+=`${H}:`),N.push(Ee+X)}T+=ue.length+1}return{output:N.length>0?`${N.join(`
|
|
178
178
|
`)}
|
|
@@ -187,10 +187,10 @@ Options:
|
|
|
187
187
|
`)}
|
|
188
188
|
`:"",matched:N.length>0,matchCount:N.length}}if(O.length===0)return{output:"",matched:!1,matchCount:0};let F=new Set,R=-1,z=[];for(let k of O){let N=Math.max(0,k.startLine-c),P=Math.min(b-1,k.endLine+u);R>=0&&N>R+1&&z.push(p);for(let v=N;v<k.startLine;v++)if(!F.has(v)){F.add(v),R=v;let T=w[v];s&&(T=`${v+1}-${T}`),o&&(T=`${o}-${T}`),z.push(T)}if(l){let v=d!==null?d:k.matchText,T=o?`${o}:`:"";m&&(T+=`${k.byteOffset}:`),s&&(T+=`${k.startLine+1}:`),h&&(T+=`${k.column}:`),z.push(T+v);for(let L=k.startLine;L<=k.endLine;L++)F.add(L),R=L}else for(let v=k.startLine;v<=k.endLine&&v<b;v++)if(!F.has(v)){F.add(v),R=v;let T=w[v];d!==null&&v===k.startLine&&(t.lastIndex=0,T=t.replace(T,d));let L=o?`${o}:`:"";m&&v===k.startLine&&(L+=`${k.byteOffset}:`),s&&(L+=`${v+1}:`),h&&v===k.startLine&&(L+=`${k.column}:`),z.push(L+T)}for(let v=k.endLine+1;v<=P;v++)if(!F.has(v)){F.add(v),R=v;let T=w[v];s&&(T=`${v+1}-${T}`),o&&(T=`${o}-${T}`),z.push(T)}}return{output:z.length>0?`${z.join(`
|
|
189
189
|
`)}
|
|
190
|
-
`:"",matched:!0,matchCount:O.length}}var Wf=I(()=>{"use strict"});function Bf(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),a=Sy.get(i);if(a){r+=a,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 is(e,t){let n,r;switch(t.mode){case"fixed":n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":{if(n=Bf(e),n=n.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),t.mode==="perl"){n=Cy(n),n=Ny(n),n=ky(n);let a=Oy(n);n=a.pattern,r=a.kResetGroup}break}default:n=Bf(e),n=Py(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 Cy(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 Ny(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function ky(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]||"",a=r[3];if(a===":"){let o=n+r[0].length-1,l=vy(e,n);if(l!==-1){let c=e.slice(o+1,l),u=Iy(c,s,i);t+=`(?:${u})`,n=l+1;continue}}else if(a===")"||a===""){n+=r[0].length;continue}}}t+=e[n],n++}return t}function vy(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 Iy(e,t,n){let r=e;return t.includes("i")&&(r=$y(r)),r}function $y(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],a=e[n+1];s.push("-"),s.push(a),/[a-z]/.test(i)&&/[a-z]/.test(a)?(s.push(i.toUpperCase()),s.push("-"),s.push(a.toUpperCase())):/[A-Z]/.test(i)&&/[A-Z]/.test(a)&&(s.push(i.toLowerCase()),s.push("-"),s.push(a.toLowerCase())),n+=2}else{let i=e[n];if(s.push(i),/[a-zA-Z]/.test(i)){let a=i===i.toLowerCase()?i.toUpperCase():i.toLowerCase();s.includes(a)||s.push(a)}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 Oy(e){let t=Ry(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),s=Ty(n);return{pattern:`(?:${n})(${r})`,kResetGroup:s+1}}function Ry(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 Ty(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 so(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 Py(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 a=e[n+1];if(a==="|"){t+="|",n+=2,r=!0;continue}if(a==="("){t+="(",n+=2,s++,r=!0;continue}if(a===")"){t+=")",n+=2,s=Math.max(0,s-1),r=!1;continue}if(a==="{"){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(a==="}"){t+="\\}",n+=2,r=!1;continue}t+=i+a,n+=2,r=!1;continue}if(i==="*"&&r){t+="\\*",n++;continue}if(i==="^"){if(r){t+="^",n++;continue}t+="\\^",n++;continue}if(i==="$"){let a=n===e.length-1,o=n+2<e.length&&e[n+1]==="\\"&&e[n+2]===")";a||o?t+="$":t+="\\$",n++,r=!1;continue}i==="+"||i==="?"||i==="|"||i==="("||i===")"||i==="{"||i==="}"?t+=`\\${i}`:t+=i,n++,r=!1}return t}var Sy,zf=I(()=>{"use strict";Me();Sy=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 io=I(()=>{"use strict";Wf();zf()});var ni={};K(ni,{egrepCommand:()=>Fy,egrepFlagsForFuzzing:()=>Wy,fgrepCommand:()=>Ly,fgrepFlagsForFuzzing:()=>Uy,flagsForFuzzing:()=>My,grepCommand:()=>ao});async function Hf(e,t,n,r){let s=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(s)).isDirectory){let o=e.split("/").pop()||"";if(t){let l=t.replace(/^\//,"");xt(o,l,{stripQuotes:!0})&&r.push(e)}return}let a=await n.fs.readdir(s);for(let o of a){let l=e==="."?o:`${e}/${o}`,c=n.fs.resolvePath(n.cwd,l);if((await n.fs.stat(c)).isDirectory)await Hf(l,t,n,r);else if(t){let f=t.replace(/^\//,"");xt(o,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function _y(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 o=[],l=e.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await Hf(c,u,t,o),o.map(f=>({path:f}))}let a=t.fs.resolvePath(t.cwd,s);try{if(t.fs.readdirWithFileTypes){let o=await t.fs.readdirWithFileTypes(a);for(let l of o)if(xt(l.name,i,{stripQuotes:!0})){let c=r===-1?l.name:`${s}/${l.name}`;n.push({path:c,isFile:l.isFile})}}else{let o=await t.fs.readdir(a);for(let l of o)if(xt(l,i,{stripQuotes:!0})){let c=r===-1?l:`${s}/${l}`;n.push({path:c})}}}catch{}return n.sort((o,l)=>o.path.localeCompare(l.path))}async function ti(e,t,n=[],r=[],s=[],i){let a=t.fs.resolvePath(t.cwd,e),o=[];try{let l,c;if(i!==void 0)l=i,c=!i;else{let f=await t.fs.stat(a);l=f.isFile,c=f.isDirectory}if(l){let f=e.split("/").pop()||e;return r.length>0&&r.some(p=>xt(f,p,{stripQuotes:!0}))?[]:n.length>0&&!n.some(p=>xt(f,p,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!c)return[];let u=e.split("/").pop()||e;if(s.length>0&&s.some(f=>xt(u,f,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let f=await t.fs.readdirWithFileTypes(a);for(let p of f){if(p.name.startsWith("."))continue;let h=e==="."?p.name:`${e}/${p.name}`,m=await ti(h,t,n,r,s,p.isFile);o.push(...m)}}else{let f=await t.fs.readdir(a);for(let p of f){if(p.startsWith("."))continue;let h=e==="."?p:`${e}/${p}`,m=await ti(h,t,n,r,s);o.push(...m)}}}catch{}return o}var Dy,ao,Ly,Fy,My,Uy,Wy,ri=I(()=>{"use strict";ro();se();io();Dy={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"]},ao={name:"grep",async execute(e,t){if(U(e))return M(Dy);let n=!1,r=!1,s=!1,i=!1,a=!1,o=!1,l=!1,c=!1,u=!1,f=!1,p=!1,h=!1,m=!1,d=!1,g=!1,w=0,y=0,b=0,x=[],S=[],$=[],O=null,F=[];for(let H=0;H<e.length;H++){let X=e[H];if(X.startsWith("-")&&X!=="-"){if(X==="-e"&&H+1<e.length){O=e[++H];continue}if(X.startsWith("--include=")){x.push(X.slice(10));continue}if(X.startsWith("--exclude=")){S.push(X.slice(10));continue}if(X.startsWith("--exclude-dir=")){$.push(X.slice(14));continue}if(X.startsWith("--max-count=")){w=parseInt(X.slice(12),10);continue}let Ee=X.match(/^-m(\d+)$/);if(Ee){w=parseInt(Ee[1],10);continue}if(X==="-m"&&H+1<e.length){w=parseInt(e[++H],10);continue}let ae=X.match(/^-([ABC])(\d+)$/);if(ae){let j=parseInt(ae[2],10);ae[1]==="A"?b=j:ae[1]==="B"?y=j:ae[1]==="C"&&(y=j,b=j);continue}if((X==="-A"||X==="-B"||X==="-C")&&H+1<e.length){let j=parseInt(e[++H],10);X==="-A"?b=j:X==="-B"?y=j:(y=j,b=j);continue}let ke=X.startsWith("--")?[X]:X.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")a=!0;else if(j==="L"||j==="--files-without-match")o=!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")p=!0;else if(j==="F"||j==="--fixed-strings")h=!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 Y("grep",j);if(j.length===1)return Y("grep",`-${j}`)}}else O===null?O=X:F.push(X)}if(O===null)return{stdout:"",stderr:`grep: missing pattern
|
|
190
|
+
`:"",matched:!0,matchCount:O.length}}var Wf=I(()=>{"use strict"});function Bf(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),a=Sy.get(i);if(a){r+=a,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 is(e,t){let n,r;switch(t.mode){case"fixed":n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");break;case"extended":case"perl":{if(n=Bf(e),n=n.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),t.mode==="perl"){n=Cy(n),n=Ny(n),n=ky(n);let a=Oy(n);n=a.pattern,r=a.kResetGroup}break}default:n=Bf(e),n=Py(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 Cy(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 Ny(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function ky(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]||"",a=r[3];if(a===":"){let o=n+r[0].length-1,l=vy(e,n);if(l!==-1){let c=e.slice(o+1,l),u=Iy(c,s,i);t+=`(?:${u})`,n=l+1;continue}}else if(a===")"||a===""){n+=r[0].length;continue}}}t+=e[n],n++}return t}function vy(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 Iy(e,t,n){let r=e;return t.includes("i")&&(r=$y(r)),r}function $y(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],a=e[n+1];s.push("-"),s.push(a),/[a-z]/.test(i)&&/[a-z]/.test(a)?(s.push(i.toUpperCase()),s.push("-"),s.push(a.toUpperCase())):/[A-Z]/.test(i)&&/[A-Z]/.test(a)&&(s.push(i.toLowerCase()),s.push("-"),s.push(a.toLowerCase())),n+=2}else{let i=e[n];if(s.push(i),/[a-zA-Z]/.test(i)){let a=i===i.toLowerCase()?i.toUpperCase():i.toLowerCase();s.includes(a)||s.push(a)}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 Oy(e){let t=Ry(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),s=Ty(n);return{pattern:`(?:${n})(${r})`,kResetGroup:s+1}}function Ry(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 Ty(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 so(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 Py(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 a=e[n+1];if(a==="|"){t+="|",n+=2,r=!0;continue}if(a==="("){t+="(",n+=2,s++,r=!0;continue}if(a===")"){t+=")",n+=2,s=Math.max(0,s-1),r=!1;continue}if(a==="{"){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(a==="}"){t+="\\}",n+=2,r=!1;continue}t+=i+a,n+=2,r=!1;continue}if(i==="*"&&r){t+="\\*",n++;continue}if(i==="^"){if(r){t+="^",n++;continue}t+="\\^",n++;continue}if(i==="$"){let a=n===e.length-1,o=n+2<e.length&&e[n+1]==="\\"&&e[n+2]===")";a||o?t+="$":t+="\\$",n++,r=!1;continue}i==="+"||i==="?"||i==="|"||i==="("||i===")"||i==="{"||i==="}"?t+=`\\${i}`:t+=i,n++,r=!1}return t}var Sy,zf=I(()=>{"use strict";Me();Sy=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 io=I(()=>{"use strict";Wf();zf()});var ni={};K(ni,{egrepCommand:()=>Fy,egrepFlagsForFuzzing:()=>Wy,fgrepCommand:()=>Ly,fgrepFlagsForFuzzing:()=>Uy,flagsForFuzzing:()=>My,grepCommand:()=>ao});async function Hf(e,t,n,r){let s=n.fs.resolvePath(n.cwd,e);try{if(!(await n.fs.stat(s)).isDirectory){let o=e.split("/").pop()||"";if(t){let l=t.replace(/^\//,"");bt(o,l,{stripQuotes:!0})&&r.push(e)}return}let a=await n.fs.readdir(s);for(let o of a){let l=e==="."?o:`${e}/${o}`,c=n.fs.resolvePath(n.cwd,l);if((await n.fs.stat(c)).isDirectory)await Hf(l,t,n,r);else if(t){let f=t.replace(/^\//,"");bt(o,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function _y(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 o=[],l=e.split("**"),c=l[0].replace(/\/$/,"")||".",u=l[1]||"";return await Hf(c,u,t,o),o.map(f=>({path:f}))}let a=t.fs.resolvePath(t.cwd,s);try{if(t.fs.readdirWithFileTypes){let o=await t.fs.readdirWithFileTypes(a);for(let l of o)if(bt(l.name,i,{stripQuotes:!0})){let c=r===-1?l.name:`${s}/${l.name}`;n.push({path:c,isFile:l.isFile})}}else{let o=await t.fs.readdir(a);for(let l of o)if(bt(l,i,{stripQuotes:!0})){let c=r===-1?l:`${s}/${l}`;n.push({path:c})}}}catch{}return n.sort((o,l)=>o.path.localeCompare(l.path))}async function ti(e,t,n=[],r=[],s=[],i){let a=t.fs.resolvePath(t.cwd,e),o=[];try{let l,c;if(i!==void 0)l=i,c=!i;else{let f=await t.fs.stat(a);l=f.isFile,c=f.isDirectory}if(l){let f=e.split("/").pop()||e;return r.length>0&&r.some(p=>bt(f,p,{stripQuotes:!0}))?[]:n.length>0&&!n.some(p=>bt(f,p,{stripQuotes:!0}))?[]:[{path:e,isFile:!0}]}if(!c)return[];let u=e.split("/").pop()||e;if(s.length>0&&s.some(f=>bt(u,f,{stripQuotes:!0})))return[];if(t.fs.readdirWithFileTypes){let f=await t.fs.readdirWithFileTypes(a);for(let p of f){if(p.name.startsWith("."))continue;let h=e==="."?p.name:`${e}/${p.name}`,m=await ti(h,t,n,r,s,p.isFile);o.push(...m)}}else{let f=await t.fs.readdir(a);for(let p of f){if(p.startsWith("."))continue;let h=e==="."?p:`${e}/${p}`,m=await ti(h,t,n,r,s);o.push(...m)}}}catch{}return o}var Dy,ao,Ly,Fy,My,Uy,Wy,ri=I(()=>{"use strict";ro();se();io();Dy={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"]},ao={name:"grep",async execute(e,t){if(U(e))return M(Dy);let n=!1,r=!1,s=!1,i=!1,a=!1,o=!1,l=!1,c=!1,u=!1,f=!1,p=!1,h=!1,m=!1,d=!1,g=!1,w=0,y=0,b=0,x=[],S=[],$=[],O=null,F=[];for(let H=0;H<e.length;H++){let X=e[H];if(X.startsWith("-")&&X!=="-"){if(X==="-e"&&H+1<e.length){O=e[++H];continue}if(X.startsWith("--include=")){x.push(X.slice(10));continue}if(X.startsWith("--exclude=")){S.push(X.slice(10));continue}if(X.startsWith("--exclude-dir=")){$.push(X.slice(14));continue}if(X.startsWith("--max-count=")){w=parseInt(X.slice(12),10);continue}let Ee=X.match(/^-m(\d+)$/);if(Ee){w=parseInt(Ee[1],10);continue}if(X==="-m"&&H+1<e.length){w=parseInt(e[++H],10);continue}let ae=X.match(/^-([ABC])(\d+)$/);if(ae){let j=parseInt(ae[2],10);ae[1]==="A"?b=j:ae[1]==="B"?y=j:ae[1]==="C"&&(y=j,b=j);continue}if((X==="-A"||X==="-B"||X==="-C")&&H+1<e.length){let j=parseInt(e[++H],10);X==="-A"?b=j:X==="-B"?y=j:(y=j,b=j);continue}let ke=X.startsWith("--")?[X]:X.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")a=!0;else if(j==="L"||j==="--files-without-match")o=!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")p=!0;else if(j==="F"||j==="--fixed-strings")h=!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 Y("grep",j);if(j.length===1)return Y("grep",`-${j}`)}}else O===null?O=X:F.push(X)}if(O===null)return{stdout:"",stderr:`grep: missing pattern
|
|
191
191
|
`,exitCode:2};let R=h?"fixed":f?"extended":p?"perl":"basic",z,k;try{let H=is(O,{mode:R,ignoreCase:n,wholeWord:c,lineRegexp:u});z=H.regex,k=H.kResetGroup}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${O}
|
|
192
192
|
`,exitCode:2}}if(F.length===0&&t.stdin!==void 0){let H=Ar(t.stdin,z,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:"",onlyMatching:m,beforeContext:y,afterContext:b,maxCount:w,kResetGroup:k});return g?{stdout:"",stderr:"",exitCode:H.matched?0:1}:{stdout:H.output,stderr:"",exitCode:H.matched?0:1}}if(F.length===0)return{stdout:"",stderr:`grep: no input files
|
|
193
|
-
`,exitCode:2};let N="",P="",v=!1,T=!1,L=[];for(let H of F)if(H.includes("*")||H.includes("?")||H.includes("[")){let X=await _y(H,t);if(l)for(let Ee of X){let ae=await ti(Ee.path,t,x,S,$,Ee.isFile);L.push(...ae)}else L.push(...X)}else if(l){let X=await ti(H,t,x,S,$);L.push(...X)}else L.push({path:H});let ue=(L.length>1||l)&&!d,re=50;for(let H=0;H<L.length;H+=re){let X=L.slice(H,H+re),Ee=await Promise.all(X.map(async ae=>{let ke=ae.path,j=ke.split("/").pop()||ke;if(S.length>0&&!l&&S.some(ve=>
|
|
193
|
+
`,exitCode:2};let N="",P="",v=!1,T=!1,L=[];for(let H of F)if(H.includes("*")||H.includes("?")||H.includes("[")){let X=await _y(H,t);if(l)for(let Ee of X){let ae=await ti(Ee.path,t,x,S,$,Ee.isFile);L.push(...ae)}else L.push(...X)}else if(l){let X=await ti(H,t,x,S,$);L.push(...X)}else L.push({path:H});let ue=(L.length>1||l)&&!d,re=50;for(let H=0;H<L.length;H+=re){let X=L.slice(H,H+re),Ee=await Promise.all(X.map(async ae=>{let ke=ae.path,j=ke.split("/").pop()||ke;if(S.length>0&&!l&&S.some(ve=>bt(j,ve,{stripQuotes:!0}))||x.length>0&&!l&&!x.some(ve=>bt(j,ve,{stripQuotes:!0})))return null;try{let ve=t.fs.resolvePath(t.cwd,ke),Fe=!1;if(ae.isFile===void 0?Fe=(await t.fs.stat(ve)).isDirectory:Fe=!ae.isFile,Fe)return l?null:{error:`grep: ${ke}: Is a directory
|
|
194
194
|
`};let je=await t.fs.readFile(ve),et=Ar(je,z,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:ue?ke:"",onlyMatching:m,beforeContext:y,afterContext:b,maxCount:w,kResetGroup:k});return{file:ke,result:et}}catch{return{error:`grep: ${ke}: No such file or directory
|
|
195
195
|
`}}}));for(let ae of Ee){if(ae===null)continue;if("error"in ae&&ae.error){P+=ae.error,ae.error.includes("Is a directory")||(T=!0);continue}if(!("file"in ae)||!ae.result)continue;let{file:ke,result:j}=ae;if(j.matched){if(v=!0,g)return{stdout:"",stderr:"",exitCode:0};a?N+=`${ke}
|
|
196
196
|
`:o||(N+=j.output)}else o?N+=`${ke}
|
|
@@ -323,12 +323,12 @@ Addresses:
|
|
|
323
323
|
`)&&(p+=`
|
|
324
324
|
`),p+=d}try{let m=await yo(p,l,f,{limits:t.limits,filename:o.length===1?o[0]:void 0,fs:t.fs,cwd:t.cwd,coverage:t.coverage});return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage}
|
|
325
325
|
`:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof te)return{stdout:"",stderr:`sed: ${m.message}
|
|
326
|
-
`,exitCode:te.EXIT_CODE};throw m}}},b4={name:"sed",flags:[{flag:"-n",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-E",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-e",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function
|
|
326
|
+
`,exitCode:te.EXIT_CODE};throw m}}},b4={name:"sed",flags:[{flag:"-n",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-E",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-e",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function xt(e){return Object.assign(Object.create(null),Object.fromEntries(e))}function nn(e,t){return Object.assign(Object.create(null),Object.fromEntries(e),t)}function ai(...e){return Object.assign(Object.create(null),...e)}var Pn=I(()=>{"use strict"});function wo(e={}){let{fieldSep:t=A4,maxIterations:n=x4,maxRecursionDepth:r=E4,maxOutputSize:s=0,fs:i,cwd:a,exec:o,coverage:l}=e;return{FS:" ",OFS:" ",ORS:`
|
|
327
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,maxOutputSize:s,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:"",openedFiles:new Set,fs:i,cwd:a,exec:o,coverage:l}}var x4,E4,A4,y1=I(()=>{"use strict";Me();x4=1e4,E4=100,A4=new Cn(/\s+/)});function w1(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 b1=I(()=>{"use strict"});function Zt(e){if(typeof e=="number")return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function ut(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}async function oi(e,t){if(e.type==="regex")return e.pattern;let n=ut(await t.evalExpr(e));return n.startsWith("/")&&n.endsWith("/")&&(n=n.slice(1,-1)),n}async function E1(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(Zt(await t.evalExpr(e.index)))}`:"$0":"$0"}function A1(e,t){if(e==="$0")return t.line;if(e.startsWith("$")){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||""}return ut(t.vars[e]??"")}function S1(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 S4(e,t,n){return e.length===0?t.line.length:ut(await n.evalExpr(e[0])).length}async function C4(e,t,n){if(e.length<2)return"";let r=ut(await n.evalExpr(e[0])),s=Math.floor(Zt(await n.evalExpr(e[1])))-1;if(e.length>=3){let i=Math.floor(Zt(await n.evalExpr(e[2])));return r.substr(Math.max(0,s),i)}return r.substr(Math.max(0,s))}async function N4(e,t,n){if(e.length<2)return 0;let r=ut(await n.evalExpr(e[0])),s=ut(await n.evalExpr(e[1])),i=r.indexOf(s);return i===-1?0:i+1}async function k4(e,t,n){if(e.length<2)return 0;let r=ut(await n.evalExpr(e[0])),s=e[1];if(s.type!=="variable")return 0;let i=s.name,a=t.FS;if(e.length>=3){let l=e[2];if(l.type==="regex")a=V(l.pattern);else{let c=ut(await n.evalExpr(l));a=c===" "?V("\\s+"):c}}else t.FS===" "&&(a=V("\\s+"));let o=typeof a=="string"?r.split(a):a.split(r);t.arrays[i]=Object.create(null);for(let l=0;l<o.length;l++)t.arrays[i][String(l+1)]=o[l];return o.length}async function v4(e,t,n){if(e.length<2)return 0;let r=await oi(e[0],n),s=ut(await n.evalExpr(e[1])),i=await E1(e[2],n),a=A1(i,t);try{let l=V(r).replace(a,C1(s)),c=l!==a?1:0;return S1(i,l,t),c}catch{return 0}}async function I4(e,t,n){if(e.length<2)return 0;let r=await oi(e[0],n),s=ut(await n.evalExpr(e[1])),i=await E1(e[2],n),a=A1(i,t);try{let o=V(r,"g"),l=o.match(a),c=l?l.length:0,u=o.replace(a,C1(s));return S1(i,u,t),c}catch{return 0}}function C1(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 $4(e,t,n){if(e.length<2)return t.RSTART=0,t.RLENGTH=-1,0;let r=ut(await n.evalExpr(e[0])),s=await oi(e[1],n);try{let a=V(s).exec(r);if(a)return t.RSTART=a.index+1,t.RLENGTH=a[0].length,t.RSTART}catch{}return t.RSTART=0,t.RLENGTH=-1,0}async function O4(e,t,n){if(e.length<3)return"";let r=await oi(e[0],n),s=ut(await n.evalExpr(e[1])),i=ut(await n.evalExpr(e[2])),a=e.length>=4?ut(await n.evalExpr(e[3])):t.line;try{let o=i.toLowerCase()==="g",l=o?0:parseInt(i,10)||1;if(o)return V(r,"g").replace(a,(u,...f)=>x1(s,u,f.slice(0,-2)));{let c=0;return V(r,"g").replace(a,(f,...p)=>(c++,c===l?x1(s,f,p.slice(0,-2)):f))}}catch{return a}}function x1(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 a=parseInt(i,10)-1;r+=n[a]||"",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 R4(e,t,n){return e.length===0?"":ut(await n.evalExpr(e[0])).toLowerCase()}async function T4(e,t,n){return e.length===0?"":ut(await n.evalExpr(e[0])).toUpperCase()}async function P4(e,t,n){if(e.length===0)return"";let r=ut(await n.evalExpr(e[0])),s=[];for(let i=1;i<e.length;i++)s.push(await n.evalExpr(e[i]));return li(r,s)}async function D4(e,t,n){return e.length===0?0:Math.floor(Zt(await n.evalExpr(e[0])))}async function _4(e,t,n){return e.length===0?0:Math.sqrt(Zt(await n.evalExpr(e[0])))}async function L4(e,t,n){return e.length===0?0:Math.sin(Zt(await n.evalExpr(e[0])))}async function F4(e,t,n){return e.length===0?0:Math.cos(Zt(await n.evalExpr(e[0])))}async function M4(e,t,n){let r=e.length>0?Zt(await n.evalExpr(e[0])):0,s=e.length>1?Zt(await n.evalExpr(e[1])):0;return Math.atan2(r,s)}async function U4(e,t,n){return e.length===0?0:Math.log(Zt(await n.evalExpr(e[0])))}async function W4(e,t,n){return e.length===0?1:Math.exp(Zt(await n.evalExpr(e[0])))}function B4(e,t,n){return t.random?t.random():Math.random()}async function z4(e,t,n){let r=e.length>0?Zt(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=r,r}function H4(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function bo(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}function li(e,t){let n=0,r="",s=0;for(;s<e.length;)if(e[s]==="%"&&s+1<e.length){let i=s+1,a="",o="",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]);)a+=e[i++];if(e[i]==="*"){let d=t[n++],g=d!==void 0?Math.floor(Number(d)):0;g<0?(a+="-",o=String(Math.min(-g,Qn))):o=String(Math.min(g,Qn)),i++}else for(;i<e.length&&/\d/.test(e[i]);)o+=e[i++];if(o&&parseInt(o,10)>Qn&&(o=String(Qn)),e[i]==="."){if(i++,e[i]==="*"){let d=t[n++];l=String(Math.min(d!==void 0?Math.floor(Number(d)):0,Qn)),i++}else for(;i<e.length&&/\d/.test(e[i]);)l+=e[i++];l&&parseInt(l,10)>Qn&&(l=String(Qn))}f();let p=e[i],m=t[c!==void 0?c:n];switch(p){case"s":{let d=m!==void 0?String(m):"";if(l&&(d=d.substring(0,parseInt(l,10))),o){let g=parseInt(o,10);a.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,w=Math.abs(d).toString();if(l){let x=parseInt(l,10);w=w.padStart(x,"0")}let y="";g?y="-":a.includes("+")?y="+":a.includes(" ")&&(y=" ");let b=y+w;if(o){let x=parseInt(o,10);a.includes("-")?b=b.padEnd(x):a.includes("0")&&!l?b=y+w.padStart(x-y.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,w=d.toFixed(g);if(o){let y=parseInt(o,10);a.includes("-")?w=w.padEnd(y):w=w.padStart(y)}r+=w,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,w=d.toExponential(g);if(p==="E"&&(w=w.toUpperCase()),o){let y=parseInt(o,10);a.includes("-")?w=w.padEnd(y):w=w.padStart(y)}r+=w,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,w=d!==0?Math.floor(Math.log10(Math.abs(d))):0,y;if(d===0?y="0":w<-4||w>=g?(y=d.toExponential(g-1),p==="G"&&(y=y.toUpperCase())):y=d.toPrecision(g),y.includes(".")&&(y=y.replace(/\.?0+$/,"").replace(/\.?0+e/,"e")),y.includes("e")&&(y=y.replace(/\.?0+e/,"e")),o){let b=parseInt(o,10);a.includes("-")?y=y.padEnd(b):y=y.padStart(b)}r+=y,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(p==="X"&&(g=g.toUpperCase()),l){let b=parseInt(l,10);g=g.padStart(b,"0")}let w=d<0?"-":"",y=w+g;if(o){let b=parseInt(o,10);a.includes("-")?y=y.padEnd(b):a.includes("0")&&!l?y=w+g.padStart(b-w.length,"0"):y=y.padStart(b)}r+=y,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 w=d<0?"-":"",y=w+g;if(o){let b=parseInt(o,10);a.includes("-")?y=y.padEnd(b):a.includes("0")&&!l?y=w+g.padStart(b-w.length,"0"):y=y.padStart(b)}r+=y,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 Qn,N1,xo=I(()=>{"use strict";Me();Qn=1e4;N1=new Map([["length",S4],["substr",C4],["index",N4],["split",k4],["sub",v4],["gsub",I4],["match",$4],["gensub",O4],["tolower",R4],["toupper",T4],["sprintf",P4],["int",D4],["sqrt",_4],["sin",L4],["cos",F4],["atan2",M4],["log",U4],["exp",W4],["rand",B4],["srand",z4],["system",H4("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",bo("systime")],["mktime",bo("mktime")],["strftime",bo("strftime")]])});function
|
|
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 Qn,N1,xo=I(()=>{"use strict";Me();Qn=1e4;N1=new Map([["length",S4],["substr",C4],["index",N4],["split",k4],["sub",v4],["gsub",I4],["match",$4],["gensub",O4],["tolower",R4],["toupper",T4],["sprintf",P4],["int",D4],["sqrt",_4],["sin",L4],["cos",F4],["atan2",M4],["log",U4],["exp",W4],["rand",B4],["srand",z4],["system",H4("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",bo("systime")],["mktime",bo("mktime")],["strftime",bo("strftime")]])});function Et(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 $e(e){return typeof e=="string"?e:(Number.isInteger(e),String(e))}function Eo(e){if(typeof e=="number")return!0;let t=String(e).trim();return t===""?!1:!Number.isNaN(Number(t))}function cs(e,t){try{return V(e).test(t)}catch{return!1}}var Cr=I(()=>{"use strict";Me()});function k1(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function ci(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function Ao(e,t,n){if(t===0)e.line=$e(n),e.fields=k1(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push("");e.fields[t-1]=$e(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function Nr(e,t){e.line=t,e.fields=k1(e,t),e.NF=e.fields.length}function v1(e,t){if(e.FS=t,t===" ")e.fieldSep=new Cn(/\s+/);else try{e.fieldSep=V(t)}catch{e.fieldSep=V(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var ui=I(()=>{"use strict";Me();Cr()});function fi(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 kr(e,t,n){switch(t){case"FS":v1(e,$e(n));return;case"OFS":e.OFS=$e(n);return;case"ORS":e.ORS=$e(n);return;case"OFMT":e.OFMT=$e(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=$e(n);return;case"RSTART":e.RSTART=Math.floor(He(n));return;case"RLENGTH":e.RLENGTH=Math.floor(He(n));return;case"SUBSEP":e.SUBSEP=$e(n);return}e.vars[t]=n}function us(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 pi(e,t,n){if(t==="ARGV")return e.ARGV[n]??"";if(t==="ENVIRON")return e.ENVIRON[n]??"";let r=us(e,t);return e.arrays[r]?.[n]??""}function So(e,t,n,r){let s=us(e,t);e.arrays[s]||(e.arrays[s]=Object.create(null)),e.arrays[s][n]=r}function I1(e,t,n){if(t==="ARGV")return e.ARGV[n]!==void 0;if(t==="ENVIRON")return e.ENVIRON[n]!==void 0;let r=us(e,t);return e.arrays[r]?.[n]!==void 0}function $1(e,t,n){let r=us(e,t);e.arrays[r]&&delete e.arrays[r][n]}function O1(e,t){let n=us(e,t);delete e.arrays[n]}var Co=I(()=>{"use strict";ui();Cr()});function R1(e){No=e}async function le(e,t){switch(e.coverage?.hit(`awk:expr:${t.type}`),t.type){case"number":return t.value;case"string":return t.value;case"regex":return cs(t.pattern,e.line)?1:0;case"field":return j4(e,t);case"variable":return fi(e,t.name);case"array_access":return G4(e,t);case"binary":return V4(e,t);case"unary":return K4(e,t);case"ternary":return Et(await le(e,t.condition))?await le(e,t.consequent):await le(e,t.alternate);case"call":return Q4(e,t.name,t.args);case"assignment":return Y4(e,t);case"pre_increment":return J4(e,t.operand);case"pre_decrement":return e3(e,t.operand);case"post_increment":return t3(e,t.operand);case"post_decrement":return n3(e,t.operand);case"in":return r3(e,t.key,t.array);case"getline":return s3(e,t.variable,t.file,t.command);case"tuple":return o3(e,t.elements);default:return""}}async function j4(e,t){let n=Math.floor(He(await le(e,t.index)));return ci(e,n)}async function G4(e,t){let n=$e(await le(e,t.key));return pi(e,t.array,n)}async function V4(e,t){let n=t.operator;if(n==="||")return Et(await le(e,t.left))||Et(await le(e,t.right))?1:0;if(n==="&&")return Et(await le(e,t.left))&&Et(await le(e,t.right))?1:0;if(n==="~"){let o=await le(e,t.left);t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let l=t.right.type==="regex"?t.right.pattern:$e(await le(e,t.right));try{return V(l).test($e(o))?1:0}catch{return 0}}if(n==="!~"){let o=await le(e,t.left);t.right.type==="regex"&&e.coverage?.hit("awk:expr:regex");let l=t.right.type==="regex"?t.right.pattern:$e(await le(e,t.right));try{return V(l).test($e(o))?0:1}catch{return 1}}let r=await le(e,t.left),s=await le(e,t.right);if(n===" "){let o=$e(r)+$e(s);if(e.maxOutputSize>0&&o.length>e.maxOutputSize)throw new te(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output);return o}if(q4(n))return Z4(r,s,n);let i=He(r),a=He(s);return w1(i,a,n)}function q4(e){return["<","<=",">",">=","==","!="].includes(e)}function Z4(e,t,n){let r=Eo(e),s=Eo(t);if(r&&s){let o=He(e),l=He(t);switch(n){case"<":return o<l?1:0;case"<=":return o<=l?1:0;case">":return o>l?1:0;case">=":return o>=l?1:0;case"==":return o===l?1:0;case"!=":return o!==l?1:0}}let i=$e(e),a=$e(t);switch(n){case"<":return i<a?1:0;case"<=":return i<=a?1:0;case">":return i>a?1:0;case">=":return i>=a?1:0;case"==":return i===a?1:0;case"!=":return i!==a?1:0}return 0}async function K4(e,t){let n=await le(e,t.operand);switch(t.operator){case"!":return Et(n)?0:1;case"-":return-He(n);case"+":return+He(n);default:return n}}async function Q4(e,t,n){let r=N1.get(t);if(r)return r(n,e,{evalExpr:i=>le(e,i)});let s=e.functions.get(t);return s?X4(e,s,n):""}async function X4(e,t,n){if(e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new te(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,"recursion",e.output);let r=Object.create(null);for(let a of t.params)r[a]=e.vars[a];let s=[];for(let a=0;a<t.params.length;a++){let o=t.params[a];if(a<n.length){let l=n[a];l.type==="variable"&&(e.arrayAliases.set(o,l.name),s.push(o));let c=await le(e,l);e.vars[o]=c}else e.vars[o]=""}e.hasReturn=!1,e.returnValue=void 0,No&&await No(e,t.body.statements);let i=e.returnValue??"";for(let a of t.params)r[a]!==void 0?e.vars[a]=r[a]:delete e.vars[a];for(let a of s)e.arrayAliases.delete(a);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,i}async function Y4(e,t){let n=await le(e,t.value),r=t.target,s=t.operator,i;if(s==="=")i=n;else{let a;if(r.type==="field"){let c=Math.floor(He(await le(e,r.index)));a=ci(e,c)}else if(r.type==="variable")a=fi(e,r.name);else{let c=$e(await le(e,r.key));a=pi(e,r.array,c)}let o=He(a),l=He(n);switch(s){case"+=":i=o+l;break;case"-=":i=o-l;break;case"*=":i=o*l;break;case"/=":i=l!==0?o/l:0;break;case"%=":i=l!==0?o%l:0;break;case"^=":i=o**l;break;default:i=n}}if(r.type==="field"){let a=Math.floor(He(await le(e,r.index)));Ao(e,a,i)}else if(r.type==="variable")kr(e,r.name,i);else{let a=$e(await le(e,r.key));So(e,r.array,a,i)}return i}async function hi(e,t,n,r){let s;if(t.type==="field"){let i=Math.floor(He(await le(e,t.index)));s=He(ci(e,i)),Ao(e,i,s+n)}else if(t.type==="variable")s=He(fi(e,t.name)),kr(e,t.name,s+n);else{let i=$e(await le(e,t.key));s=He(pi(e,t.array,i)),So(e,t.array,i,s+n)}return r?s+n:s}async function J4(e,t){return hi(e,t,1,!0)}async function e3(e,t){return hi(e,t,-1,!0)}async function t3(e,t){return hi(e,t,1,!1)}async function n3(e,t){return hi(e,t,-1,!1)}async function r3(e,t,n){let r;if(t.type==="tuple"){e.coverage?.hit("awk:expr:tuple");let s=[];for(let i of t.elements)s.push($e(await le(e,i)));r=s.join(e.SUBSEP)}else r=$e(await le(e,t));return I1(e,n,r)?1:0}async function s3(e,t,n,r){if(r)return i3(e,t,r);if(n)return a3(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?kr(e,t,i):Nr(e,i),e.NR++,e.lineIndex=s,1}async function i3(e,t,n){if(!e.exec)return-1;let r=$e(await le(e,n)),s=`__cmd_${r}`,i=`__cmdi_${r}`,a,o;if(e.vars[s]===void 0)try{a=(await e.exec(r)).stdout.split(`
|
|
330
330
|
`),a.length>0&&a[a.length-1]===""&&a.pop(),e.vars[s]=JSON.stringify(a),e.vars[i]=-1,o=-1}catch{return-1}else a=JSON.parse(e.vars[s]),o=e.vars[i];let l=o+1;if(l>=a.length)return 0;let c=a[l];return e.vars[i]=l,t?kr(e,t,c):Nr(e,c),1}async function a3(e,t,n){if(!e.fs||!e.cwd)return-1;let r=$e(await le(e,n));if(r==="/dev/null")return 0;let s=e.fs.resolvePath(e.cwd,r),i=`__fc_${s}`,a=`__fi_${s}`,o,l;if(e.vars[i]===void 0)try{o=(await e.fs.readFile(s)).split(`
|
|
331
|
-
`),o.length>0&&o[o.length-1]===""&&o.pop(),e.vars[i]=JSON.stringify(o),e.vars[a]=-1,l=-1}catch{return-1}else o=JSON.parse(e.vars[i]),l=e.vars[a];let c=l+1;if(c>=o.length)return 0;let u=o[c];return e.vars[a]=c,t?kr(e,t,u):Nr(e,u),1}async function o3(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 No,ko=I(()=>{"use strict";ye();Me();b1();xo();ui();Cr();Co();No=null});function vo(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new te(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output)}async function vr(e,t){for(let n of t)if(await Xn(e,n),l3(e))break}function l3(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function Xn(e,t){switch(e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case"block":await vr(e,t.statements);break;case"expr_stmt":await le(e,t.expression);break;case"print":await c3(e,t.args,t.output);break;case"printf":await u3(e,t.format,t.args,t.output);break;case"if":await f3(e,t);break;case"while":await p3(e,t);break;case"do_while":await h3(e,t);break;case"for":await d3(e,t);break;case"for_in":await m3(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 g3(e,t.target);break}}async function c3(e,t,n){let r=[];for(let i of t){let a=await le(e,i);typeof a=="number"?Number.isInteger(a)&&Math.abs(a)<Number.MAX_SAFE_INTEGER?r.push(String(a)):r.push(li(e.OFMT,[a])):r.push($e(a))}let s=r.join(e.OFS)+e.ORS;n?await T1(e,n.redirect,n.file,s):(e.output+=s,vo(e))}async function u3(e,t,n,r){let s=$e(await le(e,t)),i=[];for(let o of n)i.push(await le(e,o));let a=li(s,i);r?await T1(e,r.redirect,r.file,a):(e.output+=a,vo(e))}async function T1(e,t,n,r){if(!e.fs||!e.cwd){e.output+=r,vo(e);return}let s=$e(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 f3(e,t){
|
|
331
|
+
`),o.length>0&&o[o.length-1]===""&&o.pop(),e.vars[i]=JSON.stringify(o),e.vars[a]=-1,l=-1}catch{return-1}else o=JSON.parse(e.vars[i]),l=e.vars[a];let c=l+1;if(c>=o.length)return 0;let u=o[c];return e.vars[a]=c,t?kr(e,t,u):Nr(e,u),1}async function o3(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 No,ko=I(()=>{"use strict";ye();Me();b1();xo();ui();Cr();Co();No=null});function vo(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new te(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,"string_length",e.output)}async function vr(e,t){for(let n of t)if(await Xn(e,n),l3(e))break}function l3(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function Xn(e,t){switch(e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case"block":await vr(e,t.statements);break;case"expr_stmt":await le(e,t.expression);break;case"print":await c3(e,t.args,t.output);break;case"printf":await u3(e,t.format,t.args,t.output);break;case"if":await f3(e,t);break;case"while":await p3(e,t);break;case"do_while":await h3(e,t);break;case"for":await d3(e,t);break;case"for_in":await m3(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 g3(e,t.target);break}}async function c3(e,t,n){let r=[];for(let i of t){let a=await le(e,i);typeof a=="number"?Number.isInteger(a)&&Math.abs(a)<Number.MAX_SAFE_INTEGER?r.push(String(a)):r.push(li(e.OFMT,[a])):r.push($e(a))}let s=r.join(e.OFS)+e.ORS;n?await T1(e,n.redirect,n.file,s):(e.output+=s,vo(e))}async function u3(e,t,n,r){let s=$e(await le(e,t)),i=[];for(let o of n)i.push(await le(e,o));let a=li(s,i);r?await T1(e,r.redirect,r.file,a):(e.output+=a,vo(e))}async function T1(e,t,n,r){if(!e.fs||!e.cwd){e.output+=r,vo(e);return}let s=$e(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 f3(e,t){Et(await le(e,t.condition))?await Xn(e,t.consequent):t.alternate&&await Xn(e,t.alternate)}async function p3(e,t){let n=0;for(;Et(await le(e,t.condition));){if(n++,n>e.maxIterations)throw new te(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await Xn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function h3(e,t){let n=0;do{if(n++,n>e.maxIterations)throw new te(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await Xn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(Et(await le(e,t.condition)))}async function d3(e,t){t.init&&await le(e,t.init);let n=0;for(;!t.condition||Et(await le(e,t.condition));){if(n++,n>e.maxIterations)throw new te(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,"iterations",e.output);if(e.loopContinue=!1,await Xn(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 m3(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 Xn(e,t.body),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function g3(e,t){if(t.type==="array_access"){let n=$e(await le(e,t.key));$1(e,t.array,n)}else t.type==="variable"&&O1(e,t.name)}var P1=I(()=>{"use strict";ye();xo();ko();Cr();Co();R1(vr)});var fs,D1=I(()=>{"use strict";ko();ui();P1();Cr();fs=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 vr(this.ctx,t.action.statements),this.ctx.shouldExit))break}}async executeLine(t){if(!(!this.program||this.ctx.shouldExit)){Nr(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 vr(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 vr(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 cs(r.pattern,this.ctx.line);case"expr_pattern":return Et(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 cs(t.pattern,this.ctx.line);case"expr_pattern":return Et(await le(this.ctx,t.expression));default:return!1}}}});var _1=I(()=>{"use strict";y1();D1()});function w3(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,y3,di,L1=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={}));y3=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]]);di=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===`
|
|
@@ -338,7 +338,7 @@ Addresses:
|
|
|
338
338
|
`)break;r+=this.advance()}return this.peek()==="/"&&this.advance(),r=w3(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=y3.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 B1(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(mi(e));e.check(Z.COMMA);)e.advance(),t.push(mi(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 mi(e){return b3(e)?Io(e,!0):Io(e,!1)}function Io(e,t){let n=t?e.parseTernary():x3(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=Io(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 b3(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 x3(e){let t=F1(e);for(;e.check(Z.OR);){e.advance();let n=F1(e);t={type:"binary",operator:"||",left:t,right:n}}return t}function F1(e){let t=M1(e);for(;e.check(Z.AND);){e.advance();let n=M1(e);t={type:"binary",operator:"&&",left:t,right:n}}return t}function M1(e){let t=E3(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 E3(e){let t=U1(e);for(;A3(e)&&!S3(e);){let n=U1(e);t={type:"binary",operator:" ",left:t,right:n}}return t}function U1(e){let t=W1(e);for(;e.match(Z.MATCH,Z.NOT_MATCH);){let n=e.advance().type===Z.MATCH?"~":"!~",r=W1(e);t={type:"binary",operator:n,left:t,right:r}}return t}function W1(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 A3(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 S3(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 z1(e){e.expect(Z.PRINTF);let t=e.check(Z.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():mi(e),r=[];for(;e.check(Z.COMMA);)e.advance(),t&&e.skipNewlines(),r.push(t?e.parseExpression():mi(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,H1=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 gi,j1=I(()=>{"use strict";L1();H1();gi=class{tokens=[];pos=0;parse(t){let n=new di(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)?B1(this):this.check(A.PRINTF)?z1(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 a=this.expect(A.IDENT).value;this.expect(A.RPAREN),this.skipNewlines();let o=this.parseStatement();return{type:"for_in",variable:i.value,array:a,body:o}}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,a)=>({type:"binary",operator:" ",left:{type:"binary",operator:" ",left:i,right:{type:"variable",name:"SUBSEP"}},right:a}));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 q1={};K(q1,{awkCommand2:()=>N3,flagsForFuzzing:()=>k3});function $o(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
|
|
339
339
|
`).replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\a/g,"\x07").replace(/\\v/g,"\v").replace(/\\\\/g,"\\")}function G1(e){if(e===" ")return V("\\s+");if(/[[\](){}.*+?^$|\\]/.test(e))try{return V(e)}catch{return V(V1(e))}return V(V1(e))}function V1(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var C3,N3,k3,Z1=I(()=>{"use strict";Pn();ye();Me();se();_1();j1();C3={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"]},N3={name:"awk",async execute(e,t){if(U(e))return M(C3);let n=new Cn(/\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=$o(e[++d]),n=G1(r),i=d+1;else if(g.startsWith("-F"))r=$o(g.slice(2)),n=G1(r),i=d+1;else if(g==="-v"&&d+1<e.length){let w=e[++d],y=w.indexOf("=");if(y>0){let b=w.slice(0,y),x=$o(w.slice(y+1));s[b]=x}i=d+1}else{if(g.startsWith("--"))return Y("awk",g);if(g.startsWith("-")&&g.length>1){let w=g[1];if(w!=="F"&&w!=="v")return Y("awk",`-${w}`);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 a=e[i],o=e.slice(i+1),l=new gi,c;try{c=l.parse(a)}catch(d){return{stdout:"",stderr:`awk: ${d instanceof Error?d.message:String(d)}
|
|
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 w=await t.fs.readFile(d);await t.fs.writeFile(d,w+g)}catch{await t.fs.writeFile(d,g)}},resolvePath:t.fs.resolvePath.bind(t.fs)},f=wo({fieldSep:n,maxIterations:t.limits?.maxAwkIterations,maxOutputSize:t.limits?.maxStringLength,fs:u,cwd:t.cwd,exec:t.exec?d=>t.exec(d,{cwd:t.cwd}):void 0,coverage:t.coverage});f.FS=r,f.vars=Object.assign(Object.create(null),s),f.ARGC=o.length+1,f.ARGV=Object.create(null),f.ARGV[0]="awk";for(let d=0;d<o.length;d++)f.ARGV[String(d+1)]=o[d];f.ENVIRON=
|
|
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 w=await t.fs.readFile(d);await t.fs.writeFile(d,w+g)}catch{await t.fs.writeFile(d,g)}},resolvePath:t.fs.resolvePath.bind(t.fs)},f=wo({fieldSep:n,maxIterations:t.limits?.maxAwkIterations,maxOutputSize:t.limits?.maxStringLength,fs:u,cwd:t.cwd,exec:t.exec?d=>t.exec(d,{cwd:t.cwd}):void 0,coverage:t.coverage});f.FS=r,f.vars=Object.assign(Object.create(null),s),f.ARGC=o.length+1,f.ARGV=Object.create(null),f.ARGV[0]="awk";for(let d=0;d<o.length;d++)f.ARGV[String(d+1)]=o[d];f.ENVIRON=xt(t.env);let p=new fs(f);p.execute(c);let h=c.rules.some(d=>d.pattern?.type!=="begin"&&d.pattern?.type!=="end"),m=c.rules.some(d=>d.pattern?.type==="end");try{if(await p.executeBegin(),f.shouldExit)return await p.executeEnd(),{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()};if(!h&&!m)return{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()};let d=[];if(o.length>0)for(let g of o)try{let w=t.fs.resolvePath(t.cwd,g),b=(await t.fs.readFile(w)).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
|
|
343
343
|
`,exitCode:1}}else{let g=t.stdin.split(`
|
|
344
344
|
`);g.length>0&&g[g.length-1]===""&&g.pop(),d.push({filename:"",lines:g})}for(let g of d){for(f.FILENAME=g.filename,f.FNR=0,f.lines=g.lines,f.lineIndex=-1,f.shouldNextFile=!1;f.lineIndex<g.lines.length-1&&(f.lineIndex++,await p.executeLine(g.lines[f.lineIndex]),!(f.shouldExit||f.shouldNextFile)););if(f.shouldExit)break}return await p.executeEnd(),{stdout:p.getOutput(),stderr:"",exitCode:p.getExitCode()}}catch(d){let g=d instanceof Error?d.message:String(d),w=d instanceof te?te.EXIT_CODE:2;return{stdout:p.getOutput(),stderr:`awk: ${g}
|
|
@@ -491,10 +491,10 @@ Try 'comm --help' for more information.
|
|
|
491
491
|
`)&&m[m.length-1]===""&&m.pop(),m.filter(d=>d.length>0).map(d=>H8(d,n.separator,h,n.ignoreCase))},o=a(i[0],n.field1),l=a(i[1],n.field2),c=new Map;for(let p of l){let h=c.get(p.joinKey);h?h.push(p):c.set(p.joinKey,[p])}let u=[],f=new Set;for(let p of o){let h=c.get(p.joinKey);if(h&&h.length>0){if(f.add(p.joinKey),n.onlyUnpairable.size===0)for(let m of h)u.push(Ro(p,m,n))}else(n.printUnpairable.has(1)||n.onlyUnpairable.has(1))&&u.push(Ro(p,null,n))}if(n.printUnpairable.has(2)||n.onlyUnpairable.has(2))for(let p of l)f.has(p.joinKey)||u.push(Ro(null,p,n));return{exitCode:0,stdout:u.length>0?`${u.join(`
|
|
492
492
|
`)}
|
|
493
493
|
`:"",stderr:""}}},V8={name:"join",flags:[{flag:"-1",type:"value",valueHint:"number"},{flag:"-2",type:"value",valueHint:"number"},{flag:"-t",type:"value",valueHint:"delimiter"},{flag:"-a",type:"value",valueHint:"number"},{flag:"-v",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"string"},{flag:"-o",type:"value",valueHint:"format"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2}});var jp={};K(jp,{flagsForFuzzing:()=>Q8,teeCommand:()=>K8});var q8,Z8,K8,Q8,Gp=I(()=>{"use strict";Ze();se();q8={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"]},Z8={append:{short:"a",long:"append",type:"boolean"}},K8={name:"tee",async execute(e,t){if(U(e))return M(q8);let n=be("tee",e,Z8);if(!n.ok)return n.error;let{append:r}=n.result.flags,s=n.result.positional,i=t.stdin,a="",o=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{a+=`tee: ${l}: No such file or directory
|
|
494
|
-
`,o=1}return{stdout:i,stderr:a,exitCode:o}}},Q8={name:"tee",flags:[{flag:"-a",type:"boolean"}],stdinType:"text",needsArgs:!0}});function Kt(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:
|
|
494
|
+
`,o=1}return{stdout:i,stderr:a,exitCode:o}}},Q8={name:"tee",flags:[{flag:"-a",type:"boolean"}],stdinType:"text",needsArgs:!0}});function Kt(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:bt(t.name,n,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let n=e.pattern,r=t.relativePath,s=n.split("/");for(let a=0;a<s.length-1;a++){let o=s[a];if(o&&o!=="."&&o!==".."&&!o.includes("*")&&!o.includes("?")&&!o.includes("[")){let l=`/${o}/`;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 a=i[1];if(e.ignoreCase){if(!r.toLowerCase().endsWith(a.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!r.endsWith(a))return{matches:!1,pruned:!1,printed:!1}}return{matches:bt(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=Kt(e.expr,t);return{matches:!n.matches,pruned:n.pruned,printed:!1}}case"and":{let n=Kt(e.left,t);if(!n.matches)return{matches:!1,pruned:n.pruned,printed:!1};let r=Kt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:n.printed||r.printed}}case"or":{let n=Kt(e.left,t);if(n.matches)return n;let r=Kt(e.right,t);return{matches:r.matches,pruned:n.pruned||r.pruned,printed:r.printed}}}}function ps(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 ps(e.expr);case"and":case"or":return ps(e.left)||ps(e.right)}}function hs(e){if(!e)return!1;switch(e.type){case"empty":return!0;case"not":return hs(e.expr);case"and":case"or":return hs(e.left)||hs(e.right);default:return!1}}function Vp(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=X8(e);if(Y8(e)&&n.length===1){let i=n[0].split("/").filter(a=>a.length>0);if(i.length>=2)for(let a=i.length-2;a>=0;a--){let o=i[a];if(!o.includes("*")&&!o.includes("?")&&!o.includes("[")&&o!=="."&&o!==".."){let l=i[a+1];if(l&&(l.includes("*")||l.includes("?"))){t.terminalDirName=o;let c=l.match(/^\*(\.[a-zA-Z0-9]+)$/);c&&(t.requiredExtension=c[1])}break}}}return t}function X8(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 Y8(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 qp(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 ds(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 ds(e.expr);case"and":case"or":return ds(e.left)&&ds(e.right)}}function Yn(e,t,n,r,s){switch(e.type){case"name":{let i=e.pattern,a=i.match(/^\*(\.[a-zA-Z0-9]+)$/);if(a){let o=a[1];if(e.ignoreCase){if(!t.toLowerCase().endsWith(o.toLowerCase()))return{matches:!1,pruned:!1,printed:!1}}else if(!t.endsWith(o))return{matches:!1,pruned:!1,printed:!1};return{matches:!0,pruned:!1,printed:!1}}return{matches:bt(t,i,e.ignoreCase),pruned:!1,printed:!1}}case"path":{let i=e.pattern,a=i.split("/");for(let l=0;l<a.length-1;l++){let c=a[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 o=i.match(/\*(\.[a-zA-Z0-9]+)$/);if(o){let l=o[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:bt(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=Yn(e.expr,t,n,r,s);return{matches:!i.matches,pruned:i.pruned,printed:!1}}case"and":{let i=Yn(e.left,t,n,r,s);if(!i.matches)return{matches:!1,pruned:i.pruned,printed:!1};let a=Yn(e.right,t,n,r,s);return{matches:a.matches,pruned:i.pruned||a.pruned,printed:i.printed||a.printed}}case"or":{let i=Yn(e.left,t,n,r,s);if(i.matches)return i;let a=Yn(e.right,t,n,r,s);return{matches:a.matches,pruned:i.pruned||a.pruned,printed:a.printed}}default:return{matches:!1,pruned:!1,printed:!1}}}function ms(e){if(!e)return!1;switch(e.type){case"prune":return!0;case"not":return ms(e.expr);case"and":case"or":return ms(e.left)||ms(e.right);default:return!1}}function Dn(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 Dn(e.expr);case"and":case"or":return Dn(e.left)&&Dn(e.right)}}function Zp(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!Dn(e))return To(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:Kt(e,n).pruned}}function To(e,t){switch(e.type){case"or":{if(Dn(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(Kt(e.left,n).pruned)return{shouldPrune:!0}}return To(e.right,t)}case"and":{if(Dn(e.left)&&Dn(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:Kt(e,n).pruned}}if(Dn(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 Kt(e.left,n).matches?To(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Kp=I(()=>{"use strict";Me();ro()});function Qp(e,t){let n=[],r=[],s=t;for(;s<e.length;){let a=e[s];if(a==="("||a==="\\("){n.push({type:"lparen"}),s++;continue}if(a===")"||a==="\\)"){n.push({type:"rparen"}),s++;continue}if(a==="-name"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s]}});else if(a==="-iname"&&s+1<e.length)n.push({type:"expr",expr:{type:"name",pattern:e[++s],ignoreCase:!0}});else if(a==="-path"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s]}});else if(a==="-ipath"&&s+1<e.length)n.push({type:"expr",expr:{type:"path",pattern:e[++s],ignoreCase:!0}});else if(a==="-regex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s]}});else if(a==="-iregex"&&s+1<e.length)n.push({type:"expr",expr:{type:"regex",pattern:e[++s],ignoreCase:!0}});else if(a==="-type"&&s+1<e.length){let o=e[++s];if(o==="f"||o==="d")n.push({type:"expr",expr:{type:"type",fileType:o}});else return{expr:null,pathIndex:s,error:`find: Unknown argument to -type: ${o}
|
|
495
495
|
`,actions:[]}}else if(a==="-empty")n.push({type:"expr",expr:{type:"empty"}});else if(a==="-mtime"&&s+1<e.length){let o=e[++s],l="exact",c=o;o.startsWith("+")?(l="more",c=o.slice(1)):o.startsWith("-")&&(l="less",c=o.slice(1));let u=parseInt(c,10);Number.isNaN(u)||n.push({type:"expr",expr:{type:"mtime",days:u,comparison:l}})}else if(a==="-newer"&&s+1<e.length){let o=e[++s];n.push({type:"expr",expr:{type:"newer",refPath:o}})}else if(a==="-size"&&s+1<e.length){let o=e[++s],l="exact",c=o;o.startsWith("+")?(l="more",c=o.slice(1)):o.startsWith("-")&&(l="less",c=o.slice(1));let u=c.match(/^(\d+)([ckMGb])?$/);if(u){let f=parseInt(u[1],10),p=u[2]||"b";n.push({type:"expr",expr:{type:"size",value:f,unit:p,comparison:l}})}}else if(a==="-perm"&&s+1<e.length){let o=e[++s],l="exact",c=o;o.startsWith("-")?(l="all",c=o.slice(1)):o.startsWith("/")&&(l="any",c=o.slice(1));let u=parseInt(c,8);Number.isNaN(u)||n.push({type:"expr",expr:{type:"perm",mode:u,matchType:l}})}else if(a==="-prune")n.push({type:"expr",expr:{type:"prune"}});else if(a==="-not"||a==="!")n.push({type:"not"});else if(a==="-o"||a==="-or")n.push({type:"op",op:"or"});else if(a==="-a"||a==="-and")n.push({type:"op",op:"and"});else if(a==="-maxdepth"||a==="-mindepth")s++;else if(a!=="-depth")if(a==="-exec"){let o=[];for(s++;s<e.length&&e[s]!==";"&&e[s]!=="+";)o.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:o,batchMode:l})}else if(a==="-print")n.push({type:"expr",expr:{type:"print"}}),r.push({type:"print"});else if(a==="-print0")r.push({type:"print0"});else if(a==="-printf"&&s+1<e.length){let o=e[++s];r.push({type:"printf",format:o})}else if(a==="-delete")r.push({type:"delete"});else{if(a.startsWith("-"))return{expr:null,pathIndex:s,error:`find: unknown predicate '${a}'
|
|
496
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 o=r();if(!o)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="or"){t++;let c=r();if(!c)return o;o={type:"or",left:o,right:c}}else break}return o}function r(){let o=s();if(!o)return null;for(;t<e.length;){let l=e[t];if(l.type==="op"&&l.op==="and"){t++;let c=s();if(!c)return o;o={type:"and",left:o,right:c}}else if(l.type==="expr"||l.type==="not"||l.type==="lparen"){let c=s();if(!c)return o;o={type:"and",left:o,right:c}}else break}return o}function s(){if(t<e.length&&e[t].type==="not"){t++;let o=s();return o?{type:"not",expr:o}:null}return i()}function i(){if(t>=e.length)return null;let o=e[t];if(o.type==="lparen"){t++;let l=n();return t<e.length&&e[t].type==="rparen"&&t++,l}return o.type==="expr"?(t++,o.expr):(o.type==="rparen",null)}return{expr:n()}}var Xp=I(()=>{"use strict"});var Jp={};K(Jp,{findCommand:()=>s9,flagsForFuzzing:()=>c9});function e9(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function t9(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 i9(e,t){let n=Vs(e),r="",s=0;for(;s<n.length;)if(n[s]==="%"&&s+1<n.length){if(s++,n[s]==="%"){r+="%",s++;continue}let[i,a,o]=Eu(n,s);if(s+=o,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=a9(t.mode,t.isDirectory),s++;break;case"t":{let u=new Date(t.mtime);c=o9(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(t.mtime);c=l9(f,u),s+=2}else c="%T",s++;break}default:r+=`%${i!==0||a!==-1?`${i}.${a}`:""}${l}`,s++;continue}r+=Gs(c,i,a)}else r+=n[s],s++;return r}function a9(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 o9(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," "),a=String(e.getHours()).padStart(2,"0"),o=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0"),c=e.getFullYear();return`${r} ${s} ${i} ${a}:${o}:${l} ${c}`}function l9(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 Yp,n9,r9,s9,c9,eh=I(()=>{"use strict";se();Ma();Kp();Xp();Yp=500;n9={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"]},r9=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),s9={name:"find",async execute(e,t){if(U(e))return M(n9);let n=[],r=null,s=null,i=!1,a=!1;for(let N=0;N<e.length;N++){let P=e[N];if(P==="-maxdepth"&&N+1<e.length)a=!0,r=parseInt(e[++N],10);else if(P==="-mindepth"&&N+1<e.length)a=!0,s=parseInt(e[++N],10);else if(P==="-depth")a=!0,i=!0;else if(P==="-exec")for(a=!0,N++;N<e.length&&e[N]!==";"&&e[N]!=="+";)N++;else!P.startsWith("-")&&P!==";"&&P!=="+"&&P!=="("&&P!==")"&&P!=="\\("&&P!=="\\)"&&P!=="!"?a||n.push(P):r9.has(P)?(a=!0,N++):(P.startsWith("-")||P==="("||P==="\\("||P==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:o,error:l,actions:c}=Qp(e,0);if(l)return{stdout:"",stderr:l,exitCode:1};let u=c.some(N=>N.type==="print"),f=c.length===0,p=[],h=c.some(N=>N.type==="printf"),m=[],d="",g=0,w=qp(o),y=new Map;for(let N of w){let P=t.fs.resolvePath(t.cwd,N);try{let v=await t.fs.stat(P);y.set(N,v.mtime?.getTime()??Date.now())}catch{}}let b=c.some(N=>{if(N.type!=="printf")return!1;let P=N.format.replace(/%%/g,"");return/%[-+]?[0-9]*\.?[0-9]*(s|m|M|t|T)/.test(P)}),x=ps(o)||b,S=hs(o),$=Vp(o),O=ms(o),F=ds(o),R=typeof t.fs.readdirWithFileTypes=="function";for(let N of n){let ue=function(H){let Ee=s===null||H.depth>=s,ae=!1;if(Ee&&o!==null){let j=Date.now(),ve;if(F)ve=Yn(o,H.name,H.relativePath,H.isFile,H.isDirectory);else{let Fe={name:H.name,relativePath:H.relativePath,isFile:H.isFile,isDirectory:H.isDirectory,isEmpty:H.isEmpty,mtime:H.stat?.mtime?.getTime()??Date.now(),size:H.stat?.size??0,mode:H.stat?.mode??420,newerRefTimes:y};ve=Kt(o,Fe)}Ee=ve.matches,ae=u?ve.printed:Ee,v.evalCalls++,v.evalTime+=Date.now()-j}else Ee&&(ae=!0);return ae?{print:!0,printfData:h?{path:H.relativePath,name:H.name,size:H.stat?.size??0,mtime:H.stat?.mtime?.getTime()??Date.now(),mode:H.stat?.mode??420,isDirectory:H.isDirectory,depth:H.depth,startingPoint:N}:null}:{print:!1,printfData:null}};var k=ue;N.length>1&&N.endsWith("/")&&(N=N.slice(0,-1));let P=t.fs.resolvePath(t.cwd,N);try{await t.fs.stat(P)}catch{d+=`find: ${N}: No such file or directory
|
|
497
|
-
`,g=1;continue}let v=e9(),T=Date.now();async function L(H){let{path:X,depth:Ee,typeInfo:ae}=H;if(v.nodeCount++,r!==null&&Ee>r)return null;let ke,j,ve;if(ae&&!x)ke=ae.isFile,j=ae.isDirectory;else{try{let Vn=Date.now();ve=await t.fs.stat(X),v.statCalls++,v.statTime+=Date.now()-Vn}catch{return null}if(!ve)return null;ke=ve.isFile,j=ve.isDirectory}let Fe;X===P?Fe=N.split("/").pop()||N:Fe=X.split("/").pop()||"";let je=X===P?N:N==="."?`./${X.slice(P==="/"?P.length:P.length+1)}`:N+X.slice(P.length),et=[],st=null,tt=null,nt=!1;j&&O&&!i&&(nt=Zp(o,{name:Fe,relativePath:je,isFile:ke,isDirectory:j}).shouldPrune,nt&&v.earlyPrunes++);let Ut=r!==null&&Ee>=r,Wt=$.terminalDirName!==null&&Fe===$.terminalDirName,ns=!Ut&&!Wt&&!nt;if(j&&((ns||S||Wt)&&!nt)){let Vn=Date.now();if(R&&t.fs.readdirWithFileTypes){if(st=await t.fs.readdirWithFileTypes(X),tt=st.map(
|
|
497
|
+
`,g=1;continue}let v=e9(),T=Date.now();async function L(H){let{path:X,depth:Ee,typeInfo:ae}=H;if(v.nodeCount++,r!==null&&Ee>r)return null;let ke,j,ve;if(ae&&!x)ke=ae.isFile,j=ae.isDirectory;else{try{let Vn=Date.now();ve=await t.fs.stat(X),v.statCalls++,v.statTime+=Date.now()-Vn}catch{return null}if(!ve)return null;ke=ve.isFile,j=ve.isDirectory}let Fe;X===P?Fe=N.split("/").pop()||N:Fe=X.split("/").pop()||"";let je=X===P?N:N==="."?`./${X.slice(P==="/"?P.length:P.length+1)}`:N+X.slice(P.length),et=[],st=null,tt=null,nt=!1;j&&O&&!i&&(nt=Zp(o,{name:Fe,relativePath:je,isFile:ke,isDirectory:j}).shouldPrune,nt&&v.earlyPrunes++);let Ut=r!==null&&Ee>=r,Wt=$.terminalDirName!==null&&Fe===$.terminalDirName,ns=!Ut&&!Wt&&!nt;if(j&&((ns||S||Wt)&&!nt)){let Vn=Date.now();if(R&&t.fs.readdirWithFileTypes){if(st=await t.fs.readdirWithFileTypes(X),tt=st.map(kt=>kt.name),v.readdirCalls++,v.readdirTime+=Date.now()-Vn,ns)et=st.map((kt,Vt)=>({path:X==="/"?`/${kt.name}`:`${X}/${kt.name}`,depth:Ee+1,typeInfo:{isFile:kt.isFile,isDirectory:kt.isDirectory},resultIndex:Vt}));else if(Wt){let kt=$.requiredExtension;et=st.filter(Vt=>Vt.isFile&&(!kt||Vt.name.endsWith(kt))).map((Vt,z6)=>({path:X==="/"?`/${Vt.name}`:`${X}/${Vt.name}`,depth:Ee+1,typeInfo:{isFile:Vt.isFile,isDirectory:Vt.isDirectory},resultIndex:z6}))}}else tt=await t.fs.readdir(X),v.readdirCalls++,v.readdirTime+=Date.now()-Vn,ns&&(et=tt.map((kt,Vt)=>({path:X==="/"?`/${kt}`:`${X}/${kt}`,depth:Ee+1,resultIndex:Vt})))}let Bs=ke?(ve?.size??0)===0:tt!==null&&tt.length===0,dr=nt;if(!i&&o!==null&&!nt&&O){let Vn=Date.now(),kt={name:Fe,relativePath:je,isFile:ke,isDirectory:j,isEmpty:Bs,mtime:ve?.mtime?.getTime()??Date.now(),size:ve?.size??0,mode:ve?.mode??420,newerRefTimes:y};dr=Kt(o,kt).pruned,v.evalCalls++,v.evalTime+=Date.now()-Vn}return{relativePath:je,name:Fe,isFile:ke,isDirectory:j,isEmpty:Bs,stat:ve,depth:Ee,children:dr?[]:et,pruned:dr}}async function re(){let H={paths:[],printfData:[]};if(i){let ve=function(Fe){let je={paths:[],printfData:[]},et=ae[Fe];if(!et)return je;for(let nt of et.childIndices){let Ut=ve(nt);je.paths.push(...Ut.paths),je.printfData.push(...Ut.printfData)}let{print:st,printfData:tt}=ue(et.node);return st&&(je.paths.push(et.node.relativePath),tt&&je.printfData.push(tt)),je};var X=ve;let ae=[],ke=[{item:{path:P,depth:0,resultIndex:0},parentIndex:-1,childOrderInParent:0}],j=new Map;for(;ke.length>0;){let Fe=Date.now(),je=ke.splice(0,Yp),et=await Promise.all(je.map(st=>L(st.item)));v.batchCount++,v.batchTime+=Date.now()-Fe;for(let st=0;st<je.length;st++){let tt=et[st],nt=je[st];if(!tt)continue;let Ut=ae.length;if(nt.parentIndex>=0){let Wt=j.get(nt.parentIndex)||[];Wt.push(Ut),j.set(nt.parentIndex,Wt)}ae.push({node:tt,parentIndex:nt.parentIndex,childIndices:[]});for(let Wt=0;Wt<tt.children.length;Wt++)ke.push({item:tt.children[Wt],parentIndex:Ut,childOrderInParent:Wt})}}for(let[Fe,je]of j)Fe>=0&&Fe<ae.length&&(ae[Fe].childIndices=je);if(ae.length>0){let Fe=ve(0);H.paths.push(...Fe.paths),H.printfData.push(...Fe.printfData)}}else{let Fe=function(je){let et=ae.get(je);et&&(H.paths.push(et.path),et.printfData&&H.printfData.push(et.printfData));let st=ve.get(je);if(st)for(let tt of st)Fe(tt)};var Ee=Fe;let ae=new Map,ke=0,j=[{item:{path:P,depth:0,resultIndex:0},orderIndex:ke++}],ve=new Map;for(;j.length>0;){let je=Date.now(),et=j.splice(0,Yp),st=await Promise.all(et.map(async({item:tt,orderIndex:nt})=>{let Ut=await L(tt);return Ut?{node:Ut,orderIndex:nt}:null}));v.batchCount++,v.batchTime+=Date.now()-je;for(let tt of st){if(!tt)continue;let{node:nt,orderIndex:Ut}=tt,{print:Wt,printfData:ns}=ue(nt);if(Wt&&ae.set(Ut,{path:nt.relativePath,printfData:ns}),nt.children.length>0){let La=[];for(let Bs of nt.children){let dr=ke++;La.push(dr),j.push({item:Bs,orderIndex:dr})}ve.set(Ut,La)}}}Fe(0)}return H}let ee=await re();if(p.push(...ee.paths),m.push(...ee.printfData),t.trace){let H=Date.now()-T;t9(t.trace,v,H),t.trace({category:"find",name:"searchPath",durationMs:H,details:{path:N,resultsFound:ee.paths.length}})}}let z="";if(c.length>0)for(let N of c)switch(N.type){case"print":z+=p.length>0?`${p.join(`
|
|
498
498
|
`)}
|
|
499
499
|
`:"";break;case"print0":z+=p.length>0?`${p.join("\0")}\0`:"";break;case"delete":{let P=[...p].sort((v,T)=>T.length-v.length);for(let v of P){let T=t.fs.resolvePath(t.cwd,v);try{await t.fs.rm(T,{recursive:!1})}catch(L){let ue=L instanceof Error?L.message:String(L);d+=`find: cannot delete '${v}': ${ue}
|
|
500
500
|
`,g=1}}break}case"printf":for(let P of m)z+=i9(N.format,P);break;case"exec":if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
@@ -543,8 +543,8 @@ ${o} director${o===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"
|
|
|
543
543
|
`,exitCode:1};let s=ai(r.exportedEnv||{},{0:t,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")});n.forEach((o,l)=>{s[String(l+1)]=o});let i=e;if(i.startsWith("#!")){let o=i.indexOf(`
|
|
544
544
|
`);o!==-1&&(i=i.slice(o+1))}return await r.exec(i,{env:s,cwd:r.cwd,stdin:r.stdin})}var wh,K9,Q9,X9,Y9,Wo=I(()=>{"use strict";Pn();se();wh={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).']},K9={name:"bash",async execute(e,t){if(U(e))return M(wh);if(e[0]==="-c"&&e.length>=2){let s=e[1],i=e[2]||"bash",a=e.slice(3);return $r(s,i,a,t)}if(e.length===0)return t.stdin?.trim()?$r(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 $r(i,n,r,t)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
|
|
545
545
|
`,exitCode:127}}}},Q9={name:"sh",async execute(e,t){if(U(e))return M({...wh,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",a=e.slice(3);return $r(s,i,a,t)}if(e.length===0)return t.stdin?.trim()?$r(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 $r(i,n,r,t)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
|
|
546
|
-
`,exitCode:127}}}};X9={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},Y9={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function Ie(e){return!bh.has(e)}function Pe(e,t,n){Ie(t)&&(e[t]=n)}function mn(e,t){return Object.hasOwn(e,t)}function Ke(e){return Object.assign(Object.create(null),e)}function Bo(...e){return Object.assign(Object.create(null),...e)}var bh,Ek,Nn=I(()=>{"use strict";bh=new Set(["__proto__","constructor","prototype"]),Ek=new Set([...bh,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function zo(e,t,n,r,s,i,a,o,l,c){switch(t){case"sort":return Array.isArray(e)?[[...e].sort(a)]:[null];case"sort_by":return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((f,p)=>{let h=s(f,n[0],r)[0],m=s(p,n[0],r)[0];return a(h,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 p=0,h=e.length;for(;p<h;){let m=p+h>>>1;a(e[m],f)<0?p=m+1:h=m}return p<e.length&&a(e[p],f)===0?p:-p-1})}case"unique_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let p of e){let h=s(p,n[0],r)[0],m=JSON.stringify(h);u.has(m)||u.set(m,{item:p,key:h})}let f=[...u.values()];return f.sort((p,h)=>a(p.key,h.key)),[f.map(p=>p.item)]}case"group_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let f of e){let p=JSON.stringify(s(f,n[0],r)[0]);u.has(p)||u.set(p,[]),u.get(p)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>a(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 p=s(u,n[0],r)[0],h=s(f,n[0],r)[0];return a(p,h)>0?u:f})];case"min":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>a(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 p=s(u,n[0],r)[0],h=s(f,n[0],r)[0];return a(p,h)<0?u:f})];case"add":{let u=f=>{let p=f.filter(h=>h!==null);return p.length===0?null:p.every(h=>typeof h=="number")?p.reduce((h,m)=>h+m,0):p.every(h=>typeof h=="string")?p.join(""):p.every(h=>Array.isArray(h))?p.flat():p.every(h=>h&&typeof h=="object"&&!Array.isArray(h))?ai(...p):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(o))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(e)?[e.some(u=>o(s(u,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(o)]:[!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(o))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(e)?[e.every(u=>o(s(u,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(o)]:[!0]}case"select":return n.length===0?[e]:s(e,n[0],r).some(o)?[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,p]of Object.entries(e)){if(!Ie(f))continue;let h=s(p,n[0],r);h.length>0&&Pe(u,f,h[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"?[mn(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"?[mn(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 xh=I(()=>{"use strict";Pn();Nn()});function Ho(e,t,n,r,s,i,a,o){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 o)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 o)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 p=[];for(let h of l){let m=h;for(let d=0;d<m;d++)p.push(d)}return p}let c=s(e,n[1],r);if(n.length===2){let p=[];for(let h of l)for(let m of c){let d=h,g=m;for(let w=d;w<g;w++)p.push(w)}return p}let u=s(e,n[2],r),f=[];for(let p of l)for(let h of c)for(let m of u){let d=p,g=h,w=m;if(w!==0)if(w>0)for(let y=d;y<g;y+=w)f.push(y);else for(let y=d;y>g;y+=w)f.push(y)}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(p){if(p instanceof o)throw p;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 o)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 o)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(a))return[l];let p=s(l,n[1],r);if(p.length===0)return[l];l=p[0]}throw new o(`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(a);f++){l.push(c);let h=s(c,n[1],r);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new o(`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 p=s(c,n[0],r);if(p.length===0)break;c=p[0]}if(l.length>=u)throw new o(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var Eh=I(()=>{"use strict"});function jo(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),a=i.getUTCFullYear(),o=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),p=i.getUTCDay(),h=Date.UTC(a,0,1),m=Math.floor((i.getTime()-h)/(1440*60*1e3));return[[a,o,l,c,u,f,p,m]]}case"mktime":{if(!Array.isArray(e))throw new Error("mktime requires parsed datetime inputs");let[i,a,o,l=0,c=0,u=0]=e;if(typeof i!="number"||typeof a!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,a,o??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let a=s(e,n[0],r)[0];if(typeof a!="string")throw new Error("strftime/1 requires a string format");let o;if(typeof e=="number")o=new Date(e*1e3);else if(Array.isArray(e)){let[p,h,m,d=0,g=0,w=0]=e;if(typeof p!="number"||typeof h!="number")throw new Error("strftime/1 requires parsed datetime inputs");o=new Date(Date.UTC(p,h,m??1,d??0,g??0,w??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=(p,h=2)=>String(p).padStart(h,"0");return[a.replace(/%Y/g,String(o.getUTCFullYear())).replace(/%m/g,u(o.getUTCMonth()+1)).replace(/%d/g,u(o.getUTCDate())).replace(/%H/g,u(o.getUTCHours())).replace(/%M/g,u(o.getUTCMinutes())).replace(/%S/g,u(o.getUTCSeconds())).replace(/%A/g,l[o.getUTCDay()]).replace(/%B/g,c[o.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 a=s(e,n[0],r)[0];if(typeof a!="string")throw new Error("strptime/1 requires a string format");if(a==="%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,p,h,m]=l.map(Number),d=new Date(Date.UTC(c,u-1,f,p,h,m)),g=d.getUTCDay(),w=Date.UTC(c,0,1),y=Math.floor((d.getTime()-w)/(1440*60*1e3));return[[c,u-1,f,p,h,m,g,y]]}}let o=new Date(e);if(!Number.isNaN(o.getTime())){let l=o.getUTCFullYear(),c=o.getUTCMonth(),u=o.getUTCDate(),f=o.getUTCHours(),p=o.getUTCMinutes(),h=o.getUTCSeconds(),m=o.getUTCDay(),d=Date.UTC(l,0,1),g=Math.floor((o.getTime()-d)/(1440*60*1e3));return[[l,c,u,f,p,h,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 Ah=I(()=>{"use strict"});function Qt(e){return e!==!1&&e!==null}function Or(e,t){return JSON.stringify(e)===JSON.stringify(t)}function gs(e,t){return typeof e=="number"&&typeof t=="number"?e-t:typeof e=="string"&&typeof t=="string"?e.localeCompare(t):0}function Go(e,t){let n=Ke(e);for(let r of Object.keys(t))Ie(r)&&(mn(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,Go(n[r],t[r])):Pe(n,r,t[r]));return n}function Rr(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 Ei(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 a=Ei(e[i],t[i]);if(a!==0)return a}return e.length-t.length}if(e&&t&&typeof e=="object"&&typeof t=="object"){let i=e,a=t,o=Object.keys(i).sort(),l=Object.keys(a).sort();for(let c=0;c<Math.min(o.length,l.length);c++){let u=o[c].localeCompare(l[c]);if(u!==0)return u}if(o.length!==l.length)return o.length-l.length;for(let c of o){let u=Ei(i[c],a[c]);if(u!==0)return u}}return 0}function Ai(e,t){if(Or(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=>Ai(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=>mn(n,s)&&Ai(n[s],r[s]))}return!1}var Si=I(()=>{"use strict";Nn()});function Vo(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??J9;return Rr(e,r+1)>r?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")]:[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 J9,Sh=I(()=>{"use strict";Si();J9=2e3});function qo(e,t,n,r,s,i){switch(t){case"index":return n.length===0?[null]:s(e,n[0],r).map(o=>{if(typeof e=="string"&&typeof o=="string"){if(o===""&&e==="")return null;let l=e.indexOf(o);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(o)){for(let c=0;c<=e.length-o.length;c++){let u=!0;for(let f=0;f<o.length;f++)if(!i(e[c+f],o[f])){u=!1;break}if(u)return c}return null}let l=e.findIndex(c=>i(c,o));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(e,n[0],r).map(o=>{if(typeof e=="string"&&typeof o=="string"){let l=e.lastIndexOf(o);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(o)){for(let l=e.length-o.length;l>=0;l--){let c=!0;for(let u=0;u<o.length;u++)if(!i(e[l+u],o[u])){c=!1;break}if(c)return l}return null}for(let l=e.length-1;l>=0;l--)if(i(e[l],o))return l;return null}return null});case"indices":return n.length===0?[[]]:s(e,n[0],r).map(o=>{let l=[];if(typeof e=="string"&&typeof o=="string"){let c=e.indexOf(o);for(;c!==-1;)l.push(c),c=e.indexOf(o,c+1)}else if(Array.isArray(e))if(Array.isArray(o)){let c=o.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 p=0;p<c;p++)if(!i(e[u+p],o[p])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<e.length;c++)i(e[c],o)&&l.push(c);return l});default:return null}}var Ch=I(()=>{"use strict"});function Zo(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),a=s(e,n[1],r),o=i[0],l=a[0];return typeof o!="number"||typeof l!="number"?[null]:[o**l]}case"atan2":{if(n.length<2)return[null];let i=s(e,n[0],r),a=s(e,n[1],r),o=i[0],l=a[0];return typeof o!="number"||typeof l!="number"?[null]:[Math.atan2(o,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],a=s(e,n[1],r)[0];return[e*i+a]}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 Nh=I(()=>{"use strict"});function Ko(e,t,n,r,s,i,a,o){switch(t){case"recurse":{if(n.length===0){let h=[],m=d=>{if(h.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),h}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,p=h=>{if(f++>u||c&&!s(h,c,r).some(i))return;l.push(h);let m=s(h,n[0],r);for(let d of m)d!=null&&p(d)};return p(e),l}case"recurse_down":return o(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 h=Object.create(null);for(let[m,d]of Object.entries(u))Ie(m)&&Pe(h,m,c(d));f=h}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 p=[],h=(m,d)=>{if(d===f){p.push([...m]);return}for(let g of e)m.push(g),h(m,d+1),m.pop()};return h([],0),p}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 p=e[u];for(let h of p)f.push(h),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[a(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[e];let f=l.slice(0,u);return[a(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(a(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var kh=I(()=>{"use strict";Nn()});function Qo(e,t,n,r,s){switch(t){case"keys":return Array.isArray(e)?[e.map((i,a)=>a)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((i,a)=>a)]: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,a=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${a}) only strings have UTF-8 byte length`)}case"to_entries":return e&&typeof e=="object"&&!Array.isArray(e)?[Object.entries(e).map(([i,a])=>({key:i,value:a}))]:[null];case"from_entries":if(Array.isArray(e)){let i=Object.create(null);for(let a of e)if(a&&typeof a=="object"){let o=a,l=o.key??o.Key??o.name??o.Name??o.k,c=o.value??o.Value??o.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 a=Object.entries(e).map(([l,c])=>({key:l,value:c})).flatMap(l=>s(l,n[0],r)),o=Object.create(null);for(let l of a)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 p=String(u);Ie(p)&&Pe(o,p,f)}}return[o]}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(a=>{let o=a;if(o<0)throw new Error("flatten depth must not be negative");return e.flat(o)}):[null];case"unique":if(Array.isArray(e)){let i=new Set,a=[];for(let o of e){let l=JSON.stringify(o);i.has(l)||(i.add(l),a.push(o))}return[a]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??e5;return Rr(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,a=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${a}) cannot be parsed as a boolean`)}case"tostream":{let i=[],a=(o,l)=>{if(o===null||typeof o!="object")i.push([l,o]);else if(Array.isArray(o))if(o.length===0)i.push([l,[]]);else for(let c=0;c<o.length;c++)a(o[c],[...l,c]);else{let c=Object.keys(o);if(c.length===0)i.push([l,Object.create(null)]);else for(let u of c)a(o[u],[...l,u])}};return a(e,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[e];let i=s(e,n[0],r),a=null;for(let o of i){if(!Array.isArray(o)||o.length===1&&Array.isArray(o[0])&&o[0].length===0||o.length!==2)continue;let[l,c]=o;if(!Array.isArray(l))continue;if(l.length===0){a=c;continue}a===null&&(a=typeof l[0]=="number"?[]:{});let u=a;for(let p=0;p<l.length-1;p++){let h=l[p],m=l[p+1];if(Array.isArray(u)&&typeof h=="number"){for(;u.length<=h;)u.push(null);u[h]===null&&(u[h]=typeof m=="number"?[]:{}),u=u[h]}else if(u&&typeof u=="object"&&!Array.isArray(u)){let d=String(h);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 p=String(f);Ie(p)&&Pe(u,p,c)}}return[a]}case"truncate_stream":{let i=typeof e=="number"?Math.floor(e):0;if(n.length===0)return[];let a=[],o=s(e,n[0],r);for(let l of o)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&a.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&a.push([c.slice(i),u])}}return a}default:return null}}var e5,vh=I(()=>{"use strict";Nn();Si();e5=2e3});function Xo(e,t,n,r,s,i,a,o,l,c){switch(t){case"getpath":{if(n.length===0)return[null];let u=s(e,n[0],r),f=[];for(let p of u){let h=p,m=e;for(let d of h){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],h=s(e,n[1],r)[0];return[a(e,f,h)]}case"delpaths":{if(n.length===0)return[e];let f=s(e,n[0],r)[0],p=e;for(let h of f.sort((m,d)=>d.length-m.length))p=o(p,h);return[p]}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 p of n)c(e,p,r,[],u);let f=null;for(let p of u){for(let m of p)if(typeof m=="number"&&m<0)throw new Error("Out of bounds negative array index");let h=e;for(let m of p){if(h==null)break;if(Array.isArray(h)&&typeof m=="number")h=h[m];else if(typeof h=="object"&&typeof m=="string"){let d=h;if(!Object.hasOwn(d,m)){h=null;break}h=d[m]}else{h=null;break}}f=a(f,p,h)}return[f]}case"paths":{let u=[],f=(p,h)=>{if(p&&typeof p=="object")if(Array.isArray(p))for(let m=0;m<p.length;m++)u.push([...h,m]),f(p[m],[...h,m]);else for(let m of Object.keys(p))u.push([...h,m]),f(p[m],[...h,m])};return f(e,[]),n.length>0?u.filter(p=>{let h=e;for(let d of p)if(Array.isArray(h)&&typeof d=="number")h=h[d];else if(h&&typeof h=="object"&&typeof d=="string"){let g=h;if(!Object.hasOwn(g,d))return!1;h=g[d]}else return!1;return s(h,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(p,h)=>{if(p===null||typeof p!="object")u.push(h);else if(Array.isArray(p))for(let m=0;m<p.length;m++)f(p[m],[...h,m]);else for(let m of Object.keys(p))f(p[m],[...h,m])};return f(e,[]),u}default:return null}}var Ih=I(()=>{"use strict"});function Yo(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 a=s(e,n[0],r),o=s(e,n[1],r),l=new Set(o.map(c=>JSON.stringify(c)));for(let c of a)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 p=String(f[0]);Ie(p)&&Pe(c,p,u)}}return[c]}let a=s(e,n[0],r),o=Object.create(null);for(let l of a){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(o,f,u[0])}}return[o]}case"JOIN":{if(n.length<2)return[null];let a=s(e,n[0],r)[0];if(!a||typeof a!="object"||Array.isArray(a))return[null];let o=a;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]):"",p=mn(o,f)?o[f]:null;l.push([c,p])}return[l]}default:return null}}var $h=I(()=>{"use strict";Nn()});function Jo(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 a of e)if(Array.isArray(a)||a!==null&&typeof a=="object")throw new Error("cannot join: contains arrays or objects");return i.map(a=>e.map(o=>o===null?"":typeof o=="string"?o:String(o)).join(String(a)))}case"split":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),a=String(i[0]);return[e.split(a)]}case"splits":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"g";return V(a,o.includes("g")?o:`${o}g`).split(e)}catch{return[]}}case"scan":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"";return[...V(a,o.includes("g")?o:`${o}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),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"";return[V(a,o).test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"",c=V(a,`${o}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,p)=>({offset:u?.[p+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),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"",c=V(a,o).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),a=s(e,n[1],r),o=String(i[0]),l=String(a[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"";return[V(o,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),a=s(e,n[1],r),o=String(i[0]),l=String(a[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[V(o,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),a=String(i[0]);return[e.startsWith(a)?e.slice(a.length):e]}case"rtrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),a=String(i[0]);return a===""?[e]:[e.endsWith(a)?e.slice(0,-a.length):e]}case"trimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),a=String(i[0]);if(a==="")return[e];let o=e;return o.startsWith(a)&&(o=o.slice(a.length)),o.endsWith(a)&&(o=o.slice(0,-a.length)),[o]}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(o=>{if(typeof o=="string")throw new Error(`string (${JSON.stringify(o)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof o!="number"||Number.isNaN(o))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(o);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var Oh=I(()=>{"use strict";Me()});function el(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 Rh=I(()=>{"use strict"});var Th=I(()=>{"use strict";xh();Eh();Ah();Sh();Ch();Nh();kh();vh();Ih();$h();Oh();Rh()});function Ci(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]=Ci(l[r],s,n),l}if(Array.isArray(e))throw new Error("Cannot index array with string");if(!Ie(r))return e??Object.create(null);let i=e&&typeof e=="object"&&!Array.isArray(e)?Ke(e):Object.create(null),a=Object.hasOwn(i,r)?i[r]:void 0;return Pe(i,r,Ci(a,s,n)),i}function Ni(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 a=Ke(e);return delete a[i],a}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n=="number"){let s=[...e];return s[n]=Ni(s[n],r),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s=String(n);if(!Ie(s))return e;let i=Ke(e);return Object.hasOwn(i,s)&&Pe(i,s,Ni(i[s],r)),i}return e}var Ph=I(()=>{"use strict";Nn()});function r5(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??t5,maxDepth:e?.limits?.maxDepth??Lh},env:e?.env,coverage:e?.coverage}}function Ii(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,coverage:e.coverage}}function ys(e,t,n){switch(t.type){case"var":return Ii(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],a=s<n.length?n[s]:null,o=ys(r,i,a);if(o===null)return null;r=o}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 a;if(typeof i.key=="string")a=i.key;else{let c=G(n,i.key,e);if(c.length===0)return null;a=String(c[0])}let o=mn(r,a)?r[a]:null;i.keyVar&&(s=Ii(s,i.keyVar,o));let l=ys(s,i.pattern,o);if(l===null)return null;s=l}return s}}}function s5(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 _n(e){if(e.type==="Identity")return[];if(e.type==="Field"){let t=e.base?_n(e.base):[];return t===null?null:[...t,e.name]}if(e.type==="Index"&&e.index.type==="Literal"){let t=e.base?_n(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=_n(e.left);return t===null?null:tl(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 tl(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=_n(t);if(n!==null)return[...e,...n]}if(t.type==="Index"&&t.index.type==="Literal"){let n=_n(t);if(n!==null)return[...e,...n]}if(t.type==="Pipe"){let n=tl(e,t.left);return n===null?null:tl(n,t.right)}return t.type==="Identity"?e:null}function Dh(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...G(e,t.left,n))}catch(s){if(s instanceof te)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 te)throw s;return r}return r}return G(e,t,n)}function G(e,t,n){let r=n&&"vars"in n?n:r5(n);switch(r.root===void 0&&(r={...r,root:e,currentPath:[]}),r.coverage?.hit(`jq:node:${t.type}`),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 o=i;if(!Object.hasOwn(o,t.name))return[null];let l=o[t.name];return[l===void 0?null:l]}if(i===null)return[null];let a=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${a} with string "${t.name}"`)});case"Index":return(t.base?G(e,t.base,r):[e]).flatMap(i=>G(i,t.index,r).flatMap(o=>{if(typeof o=="number"&&Array.isArray(i)){if(Number.isNaN(o))return[null];let l=Math.trunc(o),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof o=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let l=i;return Object.hasOwn(l,o)?[l[o]]:[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 a=i.length,o=t.start?G(e,t.start,r):[0],l=t.end?G(e,t.end,r):[a];return o.flatMap(c=>l.map(u=>{let f=c,p=u,h=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),m=Number.isNaN(p)?a:Number.isInteger(p)?p:Math.ceil(p),d=_h(h,a),g=_h(m,a);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=_n(t.left),a=[];for(let o of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};a.push(...G(o,t.right,l))}else a.push(...G(o,t.right,r))}catch(l){throw l instanceof Tr?l.withPrependedResults(a):l}return a}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=[Object.create(null)];for(let i of t.entries){let a=typeof i.key=="string"?[i.key]:G(e,i.key,r),o=G(e,i.value,r),l=[];for(let c of s)for(let u of a){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 o)l.push(Ke(c));continue}for(let f of o){let p=Ke(c);Pe(p,u,f),l.push(p)}}s.length=0,s.push(...l)}return s}case"Paren":return G(e,t.expr,r);case"BinaryOp":return o5(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 a=o=>o.length>5?`"${o.slice(0,3)}...`:JSON.stringify(o);throw new Error(`string (${a(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 a of t.elifs)if(G(e,a.cond,r).some(Qt))return G(e,a.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 vi?s.value:s instanceof Error?s.message:String(s);return G(i,t.catch,r)}return[]}case"Call":return Fh(e,t.name,t.args,r);case"VarBind":return G(e,t.value,r).flatMap(i=>{let a=null,o=[];t.pattern?o.push(t.pattern):t.name&&o.push({type:"var",name:t.name}),t.alternatives&&o.push(...t.alternatives);for(let l of o)if(a=ys(r,l,i),a!==null)break;return a===null?[]:G(e,t.body,a)});case"VarRef":{if(t.name==="$ENV")return[r.env?Et(r.env):Object.create(null)];let s=r.vars.get(t.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,a=o=>{if(o&&typeof o=="object"){if(i.has(o))return;i.add(o)}if(s.push(o),Array.isArray(o))for(let l of o)a(l);else if(o&&typeof o=="object")for(let l of Object.keys(o))a(o[l])};return a(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(o=>typeof o=="string"?o:JSON.stringify(o)).join("")).join("")];case"UpdateOp":return[i5(e,t.path,t.op,t.value,r)];case"Reduce":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],a=r.limits.maxDepth??Lh;for(let o of s){let l;if(t.pattern){if(l=ys(r,t.pattern,o),l===null)continue}else l=Ii(r,t.varName,o);if(i=G(i,t.update,l)[0],Rr(i,a+1)>a)return[null]}return[i]}case"Foreach":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],a=[];for(let o of s)try{let l;if(t.pattern){if(l=ys(r,t.pattern,o),l===null)continue}else l=Ii(r,t.varName,o);if(i=G(i,t.update,l)[0],t.extract){let c=G(i,t.extract,l);a.push(...c)}else a.push(i)}catch(l){throw l instanceof Tr?l.withPrependedResults(a):l}return a}case"Label":try{return G(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(s){if(s instanceof Tr&&s.label===t.name)return s.partialResults;throw s}case"Break":throw new Tr(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 a={...r,funcs:s};return G(e,t.body,a)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function _h(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function i5(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"?Bo(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 a(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(!Ie(c.name))return l;if(c.base)return a(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let p=Ke(f),h=Object.hasOwn(p,c.name)?p[c.name]:void 0;return Pe(p,c.name,u(h)),p}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f=Ke(l),p=Object.hasOwn(f,c.name)?f[c.name]:void 0;return Pe(f,c.name,u(p)),f}return l}case"Index":{let p=G(e,c.index,s)[0];if(typeof p=="number"&&Number.isNaN(p))throw new Error("Cannot set array element at NaN index");if(typeof p=="number"&&!Number.isInteger(p)&&(p=Math.trunc(p)),c.base)return a(l,c.base,h=>{if(typeof p=="number"&&Array.isArray(h)){let m=[...h],d=p<0?m.length+p:p;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(typeof p=="string"&&h&&typeof h=="object"&&!Array.isArray(h)){if(!Ie(p))return h;let m=Ke(h),d=Object.hasOwn(m,p)?m[p]:void 0;return Pe(m,p,u(d)),m}return h});if(typeof p=="number"){if(p>536870911)throw new Error("Array index too large");if(p<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let m=[...l],d=p<0?m.length+p:p;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<=p;)m.push(null);return m[p]=u(null),m}return l}if(typeof p=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!Ie(p))return l;let h=Ke(l),m=Object.hasOwn(h,p)?h[p]:void 0;return Pe(h,p,u(m)),h}return l}case"Iterate":{let f=p=>{if(Array.isArray(p))return p.map(h=>u(h));if(p&&typeof p=="object"){let h=Object.create(null);for(let[m,d]of Object.entries(p))Ie(m)&&Pe(h,m,u(d));return h}return p};return c.base?a(l,c.base,f):f(l)}case"Pipe":{let f=a(l,c.left,p=>p);return a(f,c.right,u)}default:return u(l)}}return a(e,t,l=>{if(n==="|=")return i(l,l);let c=G(e,r,s);return i(l,c[0]??null)})}function a5(e,t,n){function r(i,a,o){switch(a.type){case"Identity":return o;case"Field":{if(!Ie(a.name))return i;if(a.base){let l=G(i,a.base,n)[0],c=r(l,{type:"Field",name:a.name},o);return r(i,a.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l=Ke(i);return Pe(l,a.name,o),l}return i}case"Index":{if(a.base){let u=G(i,a.base,n)[0],f=r(u,{type:"Index",index:a.index},o);return r(i,a.base,f)}let c=G(e,a.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]=o),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u=Ke(i);return Pe(u,c,o),u}return i}default:return i}}function s(i,a){switch(a.type){case"Identity":return null;case"Field":{if(!Ie(a.name))return i;if(a.base){let l=G(i,a.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:a.name});return r(i,a.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(a.name))return i;let l=Ke(i);return delete l[a.name],l}return i}case"Index":{if(a.base){let u=G(i,a.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:a.index});return r(i,a.base,f)}let c=G(e,a.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=Ke(i);return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let u=function(h,m,d){switch(m.type){case"Identity":return d;case"Field":{if(!Ie(m.name))return h;if(h&&typeof h=="object"&&!Array.isArray(h)){let g=Ke(h);return Pe(g,m.name,d),g}return h}case"Index":{let w=G(e,m.index,n)[0];if(typeof w=="number"&&Array.isArray(h)){let y=[...h],b=w<0?y.length+w:w;return b>=0&&b<y.length&&(y[b]=d),y}if(typeof w=="string"&&h&&typeof h=="object"&&!Array.isArray(h)){if(!Ie(w))return h;let y=Ke(h);return Pe(y,w,d),y}return h}case"Pipe":{let g=G(h,m.left,n)[0],w=u(g,m.right,d);return u(h,m.left,w)}default:return h}};var o=u;let l=a.left,c=a.right,f=G(i,l,n)[0];if(f==null)return i;let p=s(f,c);return u(i,l,p)}default:return i}}return s(e,t)}function o5(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),a=G(e,r,s);return i.flatMap(o=>a.map(l=>{switch(t){case"+":return o===null?l:l===null?o:typeof o=="number"&&typeof l=="number"||typeof o=="string"&&typeof l=="string"?o+l:Array.isArray(o)&&Array.isArray(l)?[...o,...l]:o&&l&&typeof o=="object"&&typeof l=="object"&&!Array.isArray(o)&&!Array.isArray(l)?Bo(o,l):null;case"-":if(typeof o=="number"&&typeof l=="number")return o-l;if(Array.isArray(o)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return o.filter(u=>!c.has(JSON.stringify(u)))}if(typeof o=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(o)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":return typeof o=="number"&&typeof l=="number"?o*l:typeof o=="string"&&typeof l=="number"?o.repeat(l):o&&l&&typeof o=="object"&&typeof l=="object"&&!Array.isArray(o)&&!Array.isArray(l)?Go(o,l):null;case"/":if(typeof o=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${o}) and number (${l}) cannot be divided because the divisor is zero`);return o/l}return typeof o=="string"&&typeof l=="string"?o.split(l):null;case"%":if(typeof o=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${o}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(o)&&!Number.isNaN(o)?!Number.isFinite(l)&&!Number.isNaN(l)&&o<0&&l>0?-1:0:o%l}return null;case"==":return Or(o,l);case"!=":return!Or(o,l);case"<":return gs(o,l)<0;case"<=":return gs(o,l)<=0;case">":return gs(o,l)>0;case">=":return gs(o,l)>=0;default:return null}}))}function Fh(e,t,n,r){let s=n5.get(t);if(s)return typeof e=="number"?[s(e)]:[null];let i=Zo(e,t,n,r,G);if(i!==null)return i;let a=Jo(e,t,n,r,G);if(a!==null)return a;let o=jo(e,t,n,r,G);if(o!==null)return o;let l=Vo(e,t,r.limits.maxDepth);if(l!==null)return l;let c=el(e,t);if(c!==null)return c;let u=Qo(e,t,n,r,G);if(u!==null)return u;let f=zo(e,t,n,r,G,Dh,Ei,Qt,Ai,te);if(f!==null)return f;let p=Xo(e,t,n,r,G,Qt,Ci,Ni,a5,ki);if(p!==null)return p;let h=qo(e,t,n,r,G,Or);if(h!==null)return h;let m=Ho(e,t,n,r,G,Dh,Qt,te);if(m!==null)return m;let d=Ko(e,t,n,r,G,Qt,s5,Fh);if(d!==null)return d;let g=Yo(e,t,n,r,G,Or);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 w=n.length>0?G(e,n[0],r)[0]:e;throw new vi(w)}case"env":return[r.env?Et(r.env):Object.create(null)];case"debug":return[e];case"input_line_number":return[1];default:{let w=`${t}/${n.length}`,y=r.funcs?.get(w);if(y){let b=y.closure??r.funcs??new Map,x=new Map(b);x.set(w,y);for(let $=0;$<y.params.length;$++){let O=y.params[$],F=n[$];if(F){let R=G(e,F,r),z;if(R.length===0)z={type:"Call",name:"empty",args:[]};else if(R.length===1)z={type:"Literal",value:R[0]};else{z={type:"Literal",value:R[R.length-1]};for(let k=R.length-2;k>=0;k--)z={type:"Comma",left:{type:"Literal",value:R[k]},right:z}}x.set(`${O}/0`,{params:[],body:z})}}let S={...r,funcs:x};return G(e,y.body,S)}throw new Error(`Unknown function: ${t}`)}}}function ki(e,t,n,r,s){if(t.type==="Comma"){let o=t;ki(e,o.left,n,r,s),ki(e,o.right,n,r,s);return}let i=_n(t);if(i!==null){s.push([...r,...i]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let o=0;o<e.length;o++)s.push([...r,o]);else if(e&&typeof e=="object")for(let o of Object.keys(e))s.push([...r,o]);return}if(t.type==="Recurse"){let o=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)o(l[u],[...c,u]);else for(let u of Object.keys(l))o(l[u],[...c,u])};o(e,[]);return}if(t.type==="Pipe"){let o=_n(t.left);if(o!==null){let l=G(e,t.left,n);for(let c of l)ki(c,t.right,n,[...r,...o],s);return}}G(e,t,n).length>0&&s.push(r)}var Tr,vi,t5,Lh,n5,Mh=I(()=>{"use strict";Pn();ye();Th();Ph();Nn();Si();Tr=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])}},vi=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},t5=1e4,Lh=2e3,n5=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 Wh(e){let t=[],n=0,r=(c=0)=>e[n+c],s=()=>e[n++],i=()=>n>=e.length,a=c=>c>="0"&&c<="9",o=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>o(c)||a(c);for(;!i();){let c=n,u=s();if(!(u===" "||u===" "||u===`
|
|
546
|
+
`,exitCode:127}}}};X9={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},Y9={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function Ie(e){return!bh.has(e)}function Pe(e,t,n){Ie(t)&&(e[t]=n)}function mn(e,t){return Object.hasOwn(e,t)}function Ke(e){return Object.assign(Object.create(null),e)}function Bo(...e){return Object.assign(Object.create(null),...e)}var bh,xk,Nn=I(()=>{"use strict";bh=new Set(["__proto__","constructor","prototype"]),xk=new Set([...bh,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function zo(e,t,n,r,s,i,a,o,l,c){switch(t){case"sort":return Array.isArray(e)?[[...e].sort(a)]:[null];case"sort_by":return!Array.isArray(e)||n.length===0?[null]:[[...e].sort((f,p)=>{let h=s(f,n[0],r)[0],m=s(p,n[0],r)[0];return a(h,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 p=0,h=e.length;for(;p<h;){let m=p+h>>>1;a(e[m],f)<0?p=m+1:h=m}return p<e.length&&a(e[p],f)===0?p:-p-1})}case"unique_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let p of e){let h=s(p,n[0],r)[0],m=JSON.stringify(h);u.has(m)||u.set(m,{item:p,key:h})}let f=[...u.values()];return f.sort((p,h)=>a(p.key,h.key)),[f.map(p=>p.item)]}case"group_by":{if(!Array.isArray(e)||n.length===0)return[null];let u=new Map;for(let f of e){let p=JSON.stringify(s(f,n[0],r)[0]);u.has(p)||u.set(p,[]),u.get(p)?.push(f)}return[[...u.values()]]}case"max":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>a(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 p=s(u,n[0],r)[0],h=s(f,n[0],r)[0];return a(p,h)>0?u:f})];case"min":return Array.isArray(e)&&e.length>0?[e.reduce((u,f)=>a(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 p=s(u,n[0],r)[0],h=s(f,n[0],r)[0];return a(p,h)<0?u:f})];case"add":{let u=f=>{let p=f.filter(h=>h!==null);return p.length===0?null:p.every(h=>typeof h=="number")?p.reduce((h,m)=>h+m,0):p.every(h=>typeof h=="string")?p.join(""):p.every(h=>Array.isArray(h))?p.flat():p.every(h=>h&&typeof h=="object"&&!Array.isArray(h))?ai(...p):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(o))return[!0]}catch(u){if(u instanceof c)throw u}return[!1]}return n.length===1?Array.isArray(e)?[e.some(u=>o(s(u,n[0],r)[0]))]:[!1]:Array.isArray(e)?[e.some(o)]:[!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(o))return[!1]}catch(u){if(u instanceof c)throw u}return[!0]}return n.length===1?Array.isArray(e)?[e.every(u=>o(s(u,n[0],r)[0]))]:[!0]:Array.isArray(e)?[e.every(o)]:[!0]}case"select":return n.length===0?[e]:s(e,n[0],r).some(o)?[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,p]of Object.entries(e)){if(!Ie(f))continue;let h=s(p,n[0],r);h.length>0&&Pe(u,f,h[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"?[mn(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"?[mn(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 xh=I(()=>{"use strict";Pn();Nn()});function Ho(e,t,n,r,s,i,a,o){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 o)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 o)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 p=[];for(let h of l){let m=h;for(let d=0;d<m;d++)p.push(d)}return p}let c=s(e,n[1],r);if(n.length===2){let p=[];for(let h of l)for(let m of c){let d=h,g=m;for(let w=d;w<g;w++)p.push(w)}return p}let u=s(e,n[2],r),f=[];for(let p of l)for(let h of c)for(let m of u){let d=p,g=h,w=m;if(w!==0)if(w>0)for(let y=d;y<g;y+=w)f.push(y);else for(let y=d;y>g;y+=w)f.push(y)}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(p){if(p instanceof o)throw p;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 o)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 o)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(a))return[l];let p=s(l,n[1],r);if(p.length===0)return[l];l=p[0]}throw new o(`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(a);f++){l.push(c);let h=s(c,n[1],r);if(h.length===0)break;c=h[0]}if(l.length>=u)throw new o(`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 p=s(c,n[0],r);if(p.length===0)break;c=p[0]}if(l.length>=u)throw new o(`jq repeat: too many iterations (${u}), increase executionLimits.maxJqIterations`,"iterations");return l}default:return null}}var Eh=I(()=>{"use strict"});function jo(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),a=i.getUTCFullYear(),o=i.getUTCMonth(),l=i.getUTCDate(),c=i.getUTCHours(),u=i.getUTCMinutes(),f=i.getUTCSeconds(),p=i.getUTCDay(),h=Date.UTC(a,0,1),m=Math.floor((i.getTime()-h)/(1440*60*1e3));return[[a,o,l,c,u,f,p,m]]}case"mktime":{if(!Array.isArray(e))throw new Error("mktime requires parsed datetime inputs");let[i,a,o,l=0,c=0,u=0]=e;if(typeof i!="number"||typeof a!="number")throw new Error("mktime requires parsed datetime inputs");let f=Date.UTC(i,a,o??1,l??0,c??0,u??0);return[Math.floor(f/1e3)]}case"strftime":{if(n.length===0)return[null];let a=s(e,n[0],r)[0];if(typeof a!="string")throw new Error("strftime/1 requires a string format");let o;if(typeof e=="number")o=new Date(e*1e3);else if(Array.isArray(e)){let[p,h,m,d=0,g=0,w=0]=e;if(typeof p!="number"||typeof h!="number")throw new Error("strftime/1 requires parsed datetime inputs");o=new Date(Date.UTC(p,h,m??1,d??0,g??0,w??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=(p,h=2)=>String(p).padStart(h,"0");return[a.replace(/%Y/g,String(o.getUTCFullYear())).replace(/%m/g,u(o.getUTCMonth()+1)).replace(/%d/g,u(o.getUTCDate())).replace(/%H/g,u(o.getUTCHours())).replace(/%M/g,u(o.getUTCMinutes())).replace(/%S/g,u(o.getUTCSeconds())).replace(/%A/g,l[o.getUTCDay()]).replace(/%B/g,c[o.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 a=s(e,n[0],r)[0];if(typeof a!="string")throw new Error("strptime/1 requires a string format");if(a==="%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,p,h,m]=l.map(Number),d=new Date(Date.UTC(c,u-1,f,p,h,m)),g=d.getUTCDay(),w=Date.UTC(c,0,1),y=Math.floor((d.getTime()-w)/(1440*60*1e3));return[[c,u-1,f,p,h,m,g,y]]}}let o=new Date(e);if(!Number.isNaN(o.getTime())){let l=o.getUTCFullYear(),c=o.getUTCMonth(),u=o.getUTCDate(),f=o.getUTCHours(),p=o.getUTCMinutes(),h=o.getUTCSeconds(),m=o.getUTCDay(),d=Date.UTC(l,0,1),g=Math.floor((o.getTime()-d)/(1440*60*1e3));return[[l,c,u,f,p,h,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 Ah=I(()=>{"use strict"});function Qt(e){return e!==!1&&e!==null}function Or(e,t){return JSON.stringify(e)===JSON.stringify(t)}function gs(e,t){return typeof e=="number"&&typeof t=="number"?e-t:typeof e=="string"&&typeof t=="string"?e.localeCompare(t):0}function Go(e,t){let n=Ke(e);for(let r of Object.keys(t))Ie(r)&&(mn(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,Go(n[r],t[r])):Pe(n,r,t[r]));return n}function Rr(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 Ei(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 a=Ei(e[i],t[i]);if(a!==0)return a}return e.length-t.length}if(e&&t&&typeof e=="object"&&typeof t=="object"){let i=e,a=t,o=Object.keys(i).sort(),l=Object.keys(a).sort();for(let c=0;c<Math.min(o.length,l.length);c++){let u=o[c].localeCompare(l[c]);if(u!==0)return u}if(o.length!==l.length)return o.length-l.length;for(let c of o){let u=Ei(i[c],a[c]);if(u!==0)return u}}return 0}function Ai(e,t){if(Or(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=>Ai(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=>mn(n,s)&&Ai(n[s],r[s]))}return!1}var Si=I(()=>{"use strict";Nn()});function Vo(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??J9;return Rr(e,r+1)>r?[null]:[JSON.stringify(e)]}case"@html":return typeof e=="string"?[e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")]:[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 J9,Sh=I(()=>{"use strict";Si();J9=2e3});function qo(e,t,n,r,s,i){switch(t){case"index":return n.length===0?[null]:s(e,n[0],r).map(o=>{if(typeof e=="string"&&typeof o=="string"){if(o===""&&e==="")return null;let l=e.indexOf(o);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(o)){for(let c=0;c<=e.length-o.length;c++){let u=!0;for(let f=0;f<o.length;f++)if(!i(e[c+f],o[f])){u=!1;break}if(u)return c}return null}let l=e.findIndex(c=>i(c,o));return l>=0?l:null}return null});case"rindex":return n.length===0?[null]:s(e,n[0],r).map(o=>{if(typeof e=="string"&&typeof o=="string"){let l=e.lastIndexOf(o);return l>=0?l:null}if(Array.isArray(e)){if(Array.isArray(o)){for(let l=e.length-o.length;l>=0;l--){let c=!0;for(let u=0;u<o.length;u++)if(!i(e[l+u],o[u])){c=!1;break}if(c)return l}return null}for(let l=e.length-1;l>=0;l--)if(i(e[l],o))return l;return null}return null});case"indices":return n.length===0?[[]]:s(e,n[0],r).map(o=>{let l=[];if(typeof e=="string"&&typeof o=="string"){let c=e.indexOf(o);for(;c!==-1;)l.push(c),c=e.indexOf(o,c+1)}else if(Array.isArray(e))if(Array.isArray(o)){let c=o.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 p=0;p<c;p++)if(!i(e[u+p],o[p])){f=!1;break}f&&l.push(u)}}else for(let c=0;c<e.length;c++)i(e[c],o)&&l.push(c);return l});default:return null}}var Ch=I(()=>{"use strict"});function Zo(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),a=s(e,n[1],r),o=i[0],l=a[0];return typeof o!="number"||typeof l!="number"?[null]:[o**l]}case"atan2":{if(n.length<2)return[null];let i=s(e,n[0],r),a=s(e,n[1],r),o=i[0],l=a[0];return typeof o!="number"||typeof l!="number"?[null]:[Math.atan2(o,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],a=s(e,n[1],r)[0];return[e*i+a]}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 Nh=I(()=>{"use strict"});function Ko(e,t,n,r,s,i,a,o){switch(t){case"recurse":{if(n.length===0){let h=[],m=d=>{if(h.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),h}let l=[],c=n.length>=2?n[1]:null,u=1e4,f=0,p=h=>{if(f++>u||c&&!s(h,c,r).some(i))return;l.push(h);let m=s(h,n[0],r);for(let d of m)d!=null&&p(d)};return p(e),l}case"recurse_down":return o(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 h=Object.create(null);for(let[m,d]of Object.entries(u))Ie(m)&&Pe(h,m,c(d));f=h}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 p=[],h=(m,d)=>{if(d===f){p.push([...m]);return}for(let g of e)m.push(g),h(m,d+1),m.pop()};return h([],0),p}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 p=e[u];for(let h of p)f.push(h),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[a(r.root,u)]}else{let u=-c-1;if(u>=l.length)return[e];let f=l.slice(0,u);return[a(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(a(r.root,l.slice(0,u)));return[c]}case"root":return r.root!==void 0?[r.root]:[];default:return null}}var kh=I(()=>{"use strict";Nn()});function Qo(e,t,n,r,s){switch(t){case"keys":return Array.isArray(e)?[e.map((i,a)=>a)]:e&&typeof e=="object"?[Object.keys(e).sort()]:[null];case"keys_unsorted":return Array.isArray(e)?[e.map((i,a)=>a)]: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,a=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${a}) only strings have UTF-8 byte length`)}case"to_entries":return e&&typeof e=="object"&&!Array.isArray(e)?[Object.entries(e).map(([i,a])=>({key:i,value:a}))]:[null];case"from_entries":if(Array.isArray(e)){let i=Object.create(null);for(let a of e)if(a&&typeof a=="object"){let o=a,l=o.key??o.Key??o.name??o.Name??o.k,c=o.value??o.Value??o.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 a=Object.entries(e).map(([l,c])=>({key:l,value:c})).flatMap(l=>s(l,n[0],r)),o=Object.create(null);for(let l of a)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 p=String(u);Ie(p)&&Pe(o,p,f)}}return[o]}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(a=>{let o=a;if(o<0)throw new Error("flatten depth must not be negative");return e.flat(o)}):[null];case"unique":if(Array.isArray(e)){let i=new Set,a=[];for(let o of e){let l=JSON.stringify(o);i.has(l)||(i.add(l),a.push(o))}return[a]}return[null];case"tojson":case"tojsonstream":{let i=r.limits.maxDepth??e5;return Rr(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,a=i==="array"||i==="object"?JSON.stringify(e):String(e);throw new Error(`${i} (${a}) cannot be parsed as a boolean`)}case"tostream":{let i=[],a=(o,l)=>{if(o===null||typeof o!="object")i.push([l,o]);else if(Array.isArray(o))if(o.length===0)i.push([l,[]]);else for(let c=0;c<o.length;c++)a(o[c],[...l,c]);else{let c=Object.keys(o);if(c.length===0)i.push([l,Object.create(null)]);else for(let u of c)a(o[u],[...l,u])}};return a(e,[]),i.push([[]]),i}case"fromstream":{if(n.length===0)return[e];let i=s(e,n[0],r),a=null;for(let o of i){if(!Array.isArray(o)||o.length===1&&Array.isArray(o[0])&&o[0].length===0||o.length!==2)continue;let[l,c]=o;if(!Array.isArray(l))continue;if(l.length===0){a=c;continue}a===null&&(a=typeof l[0]=="number"?[]:{});let u=a;for(let p=0;p<l.length-1;p++){let h=l[p],m=l[p+1];if(Array.isArray(u)&&typeof h=="number"){for(;u.length<=h;)u.push(null);u[h]===null&&(u[h]=typeof m=="number"?[]:{}),u=u[h]}else if(u&&typeof u=="object"&&!Array.isArray(u)){let d=String(h);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 p=String(f);Ie(p)&&Pe(u,p,c)}}return[a]}case"truncate_stream":{let i=typeof e=="number"?Math.floor(e):0;if(n.length===0)return[];let a=[],o=s(e,n[0],r);for(let l of o)if(Array.isArray(l)){if(l.length===1&&Array.isArray(l[0])){let c=l[0];c.length>i&&a.push([c.slice(i)]);continue}if(l.length===2&&Array.isArray(l[0])){let c=l[0],u=l[1];c.length>i&&a.push([c.slice(i),u])}}return a}default:return null}}var e5,vh=I(()=>{"use strict";Nn();Si();e5=2e3});function Xo(e,t,n,r,s,i,a,o,l,c){switch(t){case"getpath":{if(n.length===0)return[null];let u=s(e,n[0],r),f=[];for(let p of u){let h=p,m=e;for(let d of h){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],h=s(e,n[1],r)[0];return[a(e,f,h)]}case"delpaths":{if(n.length===0)return[e];let f=s(e,n[0],r)[0],p=e;for(let h of f.sort((m,d)=>d.length-m.length))p=o(p,h);return[p]}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 p of n)c(e,p,r,[],u);let f=null;for(let p of u){for(let m of p)if(typeof m=="number"&&m<0)throw new Error("Out of bounds negative array index");let h=e;for(let m of p){if(h==null)break;if(Array.isArray(h)&&typeof m=="number")h=h[m];else if(typeof h=="object"&&typeof m=="string"){let d=h;if(!Object.hasOwn(d,m)){h=null;break}h=d[m]}else{h=null;break}}f=a(f,p,h)}return[f]}case"paths":{let u=[],f=(p,h)=>{if(p&&typeof p=="object")if(Array.isArray(p))for(let m=0;m<p.length;m++)u.push([...h,m]),f(p[m],[...h,m]);else for(let m of Object.keys(p))u.push([...h,m]),f(p[m],[...h,m])};return f(e,[]),n.length>0?u.filter(p=>{let h=e;for(let d of p)if(Array.isArray(h)&&typeof d=="number")h=h[d];else if(h&&typeof h=="object"&&typeof d=="string"){let g=h;if(!Object.hasOwn(g,d))return!1;h=g[d]}else return!1;return s(h,n[0],r).some(i)}):u}case"leaf_paths":{let u=[],f=(p,h)=>{if(p===null||typeof p!="object")u.push(h);else if(Array.isArray(p))for(let m=0;m<p.length;m++)f(p[m],[...h,m]);else for(let m of Object.keys(p))f(p[m],[...h,m])};return f(e,[]),u}default:return null}}var Ih=I(()=>{"use strict"});function Yo(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 a=s(e,n[0],r),o=s(e,n[1],r),l=new Set(o.map(c=>JSON.stringify(c)));for(let c of a)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 p=String(f[0]);Ie(p)&&Pe(c,p,u)}}return[c]}let a=s(e,n[0],r),o=Object.create(null);for(let l of a){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(o,f,u[0])}}return[o]}case"JOIN":{if(n.length<2)return[null];let a=s(e,n[0],r)[0];if(!a||typeof a!="object"||Array.isArray(a))return[null];let o=a;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]):"",p=mn(o,f)?o[f]:null;l.push([c,p])}return[l]}default:return null}}var $h=I(()=>{"use strict";Nn()});function Jo(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 a of e)if(Array.isArray(a)||a!==null&&typeof a=="object")throw new Error("cannot join: contains arrays or objects");return i.map(a=>e.map(o=>o===null?"":typeof o=="string"?o:String(o)).join(String(a)))}case"split":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),a=String(i[0]);return[e.split(a)]}case"splits":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"g";return V(a,o.includes("g")?o:`${o}g`).split(e)}catch{return[]}}case"scan":{if(typeof e!="string"||n.length===0)return[];let i=s(e,n[0],r),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"";return[...V(a,o.includes("g")?o:`${o}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),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"";return[V(a,o).test(e)]}catch{return[!1]}}case"match":{if(typeof e!="string"||n.length===0)return[null];let i=s(e,n[0],r),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"",c=V(a,`${o}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,p)=>({offset:u?.[p+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),a=String(i[0]);try{let o=n.length>1?String(s(e,n[1],r)[0]):"",c=V(a,o).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),a=s(e,n[1],r),o=String(i[0]),l=String(a[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"";return[V(o,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),a=s(e,n[1],r),o=String(i[0]),l=String(a[0]);try{let c=n.length>2?String(s(e,n[2],r)[0]):"g",u=c.includes("g")?c:`${c}g`;return[V(o,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),a=String(i[0]);return[e.startsWith(a)?e.slice(a.length):e]}case"rtrimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),a=String(i[0]);return a===""?[e]:[e.endsWith(a)?e.slice(0,-a.length):e]}case"trimstr":{if(typeof e!="string"||n.length===0)return[e];let i=s(e,n[0],r),a=String(i[0]);if(a==="")return[e];let o=e;return o.startsWith(a)&&(o=o.slice(a.length)),o.endsWith(a)&&(o=o.slice(0,-a.length)),[o]}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(o=>{if(typeof o=="string")throw new Error(`string (${JSON.stringify(o)}) can't be imploded, unicode codepoint needs to be numeric`);if(typeof o!="number"||Number.isNaN(o))throw new Error("number (null) can't be imploded, unicode codepoint needs to be numeric");let l=Math.trunc(o);return l<0||l>1114111||l>=55296&&l<=57343?String.fromCodePoint(65533):String.fromCodePoint(l)}).join("")];default:return null}}var Oh=I(()=>{"use strict";Me()});function el(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 Rh=I(()=>{"use strict"});var Th=I(()=>{"use strict";xh();Eh();Ah();Sh();Ch();Nh();kh();vh();Ih();$h();Oh();Rh()});function Ci(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]=Ci(l[r],s,n),l}if(Array.isArray(e))throw new Error("Cannot index array with string");if(!Ie(r))return e??Object.create(null);let i=e&&typeof e=="object"&&!Array.isArray(e)?Ke(e):Object.create(null),a=Object.hasOwn(i,r)?i[r]:void 0;return Pe(i,r,Ci(a,s,n)),i}function Ni(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 a=Ke(e);return delete a[i],a}return e}let[n,...r]=t;if(Array.isArray(e)&&typeof n=="number"){let s=[...e];return s[n]=Ni(s[n],r),s}if(e&&typeof e=="object"&&!Array.isArray(e)){let s=String(n);if(!Ie(s))return e;let i=Ke(e);return Object.hasOwn(i,s)&&Pe(i,s,Ni(i[s],r)),i}return e}var Ph=I(()=>{"use strict";Nn()});function r5(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??t5,maxDepth:e?.limits?.maxDepth??Lh},env:e?.env,coverage:e?.coverage}}function Ii(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,coverage:e.coverage}}function ys(e,t,n){switch(t.type){case"var":return Ii(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],a=s<n.length?n[s]:null,o=ys(r,i,a);if(o===null)return null;r=o}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 a;if(typeof i.key=="string")a=i.key;else{let c=G(n,i.key,e);if(c.length===0)return null;a=String(c[0])}let o=mn(r,a)?r[a]:null;i.keyVar&&(s=Ii(s,i.keyVar,o));let l=ys(s,i.pattern,o);if(l===null)return null;s=l}return s}}}function s5(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 _n(e){if(e.type==="Identity")return[];if(e.type==="Field"){let t=e.base?_n(e.base):[];return t===null?null:[...t,e.name]}if(e.type==="Index"&&e.index.type==="Literal"){let t=e.base?_n(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=_n(e.left);return t===null?null:tl(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 tl(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=_n(t);if(n!==null)return[...e,...n]}if(t.type==="Index"&&t.index.type==="Literal"){let n=_n(t);if(n!==null)return[...e,...n]}if(t.type==="Pipe"){let n=tl(e,t.left);return n===null?null:tl(n,t.right)}return t.type==="Identity"?e:null}function Dh(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...G(e,t.left,n))}catch(s){if(s instanceof te)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 te)throw s;return r}return r}return G(e,t,n)}function G(e,t,n){let r=n&&"vars"in n?n:r5(n);switch(r.root===void 0&&(r={...r,root:e,currentPath:[]}),r.coverage?.hit(`jq:node:${t.type}`),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 o=i;if(!Object.hasOwn(o,t.name))return[null];let l=o[t.name];return[l===void 0?null:l]}if(i===null)return[null];let a=Array.isArray(i)?"array":typeof i;throw new Error(`Cannot index ${a} with string "${t.name}"`)});case"Index":return(t.base?G(e,t.base,r):[e]).flatMap(i=>G(i,t.index,r).flatMap(o=>{if(typeof o=="number"&&Array.isArray(i)){if(Number.isNaN(o))return[null];let l=Math.trunc(o),c=l<0?i.length+l:l;return c>=0&&c<i.length?[i[c]]:[null]}if(typeof o=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){let l=i;return Object.hasOwn(l,o)?[l[o]]:[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 a=i.length,o=t.start?G(e,t.start,r):[0],l=t.end?G(e,t.end,r):[a];return o.flatMap(c=>l.map(u=>{let f=c,p=u,h=Number.isNaN(f)?0:Number.isInteger(f)?f:Math.floor(f),m=Number.isNaN(p)?a:Number.isInteger(p)?p:Math.ceil(p),d=_h(h,a),g=_h(m,a);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=_n(t.left),a=[];for(let o of s)try{if(i!==null){let l={...r,currentPath:[...r.currentPath??[],...i]};a.push(...G(o,t.right,l))}else a.push(...G(o,t.right,r))}catch(l){throw l instanceof Tr?l.withPrependedResults(a):l}return a}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=[Object.create(null)];for(let i of t.entries){let a=typeof i.key=="string"?[i.key]:G(e,i.key,r),o=G(e,i.value,r),l=[];for(let c of s)for(let u of a){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 o)l.push(Ke(c));continue}for(let f of o){let p=Ke(c);Pe(p,u,f),l.push(p)}}s.length=0,s.push(...l)}return s}case"Paren":return G(e,t.expr,r);case"BinaryOp":return o5(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 a=o=>o.length>5?`"${o.slice(0,3)}...`:JSON.stringify(o);throw new Error(`string (${a(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 a of t.elifs)if(G(e,a.cond,r).some(Qt))return G(e,a.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 vi?s.value:s instanceof Error?s.message:String(s);return G(i,t.catch,r)}return[]}case"Call":return Fh(e,t.name,t.args,r);case"VarBind":return G(e,t.value,r).flatMap(i=>{let a=null,o=[];t.pattern?o.push(t.pattern):t.name&&o.push({type:"var",name:t.name}),t.alternatives&&o.push(...t.alternatives);for(let l of o)if(a=ys(r,l,i),a!==null)break;return a===null?[]:G(e,t.body,a)});case"VarRef":{if(t.name==="$ENV")return[r.env?xt(r.env):Object.create(null)];let s=r.vars.get(t.name);return s!==void 0?[s]:[null]}case"Recurse":{let s=[],i=new WeakSet,a=o=>{if(o&&typeof o=="object"){if(i.has(o))return;i.add(o)}if(s.push(o),Array.isArray(o))for(let l of o)a(l);else if(o&&typeof o=="object")for(let l of Object.keys(o))a(o[l])};return a(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(o=>typeof o=="string"?o:JSON.stringify(o)).join("")).join("")];case"UpdateOp":return[i5(e,t.path,t.op,t.value,r)];case"Reduce":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],a=r.limits.maxDepth??Lh;for(let o of s){let l;if(t.pattern){if(l=ys(r,t.pattern,o),l===null)continue}else l=Ii(r,t.varName,o);if(i=G(i,t.update,l)[0],Rr(i,a+1)>a)return[null]}return[i]}case"Foreach":{let s=G(e,t.expr,r),i=G(e,t.init,r)[0],a=[];for(let o of s)try{let l;if(t.pattern){if(l=ys(r,t.pattern,o),l===null)continue}else l=Ii(r,t.varName,o);if(i=G(i,t.update,l)[0],t.extract){let c=G(i,t.extract,l);a.push(...c)}else a.push(i)}catch(l){throw l instanceof Tr?l.withPrependedResults(a):l}return a}case"Label":try{return G(e,t.body,{...r,labels:new Set([...r.labels??[],t.name])})}catch(s){if(s instanceof Tr&&s.label===t.name)return s.partialResults;throw s}case"Break":throw new Tr(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 a={...r,funcs:s};return G(e,t.body,a)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function _h(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function i5(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"?Bo(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 a(l,c,u){switch(c.type){case"Identity":return u(l);case"Field":{if(!Ie(c.name))return l;if(c.base)return a(l,c.base,f=>{if(f&&typeof f=="object"&&!Array.isArray(f)){let p=Ke(f),h=Object.hasOwn(p,c.name)?p[c.name]:void 0;return Pe(p,c.name,u(h)),p}return f});if(l&&typeof l=="object"&&!Array.isArray(l)){let f=Ke(l),p=Object.hasOwn(f,c.name)?f[c.name]:void 0;return Pe(f,c.name,u(p)),f}return l}case"Index":{let p=G(e,c.index,s)[0];if(typeof p=="number"&&Number.isNaN(p))throw new Error("Cannot set array element at NaN index");if(typeof p=="number"&&!Number.isInteger(p)&&(p=Math.trunc(p)),c.base)return a(l,c.base,h=>{if(typeof p=="number"&&Array.isArray(h)){let m=[...h],d=p<0?m.length+p:p;if(d>=0){for(;m.length<=d;)m.push(null);m[d]=u(m[d])}return m}if(typeof p=="string"&&h&&typeof h=="object"&&!Array.isArray(h)){if(!Ie(p))return h;let m=Ke(h),d=Object.hasOwn(m,p)?m[p]:void 0;return Pe(m,p,u(d)),m}return h});if(typeof p=="number"){if(p>536870911)throw new Error("Array index too large");if(p<0&&(!l||!Array.isArray(l)))throw new Error("Out of bounds negative array index");if(Array.isArray(l)){let m=[...l],d=p<0?m.length+p:p;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<=p;)m.push(null);return m[p]=u(null),m}return l}if(typeof p=="string"&&l&&typeof l=="object"&&!Array.isArray(l)){if(!Ie(p))return l;let h=Ke(l),m=Object.hasOwn(h,p)?h[p]:void 0;return Pe(h,p,u(m)),h}return l}case"Iterate":{let f=p=>{if(Array.isArray(p))return p.map(h=>u(h));if(p&&typeof p=="object"){let h=Object.create(null);for(let[m,d]of Object.entries(p))Ie(m)&&Pe(h,m,u(d));return h}return p};return c.base?a(l,c.base,f):f(l)}case"Pipe":{let f=a(l,c.left,p=>p);return a(f,c.right,u)}default:return u(l)}}return a(e,t,l=>{if(n==="|=")return i(l,l);let c=G(e,r,s);return i(l,c[0]??null)})}function a5(e,t,n){function r(i,a,o){switch(a.type){case"Identity":return o;case"Field":{if(!Ie(a.name))return i;if(a.base){let l=G(i,a.base,n)[0],c=r(l,{type:"Field",name:a.name},o);return r(i,a.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){let l=Ke(i);return Pe(l,a.name,o),l}return i}case"Index":{if(a.base){let u=G(i,a.base,n)[0],f=r(u,{type:"Index",index:a.index},o);return r(i,a.base,f)}let c=G(e,a.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]=o),u}if(typeof c=="string"&&i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(c))return i;let u=Ke(i);return Pe(u,c,o),u}return i}default:return i}}function s(i,a){switch(a.type){case"Identity":return null;case"Field":{if(!Ie(a.name))return i;if(a.base){let l=G(i,a.base,n)[0];if(l==null)return i;let c=s(l,{type:"Field",name:a.name});return r(i,a.base,c)}if(i&&typeof i=="object"&&!Array.isArray(i)){if(!Ie(a.name))return i;let l=Ke(i);return delete l[a.name],l}return i}case"Index":{if(a.base){let u=G(i,a.base,n)[0];if(u==null)return i;let f=s(u,{type:"Index",index:a.index});return r(i,a.base,f)}let c=G(e,a.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=Ke(i);return delete u[c],u}return i}case"Iterate":return Array.isArray(i)?[]:i&&typeof i=="object"?Object.create(null):i;case"Pipe":{let u=function(h,m,d){switch(m.type){case"Identity":return d;case"Field":{if(!Ie(m.name))return h;if(h&&typeof h=="object"&&!Array.isArray(h)){let g=Ke(h);return Pe(g,m.name,d),g}return h}case"Index":{let w=G(e,m.index,n)[0];if(typeof w=="number"&&Array.isArray(h)){let y=[...h],b=w<0?y.length+w:w;return b>=0&&b<y.length&&(y[b]=d),y}if(typeof w=="string"&&h&&typeof h=="object"&&!Array.isArray(h)){if(!Ie(w))return h;let y=Ke(h);return Pe(y,w,d),y}return h}case"Pipe":{let g=G(h,m.left,n)[0],w=u(g,m.right,d);return u(h,m.left,w)}default:return h}};var o=u;let l=a.left,c=a.right,f=G(i,l,n)[0];if(f==null)return i;let p=s(f,c);return u(i,l,p)}default:return i}}return s(e,t)}function o5(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),a=G(e,r,s);return i.flatMap(o=>a.map(l=>{switch(t){case"+":return o===null?l:l===null?o:typeof o=="number"&&typeof l=="number"||typeof o=="string"&&typeof l=="string"?o+l:Array.isArray(o)&&Array.isArray(l)?[...o,...l]:o&&l&&typeof o=="object"&&typeof l=="object"&&!Array.isArray(o)&&!Array.isArray(l)?Bo(o,l):null;case"-":if(typeof o=="number"&&typeof l=="number")return o-l;if(Array.isArray(o)&&Array.isArray(l)){let c=new Set(l.map(u=>JSON.stringify(u)));return o.filter(u=>!c.has(JSON.stringify(u)))}if(typeof o=="string"&&typeof l=="string"){let c=u=>u.length>10?`"${u.slice(0,10)}...`:JSON.stringify(u);throw new Error(`string (${c(o)}) and string (${c(l)}) cannot be subtracted`)}return null;case"*":return typeof o=="number"&&typeof l=="number"?o*l:typeof o=="string"&&typeof l=="number"?o.repeat(l):o&&l&&typeof o=="object"&&typeof l=="object"&&!Array.isArray(o)&&!Array.isArray(l)?Go(o,l):null;case"/":if(typeof o=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${o}) and number (${l}) cannot be divided because the divisor is zero`);return o/l}return typeof o=="string"&&typeof l=="string"?o.split(l):null;case"%":if(typeof o=="number"&&typeof l=="number"){if(l===0)throw new Error(`number (${o}) and number (${l}) cannot be divided (remainder) because the divisor is zero`);return!Number.isFinite(o)&&!Number.isNaN(o)?!Number.isFinite(l)&&!Number.isNaN(l)&&o<0&&l>0?-1:0:o%l}return null;case"==":return Or(o,l);case"!=":return!Or(o,l);case"<":return gs(o,l)<0;case"<=":return gs(o,l)<=0;case">":return gs(o,l)>0;case">=":return gs(o,l)>=0;default:return null}}))}function Fh(e,t,n,r){let s=n5.get(t);if(s)return typeof e=="number"?[s(e)]:[null];let i=Zo(e,t,n,r,G);if(i!==null)return i;let a=Jo(e,t,n,r,G);if(a!==null)return a;let o=jo(e,t,n,r,G);if(o!==null)return o;let l=Vo(e,t,r.limits.maxDepth);if(l!==null)return l;let c=el(e,t);if(c!==null)return c;let u=Qo(e,t,n,r,G);if(u!==null)return u;let f=zo(e,t,n,r,G,Dh,Ei,Qt,Ai,te);if(f!==null)return f;let p=Xo(e,t,n,r,G,Qt,Ci,Ni,a5,ki);if(p!==null)return p;let h=qo(e,t,n,r,G,Or);if(h!==null)return h;let m=Ho(e,t,n,r,G,Dh,Qt,te);if(m!==null)return m;let d=Ko(e,t,n,r,G,Qt,s5,Fh);if(d!==null)return d;let g=Yo(e,t,n,r,G,Or);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 w=n.length>0?G(e,n[0],r)[0]:e;throw new vi(w)}case"env":return[r.env?xt(r.env):Object.create(null)];case"debug":return[e];case"input_line_number":return[1];default:{let w=`${t}/${n.length}`,y=r.funcs?.get(w);if(y){let b=y.closure??r.funcs??new Map,x=new Map(b);x.set(w,y);for(let $=0;$<y.params.length;$++){let O=y.params[$],F=n[$];if(F){let R=G(e,F,r),z;if(R.length===0)z={type:"Call",name:"empty",args:[]};else if(R.length===1)z={type:"Literal",value:R[0]};else{z={type:"Literal",value:R[R.length-1]};for(let k=R.length-2;k>=0;k--)z={type:"Comma",left:{type:"Literal",value:R[k]},right:z}}x.set(`${O}/0`,{params:[],body:z})}}let S={...r,funcs:x};return G(e,y.body,S)}throw new Error(`Unknown function: ${t}`)}}}function ki(e,t,n,r,s){if(t.type==="Comma"){let o=t;ki(e,o.left,n,r,s),ki(e,o.right,n,r,s);return}let i=_n(t);if(i!==null){s.push([...r,...i]);return}if(t.type==="Iterate"){if(Array.isArray(e))for(let o=0;o<e.length;o++)s.push([...r,o]);else if(e&&typeof e=="object")for(let o of Object.keys(e))s.push([...r,o]);return}if(t.type==="Recurse"){let o=(l,c)=>{if(s.push([...r,...c]),l&&typeof l=="object")if(Array.isArray(l))for(let u=0;u<l.length;u++)o(l[u],[...c,u]);else for(let u of Object.keys(l))o(l[u],[...c,u])};o(e,[]);return}if(t.type==="Pipe"){let o=_n(t.left);if(o!==null){let l=G(e,t.left,n);for(let c of l)ki(c,t.right,n,[...r,...o],s);return}}G(e,t,n).length>0&&s.push(r)}var Tr,vi,t5,Lh,n5,Mh=I(()=>{"use strict";Pn();ye();Th();Ph();Nn();Si();Tr=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])}},vi=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},t5=1e4,Lh=2e3,n5=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 Wh(e){let t=[],n=0,r=(c=0)=>e[n+c],s=()=>e[n++],i=()=>n>=e.length,a=c=>c>="0"&&c<="9",o=c=>c>="a"&&c<="z"||c>="A"&&c<="Z"||c==="_",l=c=>o(c)||a(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(a(u)){let f=u;for(;!i()&&(a(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 p=s();switch(p){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+=p}}else f+=s();i()||s(),t.push({type:"STRING",value:f,pos:c});continue}if(o(u)||u==="$"||u==="@"){let f=u;for(;!i()&&l(r());)f+=s();let p=Uh.get(f);p?t.push({type:p,value:f,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 Bh(e){let t=Wh(e);return new nl(t).parse()}var Uh,$i,nl,zh=I(()=>{"use strict";Uh=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"]]),$i=new Set(Uh.values());nl=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()}isFieldNameAfterDot(t=0){let n=this.peek(t),r=this.peek(t+1);return r.type==="STRING"?!0:r.type==="IDENT"||$i.has(r.type)?r.pos===n.pos+1:!1}isIdentLike(){let t=this.peek().type;return t==="IDENT"||$i.has(t)}consumeFieldNameAfterDot(t){let n=this.peek();return n.type==="STRING"?this.advance().value:(n.type==="IDENT"||$i.has(n.type))&&n.pos===t.pos+1?this.advance().value:null}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"||$i.has(t.type)){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.isFieldNameAfterDot())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.check("DOT")){let t=this.advance();if(this.check("LBRACKET")){if(this.advance(),this.match("RBRACKET"))return{type:"Iterate"};if(this.check("COLON")){this.advance();let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",end:s}}let r=this.parseExpr();if(this.match("COLON")){let s=this.check("RBRACKET")?void 0:this.parseExpr();return this.expect("RBRACKET","Expected ']'"),{type:"Slice",start:r,end:s}}return this.expect("RBRACKET","Expected ']'"),{type:"Index",index:r}}let n=this.consumeFieldNameAfterDot(t);return n!==null?{type:"Field",name:n}:{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 a=n.type==="var"?n.name:"";return{type:"Foreach",expr:t,varName:a,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 a=this.expect("IDENT","Expected parameter name");for(r.push(a.value);this.match("SEMICOLON");){let o=this.expect("IDENT","Expected parameter name");r.push(o.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.isIdentLike()){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 a=this.parseExpr();r.push({cond:i,then:a})}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,a="";for(;s<t.length&&i>0;)t[s]==="("?i++:t[s]===")"&&i--,i>0&&(a+=t[s]),s++;let o=Wh(a),l=new e(o);n.push(l.parse())}else r+=t[s],s++;return r&&n.push(r),{type:"StringInterp",parts:n}}}});var Hh=I(()=>{"use strict";Mh();zh()});var Gh={};K(Gh,{flagsForFuzzing:()=>u5,jqCommand:()=>c5});function jh(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 a=i,o=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===a?l++:f===o&&l--),n++}if(l!==0)throw new Error(`Unexpected end of JSON input at position ${n} (unclosed ${a})`);t.push(JSON.parse(e.slice(s,n)))}else if(i==='"'){let a=!1;for(n++;n<r;){let o=e[n];if(a)a=!1;else if(o==="\\")a=!0;else if(o==='"'){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 a=e.slice(n,n+10);throw new Error(`Invalid JSON at position ${s}: unexpected '${a.split(/\s/)[0]}'`)}}return t}function ws(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 a=s?" ":" ";if(Array.isArray(e))return e.length===0?"[]":t?`[${e.map(l=>ws(l,!0,!1,r,s)).join(",")}]`:`[
|
|
@@ -567,75 +567,75 @@ ${a.repeat(i)}}`}return String(e)}var l5,c5,u5,Vh=I(()=>{"use strict";ye();Zn();
|
|
|
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=o,p=l;return i&&(f=f.toLowerCase(),p=p.toLowerCase()),f===p?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
|
-
`,stderr:"",exitCode:1}:{stdout:Qh.createTwoFilesPatch(c,u,o,l,"","",{context:3}),stderr:"",exitCode:1}}},w5={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2}});var Jh={};K(Jh,{dateCommand:()=>
|
|
571
|
-
`;break;case"p":s+=r.H<12?"AM":"PM";break;case"P":s+=r.H<12?"am":"pm";break;case"R":s+=`${
|
|
570
|
+
`,stderr:"",exitCode:1}:{stdout:Qh.createTwoFilesPatch(c,u,o,l,"","",{context:3}),stderr:"",exitCode:1}}},w5={name:"diff",flags:[{flag:"-u",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-i",type:"boolean"}],needsArgs:!0,minArgs:2}});var Jh={};K(Jh,{dateCommand:()=>S5,flagsForFuzzing:()=>C5});function It(e,t=2){return String(e).padStart(t,"0")}function Oi(e,t,n){let r={Y:e.getUTCFullYear(),m:e.getUTCMonth(),D:e.getUTCDate(),H:e.getUTCHours(),M:e.getUTCMinutes(),S:e.getUTCSeconds(),w:e.getUTCDay()},s="",i=0;for(;i<t.length;){if(t[i]==="%"&&i+1<t.length){let a=t[++i];switch(a){case"%":s+="%";break;case"a":s+=x5[r.w];break;case"b":case"h":s+=E5[r.m];break;case"d":s+=It(r.D);break;case"e":s+=String(r.D).padStart(2," ");break;case"F":s+=`${r.Y}-${It(r.m+1)}-${It(r.D)}`;break;case"H":s+=It(r.H);break;case"I":s+=It(r.H%12||12);break;case"m":s+=It(r.m+1);break;case"M":s+=It(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+=`${It(r.H)}:${It(r.M)}`;break;case"s":s+=Math.floor(e.getTime()/1e3);break;case"S":s+=It(r.S);break;case"t":s+=" ";break;case"T":s+=`${It(r.H)}:${It(r.M)}:${It(r.S)}`;break;case"u":s+=r.w||7;break;case"w":s+=r.w;break;case"y":s+=It(r.Y%100);break;case"Y":s+=r.Y;break;case"z":s+="+0000";break;case"Z":s+="UTC";break;default:s+=`%${a}`}}else s+=t[i];i++}return s}function A5(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 b5,x5,E5,S5,C5,ed=I(()=>{"use strict";se();b5={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"]},x5=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],E5=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];S5={name:"date",async execute(e,t){if(U(e))return M(b5);let n=!1,r=null,s=null,i=!1,a=!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")a=!0;else if(u.startsWith("+"))s=u.slice(1);else{if(u.startsWith("--"))return Y("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")a=!0;else return Y("date",`-${f}`)}}let o=r!==null?A5(r):new Date;if(!o)return{stdout:"",stderr:`date: invalid date '${r}'
|
|
572
572
|
`,exitCode:1};let l;return s?l=Oi(o,s,n):i?l=Oi(o,"%Y-%m-%dT%H:%M:%S%z",n):a?l=Oi(o,"%a, %d %b %Y %H:%M:%S %z",n):l=Oi(o,"%a %b %e %H:%M:%S %Z %Y",n),{stdout:`${l}
|
|
573
|
-
`,stderr:"",exitCode:0}}},
|
|
573
|
+
`,stderr:"",exitCode:0}}},C5={name:"date",flags:[{flag:"-d",type:"value",valueHint:"string"},{flag:"-u",type:"boolean"},{flag:"-I",type:"boolean"},{flag:"-R",type:"boolean"}]}});var td={};K(td,{flagsForFuzzing:()=>I5,sleepCommand:()=>v5});function k5(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 N5,v5,I5,nd=I(()=>{"use strict";se();N5={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)
|
|
575
575
|
m - minutes
|
|
576
576
|
h - hours
|
|
577
577
|
d - days
|
|
578
578
|
|
|
579
|
-
NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};
|
|
580
|
-
`,exitCode:1};let n=0;for(let r of e){let s=
|
|
581
|
-
`,exitCode:1};n+=s}return t.sleep?await t.sleep(n):await new Promise(r=>setTimeout(r,n)),{stdout:"",stderr:"",exitCode:0}}}
|
|
579
|
+
NUMBER may be a decimal number.`,options:[" --help display this help and exit"]};v5={name:"sleep",async execute(e,t){if(U(e))return M(N5);if(e.length===0)return{stdout:"",stderr:`sleep: missing operand
|
|
580
|
+
`,exitCode:1};let n=0;for(let r of e){let s=k5(r);if(s===null)return{stdout:"",stderr:`sleep: invalid time interval '${r}'
|
|
581
|
+
`,exitCode:1};n+=s}return t.sleep?await t.sleep(n):await new Promise(r=>setTimeout(r,n)),{stdout:"",stderr:"",exitCode:0}}},I5={name:"sleep",flags:[],needsArgs:!0}});var rd={};K(rd,{flagsForFuzzing:()=>T5,timeoutCommand:()=>R5});function O5(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 $5,R5,T5,sd=I(()=>{"use strict";se();$5={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
|
|
|
583
583
|
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"]};
|
|
588
|
-
`,exitCode:1};let i=s[0],a=
|
|
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"]};R5={name:"timeout",async execute(e,t){if(U(e))return M($5);let n=!1,r=0;for(let p=0;p<e.length;p++){let h=e[p];if(h==="--preserve-status")n=!0,r=p+1;else if(h==="--foreground")r=p+1;else if(h==="-k"||h==="--kill-after")p++,r=p+1;else if(h.startsWith("--kill-after="))r=p+1;else if(h==="-s"||h==="--signal")p++,r=p+1;else if(h.startsWith("--signal="))r=p+1;else{if(h.startsWith("--")&&h!=="--")return Y("timeout",h);if(h.startsWith("-")&&h.length>1&&h!=="--")if(h.startsWith("-k"))r=p+1;else if(h.startsWith("-s"))r=p+1;else return Y("timeout",h);else{r=p;break}}}let s=e.slice(r);if(s.length===0)return{stdout:"",stderr:`timeout: missing operand
|
|
588
|
+
`,exitCode:1};let i=s[0],a=O5(i);if(a===null)return{stdout:"",stderr:`timeout: invalid time interval '${i}'
|
|
589
589
|
`,exitCode:1};let o=s.slice(1);if(o.length===0)return{stdout:"",stderr:`timeout: missing operand
|
|
590
590
|
`,exitCode:1};if(!t.exec)return{stdout:"",stderr:`timeout: exec not available
|
|
591
|
-
`,exitCode:1};let l=o.map(p=>p.includes(" ")||p.includes(" ")?`'${p.replace(/'/g,"'\\''")}'`:p).join(" "),c=new Promise(p=>{setTimeout(()=>p({timedOut:!0}),a)}),u=t.exec(l,{cwd:t.cwd}).then(p=>({timedOut:!1,result:p})),f=await Promise.race([c,u]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}},
|
|
591
|
+
`,exitCode:1};let l=o.map(p=>p.includes(" ")||p.includes(" ")?`'${p.replace(/'/g,"'\\''")}'`:p).join(" "),c=new Promise(p=>{setTimeout(()=>p({timedOut:!0}),a)}),u=t.exec(l,{cwd:t.cwd}).then(p=>({timedOut:!1,result:p})),f=await Promise.race([c,u]);return f.timedOut?{stdout:"",stderr:"",exitCode:124}:f.result}},T5={name:"timeout",flags:[{flag:"-k",type:"value",valueHint:"string"},{flag:"-s",type:"value",valueHint:"string"},{flag:"--preserve-status",type:"boolean"},{flag:"--foreground",type:"boolean"}],needsArgs:!0,minArgs:2}});var id={};K(id,{flagsForFuzzing:()=>_5,timeCommand:()=>P5});function D5(e){let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}:${n.toString().padStart(2,"0")}:${r.toFixed(2).padStart(5,"0")}`:`${n}:${r.toFixed(2).padStart(5,"0")}`}var P5,_5,ad=I(()=>{"use strict";Pn();P5={name:"time",async execute(e,t){let n="%e %M",r=null,s=!1,i=!1,a=0;for(;a<e.length;){let m=e[a];if(m==="-f"||m==="--format"){if(a++,a>=e.length)return{stdout:"",stderr:`time: missing argument to '-f'
|
|
592
592
|
`,exitCode:1};n=e[a],a++}else if(m==="-o"||m==="--output"){if(a++,a>=e.length)return{stdout:"",stderr:`time: missing argument to '-o'
|
|
593
593
|
`,exitCode:1};r=e[a],a++}else if(m==="-a"||m==="--append")s=!0,a++;else if(m==="-v"||m==="--verbose")n=`Command being timed: %C
|
|
594
594
|
Elapsed (wall clock) time: %e seconds
|
|
595
595
|
Maximum resident set size (kbytes): %M`,a++;else if(m==="-p"||m==="--portability")i=!0,a++;else if(m==="--"){a++;break}else if(m.startsWith("-"))a++;else break}let o=e.slice(a);if(o.length===0)return{stdout:"",stderr:"",exitCode:0};let l=performance.now(),c=o.join(" "),u;try{if(!t.exec)return{stdout:"",stderr:`time: exec not available
|
|
596
|
-
`,exitCode:1};u=await t.exec(c,{env:
|
|
596
|
+
`,exitCode:1};u=await t.exec(c,{env:xt(t.env),cwd:t.cwd})}catch(m){u={stdout:"",stderr:`time: ${m.message}
|
|
597
597
|
`,exitCode:127}}let p=(performance.now()-l)/1e3,h;if(i?h=`real ${p.toFixed(2)}
|
|
598
598
|
user 0.00
|
|
599
599
|
sys 0.00
|
|
600
|
-
`:(h=n.replace(/%e/g,p.toFixed(2)).replace(/%E/g,
|
|
600
|
+
`:(h=n.replace(/%e/g,p.toFixed(2)).replace(/%E/g,D5(p)).replace(/%M/g,"0").replace(/%S/g,"0.00").replace(/%U/g,"0.00").replace(/%P/g,"0%").replace(/%C/g,c),h.endsWith(`
|
|
601
601
|
`)||(h+=`
|
|
602
602
|
`)),r)try{let m=t.fs.resolvePath(t.cwd,r);if(s&&await t.fs.exists(m)){let d=await t.fs.readFile(m);await t.fs.writeFile(m,d+h)}else await t.fs.writeFile(m,h)}catch(m){return{stdout:u.stdout,stderr:u.stderr+`time: cannot write to '${r}': ${m.message}
|
|
603
|
-
`,exitCode:u.exitCode}}else u={...u,stderr:u.stderr+h};return u}};
|
|
603
|
+
`,exitCode:u.exitCode}}else u={...u,stderr:u.stderr+h};return u}};_5={name:"time",flags:[{flag:"-p",type:"boolean"}],needsArgs:!0}});var od={};K(od,{flagsForFuzzing:()=>F5,seqCommand:()=>L5});var L5,F5,ld=I(()=>{"use strict";L5={name:"seq",async execute(e){let t=`
|
|
604
604
|
`,n=!1,r=[],s=0;for(;s<e.length;){let m=e[s];if(m==="-s"&&s+1<e.length){t=e[s+1],s+=2;continue}if(m==="-w"){n=!0,s++;continue}if(m==="--"){s++;break}if(m.startsWith("-")&&m!=="-"){if(m.startsWith("-s")&&m.length>2){t=m.slice(2),s++;continue}if((m==="-ws"||m==="-sw")&&(n=!0,s+1<e.length)){t=e[s+1],s+=2;continue}}r.push(m),s++}for(;s<e.length;)r.push(e[s]),s++;if(r.length===0)return{stdout:"",stderr:`seq: missing operand
|
|
605
605
|
`,exitCode:1};let i=1,a=1,o;if(r.length===1?o=parseFloat(r[0]):r.length===2?(i=parseFloat(r[0]),o=parseFloat(r[1])):(i=parseFloat(r[0]),a=parseFloat(r[1]),o=parseFloat(r[2])),Number.isNaN(i)||Number.isNaN(a)||Number.isNaN(o))return{stdout:"",stderr:`seq: invalid floating point argument: '${r.find(d=>Number.isNaN(parseFloat(d)))}'
|
|
606
606
|
`,exitCode:1};if(a===0)return{stdout:"",stderr:`seq: invalid Zero increment value: '0'
|
|
607
607
|
`,exitCode:1};let l=[],c=m=>{let d=String(m),g=d.indexOf(".");return g===-1?0:d.length-g-1},u=Math.max(c(i),c(a),c(o)),f=1e5,p=0;if(a>0)for(let m=i;m<=o+1e-10&&!(p++>f);m+=a)l.push(u>0?m.toFixed(u):String(Math.round(m)));else for(let m=i;m>=o-1e-10&&!(p++>f);m+=a)l.push(u>0?m.toFixed(u):String(Math.round(m)));if(n&&l.length>0){let m=Math.max(...l.map(d=>d.replace("-","").length));for(let d=0;d<l.length;d++){let g=l[d].startsWith("-"),y=(g?l[d].slice(1):l[d]).padStart(m,"0");l[d]=g?`-${y}`:y}}let h=l.join(t);return{stdout:h?`${h}
|
|
608
|
-
`:"",stderr:"",exitCode:0}}},
|
|
609
|
-
`,exitCode:2};try{let n=
|
|
608
|
+
`:"",stderr:"",exitCode:0}}},F5={name:"seq",flags:[{flag:"-s",type:"value",valueHint:"string"},{flag:"-w",type:"boolean"}],needsArgs:!0}});var cd={};K(cd,{exprCommand:()=>M5,flagsForFuzzing:()=>W5});function U5(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(),p=parseInt(c,10),h=parseInt(f,10),m=!Number.isNaN(p)&&!Number.isNaN(h),d;u==="="?d=m?p===h:c===f:u==="!="?d=m?p!==h:c!==f:u==="<"?d=m?p<h:c<f:u===">"?d=m?p>h:c>f:u==="<="?d=m?p<=h:c<=f:d=m?p>=h:c>=f,c=d?"1":"0"}else break}return c}function i(){let c=a();for(;t<e.length;){let u=e[t];if(u==="+"||u==="-"){t++;let f=a(),p=parseInt(c,10),h=parseInt(f,10);if(Number.isNaN(p)||Number.isNaN(h))throw new Error("non-integer argument");c=String(u==="+"?p+h:p-h)}else break}return c}function a(){let c=o();for(;t<e.length;){let u=e[t];if(u==="*"||u==="/"||u==="%"){t++;let f=o(),p=parseInt(c,10),h=parseInt(f,10);if(Number.isNaN(p)||Number.isNaN(h))throw new Error("non-integer argument");if((u==="/"||u==="%")&&h===0)throw new Error("division by zero");u==="*"?c=String(p*h):u==="/"?c=String(Math.trunc(p/h)):c=String(p%h)}else break}return c}function o(){let c=l();for(;t<e.length&&e[t]===":";){t++;let u=l(),p=V(`^${u}`).match(c);p?c=p[1]!==void 0?p[1]:String(p[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(),h=V(f).match(u);return h?h[1]!==void 0?h[1]:String(h[0].length):"0"}if(c==="substr"){t++;let u=l(),f=parseInt(l(),10),p=parseInt(l(),10);if(Number.isNaN(f)||Number.isNaN(p))throw new Error("non-integer argument");return u.substring(f-1,f-1+p)}if(c==="index"){t++;let u=l(),f=l();for(let p=0;p<u.length;p++)if(f.includes(u[p]))return String(p+1);return"0"}if(c==="length"){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 M5,W5,ud=I(()=>{"use strict";Me();M5={name:"expr",async execute(e,t){if(e.length===0)return{stdout:"",stderr:`expr: missing operand
|
|
609
|
+
`,exitCode:2};try{let n=U5(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}}}};
|
|
611
|
+
`,exitCode:2}}}};W5={name:"expr",flags:[],needsArgs:!0}});function z5(e){function t(h,m){return h<<m|h>>>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,a=new Uint8Array(e.length+i+8);a.set(e),a[e.length]=128;let o=new DataView(a.buffer);o.setUint32(a.length-8,s>>>0,!0),o.setUint32(a.length-4,Math.floor(s/4294967296),!0);let l=1732584193,c=4023233417,u=2562383102,f=271733878;for(let h=0;h<a.length;h+=64){let m=new Uint32Array(16);for(let b=0;b<16;b++)m[b]=o.getUint32(h+b*4,!0);let d=l,g=c,w=u,y=f;for(let b=0;b<64;b++){let x,S;b<16?(x=g&w|~g&y,S=b):b<32?(x=y&g|~y&w,S=(5*b+1)%16):b<48?(x=g^w^y,S=(3*b+5)%16):(x=w^(g|~y),S=7*b%16),x=x+d+n[b]+m[S]>>>0,d=y,y=w,w=g,g=g+t(x,r[b])>>>0}l=l+d>>>0,c=c+g>>>0,u=u+w>>>0,f=f+y>>>0}let p=new Uint8Array(16);return new DataView(p.buffer).setUint32(0,l,!0),new DataView(p.buffer).setUint32(4,c,!0),new DataView(p.buffer).setUint32(8,u,!0),new DataView(p.buffer).setUint32(12,f,!0),Array.from(p).map(h=>h.toString(16).padStart(2,"0")).join("")}async function fd(e,t){if(e==="md5")return z5(t);let n=B5.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 Pr(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 M(r);let a=!1,o=[];for(let f of s)if(f==="-c"||f==="--check")a=!0;else if(!(f==="-b"||f==="-t"||f==="--binary"||f==="--text")){if(f.startsWith("-")&&f!=="-")return Y(e,f);o.push(f)}o.length===0&&o.push("-");let l=async f=>{if(f==="-")return Uint8Array.from(i.stdin,p=>p.charCodeAt(0));try{return await i.fs.readFileBuffer(i.fs.resolvePath(i.cwd,f))}catch{return null}};if(a){let f=0,p="";for(let h of o){let m=h==="-"?i.stdin:await i.fs.readFile(i.fs.resolvePath(i.cwd,h)).catch(()=>null);if(m===null)return{stdout:"",stderr:`${e}: ${h}: 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[,w,y]=g,b=await l(y);if(b===null){p+=`${y}: FAILED open or read
|
|
614
614
|
`,f++;continue}let x=await fd(t,b)===w.toLowerCase();p+=`${y}: ${x?"OK":"FAILED"}
|
|
615
615
|
`,x||f++}}return f>0&&(p+=`${e}: WARNING: ${f} computed checksum${f>1?"s":""} did NOT match
|
|
616
616
|
`),{stdout:p,stderr:"",exitCode:f>0?1:0}}let c="",u=0;for(let f of o){let p=await l(f);if(p===null){c+=`${e}: ${f}: No such file or directory
|
|
617
617
|
`,u=1;continue}c+=`${await fd(t,p)} ${f}
|
|
618
|
-
`}return{stdout:c,stderr:"",exitCode:u}}}}var z5,Ri=I(()=>{"use strict";se();z5=new Map([["sha1","SHA-1"],["sha256","SHA-256"]])});var pd={};K(pd,{flagsForFuzzing:()=>G5,md5sumCommand:()=>j5});var j5,G5,hd=I(()=>{"use strict";Ri();j5=Pr("md5sum","md5","compute MD5 message digest"),G5={name:"md5sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var dd={};K(dd,{flagsForFuzzing:()=>q5,sha1sumCommand:()=>V5});var V5,q5,md=I(()=>{"use strict";Ri();V5=Pr("sha1sum","sha1","compute SHA1 message digest"),q5={name:"sha1sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var gd={};K(gd,{flagsForFuzzing:()=>K5,sha256sumCommand:()=>Z5});var Z5,K5,yd=I(()=>{"use strict";Ri();Z5=Pr("sha256sum","sha256","compute SHA256 message digest"),K5={name:"sha256sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var wd=Hs(rl=>{rl.read=function(e,t,n,r,s){var i,a,o=s*8-r-1,l=(1<<o)-1,c=l>>1,u=-7,f=n?s-1:0,p=n?-1:1,h=e[t+f];for(f+=p,i=h&(1<<-u)-1,h>>=-u,u+=o;u>0;i=i*256+e[t+f],f+=p,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=a*256+e[t+f],f+=p,u-=8);if(i===0)i=1-c;else{if(i===l)return a?NaN:(h?-1:1)*(1/0);a=a+Math.pow(2,r),i=i-c}return(h?-1:1)*a*Math.pow(2,i-r)};rl.write=function(e,t,n,r,s,i){var a,o,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,p=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=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?(o=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+f>=1?t+=p/l:t+=p*Math.pow(2,1-f),t*l>=2&&(a++,l/=2),a+f>=u?(o=0,a=u):a+f>=1?(o=(t*l-1)*Math.pow(2,s),a=a+f):(o=t*Math.pow(2,f-1)*Math.pow(2,s),a=0));s>=8;e[n+h]=o&255,h+=m,o/=256,s-=8);for(a=a<<s|o,c+=s;c>0;e[n+h]=a&255,h+=m,a/=256,c-=8);e[n+h-m]|=d*128}});function bd(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):X5(e);case"utf-16le":return Y5(e);case"ascii":return J5(e);case"latin1":case"iso-8859-1":return ew(e);case"windows-1252":return tw(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function X5(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,a=e[n++]&63,o=(r&7)<<18|s<<12|i<<6|a;o-=65536,t+=String.fromCharCode(55296+(o>>10&1023),56320+(o&1023))}}return t}function Y5(e){let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function J5(e){return String.fromCharCode(...e.map(t=>t&127))}function ew(e){return String.fromCharCode(...e)}function tw(e){let t="";for(let n of e)n>=128&&n<=159&&sl[n]?t+=sl[n]:t+=String.fromCharCode(n);return t}var sl,Q5,xd=I(()=>{sl={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"},Q5={};for(let[e,t]of Object.entries(sl))Q5[t]=Number.parseInt(e)});function $t(e){return new DataView(e.buffer,e.byteOffset)}var Ed,Ad,Ve,Dr,Qe,Sd,Cd,Nd,Ot,bs=I(()=>{Ed=gu(wd(),1);xd();Ad={len:1,get(e,t){return $t(e).getUint8(t)},put(e,t,n){return $t(e).setUint8(t,n),t+1}},Ve={len:2,get(e,t){return $t(e).getUint16(t,!0)},put(e,t,n){return $t(e).setUint16(t,n,!0),t+2}},Dr={len:2,get(e,t){return $t(e).getUint16(t)},put(e,t,n){return $t(e).setUint16(t,n),t+2}},Qe={len:4,get(e,t){return $t(e).getUint32(t,!0)},put(e,t,n){return $t(e).setUint32(t,n,!0),t+4}},Sd={len:4,get(e,t){return $t(e).getUint32(t)},put(e,t,n){return $t(e).setUint32(t,n),t+4}},Cd={len:4,get(e,t){return $t(e).getInt32(t)},put(e,t,n){return $t(e).setInt32(t,n),t+4}},Nd={len:8,get(e,t){return $t(e).getBigUint64(t,!0)},put(e,t,n){return $t(e).setBigUint64(t,n,!0),t+8}},Ot=class{constructor(t,n){this.len=t,this.encoding=n}get(t,n=0){let r=t.subarray(n,n+this.len);return bd(r,this.encoding)}}});var rw,We,Jn,xs=I(()=>{rw="End-Of-Stream",We=class extends Error{constructor(){super(rw),this.name="EndOfStreamError"}},Jn=class extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}});var kd=I(()=>{});var er,Ti=I(()=>{xs();er=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 We;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 Jn;let s=await this.readFromStream(t.subarray(r),n);if(s===0)break;r+=s}if(!n&&r<t.length)throw new We;return r}}});var vd=I(()=>{xs();kd();Ti()});var Pi,Id=I(()=>{Ti();Pi=class extends er{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var Es,il=I(()=>{Id();Es=class extends Pi{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 _r,al=I(()=>{xs();Ti();_r=class extends er{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 We;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function ol(e){try{let t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new _r(t):new Es(t)}catch(t){if(t instanceof TypeError)return new _r(e.getReader());throw t}}var $d=I(()=>{il();al()});var tr=I(()=>{xs();vd();il();al();$d()});var kn,As=I(()=>{tr();kn=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 We;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 We;return t.get(r,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new We;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new We;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 iw,Di,Od=I(()=>{As();tr();iw=256e3,Di=class extends kn{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 We;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 a=new Uint8Array(r.length+i);return s=await this.peekBuffer(a,{mayBeLess:r.mayBeLess}),t.set(a.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 We)return 0;throw i}if(!r.mayBeLess&&s<r.length)throw new We}return s}async ignore(t){let n=Math.min(iw,t),r=new Uint8Array(n),s=0;for(;s<t;){let i=t-s,a=await this.readBuffer(r,{length:Math.min(n,i)});if(a<0)return a;s+=a}return s}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}});var _i,Rd=I(()=>{tr();As();_i=class extends kn{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 We;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 Li,Td=I(()=>{tr();As();Li=class extends kn{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 We;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 Pd(e,t){let n=ol(e),r=t??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new Di(n,r)}function Dd(e,t){return new _i(e,t)}function _d(e,t){return new Li(e,t)}var Ld=I(()=>{tr();Od();Rd();Td();tr();As()});var Md=Hs((kI,Fd)=>{var Lr=1e3,Fr=Lr*60,Mr=Fr*60,nr=Mr*24,ow=nr*7,lw=nr*365.25;Fd.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return cw(e);if(n==="number"&&isFinite(e))return t.long?fw(e):uw(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function cw(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*lw;case"weeks":case"week":case"w":return n*ow;case"days":case"day":case"d":return n*nr;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Mr;case"minutes":case"minute":case"mins":case"min":case"m":return n*Fr;case"seconds":case"second":case"secs":case"sec":case"s":return n*Lr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function uw(e){var t=Math.abs(e);return t>=nr?Math.round(e/nr)+"d":t>=Mr?Math.round(e/Mr)+"h":t>=Fr?Math.round(e/Fr)+"m":t>=Lr?Math.round(e/Lr)+"s":e+"ms"}function fw(e){var t=Math.abs(e);return t>=nr?Fi(e,t,nr,"day"):t>=Mr?Fi(e,t,Mr,"hour"):t>=Fr?Fi(e,t,Fr,"minute"):t>=Lr?Fi(e,t,Lr,"second"):e+" ms"}function Fi(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}});var Wd=Hs((vI,Ud)=>{function pw(e){n.debug=n,n.default=n,n.coerce=l,n.disable=a,n.enable=s,n.enabled=o,n.humanize=Md(),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 p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(u){let f,p=null,h,m;function d(...g){if(!d.enabled)return;let w=d,y=Number(new Date),b=y-(f||y);w.diff=b,w.prev=f,w.curr=y,f=y,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,($,O)=>{if($==="%%")return"%";x++;let F=n.formatters[O];if(typeof F=="function"){let R=g[x];$=F.call(w,R),g.splice(x,1),x--}return $}),n.formatArgs.call(w,g),(w.log||n.log).apply(w,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:()=>p!==null?p:(h!==n.namespaces&&(h=n.namespaces,m=n.enabled(u)),m),set:g=>{p=g}}),typeof n.init=="function"&&n.init(d),d}function r(u,f){let p=n(this.namespace+(typeof f>"u"?":":f)+u);return p.log=this.log,p}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 p of f)p[0]==="-"?n.skips.push(p.slice(1)):n.names.push(p)}function i(u,f){let p=0,h=0,m=-1,d=0;for(;p<u.length;)if(h<f.length&&(f[h]===u[p]||f[h]==="*"))f[h]==="*"?(m=h,d=p,h++):(p++,h++);else if(m!==-1)h=m+1,d++,p=d;else return!1;for(;h<f.length&&f[h]==="*";)h++;return h===f.length}function a(){let u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function o(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}Ud.exports=pw});var Bd=Hs((Rt,Mi)=>{Rt.formatArgs=dw;Rt.save=mw;Rt.load=gw;Rt.useColors=hw;Rt.storage=yw();Rt.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`."))}})();Rt.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 hw(){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 dw(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Mi.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)}Rt.log=console.debug||console.log||(()=>{});function mw(e){try{e?Rt.storage.setItem("debug",e):Rt.storage.removeItem("debug")}catch{}}function gw(){let e;try{e=Rt.storage.getItem("debug")||Rt.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function yw(){try{return localStorage}catch{}}Mi.exports=Wd()(Rt);var{formatters:ww}=Mi.exports;ww.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var rr,ll,zd,Hd,jd,Gd=I(()=>{bs();rr={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},ll={get(e){return{signature:Qe.get(e,0),compressedSize:Qe.get(e,8),uncompressedSize:Qe.get(e,12)}},len:16},zd={get(e){let t=Ve.get(e,6);return{signature:Qe.get(e,0),minVersion:Ve.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Ve.get(e,8),compressedSize:Qe.get(e,18),uncompressedSize:Qe.get(e,22),filenameLength:Ve.get(e,26),extraFieldLength:Ve.get(e,28),filename:null}},len:30},Hd={get(e){return{signature:Qe.get(e,0),nrOfThisDisk:Ve.get(e,4),nrOfThisDiskWithTheStart:Ve.get(e,6),nrOfEntriesOnThisDisk:Ve.get(e,8),nrOfEntriesOfSize:Ve.get(e,10),sizeOfCd:Qe.get(e,12),offsetOfStartOfCd:Qe.get(e,16),zipFileCommentLength:Ve.get(e,20)}},len:22},jd={get(e){let t=Ve.get(e,8);return{signature:Qe.get(e,0),minVersion:Ve.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Ve.get(e,10),compressedSize:Qe.get(e,20),uncompressedSize:Qe.get(e,24),filenameLength:Ve.get(e,28),extraFieldLength:Ve.get(e,30),fileCommentLength:Ve.get(e,32),relativeOffsetOfLocalHeader:Qe.get(e,42),filename:null}},len:46}});function qd(e){let t=new Uint8Array(Qe.len);return Qe.put(t,0,e),t}function xw(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 a=0;a<r;a++)if(e[s+a]!==t[a]){i=!1;break}if(i)return s}return-1}function Ew(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 Vd,gn,cl,bw,Ui,Ss,Zd=I(()=>{bs();Vd=gu(Bd(),1);Gd();gn=(0,Vd.default)("tokenizer:inflate"),cl=256*1024,bw=qd(rr.DataDescriptor),Ui=qd(rr.EndOfCentralDirectory),Ss=class e{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(cl)}async isZip(){return await this.peekSignature()===rr.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Qe)}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]===Ui[0]&&r[s+1]===Ui[1]&&r[s+2]===Ui[2]&&r[s+3]===Ui[3])return t.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){gn("Cannot reading central-directory without random-read support");return}gn("Reading central-directory...");let t=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){gn("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(Hd,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let a=await this.tokenizer.readToken(jd);if(a.signature!==rr.CentralFileHeader)throw new Error("Expected Central-File-Header signature");a.filename=await this.tokenizer.readToken(new Ot(a.filenameLength,"utf-8")),await this.tokenizer.ignore(a.extraFieldLength),await this.tokenizer.ignore(a.fileCommentLength),s.push(a),gn(`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 a;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let o=[],l=cl;gn("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===cl;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=xw(this.syncBuffer.subarray(0,l),bw);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),o.push(f)}else await this.tokenizer.ignore(u)}gn(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,Ew(o),i.handler)}else i.handler?(gn(`Reading compressed-file-data: ${s.compressedSize} bytes`),a=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(a),await this.inflate(s,a,i.handler)):(gn(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(gn(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(ll)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-ll.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 a=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(a),await this.inflate(i,a,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}`);gn(`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 a=await new Response(s).arrayBuffer();return new Uint8Array(a)}catch(i){let a=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(a)}}async readLocalFileHeader(){let t=await this.tokenizer.peekToken(Qe);if(t===rr.LocalFileHeader){let n=await this.tokenizer.readToken(zd);return n.filename=await this.tokenizer.readToken(new Ot(n.filenameLength,"utf-8")),n}if(t===rr.CentralFileHeader)return!1;throw t===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var Cs,Kd=I(()=>{Cs=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 Qd=I(()=>{Zd();Kd()});function ul(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 FI,MI,UI,Xd=I(()=>{FI={utf8:new globalThis.TextDecoder("utf8")},MI=new globalThis.TextEncoder,UI=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});function Yd(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 Jd(e,t=0){let n=Number.parseInt(new Ot(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 e0,t0=I(()=>{bs();e0={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}});var n0,r0,s0=I(()=>{n0=["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"],r0=["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 i0(e,t){return new hl(t).fromBuffer(e)}function pl(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 yn(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 fl,hl,ZI,KI,a0=I(()=>{bs();Ld();Qd();Xd();t0();s0();fl=4100;hl=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(Dd(n,this.tokenizerOptions))}async fromBlob(t){let n=_d(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(t){let n=Pd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(t,n){let{sampleSize:r=fl}=n,s,i,a=t.getReader({mode:"byob"});try{let{value:c,done:u}=await a.read(new Uint8Array(r));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof We))throw f;s=void 0}i=c}finally{a.releaseLock()}let o=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=t.pipeThrough(o);return l.fileType=s,l}check(t,n){return yn(this.buffer,t,n)}checkString(t,n){return this.check(Yd(t,n?.encoding),n)}detectConfident=async t=>{if(this.buffer=new Uint8Array(fl),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 Cs(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(e0);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 Ss(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=pl(i)},stop:!0};case"[Content_Types].xml":return{async handler(s){let i=new TextDecoder("utf-8").decode(s),a=i.indexOf('.main+xml"');if(a===-1){let o="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";i.includes(`ContentType="${o}"`)&&(n=pl(o))}else{i=i.slice(0,Math.max(0,a));let o=i.lastIndexOf('"'),l=i.slice(Math.max(0,o+1));n=pl(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 We))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),yn(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:yn(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:yn(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:yn(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:yn(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:yn(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 o=await t.peekNumber(Ad),l=128,c=0;for(;(o&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await t.readBuffer(u),u}async function r(){let o=await n(),l=await n();l[0]^=128>>l.length-1;let c=Math.min(6,l.length),u=new DataView(o.buffer),f=new DataView(l.buffer,l.length-c,c);return{id:ul(u),len:ul(f)}}async function s(o){for(;o>0;){let l=await r();if(l.id===17026)return(await t.readToken(new Ot(l.len))).replaceAll(/\00.*$/g,"");await t.ignore(l.len),--o}}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 Ot(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 Ot(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 B5,Ri=I(()=>{"use strict";se();B5=new Map([["sha1","SHA-1"],["sha256","SHA-256"]])});var pd={};K(pd,{flagsForFuzzing:()=>j5,md5sumCommand:()=>H5});var H5,j5,hd=I(()=>{"use strict";Ri();H5=Pr("md5sum","md5","compute MD5 message digest"),j5={name:"md5sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var dd={};K(dd,{flagsForFuzzing:()=>V5,sha1sumCommand:()=>G5});var G5,V5,md=I(()=>{"use strict";Ri();G5=Pr("sha1sum","sha1","compute SHA1 message digest"),V5={name:"sha1sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var gd={};K(gd,{flagsForFuzzing:()=>Z5,sha256sumCommand:()=>q5});var q5,Z5,yd=I(()=>{"use strict";Ri();q5=Pr("sha256sum","sha256","compute SHA256 message digest"),Z5={name:"sha256sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var wd=Hs(rl=>{rl.read=function(e,t,n,r,s){var i,a,o=s*8-r-1,l=(1<<o)-1,c=l>>1,u=-7,f=n?s-1:0,p=n?-1:1,h=e[t+f];for(f+=p,i=h&(1<<-u)-1,h>>=-u,u+=o;u>0;i=i*256+e[t+f],f+=p,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=r;u>0;a=a*256+e[t+f],f+=p,u-=8);if(i===0)i=1-c;else{if(i===l)return a?NaN:(h?-1:1)*(1/0);a=a+Math.pow(2,r),i=i-c}return(h?-1:1)*a*Math.pow(2,i-r)};rl.write=function(e,t,n,r,s,i){var a,o,l,c=i*8-s-1,u=(1<<c)-1,f=u>>1,p=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=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?(o=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+f>=1?t+=p/l:t+=p*Math.pow(2,1-f),t*l>=2&&(a++,l/=2),a+f>=u?(o=0,a=u):a+f>=1?(o=(t*l-1)*Math.pow(2,s),a=a+f):(o=t*Math.pow(2,f-1)*Math.pow(2,s),a=0));s>=8;e[n+h]=o&255,h+=m,o/=256,s-=8);for(a=a<<s|o,c+=s;c>0;e[n+h]=a&255,h+=m,a/=256,c-=8);e[n+h-m]|=d*128}});function bd(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):Q5(e);case"utf-16le":return X5(e);case"ascii":return Y5(e);case"latin1":case"iso-8859-1":return J5(e);case"windows-1252":return ew(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function Q5(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,a=e[n++]&63,o=(r&7)<<18|s<<12|i<<6|a;o-=65536,t+=String.fromCharCode(55296+(o>>10&1023),56320+(o&1023))}}return t}function X5(e){let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function Y5(e){return String.fromCharCode(...e.map(t=>t&127))}function J5(e){return String.fromCharCode(...e)}function ew(e){let t="";for(let n of e)n>=128&&n<=159&&sl[n]?t+=sl[n]:t+=String.fromCharCode(n);return t}var sl,K5,xd=I(()=>{sl={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"},K5={};for(let[e,t]of Object.entries(sl))K5[t]=Number.parseInt(e)});function $t(e){return new DataView(e.buffer,e.byteOffset)}var Ed,Ad,Ve,Dr,Qe,Sd,Cd,Nd,Ot,bs=I(()=>{Ed=gu(wd(),1);xd();Ad={len:1,get(e,t){return $t(e).getUint8(t)},put(e,t,n){return $t(e).setUint8(t,n),t+1}},Ve={len:2,get(e,t){return $t(e).getUint16(t,!0)},put(e,t,n){return $t(e).setUint16(t,n,!0),t+2}},Dr={len:2,get(e,t){return $t(e).getUint16(t)},put(e,t,n){return $t(e).setUint16(t,n),t+2}},Qe={len:4,get(e,t){return $t(e).getUint32(t,!0)},put(e,t,n){return $t(e).setUint32(t,n,!0),t+4}},Sd={len:4,get(e,t){return $t(e).getUint32(t)},put(e,t,n){return $t(e).setUint32(t,n),t+4}},Cd={len:4,get(e,t){return $t(e).getInt32(t)},put(e,t,n){return $t(e).setInt32(t,n),t+4}},Nd={len:8,get(e,t){return $t(e).getBigUint64(t,!0)},put(e,t,n){return $t(e).setBigUint64(t,n,!0),t+8}},Ot=class{constructor(t,n){this.len=t,this.encoding=n}get(t,n=0){let r=t.subarray(n,n+this.len);return bd(r,this.encoding)}}});var nw,We,Jn,xs=I(()=>{nw="End-Of-Stream",We=class extends Error{constructor(){super(nw),this.name="EndOfStreamError"}},Jn=class extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}});var kd=I(()=>{});var er,Ti=I(()=>{xs();er=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 We;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 Jn;let s=await this.readFromStream(t.subarray(r),n);if(s===0)break;r+=s}if(!n&&r<t.length)throw new We;return r}}});var vd=I(()=>{xs();kd();Ti()});var Pi,Id=I(()=>{Ti();Pi=class extends er{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var Es,il=I(()=>{Id();Es=class extends Pi{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 _r,al=I(()=>{xs();Ti();_r=class extends er{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 We;return r}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}}});function ol(e){try{let t=e.getReader({mode:"byob"});return t instanceof ReadableStreamDefaultReader?new _r(t):new Es(t)}catch(t){if(t instanceof TypeError)return new _r(e.getReader());throw t}}var $d=I(()=>{il();al()});var tr=I(()=>{xs();vd();il();al();$d()});var kn,As=I(()=>{tr();kn=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 We;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 We;return t.get(r,0)}async readNumber(t){if(await this.readBuffer(this.numBuffer,{length:t.len})<t.len)throw new We;return t.get(this.numBuffer,0)}async peekNumber(t){if(await this.peekBuffer(this.numBuffer,{length:t.len})<t.len)throw new We;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 sw,Di,Od=I(()=>{As();tr();sw=256e3,Di=class extends kn{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 We;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 a=new Uint8Array(r.length+i);return s=await this.peekBuffer(a,{mayBeLess:r.mayBeLess}),t.set(a.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 We)return 0;throw i}if(!r.mayBeLess&&s<r.length)throw new We}return s}async ignore(t){let n=Math.min(sw,t),r=new Uint8Array(n),s=0;for(;s<t;){let i=t-s,a=await this.readBuffer(r,{length:Math.min(n,i)});if(a<0)return a;s+=a}return s}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}}});var _i,Rd=I(()=>{tr();As();_i=class extends kn{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 We;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 Li,Td=I(()=>{tr();As();Li=class extends kn{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 We;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 Pd(e,t){let n=ol(e),r=t??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new Di(n,r)}function Dd(e,t){return new _i(e,t)}function _d(e,t){return new Li(e,t)}var Ld=I(()=>{tr();Od();Rd();Td();tr();As()});var Md=Hs((NI,Fd)=>{var Lr=1e3,Fr=Lr*60,Mr=Fr*60,nr=Mr*24,aw=nr*7,ow=nr*365.25;Fd.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return lw(e);if(n==="number"&&isFinite(e))return t.long?uw(e):cw(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function lw(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*ow;case"weeks":case"week":case"w":return n*aw;case"days":case"day":case"d":return n*nr;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Mr;case"minutes":case"minute":case"mins":case"min":case"m":return n*Fr;case"seconds":case"second":case"secs":case"sec":case"s":return n*Lr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function cw(e){var t=Math.abs(e);return t>=nr?Math.round(e/nr)+"d":t>=Mr?Math.round(e/Mr)+"h":t>=Fr?Math.round(e/Fr)+"m":t>=Lr?Math.round(e/Lr)+"s":e+"ms"}function uw(e){var t=Math.abs(e);return t>=nr?Fi(e,t,nr,"day"):t>=Mr?Fi(e,t,Mr,"hour"):t>=Fr?Fi(e,t,Fr,"minute"):t>=Lr?Fi(e,t,Lr,"second"):e+" ms"}function Fi(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}});var Wd=Hs((kI,Ud)=>{function fw(e){n.debug=n,n.default=n,n.coerce=l,n.disable=a,n.enable=s,n.enabled=o,n.humanize=Md(),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 p=0;p<u.length;p++)f=(f<<5)-f+u.charCodeAt(p),f|=0;return n.colors[Math.abs(f)%n.colors.length]}n.selectColor=t;function n(u){let f,p=null,h,m;function d(...g){if(!d.enabled)return;let w=d,y=Number(new Date),b=y-(f||y);w.diff=b,w.prev=f,w.curr=y,f=y,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,($,O)=>{if($==="%%")return"%";x++;let F=n.formatters[O];if(typeof F=="function"){let R=g[x];$=F.call(w,R),g.splice(x,1),x--}return $}),n.formatArgs.call(w,g),(w.log||n.log).apply(w,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:()=>p!==null?p:(h!==n.namespaces&&(h=n.namespaces,m=n.enabled(u)),m),set:g=>{p=g}}),typeof n.init=="function"&&n.init(d),d}function r(u,f){let p=n(this.namespace+(typeof f>"u"?":":f)+u);return p.log=this.log,p}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 p of f)p[0]==="-"?n.skips.push(p.slice(1)):n.names.push(p)}function i(u,f){let p=0,h=0,m=-1,d=0;for(;p<u.length;)if(h<f.length&&(f[h]===u[p]||f[h]==="*"))f[h]==="*"?(m=h,d=p,h++):(p++,h++);else if(m!==-1)h=m+1,d++,p=d;else return!1;for(;h<f.length&&f[h]==="*";)h++;return h===f.length}function a(){let u=[...n.names,...n.skips.map(f=>"-"+f)].join(",");return n.enable(""),u}function o(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}Ud.exports=fw});var Bd=Hs((Rt,Mi)=>{Rt.formatArgs=hw;Rt.save=dw;Rt.load=mw;Rt.useColors=pw;Rt.storage=gw();Rt.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`."))}})();Rt.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 pw(){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 hw(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Mi.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)}Rt.log=console.debug||console.log||(()=>{});function dw(e){try{e?Rt.storage.setItem("debug",e):Rt.storage.removeItem("debug")}catch{}}function mw(){let e;try{e=Rt.storage.getItem("debug")||Rt.storage.getItem("DEBUG")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function gw(){try{return localStorage}catch{}}Mi.exports=Wd()(Rt);var{formatters:yw}=Mi.exports;yw.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var rr,ll,zd,Hd,jd,Gd=I(()=>{bs();rr={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},ll={get(e){return{signature:Qe.get(e,0),compressedSize:Qe.get(e,8),uncompressedSize:Qe.get(e,12)}},len:16},zd={get(e){let t=Ve.get(e,6);return{signature:Qe.get(e,0),minVersion:Ve.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Ve.get(e,8),compressedSize:Qe.get(e,18),uncompressedSize:Qe.get(e,22),filenameLength:Ve.get(e,26),extraFieldLength:Ve.get(e,28),filename:null}},len:30},Hd={get(e){return{signature:Qe.get(e,0),nrOfThisDisk:Ve.get(e,4),nrOfThisDiskWithTheStart:Ve.get(e,6),nrOfEntriesOnThisDisk:Ve.get(e,8),nrOfEntriesOfSize:Ve.get(e,10),sizeOfCd:Qe.get(e,12),offsetOfStartOfCd:Qe.get(e,16),zipFileCommentLength:Ve.get(e,20)}},len:22},jd={get(e){let t=Ve.get(e,8);return{signature:Qe.get(e,0),minVersion:Ve.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Ve.get(e,10),compressedSize:Qe.get(e,20),uncompressedSize:Qe.get(e,24),filenameLength:Ve.get(e,28),extraFieldLength:Ve.get(e,30),fileCommentLength:Ve.get(e,32),relativeOffsetOfLocalHeader:Qe.get(e,42),filename:null}},len:46}});function qd(e){let t=new Uint8Array(Qe.len);return Qe.put(t,0,e),t}function bw(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 a=0;a<r;a++)if(e[s+a]!==t[a]){i=!1;break}if(i)return s}return-1}function xw(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 Vd,gn,cl,ww,Ui,Ss,Zd=I(()=>{bs();Vd=gu(Bd(),1);Gd();gn=(0,Vd.default)("tokenizer:inflate"),cl=256*1024,ww=qd(rr.DataDescriptor),Ui=qd(rr.EndOfCentralDirectory),Ss=class e{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(cl)}async isZip(){return await this.peekSignature()===rr.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(Qe)}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]===Ui[0]&&r[s+1]===Ui[1]&&r[s+2]===Ui[2]&&r[s+3]===Ui[3])return t.fileInfo.size-n+s;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){gn("Cannot reading central-directory without random-read support");return}gn("Reading central-directory...");let t=this.tokenizer.position,n=await this.findEndOfCentralDirectoryLocator();if(n>0){gn("Central-directory 32-bit signature found");let r=await this.tokenizer.readToken(Hd,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let a=await this.tokenizer.readToken(jd);if(a.signature!==rr.CentralFileHeader)throw new Error("Expected Central-File-Header signature");a.filename=await this.tokenizer.readToken(new Ot(a.filenameLength,"utf-8")),await this.tokenizer.ignore(a.extraFieldLength),await this.tokenizer.ignore(a.fileCommentLength),s.push(a),gn(`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 a;if(await this.tokenizer.ignore(s.extraFieldLength),s.dataDescriptor&&s.compressedSize===0){let o=[],l=cl;gn("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===cl;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=bw(this.syncBuffer.subarray(0,l),ww);let u=c>=0?c:l;if(i.handler){let f=new Uint8Array(u);await this.tokenizer.readBuffer(f),o.push(f)}else await this.tokenizer.ignore(u)}gn(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),i.handler&&await this.inflate(s,xw(o),i.handler)}else i.handler?(gn(`Reading compressed-file-data: ${s.compressedSize} bytes`),a=new Uint8Array(s.compressedSize),await this.tokenizer.readBuffer(a),await this.inflate(s,a,i.handler)):(gn(`Ignoring compressed-file-data: ${s.compressedSize} bytes`),await this.tokenizer.ignore(s.compressedSize));if(gn(`Reading data-descriptor at pos=${this.tokenizer.position}`),s.dataDescriptor&&(await this.tokenizer.readToken(ll)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-ll.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 a=new Uint8Array(r.compressedSize);await this.tokenizer.readBuffer(a),await this.inflate(i,a,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}`);gn(`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 a=await new Response(s).arrayBuffer();return new Uint8Array(a)}catch(i){let a=i instanceof Error?`Failed to deflate ZIP entry: ${i.message}`:"Unknown decompression error in ZIP entry";throw new TypeError(a)}}async readLocalFileHeader(){let t=await this.tokenizer.peekToken(Qe);if(t===rr.LocalFileHeader){let n=await this.tokenizer.readToken(zd);return n.filename=await this.tokenizer.readToken(new Ot(n.filenameLength,"utf-8")),n}if(t===rr.CentralFileHeader)return!1;throw t===3759263696?new Error("Encrypted ZIP"):new Error("Unexpected signature")}}});var Cs,Kd=I(()=>{Cs=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 Qd=I(()=>{Zd();Kd()});function ul(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 LI,FI,MI,Xd=I(()=>{LI={utf8:new globalThis.TextDecoder("utf8")},FI=new globalThis.TextEncoder,MI=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});function Yd(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 Jd(e,t=0){let n=Number.parseInt(new Ot(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 e0,t0=I(()=>{bs();e0={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}});var n0,r0,s0=I(()=>{n0=["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"],r0=["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 i0(e,t){return new hl(t).fromBuffer(e)}function pl(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 yn(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 fl,hl,qI,ZI,a0=I(()=>{bs();Ld();Qd();Xd();t0();s0();fl=4100;hl=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(Dd(n,this.tokenizerOptions))}async fromBlob(t){let n=_d(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(t){let n=Pd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(t,n){let{sampleSize:r=fl}=n,s,i,a=t.getReader({mode:"byob"});try{let{value:c,done:u}=await a.read(new Uint8Array(r));if(i=c,!u&&c)try{s=await this.fromBuffer(c.subarray(0,r))}catch(f){if(!(f instanceof We))throw f;s=void 0}i=c}finally{a.releaseLock()}let o=new TransformStream({async start(c){c.enqueue(i)},transform(c,u){u.enqueue(c)}}),l=t.pipeThrough(o);return l.fileType=s,l}check(t,n){return yn(this.buffer,t,n)}checkString(t,n){return this.check(Yd(t,n?.encoding),n)}detectConfident=async t=>{if(this.buffer=new Uint8Array(fl),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 Cs(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(e0);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 Ss(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=pl(i)},stop:!0};case"[Content_Types].xml":return{async handler(s){let i=new TextDecoder("utf-8").decode(s),a=i.indexOf('.main+xml"');if(a===-1){let o="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";i.includes(`ContentType="${o}"`)&&(n=pl(o))}else{i=i.slice(0,Math.max(0,a));let o=i.lastIndexOf('"'),l=i.slice(Math.max(0,o+1));n=pl(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 We))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),yn(n,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:yn(n,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:yn(n,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:yn(n,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:yn(n,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:yn(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 o=await t.peekNumber(Ad),l=128,c=0;for(;(o&l)===0&&l!==0;)++c,l>>=1;let u=new Uint8Array(c+1);return await t.readBuffer(u),u}async function r(){let o=await n(),l=await n();l[0]^=128>>l.length-1;let c=Math.min(6,l.length),u=new DataView(o.buffer),f=new DataView(l.buffer,l.length-c,c);return{id:ul(u),len:ul(f)}}async function s(o){for(;o>0;){let l=await r();if(l.id===17026)return(await t.readToken(new Ot(l.len))).replaceAll(/\00.*$/g,"");await t.ignore(l.len),--o}}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 Ot(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 Ot(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(Cd),type:await t.readToken(new Ot(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 Ot(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(Nd))}}for(await t.ignore(30);t.position+24<t.fileInfo.size;){let r=await n(),s=r.size-24;if(yn(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),yn(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(yn(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 Ot(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})&&Jd(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
|
-
`,{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(fl),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?Dr:Ve);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?Dr:Ve);for(let r=0;r<n;++r){let s=await this.readTiffTag(t);if(s)return s}}async readTiffHeader(t){let n=(t?Dr:Ve).get(this.buffer,2),r=(t?Sd:Qe).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?Dr:Ve).get(this.buffer,8),a=(t?Dr:Ve).get(this.buffer,10);if(i===28&&a===254||i===31&&a===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"}}}},
|
|
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(fl),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?Dr:Ve);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?Dr:Ve);for(let r=0;r<n;++r){let s=await this.readTiffTag(t);if(s)return s}}async readTiffHeader(t){let n=(t?Dr:Ve).get(this.buffer,2),r=(t?Sd:Qe).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?Dr:Ve).get(this.buffer,8),a=(t?Dr:Ve).get(this.buffer,10);if(i===28&&a===254||i===31&&a===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"}}}},qI=new Set(n0),ZI=new Set(r0)});var o0={};K(o0,{fileCommand:()=>Iw,flagsForFuzzing:()=>$w});function Cw(e,t){let n=Sw.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 Nw(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 kw(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 a=
|
|
623
|
+
`),s=e.includes("\r")&&!r,i="";r?i=", with CRLF line terminators":s&&(i=", with CR line terminators");let a=Nw(t),o=a?Aw.get(a):void 0;if(o)return o.mime.startsWith("text/")&&i?{description:`${o.description}${i}`,mime:o.mime}:o;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 vw(e,t){if(t.length===0)return{description:"empty",mime:"inode/x-empty"};let n=await i0(t);if(n)return{description:Cw(n.ext,n.mime),mime:n.mime};let r=new TextDecoder("utf-8",{fatal:!1}).decode(t);return kw(r,e)}var Ew,Aw,Sw,Iw,$w,l0=I(()=>{"use strict";a0();se();Ew={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"]},Aw=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"}]]),Sw=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"]]);Iw={name:"file",async execute(e,t){if(U(e))return M(Ew);let n=!1,r=!1,s=[];for(let o of e)if(o.startsWith("--")){if(o==="--brief")n=!0;else if(o==="--mime"||o==="--mime-type")r=!0;else if(o!=="--dereference")return Y("file",o)}else if(o.startsWith("-")&&o!=="-"){for(let l of o.slice(1))if(l==="b")n=!0;else if(l==="i")r=!0;else if(l!=="L")return Y("file",`-${l}`)}else s.push(o);if(s.length===0)return{stdout:"",stderr:`Usage: file [-bLi] FILE...
|
|
624
624
|
`,exitCode:1};let i="",a=0;for(let o of s)try{let l=t.fs.resolvePath(t.cwd,o);if((await t.fs.stat(l)).isDirectory){let h=r?"inode/directory":"directory";i+=n?`${h}
|
|
625
625
|
`:`${o}: ${h}
|
|
626
|
-
`;continue}let u=await t.fs.readFileBuffer(l),f=await
|
|
626
|
+
`;continue}let u=await t.fs.readFileBuffer(l),f=await vw(o,u),p=r?f.mime:f.description;i+=n?`${p}
|
|
627
627
|
`:`${o}: ${p}
|
|
628
628
|
`}catch{i+=n?`cannot open
|
|
629
629
|
`:`${o}: cannot open (No such file or directory)
|
|
630
|
-
`,a=1}return{stdout:i,stderr:"",exitCode:a}}}
|
|
631
|
-
`,exitCode:1}}if(!o.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new
|
|
630
|
+
`,a=1}return{stdout:i,stderr:"",exitCode:a}}},$w={name:"file",flags:[{flag:"-b",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-L",type:"boolean"}],needsArgs:!0}});var c0={};K(c0,{flagsForFuzzing:()=>Pw,htmlToMarkdownCommand:()=>Tw});import Ow from"turndown";var Rw,Tw,Pw,u0=I(()=>{"use strict";se();Rw={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 "," - 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"]},Tw={name:"html-to-markdown",async execute(e,t){if(U(e))return M(Rw);let n="-",r="```",s="---",i="atx",a=[];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==="-")a.push("-");else{if(c.startsWith("--"))return Y("html-to-markdown",c);if(c.startsWith("-"))return Y("html-to-markdown",c);a.push(c)}}let o;if(a.length===0||a.length===1&&a[0]==="-")o=t.stdin;else try{let l=t.fs.resolvePath(t.cwd,a[0]);o=await t.fs.readFile(l)}catch{return{stdout:"",stderr:`html-to-markdown: ${a[0]}: No such file or directory
|
|
631
|
+
`,exitCode:1}}if(!o.trim())return{stdout:"",stderr:"",exitCode:0};try{let l=new Ow({bulletListMarker:n,codeBlockStyle:"fenced",fence:r,hr:s,headingStyle:i});return l.remove(["script","style","footer"]),{stdout:`${l.turndown(o).trim()}
|
|
632
632
|
`,stderr:"",exitCode:0}}catch(l){return{stdout:"",stderr:`html-to-markdown: conversion error: ${l.message}
|
|
633
|
-
`,exitCode:1}}}},
|
|
634
|
-
`);let r=[];for(let[s,i]of
|
|
633
|
+
`,exitCode:1}}}},Pw={name:"html-to-markdown",flags:[],stdinType:"text"}});var f0={};K(f0,{flagsForFuzzing:()=>Fw,helpCommand:()=>Lw});function _w(e){let t=[],n=new Set(e);t.push(`Available commands:
|
|
634
|
+
`);let r=[];for(let[s,i]of Dw){let a=i.filter(o=>n.has(o));if(a.length>0){t.push(` ${s}:`),t.push(` ${a.join(", ")}
|
|
635
635
|
`);for(let o of a)n.delete(o)}}for(let s of n)r.push(s);return r.length>0&&(t.push(" Other:"),t.push(` ${r.sort().join(", ")}
|
|
636
636
|
`)),t.push("Use '<command> --help' for details on a specific command."),`${t.join(`
|
|
637
637
|
`)}
|
|
638
|
-
`}var
|
|
638
|
+
`}var Dw,Lw,Fw,p0=I(()=>{"use strict";Dw=new Map([["File operations",["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"]],["Text processing",["grep","sed","awk","sort","uniq","cut","tr","tee","diff"]],["Search",["find"]],["Navigation & paths",["pwd","basename","dirname","tree","du"]],["Environment & shell",["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"]],["Data processing",["xargs","jq","base64","date"]],["Network",["curl","html-to-markdown"]]]);Lw={name:"help",async execute(e,t){if(e.includes("--help")||e.includes("-h"))return{stdout:`help - display available commands
|
|
639
639
|
|
|
640
640
|
Usage: help [command]
|
|
641
641
|
|
|
@@ -644,20 +644,20 @@ 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:
|
|
648
|
-
`),!r))break}f||(c=!1)}return{stdout:l,stderr:"",exitCode:c?0:1}}},
|
|
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:_w(n),stderr:"",exitCode:0}}},Fw={name:"help",flags:[]}});var h0={};K(h0,{flagsForFuzzing:()=>Bw,whichCommand:()=>Ww});var Mw,Uw,Ww,Bw,d0=I(()=>{"use strict";Ze();se();Mw={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"]},Uw={showAll:{short:"a",type:"boolean"},silent:{short:"s",type:"boolean"}},Ww={name:"which",async execute(e,t){if(U(e))return M(Mw);let n=be("which",e,Uw);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 o=(t.env.get("PATH")||"/usr/bin:/bin").split(":"),l="",c=!0;for(let u of i){let f=!1;for(let p of o){if(!p)continue;let h=`${p}/${u}`;if(await t.fs.exists(h)&&(f=!0,s||(l+=`${h}
|
|
648
|
+
`),!r))break}f||(c=!1)}return{stdout:l,stderr:"",exitCode:c?0:1}}},Bw={name:"which",flags:[{flag:"-a",type:"boolean"},{flag:"-s",type:"boolean"}],needsArgs:!0}});var m0={};K(m0,{flagsForFuzzing:()=>jw,tac:()=>Hw});async function zw(e,t){if(e.length>0&&e[0]!=="-"){let s=e[0].startsWith("/")?e[0]:`${t.cwd}/${e[0]}`;try{let a=(await t.fs.readFile(s)).split(`
|
|
649
649
|
`);a[a.length-1]===""&&a.pop();let o=a.reverse();return{stdout:o.length>0?`${o.join(`
|
|
650
650
|
`)}
|
|
651
651
|
`:"",stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`tac: ${e[0]}: No such file or directory
|
|
652
652
|
`,exitCode:1}}}let n=t.stdin.split(`
|
|
653
653
|
`);n[n.length-1]===""&&n.pop();let r=n.reverse();return{stdout:r.length>0?`${r.join(`
|
|
654
654
|
`)}
|
|
655
|
-
`:"",stderr:"",exitCode:0}}var jw,
|
|
656
|
-
`,stderr:"",exitCode:0}}var qw,
|
|
657
|
-
`,stderr:"",exitCode:0}}var Qw,
|
|
655
|
+
`:"",stderr:"",exitCode:0}}var Hw,jw,g0=I(()=>{"use strict";Hw={name:"tac",execute:zw},jw={name:"tac",flags:[],stdinType:"text",needsFiles:!0}});var y0={};K(y0,{flagsForFuzzing:()=>qw,hostname:()=>Vw});async function Gw(e,t){return{stdout:`localhost
|
|
656
|
+
`,stderr:"",exitCode:0}}var Vw,qw,w0=I(()=>{"use strict";Vw={name:"hostname",execute:Gw},qw={name:"hostname",flags:[]}});var b0={};K(b0,{flagsForFuzzing:()=>Qw,whoami:()=>Kw});async function Zw(e,t){return{stdout:`user
|
|
657
|
+
`,stderr:"",exitCode:0}}var Kw,Qw,x0=I(()=>{"use strict";Kw={name:"whoami",execute:Zw},Qw={name:"whoami",flags:[]}});var E0={};K(E0,{flagsForFuzzing:()=>Jw,od:()=>Yw});async function Xw(e,t){let n="octal",r=[],s=[];for(let h=0;h<e.length;h++){let m=e[h];if(m==="-c")r.push("char");else if(m==="-An"||m==="-A"&&e[h+1]==="n")n="none",m==="-A"&&h++;else if(m==="-t"&&e[h+1]){let d=e[++h];d==="x1"?r.push("hex"):d==="c"?r.push("char"):d.startsWith("o")&&r.push("octal")}else(!m.startsWith("-")||m==="-")&&s.push(m)}r.length===0&&r.push("octal");let i=t.stdin;if(s.length>0&&s[0]!=="-"){let h=s[0].startsWith("/")?s[0]:`${t.cwd}/${s[0]}`;try{i=await t.fs.readFile(h)}catch{return{stdout:"",stderr:`od: ${s[0]}: No such file or directory
|
|
658
658
|
`,exitCode:1}}}let a=r.includes("char");function o(h){return h===0?" \\0":h===7?" \\a":h===8?" \\b":h===9?" \\t":h===10?" \\n":h===11?" \\v":h===12?" \\f":h===13?" \\r":h>=32&&h<127?` ${String.fromCharCode(h)}`:` ${h.toString(8).padStart(3,"0")}`}function l(h){return a?` ${h.toString(16).padStart(2,"0")}`:` ${h.toString(16).padStart(2,"0")}`}function c(h){return` ${h.toString(8).padStart(3,"0")}`}let u=[];for(let h of i)u.push(h.charCodeAt(0));let f=16,p=[];for(let h=0;h<u.length;h+=f){let m=u.slice(h,h+f);for(let d=0;d<r.length;d++){let g=r[d],w;g==="char"?w=m.map(o):g==="hex"?w=m.map(l):w=m.map(c);let y="";d===0&&n!=="none"?y=`${h.toString(8).padStart(7,"0")} `:(d>0||n==="none")&&(y=n==="none"?"":" "),p.push(y+w.join(""))}}return n!=="none"&&u.length>0&&p.push(u.length.toString(8).padStart(7,"0")),{stdout:p.length>0?`${p.join(`
|
|
659
659
|
`)}
|
|
660
|
-
`:"",stderr:"",exitCode:0}}var Jw,
|
|
660
|
+
`:"",stderr:"",exitCode:0}}var Yw,Jw,A0=I(()=>{"use strict";Yw={name:"od",execute:Xw},Jw={name:"od",flags:[{flag:"-c",type:"boolean"},{flag:"-A",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"string"},{flag:"-N",type:"value",valueHint:"number"}],stdinType:"text",needsFiles:!0}});var Bi={};K(Bi,{flagsForFuzzing:()=>ub,gunzipCommand:()=>lb,gunzipFlagsForFuzzing:()=>fb,gzipCommand:()=>ob,zcatCommand:()=>cb,zcatFlagsForFuzzing:()=>pb});import{constants as dl,gunzipSync as ml,gzipSync as S0}from"node:zlib";function C0(e){return e.best?dl.Z_BEST_COMPRESSION:e.level8?8:e.level7?7:e.level6?6:e.level5?5:e.level4?4:e.level3?3:e.level2?2:e.fast?dl.Z_BEST_SPEED:dl.Z_DEFAULT_COMPRESSION}function N0(e){if(e.length<10)return{originalName:null,mtime:null,headerSize:0};if(e[0]!==31||e[1]!==139)return{originalName:null,mtime:null,headerSize:0};let t=e[3],n=e[4]|e[5]<<8|e[6]<<16|e[7]<<24,r=10;if(t&4){if(r+2>e.length)return{originalName:null,mtime:null,headerSize:0};let i=e[r]|e[r+1]<<8;r+=2+i}let s=null;if(t&8){let i=r;for(;r<e.length&&e[r]!==0;)r++;r<e.length&&(s=new TextDecoder().decode(e.slice(i,r)),r++)}if(t&16){for(;r<e.length&&e[r]!==0;)r++;r++}return t&2&&(r+=2),{originalName:s,mtime:n>0?new Date(n*1e3):null,headerSize:r}}function sb(e){if(e.length<4)return 0;let t=e.length;return e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24}function Wi(e){return e.length>=2&&e[0]===31&&e[1]===139}async function k0(e,t,n,r,s,i){let a=n.suffix,o,l,c;if(t==="-"||t==="")if(c=Uint8Array.from(e.stdin,u=>u.charCodeAt(0)),s){if(!Wi(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
|
|
661
661
|
`,exitCode:1};try{let u=ml(c);return{stdout:String.fromCharCode(...u),stderr:"",exitCode:0}}catch(u){let f=u instanceof Error?u.message:"unknown error";return{stdout:"",stderr:`${r}: stdin: ${f}
|
|
662
662
|
`,exitCode:1}}}else{let u=C0(n),f=S0(c,{level:u});return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0}}o=e.fs.resolvePath(e.cwd,t);try{if((await e.fs.stat(o)).isDirectory)return n.recursive?await v0(e,o,n,r,s,i):n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: is a directory -- ignored
|
|
663
663
|
`,exitCode:1}}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
|
|
@@ -671,23 +671,23 @@ Otherwise, lists all available commands.
|
|
|
671
671
|
`,exitCode:1};let u=C0(n),f;try{f=S0(c,{level:u})}catch(p){let h=p instanceof Error?p.message:"unknown error";return{stdout:"",stderr:`${r}: ${t}: ${h}
|
|
672
672
|
`,exitCode:1}}if(i)return{stdout:String.fromCharCode(...f),stderr:"",exitCode:0};if(l=o+a,!n.force)try{return await e.fs.stat(l),{stdout:"",stderr:`${r}: ${l} already exists; not overwritten
|
|
673
673
|
`,exitCode:1}}catch{}if(await e.fs.writeFile(l,f),!n.keep&&!i&&await e.fs.rm(o),n.verbose){let p=c.length>0?((1-f.length/c.length)*100).toFixed(1):"0.0";return{stdout:"",stderr:`${t}: ${p}% -- replaced with ${l.split("/").pop()}
|
|
674
|
-
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function v0(e,t,n,r,s,i){let a=await e.fs.readdir(t),o="",l="",c=0;for(let u of a){let f=e.fs.resolvePath(t,u),p=await e.fs.stat(f);if(p.isDirectory){let h=await v0(e,f,n,r,s,i);o+=h.stdout,l+=h.stderr,h.exitCode!==0&&(c=h.exitCode)}else if(p.isFile){let h=n.suffix;if(s&&!u.endsWith(h)||!s&&u.endsWith(h))continue;let m=f.startsWith(`${e.cwd}/`)?f.slice(e.cwd.length+1):f,d=await k0(e,m,n,r,s,i);o+=d.stdout,l+=d.stderr,d.exitCode!==0&&(c=d.exitCode)}}return{stdout:o,stderr:l,exitCode:c}}async function
|
|
674
|
+
`,exitCode:0}}return{stdout:"",stderr:"",exitCode:0}}}async function v0(e,t,n,r,s,i){let a=await e.fs.readdir(t),o="",l="",c=0;for(let u of a){let f=e.fs.resolvePath(t,u),p=await e.fs.stat(f);if(p.isDirectory){let h=await v0(e,f,n,r,s,i);o+=h.stdout,l+=h.stderr,h.exitCode!==0&&(c=h.exitCode)}else if(p.isFile){let h=n.suffix;if(s&&!u.endsWith(h)||!s&&u.endsWith(h))continue;let m=f.startsWith(`${e.cwd}/`)?f.slice(e.cwd.length+1):f,d=await k0(e,m,n,r,s,i);o+=d.stdout,l+=d.stderr,d.exitCode!==0&&(c=d.exitCode)}}return{stdout:o,stderr:l,exitCode:c}}async function ib(e,t,n,r){let s;if(t==="-"||t==="")s=Uint8Array.from(e.stdin,f=>f.charCodeAt(0));else{let f=e.fs.resolvePath(e.cwd,t);try{s=await e.fs.readFileBuffer(f)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
|
|
675
675
|
`,exitCode:1}}}if(!Wi(s))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
|
|
676
|
-
`,exitCode:1};let i=s.length,a=
|
|
677
|
-
`,stderr:"",exitCode:0}}async function
|
|
676
|
+
`,exitCode:1};let i=s.length,a=sb(s),o=a>0?((1-i/a)*100).toFixed(1):"0.0",c=N0(s).originalName||(t==="-"?"":t.replace(/\.gz$/,""));return{stdout:`${i.toString().padStart(10)} ${a.toString().padStart(10)} ${o.padStart(5)}% ${c}
|
|
677
|
+
`,stderr:"",exitCode:0}}async function ab(e,t,n,r){let s;if(t==="-"||t==="")s=Uint8Array.from(e.stdin,i=>i.charCodeAt(0));else{let i=e.fs.resolvePath(e.cwd,t);try{s=await e.fs.readFileBuffer(i)}catch{return{stdout:"",stderr:`${r}: ${t}: No such file or directory
|
|
678
678
|
`,exitCode:1}}}if(!Wi(s))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: ${t}: not in gzip format
|
|
679
679
|
`,exitCode:1};try{return ml(s),n.verbose?{stdout:"",stderr:`${t}: OK
|
|
680
680
|
`,exitCode:0}:{stdout:"",stderr:"",exitCode:0}}catch(i){let a=i instanceof Error?i.message:"invalid";return{stdout:"",stderr:`${r}: ${t}: ${a}
|
|
681
|
-
`,exitCode:1}}}async function gl(e,t,n){let r=n==="zcat"?
|
|
682
|
-
`,h="",m=0;for(let d of a){let g=await
|
|
681
|
+
`,exitCode:1}}}async function gl(e,t,n){let r=n==="zcat"?nb:n==="gunzip"?tb:eb;if(U(e))return M(r);let s=be(n,e,rb);if(!s.ok)return s.error.stderr.includes("unrecognized option"),s.error;let i=s.result.flags,a=s.result.positional,o=n==="gunzip"||n==="zcat"||i.decompress||i.uncompress,l=n==="zcat"||i.stdout||i.toStdout;if(i.list){a.length===0&&(a=["-"]);let p=` compressed uncompressed ratio uncompressed_name
|
|
682
|
+
`,h="",m=0;for(let d of a){let g=await ib(t,d,i,n);p+=g.stdout,h+=g.stderr,g.exitCode!==0&&(m=g.exitCode)}return{stdout:p,stderr:h,exitCode:m}}if(i.test){a.length===0&&(a=["-"]);let p="",h="",m=0;for(let d of a){let g=await ab(t,d,i,n);p+=g.stdout,h+=g.stderr,g.exitCode!==0&&(m=g.exitCode)}return{stdout:p,stderr:h,exitCode:m}}a.length===0&&(a=["-"]);let c="",u="",f=0;for(let p of a){let h=await k0(t,p,i,n,o,l);c+=h.stdout,u+=h.stderr,h.exitCode!==0&&(f=h.exitCode)}return{stdout:c,stderr:u,exitCode:f}}var eb,tb,nb,rb,ob,lb,cb,ub,fb,pb,zi=I(()=>{"use strict";Ze();se();eb={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
|
|
|
686
|
-
With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},
|
|
686
|
+
With -d, decompress instead.`,options:["-c, --stdout write to standard output, keep original files","-d, --decompress decompress","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not save or restore the original name and timestamp","-N, --name save or restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode","-1, --fast compress faster","-9, --best compress better"," --help display this help and exit"]},tb={name:"gunzip",summary:"decompress files",usage:"gunzip [OPTION]... [FILE]...",description:`Decompress FILEs (by default, in-place).
|
|
687
687
|
|
|
688
|
-
When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},
|
|
688
|
+
When no FILE is given, or when FILE is -, read from standard input.`,options:["-c, --stdout write to standard output, keep original files","-f, --force force overwrite of output file","-k, --keep keep (don't delete) input files","-l, --list list compressed file contents","-n, --no-name do not restore the original name and timestamp","-N, --name restore the original file name and timestamp","-q, --quiet suppress all warnings","-r, --recursive operate recursively on directories","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},nb={name:"zcat",summary:"decompress files to stdout",usage:"zcat [OPTION]... [FILE]...",description:`Decompress FILEs to standard output.
|
|
689
689
|
|
|
690
|
-
When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},
|
|
690
|
+
When no FILE is given, or when FILE is -, read from standard input.`,options:["-f, --force force; read compressed data even from a terminal","-l, --list list compressed file contents","-q, --quiet suppress all warnings","-S, --suffix=SUF use suffix SUF on compressed files (default: .gz)","-t, --test test compressed file integrity","-v, --verbose verbose mode"," --help display this help and exit"]},rb={stdout:{short:"c",long:"stdout",type:"boolean"},toStdout:{long:"to-stdout",type:"boolean"},decompress:{short:"d",long:"decompress",type:"boolean"},uncompress:{long:"uncompress",type:"boolean"},force:{short:"f",long:"force",type:"boolean"},keep:{short:"k",long:"keep",type:"boolean"},list:{short:"l",long:"list",type:"boolean"},noName:{short:"n",long:"no-name",type:"boolean"},name:{short:"N",long:"name",type:"boolean"},quiet:{short:"q",long:"quiet",type:"boolean"},recursive:{short:"r",long:"recursive",type:"boolean"},suffix:{short:"S",long:"suffix",type:"string",default:".gz"},test:{short:"t",long:"test",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"},fast:{short:"1",long:"fast",type:"boolean"},level2:{short:"2",type:"boolean"},level3:{short:"3",type:"boolean"},level4:{short:"4",type:"boolean"},level5:{short:"5",type:"boolean"},level6:{short:"6",type:"boolean"},level7:{short:"7",type:"boolean"},level8:{short:"8",type:"boolean"},best:{short:"9",long:"best",type:"boolean"}};ob={name:"gzip",async execute(e,t){return gl(e,t,"gzip")}},lb={name:"gunzip",async execute(e,t){return gl(e,t,"gunzip")}},cb={name:"zcat",async execute(e,t){return gl(e,t,"zcat")}},ub={name:"gzip",flags:[{flag:"-c",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-k",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-1",type:"boolean"},{flag:"-9",type:"boolean"}],stdinType:"binary",needsFiles:!0},fb={name:"gunzip",flags:[{flag:"-c",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-k",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"binary",needsFiles:!0},pb={name:"zcat",flags:[{flag:"-f",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"binary",needsFiles:!0}});function yl(e){let t=e.indexOf("=");if(t>=0){let n=e.slice(0,t),r=e.slice(t+1);return n?`${encodeURIComponent(n)}=${encodeURIComponent(r)}`:encodeURIComponent(r)}return encodeURIComponent(e)}function wl(e){let t=e.indexOf("=");if(t<0)return null;let n=e.slice(0,t),r=e.slice(t+1),s,i,a=r.match(/;type=([^;]+)$/);a&&(i=a[1],r=r.slice(0,-a[0].length));let o=r.match(/;filename=([^;]+)/);return o&&(s=o[1],r=r.replace(o[0],"")),(r.startsWith("@")||r.startsWith("<"))&&(s=s??r.slice(1).split("/").pop()),{name:n,value:r,filename:s,contentType:i}}function I0(e,t){let n=`----CurlFormBoundary${Date.now().toString(36)}`,r=[];for(let s of e){let i=s.value;if(i.startsWith("@")||i.startsWith("<")){let o=i.slice(1);i=t.get(o)??""}let a=`--${n}\r
|
|
691
691
|
`;s.filename?(a+=`Content-Disposition: form-data; name="${s.name}"; filename="${s.filename}"\r
|
|
692
692
|
`,s.contentType&&(a+=`Content-Type: ${s.contentType}\r
|
|
693
693
|
`)):a+=`Content-Disposition: form-data; name="${s.name}"\r
|
|
@@ -696,7 +696,7 @@ ${i}\r
|
|
|
696
696
|
`,r.push(a)}return r.push(`--${n}--\r
|
|
697
697
|
`),{body:r.join(""),boundary:n}}var bl=I(()=>{"use strict"});var $0,O0=I(()=>{"use strict";$0={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]}});function R0(e){let t={method:"GET",headers:Object.create(null),dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let n=0;n<e.length;n++){let r=e[n];if(r==="-X"||r==="--request")t.method=e[++n]??"GET";else if(r.startsWith("-X"))t.method=r.slice(2);else if(r.startsWith("--request="))t.method=r.slice(10);else if(r==="-H"||r==="--header"){let s=e[++n];if(s){let i=s.indexOf(":");if(i>0){let a=s.slice(0,i).trim(),o=s.slice(i+1).trim();t.headers[a]=o}}}else if(r.startsWith("--header=")){let s=r.slice(9),i=s.indexOf(":");if(i>0){let a=s.slice(0,i).trim(),o=s.slice(i+1).trim();t.headers[a]=o}}else if(r==="-d"||r==="--data"||r==="--data-raw")t.data=e[++n]??"",t.method==="GET"&&(t.method="POST");else if(r.startsWith("-d"))t.data=r.slice(2),t.method==="GET"&&(t.method="POST");else if(r.startsWith("--data="))t.data=r.slice(7),t.method==="GET"&&(t.method="POST");else if(r.startsWith("--data-raw="))t.data=r.slice(11),t.method==="GET"&&(t.method="POST");else if(r==="--data-binary")t.data=e[++n]??"",t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(r.startsWith("--data-binary="))t.data=r.slice(14),t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(r==="--data-urlencode"){let s=e[++n]??"";t.data=(t.data?`${t.data}&`:"")+yl(s),t.method==="GET"&&(t.method="POST")}else if(r.startsWith("--data-urlencode=")){let s=r.slice(17);t.data=(t.data?`${t.data}&`:"")+yl(s),t.method==="GET"&&(t.method="POST")}else if(r==="-F"||r==="--form"){let s=e[++n]??"",i=wl(s);i&&t.formFields.push(i),t.method==="GET"&&(t.method="POST")}else if(r.startsWith("--form=")){let s=r.slice(7),i=wl(s);i&&t.formFields.push(i),t.method==="GET"&&(t.method="POST")}else if(r==="-u"||r==="--user")t.user=e[++n];else if(r.startsWith("-u"))t.user=r.slice(2);else if(r.startsWith("--user="))t.user=r.slice(7);else if(r==="-A"||r==="--user-agent")t.headers["User-Agent"]=e[++n]??"";else if(r.startsWith("-A"))t.headers["User-Agent"]=r.slice(2);else if(r.startsWith("--user-agent="))t.headers["User-Agent"]=r.slice(13);else if(r==="-e"||r==="--referer")t.headers.Referer=e[++n]??"";else if(r.startsWith("-e"))t.headers.Referer=r.slice(2);else if(r.startsWith("--referer="))t.headers.Referer=r.slice(10);else if(r==="-b"||r==="--cookie")t.headers.Cookie=e[++n]??"";else if(r.startsWith("-b"))t.headers.Cookie=r.slice(2);else if(r.startsWith("--cookie="))t.headers.Cookie=r.slice(9);else if(r==="-c"||r==="--cookie-jar")t.cookieJar=e[++n];else if(r.startsWith("--cookie-jar="))t.cookieJar=r.slice(13);else if(r==="-T"||r==="--upload-file")t.uploadFile=e[++n],t.method==="GET"&&(t.method="PUT");else if(r.startsWith("--upload-file="))t.uploadFile=r.slice(14),t.method==="GET"&&(t.method="PUT");else if(r==="-m"||r==="--max-time"){let s=parseFloat(e[++n]??"0");!Number.isNaN(s)&&s>0&&(t.timeoutMs=s*1e3)}else if(r.startsWith("--max-time=")){let s=parseFloat(r.slice(11));!Number.isNaN(s)&&s>0&&(t.timeoutMs=s*1e3)}else if(r==="--connect-timeout"){let s=parseFloat(e[++n]??"0");!Number.isNaN(s)&&s>0&&t.timeoutMs===void 0&&(t.timeoutMs=s*1e3)}else if(r.startsWith("--connect-timeout=")){let s=parseFloat(r.slice(18));!Number.isNaN(s)&&s>0&&t.timeoutMs===void 0&&(t.timeoutMs=s*1e3)}else if(r==="-o"||r==="--output")t.outputFile=e[++n];else if(r.startsWith("--output="))t.outputFile=r.slice(9);else if(r==="-O"||r==="--remote-name")t.useRemoteName=!0;else if(r==="-I"||r==="--head")t.headOnly=!0,t.method="HEAD";else if(r==="-i"||r==="--include")t.includeHeaders=!0;else if(r==="-s"||r==="--silent")t.silent=!0;else if(r==="-S"||r==="--show-error")t.showError=!0;else if(r==="-f"||r==="--fail")t.failSilently=!0;else if(r==="-L"||r==="--location")t.followRedirects=!0;else if(r==="--max-redirs")n++;else if(!r.startsWith("--max-redirs="))if(r==="-w"||r==="--write-out")t.writeOut=e[++n];else if(r.startsWith("--write-out="))t.writeOut=r.slice(12);else if(r==="-v"||r==="--verbose")t.verbose=!0;else{if(r.startsWith("--")&&r!=="--")return Y("curl",r);if(r.startsWith("-")&&r!=="-")for(let s of r.slice(1))switch(s){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD";break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;default:return Y("curl",`-${s}`)}else r.startsWith("-")||(t.url=r)}}return t}var T0=I(()=>{"use strict";se();bl()});function xl(e){return Object.entries(e).map(([t,n])=>`${t}: ${n}`).join(`\r
|
|
698
698
|
`)}function P0(e){try{return new URL(e).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function El(e,t){let n=e;return n=n.replace(/%\{http_code\}/g,String(t.status)),n=n.replace(/%\{content_type\}/g,t.headers["content-type"]||""),n=n.replace(/%\{url_effective\}/g,t.url),n=n.replace(/%\{size_download\}/g,String(t.bodyLength)),n=n.replace(/\\n/g,`
|
|
699
|
-
`),n}var D0=I(()=>{"use strict"});var _0={};K(_0,{curlCommand:()=>
|
|
699
|
+
`),n}var D0=I(()=>{"use strict"});var _0={};K(_0,{curlCommand:()=>yb});async function hb(e,t){if(e.uploadFile){let n=t.fs.resolvePath(t.cwd,e.uploadFile);return{body:await t.fs.readFile(n)}}if(e.formFields.length>0){let n=new Map;for(let i of e.formFields)if(i.value.startsWith("@")||i.value.startsWith("<")){let a=t.fs.resolvePath(t.cwd,i.value.slice(1));try{let o=await t.fs.readFile(a);n.set(i.value.slice(1),o)}catch{n.set(i.value.slice(1),"")}}let{body:r,boundary:s}=I0(e.formFields,n);return{body:r,contentType:`multipart/form-data; boundary=${s}`}}return e.data!==void 0?{body:e.data}:{}}function db(e,t){let n=Ke(e.headers??{});if(e.user){let r=Buffer.from(e.user).toString("base64");n.Authorization=`Basic ${r}`}return t&&!n["Content-Type"]&&(n["Content-Type"]=t),n}async function mb(e,t,n){if(!e.cookieJar)return;let r=t["set-cookie"];if(!r)return;let s=n.fs.resolvePath(n.cwd,e.cookieJar);await n.fs.writeFile(s,r)}function gb(e,t,n){let r="";if(e.verbose){r+=`> ${e.method} ${n}
|
|
700
700
|
`;for(let[s,i]of Object.entries(e.headers))r+=`> ${s}: ${i}
|
|
701
701
|
`;r+=`>
|
|
702
702
|
`,r+=`< HTTP/1.1 ${t.status} ${t.statusText}
|
|
@@ -707,22 +707,22 @@ ${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+=xl(t.headers),r+=`\r
|
|
710
|
-
`):r+=t.body,e.writeOut&&(r+=El(e.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),r}var
|
|
710
|
+
`):r+=t.body,e.writeOut&&(r+=El(e.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),r}var yb,L0=I(()=>{"use strict";zt();se();Nn();bl();O0();T0();D0();yb={name:"curl",async execute(e,t){if(U(e))return M($0);let n=R0(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
|
-
`,exitCode:1};let s=r.url;s.match(/^https?:\/\//)||(s=`https://${s}`);try{let{body:i,contentType:a}=await
|
|
713
|
-
`:"",exitCode:22};let c=
|
|
712
|
+
`,exitCode:1};let s=r.url;s.match(/^https?:\/\//)||(s=`https://${s}`);try{let{body:i,contentType:a}=await hb(r,t),o=db(r,a),l=await t.fetch(s,{method:r.method,headers:Object.keys(o).length>0?o:void 0,body:i,followRedirects:r.followRedirects,timeoutMs:r.timeoutMs});if(await mb(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
|
+
`:"",exitCode:22};let c=gb(r,l,s);if(r.outputFile||r.useRemoteName){let u=r.outputFile||P0(s),f=t.fs.resolvePath(t.cwd,u);await t.fs.writeFile(f,r.headOnly?"":l.body),r.verbose||(c=""),r.writeOut&&(c=El(r.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:c,stderr:"",exitCode:0}}catch(i){let a=Ue(i),o=1;return a.includes("Network access denied")?o=7:a.includes("HTTP method")&&a.includes("not allowed")?o=3:a.includes("Redirect target not in allow-list")||a.includes("Too many redirects")?o=47:a.includes("aborted")&&(o=28),{stdout:"",stderr:!r.silent||r.showError?`curl: (${o}) ${a}
|
|
714
714
|
`:"",exitCode:o}}}}});function Nl(e){let{pid:t,ppid:n,uid:r,gid:s}=e;return`Name: bash
|
|
715
715
|
State: R (running)
|
|
716
716
|
Pid: ${t}
|
|
717
717
|
PPid: ${n}
|
|
718
718
|
Uid: ${r} ${r} ${r} ${r}
|
|
719
719
|
Gid: ${s} ${s} ${s} ${s}
|
|
720
|
-
`}var G0,V0,kl=I(()=>{"use strict";G0="5.1.0(1)-release",V0="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT"});function K0(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 Q0(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
|
|
721
|
-
`||e===";"||e==="&"||e==="|"||e==="("||e===")"||e==="<"||e===">"}var E,Ln,Z0,Pb,Db,
|
|
720
|
+
`}var G0,V0,kl=I(()=>{"use strict";G0="5.1.0(1)-release",V0="Linux version 5.15.0-generic (just-bash) #1 SMP PREEMPT"});function K0(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 Q0(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 _b(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function X0(e){return e===" "||e===" "||e===`
|
|
721
|
+
`||e===";"||e==="&"||e==="|"||e==="("||e===")"||e==="<"||e===">"}var E,Ln,Z0,Tb,Pb,Db,ji,Fn=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={}));Ln=class extends Error{line;column;constructor(t,n,r){super(`line ${n}: ${t}`),this.line=n,this.column=r,this.name="LexerError"}},Z0=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]]);Tb=[[";",";","&",E.SEMI_SEMI_AND],["<","<","<",E.TLESS],["&",">",">",E.AND_DGREAT]],Pb=[["[","[",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]],Db=new Map([["|",E.PIPE],["&",E.AMP],[";",E.SEMICOLON],["(",E.LPAREN],[")",E.RPAREN],["<",E.LESS],[">",E.GREAT]]);ji=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 a=t[r];if(a===" "||a===" ")r++,s++;else if(a==="\\"&&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],a=t[n+1],o=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:`
|
|
724
|
-
`,start:n,end:n+1,line:r,column:s};if(i==="<"&&a==="<"&&o==="-")return this.pos=n+3,this.column=s+3,this.registerHeredocFromLookahead(!0),this.makeToken(E.DLESSDASH,"<<-",n,r,s);for(let[c,u,f,p]of
|
|
725
|
-
`&&p!==";"&&p!=="&"&&p!=="|"&&p!=="("&&p!==")"&&p!=="<"&&p!==">")break}return this.pos=n+2,this.column=s+2,this.makeToken(f,c+u,n,r,s)}if(i==="("&&this.dparenDepth>0)return this.pos=n+1,this.column=s+1,this.dparenDepth++,this.makeToken(E.LPAREN,"(",n,r,s);if(i===")"&&this.dparenDepth>1)return this.pos=n+1,this.column=s+1,this.dparenDepth--,this.makeToken(E.RPAREN,")",n,r,s);let l=
|
|
724
|
+
`,start:n,end:n+1,line:r,column:s};if(i==="<"&&a==="<"&&o==="-")return this.pos=n+3,this.column=s+3,this.registerHeredocFromLookahead(!0),this.makeToken(E.DLESSDASH,"<<-",n,r,s);for(let[c,u,f,p]of Tb)if(i===c&&a===u&&o===f)return this.pos=n+3,this.column=s+3,this.makeToken(p,c+u+f,n,r,s);if(i==="<"&&a==="<")return this.pos=n+2,this.column=s+2,this.registerHeredocFromLookahead(!1),this.makeToken(E.DLESS,"<<",n,r,s);if(i==="("&&a==="(")return this.dparenDepth>0?(this.pos=n+1,this.column=s+1,this.dparenDepth++,this.makeToken(E.LPAREN,"(",n,r,s)):this.looksLikeNestedSubshells(n+2)||this.dparenClosesWithSpacedParens(n+2)?(this.pos=n+1,this.column=s+1,this.makeToken(E.LPAREN,"(",n,r,s)):(this.pos=n+2,this.column=s+2,this.dparenDepth=1,this.makeToken(E.DPAREN_START,"((",n,r,s));if(i===")"&&a===")")return this.dparenDepth===1?(this.pos=n+2,this.column=s+2,this.dparenDepth=0,this.makeToken(E.DPAREN_END,"))",n,r,s)):this.dparenDepth>1?(this.pos=n+1,this.column=s+1,this.dparenDepth--,this.makeToken(E.RPAREN,")",n,r,s)):(this.pos=n+1,this.column=s+1,this.makeToken(E.RPAREN,")",n,r,s));for(let[c,u,f]of Pb)if(!(c==="("&&u==="("||c===")"&&u===")")&&!(this.dparenDepth>0&&c===";"&&(f===E.DSEMI||f===E.SEMI_AND||f===E.SEMI_SEMI_AND))&&i===c&&a===u){if(f===E.DBRACK_START||f===E.DBRACK_END){let p=t[n+2];if(p!==void 0&&p!==" "&&p!==" "&&p!==`
|
|
725
|
+
`&&p!==";"&&p!=="&"&&p!=="|"&&p!=="("&&p!==")"&&p!=="<"&&p!==">")break}return this.pos=n+2,this.column=s+2,this.makeToken(f,c+u,n,r,s)}if(i==="("&&this.dparenDepth>0)return this.pos=n+1,this.column=s+1,this.dparenDepth++,this.makeToken(E.LPAREN,"(",n,r,s);if(i===")"&&this.dparenDepth>1)return this.pos=n+1,this.column=s+1,this.dparenDepth--,this.makeToken(E.RPAREN,")",n,r,s);let l=Db.get(i);if(l!==void 0)return this.pos=n+1,this.column=s+1,this.makeToken(l,i,n,r,s);if(i==="{"){let c=this.scanFdVariable(n);return c!==null?(this.pos=c.end,this.column=s+(c.end-n),{type:E.FD_VARIABLE,value:c.varname,start:n,end:c.end,line:r,column:s}):a==="}"?(this.pos=n+2,this.column=s+2,{type:E.WORD,value:"{}",start:n,end:n+2,line:r,column:s,quoted:!1,singleQuoted:!1}):this.scanBraceExpansion(n)!==null?this.readWordWithBraceExpansion(n,r,s):this.scanLiteralBraceWord(n)!==null?this.readWordWithBraceExpansion(n,r,s):a!==void 0&&a!==" "&&a!==" "&&a!==`
|
|
726
726
|
`?this.readWord(n,r,s):(this.pos=n+1,this.column=s+1,this.makeToken(E.LBRACE,"{",n,r,s))}return i==="}"?this.isWordCharFollowing(n+1)?this.readWord(n,r,s):(this.pos=n+1,this.column=s+1,this.makeToken(E.RBRACE,"}",n,r,s)):i==="!"?a==="="?(this.pos=n+2,this.column=s+2,this.makeToken(E.WORD,"!=",n,r,s)):(this.pos=n+1,this.column=s+1,this.makeToken(E.BANG,"!",n,r,s)):this.readWord(n,r,s)}looksLikeNestedSubshells(t){let n=this.input,r=n.length,s=t;for(;s<r&&(n[s]===" "||n[s]===" ");)s++;if(s>=r)return!1;let i=n[s];if(i==="(")return this.looksLikeNestedSubshells(s+1);let a=/[a-zA-Z_]/.test(i),o=i==="!"||i==="[";if(!a&&!o)return!1;let l=s;for(;l<r&&/[a-zA-Z0-9_\-.]/.test(n[l]);)l++;if(l===s)return o;let c=l;for(;c<r&&(n[c]===" "||n[c]===" ");)c++;if(c>=r)return!1;let u=n[c];if(u==="="&&n[c+1]!=="="||u===`
|
|
727
727
|
`||l===c&&/[+\-*/%<>&|^!~?:]/.test(u)&&u!=="-"||u===")"&&n[c+1]===")")return!1;if(c>l&&(u==="-"||u==='"'||u==="'"||u==="$"||/[a-zA-Z_/.]/.test(u))){let f=c;for(;f<r&&n[f]!==`
|
|
728
728
|
`;){if(n[f]===")")return!0;f++}return!1}if(u===")"){let f=c+1;for(;f<r&&(n[f]===" "||n[f]===" ");)f++;if(n[f]==="|"&&n[f+1]==="|"||n[f]==="&"&&n[f+1]==="&"||n[f]===";"||n[f]==="|"&&n[f+1]!=="|")return!0}return!1}makeToken(t,n,r,s,i){return{type:t,value:n,start:r,end:this.pos,line:s,column:i}}readComment(t,n,r){let s=this.input,i=s.length,a=this.pos;for(;a<i&&s[a]!==`
|
|
@@ -741,7 +741,7 @@ Gid: ${s} ${s} ${s} ${s}
|
|
|
741
741
|
`){a+=2,c++,l=1;continue}if(k==="\\"&&a+1<i&&!S){u+=k,a++,l++,u+=s[a],a++,l++;continue}u+=k,S?k==="'"&&(S=!1):$?k==='"'&&($=!1):k==="'"?(S=!0,O=c,F=l):k==='"'?($=!0,R=c,z=l):k==="{"?x++:k==="}"&&x--,k===`
|
|
742
742
|
`&&(c++,l=0),a++,l++}if(S)throw new Ln("unexpected EOF while looking for matching `''",O,F);if($)throw new Ln("unexpected EOF while looking for matching `\"'",R,z);continue}if(b==="$"&&a+1<i&&!h){let x=s[a+1];if(x==="#"||x==="?"||x==="$"||x==="!"||x==="@"||x==="*"||x==="-"||x>="0"&&x<="9"){u+=b+x,a+=2,l+=2;continue}}if(b==="`"&&!h){for(u+=b,a++,l++;a<i&&s[a]!=="`";){let x=s[a];u+=x,x==="\\"&&a+1<i&&(u+=s[a+1],a++,l++),x===`
|
|
743
743
|
`&&(c++,l=0),a++,l++}a<i&&(u+=s[a],a++,l++);continue}u+=b,a++,b===`
|
|
744
|
-
`?(c++,l=1):l++}if(this.pos=a,this.column=l,this.line=c,g&&d&&(u=s[t]+u,f=!1,p=!1),h||m){let b=h?"'":'"';throw new Ln(`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,p=!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,p=!1)}}if(u==="")return{type:E.WORD,value:"",start:t,end:a,line:n,column:r,quoted:f,singleQuoted:p};let y=Z0.get(u);if(!f&&y!==void 0)return{type:y,value:u,start:t,end:a,line:n,column:r};if(!d){let b=Q0(u);if(b>0&&K0(u.slice(0,b)))return{type:E.ASSIGNMENT_WORD,value:u,start:t,end:a,line:n,column:r,quoted:f,singleQuoted:p}}return/^[0-9]+$/.test(u)?{type:E.NUMBER,value:u,start:t,end:a,line:n,column:r}:
|
|
744
|
+
`?(c++,l=1):l++}if(this.pos=a,this.column=l,this.line=c,g&&d&&(u=s[t]+u,f=!1,p=!1),h||m){let b=h?"'":'"';throw new Ln(`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,p=!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,p=!1)}}if(u==="")return{type:E.WORD,value:"",start:t,end:a,line:n,column:r,quoted:f,singleQuoted:p};let y=Z0.get(u);if(!f&&y!==void 0)return{type:y,value:u,start:t,end:a,line:n,column:r};if(!d){let b=Q0(u);if(b>0&&K0(u.slice(0,b)))return{type:E.ASSIGNMENT_WORD,value:u,start:t,end:a,line:n,column:r,quoted:f,singleQuoted:p}}return/^[0-9]+$/.test(u)?{type:E.NUMBER,value:u,start:t,end:a,line:n,column:r}:_b(u)?{type:E.NAME,value:u,start:t,end:a,line:n,column:r,quoted:f,singleQuoted:p}:{type:E.WORD,value:u,start:t,end:a,line:n,column:r,quoted:f,singleQuoted:p}}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 a=this.pos,o="";for(;this.pos<this.input.length&&this.input[this.pos]!==`
|
|
745
745
|
`;)o+=this.input[this.pos],this.pos++,this.column++;if((t.stripTabs?o.replace(/^\t+/,""):o)===t.delimiter){this.pos<this.input.length&&this.input[this.pos]===`
|
|
746
746
|
`&&(this.pos++,this.line++,this.column=1);break}if(i+=o,i.length>10485760)throw new Ln("Heredoc size limit exceeded (10485760 bytes)",r,s);this.pos<this.input.length&&this.input[this.pos]===`
|
|
747
747
|
`&&(i+=`
|
|
@@ -757,49 +757,49 @@ Gid: ${s} ${s} ${s} ${s}
|
|
|
757
757
|
`);)p=!0,f++;if(p&&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,a=!1,o=!1;for(;s<r&&i>0;){let l=n[s];if(a){l==="'"&&(a=!1),s++;continue}if(o){if(l==="\\"){s+=2;continue}l==='"'&&(o=!1),s++;continue}if(l==="'"){a=!0,s++;continue}if(l==='"'){o=!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 Ol,Rl,Y0,Tl,J0,em,tm,lt,ir=I(()=>{"use strict";Fn();Ol=1e6,Rl=1e5,Y0=1e6,Tl=200,J0=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]),em=new Set([E.LESS,E.GREAT,E.DLESS,E.DGREAT,E.LESSAND,E.GREATAND,E.LESSGREAT,E.DLESSDASH,E.CLOBBER,E.TLESS]),tm=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,ar=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 Be(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 Ns(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 a;if(/[0-9]/.test(i))a=i.charCodeAt(0)-48;else if(/[a-z]/.test(i))a=i.charCodeAt(0)-97+10;else if(/[A-Z]/.test(i))a=i.charCodeAt(0)-65+36;else if(i==="@")a=62;else if(i==="_")a=63;else return Number.NaN;if(a>=r)return Number.NaN;s=s*r+a}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 nm(e,t,n,r){if(n.slice(r,r+3)!=="$((")return null;let s=r+3,i=1,a=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 o=n.slice(a,s),{expr:l}=e(t,o,0);return s+=2,{expr:{type:"ArithNested",expression:l},pos:s}}function rm(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 sm(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 Gi,im=I(()=>{"use strict";Gi=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function Fb(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=Fb(t),{expr:r,pos:s}=Ht(e,n,0),i=Be(n,s);if(i<n.length){let a=t.slice(i).trim();if(a)return{type:"ArithmeticExpression",originalText:t,expression:{type:"ArithSyntaxError",errorToken:a,message:`${a}: syntax error: invalid arithmetic operator (error token is "${a}")`}}}return{type:"ArithmeticExpression",expression:r,originalText:t}}function Tt(e,t){return{expr:{type:"ArithSyntaxError",errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function Pt(e,t){return Be(e,t)>=e.length}function Ht(e,t,n){return Mb(e,t,n)}function Mb(e,t,n){let{expr:r,pos:s}=ks(e,t,n);for(s=Be(t,s);t[s]===",";){if(s++,Pt(t,s))return Tt(",",s);let{expr:a,pos:o}=ks(e,t,s);r={type:"ArithBinary",operator:",",left:r,right:a},s=Be(t,o)}return{expr:r,pos:s}}function ks(e,t,n){let{expr:r,pos:s}=Ub(e,t,n);if(s=Be(t,s),t[s]==="?"){s++;let{expr:i,pos:a}=Ht(e,t,s);if(s=Be(t,a),t[s]===":"){s++;let{expr:o,pos:l}=Ht(e,t,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:o},pos:l}}}return{expr:r,pos:s}}function Ub(e,t,n){let{expr:r,pos:s}=am(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="||";){if(s+=2,Pt(t,s))return Tt("||",s);let{expr:a,pos:o}=am(e,t,s);r={type:"ArithBinary",operator:"||",left:r,right:a},s=o}return{expr:r,pos:s}}function am(e,t,n){let{expr:r,pos:s}=om(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="&&";){if(s+=2,Pt(t,s))return Tt("&&",s);let{expr:a,pos:o}=om(e,t,s);r={type:"ArithBinary",operator:"&&",left:r,right:a},s=o}return{expr:r,pos:s}}function om(e,t,n){let{expr:r,pos:s}=lm(e,t,n);for(;s=Be(t,s),t[s]==="|"&&t[s+1]!=="|";){if(s++,Pt(t,s))return Tt("|",s);let{expr:a,pos:o}=lm(e,t,s);r={type:"ArithBinary",operator:"|",left:r,right:a},s=o}return{expr:r,pos:s}}function lm(e,t,n){let{expr:r,pos:s}=cm(e,t,n);for(;s=Be(t,s),t[s]==="^";){if(s++,Pt(t,s))return Tt("^",s);let{expr:a,pos:o}=cm(e,t,s);r={type:"ArithBinary",operator:"^",left:r,right:a},s=o}return{expr:r,pos:s}}function cm(e,t,n){let{expr:r,pos:s}=um(e,t,n);for(;s=Be(t,s),t[s]==="&"&&t[s+1]!=="&";){if(s++,Pt(t,s))return Tt("&",s);let{expr:a,pos:o}=um(e,t,s);r={type:"ArithBinary",operator:"&",left:r,right:a},s=o}return{expr:r,pos:s}}function um(e,t,n){let{expr:r,pos:s}=fm(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="=="||t.slice(s,s+2)==="!=";){let i=t.slice(s,s+2);if(s+=2,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=fm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}return{expr:r,pos:s}}function fm(e,t,n){let{expr:r,pos:s}=Pl(e,t,n);for(;;)if(s=Be(t,s),t.slice(s,s+2)==="<="||t.slice(s,s+2)===">="){let i=t.slice(s,s+2);if(s+=2,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=Pl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else if(t[s]==="<"||t[s]===">"){let i=t[s];if(s++,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=Pl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else break;return{expr:r,pos:s}}function Pl(e,t,n){let{expr:r,pos:s}=pm(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="<<"||t.slice(s,s+2)===">>";){let i=t.slice(s,s+2);if(s+=2,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=pm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}return{expr:r,pos:s}}function pm(e,t,n){let{expr:r,pos:s}=hm(e,t,n);for(;s=Be(t,s),(t[s]==="+"||t[s]==="-")&&t[s+1]!==t[s];){let i=t[s];if(s++,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=hm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}return{expr:r,pos:s}}function hm(e,t,n){let{expr:r,pos:s}=Vi(e,t,n);for(;;)if(s=Be(t,s),t[s]==="*"&&t[s+1]!=="*"){if(s++,Pt(t,s))return Tt("*",s);let{expr:a,pos:o}=Vi(e,t,s);r={type:"ArithBinary",operator:"*",left:r,right:a},s=o}else if(t[s]==="/"||t[s]==="%"){let i=t[s];if(s++,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=Vi(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else break;return{expr:r,pos:s}}function Vi(e,t,n){let{expr:r,pos:s}=Dl(e,t,n),i=Be(t,s);if(t.slice(i,i+2)==="**"){if(i+=2,Pt(t,i))return Tt("**",i);let{expr:o,pos:l}=Vi(e,t,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:o},pos:l}}return{expr:r,pos:s}}function Dl(e,t,n){let r=Be(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:a}=Dl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:a}}if(t[r]==="+"||t[r]==="-"||t[r]==="!"||t[r]==="~"){let s=t[r];r++;let{expr:i,pos:a}=Dl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:a}}return Bb(e,t,r)}function Wb(e,t){let n=e[t];return n==="$"||n==="`"}function Bb(e,t,n){let{expr:r,pos:s}=dm(e,t,n,!1),i=[r];for(;Wb(t,s);){let{expr:o,pos:l}=dm(e,t,s,!0);i.push(o),s=l}i.length>1&&(r={type:"ArithConcat",parts:i});let a;if(t[s]==="["&&r.type==="ArithConcat"){s++;let{expr:o,pos:l}=Ht(e,t,s);a=o,s=l,t[s]==="]"&&s++}if(a&&r.type==="ArithConcat"&&(r={type:"ArithDynamicElement",nameExpr:r,subscript:a},a=void 0),s=Be(t,s),r.type==="ArithConcat"||r.type==="ArithVariable"||r.type==="ArithDynamicElement"){for(let o of Gi)if(t.slice(s,s+o.length)===o&&t.slice(s,s+o.length+1)!=="=="){s+=o.length;let{expr:l,pos:c}=ks(e,t,s);return r.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:o,target:r.nameExpr,subscript:r.subscript,value:l},pos:c}:r.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:o,target:r,value:l},pos:c}:{expr:{type:"ArithAssignment",operator:o,variable:r.name,value:l},pos:c}}}if(t.slice(s,s+2)==="++"||t.slice(s,s+2)==="--"){let o=t.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:o,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function dm(e,t,n,r=!1){let s=Be(t,n),i=nm(Ht,e,t,s);if(i)return i;let a=rm(t,s);if(a)return a;let o=sm(t,s);if(o)return o;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}=Ht(e,t,s);return s=Be(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}=Ht(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 h=t[s];if(u)if(/[0-9a-zA-Z@_]/.test(h))c+=h,s++;else break;else if(h==="#")u=!0,c+=h,s++;else if(c==="0"&&(h==="x"||h==="X")&&s+1<t.length&&/[0-9a-fA-F]/.test(t[s+1]))f=!0,c+=h,s++;else if(f&&/[0-9a-fA-F]/.test(h))c+=h,s++;else if(!f&&/[0-9]/.test(h))c+=h,s++;else break}if(s<t.length&&/[a-zA-Z_]/.test(t[s])){let h=c;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)h+=t[s],s++;return{expr:{type:"ArithSyntaxError",errorToken:h,message:`${h}: value too great for base (error token is "${h}")`},pos:s}}if(t[s]==="."&&/[0-9]/.test(t[s+1]))throw new Re(`${c}.${t[s+1]}...: syntax error: invalid arithmetic operator`);if(t[s]==="["){let h=t.slice(s).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:h},pos:t.length}}return{expr:{type:"ArithNumber",value:Ns(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 p=t.slice(c,f),h=f+1;if(t[h]==="#"){let m=h+1;for(;m<t.length&&/[0-9a-zA-Z@_]/.test(t[m]);)m++;let d=t.slice(h+1,m);return{expr:{type:"ArithDynamicBase",baseExpr:p,value:d},pos:m}}if(/[0-9]/.test(t[h])||t[h]==="x"||t[h]==="X"){let m=h;if(t[h]==="x"||t[h]==="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(h,m);return{expr:{type:"ArithDynamicNumber",prefix:p,suffix:d},pos:m}}return s=h,{expr:{type:"ArithBracedExpansion",content:p},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 p=t[s];for(s++,u="";s<t.length&&t[s]!==p;)u+=t[s],s++;t[s]===p&&s++,s=Be(t,s),t[s]==="]"&&s++}let f;if(u===void 0){let{expr:p,pos:h}=Ht(e,t,s);f=p,s=h,t[s]==="]"&&s++}if(s=Be(t,s),t[s]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:s};if(!r){for(let p of Gi)if(t.slice(s,s+p.length)===p&&t.slice(s,s+p.length+1)!=="=="){s+=p.length;let{expr:h,pos:m}=ks(e,t,s);return{expr:{type:"ArithAssignment",operator:p,variable:c,subscript:f,stringKey:u,value:h},pos:m}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:s}}if(s=Be(t,s),!r){for(let u of Gi)if(t.slice(s,s+u.length)===u&&t.slice(s,s+u.length+1)!=="=="){s+=u.length;let{expr:f,pos:p}=ks(e,t,s);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:p}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:l},pos:s}}if(t[s]==="#"){let c=s+1;for(;c<t.length&&t[c]!==`
|
|
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
|
|
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 o=[],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)o.push(u),l+=2+c.length;else break}o.length>0?(r+=zb(o),s=l):(r+="\\x",s+=2);break}case"u":{let o=t.slice(s+2,s+6),l=parseInt(o,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 o="",l=s+1;for(;l<t.length&&l<s+4&&/[0-7]/.test(t[l]);)o+=t[l],l++;let c=parseInt(o,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 Ll(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ae(e,n)}function gm(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 Em(e,t,n,r){let s=_l(e,t,n,"{","}");if(s===-1)return null;let i=t.slice(n+1,s),a=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(a)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(a[1],10),end:Number.parseInt(a[2],10),step:a[3]?Number.parseInt(a[3],10):void 0,startStr:a[1],endStr:a[2]}]},endIndex:s+1};let o=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return o?{part:{type:"BraceExpansion",items:[{type:"Range",start:o[1],end:o[2],step:o[3]?Number.parseInt(o[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:gm(i).map(u=>({type:"Word",word:q.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:gm(i).map(u=>({type:"Word",word:q.word([q.literal(u)])}))},endIndex:s+1}:null}function Fl(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 a=i.startStr??String(i.start),o=i.endStr??String(i.end);i.step!==void 0?s.push(`${a}..${o}..${i.step}`):s.push(`${a}..${o}`)}else s.push(Fl(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 Am(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 Ml=I(()=>{"use strict";ar();mt();Fn()});function qi(e){let t=e.current(),n=t.type;if(n===E.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:em.has(r.type)}if(n===E.FD_VARIABLE){let r=e.peek(1);return tm.has(r.type)}return J0.has(n)}function Zi(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=Am(e,r.type);if(r.type===E.DLESS||r.type===E.DLESSDASH)return jb(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 jb(e,t,n,r){e.isWord()||e.error("Expected here-document delimiter");let s=e.advance(),i=s.value,a=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let o=q.redirection(r?"<<-":"<<",q.hereDoc(i,q.word([]),r,a),n);return e.addPendingHeredoc(o,i,r,a),o}function Cm(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(E.ASSIGNMENT_WORD)||qi(e);)e.checkIterationLimit(),e.check(E.ASSIGNMENT_WORD)?n.push(Gb(e)):i.push(Zi(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(E.DBRACK_START)||e.check(E.DPAREN_START))){let o=e.advance();r=q.word([q.literal(o.value)])}for(;(!e.isStatementEnd()||e.check(E.RBRACE))&&!e.check(E.PIPE,E.PIPE_AMP);)if(e.checkIterationLimit(),qi(e))i.push(Zi(e));else if(e.check(E.RBRACE)){let o=e.advance();s.push(e.parseWordFromString(o.value,!1,!1))}else if(e.check(E.LBRACE)){let o=e.advance();s.push(e.parseWordFromString(o.value,!1,!1))}else if(e.check(E.DBRACK_END)){let o=e.advance();s.push(e.parseWordFromString(o.value,!1,!1))}else if(e.isWord())s.push(e.parseWord());else if(e.check(E.ASSIGNMENT_WORD)){let o=e.advance(),l=o.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 p=Ul(e);e.expect(E.RPAREN);let h=p.map(d=>Fl(e,d)),m=`${f}=(${h.join(" ")})`;s.push(e.parseWordFromString(m,!1,!1))}else s.push(e.parseWordFromString(l,o.quoted,o.singleQuoted))}else if(e.check(E.LPAREN))e.error("syntax error near unexpected token `('");else break;let a=q.simpleCommand(r,s,n,i);return a.line=t,a}function Gb(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,a=s.length;if(n[a]==="["){let f=0,p=a+1;for(;a<n.length;a++)if(n[a]==="[")f++;else if(n[a]==="]"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${n}`),i=n.slice(p,a),a++}let o=n[a]==="+";o&&a++,n[a]!=="="&&e.error(`Invalid assignment: ${n}`),a++;let l=n.slice(a);if(l==="("){let f=Ul(e);e.expect(E.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return q.assignment(p,null,o,f)}if(l===""&&e.check(E.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let p=Ul(e);e.expect(E.RPAREN);let h=i!==void 0?`${s}[${i}]`:s;return q.assignment(h,null,o,p)}}let c=l?e.parseWordFromString(l,t.quoted,t.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return q.assignment(u,c,o,null)}function Ul(e){let t=[];for(e.skipNewlines();!e.check(E.RPAREN,E.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):Vb.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var Vb,Nm=I(()=>{"use strict";ar();Fn();ir();Ml();Vb=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 Wl(e,t){e.expect(E.IF);let n=[],r=e.parseCompoundList();e.expect(E.THEN);let s=e.parseCompoundList();if(s.length===0){let o=e.check(E.FI)?"fi":e.check(E.ELSE)?"else":e.check(E.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${o}'`)}for(n.push({condition:r,body:s});e.check(E.ELIF);){e.advance();let o=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:o,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 a=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.ifNode(n,i,a)}function Bl(e,t){let n=e.expect(E.FOR);if(e.check(E.DPAREN_START))return Zb(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 a=e.parseCompoundList();e.expect(E.DONE);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.forNode(s,i,a,o)}function Zb(e,t,n){e.expect(E.DPAREN_START);let r=null,s=null,i=null,a=["","",""],o=0,l=0;for(;!e.check(E.DPAREN_END,E.EOF);){let f=e.advance();if(f.type===E.SEMICOLON&&l===0){if(o++,o>2)break}else f.value==="("&&l++,f.value===")"&&l--,a[o]+=f.value}e.expect(E.DPAREN_END),a[0].trim()&&(r=Ae(e,a[0].trim())),a[1].trim()&&(s=Ae(e,a[1].trim())),a[2].trim()&&(i=Ae(e,a[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 zl(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 Hl(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 jl(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(),a=Kb(e);if(a&&r.push(a),e.skipNewlines(),e.getPos()===i&&!a)break}e.expect(E.ESAC);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.caseNode(n,r,s)}function Kb(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 Gl(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 Vl(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 km=I(()=>{"use strict";ar();mt();Fn()});function vm(e){return e.isWord()||e.check(E.LBRACE)||e.check(E.RBRACE)||e.check(E.ASSIGNMENT_WORD)}function Im(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 Zl(e){return e.skipNewlines(),Jb(e)}function Jb(e){let t=$m(e);for(e.skipNewlines();e.check(E.OR_OR);){e.advance(),e.skipNewlines();let n=$m(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function $m(e){let t=ql(e);for(e.skipNewlines();e.check(E.AND_AND);){e.advance(),e.skipNewlines();let n=ql(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function ql(e){return e.skipNewlines(),e.check(E.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:ql(e)}):ex(e)}function ex(e){if(e.check(E.LPAREN)){e.advance();let t=Zl(e);return e.expect(E.RPAREN),{type:"CondGroup",expression:t}}if(vm(e)){let t=e.current(),n=t.value;if(Xb.includes(n)&&!t.quoted){if(e.advance(),e.check(E.DBRACK_END)&&e.error(`Expected operand after ${n}`),vm(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()&&Yb.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=tx(e):s==="=="||s==="!="?i=Im(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=Im(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function tx(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 a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let l=s.slice(r,a.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 Xb,Yb,Om=I(()=>{"use strict";Fn();Xb=["-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"],Yb=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function rx(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 sx(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 ix(e,t,n,r=!1){let s=n+2,i=!1;t[s]==="!"&&(i=!0,s++);let a=!1;t[s]==="#"&&!/[}:#%/^,]/.test(t[s+1]||"}")&&(a=!0,s++);let o="",l=t[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(t[s+1]||""))o=l,s++;else for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)o+=t[s],s++;if(t[s]==="["){let u=_l(e,t,s,"[","]");if(o+=t.slice(s,u+1),s=u+1,t[s]==="["){let f=1,p=s;for(;p<t.length&&f>0;)t[p]==="{"?f++:t[p]==="}"&&f--,f>0&&p++;let h=t.slice(n+2,p);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:h}),endIndex:p+1}}}if(o===""&&!i&&!a&&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 p=t.slice(n+2,f);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:p}),endIndex:f+1}}let c=null;if(i){let u=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Kl(e,t,s,o,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},o="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},o="";else if(t[s]==="*"||t[s]==="@"&&!/[QPaAEKkuUL]/.test(t[s+1]||"")){let f=t[s];s++,c={type:"VarNamePrefix",prefix:o,star:f==="*"},o=""}else if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Kl(e,t,s,o,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(a)if(t[s]===":")for(c={type:"LengthSliceError"};s<t.length&&t[s]!=="}";)s++;else t[s]!=="}"&&/[-+=?]/.test(t[s])?e.error(`\${#${o}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):t[s]==="/"?e.error(`\${#${o}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<t.length&&t[s]!=="}"){let u=Kl(e,t,s,o,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 p=t.slice(n,f+1);e.error(`\${${p.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(o,c),endIndex:s+1}}function Kl(e,t,n,r,s=!1){let i=n,a=t[i],o=t[i+1]||"";if(a===":"){let l=o;if("-=?+".includes(l)){i+=2;let w=or(e,t,i),y=t.slice(i,w),b=Mn(e,y,!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:w};if(l==="=")return{operation:{type:"AssignDefault",word:x,checkEmpty:!0},endIndex:w};if(l==="?")return{operation:{type:"ErrorIfUnset",word:x,checkEmpty:!0},endIndex:w};if(l==="+")return{operation:{type:"UseAlternative",word:x,checkEmpty:!0},endIndex:w}}i++;let c=or(e,t,i),u=t.slice(i,c),f=-1,p=0,h=0;for(let g=0;g<u.length;g++){let w=u[g];if(w==="("||w==="[")p++;else if(w===")"||w==="]")p--;else if(w==="?"&&p===0)h++;else if(w===":"&&p===0)if(h>0)h--;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:Ll(e,m),length:d!==null?Ll(e,d):null},endIndex:c}}if("-=?+".includes(a)){i++;let l=or(e,t,i),c=t.slice(i,l),u=Mn(e,c,!1,!1,!0,!1,s,!1,!1,!0),f=q.word(u.length>0?u:[q.literal("")]);if(a==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(a==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(a==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(a==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(a==="#"||a==="%"){let l=o===a,c=a==="#"?"prefix":"suffix";i+=l?2:1;let u=or(e,t,i),f=t.slice(i,u),p=Mn(e,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:q.word(p.length>0?p:[q.literal("")]),side:c,greedy:l},endIndex:u}}if(a==="/"){let l=o==="/";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=wm(e,t,i);let f=t.slice(i,u),p=Mn(e,f,!1,!1,!1),h=q.word(p.length>0?p:[q.literal("")]),m=null,d=u;if(t[u]==="/"){let g=u+1,w=or(e,t,g),y=t.slice(g,w),b=Mn(e,y,!1,!1,!1);m=q.word(b.length>0?b:[q.literal("")]),d=w}return{operation:{type:"PatternReplacement",pattern:h,replacement:m,all:l,anchor:c},endIndex:d}}if(a==="^"||a===","){let l=o===a,c=a==="^"?"upper":"lower";i+=l?2:1;let u=or(e,t,i),f=t.slice(i,u),p=f?q.word([q.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:p},endIndex:u}}return a==="@"&&/[QPaAEKkuUL]/.test(o)?{operation:{type:"Transform",operator:o},endIndex:i+2}:{operation:null,endIndex:i}}function Ql(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 a=1,o=s+1;for(;o<t.length&&a>0;)t[o]==="["?a++:t[o]==="]"&&a--,a>0&&o++;if(a===0){let l=t.slice(s+1,o),c=Ae(e,l);return{part:q.arithmeticExpansion(c),endIndex:o+1}}}return i==="("?e.parseCommandSubstitution(t,n):i==="{"?ix(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?sx(e,t,n):{part:q.literal("$"),endIndex:s}}function Rm(e,t){let n=[],r=0,s="",i=()=>{s&&(n.push(q.literal(s)),s="")};for(;r<t.length;){let a=t[r];if(a==="\\"&&r+1<t.length){let o=t[r+1];if(o==="$"||o==="`"||o==='"'||o==="\\"){s+=o,r+=2;continue}s+=a,r++;continue}if(a==="$"){i();let{part:o,endIndex:l}=Ql(e,t,r,!0);o&&n.push(o),r=l;continue}if(a==="`"){i();let{part:o,endIndex:l}=e.parseBacktickSubstitution(t,r,!0);n.push(o),r=l;continue}s+=a,r++}return i(),n}function ax(e,t,n){let r=[],s=n,i="",a=()=>{i&&(r.push(q.literal(i)),i="")};for(;s<t.length&&t[s]!=='"';){let o=t[s];if(o==="\\"&&s+1<t.length){let l=t[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=o,s++;continue}if(o==="$"){a();let{part:l,endIndex:c}=Ql(e,t,s,!0);l&&r.push(l),s=c;continue}if(o==="`"){a();let{part:l,endIndex:c}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=c;continue}i+=o,s++}return a(),{part:q.doubleQuoted(r),endIndex:s}}function Mn(e,t,n=!1,r=!1,s=!1,i=!1,a=!1,o=!1,l=!1,c=!1){if(r)return[q.singleQuoted(t)];if(n){let m=Rm(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=Rm(e,m);return[q.doubleQuoted(g)]}}let u=[],f=0,p="",h=()=>{p&&(u.push(q.literal(p)),p="")};for(;f<t.length;){let m=t[f];if(m==="\\"&&f+1<t.length){let d=t[f+1];if(l){h(),u.push(q.escaped(d)),f+=2;continue}let g=i?d==="$"||d==="`"||d===`
|
|
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 sm(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 Gi,im=I(()=>{"use strict";Gi=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function Lb(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=Lb(t),{expr:r,pos:s}=Ht(e,n,0),i=Be(n,s);if(i<n.length){let a=t.slice(i).trim();if(a)return{type:"ArithmeticExpression",originalText:t,expression:{type:"ArithSyntaxError",errorToken:a,message:`${a}: syntax error: invalid arithmetic operator (error token is "${a}")`}}}return{type:"ArithmeticExpression",expression:r,originalText:t}}function Tt(e,t){return{expr:{type:"ArithSyntaxError",errorToken:e,message:`syntax error: operand expected (error token is "${e}")`},pos:t}}function Pt(e,t){return Be(e,t)>=e.length}function Ht(e,t,n){return Fb(e,t,n)}function Fb(e,t,n){let{expr:r,pos:s}=ks(e,t,n);for(s=Be(t,s);t[s]===",";){if(s++,Pt(t,s))return Tt(",",s);let{expr:a,pos:o}=ks(e,t,s);r={type:"ArithBinary",operator:",",left:r,right:a},s=Be(t,o)}return{expr:r,pos:s}}function ks(e,t,n){let{expr:r,pos:s}=Mb(e,t,n);if(s=Be(t,s),t[s]==="?"){s++;let{expr:i,pos:a}=Ht(e,t,s);if(s=Be(t,a),t[s]===":"){s++;let{expr:o,pos:l}=Ht(e,t,s);return{expr:{type:"ArithTernary",condition:r,consequent:i,alternate:o},pos:l}}}return{expr:r,pos:s}}function Mb(e,t,n){let{expr:r,pos:s}=am(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="||";){if(s+=2,Pt(t,s))return Tt("||",s);let{expr:a,pos:o}=am(e,t,s);r={type:"ArithBinary",operator:"||",left:r,right:a},s=o}return{expr:r,pos:s}}function am(e,t,n){let{expr:r,pos:s}=om(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="&&";){if(s+=2,Pt(t,s))return Tt("&&",s);let{expr:a,pos:o}=om(e,t,s);r={type:"ArithBinary",operator:"&&",left:r,right:a},s=o}return{expr:r,pos:s}}function om(e,t,n){let{expr:r,pos:s}=lm(e,t,n);for(;s=Be(t,s),t[s]==="|"&&t[s+1]!=="|";){if(s++,Pt(t,s))return Tt("|",s);let{expr:a,pos:o}=lm(e,t,s);r={type:"ArithBinary",operator:"|",left:r,right:a},s=o}return{expr:r,pos:s}}function lm(e,t,n){let{expr:r,pos:s}=cm(e,t,n);for(;s=Be(t,s),t[s]==="^";){if(s++,Pt(t,s))return Tt("^",s);let{expr:a,pos:o}=cm(e,t,s);r={type:"ArithBinary",operator:"^",left:r,right:a},s=o}return{expr:r,pos:s}}function cm(e,t,n){let{expr:r,pos:s}=um(e,t,n);for(;s=Be(t,s),t[s]==="&"&&t[s+1]!=="&";){if(s++,Pt(t,s))return Tt("&",s);let{expr:a,pos:o}=um(e,t,s);r={type:"ArithBinary",operator:"&",left:r,right:a},s=o}return{expr:r,pos:s}}function um(e,t,n){let{expr:r,pos:s}=fm(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="=="||t.slice(s,s+2)==="!=";){let i=t.slice(s,s+2);if(s+=2,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=fm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}return{expr:r,pos:s}}function fm(e,t,n){let{expr:r,pos:s}=Pl(e,t,n);for(;;)if(s=Be(t,s),t.slice(s,s+2)==="<="||t.slice(s,s+2)===">="){let i=t.slice(s,s+2);if(s+=2,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=Pl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else if(t[s]==="<"||t[s]===">"){let i=t[s];if(s++,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=Pl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else break;return{expr:r,pos:s}}function Pl(e,t,n){let{expr:r,pos:s}=pm(e,t,n);for(;s=Be(t,s),t.slice(s,s+2)==="<<"||t.slice(s,s+2)===">>";){let i=t.slice(s,s+2);if(s+=2,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=pm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}return{expr:r,pos:s}}function pm(e,t,n){let{expr:r,pos:s}=hm(e,t,n);for(;s=Be(t,s),(t[s]==="+"||t[s]==="-")&&t[s+1]!==t[s];){let i=t[s];if(s++,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=hm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}return{expr:r,pos:s}}function hm(e,t,n){let{expr:r,pos:s}=Vi(e,t,n);for(;;)if(s=Be(t,s),t[s]==="*"&&t[s+1]!=="*"){if(s++,Pt(t,s))return Tt("*",s);let{expr:a,pos:o}=Vi(e,t,s);r={type:"ArithBinary",operator:"*",left:r,right:a},s=o}else if(t[s]==="/"||t[s]==="%"){let i=t[s];if(s++,Pt(t,s))return Tt(i,s);let{expr:a,pos:o}=Vi(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else break;return{expr:r,pos:s}}function Vi(e,t,n){let{expr:r,pos:s}=Dl(e,t,n),i=Be(t,s);if(t.slice(i,i+2)==="**"){if(i+=2,Pt(t,i))return Tt("**",i);let{expr:o,pos:l}=Vi(e,t,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:o},pos:l}}return{expr:r,pos:s}}function Dl(e,t,n){let r=Be(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:a}=Dl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:a}}if(t[r]==="+"||t[r]==="-"||t[r]==="!"||t[r]==="~"){let s=t[r];r++;let{expr:i,pos:a}=Dl(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:a}}return Wb(e,t,r)}function Ub(e,t){let n=e[t];return n==="$"||n==="`"}function Wb(e,t,n){let{expr:r,pos:s}=dm(e,t,n,!1),i=[r];for(;Ub(t,s);){let{expr:o,pos:l}=dm(e,t,s,!0);i.push(o),s=l}i.length>1&&(r={type:"ArithConcat",parts:i});let a;if(t[s]==="["&&r.type==="ArithConcat"){s++;let{expr:o,pos:l}=Ht(e,t,s);a=o,s=l,t[s]==="]"&&s++}if(a&&r.type==="ArithConcat"&&(r={type:"ArithDynamicElement",nameExpr:r,subscript:a},a=void 0),s=Be(t,s),r.type==="ArithConcat"||r.type==="ArithVariable"||r.type==="ArithDynamicElement"){for(let o of Gi)if(t.slice(s,s+o.length)===o&&t.slice(s,s+o.length+1)!=="=="){s+=o.length;let{expr:l,pos:c}=ks(e,t,s);return r.type==="ArithDynamicElement"?{expr:{type:"ArithDynamicAssignment",operator:o,target:r.nameExpr,subscript:r.subscript,value:l},pos:c}:r.type==="ArithConcat"?{expr:{type:"ArithDynamicAssignment",operator:o,target:r,value:l},pos:c}:{expr:{type:"ArithAssignment",operator:o,variable:r.name,value:l},pos:c}}}if(t.slice(s,s+2)==="++"||t.slice(s,s+2)==="--"){let o=t.slice(s,s+2);return s+=2,{expr:{type:"ArithUnary",operator:o,operand:r,prefix:!1},pos:s}}return{expr:r,pos:s}}function dm(e,t,n,r=!1){let s=Be(t,n),i=nm(Ht,e,t,s);if(i)return i;let a=rm(t,s);if(a)return a;let o=sm(t,s);if(o)return o;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}=Ht(e,t,s);return s=Be(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}=Ht(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 h=t[s];if(u)if(/[0-9a-zA-Z@_]/.test(h))c+=h,s++;else break;else if(h==="#")u=!0,c+=h,s++;else if(c==="0"&&(h==="x"||h==="X")&&s+1<t.length&&/[0-9a-fA-F]/.test(t[s+1]))f=!0,c+=h,s++;else if(f&&/[0-9a-fA-F]/.test(h))c+=h,s++;else if(!f&&/[0-9]/.test(h))c+=h,s++;else break}if(s<t.length&&/[a-zA-Z_]/.test(t[s])){let h=c;for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)h+=t[s],s++;return{expr:{type:"ArithSyntaxError",errorToken:h,message:`${h}: value too great for base (error token is "${h}")`},pos:s}}if(t[s]==="."&&/[0-9]/.test(t[s+1]))throw new Re(`${c}.${t[s+1]}...: syntax error: invalid arithmetic operator`);if(t[s]==="["){let h=t.slice(s).trim();return{expr:{type:"ArithNumberSubscript",number:c,errorToken:h},pos:t.length}}return{expr:{type:"ArithNumber",value:Ns(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 p=t.slice(c,f),h=f+1;if(t[h]==="#"){let m=h+1;for(;m<t.length&&/[0-9a-zA-Z@_]/.test(t[m]);)m++;let d=t.slice(h+1,m);return{expr:{type:"ArithDynamicBase",baseExpr:p,value:d},pos:m}}if(/[0-9]/.test(t[h])||t[h]==="x"||t[h]==="X"){let m=h;if(t[h]==="x"||t[h]==="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(h,m);return{expr:{type:"ArithDynamicNumber",prefix:p,suffix:d},pos:m}}return s=h,{expr:{type:"ArithBracedExpansion",content:p},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 p=t[s];for(s++,u="";s<t.length&&t[s]!==p;)u+=t[s],s++;t[s]===p&&s++,s=Be(t,s),t[s]==="]"&&s++}let f;if(u===void 0){let{expr:p,pos:h}=Ht(e,t,s);f=p,s=h,t[s]==="]"&&s++}if(s=Be(t,s),t[s]==="["&&f)return{expr:{type:"ArithDoubleSubscript",array:c,index:f},pos:s};if(!r){for(let p of Gi)if(t.slice(s,s+p.length)===p&&t.slice(s,s+p.length+1)!=="=="){s+=p.length;let{expr:h,pos:m}=ks(e,t,s);return{expr:{type:"ArithAssignment",operator:p,variable:c,subscript:f,stringKey:u,value:h},pos:m}}}return{expr:{type:"ArithArrayElement",array:c,index:f,stringKey:u},pos:s}}if(s=Be(t,s),!r){for(let u of Gi)if(t.slice(s,s+u.length)===u&&t.slice(s,s+u.length+1)!=="=="){s+=u.length;let{expr:f,pos:p}=ks(e,t,s);return{expr:{type:"ArithAssignment",operator:u,variable:c,value:f},pos:p}}}return{expr:{type:"ArithVariable",name:c,hasDollarPrefix:l},pos:s}}if(t[s]==="#"){let c=s+1;for(;c<t.length&&t[c]!==`
|
|
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 dt=I(()=>{"use strict";ye();im()});function Bb(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 ym(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function _l(e,t,n,r,s){let i=1,a=n+1;for(;a<t.length&&i>0;)t[a]===r?i++:t[a]===s&&i--,i>0&&a++;return i===0?a:-1}function or(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 a=t.indexOf("'",r+1);if(a!==-1){r=a+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 wm(e,t,n){let r=n,s=!1;for(;r<t.length;){let i=t[r];if(i==="/"&&s||i==="}")break;if(i==="'"){let a=t.indexOf("'",r+1);if(a!==-1){r=a+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 bm(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 a=zb(t,r);a===-1?(s+=i,r++):(s+=t.slice(r,a+1),r=a+1)}else break}return{pattern:s,endIndex:r}}function zb(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]}]`,a=e.indexOf(i,n+2);if(a!==-1){n=a+2;continue}}n++}return-1}function xm(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 o=[],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)o.push(u),l+=2+c.length;else break}o.length>0?(r+=Bb(o),s=l):(r+="\\x",s+=2);break}case"u":{let o=t.slice(s+2,s+6),l=parseInt(o,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 o="",l=s+1;for(;l<t.length&&l<s+4&&/[0-7]/.test(t[l]);)o+=t[l],l++;let c=parseInt(o,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 Ll(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ae(e,n)}function gm(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 Em(e,t,n,r){let s=_l(e,t,n,"{","}");if(s===-1)return null;let i=t.slice(n+1,s),a=i.match(/^(-?\d+)\.\.(-?\d+)(?:\.\.(-?\d+))?$/);if(a)return{part:{type:"BraceExpansion",items:[{type:"Range",start:Number.parseInt(a[1],10),end:Number.parseInt(a[2],10),step:a[3]?Number.parseInt(a[3],10):void 0,startStr:a[1],endStr:a[2]}]},endIndex:s+1};let o=i.match(/^([a-zA-Z])\.\.([a-zA-Z])(?:\.\.(-?\d+))?$/);return o?{part:{type:"BraceExpansion",items:[{type:"Range",start:o[1],end:o[2],step:o[3]?Number.parseInt(o[3],10):void 0}]},endIndex:s+1}:i.includes(",")&&r?{part:{type:"BraceExpansion",items:gm(i).map(u=>({type:"Word",word:q.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:gm(i).map(u=>({type:"Word",word:q.word([q.literal(u)])}))},endIndex:s+1}:null}function Fl(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 a=i.startStr??String(i.start),o=i.endStr??String(i.end);i.step!==void 0?s.push(`${a}..${o}..${i.step}`):s.push(`${a}..${o}`)}else s.push(Fl(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 Am(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 Ml=I(()=>{"use strict";ar();dt();Fn()});function qi(e){let t=e.current(),n=t.type;if(n===E.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:em.has(r.type)}if(n===E.FD_VARIABLE){let r=e.peek(1);return tm.has(r.type)}return J0.has(n)}function Zi(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=Am(e,r.type);if(r.type===E.DLESS||r.type===E.DLESSDASH)return Hb(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 Hb(e,t,n,r){e.isWord()||e.error("Expected here-document delimiter");let s=e.advance(),i=s.value,a=s.quoted||!1;(i.startsWith("'")&&i.endsWith("'")||i.startsWith('"')&&i.endsWith('"'))&&(i=i.slice(1,-1));let o=q.redirection(r?"<<-":"<<",q.hereDoc(i,q.word([]),r,a),n);return e.addPendingHeredoc(o,i,r,a),o}function Cm(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(E.ASSIGNMENT_WORD)||qi(e);)e.checkIterationLimit(),e.check(E.ASSIGNMENT_WORD)?n.push(jb(e)):i.push(Zi(e));if(e.isWord())r=e.parseWord();else if(n.length>0&&(e.check(E.DBRACK_START)||e.check(E.DPAREN_START))){let o=e.advance();r=q.word([q.literal(o.value)])}for(;(!e.isStatementEnd()||e.check(E.RBRACE))&&!e.check(E.PIPE,E.PIPE_AMP);)if(e.checkIterationLimit(),qi(e))i.push(Zi(e));else if(e.check(E.RBRACE)){let o=e.advance();s.push(e.parseWordFromString(o.value,!1,!1))}else if(e.check(E.LBRACE)){let o=e.advance();s.push(e.parseWordFromString(o.value,!1,!1))}else if(e.check(E.DBRACK_END)){let o=e.advance();s.push(e.parseWordFromString(o.value,!1,!1))}else if(e.isWord())s.push(e.parseWord());else if(e.check(E.ASSIGNMENT_WORD)){let o=e.advance(),l=o.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 p=Ul(e);e.expect(E.RPAREN);let h=p.map(d=>Fl(e,d)),m=`${f}=(${h.join(" ")})`;s.push(e.parseWordFromString(m,!1,!1))}else s.push(e.parseWordFromString(l,o.quoted,o.singleQuoted))}else if(e.check(E.LPAREN))e.error("syntax error near unexpected token `('");else break;let a=q.simpleCommand(r,s,n,i);return a.line=t,a}function jb(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,a=s.length;if(n[a]==="["){let f=0,p=a+1;for(;a<n.length;a++)if(n[a]==="[")f++;else if(n[a]==="]"&&(f--,f===0))break;f!==0&&e.error(`Invalid assignment: ${n}`),i=n.slice(p,a),a++}let o=n[a]==="+";o&&a++,n[a]!=="="&&e.error(`Invalid assignment: ${n}`),a++;let l=n.slice(a);if(l==="("){let f=Ul(e);e.expect(E.RPAREN);let p=i!==void 0?`${s}[${i}]`:s;return q.assignment(p,null,o,f)}if(l===""&&e.check(E.LPAREN)){let f=e.current();if(t.end===f.start){e.advance();let p=Ul(e);e.expect(E.RPAREN);let h=i!==void 0?`${s}[${i}]`:s;return q.assignment(h,null,o,p)}}let c=l?e.parseWordFromString(l,t.quoted,t.singleQuoted,!0):null,u=i!==void 0?`${s}[${i}]`:s;return q.assignment(u,c,o,null)}function Ul(e){let t=[];for(e.skipNewlines();!e.check(E.RPAREN,E.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):Gb.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var Gb,Nm=I(()=>{"use strict";ar();Fn();ir();Ml();Gb=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 Wl(e,t){e.expect(E.IF);let n=[],r=e.parseCompoundList();e.expect(E.THEN);let s=e.parseCompoundList();if(s.length===0){let o=e.check(E.FI)?"fi":e.check(E.ELSE)?"else":e.check(E.ELIF)?"elif":"fi";e.error(`syntax error near unexpected token \`${o}'`)}for(n.push({condition:r,body:s});e.check(E.ELIF);){e.advance();let o=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:o,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 a=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.ifNode(n,i,a)}function Bl(e,t){let n=e.expect(E.FOR);if(e.check(E.DPAREN_START))return qb(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 a=e.parseCompoundList();e.expect(E.DONE);let o=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.forNode(s,i,a,o)}function qb(e,t,n){e.expect(E.DPAREN_START);let r=null,s=null,i=null,a=["","",""],o=0,l=0;for(;!e.check(E.DPAREN_END,E.EOF);){let f=e.advance();if(f.type===E.SEMICOLON&&l===0){if(o++,o>2)break}else f.value==="("&&l++,f.value===")"&&l--,a[o]+=f.value}e.expect(E.DPAREN_END),a[0].trim()&&(r=Ae(e,a[0].trim())),a[1].trim()&&(s=Ae(e,a[1].trim())),a[2].trim()&&(i=Ae(e,a[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 zl(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 Hl(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 jl(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(),a=Zb(e);if(a&&r.push(a),e.skipNewlines(),e.getPos()===i&&!a)break}e.expect(E.ESAC);let s=t?.skipRedirections?[]:e.parseOptionalRedirections();return q.caseNode(n,r,s)}function Zb(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 Gl(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 Vl(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 km=I(()=>{"use strict";ar();dt();Fn()});function vm(e){return e.isWord()||e.check(E.LBRACE)||e.check(E.RBRACE)||e.check(E.ASSIGNMENT_WORD)}function Im(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 Zl(e){return e.skipNewlines(),Yb(e)}function Yb(e){let t=$m(e);for(e.skipNewlines();e.check(E.OR_OR);){e.advance(),e.skipNewlines();let n=$m(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function $m(e){let t=ql(e);for(e.skipNewlines();e.check(E.AND_AND);){e.advance(),e.skipNewlines();let n=ql(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function ql(e){return e.skipNewlines(),e.check(E.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:ql(e)}):Jb(e)}function Jb(e){if(e.check(E.LPAREN)){e.advance();let t=Zl(e);return e.expect(E.RPAREN),{type:"CondGroup",expression:t}}if(vm(e)){let t=e.current(),n=t.value;if(Qb.includes(n)&&!t.quoted){if(e.advance(),e.check(E.DBRACK_END)&&e.error(`Expected operand after ${n}`),vm(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()&&Xb.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=ex(e):s==="=="||s==="!="?i=Im(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=Im(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function ex(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 a=e.current(),o=r>=0&&a.start>r;if(n===0&&o)break;if(n>0&&o){let l=s.slice(r,a.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 Qb,Xb,Om=I(()=>{"use strict";Fn();Qb=["-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"],Xb=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function nx(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 rx(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 sx(e,t,n,r=!1){let s=n+2,i=!1;t[s]==="!"&&(i=!0,s++);let a=!1;t[s]==="#"&&!/[}:#%/^,]/.test(t[s+1]||"}")&&(a=!0,s++);let o="",l=t[s];if(/[@*#?$!-]/.test(l)&&!/[a-zA-Z0-9_]/.test(t[s+1]||""))o=l,s++;else for(;s<t.length&&/[a-zA-Z0-9_]/.test(t[s]);)o+=t[s],s++;if(t[s]==="["){let u=_l(e,t,s,"[","]");if(o+=t.slice(s,u+1),s=u+1,t[s]==="["){let f=1,p=s;for(;p<t.length&&f>0;)t[p]==="{"?f++:t[p]==="}"&&f--,f>0&&p++;let h=t.slice(n+2,p);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:h}),endIndex:p+1}}}if(o===""&&!i&&!a&&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 p=t.slice(n+2,f);return{part:q.parameterExpansion("",{type:"BadSubstitution",text:p}),endIndex:f+1}}let c=null;if(i){let u=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(u)if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Kl(e,t,s,o,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):(c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},o="")}else c={type:"ArrayKeys",array:u[1],star:u[2]==="*"},o="";else if(t[s]==="*"||t[s]==="@"&&!/[QPaAEKkuUL]/.test(t[s+1]||"")){let f=t[s];s++,c={type:"VarNamePrefix",prefix:o,star:f==="*"},o=""}else if(s<t.length&&t[s]!=="}"&&/[:=\-+?#%/^,@]/.test(t[s])){let f=Kl(e,t,s,o,r);f.operation?(c={type:"Indirection",innerOp:f.operation},s=f.endIndex):c={type:"Indirection"}}else c={type:"Indirection"}}else if(a)if(t[s]===":")for(c={type:"LengthSliceError"};s<t.length&&t[s]!=="}";)s++;else t[s]!=="}"&&/[-+=?]/.test(t[s])?e.error(`\${#${o}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):t[s]==="/"?e.error(`\${#${o}${t.slice(s,t.indexOf("}",s))}}: bad substitution`):c={type:"Length"};if(!c&&s<t.length&&t[s]!=="}"){let u=Kl(e,t,s,o,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 p=t.slice(n,f+1);e.error(`\${${p.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(o,c),endIndex:s+1}}function Kl(e,t,n,r,s=!1){let i=n,a=t[i],o=t[i+1]||"";if(a===":"){let l=o;if("-=?+".includes(l)){i+=2;let w=or(e,t,i),y=t.slice(i,w),b=Mn(e,y,!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:w};if(l==="=")return{operation:{type:"AssignDefault",word:x,checkEmpty:!0},endIndex:w};if(l==="?")return{operation:{type:"ErrorIfUnset",word:x,checkEmpty:!0},endIndex:w};if(l==="+")return{operation:{type:"UseAlternative",word:x,checkEmpty:!0},endIndex:w}}i++;let c=or(e,t,i),u=t.slice(i,c),f=-1,p=0,h=0;for(let g=0;g<u.length;g++){let w=u[g];if(w==="("||w==="[")p++;else if(w===")"||w==="]")p--;else if(w==="?"&&p===0)h++;else if(w===":"&&p===0)if(h>0)h--;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:Ll(e,m),length:d!==null?Ll(e,d):null},endIndex:c}}if("-=?+".includes(a)){i++;let l=or(e,t,i),c=t.slice(i,l),u=Mn(e,c,!1,!1,!0,!1,s,!1,!1,!0),f=q.word(u.length>0?u:[q.literal("")]);if(a==="-")return{operation:{type:"DefaultValue",word:f,checkEmpty:!1},endIndex:l};if(a==="=")return{operation:{type:"AssignDefault",word:f,checkEmpty:!1},endIndex:l};if(a==="?")return{operation:{type:"ErrorIfUnset",word:c?f:null,checkEmpty:!1},endIndex:l};if(a==="+")return{operation:{type:"UseAlternative",word:f,checkEmpty:!1},endIndex:l}}if(a==="#"||a==="%"){let l=o===a,c=a==="#"?"prefix":"suffix";i+=l?2:1;let u=or(e,t,i),f=t.slice(i,u),p=Mn(e,f,!1,!1,!1);return{operation:{type:"PatternRemoval",pattern:q.word(p.length>0?p:[q.literal("")]),side:c,greedy:l},endIndex:u}}if(a==="/"){let l=o==="/";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=wm(e,t,i);let f=t.slice(i,u),p=Mn(e,f,!1,!1,!1),h=q.word(p.length>0?p:[q.literal("")]),m=null,d=u;if(t[u]==="/"){let g=u+1,w=or(e,t,g),y=t.slice(g,w),b=Mn(e,y,!1,!1,!1);m=q.word(b.length>0?b:[q.literal("")]),d=w}return{operation:{type:"PatternReplacement",pattern:h,replacement:m,all:l,anchor:c},endIndex:d}}if(a==="^"||a===","){let l=o===a,c=a==="^"?"upper":"lower";i+=l?2:1;let u=or(e,t,i),f=t.slice(i,u),p=f?q.word([q.literal(f)]):null;return{operation:{type:"CaseModification",direction:c,all:l,pattern:p},endIndex:u}}return a==="@"&&/[QPaAEKkuUL]/.test(o)?{operation:{type:"Transform",operator:o},endIndex:i+2}:{operation:null,endIndex:i}}function Ql(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 a=1,o=s+1;for(;o<t.length&&a>0;)t[o]==="["?a++:t[o]==="]"&&a--,a>0&&o++;if(a===0){let l=t.slice(s+1,o),c=Ae(e,l);return{part:q.arithmeticExpansion(c),endIndex:o+1}}}return i==="("?e.parseCommandSubstitution(t,n):i==="{"?sx(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?rx(e,t,n):{part:q.literal("$"),endIndex:s}}function Rm(e,t){let n=[],r=0,s="",i=()=>{s&&(n.push(q.literal(s)),s="")};for(;r<t.length;){let a=t[r];if(a==="\\"&&r+1<t.length){let o=t[r+1];if(o==="$"||o==="`"||o==='"'||o==="\\"){s+=o,r+=2;continue}s+=a,r++;continue}if(a==="$"){i();let{part:o,endIndex:l}=Ql(e,t,r,!0);o&&n.push(o),r=l;continue}if(a==="`"){i();let{part:o,endIndex:l}=e.parseBacktickSubstitution(t,r,!0);n.push(o),r=l;continue}s+=a,r++}return i(),n}function ix(e,t,n){let r=[],s=n,i="",a=()=>{i&&(r.push(q.literal(i)),i="")};for(;s<t.length&&t[s]!=='"';){let o=t[s];if(o==="\\"&&s+1<t.length){let l=t[s+1];if('"\\$`\n'.includes(l)){i+=l,s+=2;continue}i+=o,s++;continue}if(o==="$"){a();let{part:l,endIndex:c}=Ql(e,t,s,!0);l&&r.push(l),s=c;continue}if(o==="`"){a();let{part:l,endIndex:c}=e.parseBacktickSubstitution(t,s,!0);r.push(l),s=c;continue}i+=o,s++}return a(),{part:q.doubleQuoted(r),endIndex:s}}function Mn(e,t,n=!1,r=!1,s=!1,i=!1,a=!1,o=!1,l=!1,c=!1){if(r)return[q.singleQuoted(t)];if(n){let m=Rm(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=Rm(e,m);return[q.doubleQuoted(g)]}}let u=[],f=0,p="",h=()=>{p&&(u.push(q.literal(p)),p="")};for(;f<t.length;){let m=t[f];if(m==="\\"&&f+1<t.length){let d=t[f+1];if(l){h(),u.push(q.escaped(d)),f+=2;continue}let g=i?d==="$"||d==="`"||d===`
|
|
763
763
|
`:d==="$"||d==="`"||d==='"'||d==="'"||d===`
|
|
764
|
-
`||c&&d==="}",w=a?"*?[]\\".includes(d):"*?[]\\(){}.^+".includes(d);g?p+=d:w?(h(),u.push(q.escaped(d))):p+=`\\${d}`,f+=2;continue}if(m==="'"&&!a&&!i){h();let d=t.indexOf("'",f+1);if(d===-1){p+=t.slice(f);break}u.push(q.singleQuoted(t.slice(f+1,d))),f=d+1;continue}if(m==='"'&&!i){h();let{part:d,endIndex:g}=
|
|
764
|
+
`||c&&d==="}",w=a?"*?[]\\".includes(d):"*?[]\\(){}.^+".includes(d);g?p+=d:w?(h(),u.push(q.escaped(d))):p+=`\\${d}`,f+=2;continue}if(m==="'"&&!a&&!i){h();let d=t.indexOf("'",f+1);if(d===-1){p+=t.slice(f);break}u.push(q.singleQuoted(t.slice(f+1,d))),f=d+1;continue}if(m==='"'&&!i){h();let{part:d,endIndex:g}=ix(e,t,f+1);u.push(d),f=g+1;continue}if(m==="$"&&t[f+1]==="'"){h();let{part:d,endIndex:g}=xm(e,t,f+2);u.push(d),f=g;continue}if(m==="$"){h();let{part:d,endIndex:g}=Ql(e,t,f);d&&u.push(d),f=g;continue}if(m==="`"){h();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 w=ym(e,t,f),y=t[w];if(y===void 0||y==="/"||y===":"){h();let b=t.slice(f+1,w)||null;u.push({type:"TildeExpansion",user:b}),f=w;continue}}}if("@*+?!".includes(m)&&f+1<t.length&&t[f+1]==="("){let d=nx(t,f+1);if(d!==-1){h();let g=t.slice(f,d+1);u.push({type:"Glob",pattern:g}),f=d+1;continue}}if(m==="*"||m==="?"||m==="["){h();let{pattern:d,endIndex:g}=bm(e,t,f);u.push({type:"Glob",pattern:d}),f=g;continue}if(m==="{"&&!s&&!o){let d=Em(e,t,f,Mn);if(d){h(),u.push(d.part),f=d.endIndex;continue}}p+=m,f++}return h(),u}var Tm=I(()=>{"use strict";ar();dt();ir();Ml()});function Pm(e,t){let n=e.length,r=t+3,s=2,i=!1,a=!1;for(;r<n&&s>0;){let o=e[r];if(i){o==="'"&&(i=!1),r++;continue}if(a){if(o==="\\"){r+=2;continue}o==='"'&&(a=!1),r++;continue}if(o==="'"){i=!0,r++;continue}if(o==='"'){a=!0,r++;continue}if(o==="\\"){r+=2;continue}if(o==="("){s++,r++;continue}if(o===")"){if(s--,s===1){let l=r+1;return!(l<n&&e[l]===")")}if(s===0)return!1;r++;continue}if(s===1&&(o==="|"&&r+1<n&&e[r+1]==="|"||o==="&"&&r+1<n&&e[r+1]==="&"||o==="|"&&r+1<n&&e[r+1]!=="|"))return!0;r++}return!1}function Dm(e,t,n,r){let s=t+2,i=1,a=s,o=!1,l=!1,c=0,u=!1,f="";for(;a<e.length&&i>0;){let d=e[a];o?d==="'"&&(o=!1):l?d==="\\"&&a+1<e.length?a++:d==='"'&&(l=!1):d==="'"?(o=!0,f=""):d==='"'?(l=!0,f=""):d==="\\"&&a+1<e.length?(a++,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==="("?a>0&&e[a-1]==="$"?i++:u||i++:d===")"?u?u=!1:i--:d===";"&&c>0&&a+1<e.length&&e[a+1]===";"&&(u=!0)),i>0&&a++}i>0&&r("unexpected EOF while looking for matching `)'");let p=e.slice(s,a),m=n().parse(p);return{part:q.commandSubstitution(m,!1),endIndex:a+1}}function _m(e,t,n,r,s){let a=t+1,o="";for(;a<e.length&&e[a]!=="`";)if(e[a]==="\\"){let u=e[a+1];u==="$"||u==="`"||u==="\\"||u===`
|
|
765
765
|
`||n&&u==='"'?(u!==`
|
|
766
|
-
`&&(o+=u),a+=2):(o+=e[a],a++)}else o+=e[a],a++;a>=e.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(o);return{part:q.commandSubstitution(c,!0),endIndex:a+1}}var Lm=I(()=>{"use strict";ar()});function rn(e){return new ce().parse(e)}var ce,Xe=I(()=>{"use strict";ar();mt();Nm();km();Om();Tm();Fn();Lm();ir();ir();ce=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Y0)throw new lt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Tl)throw new lt(`Maximum parser nesting depth exceeded (${Tl})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(t){if(t.length>Ol)throw new lt(`Input too large: ${t.length} bytes exceeds limit of ${Ol}`,1,1);this._input=t;let n=new ji(t);if(this.tokens=n.tokenize(),this.tokens.length>Rl)throw new lt(`Too many tokens: ${this.tokens.length} exceeds limit of ${Rl}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(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 a=this.tokens[this.pos]?.type;return a===t||n!==void 0&&a===n||r!==void 0&&a===r||s!==void 0&&a===s?!0:i.length>0?i.includes(a):!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,a=this.parseStatement();a&&t.push(a),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 a=this.pos>0?this.tokens[this.pos-1].end:t,o=this._input.slice(t,a);return q.statement(n,r,s,void 0,o)}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=[],a=[],o=this.parseCommand();for(i.push(o);this.check(E.PIPE,E.PIPE_AMP);){let l=this.advance();this.skipNewlines(),a.push(l.type===E.PIPE_AMP);let c=this.parseCommand();i.push(c)}return q.pipeline(i,s,t,n,a.length>0?a:void 0)}parseCommand(){return this.check(E.IF)?Wl(this):this.check(E.FOR)?Bl(this):this.check(E.WHILE)?zl(this):this.check(E.UNTIL)?Hl(this):this.check(E.CASE)?jl(this):this.check(E.LPAREN)?Gl(this):this.check(E.LBRACE)?Vl(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():Cm(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,a=!1,o=!1){let l=Mn(this,t,n,r,s,i,!1,a,o);return q.word(l)}parseCommandSubstitution(t,n){return Dm(t,n,()=>new e,r=>this.error(r))}parseBacktickSubstitution(t,n,r=!1){return _m(t,n,r,()=>new e,s=>this.error(s))}isDollarDparenSubshell(t,n){return Pm(t,n)}parseArithmeticExpansion(t,n){let r=n+3,s=1,i=0,a=r;for(;a<t.length-1&&s>0;)t[a]==="$"&&t[a+1]==="("?t[a+2]==="("?(s++,a+=3):(i++,a+=2):t[a]==="("&&t[a+1]==="("?(s++,a+=2):t[a]===")"&&t[a+1]===")"?i>0?(i--,a++):(s--,s>0&&(a+=2)):t[a]==="("?(i++,a++):(t[a]===")"&&i>0&&i--,a++);let o=t.slice(r,a),l=this.parseArithmeticExpression(o);return{part:q.arithmeticExpansion(l),endIndex:a+2}}parseArithmeticCommand(){let t=this.expect(E.DPAREN_START),n="",r=1,s=0,i=!1,a=!1;for(;r>0&&!this.check(E.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(E.RPAREN)){r--,a=!0,this.advance();continue}if(this.check(E.DPAREN_END)){r--,a=!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--,a=!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()}}a||this.expect(E.DPAREN_END);let o=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return q.arithmeticCommand(o,l,t.line)}parseConditionalCommand(){let t=this.expect(E.DBRACK_START),n=Zl(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 Vl(this,{skipRedirections:n});if(this.check(E.LPAREN))return Gl(this,{skipRedirections:n});if(this.check(E.IF))return Wl(this,{skipRedirections:n});if(this.check(E.FOR))return Bl(this,{skipRedirections:n});if(this.check(E.WHILE))return zl(this,{skipRedirections:n});if(this.check(E.UNTIL))return Hl(this,{skipRedirections:n});if(this.check(E.CASE))return jl(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let t=this.enterDepth(),n=[];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 r=this.pos,s=this.parseStatement();if(s&&n.push(s),this.skipSeparators(),this.pos===r&&!s)break}return t(),n}parseOptionalRedirections(){let t=[];for(;qi(this);){this.checkIterationLimit();let n=this.pos;if(t.push(Zi(this)),this.pos===n)break}return t}parseArithmeticExpression(t){return Ae(this,t)}}});function Yl(e){return cx.get(e)??""}function zm(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 Hm(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 a=s;for(;a<e.length;){if(e[a]==="\\"&&a+1<e.length){a+=2;continue}if(e[a]==="["&&a+1<e.length&&e[a+1]===":"){let l=e.indexOf(":]",a+2);if(l!==-1){a=l+2;continue}}if(e[a]==="]")break;a++}let o=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=Yl(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===o,c=s+1===a;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 Jl(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 ec(e){let t=[],n="",r=0,s=!1,i=0;for(;i<e.length;){let a=e[i];if(a==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(a==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=a,i++;continue}if(a==="\\"){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a==="("?(r++,n+=a):a===")"?(r--,n+=a):a==="|"&&r===0?(t.push(n),n=""):n+=a,i++}return t.push(n),t}var cx,jm=I(()=>{"use strict";Me();cx=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 Un,Ki=I(()=>{"use strict";ye();Me();mr();jm();Un=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=zm(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new te(`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 Hm(n).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,n){let r=t.map((a,o)=>(n?.[o]??!1)||!this.isGlobPattern(a)?null:this.expand(a)),s=await Promise.all(r.map(a=>a||Promise.resolve(null))),i=[];for(let a=0;a<t.length;a++){let o=s[a];o===null?i.push(t[a]):o.length>0?i.push(...o):i.push(t[a])}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,a;if(s===0)n?(i="/",a="/"):(i=this.cwd,a="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,a=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),a=c.join("/"))}let o=r.slice(s);return(await this.expandSegments(i,a,o)).sort()}async expandSegments(t,n,r){if(this.checkOpsLimit(),r.length===0)return[n];let[s,...i]=r,a=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let o=await this.fs.readdirWithFileTypes(t),l=[],c=[...o],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let p=o.some(m=>m.name==="."),h=o.some(m=>m.name==="..");p||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),h||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let p of c)if(!(p.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p.name,s)){let h=t==="/"?`/${p.name}`:`${t}/${p.name}`,m;n===""?m=p.name:n==="/"?m=`/${p.name}`:m=`${n}/${p.name}`,i.length===0?l.push(Promise.resolve([m])):p.isDirectory&&l.push(this.expandSegments(h,m,i))}let f=await Promise.all(l);for(let p of f)a.push(...p)}else{this.checkOpsLimit();let o=await this.fs.readdir(t),l=[],c=[...o],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(o.includes(".")||c.push("."),o.includes("..")||c.push(".."));for(let p of c)if(!(p.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p,s)){let h=t==="/"?`/${p}`:`${t}/${p}`,m;n===""?m=p:n==="/"?m=`/${p}`:m=`${n}/${p}`,i.length===0?l.push(Promise.resolve([m])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory)return this.expandSegments(h,m,i)}catch(d){if(d instanceof te)throw d}return[]})())}let f=await Promise.all(l);for(let p of f)a.push(...p)}}catch(o){if(o instanceof te)throw o}return a}async expandRecursive(t){let n=[],r=t.indexOf("**"),s=t.slice(0,r).replace(/\/$/,"")||".",a=t.slice(r+2).replace(/^\//,"");return a.includes("**")&&this.isGlobstarValid(a)?(await this.walkDirectoryMultiGlobstar(s,a,n),[...new Set(n)].sort()):(await this.walkDirectory(s,a,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 a=[];for(let c of i){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&a.push(u)}let o=t==="."?n:`${t}/${n}`,l=await this.expandRecursive(o);r.push(...l);for(let c=0;c<a.length;c+=100){let u=a.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{this.checkOpsLimit();let a=await this.fs.readdir(s),o=[];for(let u of a){let f=t==="."?u:`${t}/${u}`,p=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(p)).isDirectory&&o.push(f)}catch(h){if(h instanceof te)throw h}}let l=t==="."?n:`${t}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<o.length;u+=100){let f=o.slice(u,u+100);await Promise.all(f.map(p=>this.walkDirectoryMultiGlobstar(p,n,r)))}}}catch(i){if(i instanceof te)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),a=[],o=[];for(let l of i){let c=t==="."?l.name:`${t}/${l.name}`;l.isDirectory?o.push(c):n&&this.matchPattern(l.name,n)&&a.push(c)}r.push(...a);for(let l=0;l<o.length;l+=100){let c=o.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),a=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let p=t==="."?f:`${t}/${f}`,h=this.fs.resolvePath(this.cwd,p);try{this.checkOpsLimit();let m=await this.fs.stat(h);return{name:f,path:p,isDirectory:m.isDirectory}}catch(m){if(m instanceof te)throw m;return null}}));a.push(...u.filter(f=>f!==null))}for(let l of a)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let o=a.filter(l=>l.isDirectory);for(let l=0;l<o.length;l+=100){let c=o.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch(i){if(i instanceof te)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 a=Jl(t,s+1);if(a!==-1){let o=t.slice(s+2,a),l=ec(o),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(a<t.length-1){let p=l.map(m=>this.computePatternLength(m));if(p.every(m=>m!==null)&&p.every(m=>m===p[0])&&p[0]!==null){let m=p[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=a;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let a=s+1,o="[";a<t.length&&(t[a]==="^"||t[a]==="!")&&(o+="^",a++),a<t.length&&t[a]==="]"&&(o+="\\]",a++);let l=a;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=a;for(;a<t.length&&t[a]!=="]";){if(t[a]==="["&&a+1<t.length&&t[a+1]===":"){let u=t.indexOf(":]",a+2);if(u!==-1){let f=t.slice(a+2,u),p=Yl(f);o+=p,a=u+2;continue}}if(t[a]==="\\"&&a+1<t.length){o+=`\\${t[a+1]}`,a+=2;continue}if(t[a]==="-"){let u=a===c,f=a+1===l;u||f?o+="\\-":o+="-"}else o+=t[a];a++}o+="]",n+=o,s=a}else if(i==="\\"&&s+1<t.length){let a=t[s+1];/[.+^${}()|\\*?[\]]/.test(a)?n+=`\\${a}`:n+=a,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 a=Jl(t,r+1);if(a!==-1){if(i==="@"){let o=t.slice(r+2,a),c=ec(o).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=a+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let a=t.indexOf("]",r+1);if(a!==-1){n+=1,r=a+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function tc(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 ux(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 Gm(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 vs(e){let t=!1,n=!1,r=!1,s=!1,i=!1,a=!1,o=!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")&&(a=!0),c.operation?.type==="Indirection"&&(o=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),ux(l)&&(t=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(a=!0),l.operation?.type==="Indirection"&&(o=!0)),l.type==="Glob"&&tc(l.pattern)&&(i=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:a,hasIndirection:o}}var Qi=I(()=>{"use strict"});function Ye(e,t){let n=`${t}_`,r=[];for(let s of e.state.env.keys())if(s.startsWith(n)){let i=s.slice(n.length),a=Number.parseInt(i,10);!Number.isNaN(a)&&String(a)===i&&r.push(a)}return r.sort((s,i)=>s-i)}function wn(e,t){let n=`${t}_`;for(let r of e.state.env.keys())r.startsWith(n)&&e.state.env.delete(r)}function sn(e,t){let n=`${t}_`,r=`${t}__length`,s=[];for(let i of e.state.env.keys())if(i!==r&&i.startsWith(n)){let a=i.slice(n.length);if(a.startsWith("_length"))continue;s.push(a)}return s.sort()}function Xi(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function nc(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 p=e.parts[2];if(p.type!=="Literal"||!p.value.startsWith("=")&&!p.value.startsWith("+="))return null;r=t.pattern.slice(1),s=p,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 p of n.parts)(p.type==="Literal"||p.type==="Escaped")&&(r+=p.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=Xi(r);let a;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?a=s.value.slice(1):a=s.value;let o=a.startsWith("+=");if(!o&&!a.startsWith("="))return null;let l=[],c=o?2:1,u=a.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<e.parts.length;f++){let p=e.parts[f];p.type==="BraceExpansion"?l.push({type:"Literal",value:fx(p)}):l.push(p)}return{key:r,valueParts:l,append:o}}function fx(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 Br(n.word)}).join(",")}}`}function Br(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}`:""}`:Br(r.word)).join(","),t+="}";break;case"TildeExpansion":t+="~",n.user&&(t+=n.user);break}return t}var Xt=I(()=>{"use strict"});function rt(e){return e.get("IFS")??`
|
|
766
|
+
`&&(o+=u),a+=2):(o+=e[a],a++)}else o+=e[a],a++;a>=e.length&&s("unexpected EOF while looking for matching ``'");let c=r().parse(o);return{part:q.commandSubstitution(c,!0),endIndex:a+1}}var Lm=I(()=>{"use strict";ar()});function rn(e){return new ce().parse(e)}var ce,Xe=I(()=>{"use strict";ar();dt();Nm();km();Om();Tm();Fn();Lm();ir();ir();ce=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>Y0)throw new lt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Tl)throw new lt(`Maximum parser nesting depth exceeded (${Tl})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(t){if(t.length>Ol)throw new lt(`Input too large: ${t.length} bytes exceeds limit of ${Ol}`,1,1);this._input=t;let n=new ji(t);if(this.tokens=n.tokenize(),this.tokens.length>Rl)throw new lt(`Too many tokens: ${this.tokens.length} exceeds limit of ${Rl}`,1,1);return this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}parseTokens(t){return this.tokens=t,this.pos=0,this.pendingHeredocs=[],this.parseIterations=0,this.parseDepth=0,this.parseScript()}current(){return this.tokens[this.pos]||this.tokens[this.tokens.length-1]}peek(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 a=this.tokens[this.pos]?.type;return a===t||n!==void 0&&a===n||r!==void 0&&a===r||s!==void 0&&a===s?!0:i.length>0?i.includes(a):!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,a=this.parseStatement();a&&t.push(a),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 a=this.pos>0?this.tokens[this.pos-1].end:t,o=this._input.slice(t,a);return q.statement(n,r,s,void 0,o)}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=[],a=[],o=this.parseCommand();for(i.push(o);this.check(E.PIPE,E.PIPE_AMP);){let l=this.advance();this.skipNewlines(),a.push(l.type===E.PIPE_AMP);let c=this.parseCommand();i.push(c)}return q.pipeline(i,s,t,n,a.length>0?a:void 0)}parseCommand(){return this.check(E.IF)?Wl(this):this.check(E.FOR)?Bl(this):this.check(E.WHILE)?zl(this):this.check(E.UNTIL)?Hl(this):this.check(E.CASE)?jl(this):this.check(E.LPAREN)?Gl(this):this.check(E.LBRACE)?Vl(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():Cm(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,a=!1,o=!1){let l=Mn(this,t,n,r,s,i,!1,a,o);return q.word(l)}parseCommandSubstitution(t,n){return Dm(t,n,()=>new e,r=>this.error(r))}parseBacktickSubstitution(t,n,r=!1){return _m(t,n,r,()=>new e,s=>this.error(s))}isDollarDparenSubshell(t,n){return Pm(t,n)}parseArithmeticExpansion(t,n){let r=n+3,s=1,i=0,a=r;for(;a<t.length-1&&s>0;)t[a]==="$"&&t[a+1]==="("?t[a+2]==="("?(s++,a+=3):(i++,a+=2):t[a]==="("&&t[a+1]==="("?(s++,a+=2):t[a]===")"&&t[a+1]===")"?i>0?(i--,a++):(s--,s>0&&(a+=2)):t[a]==="("?(i++,a++):(t[a]===")"&&i>0&&i--,a++);let o=t.slice(r,a),l=this.parseArithmeticExpression(o);return{part:q.arithmeticExpansion(l),endIndex:a+2}}parseArithmeticCommand(){let t=this.expect(E.DPAREN_START),n="",r=1,s=0,i=!1,a=!1;for(;r>0&&!this.check(E.EOF);){if(i){if(i=!1,s>0){s--,n+=")";continue}if(this.check(E.RPAREN)){r--,a=!0,this.advance();continue}if(this.check(E.DPAREN_END)){r--,a=!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--,a=!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()}}a||this.expect(E.DPAREN_END);let o=this.parseArithmeticExpression(n.trim()),l=this.parseOptionalRedirections();return q.arithmeticCommand(o,l,t.line)}parseConditionalCommand(){let t=this.expect(E.DBRACK_START),n=Zl(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 Vl(this,{skipRedirections:n});if(this.check(E.LPAREN))return Gl(this,{skipRedirections:n});if(this.check(E.IF))return Wl(this,{skipRedirections:n});if(this.check(E.FOR))return Bl(this,{skipRedirections:n});if(this.check(E.WHILE))return zl(this,{skipRedirections:n});if(this.check(E.UNTIL))return Hl(this,{skipRedirections:n});if(this.check(E.CASE))return jl(this,{skipRedirections:n});this.error("Expected compound command for function body")}parseCompoundList(){let t=this.enterDepth(),n=[];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 r=this.pos,s=this.parseStatement();if(s&&n.push(s),this.skipSeparators(),this.pos===r&&!s)break}return t(),n}parseOptionalRedirections(){let t=[];for(;qi(this);){this.checkIterationLimit();let n=this.pos;if(t.push(Zi(this)),this.pos===n)break}return t}parseArithmeticExpression(t){return Ae(this,t)}}});function Yl(e){return lx.get(e)??""}function zm(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 Hm(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 a=s;for(;a<e.length;){if(e[a]==="\\"&&a+1<e.length){a+=2;continue}if(e[a]==="["&&a+1<e.length&&e[a+1]===":"){let l=e.indexOf(":]",a+2);if(l!==-1){a=l+2;continue}}if(e[a]==="]")break;a++}let o=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=Yl(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===o,c=s+1===a;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 Jl(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 ec(e){let t=[],n="",r=0,s=!1,i=0;for(;i<e.length;){let a=e[i];if(a==="'"&&!s){s=!0,n+="\0QUOTE_START\0",i++;continue}if(a==="'"&&s){s=!1,n+="\0QUOTE_END\0",i++;continue}if(s){n+=a,i++;continue}if(a==="\\"){n+=a,i+1<e.length?(n+=e[i+1],i+=2):i++;continue}a==="("?(r++,n+=a):a===")"?(r--,n+=a):a==="|"&&r===0?(t.push(n),n=""):n+=a,i++}return t.push(n),t}var lx,jm=I(()=>{"use strict";Me();lx=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 Un,Ki=I(()=>{"use strict";ye();Me();mr();jm();Un=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=zm(i))}checkOpsLimit(){if(++this.ops.count>this.maxOps)throw new te(`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 Hm(n).test(t)}isGlobPattern(t){return!!(t.includes("*")||t.includes("?")||/\[.*\]/.test(t)||this.extglob&&/[@*+?!]\(/.test(t))}async expandArgs(t,n){let r=t.map((a,o)=>(n?.[o]??!1)||!this.isGlobPattern(a)?null:this.expand(a)),s=await Promise.all(r.map(a=>a||Promise.resolve(null))),i=[];for(let a=0;a<t.length;a++){let o=s[a];o===null?i.push(t[a]):o.length>0?i.push(...o):i.push(t[a])}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,a;if(s===0)n?(i="/",a="/"):(i=this.cwd,a="");else{let c=r.slice(0,s);n?(i=`/${c.join("/")}`,a=`/${c.join("/")}`):(i=this.fs.resolvePath(this.cwd,c.join("/")),a=c.join("/"))}let o=r.slice(s);return(await this.expandSegments(i,a,o)).sort()}async expandSegments(t,n,r){if(this.checkOpsLimit(),r.length===0)return[n];let[s,...i]=r,a=[];try{if(this.fs.readdirWithFileTypes){this.checkOpsLimit();let o=await this.fs.readdirWithFileTypes(t),l=[],c=[...o],u=this.dotglob||this.hasGlobignore;if(s.startsWith(".")||this.dotglob){let p=o.some(m=>m.name==="."),h=o.some(m=>m.name==="..");p||c.push({name:".",isFile:!1,isDirectory:!0,isSymbolicLink:!1}),h||c.push({name:"..",isFile:!1,isDirectory:!0,isSymbolicLink:!1})}for(let p of c)if(!(p.name.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p.name,s)){let h=t==="/"?`/${p.name}`:`${t}/${p.name}`,m;n===""?m=p.name:n==="/"?m=`/${p.name}`:m=`${n}/${p.name}`,i.length===0?l.push(Promise.resolve([m])):p.isDirectory&&l.push(this.expandSegments(h,m,i))}let f=await Promise.all(l);for(let p of f)a.push(...p)}else{this.checkOpsLimit();let o=await this.fs.readdir(t),l=[],c=[...o],u=this.dotglob||this.hasGlobignore;(s.startsWith(".")||this.dotglob)&&(o.includes(".")||c.push("."),o.includes("..")||c.push(".."));for(let p of c)if(!(p.startsWith(".")&&!s.startsWith(".")&&!u)&&this.matchPattern(p,s)){let h=t==="/"?`/${p}`:`${t}/${p}`,m;n===""?m=p:n==="/"?m=`/${p}`:m=`${n}/${p}`,i.length===0?l.push(Promise.resolve([m])):l.push((async()=>{try{if(this.checkOpsLimit(),(await this.fs.stat(h)).isDirectory)return this.expandSegments(h,m,i)}catch(d){if(d instanceof te)throw d}return[]})())}let f=await Promise.all(l);for(let p of f)a.push(...p)}}catch(o){if(o instanceof te)throw o}return a}async expandRecursive(t){let n=[],r=t.indexOf("**"),s=t.slice(0,r).replace(/\/$/,"")||".",a=t.slice(r+2).replace(/^\//,"");return a.includes("**")&&this.isGlobstarValid(a)?(await this.walkDirectoryMultiGlobstar(s,a,n),[...new Set(n)].sort()):(await this.walkDirectory(s,a,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 a=[];for(let c of i){let u=t==="."?c.name:`${t}/${c.name}`;c.isDirectory&&a.push(u)}let o=t==="."?n:`${t}/${n}`,l=await this.expandRecursive(o);r.push(...l);for(let c=0;c<a.length;c+=100){let u=a.slice(c,c+100);await Promise.all(u.map(f=>this.walkDirectoryMultiGlobstar(f,n,r)))}}else{this.checkOpsLimit();let a=await this.fs.readdir(s),o=[];for(let u of a){let f=t==="."?u:`${t}/${u}`,p=this.fs.resolvePath(this.cwd,f);try{this.checkOpsLimit(),(await this.fs.stat(p)).isDirectory&&o.push(f)}catch(h){if(h instanceof te)throw h}}let l=t==="."?n:`${t}/${n}`,c=await this.expandRecursive(l);r.push(...c);for(let u=0;u<o.length;u+=100){let f=o.slice(u,u+100);await Promise.all(f.map(p=>this.walkDirectoryMultiGlobstar(p,n,r)))}}}catch(i){if(i instanceof te)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),a=[],o=[];for(let l of i){let c=t==="."?l.name:`${t}/${l.name}`;l.isDirectory?o.push(c):n&&this.matchPattern(l.name,n)&&a.push(c)}r.push(...a);for(let l=0;l<o.length;l+=100){let c=o.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),a=[];for(let l=0;l<i.length;l+=100){let c=i.slice(l,l+100),u=await Promise.all(c.map(async f=>{let p=t==="."?f:`${t}/${f}`,h=this.fs.resolvePath(this.cwd,p);try{this.checkOpsLimit();let m=await this.fs.stat(h);return{name:f,path:p,isDirectory:m.isDirectory}}catch(m){if(m instanceof te)throw m;return null}}));a.push(...u.filter(f=>f!==null))}for(let l of a)!l.isDirectory&&n&&this.matchPattern(l.name,n)&&r.push(l.path);let o=a.filter(l=>l.isDirectory);for(let l=0;l<o.length;l+=100){let c=o.slice(l,l+100);await Promise.all(c.map(u=>this.walkDirectory(u.path,n,r)))}}}catch(i){if(i instanceof te)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 a=Jl(t,s+1);if(a!==-1){let o=t.slice(s+2,a),l=ec(o),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(a<t.length-1){let p=l.map(m=>this.computePatternLength(m));if(p.every(m=>m!==null)&&p.every(m=>m===p[0])&&p[0]!==null){let m=p[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=a;continue}}if(i==="*")n+=".*";else if(i==="?")n+=".";else if(i==="["){let a=s+1,o="[";a<t.length&&(t[a]==="^"||t[a]==="!")&&(o+="^",a++),a<t.length&&t[a]==="]"&&(o+="\\]",a++);let l=a;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=a;for(;a<t.length&&t[a]!=="]";){if(t[a]==="["&&a+1<t.length&&t[a+1]===":"){let u=t.indexOf(":]",a+2);if(u!==-1){let f=t.slice(a+2,u),p=Yl(f);o+=p,a=u+2;continue}}if(t[a]==="\\"&&a+1<t.length){o+=`\\${t[a+1]}`,a+=2;continue}if(t[a]==="-"){let u=a===c,f=a+1===l;u||f?o+="\\-":o+="-"}else o+=t[a];a++}o+="]",n+=o,s=a}else if(i==="\\"&&s+1<t.length){let a=t[s+1];/[.+^${}()|\\*?[\]]/.test(a)?n+=`\\${a}`:n+=a,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 a=Jl(t,r+1);if(a!==-1){if(i==="@"){let o=t.slice(r+2,a),c=ec(o).map(u=>this.computePatternLength(u));if(c.every(u=>u!==null)&&c.every(u=>u===c[0])){n+=c[0],r=a+1;continue}return null}return null}}if(i==="*")return null;if(i==="?"){n+=1,r++;continue}if(i==="["){let a=t.indexOf("]",r+1);if(a!==-1){n+=1,r=a+1;continue}n+=1,r++;continue}if(i==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}}});function tc(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 cx(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 Gm(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 vs(e){let t=!1,n=!1,r=!1,s=!1,i=!1,a=!1,o=!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")&&(a=!0),c.operation?.type==="Indirection"&&(o=!0));l.type==="CommandSubstitution"&&(n=!0),l.type==="ParameterExpansion"&&(i=!0,(l.parameter==="@"||l.parameter==="*")&&(r=!0),cx(l)&&(t=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(a=!0),l.operation?.type==="Indirection"&&(o=!0)),l.type==="Glob"&&tc(l.pattern)&&(i=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:a,hasIndirection:o}}var Qi=I(()=>{"use strict"});function Ye(e,t){let n=`${t}_`,r=[];for(let s of e.state.env.keys())if(s.startsWith(n)){let i=s.slice(n.length),a=Number.parseInt(i,10);!Number.isNaN(a)&&String(a)===i&&r.push(a)}return r.sort((s,i)=>s-i)}function wn(e,t){let n=`${t}_`;for(let r of e.state.env.keys())r.startsWith(n)&&e.state.env.delete(r)}function sn(e,t){let n=`${t}_`,r=`${t}__length`,s=[];for(let i of e.state.env.keys())if(i!==r&&i.startsWith(n)){let a=i.slice(n.length);if(a.startsWith("_length"))continue;s.push(a)}return s.sort()}function Xi(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function nc(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 p=e.parts[2];if(p.type!=="Literal"||!p.value.startsWith("=")&&!p.value.startsWith("+="))return null;r=t.pattern.slice(1),s=p,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 p of n.parts)(p.type==="Literal"||p.type==="Escaped")&&(r+=p.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=Xi(r);let a;if(s.type!=="Literal")return null;s.value.startsWith("]=")||s.value.startsWith("]+=")?a=s.value.slice(1):a=s.value;let o=a.startsWith("+=");if(!o&&!a.startsWith("="))return null;let l=[],c=o?2:1,u=a.slice(c);u&&l.push({type:"Literal",value:u});for(let f=i+1;f<e.parts.length;f++){let p=e.parts[f];p.type==="BraceExpansion"?l.push({type:"Literal",value:ux(p)}):l.push(p)}return{key:r,valueParts:l,append:o}}function ux(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 Br(n.word)}).join(",")}}`}function Br(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}`:""}`:Br(r.word)).join(","),t+="}";break;case"TildeExpansion":t+="~",n.user&&(t+=n.user);break}return t}var Xt=I(()=>{"use strict"});function rt(e){return e.get("IFS")??`
|
|
767
767
|
`}function ft(e){return e.get("IFS")===""}function Yi(e){let t=rt(e);if(t==="")return!0;for(let n of t)if(n!==" "&&n!==" "&&n!==`
|
|
768
768
|
`)return!1;return!0}function Vm(e){return e.split("").map(t=>/[\\^$.*+?()[\]{}|-]/.test(t)?`\\${t}`:t===" "?"\\t":t===`
|
|
769
|
-
`?"\\n":t).join("")}function fe(e){let t=e.get("IFS");return t===void 0?" ":t[0]||""}function
|
|
770
|
-
`});function Te(e,t){return e.state.namerefs?.has(t)??!1}function vn(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function Zm(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Km(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function Qm(e,t){return e.state.invalidNamerefs?.has(t)??!1}function ic(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function ea(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(o=>o.startsWith(`${s}_`)&&!o.includes("__")),a=e.state.associativeArrays?.has(s)??!1;return i||a}return Array.from(e.state.env.keys()).some(s=>s.startsWith(`${t}_`)&&!s.includes("__"))?!0:e.state.env.has(t)}function
|
|
769
|
+
`?"\\n":t).join("")}function fe(e){let t=e.get("IFS");return t===void 0?" ":t[0]||""}function px(e){return fx.includes(e)}function rc(e){let t=new Set,n=new Set;for(let r of e)px(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function sc(e,t,n,r){if(t==="")return e===""?{words:[],wordStarts:[]}:{words:[e],wordStarts:[0]};let{whitespace:s,nonWhitespace:i}=rc(t),a=[],o=[],l=0;for(;l<e.length&&s.has(e[l]);)l++;if(l>=e.length)return{words:[],wordStarts:[]};if(i.has(e[l]))for(a.push(""),o.push(l),l++;l<e.length&&s.has(e[l]);)l++;for(;l<e.length&&!(n!==void 0&&a.length>=n);){let c=l;for(o.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(a.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&&a.length>=n);)for(a.push(""),o.push(l),l++;l<e.length&&s.has(e[l]);)l++}}return{words:a,wordStarts:o}}function Ji(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}=rc(t),s=[],i=0,a=!1,o=!1,l=i;for(;i<e.length&&n.has(e[i]);)i++;if(i>l&&(a=!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){o=!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&&(o=!0)}return{words:s,hadLeadingDelimiter:a,hadTrailingDelimiter:o}}function _e(e,t){return Ji(e,t).words}function hx(e,t){for(let n of e)if(t.has(n))return!0;return!1}function qm(e,t,n){if(t==="")return e;let{whitespace:r,nonWhitespace:s}=rc(t),i=e.length;for(;i>0&&r.has(e[i-1]);){if(!n&&i>=2){let o=0,l=i-2;for(;l>=0&&e[l]==="\\";)o++,l--;if(o%2===1)break}i--}let a=e.substring(0,i);if(a.length>=1&&s.has(a[a.length-1])){if(!n&&a.length>=2){let l=0,c=a.length-2;for(;c>=0&&a[c]==="\\";)l++,c--;if(l%2===1)return a}let o=a.substring(0,a.length-1);if(!hx(o,s))return o}return a}var fx,jt=I(()=>{"use strict";fx=`
|
|
770
|
+
`});function Te(e,t){return e.state.namerefs?.has(t)??!1}function vn(e,t){e.state.namerefs??=new Set,e.state.namerefs.add(t)}function Zm(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Km(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function Qm(e,t){return e.state.invalidNamerefs?.has(t)??!1}function ic(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function ea(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(o=>o.startsWith(`${s}_`)&&!o.includes("__")),a=e.state.associativeArrays?.has(s)??!1;return i||a}return Array.from(e.state.env.keys()).some(s=>s.startsWith(`${t}_`)&&!s.includes("__"))?!0:e.state.env.has(t)}function At(e,t,n=100){if(!Te(e,t)||Qm(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 lr(e,t){if(Te(e,t))return e.state.env.get(t)}function Xm(e,t,n,r=100){if(!Te(e,t)||Qm(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 a=e.state.env.get(i);if(a===void 0||a==="")return n!==void 0?/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)&&ea(e,n)?i:null:i;if(!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(a))return i;i=a}}var an=I(()=>{"use strict"});function dx(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 oe(e,t){return t==="FUNCNAME"?(e.state.funcNameStack??[]).map((i,a)=>[a,i]):t==="BASH_LINENO"?(e.state.callLineStack??[]).map((i,a)=>[a,String(i)]):t==="BASH_SOURCE"?(e.state.sourceStack??[]).map((i,a)=>[a,i]):e.state.associativeArrays?.has(t)?sn(e,t).map(i=>[i,e.state.env.get(`${t}_${i}`)??""]):Ye(e,t).map(s=>[s,e.state.env.get(`${t}_${s}`)??""])}function In(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)?sn(e,t).length>0:Ye(e,t).length>0}async function Se(e,t,n=!0,r=!1){switch(t){case"?":return String(e.state.lastExitCode);case"$":return String(e.state.virtualPid);case"#":return e.state.env.get("#")||"0";case"@":return e.state.env.get("@")||"";case"_":return e.state.lastArg;case"-":{let a="";return a+="h",e.state.options.errexit&&(a+="e"),e.state.options.noglob&&(a+="f"),e.state.options.nounset&&(a+="u"),e.state.options.verbose&&(a+="v"),e.state.options.xtrace&&(a+="x"),a+="B",e.state.options.noclobber&&(a+="C"),a+="s",a}case"*":{let a=Number.parseInt(e.state.env.get("#")||"0",10);if(a===0)return"";let o=[];for(let l=1;l<=a;l++)o.push(e.state.env.get(String(l))||"");return o.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":return String(e.state.virtualPpid);case"UID":return String(e.state.virtualUid);case"EUID":return String(e.state.virtualUid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-e.state.startTime)/1e3));case"BASH_VERSION":return G0;case"!":return String(e.state.lastBackgroundPid);case"BASHPID":return String(e.state.bashPid);case"LINENO":return String(e.state.currentLine);case"FUNCNAME":{let a=e.state.funcNameStack?.[0];if(a!==void 0)return a;if(n&&e.state.options.nounset)throw new yt("FUNCNAME");return""}case"BASH_LINENO":{let a=e.state.callLineStack?.[0];if(a!==void 0)return String(a);if(n&&e.state.options.nounset)throw new yt("BASH_LINENO");return""}case"BASH_SOURCE":{let a=e.state.sourceStack?.[0];if(a!==void 0)return a;if(n&&e.state.options.nounset)throw new yt("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new wt(`\${${t}}`);let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(s){let a=s[1],o=s[2];if(Te(e,a)){let f=At(e,a);if(f&&f!==a){if(f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return"";a=f}}if(o==="@"||o==="*"){let f=oe(e,a);if(f.length>0)return f.map(([,h])=>h).join(" ");let p=e.state.env.get(a);return p!==void 0?p:""}if(a==="FUNCNAME"){let f=Number.parseInt(o,10);return!Number.isNaN(f)&&f>=0?e.state.funcNameStack?.[f]??"":""}if(a==="BASH_LINENO"){let f=Number.parseInt(o,10);if(!Number.isNaN(f)&&f>=0){let p=e.state.callLineStack?.[f];return p!==void 0?String(p):""}return""}if(a==="BASH_SOURCE"){let f=Number.parseInt(o,10);return!Number.isNaN(f)&&f>=0?e.state.sourceStack?.[f]??"":""}if(e.state.associativeArrays?.has(a)){let f=Xi(o);f=dx(e,f);let p=e.state.env.get(`${a}_${f}`);if(p===void 0&&n&&e.state.options.nounset)throw new yt(`${a}[${o}]`);return p||""}let c;if(/^-?\d+$/.test(o))c=Number.parseInt(o,10);else try{let f=new ce,p=Ae(f,o);c=await ne(e,p.expression)}catch{let f=e.state.env.get(o);c=f?Number.parseInt(f,10):0,Number.isNaN(c)&&(c=0)}if(c<0){let f=oe(e,a),p=e.state.currentLine;if(f.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${p}: ${a}: 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 ${p}: ${a}: bad array subscript
|
|
772
|
-
`,""):e.state.env.get(`${a}_${m}`)||""}let u=e.state.env.get(`${a}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(a);if(f!==void 0)return f}if(n&&e.state.options.nounset)throw new wt(`${a}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let a=e.state.env.get(t);if(a===void 0&&n&&e.state.options.nounset)throw new wt(t);return a||""}if(Te(e,t)){let a=St(e,t);if(a===void 0)return"";if(a!==t)return await Se(e,a,n,r);let o=e.state.env.get(t);if((o===void 0||o==="")&&n&&e.state.options.nounset)throw new wt(t);return o||""}let i=e.state.env.get(t);if(i!==void 0)return e.state.tempEnvBindings?.some(a=>a.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),i;if(In(e,t)){let a=e.state.env.get(`${t}_0`);return a!==void 0?a:""}if(n&&e.state.options.nounset)throw new wt(t);return""}async function bn(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=St(e,s);if(l&&l!==s){if(l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;s=l}}if(i==="@"||i==="*")return oe(e,s).length>0?!0:e.state.env.has(s);if(e.state.associativeArrays?.has(s)){let l=Xi(i);return e.state.env.has(`${s}_${l}`)}let o;if(/^-?\d+$/.test(i))o=Number.parseInt(i,10);else try{let l=new ce,c=Ae(l,i);o=await ne(e,c.expression)}catch{let l=e.state.env.get(i);o=l?Number.parseInt(l,10):0,Number.isNaN(o)&&(o=0)}if(o<0){let l=oe(e,s);if(l.length===0)return!1;let u=Math.max(...l.map(([f])=>typeof f=="number"?f:0))+1+o;return u<0?!1:e.state.env.has(`${s}_${u}`)}return e.state.env.has(`${s}_${o}`)}if(Te(e,t)){let s=St(e,t);return s===void 0||s===t?e.state.env.has(t):bn(e,s)}return!!(e.state.env.has(t)||In(e,t))}var Dt=I(()=>{"use strict";mt();Xe();kl();Ct();ye();Xt();jt();an()});async function Ym(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),a=await Se(e,i);n+=a,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),a=await Se(e,i);n+=a,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),a=await Se(e,i);n+=a,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 ac(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="",a=0;for(;a<n.length;)if(n[a]==="$")if(n[a+1]==="("){let o=1,l=a+2;for(;l<n.length&&o>0;)n[l]==="("&&n[l-1]==="$"||n[l]==="("?o++:n[l]===")"&&o--,l++;let c=n.slice(a+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)}a=l}else if(n[a+1]==="{"){let o=1,l=a+2;for(;l<n.length&&o>0;)n[l]==="{"?o++:n[l]==="}"&&o--,l++;let c=n.slice(a+2,l-1),u=await Se(e,c);i+=u,a=l}else if(/[a-zA-Z_]/.test(n[a+1]||"")){let o=a+1;for(;o<n.length&&/[a-zA-Z0-9_]/.test(n[o]);)o++;let l=n.slice(a+1,o),c=await Se(e,l);i+=c,a=o}else i+=n[a],a++;else if(n[a]==="`"){let o=a+1;for(;o<n.length&&n[o]!=="`";)o++;let l=n.slice(a+1,o);if(e.execFn){let c=await e.execFn(l);i+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}a=o+1}else i+=n[a],a++;return i}var Jm=I(()=>{"use strict";Dt()});function gx(e,t,n,r,s){let i=n??1;i===0&&(i=1);let a=Math.abs(i),o=[],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,p=String(Math.abs(u)).padStart(l,"0");return f?`-${p}`:p}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<ta;u+=a,f++)o.push(c(u));else for(let u=e,f=0;u>=t&&f<ta;u-=a,f++)o.push(c(u));return o}function yx(e,t,n){let r=n??1;r===0&&(r=1);let s=e.charCodeAt(0),i=t.charCodeAt(0),a=Math.abs(r),o=e>="A"&&e<="Z",l=e>="a"&&e<="z",c=t>="A"&&t<="Z",u=t>="a"&&t<="z";if(o&&u||l&&c){let p=n!==void 0?`..${n}`:"";throw new yr(`{${e}..${t}${p}}: invalid sequence`)}let f=[];if(s<=i)for(let p=s,h=0;p<=i&&h<ta;p+=a,h++)f.push(String.fromCharCode(p));else for(let p=s,h=0;p>=i&&h<ta;p-=a,h++)f.push(String.fromCharCode(p));return f}function oc(e,t,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:gx(e,t,n,r,s),literal:`{${e}..${t}${i}}`}:typeof e=="string"&&typeof t=="string"?{expanded:yx(e,t,n),literal:`{${e}..${t}${i}}`}:{expanded:null,literal:`{${e}..${t}${i}}`}}var ta,e2=I(()=>{"use strict";ye();ta=1e4});function t2(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 n2=I(()=>{"use strict"});function xn(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function lc(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 zr(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}var Hr=I(()=>{"use strict"});function xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var jr=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 a=wx(e,s+1);if(a!==-1){let o=e.slice(s+2,a),c=bx(o).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=a+1;continue}}if(i==="\\")if(s+1<e.length){let a=e[s+1];/[\\^$.|+(){}[\]*?]/.test(a)?r+=`\\${a}`:r+=a,s+=2}else r+="\\\\",s++;else if(i==="*")r+=t?".*":".*?",s++;else if(i==="?")r+=".",s++;else if(i==="["){let a=xx(e,s);if(a===-1)r+="\\[",s++;else{let o=e.slice(s+1,a);r+=Ex(o),s=a+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function wx(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 bx(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 xx(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 Ex(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 a of i)a==="\\"?t+="\\\\":a==="]"?t+="\\]":a==="^"&&t==="["?t+="\\^":t+=a;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+=Sx(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 Sx(e){return Ax.get(e)??""}var Ax,Gr=I(()=>{"use strict";Ax=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 $n(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 a=e.slice(i);if(s.test(a))return e.slice(0,i)}return e}function Vr(e,t){let n=Array.from(e.state.env.keys()),r=new Set,s=e.state.associativeArrays??new Set,i=new Set;for(let o of n){let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l&&i.add(l[1]);let c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&i.add(c[1])}let a=o=>{for(let l of s){let c=`${l}_`;if(o.startsWith(c)&&o!==l)return!0}return!1};for(let o of n)if(o.startsWith(t))if(o.includes("__")){let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);l?.[1].startsWith(t)&&r.add(l[1])}else if(/_\d+$/.test(o)){let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l?.[1].startsWith(t)&&r.add(l[1])}else a(o)||r.add(o);return[...r].sort()}var cr=I(()=>{"use strict";Me()});function Cx(e,t){let n=(i,a=2)=>String(i).padStart(a,"0");if(e===""){let i=n(t.getHours()),a=n(t.getMinutes()),o=n(t.getSeconds());return`${i}:${a}:${o}`}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 a=t.getHours()%12;a===0&&(a=12),r+=n(a);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 Is(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",a=i.split(".")[0],o=e.state.env.get("PWD")||"/",l=e.state.env.get("HOME")||"/",c=o.startsWith(l)?`~${o.slice(l.length)}`:o,u=o.split("/").pop()||o,f=new Date,p=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=["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 w="",y=r+1;for(;y<t.length&&y<r+4&&t[y]>="0"&&t[y]<="7";)w+=t[y],y++;let b=Number.parseInt(w,8)%256;n+=String.fromCharCode(b),r=y;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
|
-
`,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+=a,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 w=String(f.getDate()).padStart(2," ");n+=`${p[f.getDay()]} ${h[f.getMonth()]} ${w}`,r+=2;break}case"t":{let w=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0"),b=String(f.getSeconds()).padStart(2,"0");n+=`${w}:${y}:${b}`,r+=2;break}case"T":{let w=f.getHours()%12;w===0&&(w=12);let y=String(w).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),x=String(f.getSeconds()).padStart(2,"0");n+=`${y}:${b}:${x}`,r+=2;break}case"@":{let w=f.getHours()%12;w===0&&(w=12);let y=String(w).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),x=f.getHours()<12?"AM":"PM";n+=`${y}:${b} ${x}`,r+=2;break}case"A":{let w=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0");n+=`${w}:${y}`,r+=2;break}case"D":if(r+2<t.length&&t[r+2]==="{"){let w=t.indexOf("}",r+3);if(w!==-1){let y=t.slice(r+3,w);n+=
|
|
772
|
+
`,""):e.state.env.get(`${a}_${m}`)||""}let u=e.state.env.get(`${a}_${c}`);if(u!==void 0)return u;if(c===0){let f=e.state.env.get(a);if(f!==void 0)return f}if(n&&e.state.options.nounset)throw new yt(`${a}[${c}]`);return""}if(/^[1-9][0-9]*$/.test(t)){let a=e.state.env.get(t);if(a===void 0&&n&&e.state.options.nounset)throw new yt(t);return a||""}if(Te(e,t)){let a=At(e,t);if(a===void 0)return"";if(a!==t)return await Se(e,a,n,r);let o=e.state.env.get(t);if((o===void 0||o==="")&&n&&e.state.options.nounset)throw new yt(t);return o||""}let i=e.state.env.get(t);if(i!==void 0)return e.state.tempEnvBindings?.some(a=>a.has(t))&&(e.state.accessedTempEnvVars=e.state.accessedTempEnvVars||new Set,e.state.accessedTempEnvVars.add(t)),i;if(In(e,t)){let a=e.state.env.get(`${t}_0`);return a!==void 0?a:""}if(n&&e.state.options.nounset)throw new yt(t);return""}async function bn(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=At(e,s);if(l&&l!==s){if(l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/))return!1;s=l}}if(i==="@"||i==="*")return oe(e,s).length>0?!0:e.state.env.has(s);if(e.state.associativeArrays?.has(s)){let l=Xi(i);return e.state.env.has(`${s}_${l}`)}let o;if(/^-?\d+$/.test(i))o=Number.parseInt(i,10);else try{let l=new ce,c=Ae(l,i);o=await ne(e,c.expression)}catch{let l=e.state.env.get(i);o=l?Number.parseInt(l,10):0,Number.isNaN(o)&&(o=0)}if(o<0){let l=oe(e,s);if(l.length===0)return!1;let u=Math.max(...l.map(([f])=>typeof f=="number"?f:0))+1+o;return u<0?!1:e.state.env.has(`${s}_${u}`)}return e.state.env.has(`${s}_${o}`)}if(Te(e,t)){let s=At(e,t);return s===void 0||s===t?e.state.env.has(t):bn(e,s)}return!!(e.state.env.has(t)||In(e,t))}var Dt=I(()=>{"use strict";dt();Xe();kl();St();ye();Xt();jt();an()});async function Ym(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),a=await Se(e,i);n+=a,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),a=await Se(e,i);n+=a,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),a=await Se(e,i);n+=a,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 ac(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="",a=0;for(;a<n.length;)if(n[a]==="$")if(n[a+1]==="("){let o=1,l=a+2;for(;l<n.length&&o>0;)n[l]==="("&&n[l-1]==="$"||n[l]==="("?o++:n[l]===")"&&o--,l++;let c=n.slice(a+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)}a=l}else if(n[a+1]==="{"){let o=1,l=a+2;for(;l<n.length&&o>0;)n[l]==="{"?o++:n[l]==="}"&&o--,l++;let c=n.slice(a+2,l-1),u=await Se(e,c);i+=u,a=l}else if(/[a-zA-Z_]/.test(n[a+1]||"")){let o=a+1;for(;o<n.length&&/[a-zA-Z0-9_]/.test(n[o]);)o++;let l=n.slice(a+1,o),c=await Se(e,l);i+=c,a=o}else i+=n[a],a++;else if(n[a]==="`"){let o=a+1;for(;o<n.length&&n[o]!=="`";)o++;let l=n.slice(a+1,o);if(e.execFn){let c=await e.execFn(l);i+=c.stdout.replace(/\n+$/,""),c.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+c.stderr)}a=o+1}else i+=n[a],a++;return i}var Jm=I(()=>{"use strict";Dt()});function mx(e,t,n,r,s){let i=n??1;i===0&&(i=1);let a=Math.abs(i),o=[],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,p=String(Math.abs(u)).padStart(l,"0");return f?`-${p}`:p}return String(u)};if(e<=t)for(let u=e,f=0;u<=t&&f<ta;u+=a,f++)o.push(c(u));else for(let u=e,f=0;u>=t&&f<ta;u-=a,f++)o.push(c(u));return o}function gx(e,t,n){let r=n??1;r===0&&(r=1);let s=e.charCodeAt(0),i=t.charCodeAt(0),a=Math.abs(r),o=e>="A"&&e<="Z",l=e>="a"&&e<="z",c=t>="A"&&t<="Z",u=t>="a"&&t<="z";if(o&&u||l&&c){let p=n!==void 0?`..${n}`:"";throw new yr(`{${e}..${t}${p}}: invalid sequence`)}let f=[];if(s<=i)for(let p=s,h=0;p<=i&&h<ta;p+=a,h++)f.push(String.fromCharCode(p));else for(let p=s,h=0;p>=i&&h<ta;p-=a,h++)f.push(String.fromCharCode(p));return f}function oc(e,t,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:mx(e,t,n,r,s),literal:`{${e}..${t}${i}}`}:typeof e=="string"&&typeof t=="string"?{expanded:gx(e,t,n),literal:`{${e}..${t}${i}}`}:{expanded:null,literal:`{${e}..${t}${i}}`}}var ta,e2=I(()=>{"use strict";ye();ta=1e4});function t2(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 n2=I(()=>{"use strict"});function xn(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function lc(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 zr(e){return e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&")}var Hr=I(()=>{"use strict"});function xe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var jr=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 a=yx(e,s+1);if(a!==-1){let o=e.slice(s+2,a),c=wx(o).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=a+1;continue}}if(i==="\\")if(s+1<e.length){let a=e[s+1];/[\\^$.|+(){}[\]*?]/.test(a)?r+=`\\${a}`:r+=a,s+=2}else r+="\\\\",s++;else if(i==="*")r+=t?".*":".*?",s++;else if(i==="?")r+=".",s++;else if(i==="["){let a=bx(e,s);if(a===-1)r+="\\[",s++;else{let o=e.slice(s+1,a);r+=xx(o),s=a+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function yx(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 wx(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 bx(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 xx(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 a of i)a==="\\"?t+="\\\\":a==="]"?t+="\\]":a==="^"&&t==="["?t+="\\^":t+=a;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+=Ax(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 Ax(e){return Ex.get(e)??""}var Ex,Gr=I(()=>{"use strict";Ex=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 $n(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 a=e.slice(i);if(s.test(a))return e.slice(0,i)}return e}function Vr(e,t){let n=Array.from(e.state.env.keys()),r=new Set,s=e.state.associativeArrays??new Set,i=new Set;for(let o of n){let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l&&i.add(l[1]);let c=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);c&&i.add(c[1])}let a=o=>{for(let l of s){let c=`${l}_`;if(o.startsWith(c)&&o!==l)return!0}return!1};for(let o of n)if(o.startsWith(t))if(o.includes("__")){let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)__length$/);l?.[1].startsWith(t)&&r.add(l[1])}else if(/_\d+$/.test(o)){let l=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)_\d+$/);l?.[1].startsWith(t)&&r.add(l[1])}else a(o)||r.add(o);return[...r].sort()}var cr=I(()=>{"use strict";Me()});function Sx(e,t){let n=(i,a=2)=>String(i).padStart(a,"0");if(e===""){let i=n(t.getHours()),a=n(t.getMinutes()),o=n(t.getSeconds());return`${i}:${a}:${o}`}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 a=t.getHours()%12;a===0&&(a=12),r+=n(a);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 Is(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",a=i.split(".")[0],o=e.state.env.get("PWD")||"/",l=e.state.env.get("HOME")||"/",c=o.startsWith(l)?`~${o.slice(l.length)}`:o,u=o.split("/").pop()||o,f=new Date,p=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=["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 w="",y=r+1;for(;y<t.length&&y<r+4&&t[y]>="0"&&t[y]<="7";)w+=t[y],y++;let b=Number.parseInt(w,8)%256;n+=String.fromCharCode(b),r=y;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
|
+
`,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+=a,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 w=String(f.getDate()).padStart(2," ");n+=`${p[f.getDay()]} ${h[f.getMonth()]} ${w}`,r+=2;break}case"t":{let w=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0"),b=String(f.getSeconds()).padStart(2,"0");n+=`${w}:${y}:${b}`,r+=2;break}case"T":{let w=f.getHours()%12;w===0&&(w=12);let y=String(w).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),x=String(f.getSeconds()).padStart(2,"0");n+=`${y}:${b}:${x}`,r+=2;break}case"@":{let w=f.getHours()%12;w===0&&(w=12);let y=String(w).padStart(2,"0"),b=String(f.getMinutes()).padStart(2,"0"),x=f.getHours()<12?"AM":"PM";n+=`${y}:${b} ${x}`,r+=2;break}case"A":{let w=String(f.getHours()).padStart(2,"0"),y=String(f.getMinutes()).padStart(2,"0");n+=`${w}:${y}`,r+=2;break}case"D":if(r+2<t.length&&t[r+2]==="{"){let w=t.indexOf("}",r+3);if(w!==-1){let y=t.slice(r+3,w);n+=Sx(y,f),r=w+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 cc=I(()=>{"use strict"});function Wn(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 uc=I(()=>{"use strict"});function Lt(e,t){e.state.readonlyVars=e.state.readonlyVars||new Set,e.state.readonlyVars.add(t)}function En(e,t){return e.state.readonlyVars?.has(t)??!1}function it(e,t,n="bash"){if(En(e,t)){let r=`${n}: ${t}: readonly variable
|
|
775
775
|
`;throw new pe(1,"",r)}return null}function on(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 na(e,t){e.state.exportedVars?.delete(t)}var Bn=I(()=>{"use strict";ye()});function zn(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"),En(e,t)&&(n+="r"),e.state.exportedVars?.has(t)&&(n+="x"),n}var ra=I(()=>{"use strict";an();Bn()});async function r2(e,t,n,r){return e.coverage?.hit("bash:expansion:default_value"),(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):n.effectiveValue}async function s2(e,t,n,r,s){if(e.coverage?.hit("bash:expansion:assign_default"),(r.isUnset||n.checkEmpty&&r.isEmpty)&&n.word){let a=await s(e,n.word.parts,r.inDoubleQuotes),o=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(o){let[,l,c]=o,u;if(/^\d+$/.test(c))u=Number.parseInt(c,10);else{try{let p=new ce,h=Ae(p,c);u=await ne(e,h.expression)}catch{let p=e.state.env.get(c);u=p?Number.parseInt(p,10):0}Number.isNaN(u)&&(u=0)}e.state.env.set(`${l}_${u}`,a);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,a);return a}return r.effectiveValue}async function i2(e,t,n,r,s){if(e.coverage?.hit("bash:expansion:error_if_unset"),r.isUnset||n.checkEmpty&&r.isEmpty){let a=n.word?await s(e,n.word.parts,r.inDoubleQuotes):`${t}: parameter null or not set`;throw new pe(1,"",`bash: ${a}
|
|
776
776
|
`)}return r.effectiveValue}async function a2(e,t,n,r){return e.coverage?.hit("bash:expansion:use_alternative"),!(n.isUnset||t.checkEmpty&&n.isEmpty)&&t.word?r(e,t.word.parts,n.inDoubleQuotes):""}async function o2(e,t,n,r,s){e.coverage?.hit("bash:expansion:pattern_removal");let i="",a=e.state.shoptOptions.extglob;if(n.pattern)for(let l of n.pattern.parts)if(l.type==="Glob")i+=me(l.pattern,n.greedy,a);else if(l.type==="Literal")i+=me(l.value,n.greedy,a);else if(l.type==="SingleQuoted"||l.type==="Escaped")i+=xe(l.value);else if(l.type==="DoubleQuoted"){let c=await r(e,l.parts);i+=xe(c)}else if(l.type==="ParameterExpansion"){let c=await s(e,l);i+=me(c,n.greedy,a)}else{let c=await s(e,l);i+=xe(c)}if(n.side==="prefix")return V(`^${i}`,"s").replace(t,"");let o=V(`${i}$`,"s");if(n.greedy)return o.replace(t,"");for(let l=t.length;l>=0;l--){let c=t.slice(l);if(o.test(c))return t.slice(0,l)}return t}async function l2(e,t,n,r,s){e.coverage?.hit("bash:expansion:pattern_replacement");let i="",a=e.state.shoptOptions.extglob;if(n.pattern)for(let c of n.pattern.parts)if(c.type==="Glob")i+=me(c.pattern,!0,a);else if(c.type==="Literal")i+=me(c.value,!0,a);else if(c.type==="SingleQuoted"||c.type==="Escaped")i+=xe(c.value);else if(c.type==="DoubleQuoted"){let u=await r(e,c.parts);i+=xe(u)}else if(c.type==="ParameterExpansion"){let u=await s(e,c);i+=me(u,!0,a)}else{let u=await s(e,c);i+=xe(u)}let o=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,p=c.exec(t);for(;p!==null&&!(p[0].length===0&&p.index===t.length);)u+=t.slice(f,p.index)+o,f=p.index+p[0].length,p[0].length===0&&f++,p=c.exec(t);return u+=t.slice(f),u}return c.replace(t,o)}catch{return t}}function c2(e,t,n){e.coverage?.hit("bash:expansion:length");let r=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(r){let s=r[1],i=oe(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)&&In(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 u2(e,t,n,r){e.coverage?.hit("bash:expansion:substring");let s=await ne(e,r.offset.expression),i=r.length?await ne(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",p,h;if(s<=0)if(p=[f,...u],s<0){if(h=p.length+s,h<0)return""}else h=0;else p=u,h=s-1;if(h<0||h>=p.length)return"";if(i!==void 0){let m=i<0?p.length+i:h+i;return p.slice(h,Math.max(h,m)).join(" ")}return p.slice(h).join(" ")}let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(a){let c=a[1];if(e.state.associativeArrays?.has(c))throw new pe(1,"",`bash: \${${c}[@]: 0: 3}: bad substitution
|
|
777
777
|
`);let u=oe(e,c),f=0;if(s<0){if(u.length>0){let p=u[u.length-1][0],m=(typeof p=="number"?p:0)+1+s;if(m<0||(f=u.findIndex(([d])=>typeof d=="number"&&d>=m),f<0))return""}}else if(f=u.findIndex(([p])=>typeof p=="number"&&p>=s),f<0)return"";if(i!==void 0){if(i<0)throw new Re(`${a[1]}[@]: substring expression < 0`);return u.slice(f,f+i).map(([,p])=>p).join(" ")}return u.slice(f).map(([,p])=>p).join(" ")}let o=[...n],l=s;if(l<0&&(l=Math.max(0,o.length+l)),i!==void 0){if(i<0){let c=o.length+i;return o.slice(l,Math.max(l,c)).join("")}return o.slice(l,l+i).join("")}return o.slice(l).join("")}async function f2(e,t,n,r,s){if(e.coverage?.hit("bash:expansion:case_modification"),n.pattern){let i=e.state.shoptOptions.extglob,a="";for(let f of n.pattern.parts)if(f.type==="Glob")a+=me(f.pattern,!0,i);else if(f.type==="Literal")a+=me(f.value,!0,i);else if(f.type==="SingleQuoted"||f.type==="Escaped")a+=xe(f.value);else if(f.type==="DoubleQuoted"){let p=await r(e,f.parts);a+=xe(p)}else if(f.type==="ParameterExpansion"){let p=await s(e,f);a+=me(p,!0,i)}let o=V(`^(?:${a})$`),l=n.direction==="upper"?f=>f.toUpperCase():f=>f.toLowerCase(),c="",u=!1;for(let f of t)!n.all&&u?c+=f:o.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 p2(e,t,n,r,s){e.coverage?.hit("bash:expansion:transform");let i=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(i&&s.operator==="Q")return oe(e,i[1]).map(([,c])=>Wn(c)).join(" ");if(i&&s.operator==="a")return zn(e,i[1]);let a=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[.+\]$/);if(a&&s.operator==="a")return zn(e,a[1]);switch(s.operator){case"Q":return r?"":Wn(n);case"P":return Is(e,n);case"a":return zn(e,t);case"A":return r?"":`${t}=${Wn(n)}`;case"E":return n.replace(/\\([\\abefnrtv'"?])/g,(o,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?"":Wn(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 h2(e,t,n,r,s,i,a=!1){if(e.coverage?.hit("bash:expansion:indirection"),Te(e,t))return lr(e,t)||"";let o=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new bt(`\${!${t}}`)}let l=n;if(o&&(l===""||l.includes(" ")))throw new bt(`\${!${t}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new bt(`\${!${t}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(e,u,a)}return await Se(e,l)}function d2(e,t){e.coverage?.hit("bash:expansion:array_keys");let r=oe(e,t.array).map(([s])=>String(s));return t.star?r.join(fe(e.state.env)):r.join(" ")}function m2(e,t){e.coverage?.hit("bash:expansion:var_name_prefix");let n=Vr(e,t.prefix);return t.star?n.join(fe(e.state.env)):n.join(" ")}function g2(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[,a,o]=i,l=oe(e,a);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(o==="*"){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 y2=I(()=>{"use strict";mt();Xe();Me();Ct();ye();jt();an();jr();Gr();cr();cc();uc();Dt();ra()});function w2(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 b2(e,t){let n=1,r=t,s=!1,i=!1;for(;r<e.length&&n>0;){let a=e[r];if(a==="\\"&&!s&&r+1<e.length){r+=2;continue}if(a==="'"&&!i){s=!s,r++;continue}if(a==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(a==="(")n++;else if(a===")"&&(n--,n===0))return r}r++}return-1}async function sa(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),a=e.state.cwd,o=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=a,e.state.suppressVerbose=o,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=a,e.state.bashPid=s,e.state.suppressVerbose=o,l instanceof te)throw l;return l instanceof pe?(e.state.lastExitCode=l.exitCode,e.state.env.set("?",String(l.exitCode)),l.stdout?.replace(/\n+$/,"")??""):""}}function fc(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 a=t.slice(r+1,i);n+=_t(a),r=i+1;continue}}if(s==='"'){let i=-1,a=r+1;for(;a<t.length;){if(t[a]==="\\"){a+=2;continue}if(t[a]==='"'){i=a;break}a++}if(i!==-1){let o=t.slice(r+1,i),l=Nx(e,o);n+=_t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}function Nx(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 a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}n+=s,r++}return n}async function x2(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 a=t.slice(r+1,i);n+=_t(a),r=i+1;continue}}if(s==='"'){let i=-1,a=r+1;for(;a<t.length;){if(t[a]==="\\"){a+=2;continue}if(t[a]==='"'){i=a;break}a++}if(i!==-1){let o=t.slice(r+1,i),l=await kx(e,o);n+=_t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=b2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=t.slice(r+1,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}async function kx(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=b2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=t.slice(r+1,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}n+=s,r++}return n}var E2=I(()=>{"use strict";Xe();ye();Hr()});function A2(e,t){if(!t.startsWith("~"))return t;e.coverage?.hit("bash:expansion:tilde");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 S2=I(()=>{"use strict"});async function vx(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+=xe(i.value);else if(i.type==="DoubleQuoted"){let a=await n(e,i.parts);s+=xe(a)}else if(i.type==="ParameterExpansion"){let a=await r(e,i);s+=me(a,!0,e.state.shoptOptions.extglob)}else{let a=await r(e,i);s+=xe(a)}return s}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!=="PatternReplacement")return null;let i=s.parts[0],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],l=a[2]==="*",c=i.operation,u=oe(e,o),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env.get(o);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let p="";c.pattern&&(p=await vx(e,c.pattern,n,r));let h=c.replacement?await n(e,c.replacement.parts):"",m=p;c.anchor==="start"?m=`^${p}`:c.anchor==="end"&&(m=`${p}$`);let d=[];try{let g=V(m,c.all?"g":"");for(let w of f)d.push(g.replace(w,h))}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 N2(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],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],l=a[2]==="*",c=i.operation,u=oe(e,o),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env.get(o);d!==void 0&&f.push(d)}if(f.length===0)return{values:[],quoted:!0};let p="",h=e.state.shoptOptions.extglob;if(c.pattern)for(let d of c.pattern.parts)if(d.type==="Glob")p+=me(d.pattern,c.greedy,h);else if(d.type==="Literal")p+=me(d.value,c.greedy,h);else if(d.type==="SingleQuoted"||d.type==="Escaped")p+=xe(d.value);else if(d.type==="DoubleQuoted"){let g=await n(e,d.parts);p+=xe(g)}else if(d.type==="ParameterExpansion"){let g=await r(e,d);p+=me(g,c.greedy,h)}else{let g=await r(e,d);p+=xe(g)}let m=[];for(let d of f)m.push($n(d,p,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 k2=I(()=>{"use strict";Me();jt();jr();Gr();cr();Dt()});async function v2(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_]*)\[([@*])\]$/),a,o=!1;if(i){let l=i[1];o=i[2]==="*";let c=oe(e,l),u=c.length>0||e.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,h])=>h===""),p=s.checkEmpty??!1;if(s.type==="UseAlternative"?a=u&&!(p&&f):a=!u||p&&f,!a){if(c.length>0){let m=c.map(([,d])=>d);if(o){let d=fe(e.state.env);return{values:[m.join(d)],quoted:!0}}return{values:m,quoted:!0}}let h=e.state.env.get(l);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await bn(e,l),u=await Se(e,l),f=u==="",p=s.checkEmpty??!1;if(s.type==="UseAlternative"?a=c&&!(p&&f):a=!c||p&&f,!a)return{values:[u],quoted:!0}}if(a&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let p=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(p){c=p[1],u=p[2]==="*";break}}if(c){let f=oe(e,c);if(f.length>0){let h=f.map(([,m])=>m);if(u||o){let m=fe(e.state.env);return{values:[h.join(m)],quoted:!0}}return{values:h,quoted:!0}}let p=e.state.env.get(c);return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}}return null}async function I2(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],a=-1,o="",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 w=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(w){a=d,o=w[1],l=w[2]==="*",c=g.operation;break}}}if(a===-1||a===0&&a===i.parts.length-1)return null;let u="";for(let d=0;d<a;d++)u+=await r(e,i.parts[d]);let f="";for(let d=a+1;d<i.parts.length;d++)f+=await r(e,i.parts[d]);let p=oe(e,o),h=p.map(([,d])=>d);if(p.length===0){let d=e.state.env.get(o);if(d!==void 0)h=[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="",w=e.state.shoptOptions.extglob;if(d.pattern)for(let y of d.pattern.parts)if(y.type==="Glob")g+=me(y.pattern,d.greedy,w);else if(y.type==="Literal")g+=me(y.value,d.greedy,w);else if(y.type==="SingleQuoted"||y.type==="Escaped")g+=xe(y.value);else if(y.type==="DoubleQuoted"){let b=await s(e,y.parts);g+=xe(b)}else if(y.type==="ParameterExpansion"){let b=await r(e,y);g+=me(b,d.greedy,w)}else{let b=await r(e,y);g+=xe(b)}h=h.map(y=>$n(y,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+=xe(b.value);else if(b.type==="DoubleQuoted"){let x=await s(e,b.parts);g+=xe(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+=xe(x)}let w=d.replacement?await s(e,d.replacement.parts):"",y=g;d.anchor==="start"?y=`^${g}`:d.anchor==="end"&&(y=`${g}$`);try{let b=V(y,d.all?"g":"");h=h.map(x=>b.replace(x,w))}catch{}}if(l){let d=fe(e.state.env);return{values:[u+h.join(d)+f],quoted:!0}}return h.length===1?{values:[u+h[0]+f],quoted:!0}:{values:[u+h[0],...h.slice(1,-1),h[h.length-1]+f],quoted:!0}}async function $2(e,t,n,r){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a="",o=!1;for(let h=0;h<s.parts.length;h++){let m=s.parts[h];if(m.type==="ParameterExpansion"&&!m.operation){let d=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(d){i=h,a=d[1],o=d[2]==="*";break}}}if(i===-1)return null;let l="";for(let h=0;h<i;h++)l+=await r(e,s.parts[h]);let c="";for(let h=i+1;h<s.parts.length;h++)c+=await r(e,s.parts[h]);let u=oe(e,a),f=u.map(([,h])=>h);if(u.length===0){let h=e.state.env.get(a);if(h!==void 0)return{values:[l+h+c],quoted:!0};if(o)return{values:[l+c],quoted:!0};let m=l+c;return{values:m?[m]:[],quoted:!0}}if(o){let h=fe(e.state.env);return{values:[l+f.join(h)+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 O2=I(()=>{"use strict";Me();jt();jr();Gr();cr();Dt()});async function R2(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 a=i[1],o=i[2]==="*",l=s.operation;if(e.state.associativeArrays?.has(a))throw new pe(1,"",`bash: \${${a}[@]: 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=oe(e,a),p=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};p=f.findIndex(([w])=>typeof w=="number"&&w>=g),p<0&&(p=f.length)}}else p=f.findIndex(([m])=>typeof m=="number"&&m>=c),p<0&&(p=f.length);let h;if(u!==void 0){if(u<0)throw new Re(`${a}[@]: substring expression < 0`);h=f.slice(p,p+u).map(([,m])=>m)}else h=f.slice(p).map(([,m])=>m);if(h.length===0)return{values:[],quoted:!0};if(o){let m=fe(e.state.env);return{values:[h.join(m)],quoted:!0}}return{values:h,quoted:!0}}function T2(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],a=s[2]==="*",o=r.operation,l=oe(e,i);if(l.length===0){let f=e.state.env.get(i);if(f!==void 0){let p;switch(o.operator){case"a":p="";break;case"P":p=Is(e,f);break;case"Q":p=Wn(f);break;default:p=f}return{values:[p],quoted:!0}}return a?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=zn(e,i),u;switch(o.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>Is(e,f));break;case"Q":u=l.map(([,f])=>Wn(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(a){let f=fe(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var P2=I(()=>{"use strict";ye();jt();cc();uc();Dt();ra()});function D2(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=lr(e,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let a=oe(e,i);if(a.length>0)return{values:a.map(([,l])=>l),quoted:!0};let o=e.state.env.get(i);return o!==void 0?{values:[o],quoted:!0}:{values:[],quoted:!0}}function _2(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=lr(e,s);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],l=oe(e,o);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=e.state.env.get(o);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var L2=I(()=>{"use strict";an();Dt()});async function F2(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 a=i.parts[0],o=a.operation,l=await Se(e,a.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!o.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]==="*",p=oe(e,u);if(o.innerOp){if(o.innerOp.type==="Substring")return Ix(e,p,u,f,o.innerOp);if(o.innerOp.type==="DefaultValue"||o.innerOp.type==="UseAlternative"||o.innerOp.type==="AssignDefault"||o.innerOp.type==="ErrorIfUnset")return $x(e,p,u,f,o.innerOp,s);if(o.innerOp.type==="Transform"&&o.innerOp.operator==="a"){let d=zn(e,u),g=p.map(()=>d);return f?{values:[g.join(fe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let m=[];for(let[,d]of p){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:o.innerOp},w=e.state.env.get("_indirect_elem_");e.state.env.set("_indirect_elem_",d);try{let y=await r(e,g,!0);m.push(y)}finally{w!==void 0?e.state.env.set("_indirect_elem_",w):e.state.env.delete("_indirect_elem_")}}return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(p.length>0){let m=p.map(([,d])=>d);return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let h=e.state.env.get(u);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}async function Ix(e,t,n,r,s){let i=s.offset?await ne(e,s.offset.expression):0,a=s.length?await ne(e,s.length.expression):void 0,o=0;if(i<0){if(t.length>0){let u=t[t.length-1][0],p=(typeof u=="number"?u:0)+1+i;if(p<0)return{values:[],quoted:!0};if(o=t.findIndex(([h])=>typeof h=="number"&&h>=p),o<0)return{values:[],quoted:!0}}}else if(o=t.findIndex(([u])=>typeof u=="number"&&u>=i),o<0)return{values:[],quoted:!0};let l;if(a!==void 0){if(a<0)throw new Re(`${n}[@]: substring expression < 0`);l=t.slice(o,o+a)}else l=t.slice(o);let c=l.map(([,u])=>u);return r?{values:[c.join(fe(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function $x(e,t,n,r,s,i){let a=s.checkEmpty??!1,o=t.map(([,u])=>u),l=t.length===0,c=t.length===0;if(s.type==="UseAlternative")return!c&&!(a&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||a&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:r?{values:[o.join(fe(e.state.env))],quoted:!0}:{values:o,quoted:!0};if(s.type==="AssignDefault"){if((c||a&&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:[o.join(fe(e.state.env))],quoted:!0}:{values:o,quoted:!0}}return r?{values:[o.join(fe(e.state.env))],quoted:!0}:{values:o,quoted:!0}}async function M2(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 a=i.parts[0],l=(await Se(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await bn(e,n.parameter),u=await Se(e,n.parameter)==="",f=r.checkEmpty??!1,p;if(r.type==="UseAlternative"?p=c&&!(f&&u):p=!c||f&&u,p){let h=l[1],m=l[2]==="*",d=oe(e,h);if(d.length>0){let w=d.map(([,y])=>y);return m?{values:[w.join(fe(e.state.env))],quoted:!0}:{values:w,quoted:!0}}let g=e.state.env.get(h);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function U2(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 a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!=="ParameterExpansion"||a.parts[0].operation?.type!=="Indirection")return null;let o=a.parts[0],c=(await Se(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await Se(e,n.parameter),f=await bn(e,n.parameter),p=u==="",h=s.checkEmpty??!1,m;if(s.type==="UseAlternative"?m=f&&!(h&&p):m=!f||h&&p,m){let d=c[1],g=c[2]==="*",w=oe(e,d);if(w.length>0){let b=w.map(([,x])=>x);return g?{values:[b.join(fe(e.state.env))],quoted:!0}:{values:b,quoted:!0}}let y=e.state.env.get(d);return y!==void 0?{values:[y],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var W2=I(()=>{"use strict";Ct();ye();jt();Dt();ra()});function B2(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 z2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a=!1;for(let y=0;y<s.parts.length;y++){let b=s.parts[y];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=y,a=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),p=[];for(let y=1;y<=f;y++)p.push(e.state.env.get(String(y))||"");let h=e.state.env.get("0")||"bash",m;if(c<=0){let y=[h,...p],b=y.length+c;if(b<0)m=[];else{let x=c<0?b:0;if(u!==void 0){let S=u<0?y.length+u:x+u;m=y.slice(x,Math.max(x,S))}else m=y.slice(x)}}else{let y=c-1;if(y>=p.length)m=[];else if(u!==void 0){let b=u<0?p.length+u:y+u;m=p.slice(y,Math.max(y,b))}else m=p.slice(y)}let d="";for(let y=0;y<i;y++)d+=await r(e,s.parts[y]);let g="";for(let y=i+1;y<s.parts.length;y++)g+=await r(e,s.parts[y]);if(m.length===0){let y=d+g;return{values:y?[y]:[],quoted:!0}}if(a){let y=fe(e.state.env);return{values:[d+m.join(y)+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 H2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a=!1;for(let w=0;w<s.parts.length;w++){let y=s.parts[w];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternReplacement"){i=w,a=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=B2(e),u="";for(let w=0;w<i;w++)u+=await n(e,s.parts[w]);let f="";for(let w=i+1;w<s.parts.length;w++)f+=await n(e,s.parts[w]);if(c.length===0){let w=u+f;return{values:w?[w]:[],quoted:!0}}let p="";if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")p+=me(w.pattern,!0,e.state.shoptOptions.extglob);else if(w.type==="Literal")p+=me(w.value,!0,e.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")p+=xe(w.value);else if(w.type==="DoubleQuoted"){let y=await r(e,w.parts);p+=xe(y)}else if(w.type==="ParameterExpansion"){let y=await n(e,w);p+=me(y,!0,e.state.shoptOptions.extglob)}else{let y=await n(e,w);p+=xe(y)}let h=l.replacement?await r(e,l.replacement.parts):"",m=p;l.anchor==="start"?m=`^${p}`:l.anchor==="end"&&(m=`${p}$`);let d=[];try{let w=V(m,l.all?"g":"");for(let y of c)d.push(w.replace(y,h))}catch{d.push(...c)}if(a){let w=fe(e.state.env);return{values:[u+d.join(w)+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 j2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a=!1;for(let g=0;g<s.parts.length;g++){let w=s.parts[g];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternRemoval"){i=g,a=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=B2(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 p="",h=e.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")p+=me(g.pattern,l.greedy,h);else if(g.type==="Literal")p+=me(g.value,l.greedy,h);else if(g.type==="SingleQuoted"||g.type==="Escaped")p+=xe(g.value);else if(g.type==="DoubleQuoted"){let w=await r(e,g.parts);p+=xe(w)}else if(g.type==="ParameterExpansion"){let w=await n(e,g);p+=me(w,l.greedy,h)}else{let w=await n(e,g);p+=xe(w)}let m=[];for(let g of c)m.push($n(g,p,l.side,l.greedy));if(a){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 G2(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0],s=-1,i=!1;for(let p=0;p<r.parts.length;p++){let h=r.parts[p];if(h.type==="ParameterExpansion"&&(h.parameter==="@"||h.parameter==="*")){s=p,i=h.parameter==="*";break}}if(s===-1)return null;let a=r.parts[s];if(a.type==="ParameterExpansion"&&a.operation)return null;let o=Number.parseInt(e.state.env.get("#")||"0",10),l="";for(let p=0;p<s;p++)l+=await n(e,r.parts[p]);let c="";for(let p=s+1;p<r.parts.length;p++)c+=await n(e,r.parts[p]);if(o===0){if(i)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}let u=[];for(let p=1;p<=o;p++)u.push(e.state.env.get(String(p))||"");if(i){let p=fe(e.state.env);return{values:[l+u.join(p)+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 V2=I(()=>{"use strict";Me();jt();jr();Gr();cr()});function Ox(e){return new Un(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 ia(e,t){if(e.state.options.noglob)return t;let n=Ox(e),r=[];for(let s of t)if(xn(s,e.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new fn(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function q2(e,t,n,r){let s=-1,i="",a=!1;for(let y=0;y<t.length;y++){let b=t[y];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let x=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(x){s=y,i=x[1],a=x[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=oe(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="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=me(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")f+=me(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=xe(y.value);else if(y.type==="DoubleQuoted"){let b=await n(e,y.parts);f+=xe(b)}else if(y.type==="ParameterExpansion"){let b=await r(e,y);f+=me(b,!0,e.state.shoptOptions.extglob)}else{let b=await r(e,y);f+=xe(b)}let p=l.replacement?await n(e,l.replacement.parts):"",h=f;l.anchor==="start"?h=`^${f}`:l.anchor==="end"&&(h=`${f}$`);let m=[];try{let y=V(h,l.all?"g":"");for(let b of u)m.push(y.replace(b,p))}catch{m.push(...u)}let d=rt(e.state.env),g=ft(e.state.env);if(a){let y=fe(e.state.env),b=m.join(y);return g?{values:b?[b]:[],quoted:!1}:{values:_e(b,d),quoted:!1}}if(g)return{values:m,quoted:!1};let w=[];for(let y of m)y===""?w.push(""):w.push(..._e(y,d));return{values:w,quoted:!1}}async function Z2(e,t,n,r){let s=-1,i="",a=!1;for(let w=0;w<t.length;w++){let y=t[w];if(y.type==="ParameterExpansion"&&y.operation?.type==="PatternRemoval"){let b=y.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=w,i=b[1],a=b[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=oe(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="",p=e.state.shoptOptions.extglob;if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")f+=me(w.pattern,l.greedy,p);else if(w.type==="Literal")f+=me(w.value,l.greedy,p);else if(w.type==="SingleQuoted"||w.type==="Escaped")f+=xe(w.value);else if(w.type==="DoubleQuoted"){let y=await n(e,w.parts);f+=xe(y)}else if(w.type==="ParameterExpansion"){let y=await r(e,w);f+=me(y,l.greedy,p)}else{let y=await r(e,w);f+=xe(y)}let h=[];for(let w of u)h.push($n(w,f,l.side,l.greedy));let m=rt(e.state.env),d=ft(e.state.env);if(a){let w=fe(e.state.env),y=h.join(w);return d?{values:y?[y]:[],quoted:!1}:{values:_e(y,m),quoted:!1}}if(d)return{values:h,quoted:!1};let g=[];for(let w of h)w===""?g.push(""):g.push(..._e(w,m));return{values:g,quoted:!1}}async function K2(e,t,n,r){let s=-1,i=!1;for(let g=0;g<t.length;g++){let w=t[g];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternRemoval"){s=g,i=w.parameter==="*";break}}if(s===-1)return null;let o=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(o.pattern)for(let g of o.pattern.parts)if(g.type==="Glob")u+=me(g.pattern,o.greedy,f);else if(g.type==="Literal")u+=me(g.value,o.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=xe(g.value);else if(g.type==="DoubleQuoted"){let w=await n(e,g.parts);u+=xe(w)}else if(g.type==="ParameterExpansion"){let w=await r(e,g);u+=me(w,o.greedy,f)}else{let w=await r(e,g);u+=xe(w)}let p=[];for(let g of c)p.push($n(g,u,o.side,o.greedy));let h=rt(e.state.env),m=ft(e.state.env);if(i){let g=fe(e.state.env),w=p.join(g);return m?{values:w?[w]:[],quoted:!1}:{values:_e(w,h),quoted:!1}}if(m)return{values:p,quoted:!1};let d=[];for(let g of p)g===""?d.push(""):d.push(..._e(g,h));return{values:d,quoted:!1}}async function Q2(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 o=t[s].operation,l=o.offset?await n(e,o.offset.expression):0,c=o.length?await n(e,o.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 p=e.state.env.get("0")||"bash",h;if(l<=0){let b=[p,...f],x=b.length+l;if(x<0)h=[];else{let S=l<0?x:0;if(c!==void 0){let $=c<0?b.length+c:S+c;h=b.slice(S,Math.max(S,$))}else h=b.slice(S)}}else{let b=l-1;if(b>=f.length)h=[];else if(c!==void 0){let x=c<0?f.length+c:b+c;h=f.slice(b,Math.max(b,x))}else h=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=rt(e.state.env),w=ft(e.state.env);if(h.length===0){let b=m+d;return b?w?{values:[b],quoted:!1}:{values:_e(b,g),quoted:!1}:{values:[],quoted:!1}}let y;if(i){let b=fe(e.state.env),x=m+h.join(b)+d;w?y=x?[x]:[]:y=_e(x,g)}else if(w)h.length===1?y=[m+h[0]+d]:y=[m+h[0],...h.slice(1,-1),h[h.length-1]+d];else{y=[];for(let b=0;b<h.length;b++){let x=h[b];if(b===0&&(x=m+x),b===h.length-1&&(x=x+d),x==="")y.push("");else{let S=_e(x,g);y.push(...S)}}}return{values:await ia(e,y),quoted:!1}}async function X2(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=rt(e.state.env),a=ft(e.state.env),o=Yi(e.state.env),l;if(n)if(a)l=s.filter(c=>c!=="");else{let c=fe(e.state.env),u=s.join(c);l=_e(u,i)}else if(a)l=s.filter(c=>c!=="");else if(o){l=[];for(let c of s){if(c==="")continue;let u=_e(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=_e(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await ia(e,l),quoted:!1}}async function Y2(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=oe(e,r),a;if(i.length===0){let f=e.state.env.get(r);if(f!==void 0)a=[f];else return{values:[],quoted:!1}}else a=i.map(([,f])=>f);let o=rt(e.state.env),l=ft(e.state.env),c=Yi(e.state.env),u;if(s)if(l)u=a.filter(f=>f!=="");else{let f=fe(e.state.env),p=a.join(f);u=_e(p,o)}else if(l)u=a.filter(f=>f!=="");else if(c){u=[];for(let f of a){if(f==="")continue;let p=_e(f,o);u.push(...p)}}else{u=[];for(let f of a)if(f==="")u.push("");else{let p=_e(f,o);u.push(...p)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await ia(e,u),quoted:!1}}function J2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=Vr(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=rt(e.state.env),i=ft(e.state.env),a;if(n.star)if(i)a=r;else{let o=fe(e.state.env),l=r.join(o);a=_e(l,s)}else if(i)a=r;else{a=[];for(let o of r){let l=_e(o,s);a.push(...l)}}return{values:a,quoted:!1}}function eg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="ArrayKeys")return null;let n=t[0].operation,s=oe(e,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=rt(e.state.env),a=ft(e.state.env),o;if(n.star)if(a)o=s;else{let l=fe(e.state.env),c=s.join(l);o=_e(c,i)}else if(a)o=s;else{o=[];for(let l of s){let c=_e(l,i);o.push(...c)}}return{values:o,quoted:!1}}async function tg(e,t,n){let r=-1;for(let p=0;p<t.length;p++){let h=t[p];if(h.type==="ParameterExpansion"&&(h.parameter==="@"||h.parameter==="*")&&!h.operation){r=p;break}}if(r===-1||t.length<=1)return null;let s=Number.parseInt(e.state.env.get("#")||"0",10),i=[];for(let p=1;p<=s;p++)i.push(e.state.env.get(String(p))||"");let a="";for(let p=0;p<r;p++)a+=await n(e,t[p]);let o="";for(let p=r+1;p<t.length;p++)o+=await n(e,t[p]);let l=rt(e.state.env),c=ft(e.state.env),u=Yi(e.state.env);if(s===0){let p=a+o;return{values:p?[p]:[],quoted:!1}}let f;{let p=[];for(let h=0;h<i.length;h++){let m=i[h];h===0&&(m=a+m),h===i.length-1&&(m=m+o),p.push(m)}if(c)f=p.filter(h=>h!=="");else if(u){f=[];for(let h of p){if(h==="")continue;let m=_e(h,l);f.push(...m)}}else{f=[];for(let h of p)if(h==="")f.push("");else{let m=_e(h,l);f.push(...m)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await ia(e,f),quoted:!1}}var ng=I(()=>{"use strict";Me();Ki();ye();jt();jr();Hr();Gr();cr();Dt()});async function ig(e,t,n){e.coverage?.hit("bash:expansion:word_glob");let r=t.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:a,hasArrayAtExpansion:o,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=vs(r),p=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(p&&p.length>1)return Rx(e,p,s);let h=await Tx(e,r,o,c,u,n);if(h!==null)return h;let m=await Dx(e,r,n);if(m!==null)return m;let d=await _x(e,r,n);if(d!==null)return d;let g=await Fx(e,r,n.expandPart);if(g!==null)return sg(e,g);if((i||a||l)&&!ft(e.state.env)){let y=rt(e.state.env),b=n.buildIfsCharClassPattern(y),x=await n.smartWordSplit(e,r,y,b,n.expandPart);return sg(e,x)}let w=await n.expandWordAsync(e,t);return Mx(e,t,r,w,s,n.expandWordForGlobbing)}async function Rx(e,t,n){let r=[];for(let s of t)if(!(!n&&s===""))if(!n&&!e.state.options.noglob&&xn(s,e.state.shoptOptions.extglob)){let i=await aa(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function Tx(e,t,n,r,s,i){if(n){let a=D2(e,t);if(a!==null)return a}{let a=_2(e,t);if(a!==null)return a}{let a=await v2(e,t);if(a!==null)return a}{let a=await I2(e,t,n,i.expandPart,i.expandWordPartsAsync);if(a!==null)return a}{let a=await $2(e,t,n,i.expandPart);if(a!==null)return a}{let a=await R2(e,t,i.evaluateArithmetic);if(a!==null)return a}{let a=T2(e,t);if(a!==null)return a}{let a=await C2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}{let a=await N2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let a=Px(e,t);if(a!==null)return a}{let a=await F2(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(a!==null)return a}{let a=await M2(e,t);if(a!==null)return a}{let a=await U2(e,t);if(a!==null)return a}return null}function Px(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=Vr(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=oe(e,r.array).map(([a])=>String(a));return r.star?{values:[i.join(fe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function Dx(e,t,n){{let r=await z2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await H2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await j2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await G2(e,t,n.expandPart);if(r!==null)return r}return null}async function _x(e,t,n){{let r=await q2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Z2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await K2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Q2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await X2(e,t);if(r!==null)return r}{let r=await Y2(e,t);if(r!==null)return r}{let r=J2(e,t);if(r!==null)return r}{let r=eg(e,t);if(r!==null)return r}{let r=await tg(e,t,n.expandPart);if(r!==null)return r}return null}function rg(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 Lx(e,t,n,r){let s="";for(let o=0;o<n.atIndex;o++)s+=await r(e,t.parts[o]);let i="";for(let o=n.atIndex+1;o<t.parts.length;o++)i+=await r(e,t.parts[o]);let a;if(n.type==="array"){if(a=oe(e,n.name).map(([,l])=>l),a.length===0){let l=e.state.env.get(n.name);l!==void 0&&(a=[l])}}else{let o=Number.parseInt(e.state.env.get("#")||"0",10);a=[];for(let l=1;l<=o;l++)a.push(e.state.env.get(String(l))||"")}if(n.isStar){let o=fe(e.state.env),l=a.join(o);return[s+l+i]}if(a.length===0){let o=s+i;return o?[o]:[]}return a.length===1?[s+a[0]+i]:[s+a[0],...a.slice(1,-1),a[a.length-1]+i]}async function Fx(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(rg(l)){r=!0;break}if(!r)return null;let s=rt(e.state.env),i=ft(e.state.env),a=[];for(let l of t){let c=rg(l);if(c&&l.type==="DoubleQuoted"){let u=await Lx(e,l,c,n);a.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(e,l);a.push([u])}else if(l.type==="Literal")a.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(e,l);if(i)a.push(u?[u]:[]);else{let f=_e(u,s);a.push(f)}}else{let u=await n(e,l);if(i)a.push(u?[u]:[]);else{let f=_e(u,s);a.push(f)}}}let o=[];for(let l of a)if(l.length!==0)if(o.length===0)o.push(...l);else{let c=o.length-1;o[c]=o[c]+l[0];for(let u=1;u<l.length;u++)o.push(l[u])}return o}async function sg(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(xn(r,e.state.shoptOptions.extglob)){let s=await aa(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function aa(e,t){let n=new Un(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 fn(t);return n.hasNullglob()?[]:[t]}async function Mx(e,t,n,r,s,i){let a=n.some(o=>o.type==="Glob");if(!e.state.options.noglob&&a){let o=await i(e,t);if(xn(o,e.state.shoptOptions.extglob)){let c=await aa(e,o);if(c.length>0&&c[0]!==o)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=lc(r);if(!ft(e.state.env)){let c=rt(e.state.env);return{values:_e(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!e.state.options.noglob&&xn(r,e.state.shoptOptions.extglob)){let o=await i(e,t);if(xn(o,e.state.shoptOptions.extglob)){let l=await aa(e,o);if(l.length>0&&l[0]!==o)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(a&&!s){let o=lc(r);if(!ft(e.state.env)){let l=rt(e.state.env);return{values:_e(o,l),quoted:!1}}return{values:[o],quoted:!1}}return{values:[r],quoted:s}}var ag=I(()=>{"use strict";Ki();ye();jt();Qi();k2();O2();P2();L2();Hr();W2();cr();V2();ng();Dt()});async function lg(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 bn(e,t.parameter),a=await Se(e,t.parameter,!1)==="",o=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(o&&a):l=!s||o&&a,l?r.parts:null}function Ux(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function Wx(e,t){if(t.type!=="ParameterExpansion")return null;let n=await lg(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>Ux(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function Bx(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?tc(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&Gm(e))}async function cg(e,t,n,r,s){if(e.coverage?.hit("bash:expansion:word_split"),t.length===1&&t[0].type==="ParameterExpansion"){let p=t[0],h=await lg(e,p);if(h&&h.length>0&&h.length>1&&h.some(d=>d.type==="DoubleQuoted"||d.type==="SingleQuoted")&&h.some(d=>d.type==="Literal"||d.type==="ParameterExpansion"||d.type==="CommandSubstitution"||d.type==="ArithmeticExpansion"))return og(e,h,n,r,s)}let i=[],a=!1;for(let p of t){let h=Bx(p),m=p.type==="DoubleQuoted"||p.type==="SingleQuoted",d=h?await Wx(e,p):null,g=await s(e,p);i.push({value:g,isSplittable:h,isQuoted:m,mixedDefaultParts:d??void 0}),h&&(a=!0)}if(!a){let p=i.map(h=>h.value).join("");return p?[p]:[]}let o=[],l="",c=!1,u=!1,f=!1;for(let p of i)if(!p.isSplittable)u?p.isQuoted&&p.value===""?(l!==""&&o.push(l),o.push(""),c=!0,l="",u=!1,f=!0):p.value!==""?(l!==""&&o.push(l),l=p.value,u=!1,f=!1):(l+=p.value,f=!1):(l+=p.value,f=p.isQuoted&&p.value==="");else if(p.mixedDefaultParts){let h=await og(e,p.mixedDefaultParts,n,r,s);if(h.length!==0)if(h.length===1)l+=h[0],c=!0;else{l+=h[0],o.push(l),c=!0;for(let m=1;m<h.length-1;m++)o.push(h[m]);l=h[h.length-1]}u=!1,f=!1}else{let{words:h,hadLeadingDelimiter:m,hadTrailingDelimiter:d}=Ji(p.value,n);if(f&&m&&l===""&&(o.push(""),c=!0),h.length===0)d&&(u=!0);else if(h.length===1)l+=h[0],c=!0,u=d;else{l+=h[0],o.push(l),c=!0;for(let g=1;g<h.length-1;g++)o.push(h[g]);l=h[h.length-1],u=d}f=!1}return l!==""?o.push(l):o.length===0&&c&&o.push(""),o}function zx(e,t){return e.length>0&&t.includes(e[0])}async function og(e,t,n,r,s){let i=[];for(let u of t){let p=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),h=await s(e,u);i.push({value:h,isSplittable:p})}let a=[],o="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(o!==""&&a.push(o),o=u.value,c=!1):o+=u.value;else{zx(u.value,n)&&o!==""&&(a.push(o),o="",l=!0);let{words:p,hadTrailingDelimiter:h}=Ji(u.value,n);if(p.length===0)h&&(c=!0);else if(p.length===1)o+=p[0],l=!0,c=h;else{o+=p[0],a.push(o),l=!0;for(let m=1;m<p.length-1;m++)a.push(p[m]);o=p[p.length-1],c=h}}return o!==""?a.push(o):a.length===0&&l&&a.push(""),a}var ug=I(()=>{"use strict";Dt();jt();Qi()});function fg(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function pg(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var hg=I(()=>{"use strict"});var yc={};K(yc,{escapeGlobChars:()=>_t,escapeRegexChars:()=>zr,expandRedirectTarget:()=>Rs,expandWord:()=>ie,expandWordForPattern:()=>mc,expandWordForRegex:()=>dc,expandWordWithGlob:()=>cn,getArrayElements:()=>oe,getVariable:()=>Se,hasQuotedMultiValueAt:()=>Os,isArray:()=>In,isWordFullyQuoted:()=>hc});function $s(e,t,n){if(e.length>t)throw new te(`${n}: string length limit exceeded (${t} bytes)`,"string_length")}async function ln(e,t,n=!1){let r=[];for(let s of t)r.push(await Gt(e,s,n));return r.join("")}function Hx(e){return pg(e)}function hc(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!Hx(t))return!1;return!0}function jx(e,t,n=!1){let r=fg(t);if(r!==null)return r;switch(t.type){case"TildeExpansion":return n?t.user===null?"~":`~${t.user}`:(e.coverage?.hit("bash:expansion:tilde"),t.user===null?e.state.env.get("HOME")??"/home/user":t.user==="root"?"/root":`~${t.user}`);case"Glob":return fc(e,t.pattern);default:return null}}async function ie(e,t){return gc(e,t)}async function dc(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 ln(e,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await Gt(e,r);n.push(zr(s))}else n.push(await Gt(e,r));return n.join("")}async function mc(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 ln(e,r.parts);n.push(_t(s))}else n.push(await Gt(e,r));return n.join("")}async function dg(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 ln(e,r.parts);n.push(_t(s))}else r.type==="Glob"?w2(r.pattern)?n.push(await x2(e,r.pattern)):n.push(fc(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await Gt(e,r));return n.join("")}function la(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&la(t.parts))return!0;return!1}async function mg(e,t,n={count:0}){if(n.count>pc)return[[]];let r=[[]];for(let s of t)if(s.type==="BraceExpansion"){let i=[],a=!1,o="";for(let u of s.items)if(u.type==="Range"){let f=oc(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let p of f.expanded)n.count++,i.push(p);else{a=!0,o=f.literal;break}}else{let f=await mg(e,u.word.parts,n);for(let p of f){n.count++;let h=[];for(let m of p)typeof m=="string"?h.push(m):h.push(await Gt(e,m));i.push(h.join(""))}}if(a){for(let u of r)n.count++,u.push(o);continue}if(r.length*i.length>Gx||n.count>pc)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>pc)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 gg(e,t){let n=t.parts;if(!la(n))return[await ie(e,t)];let r=await mg(e,n),s=[];for(let i of r){let a=[];for(let o of i)typeof o=="string"?a.push(o):a.push(await Gt(e,o));s.push(A2(e,a.join("")))}return s}function Vx(){return{expandWordAsync:gc,expandWordForGlobbing:dg,expandWordWithBracesAsync:gg,expandWordPartsAsync:ln,expandPart:Gt,expandParameterAsync:oa,hasBraceExpansion:la,evaluateArithmetic:ne,buildIfsCharClassPattern:Vm,smartWordSplit:cg}}async function cn(e,t){return ig(e,t,Vx())}function qx(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function Os(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 a of i.parts)if(a.type==="ParameterExpansion"&&a.parameter==="@"&&!a.operation)return!0}return!1}return r(t.parts)}async function Rs(e,t){if(Os(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?"":Wn(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 h2(e,t,n,r,s,i,a=!1){if(e.coverage?.hit("bash:expansion:indirection"),Te(e,t))return lr(e,t)||"";let o=/^[a-zA-Z_][a-zA-Z0-9_]*\[([@*])\]$/.test(t);if(r){if(s.innerOp?.type==="UseAlternative")return"";throw new wt(`\${!${t}}`)}let l=n;if(o&&(l===""||l.includes(" ")))throw new wt(`\${!${t}}`);let c=l.match(/^[a-zA-Z_][a-zA-Z0-9_]*\[(.+)\]$/);if(c&&c[1].includes("~"))throw new wt(`\${!${t}}`);if(s.innerOp){let u={type:"ParameterExpansion",parameter:l,operation:s.innerOp};return i(e,u,a)}return await Se(e,l)}function d2(e,t){e.coverage?.hit("bash:expansion:array_keys");let r=oe(e,t.array).map(([s])=>String(s));return t.star?r.join(fe(e.state.env)):r.join(" ")}function m2(e,t){e.coverage?.hit("bash:expansion:var_name_prefix");let n=Vr(e,t.prefix);return t.star?n.join(fe(e.state.env)):n.join(" ")}function g2(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[,a,o]=i,l=oe(e,a);if(l.length===0)return{isEmpty:!0,effectiveValue:""};if(o==="*"){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 y2=I(()=>{"use strict";dt();Xe();Me();St();ye();jt();an();jr();Gr();cr();cc();uc();Dt();ra()});function w2(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 b2(e,t){let n=1,r=t,s=!1,i=!1;for(;r<e.length&&n>0;){let a=e[r];if(a==="\\"&&!s&&r+1<e.length){r+=2;continue}if(a==="'"&&!i){s=!s,r++;continue}if(a==='"'&&!s){i=!i,r++;continue}if(!s&&!i){if(a==="(")n++;else if(a===")"&&(n--,n===0))return r}r++}return-1}async function sa(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),a=e.state.cwd,o=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=a,e.state.suppressVerbose=o,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=a,e.state.bashPid=s,e.state.suppressVerbose=o,l instanceof te)throw l;return l instanceof pe?(e.state.lastExitCode=l.exitCode,e.state.env.set("?",String(l.exitCode)),l.stdout?.replace(/\n+$/,"")??""):""}}function fc(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 a=t.slice(r+1,i);n+=_t(a),r=i+1;continue}}if(s==='"'){let i=-1,a=r+1;for(;a<t.length;){if(t[a]==="\\"){a+=2;continue}if(t[a]==='"'){i=a;break}a++}if(i!==-1){let o=t.slice(r+1,i),l=Cx(e,o);n+=_t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}function Cx(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 a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}n+=s,r++}return n}async function x2(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 a=t.slice(r+1,i);n+=_t(a),r=i+1;continue}}if(s==='"'){let i=-1,a=r+1;for(;a<t.length;){if(t[a]==="\\"){a+=2;continue}if(t[a]==='"'){i=a;break}a++}if(i!==-1){let o=t.slice(r+1,i),l=await Nx(e,o);n+=_t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=b2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=t.slice(r+1,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}if(s==="\\"&&r+1<t.length){n+=s+t[r+1],r+=2;continue}n+=s,r++}return n}async function Nx(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=b2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="`"){let i=t.indexOf("`",r+1);if(i!==-1){let a=t.slice(r+1,i),o=await sa(e,a);n+=o,r=i+1;continue}}if(s==="$"&&r+1<t.length){let i=t[r+1];if(i==="{"){let a=t.indexOf("}",r+2);if(a!==-1){let o=t.slice(r+2,a);n+=e.state.env.get(o)??"",r=a+1;continue}}else if(/[a-zA-Z_]/.test(i)){let a=r+1;for(;a<t.length&&/[a-zA-Z0-9_]/.test(t[a]);)a++;let o=t.slice(r+1,a);n+=e.state.env.get(o)??"",r=a;continue}}n+=s,r++}return n}var E2=I(()=>{"use strict";Xe();ye();Hr()});function A2(e,t){if(!t.startsWith("~"))return t;e.coverage?.hit("bash:expansion:tilde");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 S2=I(()=>{"use strict"});async function kx(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+=xe(i.value);else if(i.type==="DoubleQuoted"){let a=await n(e,i.parts);s+=xe(a)}else if(i.type==="ParameterExpansion"){let a=await r(e,i);s+=me(a,!0,e.state.shoptOptions.extglob)}else{let a=await r(e,i);s+=xe(a)}return s}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!=="PatternReplacement")return null;let i=s.parts[0],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],l=a[2]==="*",c=i.operation,u=oe(e,o),f=u.map(([,g])=>g);if(u.length===0){let g=e.state.env.get(o);g!==void 0&&f.push(g)}if(f.length===0)return{values:[],quoted:!0};let p="";c.pattern&&(p=await kx(e,c.pattern,n,r));let h=c.replacement?await n(e,c.replacement.parts):"",m=p;c.anchor==="start"?m=`^${p}`:c.anchor==="end"&&(m=`${p}$`);let d=[];try{let g=V(m,c.all?"g":"");for(let w of f)d.push(g.replace(w,h))}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 N2(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],a=i.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!a)return null;let o=a[1],l=a[2]==="*",c=i.operation,u=oe(e,o),f=u.map(([,d])=>d);if(u.length===0){let d=e.state.env.get(o);d!==void 0&&f.push(d)}if(f.length===0)return{values:[],quoted:!0};let p="",h=e.state.shoptOptions.extglob;if(c.pattern)for(let d of c.pattern.parts)if(d.type==="Glob")p+=me(d.pattern,c.greedy,h);else if(d.type==="Literal")p+=me(d.value,c.greedy,h);else if(d.type==="SingleQuoted"||d.type==="Escaped")p+=xe(d.value);else if(d.type==="DoubleQuoted"){let g=await n(e,d.parts);p+=xe(g)}else if(d.type==="ParameterExpansion"){let g=await r(e,d);p+=me(g,c.greedy,h)}else{let g=await r(e,d);p+=xe(g)}let m=[];for(let d of f)m.push($n(d,p,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 k2=I(()=>{"use strict";Me();jt();jr();Gr();cr();Dt()});async function v2(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_]*)\[([@*])\]$/),a,o=!1;if(i){let l=i[1];o=i[2]==="*";let c=oe(e,l),u=c.length>0||e.state.env.has(l),f=c.length===0||c.length===1&&c.every(([,h])=>h===""),p=s.checkEmpty??!1;if(s.type==="UseAlternative"?a=u&&!(p&&f):a=!u||p&&f,!a){if(c.length>0){let m=c.map(([,d])=>d);if(o){let d=fe(e.state.env);return{values:[m.join(d)],quoted:!0}}return{values:m,quoted:!0}}let h=e.state.env.get(l);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}}else{let l=r.parameter,c=await bn(e,l),u=await Se(e,l),f=u==="",p=s.checkEmpty??!1;if(s.type==="UseAlternative"?a=c&&!(p&&f):a=!c||p&&f,!a)return{values:[u],quoted:!0}}if(a&&s.word){let l=s.word.parts,c=null,u=!1;for(let f of l)if(f.type==="ParameterExpansion"&&!f.operation){let p=f.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(p){c=p[1],u=p[2]==="*";break}}if(c){let f=oe(e,c);if(f.length>0){let h=f.map(([,m])=>m);if(u||o){let m=fe(e.state.env);return{values:[h.join(m)],quoted:!0}}return{values:h,quoted:!0}}let p=e.state.env.get(c);return p!==void 0?{values:[p],quoted:!0}:{values:[],quoted:!0}}}return null}async function I2(e,t,n,r,s){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let i=t[0],a=-1,o="",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 w=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(w){a=d,o=w[1],l=w[2]==="*",c=g.operation;break}}}if(a===-1||a===0&&a===i.parts.length-1)return null;let u="";for(let d=0;d<a;d++)u+=await r(e,i.parts[d]);let f="";for(let d=a+1;d<i.parts.length;d++)f+=await r(e,i.parts[d]);let p=oe(e,o),h=p.map(([,d])=>d);if(p.length===0){let d=e.state.env.get(o);if(d!==void 0)h=[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="",w=e.state.shoptOptions.extglob;if(d.pattern)for(let y of d.pattern.parts)if(y.type==="Glob")g+=me(y.pattern,d.greedy,w);else if(y.type==="Literal")g+=me(y.value,d.greedy,w);else if(y.type==="SingleQuoted"||y.type==="Escaped")g+=xe(y.value);else if(y.type==="DoubleQuoted"){let b=await s(e,y.parts);g+=xe(b)}else if(y.type==="ParameterExpansion"){let b=await r(e,y);g+=me(b,d.greedy,w)}else{let b=await r(e,y);g+=xe(b)}h=h.map(y=>$n(y,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+=xe(b.value);else if(b.type==="DoubleQuoted"){let x=await s(e,b.parts);g+=xe(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+=xe(x)}let w=d.replacement?await s(e,d.replacement.parts):"",y=g;d.anchor==="start"?y=`^${g}`:d.anchor==="end"&&(y=`${g}$`);try{let b=V(y,d.all?"g":"");h=h.map(x=>b.replace(x,w))}catch{}}if(l){let d=fe(e.state.env);return{values:[u+h.join(d)+f],quoted:!0}}return h.length===1?{values:[u+h[0]+f],quoted:!0}:{values:[u+h[0],...h.slice(1,-1),h[h.length-1]+f],quoted:!0}}async function $2(e,t,n,r){if(!n||t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a="",o=!1;for(let h=0;h<s.parts.length;h++){let m=s.parts[h];if(m.type==="ParameterExpansion"&&!m.operation){let d=m.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(d){i=h,a=d[1],o=d[2]==="*";break}}}if(i===-1)return null;let l="";for(let h=0;h<i;h++)l+=await r(e,s.parts[h]);let c="";for(let h=i+1;h<s.parts.length;h++)c+=await r(e,s.parts[h]);let u=oe(e,a),f=u.map(([,h])=>h);if(u.length===0){let h=e.state.env.get(a);if(h!==void 0)return{values:[l+h+c],quoted:!0};if(o)return{values:[l+c],quoted:!0};let m=l+c;return{values:m?[m]:[],quoted:!0}}if(o){let h=fe(e.state.env);return{values:[l+f.join(h)+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 O2=I(()=>{"use strict";Me();jt();jr();Gr();cr();Dt()});async function R2(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 a=i[1],o=i[2]==="*",l=s.operation;if(e.state.associativeArrays?.has(a))throw new pe(1,"",`bash: \${${a}[@]: 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=oe(e,a),p=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};p=f.findIndex(([w])=>typeof w=="number"&&w>=g),p<0&&(p=f.length)}}else p=f.findIndex(([m])=>typeof m=="number"&&m>=c),p<0&&(p=f.length);let h;if(u!==void 0){if(u<0)throw new Re(`${a}[@]: substring expression < 0`);h=f.slice(p,p+u).map(([,m])=>m)}else h=f.slice(p).map(([,m])=>m);if(h.length===0)return{values:[],quoted:!0};if(o){let m=fe(e.state.env);return{values:[h.join(m)],quoted:!0}}return{values:h,quoted:!0}}function T2(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],a=s[2]==="*",o=r.operation,l=oe(e,i);if(l.length===0){let f=e.state.env.get(i);if(f!==void 0){let p;switch(o.operator){case"a":p="";break;case"P":p=Is(e,f);break;case"Q":p=Wn(f);break;default:p=f}return{values:[p],quoted:!0}}return a?{values:[""],quoted:!0}:{values:[],quoted:!0}}let c=zn(e,i),u;switch(o.operator){case"a":u=l.map(()=>c);break;case"P":u=l.map(([,f])=>Is(e,f));break;case"Q":u=l.map(([,f])=>Wn(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(a){let f=fe(e.state.env);return{values:[u.join(f)],quoted:!0}}return{values:u,quoted:!0}}var P2=I(()=>{"use strict";ye();jt();cc();uc();Dt();ra()});function D2(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=lr(e,i);if(l?.endsWith("[@]")||l?.endsWith("[*]"))return{values:[],quoted:!0}}let a=oe(e,i);if(a.length>0)return{values:a.map(([,l])=>l),quoted:!0};let o=e.state.env.get(i);return o!==void 0?{values:[o],quoted:!0}:{values:[],quoted:!0}}function _2(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=lr(e,s);if(!i)return null;let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(@)\]$/);if(!a)return null;let o=a[1],l=oe(e,o);if(l.length>0)return{values:l.map(([,u])=>u),quoted:!0};let c=e.state.env.get(o);return c!==void 0?{values:[c],quoted:!0}:{values:[],quoted:!0}}var L2=I(()=>{"use strict";an();Dt()});async function F2(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 a=i.parts[0],o=a.operation,l=await Se(e,a.parameter),c=l.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c){if(!o.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]==="*",p=oe(e,u);if(o.innerOp){if(o.innerOp.type==="Substring")return vx(e,p,u,f,o.innerOp);if(o.innerOp.type==="DefaultValue"||o.innerOp.type==="UseAlternative"||o.innerOp.type==="AssignDefault"||o.innerOp.type==="ErrorIfUnset")return Ix(e,p,u,f,o.innerOp,s);if(o.innerOp.type==="Transform"&&o.innerOp.operator==="a"){let d=zn(e,u),g=p.map(()=>d);return f?{values:[g.join(fe(e.state.env))],quoted:!0}:{values:g,quoted:!0}}let m=[];for(let[,d]of p){let g={type:"ParameterExpansion",parameter:"_indirect_elem_",operation:o.innerOp},w=e.state.env.get("_indirect_elem_");e.state.env.set("_indirect_elem_",d);try{let y=await r(e,g,!0);m.push(y)}finally{w!==void 0?e.state.env.set("_indirect_elem_",w):e.state.env.delete("_indirect_elem_")}}return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(p.length>0){let m=p.map(([,d])=>d);return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}let h=e.state.env.get(u);return h!==void 0?{values:[h],quoted:!0}:{values:[],quoted:!0}}async function vx(e,t,n,r,s){let i=s.offset?await ne(e,s.offset.expression):0,a=s.length?await ne(e,s.length.expression):void 0,o=0;if(i<0){if(t.length>0){let u=t[t.length-1][0],p=(typeof u=="number"?u:0)+1+i;if(p<0)return{values:[],quoted:!0};if(o=t.findIndex(([h])=>typeof h=="number"&&h>=p),o<0)return{values:[],quoted:!0}}}else if(o=t.findIndex(([u])=>typeof u=="number"&&u>=i),o<0)return{values:[],quoted:!0};let l;if(a!==void 0){if(a<0)throw new Re(`${n}[@]: substring expression < 0`);l=t.slice(o,o+a)}else l=t.slice(o);let c=l.map(([,u])=>u);return r?{values:[c.join(fe(e.state.env))],quoted:!0}:{values:c,quoted:!0}}async function Ix(e,t,n,r,s,i){let a=s.checkEmpty??!1,o=t.map(([,u])=>u),l=t.length===0,c=t.length===0;if(s.type==="UseAlternative")return!c&&!(a&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:{values:[],quoted:!0};if(s.type==="DefaultValue")return(c||a&&l)&&s.word?{values:[await i(e,s.word.parts,!0)],quoted:!0}:r?{values:[o.join(fe(e.state.env))],quoted:!0}:{values:o,quoted:!0};if(s.type==="AssignDefault"){if((c||a&&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:[o.join(fe(e.state.env))],quoted:!0}:{values:o,quoted:!0}}return r?{values:[o.join(fe(e.state.env))],quoted:!0}:{values:o,quoted:!0}}async function M2(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 a=i.parts[0],l=(await Se(e,a.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!l)return null;let c=await bn(e,n.parameter),u=await Se(e,n.parameter)==="",f=r.checkEmpty??!1,p;if(r.type==="UseAlternative"?p=c&&!(f&&u):p=!c||f&&u,p){let h=l[1],m=l[2]==="*",d=oe(e,h);if(d.length>0){let w=d.map(([,y])=>y);return m?{values:[w.join(fe(e.state.env))],quoted:!0}:{values:w,quoted:!0}}let g=e.state.env.get(h);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function U2(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 a=i.parts[0];if(a.parts.length!==1||a.parts[0].type!=="ParameterExpansion"||a.parts[0].operation?.type!=="Indirection")return null;let o=a.parts[0],c=(await Se(e,o.parameter)).match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(!c)return null;let u=await Se(e,n.parameter),f=await bn(e,n.parameter),p=u==="",h=s.checkEmpty??!1,m;if(s.type==="UseAlternative"?m=f&&!(h&&p):m=!f||h&&p,m){let d=c[1],g=c[2]==="*",w=oe(e,d);if(w.length>0){let b=w.map(([,x])=>x);return g?{values:[b.join(fe(e.state.env))],quoted:!0}:{values:b,quoted:!0}}let y=e.state.env.get(d);return y!==void 0?{values:[y],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var W2=I(()=>{"use strict";St();ye();jt();Dt();ra()});function B2(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 z2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a=!1;for(let y=0;y<s.parts.length;y++){let b=s.parts[y];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=y,a=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),p=[];for(let y=1;y<=f;y++)p.push(e.state.env.get(String(y))||"");let h=e.state.env.get("0")||"bash",m;if(c<=0){let y=[h,...p],b=y.length+c;if(b<0)m=[];else{let x=c<0?b:0;if(u!==void 0){let S=u<0?y.length+u:x+u;m=y.slice(x,Math.max(x,S))}else m=y.slice(x)}}else{let y=c-1;if(y>=p.length)m=[];else if(u!==void 0){let b=u<0?p.length+u:y+u;m=p.slice(y,Math.max(y,b))}else m=p.slice(y)}let d="";for(let y=0;y<i;y++)d+=await r(e,s.parts[y]);let g="";for(let y=i+1;y<s.parts.length;y++)g+=await r(e,s.parts[y]);if(m.length===0){let y=d+g;return{values:y?[y]:[],quoted:!0}}if(a){let y=fe(e.state.env);return{values:[d+m.join(y)+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 H2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a=!1;for(let w=0;w<s.parts.length;w++){let y=s.parts[w];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternReplacement"){i=w,a=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=B2(e),u="";for(let w=0;w<i;w++)u+=await n(e,s.parts[w]);let f="";for(let w=i+1;w<s.parts.length;w++)f+=await n(e,s.parts[w]);if(c.length===0){let w=u+f;return{values:w?[w]:[],quoted:!0}}let p="";if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")p+=me(w.pattern,!0,e.state.shoptOptions.extglob);else if(w.type==="Literal")p+=me(w.value,!0,e.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")p+=xe(w.value);else if(w.type==="DoubleQuoted"){let y=await r(e,w.parts);p+=xe(y)}else if(w.type==="ParameterExpansion"){let y=await n(e,w);p+=me(y,!0,e.state.shoptOptions.extglob)}else{let y=await n(e,w);p+=xe(y)}let h=l.replacement?await r(e,l.replacement.parts):"",m=p;l.anchor==="start"?m=`^${p}`:l.anchor==="end"&&(m=`${p}$`);let d=[];try{let w=V(m,l.all?"g":"");for(let y of c)d.push(w.replace(y,h))}catch{d.push(...c)}if(a){let w=fe(e.state.env);return{values:[u+d.join(w)+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 j2(e,t,n,r){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let s=t[0],i=-1,a=!1;for(let g=0;g<s.parts.length;g++){let w=s.parts[g];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternRemoval"){i=g,a=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=B2(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 p="",h=e.state.shoptOptions.extglob;if(l.pattern)for(let g of l.pattern.parts)if(g.type==="Glob")p+=me(g.pattern,l.greedy,h);else if(g.type==="Literal")p+=me(g.value,l.greedy,h);else if(g.type==="SingleQuoted"||g.type==="Escaped")p+=xe(g.value);else if(g.type==="DoubleQuoted"){let w=await r(e,g.parts);p+=xe(w)}else if(g.type==="ParameterExpansion"){let w=await n(e,g);p+=me(w,l.greedy,h)}else{let w=await n(e,g);p+=xe(w)}let m=[];for(let g of c)m.push($n(g,p,l.side,l.greedy));if(a){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 G2(e,t,n){if(t.length!==1||t[0].type!=="DoubleQuoted")return null;let r=t[0],s=-1,i=!1;for(let p=0;p<r.parts.length;p++){let h=r.parts[p];if(h.type==="ParameterExpansion"&&(h.parameter==="@"||h.parameter==="*")){s=p,i=h.parameter==="*";break}}if(s===-1)return null;let a=r.parts[s];if(a.type==="ParameterExpansion"&&a.operation)return null;let o=Number.parseInt(e.state.env.get("#")||"0",10),l="";for(let p=0;p<s;p++)l+=await n(e,r.parts[p]);let c="";for(let p=s+1;p<r.parts.length;p++)c+=await n(e,r.parts[p]);if(o===0){if(i)return{values:[l+c],quoted:!0};let p=l+c;return{values:p?[p]:[],quoted:!0}}let u=[];for(let p=1;p<=o;p++)u.push(e.state.env.get(String(p))||"");if(i){let p=fe(e.state.env);return{values:[l+u.join(p)+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 V2=I(()=>{"use strict";Me();jt();jr();Gr();cr()});function $x(e){return new Un(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 ia(e,t){if(e.state.options.noglob)return t;let n=$x(e),r=[];for(let s of t)if(xn(s,e.state.shoptOptions.extglob)){let i=await n.expand(s);if(i.length>0)r.push(...i);else{if(n.hasFailglob())throw new fn(s);n.hasNullglob()||r.push(s)}}else r.push(s);return r}async function q2(e,t,n,r){let s=-1,i="",a=!1;for(let y=0;y<t.length;y++){let b=t[y];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let x=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(x){s=y,i=x[1],a=x[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=oe(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="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=me(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")f+=me(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=xe(y.value);else if(y.type==="DoubleQuoted"){let b=await n(e,y.parts);f+=xe(b)}else if(y.type==="ParameterExpansion"){let b=await r(e,y);f+=me(b,!0,e.state.shoptOptions.extglob)}else{let b=await r(e,y);f+=xe(b)}let p=l.replacement?await n(e,l.replacement.parts):"",h=f;l.anchor==="start"?h=`^${f}`:l.anchor==="end"&&(h=`${f}$`);let m=[];try{let y=V(h,l.all?"g":"");for(let b of u)m.push(y.replace(b,p))}catch{m.push(...u)}let d=rt(e.state.env),g=ft(e.state.env);if(a){let y=fe(e.state.env),b=m.join(y);return g?{values:b?[b]:[],quoted:!1}:{values:_e(b,d),quoted:!1}}if(g)return{values:m,quoted:!1};let w=[];for(let y of m)y===""?w.push(""):w.push(..._e(y,d));return{values:w,quoted:!1}}async function Z2(e,t,n,r){let s=-1,i="",a=!1;for(let w=0;w<t.length;w++){let y=t[w];if(y.type==="ParameterExpansion"&&y.operation?.type==="PatternRemoval"){let b=y.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=w,i=b[1],a=b[2]==="*";break}}}if(s===-1)return null;let l=t[s].operation,c=oe(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="",p=e.state.shoptOptions.extglob;if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")f+=me(w.pattern,l.greedy,p);else if(w.type==="Literal")f+=me(w.value,l.greedy,p);else if(w.type==="SingleQuoted"||w.type==="Escaped")f+=xe(w.value);else if(w.type==="DoubleQuoted"){let y=await n(e,w.parts);f+=xe(y)}else if(w.type==="ParameterExpansion"){let y=await r(e,w);f+=me(y,l.greedy,p)}else{let y=await r(e,w);f+=xe(y)}let h=[];for(let w of u)h.push($n(w,f,l.side,l.greedy));let m=rt(e.state.env),d=ft(e.state.env);if(a){let w=fe(e.state.env),y=h.join(w);return d?{values:y?[y]:[],quoted:!1}:{values:_e(y,m),quoted:!1}}if(d)return{values:h,quoted:!1};let g=[];for(let w of h)w===""?g.push(""):g.push(..._e(w,m));return{values:g,quoted:!1}}async function K2(e,t,n,r){let s=-1,i=!1;for(let g=0;g<t.length;g++){let w=t[g];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternRemoval"){s=g,i=w.parameter==="*";break}}if(s===-1)return null;let o=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(o.pattern)for(let g of o.pattern.parts)if(g.type==="Glob")u+=me(g.pattern,o.greedy,f);else if(g.type==="Literal")u+=me(g.value,o.greedy,f);else if(g.type==="SingleQuoted"||g.type==="Escaped")u+=xe(g.value);else if(g.type==="DoubleQuoted"){let w=await n(e,g.parts);u+=xe(w)}else if(g.type==="ParameterExpansion"){let w=await r(e,g);u+=me(w,o.greedy,f)}else{let w=await r(e,g);u+=xe(w)}let p=[];for(let g of c)p.push($n(g,u,o.side,o.greedy));let h=rt(e.state.env),m=ft(e.state.env);if(i){let g=fe(e.state.env),w=p.join(g);return m?{values:w?[w]:[],quoted:!1}:{values:_e(w,h),quoted:!1}}if(m)return{values:p,quoted:!1};let d=[];for(let g of p)g===""?d.push(""):d.push(..._e(g,h));return{values:d,quoted:!1}}async function Q2(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 o=t[s].operation,l=o.offset?await n(e,o.offset.expression):0,c=o.length?await n(e,o.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 p=e.state.env.get("0")||"bash",h;if(l<=0){let b=[p,...f],x=b.length+l;if(x<0)h=[];else{let S=l<0?x:0;if(c!==void 0){let $=c<0?b.length+c:S+c;h=b.slice(S,Math.max(S,$))}else h=b.slice(S)}}else{let b=l-1;if(b>=f.length)h=[];else if(c!==void 0){let x=c<0?f.length+c:b+c;h=f.slice(b,Math.max(b,x))}else h=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=rt(e.state.env),w=ft(e.state.env);if(h.length===0){let b=m+d;return b?w?{values:[b],quoted:!1}:{values:_e(b,g),quoted:!1}:{values:[],quoted:!1}}let y;if(i){let b=fe(e.state.env),x=m+h.join(b)+d;w?y=x?[x]:[]:y=_e(x,g)}else if(w)h.length===1?y=[m+h[0]+d]:y=[m+h[0],...h.slice(1,-1),h[h.length-1]+d];else{y=[];for(let b=0;b<h.length;b++){let x=h[b];if(b===0&&(x=m+x),b===h.length-1&&(x=x+d),x==="")y.push("");else{let S=_e(x,g);y.push(...S)}}}return{values:await ia(e,y),quoted:!1}}async function X2(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=rt(e.state.env),a=ft(e.state.env),o=Yi(e.state.env),l;if(n)if(a)l=s.filter(c=>c!=="");else{let c=fe(e.state.env),u=s.join(c);l=_e(u,i)}else if(a)l=s.filter(c=>c!=="");else if(o){l=[];for(let c of s){if(c==="")continue;let u=_e(c,i);l.push(...u)}}else{l=[];for(let c of s)if(c==="")l.push("");else{let u=_e(c,i);l.push(...u)}for(;l.length>0&&l[l.length-1]==="";)l.pop()}return{values:await ia(e,l),quoted:!1}}async function Y2(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=oe(e,r),a;if(i.length===0){let f=e.state.env.get(r);if(f!==void 0)a=[f];else return{values:[],quoted:!1}}else a=i.map(([,f])=>f);let o=rt(e.state.env),l=ft(e.state.env),c=Yi(e.state.env),u;if(s)if(l)u=a.filter(f=>f!=="");else{let f=fe(e.state.env),p=a.join(f);u=_e(p,o)}else if(l)u=a.filter(f=>f!=="");else if(c){u=[];for(let f of a){if(f==="")continue;let p=_e(f,o);u.push(...p)}}else{u=[];for(let f of a)if(f==="")u.push("");else{let p=_e(f,o);u.push(...p)}for(;u.length>0&&u[u.length-1]==="";)u.pop()}return{values:await ia(e,u),quoted:!1}}function J2(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=Vr(e,n.prefix);if(r.length===0)return{values:[],quoted:!1};let s=rt(e.state.env),i=ft(e.state.env),a;if(n.star)if(i)a=r;else{let o=fe(e.state.env),l=r.join(o);a=_e(l,s)}else if(i)a=r;else{a=[];for(let o of r){let l=_e(o,s);a.push(...l)}}return{values:a,quoted:!1}}function eg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="ArrayKeys")return null;let n=t[0].operation,s=oe(e,n.array).map(([l])=>String(l));if(s.length===0)return{values:[],quoted:!1};let i=rt(e.state.env),a=ft(e.state.env),o;if(n.star)if(a)o=s;else{let l=fe(e.state.env),c=s.join(l);o=_e(c,i)}else if(a)o=s;else{o=[];for(let l of s){let c=_e(l,i);o.push(...c)}}return{values:o,quoted:!1}}async function tg(e,t,n){let r=-1;for(let p=0;p<t.length;p++){let h=t[p];if(h.type==="ParameterExpansion"&&(h.parameter==="@"||h.parameter==="*")&&!h.operation){r=p;break}}if(r===-1||t.length<=1)return null;let s=Number.parseInt(e.state.env.get("#")||"0",10),i=[];for(let p=1;p<=s;p++)i.push(e.state.env.get(String(p))||"");let a="";for(let p=0;p<r;p++)a+=await n(e,t[p]);let o="";for(let p=r+1;p<t.length;p++)o+=await n(e,t[p]);let l=rt(e.state.env),c=ft(e.state.env),u=Yi(e.state.env);if(s===0){let p=a+o;return{values:p?[p]:[],quoted:!1}}let f;{let p=[];for(let h=0;h<i.length;h++){let m=i[h];h===0&&(m=a+m),h===i.length-1&&(m=m+o),p.push(m)}if(c)f=p.filter(h=>h!=="");else if(u){f=[];for(let h of p){if(h==="")continue;let m=_e(h,l);f.push(...m)}}else{f=[];for(let h of p)if(h==="")f.push("");else{let m=_e(h,l);f.push(...m)}for(;f.length>0&&f[f.length-1]==="";)f.pop()}}return f.length===0?{values:[],quoted:!1}:{values:await ia(e,f),quoted:!1}}var ng=I(()=>{"use strict";Me();Ki();ye();jt();jr();Hr();Gr();cr();Dt()});async function ig(e,t,n){e.coverage?.hit("bash:expansion:word_glob");let r=t.parts,{hasQuoted:s,hasCommandSub:i,hasArrayVar:a,hasArrayAtExpansion:o,hasParamExpansion:l,hasVarNamePrefixExpansion:c,hasIndirection:u}=vs(r),p=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(p&&p.length>1)return Ox(e,p,s);let h=await Rx(e,r,o,c,u,n);if(h!==null)return h;let m=await Px(e,r,n);if(m!==null)return m;let d=await Dx(e,r,n);if(d!==null)return d;let g=await Lx(e,r,n.expandPart);if(g!==null)return sg(e,g);if((i||a||l)&&!ft(e.state.env)){let y=rt(e.state.env),b=n.buildIfsCharClassPattern(y),x=await n.smartWordSplit(e,r,y,b,n.expandPart);return sg(e,x)}let w=await n.expandWordAsync(e,t);return Fx(e,t,r,w,s,n.expandWordForGlobbing)}async function Ox(e,t,n){let r=[];for(let s of t)if(!(!n&&s===""))if(!n&&!e.state.options.noglob&&xn(s,e.state.shoptOptions.extglob)){let i=await aa(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function Rx(e,t,n,r,s,i){if(n){let a=D2(e,t);if(a!==null)return a}{let a=_2(e,t);if(a!==null)return a}{let a=await v2(e,t);if(a!==null)return a}{let a=await I2(e,t,n,i.expandPart,i.expandWordPartsAsync);if(a!==null)return a}{let a=await $2(e,t,n,i.expandPart);if(a!==null)return a}{let a=await R2(e,t,i.evaluateArithmetic);if(a!==null)return a}{let a=T2(e,t);if(a!==null)return a}{let a=await C2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}{let a=await N2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let a=Tx(e,t);if(a!==null)return a}{let a=await F2(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(a!==null)return a}{let a=await M2(e,t);if(a!==null)return a}{let a=await U2(e,t);if(a!==null)return a}return null}function Tx(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=Vr(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=oe(e,r.array).map(([a])=>String(a));return r.star?{values:[i.join(fe(e.state.env))],quoted:!0}:{values:i,quoted:!0}}return null}async function Px(e,t,n){{let r=await z2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await H2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await j2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await G2(e,t,n.expandPart);if(r!==null)return r}return null}async function Dx(e,t,n){{let r=await q2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Z2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await K2(e,t,n.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await Q2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await X2(e,t);if(r!==null)return r}{let r=await Y2(e,t);if(r!==null)return r}{let r=J2(e,t);if(r!==null)return r}{let r=eg(e,t);if(r!==null)return r}{let r=await tg(e,t,n.expandPart);if(r!==null)return r}return null}function rg(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 _x(e,t,n,r){let s="";for(let o=0;o<n.atIndex;o++)s+=await r(e,t.parts[o]);let i="";for(let o=n.atIndex+1;o<t.parts.length;o++)i+=await r(e,t.parts[o]);let a;if(n.type==="array"){if(a=oe(e,n.name).map(([,l])=>l),a.length===0){let l=e.state.env.get(n.name);l!==void 0&&(a=[l])}}else{let o=Number.parseInt(e.state.env.get("#")||"0",10);a=[];for(let l=1;l<=o;l++)a.push(e.state.env.get(String(l))||"")}if(n.isStar){let o=fe(e.state.env),l=a.join(o);return[s+l+i]}if(a.length===0){let o=s+i;return o?[o]:[]}return a.length===1?[s+a[0]+i]:[s+a[0],...a.slice(1,-1),a[a.length-1]+i]}async function Lx(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(rg(l)){r=!0;break}if(!r)return null;let s=rt(e.state.env),i=ft(e.state.env),a=[];for(let l of t){let c=rg(l);if(c&&l.type==="DoubleQuoted"){let u=await _x(e,l,c,n);a.push(u)}else if(l.type==="DoubleQuoted"||l.type==="SingleQuoted"){let u=await n(e,l);a.push([u])}else if(l.type==="Literal")a.push([l.value]);else if(l.type==="ParameterExpansion"){let u=await n(e,l);if(i)a.push(u?[u]:[]);else{let f=_e(u,s);a.push(f)}}else{let u=await n(e,l);if(i)a.push(u?[u]:[]);else{let f=_e(u,s);a.push(f)}}}let o=[];for(let l of a)if(l.length!==0)if(o.length===0)o.push(...l);else{let c=o.length-1;o[c]=o[c]+l[0];for(let u=1;u<l.length;u++)o.push(l[u])}return o}async function sg(e,t){if(e.state.options.noglob)return{values:t,quoted:!1};let n=[];for(let r of t)if(xn(r,e.state.shoptOptions.extglob)){let s=await aa(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function aa(e,t){let n=new Un(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 fn(t);return n.hasNullglob()?[]:[t]}async function Fx(e,t,n,r,s,i){let a=n.some(o=>o.type==="Glob");if(!e.state.options.noglob&&a){let o=await i(e,t);if(xn(o,e.state.shoptOptions.extglob)){let c=await aa(e,o);if(c.length>0&&c[0]!==o)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=lc(r);if(!ft(e.state.env)){let c=rt(e.state.env);return{values:_e(l,c),quoted:!1}}return{values:[l],quoted:!1}}if(!s&&!e.state.options.noglob&&xn(r,e.state.shoptOptions.extglob)){let o=await i(e,t);if(xn(o,e.state.shoptOptions.extglob)){let l=await aa(e,o);if(l.length>0&&l[0]!==o)return{values:l,quoted:!1}}}if(r===""&&!s)return{values:[],quoted:!1};if(a&&!s){let o=lc(r);if(!ft(e.state.env)){let l=rt(e.state.env);return{values:_e(o,l),quoted:!1}}return{values:[o],quoted:!1}}return{values:[r],quoted:s}}var ag=I(()=>{"use strict";Ki();ye();jt();Qi();k2();O2();P2();L2();Hr();W2();cr();V2();ng();Dt()});async function lg(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 bn(e,t.parameter),a=await Se(e,t.parameter,!1)==="",o=n.checkEmpty??!1,l;return n.type==="UseAlternative"?l=s&&!(o&&a):l=!s||o&&a,l?r.parts:null}function Mx(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function Ux(e,t){if(t.type!=="ParameterExpansion")return null;let n=await lg(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>Mx(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function Wx(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?tc(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&Gm(e))}async function cg(e,t,n,r,s){if(e.coverage?.hit("bash:expansion:word_split"),t.length===1&&t[0].type==="ParameterExpansion"){let p=t[0],h=await lg(e,p);if(h&&h.length>0&&h.length>1&&h.some(d=>d.type==="DoubleQuoted"||d.type==="SingleQuoted")&&h.some(d=>d.type==="Literal"||d.type==="ParameterExpansion"||d.type==="CommandSubstitution"||d.type==="ArithmeticExpansion"))return og(e,h,n,r,s)}let i=[],a=!1;for(let p of t){let h=Wx(p),m=p.type==="DoubleQuoted"||p.type==="SingleQuoted",d=h?await Ux(e,p):null,g=await s(e,p);i.push({value:g,isSplittable:h,isQuoted:m,mixedDefaultParts:d??void 0}),h&&(a=!0)}if(!a){let p=i.map(h=>h.value).join("");return p?[p]:[]}let o=[],l="",c=!1,u=!1,f=!1;for(let p of i)if(!p.isSplittable)u?p.isQuoted&&p.value===""?(l!==""&&o.push(l),o.push(""),c=!0,l="",u=!1,f=!0):p.value!==""?(l!==""&&o.push(l),l=p.value,u=!1,f=!1):(l+=p.value,f=!1):(l+=p.value,f=p.isQuoted&&p.value==="");else if(p.mixedDefaultParts){let h=await og(e,p.mixedDefaultParts,n,r,s);if(h.length!==0)if(h.length===1)l+=h[0],c=!0;else{l+=h[0],o.push(l),c=!0;for(let m=1;m<h.length-1;m++)o.push(h[m]);l=h[h.length-1]}u=!1,f=!1}else{let{words:h,hadLeadingDelimiter:m,hadTrailingDelimiter:d}=Ji(p.value,n);if(f&&m&&l===""&&(o.push(""),c=!0),h.length===0)d&&(u=!0);else if(h.length===1)l+=h[0],c=!0,u=d;else{l+=h[0],o.push(l),c=!0;for(let g=1;g<h.length-1;g++)o.push(h[g]);l=h[h.length-1],u=d}f=!1}return l!==""?o.push(l):o.length===0&&c&&o.push(""),o}function Bx(e,t){return e.length>0&&t.includes(e[0])}async function og(e,t,n,r,s){let i=[];for(let u of t){let p=!(u.type==="DoubleQuoted"||u.type==="SingleQuoted"),h=await s(e,u);i.push({value:h,isSplittable:p})}let a=[],o="",l=!1,c=!1;for(let u of i)if(!u.isSplittable)c&&u.value!==""?(o!==""&&a.push(o),o=u.value,c=!1):o+=u.value;else{Bx(u.value,n)&&o!==""&&(a.push(o),o="",l=!0);let{words:p,hadTrailingDelimiter:h}=Ji(u.value,n);if(p.length===0)h&&(c=!0);else if(p.length===1)o+=p[0],l=!0,c=h;else{o+=p[0],a.push(o),l=!0;for(let m=1;m<p.length-1;m++)a.push(p[m]);o=p[p.length-1],c=h}}return o!==""?a.push(o):a.length===0&&l&&a.push(""),a}var ug=I(()=>{"use strict";Dt();jt();Qi()});function fg(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function pg(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var hg=I(()=>{"use strict"});var yc={};K(yc,{escapeGlobChars:()=>_t,escapeRegexChars:()=>zr,expandRedirectTarget:()=>Rs,expandWord:()=>ie,expandWordForPattern:()=>mc,expandWordForRegex:()=>dc,expandWordWithGlob:()=>cn,getArrayElements:()=>oe,getVariable:()=>Se,hasQuotedMultiValueAt:()=>Os,isArray:()=>In,isWordFullyQuoted:()=>hc});function $s(e,t,n){if(e.length>t)throw new te(`${n}: string length limit exceeded (${t} bytes)`,"string_length")}async function ln(e,t,n=!1){let r=[];for(let s of t)r.push(await Gt(e,s,n));return r.join("")}function zx(e){return pg(e)}function hc(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!zx(t))return!1;return!0}function Hx(e,t,n=!1){let r=fg(t);if(r!==null)return r;switch(t.type){case"TildeExpansion":return n?t.user===null?"~":`~${t.user}`:(e.coverage?.hit("bash:expansion:tilde"),t.user===null?e.state.env.get("HOME")??"/home/user":t.user==="root"?"/root":`~${t.user}`);case"Glob":return fc(e,t.pattern);default:return null}}async function ie(e,t){return gc(e,t)}async function dc(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 ln(e,r.parts);n.push(s)}else if(r.type==="TildeExpansion"){let s=await Gt(e,r);n.push(zr(s))}else n.push(await Gt(e,r));return n.join("")}async function mc(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 ln(e,r.parts);n.push(_t(s))}else n.push(await Gt(e,r));return n.join("")}async function dg(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 ln(e,r.parts);n.push(_t(s))}else r.type==="Glob"?w2(r.pattern)?n.push(await x2(e,r.pattern)):n.push(fc(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await Gt(e,r));return n.join("")}function la(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&la(t.parts))return!0;return!1}async function mg(e,t,n={count:0}){if(n.count>pc)return[[]];let r=[[]];for(let s of t)if(s.type==="BraceExpansion"){let i=[],a=!1,o="";for(let u of s.items)if(u.type==="Range"){let f=oc(u.start,u.end,u.step,u.startStr,u.endStr);if(f.expanded)for(let p of f.expanded)n.count++,i.push(p);else{a=!0,o=f.literal;break}}else{let f=await mg(e,u.word.parts,n);for(let p of f){n.count++;let h=[];for(let m of p)typeof m=="string"?h.push(m):h.push(await Gt(e,m));i.push(h.join(""))}}if(a){for(let u of r)n.count++,u.push(o);continue}if(r.length*i.length>jx||n.count>pc)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>pc)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 gg(e,t){let n=t.parts;if(!la(n))return[await ie(e,t)];let r=await mg(e,n),s=[];for(let i of r){let a=[];for(let o of i)typeof o=="string"?a.push(o):a.push(await Gt(e,o));s.push(A2(e,a.join("")))}return s}function Gx(){return{expandWordAsync:gc,expandWordForGlobbing:dg,expandWordWithBracesAsync:gg,expandWordPartsAsync:ln,expandPart:Gt,expandParameterAsync:oa,hasBraceExpansion:la,evaluateArithmetic:ne,buildIfsCharClassPattern:Vm,smartWordSplit:cg}}async function cn(e,t){return ig(e,t,Gx())}function Vx(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function Os(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 a of i.parts)if(a.type==="ParameterExpansion"&&a.parameter==="@"&&!a.operation)return!0}return!1}return r(t.parts)}async function Rs(e,t){if(Os(e,t))return{error:`bash: $@: ambiguous redirect
|
|
780
780
|
`};let n=t.parts,{hasQuoted:r}=vs(n);if(la(n)&&(await gg(e,t)).length>1)return{error:`bash: ${n.map(h=>h.type==="Literal"?h.value:h.type==="BraceExpansion"?`{${h.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
|
-
`};let s=await gc(e,t),{hasParamExpansion:i,hasCommandSub:a}=vs(n);if((i||a)&&!r&&!ft(e.state.env)){let f=rt(e.state.env);if(_e(s,f).length>1)return{error:`bash: $${
|
|
781
|
+
`};let s=await gc(e,t),{hasParamExpansion:i,hasCommandSub:a}=vs(n);if((i||a)&&!r&&!ft(e.state.env)){let f=rt(e.state.env);if(_e(s,f).length>1)return{error:`bash: $${Vx(n)}: ambiguous redirect
|
|
782
782
|
`}}if(r||e.state.options.noglob)return{target:s};let l=await dg(e,t);if(!xn(l,e.state.shoptOptions.extglob))return{target:s};let c=new Un(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 gc(e,t){let n=t.parts,r=n.length;if(r===1){let a=await Gt(e,n[0]);return $s(a,e.limits.maxStringLength,"word expansion"),a}let s=[];for(let a=0;a<r;a++)s.push(await Gt(e,n[a]));let i=s.join("");return $s(i,e.limits.maxStringLength,"word expansion"),i}async function Gt(e,t,n=!1){if(t.type==="ParameterExpansion")return oa(e,t,n);let r=
|
|
784
|
+
`}}async function gc(e,t){let n=t.parts,r=n.length;if(r===1){let a=await Gt(e,n[0]);return $s(a,e.limits.maxStringLength,"word expansion"),a}let s=[];for(let a=0;a<r;a++)s.push(await Gt(e,n[a]));let i=s.join("");return $s(i,e.limits.maxStringLength,"word expansion"),i}async function Gt(e,t,n=!1){if(t.type==="ParameterExpansion")return oa(e,t,n);let r=Hx(e,t,n);if(r!==null)return r;switch(t.type){case"DoubleQuoted":{let s=[];for(let i of t.parts)s.push(await Gt(e,i,!0));return s.join("")}case"CommandSubstitution":{let s=t2(t.body);if(s)try{let p=await ie(e,s.target),h=p.startsWith("/")?p:`${e.state.cwd}/${p}`,m=await e.fs.readFile(h);e.state.lastExitCode=0,e.state.env.set("?","0");let d=m.replace(/\n+$/,"");return $s(d,e.limits.maxStringLength,"command substitution"),d}catch(p){if(p instanceof te)throw p;return e.state.lastExitCode=1,e.state.env.set("?","1"),""}let i=e.substitutionDepth??0,a=e.limits.maxSubstitutionDepth;if(i>=a)throw new te(`Command substitution nesting limit exceeded (${a})`,"substitution_depth");let o=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 p=await e.executeScript(t.body),h=p.exitCode;e.state.env=c,e.state.cwd=u,e.state.suppressVerbose=f,e.state.lastExitCode=h,e.state.env.set("?",String(h)),p.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+p.stderr),e.state.bashPid=l,e.substitutionDepth=o;let m=p.stdout.replace(/\n+$/,"");return $s(m,e.limits.maxStringLength,"command substitution"),m}catch(p){if(e.state.env=c,e.state.cwd=u,e.state.bashPid=l,e.substitutionDepth=o,e.state.suppressVerbose=f,p instanceof te)throw p;if(p instanceof pe){e.state.lastExitCode=p.exitCode,e.state.env.set("?",String(p.exitCode)),p.stderr&&(e.state.expansionStderr=(e.state.expansionStderr||"")+p.stderr);let h=p.stdout.replace(/\n+$/,"");return $s(h,e.limits.maxStringLength,"command substitution"),h}throw p}}case"ArithmeticExpansion":{let s=t.expression.originalText;if(s&&/\$[a-zA-Z_][a-zA-Z0-9_]*(?![{[(])/.test(s)){let a=await Ym(e,s),o=new ce,l=Ae(o,a);return String(await ne(e,l.expression,!0))}return String(await ne(e,t.expression.expression,!0))}case"BraceExpansion":{let s=[];for(let i of t.items)if(i.type==="Range"){let a=oc(i.start,i.end,i.step,i.startStr,i.endStr);if(a.expanded)s.push(...a.expanded);else return a.literal}else s.push(await ie(e,i.word));return s.join(" ")}default:return""}}async function oa(e,t,n=!1){let{parameter:r}=t,{operation:s}=t,i=r.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(i){let[,p,h]=i;if(e.state.associativeArrays?.has(p)||h.includes("$(")||h.includes("`")||h.includes("${")){let d=await ac(e,h);r=`${p}[${d}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&Te(e,r)){let p=At(e,r);if(p&&p!==r){let h=p.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(h){let[,m,d]=h;if(e.state.associativeArrays?.has(m)||d.includes("$(")||d.includes("`")||d.includes("${")){let w=await ac(e,d);r=`${m}[${w}]`}}}}let a=s&&(s.type==="DefaultValue"||s.type==="AssignDefault"||s.type==="UseAlternative"||s.type==="ErrorIfUnset"),o=await Se(e,r,!a);if(!s)return o;let l=!await bn(e,r),{isEmpty:c,effectiveValue:u}=g2(e,r,o,n),f={value:o,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:n};switch(s.type){case"DefaultValue":return r2(e,s,f,ln);case"AssignDefault":return s2(e,r,s,f,ln);case"ErrorIfUnset":return i2(e,r,s,f,ln);case"UseAlternative":return a2(e,s,f,ln);case"PatternRemoval":return o2(e,o,s,ln,Gt);case"PatternReplacement":return l2(e,o,s,ln,Gt);case"Length":return c2(e,r,o);case"LengthSliceError":throw new wt(r);case"BadSubstitution":throw new wt(s.text);case"Substring":return u2(e,r,o,s);case"CaseModification":return f2(e,o,s,ln,oa);case"Transform":return p2(e,r,o,l,s);case"Indirection":return h2(e,r,o,l,s,oa,n);case"ArrayKeys":return d2(e,s);case"VarNamePrefix":return m2(e,s);default:return o}}var jx,pc,Ct=I(()=>{"use strict";dt();Xe();Ki();St();ye();Qi();Jm();e2();n2();Hr();y2();E2();S2();Dt();ag();ug();jt();an();hg();Hr();Dt();jx=1e4,pc=1e5});function qx(e,t,n){switch(n){case"+":return e+t;case"-":return e-t;case"*":return e*t;case"/":if(t===0)throw new Re("division by 0");return Math.trunc(e/t);case"%":if(t===0)throw new Re("division by 0");return e%t;case"**":if(t<0)throw new Re("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 yg(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 Zx(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return e===0?1:0;case"~":return~e;default:return e}}async function Kx(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 Qx(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}=Ht(r,n,0);if(i<n.length){let a=n.slice(i).trim().split(/\s+/)[0];throw new Re(`${n}: syntax error in expression (error token is "${a}")`)}return s.type==="ArithNumber"?s.value:t||0}catch(r){if(r instanceof Re)throw r;let s=n.split(/\s+/).slice(1)[0]||n;throw new Re(`${n}: syntax error in expression (error token is "${s}")`)}}async function wc(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:a}=Ht(s,r,0);if(a<r.length){let o=r.slice(a).trim(),l=o.split(/\s+/)[0]||o;throw new Re(`syntax error in expression (error token is "${l}")`,"","")}return await ne(e,i)}async function bc(e,t,n=new Set){if(n.has(t))return 0;n.add(t);let r=await Kx(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 bc(e,i,n);let a=new ce,{expr:o,pos:l}=Ht(a,i,0);if(l<i.length){let c=i.slice(l).trim(),u=c.split(/\s+/)[0]||c;throw new Re(`${i}: syntax error in expression (error token is "${u}")`)}return await ne(e,o)}async function ca(e,t){if(t.startsWith("#")){let f=t.slice(1),p=f.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[[@*]\]$/);if(p){let m=p[1],d=oe(e,m);return String(d.length)}let h=e.state.env.get(f)||"";return String(h.length)}if(t.startsWith("!")){let f=t.slice(1),p=e.state.env.get(f)||"";return e.state.env.get(p)||""}let n=[":-",":=",":?",":+","-","=","?","+"],r=-1,s="";for(let f of n){let p=t.indexOf(f);p>0&&(r===-1||p<r)&&(r=p,s=f)}if(r===-1)return await Se(e,t);let i=t.slice(0,r),a=t.slice(r+s.length),o=e.state.env.get(i),l=o===void 0,c=o==="",u=s.startsWith(":");switch(s){case":-":case"-":return l||u&&c?a:o||"";case":=":case"=":return l||u&&c?(e.state.env.set(i,a),a):o||"";case":+":case"+":return!(l||u&&c)?a:"";case":?":case"?":{if(l||u&&c)throw new Error(a||`${i}: parameter null or not set`);return o||""}default:return o||""}}async function ne(e,t,n=!1){switch(t.type){case"ArithNumber":if(Number.isNaN(t.value))throw new Re("value too great for base");return t.value;case"ArithVariable":return await bc(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 a=new ce,{expr:o}=Ht(a,s,0);return await ne(e,o)}case"ArithNested":return await ne(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 ca(e,t.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=await ca(e,t.baseExpr),s=Number.parseInt(r,10);if(s<2||s>64)return 0;let i=`${s}#${t.value}`;return Ns(i)}case"ArithDynamicNumber":{let s=await ca(e,t.prefix)+t.suffix;return Ns(s)}case"ArithArrayElement":{let r=e.state.associativeArrays?.has(t.array),s=async i=>{let a=e.state.env.get(i);return a!==void 0?await wc(e,a):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 ne(e,t.index,n);if(i<0){let l=oe(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(([p])=>typeof p=="number"?p: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 a=`${t.array}_${i}`,o=e.state.env.get(a);if(o!==void 0)return wc(e,o);if(i===0){let l=e.state.env.get(t.array);if(l!==void 0)return wc(e,l)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new wt(`${t.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new Re("double subscript","","");case"ArithNumberSubscript":throw new Re(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new Re(t.message,"","",!0);case"ArithSingleQuote":{if(n)throw new Re(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value}case"ArithBinary":{if(t.operator==="||")return await ne(e,t.left,n)||await ne(e,t.right,n)?1:0;if(t.operator==="&&")return await ne(e,t.left,n)&&await ne(e,t.right,n)?1:0;let r=await ne(e,t.left,n),s=await ne(e,t.right,n);return Zx(r,s,t.operator)}case"ArithUnary":{let r=await ne(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,a=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(a)),t.prefix?a:i}if(t.operand.type==="ArithArrayElement"){let s=t.operand.array,i=e.state.associativeArrays?.has(s),a;if(t.operand.stringKey!==void 0)a=`${s}_${t.operand.stringKey}`;else if(i&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)a=`${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);a=`${s}_${c}`}else if(t.operand.index){let c=await ne(e,t.operand.index,n);a=`${s}_${c}`}else return r;let o=Number.parseInt(e.state.env.get(a)||"0",10)||0,l=t.operator==="++"?o+1:o-1;return e.state.env.set(a,String(l)),t.prefix?l:o}if(t.operand.type==="ArithConcat"){let s="";for(let i of t.operand.parts)s+=await qr(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,a=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(a)),t.prefix?a:i}}if(t.operand.type==="ArithDynamicElement"){let s="";if(t.operand.nameExpr.type==="ArithConcat")for(let i of t.operand.nameExpr.parts)s+=await qr(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 ne(e,t.operand.subscript,n),a=`${s}_${i}`,o=Number.parseInt(e.state.env.get(a)||"0",10)||0,l=t.operator==="++"?o+1:o-1;return e.state.env.set(a,String(l)),t.prefix?l:o}}return r}return Kx(r,t.operator)}case"ArithTernary":return await ne(e,t.condition,n)?await ne(e,t.consequent,n):await ne(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 ne(e,t.subscript,n);s=`${r}_${c}`}else{let c=await ne(e,t.subscript,n);if(c<0){let u=oe(e,r);u.length>0&&(c=Math.max(...u.map(([p])=>typeof p=="number"?p:0))+1+c)}s=`${r}_${c}`}}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,a=await ne(e,t.value,n),o=yg(i,a,t.operator);return e.state.env.set(s,String(o)),o}case"ArithGroup":return await ne(e,t.expression,n);case"ArithConcat":{let r="";for(let s of t.parts)r+=await qr(e,s,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await bc(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 qr(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 ne(e,t.subscript,n);s=`${r}_${l}`}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,a=await ne(e,t.value,n),o=yg(i,a,t.operator);return e.state.env.set(s,String(o)),o}case"ArithDynamicElement":{let r="";if(t.nameExpr.type==="ArithConcat")for(let o of t.nameExpr.parts)r+=await qr(e,o,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 ne(e,t.subscript,n),i=`${r}_${s}`,a=e.state.env.get(i);return a!==void 0?Xx(a):0}default:return 0}}async function qr(e,t,n=!1){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await ne(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 ca(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 qr(e,s,n);return r}default:return String(await ne(e,t,n))}}var Ct=I(()=>{"use strict";mt();Xe();ye();Nt()});var Al=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(wu(),yu))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(xu(),bu))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>($u(),Iu))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(Pu(),Tu))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(_u(),Du))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(Uu(),Mu))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Bu(),Wu))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(Hu(),zu))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Gu(),ju))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(qu(),Vu))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Ku(),Zu))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(Yu(),Xu))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(ef(),Ju))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(nf(),tf))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(of(),af))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(cf(),lf))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(pf(),ff))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(mf(),df))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(ri(),ni))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(ri(),ni))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(ri(),ni))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(i1(),s1))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(g1(),m1))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(Z1(),q1))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(sp(),rp))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(ap(),ip))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(lp(),op))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(up(),cp))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(hp(),pp))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(gp(),mp))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(wp(),yp))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(Ep(),xp))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Cp(),Sp))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(vp(),kp))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(Rp(),Op))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(_p(),Dp))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Mp(),Fp))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Bp(),Wp))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(Hp(),zp))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Gp(),jp))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(eh(),Jp))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(nh(),th))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(sh(),rh))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(oh(),ah))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(uh(),ch))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Do(),Po))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Do(),Po))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Lo(),_o))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Lo(),_o))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(hh(),ph))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(mh(),dh))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Mo(),Fo))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Mo(),Fo))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(yh(),gh))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(Wo(),Uo))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(Wo(),Uo))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Vh(),Gh))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Kh(),Zh))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Yh(),Xh))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(ed(),Jh))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(nd(),td))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(sd(),rd))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(ad(),id))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(ld(),od))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(ud(),cd))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(hd(),pd))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(md(),dd))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(yd(),gd))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(l0(),o0))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(u0(),c0))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(p0(),f0))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(d0(),h0))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(g0(),m0))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(w0(),y0))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(x0(),b0))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(A0(),E0))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(zi(),Bi))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(zi(),Bi))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(zi(),Bi))).zcatCommand}],bb=[],M0=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(L0(),_0))).curlCommand}],F0=new Map;function Sl(e){return{name:e.name,async execute(t,n){let r=F0.get(e.name);return r||(r=await e.load(),F0.set(e.name,r)),n.coverage,r.execute(t,n)}}}function xb(){return Al.map(e=>e.name)}function Eb(){return M0.map(e=>e.name)}function U0(e){return(e?Al.filter(n=>e.includes(n.name)):Al).map(Sl)}function W0(){return M0.map(Sl)}function B0(){return bb.map(Sl)}function z0(e){return"load"in e&&typeof e.load=="function"}function Ab(e,t){return{name:e,execute:t}}function H0(e){let t=null;return{name:e.name,async execute(n,r){return t||(t=await e.load()),t.execute(n,r)}}}var Sb=new TextEncoder,Cb=new TextDecoder;function Cl(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}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,s=>s.charCodeAt(0));let r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}return Sb.encode(e)}function j0(e,t){if(t==="base64"){if(typeof Buffer<"u")return Buffer.from(e).toString("base64");let n=65536,r="";for(let s=0;s<e.length;s+=n){let i=e.subarray(s,s+n);r+=String.fromCharCode(...i)}return btoa(r)}if(t==="hex")return Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let n=65536;if(e.length<=n)return String.fromCharCode(...e);let r="";for(let s=0;s<e.length;s+=n){let i=e.subarray(s,s+n);r+=String.fromCharCode(...i)}return r}return Cb.decode(e)}function Hi(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var Ur=new TextEncoder;function Nb(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function ot(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var sr=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))typeof r=="function"?this.writeFileLazy(n,r):Nb(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){ot(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let a=Hi(r),o=Cl(n,a);this.data.set(i,{type:"file",content:o,mode:s?.mode??420,mtime:s?.mtime??new Date})}writeFileLazy(t,n,r){ot(t,"write");let s=this.normalizePath(t);this.ensureParentDirs(s),this.data.set(s,{type:"file",lazy:n,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,n){let r=await n.lazy(),i={type:"file",content:typeof r=="string"?Ur.encode(r):r,mode:n.mode,mtime:n.mtime};return this.data.set(t,i),i}async readFile(t,n){let r=await this.readFileBuffer(t),s=Hi(n);return j0(r,s)}async readFileBuffer(t){ot(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}'`);if("lazy"in r){let s=await this.materializeLazy(n,r);return s.content instanceof Uint8Array?s.content:Ur.encode(s.content)}return r.content instanceof Uint8Array?r.content:Ur.encode(r.content)}async writeFile(t,n,r){this.writeFileSync(t,n,r)}async appendFile(t,n,r){ot(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 a=Hi(r),o=Cl(n,a);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(s,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:Ur.encode("content"in l?l.content:""),u=new Uint8Array(c.length+o.length);u.set(c),u.set(o,c.length),this.data.set(s,{type:"file",content:u,mode:l.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){ot(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}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ur.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){ot(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};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ur.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 a=0;a<r.length-1;a++){let o=r[a];s=`${s}/${o}`;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 a of r){s=`${s}/${a}`;let o=this.data.get(s),l=0,c=40;for(;o&&o.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,o.target),o=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){ot(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){ot(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}/`,a=new Map;for(let[o,l]of this.data.entries())if(o!==n&&o.startsWith(i)){let c=o.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!a.has(u)&&a.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(a.values()).sort((o,l)=>o.name<l.name?-1:o.name>l.name?1:0)}async rm(t,n){ot(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 a of i){let o=r==="/"?`/${a}`:`${r}/${a}`;await this.rm(o,n)}}}this.data.delete(r)}async cp(t,n,r){ot(t,"cp"),ot(n,"cp");let s=this.normalizePath(t),i=this.normalizePath(n),a=this.data.get(s);if(!a)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(a.type==="file")if(this.ensureParentDirs(i),"content"in a){let o=a.content instanceof Uint8Array?new Uint8Array(a.content):a.content;this.data.set(i,{...a,content:o})}else this.data.set(i,{...a});else if(a.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...a});else if(a.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let o=await this.readdir(s);for(let l of o){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){ot(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){ot(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){ot(t,"link"),ot(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}'`);let a=i;"lazy"in a&&(a=await this.materializeLazy(r,a)),this.ensureParentDirs(s),this.data.set(s,{type:"file",content:a.content,mode:a.mode,mtime:a.mtime})}async readlink(t){ot(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){ot(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){ot(t,"utimes");let s=this.normalizePath(t),i=this.resolvePathWithSymlinks(s),a=this.data.get(i);if(!a)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);a.mtime=r}};kl();function kb(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function vb(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 Ib(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 $b(e,t){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${V0}
|
|
786
|
+
`,0;i=f}let a=`${t.array}_${i}`,o=e.state.env.get(a);if(o!==void 0)return wc(e,o);if(i===0){let l=e.state.env.get(t.array);if(l!==void 0)return wc(e,l)}if(e.state.options.nounset&&!Array.from(e.state.env.keys()).some(c=>c===t.array||c.startsWith(`${t.array}_`)))throw new yt(`${t.array}[${i}]`);return 0}return 0}case"ArithDoubleSubscript":throw new Re("double subscript","","");case"ArithNumberSubscript":throw new Re(`${t.number}${t.errorToken}: syntax error: invalid arithmetic operator (error token is "${t.errorToken}")`);case"ArithSyntaxError":throw new Re(t.message,"","",!0);case"ArithSingleQuote":{if(n)throw new Re(`syntax error: operand expected (error token is "'${t.content}'")`);return t.value}case"ArithBinary":{if(t.operator==="||")return await ne(e,t.left,n)||await ne(e,t.right,n)?1:0;if(t.operator==="&&")return await ne(e,t.left,n)&&await ne(e,t.right,n)?1:0;let r=await ne(e,t.left,n),s=await ne(e,t.right,n);return qx(r,s,t.operator)}case"ArithUnary":{let r=await ne(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,a=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(a)),t.prefix?a:i}if(t.operand.type==="ArithArrayElement"){let s=t.operand.array,i=e.state.associativeArrays?.has(s),a;if(t.operand.stringKey!==void 0)a=`${s}_${t.operand.stringKey}`;else if(i&&t.operand.index?.type==="ArithVariable"&&!t.operand.index.hasDollarPrefix)a=`${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);a=`${s}_${c}`}else if(t.operand.index){let c=await ne(e,t.operand.index,n);a=`${s}_${c}`}else return r;let o=Number.parseInt(e.state.env.get(a)||"0",10)||0,l=t.operator==="++"?o+1:o-1;return e.state.env.set(a,String(l)),t.prefix?l:o}if(t.operand.type==="ArithConcat"){let s="";for(let i of t.operand.parts)s+=await qr(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,a=t.operator==="++"?i+1:i-1;return e.state.env.set(s,String(a)),t.prefix?a:i}}if(t.operand.type==="ArithDynamicElement"){let s="";if(t.operand.nameExpr.type==="ArithConcat")for(let i of t.operand.nameExpr.parts)s+=await qr(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 ne(e,t.operand.subscript,n),a=`${s}_${i}`,o=Number.parseInt(e.state.env.get(a)||"0",10)||0,l=t.operator==="++"?o+1:o-1;return e.state.env.set(a,String(l)),t.prefix?l:o}}return r}return Zx(r,t.operator)}case"ArithTernary":return await ne(e,t.condition,n)?await ne(e,t.consequent,n):await ne(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 ne(e,t.subscript,n);s=`${r}_${c}`}else{let c=await ne(e,t.subscript,n);if(c<0){let u=oe(e,r);u.length>0&&(c=Math.max(...u.map(([p])=>typeof p=="number"?p:0))+1+c)}s=`${r}_${c}`}}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,a=await ne(e,t.value,n),o=yg(i,a,t.operator);return e.state.env.set(s,String(o)),o}case"ArithGroup":return await ne(e,t.expression,n);case"ArithConcat":{let r="";for(let s of t.parts)r+=await qr(e,s,n);return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)?await bc(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 qr(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 ne(e,t.subscript,n);s=`${r}_${l}`}let i=Number.parseInt(e.state.env.get(s)||"0",10)||0,a=await ne(e,t.value,n),o=yg(i,a,t.operator);return e.state.env.set(s,String(o)),o}case"ArithDynamicElement":{let r="";if(t.nameExpr.type==="ArithConcat")for(let o of t.nameExpr.parts)r+=await qr(e,o,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 ne(e,t.subscript,n),i=`${r}_${s}`,a=e.state.env.get(i);return a!==void 0?Qx(a):0}default:return 0}}async function qr(e,t,n=!1){switch(t.type){case"ArithNumber":return String(t.value);case"ArithSingleQuote":return String(await ne(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 ca(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 qr(e,s,n);return r}default:return String(await ne(e,t,n))}}var St=I(()=>{"use strict";dt();Xe();ye();Ct()});var Al=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(wu(),yu))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(xu(),bu))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>($u(),Iu))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(Pu(),Tu))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(_u(),Du))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(Uu(),Mu))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(Bu(),Wu))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(Hu(),zu))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Gu(),ju))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(qu(),Vu))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Ku(),Zu))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(Yu(),Xu))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(ef(),Ju))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(nf(),tf))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(of(),af))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(cf(),lf))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(pf(),ff))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(mf(),df))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(ri(),ni))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(ri(),ni))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(ri(),ni))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(i1(),s1))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(g1(),m1))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(Z1(),q1))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(sp(),rp))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(ap(),ip))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(lp(),op))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(up(),cp))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(hp(),pp))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(gp(),mp))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(wp(),yp))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(Ep(),xp))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Cp(),Sp))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(vp(),kp))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(Rp(),Op))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(_p(),Dp))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Mp(),Fp))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(Bp(),Wp))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(Hp(),zp))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Gp(),jp))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(eh(),Jp))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(nh(),th))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(sh(),rh))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(oh(),ah))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(uh(),ch))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(Do(),Po))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(Do(),Po))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Lo(),_o))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Lo(),_o))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(hh(),ph))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(mh(),dh))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Mo(),Fo))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Mo(),Fo))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(yh(),gh))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(Wo(),Uo))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(Wo(),Uo))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(Vh(),Gh))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Kh(),Zh))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Yh(),Xh))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(ed(),Jh))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(nd(),td))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(sd(),rd))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(ad(),id))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(ld(),od))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(ud(),cd))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(hd(),pd))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(md(),dd))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(yd(),gd))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(l0(),o0))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(u0(),c0))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(p0(),f0))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(d0(),h0))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(g0(),m0))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(w0(),y0))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(x0(),b0))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(A0(),E0))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(zi(),Bi))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(zi(),Bi))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(zi(),Bi))).zcatCommand}],wb=[],M0=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(L0(),_0))).curlCommand}],F0=new Map;function Sl(e){return{name:e.name,async execute(t,n){let r=F0.get(e.name);return r||(r=await e.load(),F0.set(e.name,r)),n.coverage,r.execute(t,n)}}}function bb(){return Al.map(e=>e.name)}function xb(){return M0.map(e=>e.name)}function U0(e){return(e?Al.filter(n=>e.includes(n.name)):Al).map(Sl)}function W0(){return M0.map(Sl)}function B0(){return wb.map(Sl)}function z0(e){return"load"in e&&typeof e.load=="function"}function Eb(e,t){return{name:e,execute:t}}function H0(e){let t=null;return{name:e.name,async execute(n,r){return t||(t=await e.load()),t.execute(n,r)}}}var Ab=new TextEncoder,Sb=new TextDecoder;function Cl(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}if(t==="binary"||t==="latin1"){if(e.length<=65536)return Uint8Array.from(e,s=>s.charCodeAt(0));let r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}return Ab.encode(e)}function j0(e,t){if(t==="base64"){if(typeof Buffer<"u")return Buffer.from(e).toString("base64");let n=65536,r="";for(let s=0;s<e.length;s+=n){let i=e.subarray(s,s+n);r+=String.fromCharCode(...i)}return btoa(r)}if(t==="hex")return Array.from(e).map(n=>n.toString(16).padStart(2,"0")).join("");if(t==="binary"||t==="latin1"){if(typeof Buffer<"u")return Buffer.from(e).toString(t);let n=65536;if(e.length<=n)return String.fromCharCode(...e);let r="";for(let s=0;s<e.length;s+=n){let i=e.subarray(s,s+n);r+=String.fromCharCode(...i)}return r}return Sb.decode(e)}function Hi(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var Ur=new TextEncoder;function Cb(e){return typeof e=="object"&&e!==null&&!(e instanceof Uint8Array)&&"content"in e}function ot(e,t){if(e.includes("\0"))throw new Error(`ENOENT: path contains null byte, ${t} '${e}'`)}var sr=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))typeof r=="function"?this.writeFileLazy(n,r):Cb(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){ot(t,"write");let i=this.normalizePath(t);this.ensureParentDirs(i);let a=Hi(r),o=Cl(n,a);this.data.set(i,{type:"file",content:o,mode:s?.mode??420,mtime:s?.mtime??new Date})}writeFileLazy(t,n,r){ot(t,"write");let s=this.normalizePath(t);this.ensureParentDirs(s),this.data.set(s,{type:"file",lazy:n,mode:r?.mode??420,mtime:r?.mtime??new Date})}async materializeLazy(t,n){let r=await n.lazy(),i={type:"file",content:typeof r=="string"?Ur.encode(r):r,mode:n.mode,mtime:n.mtime};return this.data.set(t,i),i}async readFile(t,n){let r=await this.readFileBuffer(t),s=Hi(n);return j0(r,s)}async readFileBuffer(t){ot(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}'`);if("lazy"in r){let s=await this.materializeLazy(n,r);return s.content instanceof Uint8Array?s.content:Ur.encode(s.content)}return r.content instanceof Uint8Array?r.content:Ur.encode(r.content)}async writeFile(t,n,r){this.writeFileSync(t,n,r)}async appendFile(t,n,r){ot(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 a=Hi(r),o=Cl(n,a);if(i?.type==="file"){let l=i;"lazy"in l&&(l=await this.materializeLazy(s,l));let c="content"in l&&l.content instanceof Uint8Array?l.content:Ur.encode("content"in l?l.content:""),u=new Uint8Array(c.length+o.length);u.set(c),u.set(o,c.length),this.data.set(s,{type:"file",content:u,mode:l.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){ot(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}'`);r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ur.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){ot(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};r.type==="file"&&"lazy"in r&&(r=await this.materializeLazy(n,r));let s=0;return r.type==="file"&&"content"in r&&r.content&&(r.content instanceof Uint8Array?s=r.content.length:s=Ur.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 a=0;a<r.length-1;a++){let o=r[a];s=`${s}/${o}`;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 a of r){s=`${s}/${a}`;let o=this.data.get(s),l=0,c=40;for(;o&&o.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,o.target),o=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){ot(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){ot(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}/`,a=new Map;for(let[o,l]of this.data.entries())if(o!==n&&o.startsWith(i)){let c=o.slice(i.length),u=c.split("/")[0];u&&!c.includes("/",u.length)&&!a.has(u)&&a.set(u,{name:u,isFile:l.type==="file",isDirectory:l.type==="directory",isSymbolicLink:l.type==="symlink"})}return Array.from(a.values()).sort((o,l)=>o.name<l.name?-1:o.name>l.name?1:0)}async rm(t,n){ot(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 a of i){let o=r==="/"?`/${a}`:`${r}/${a}`;await this.rm(o,n)}}}this.data.delete(r)}async cp(t,n,r){ot(t,"cp"),ot(n,"cp");let s=this.normalizePath(t),i=this.normalizePath(n),a=this.data.get(s);if(!a)throw new Error(`ENOENT: no such file or directory, cp '${t}'`);if(a.type==="file")if(this.ensureParentDirs(i),"content"in a){let o=a.content instanceof Uint8Array?new Uint8Array(a.content):a.content;this.data.set(i,{...a,content:o})}else this.data.set(i,{...a});else if(a.type==="symlink")this.ensureParentDirs(i),this.data.set(i,{...a});else if(a.type==="directory"){if(!r?.recursive)throw new Error(`EISDIR: is a directory, cp '${t}'`);await this.mkdir(i,{recursive:!0});let o=await this.readdir(s);for(let l of o){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){ot(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){ot(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){ot(t,"link"),ot(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}'`);let a=i;"lazy"in a&&(a=await this.materializeLazy(r,a)),this.ensureParentDirs(s),this.data.set(s,{type:"file",content:a.content,mode:a.mode,mtime:a.mtime})}async readlink(t){ot(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){ot(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){ot(t,"utimes");let s=this.normalizePath(t),i=this.resolvePathWithSymlinks(s),a=this.data.get(i);if(!a)throw new Error(`ENOENT: no such file or directory, utimes '${t}'`);a.mtime=r}};kl();function Nb(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function kb(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 vb(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 Ib(e,t){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${V0}
|
|
787
787
|
`),e.writeFileSync("/proc/self/exe","/bin/bash"),e.writeFileSync("/proc/self/cmdline","bash\0"),e.writeFileSync("/proc/self/comm",`bash
|
|
788
|
-
`),e.writeFileLazy?e.writeFileLazy("/proc/self/status",()=>Nl(t)):e.writeFileSync("/proc/self/status",Nl(t)),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 q0(e,t,n={pid:1,ppid:0,uid:1e3,gid:1e3}){
|
|
788
|
+
`),e.writeFileLazy?e.writeFileLazy("/proc/self/status",()=>Nl(t)):e.writeFileSync("/proc/self/status",Nl(t)),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 q0(e,t,n={pid:1,ppid:0,uid:1e3,gid:1e3}){Nb(e)&&(kb(e,t),vb(e),Ib(e,n))}Pn();ye();var $b=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Ob=["braceexpand","hashall","interactive-comments"];function vl(e){let t=[],n=[...Ob.map(r=>({name:r,enabled:!0})),...$b.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 Wr(e){e.state.env.set("SHELLOPTS",vl(e.state.options))}var Rb=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function Il(e){let t=[];for(let n of Rb)e[n]&&t.push(n);return t.join(":")}function $l(e){e.state.env.set("BASHOPTS",Il(e.state.shoptOptions))}Pn();ir();Xe();ir();var ox="BASH_ALIAS_";function Fm(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Mm(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Um(e,t){return e.env.get(`${ox}${t}`)}function Xl(e,t,n){if(!t.name||!Fm(t.name))return t;let r=Mm(t.name);if(!r)return t;let s=Um(e,r);if(!s||n.has(r))return t;try{n.add(r);let i=new ce,a=s,o=s.endsWith(" ");if(!o)for(let f of t.args){let p=Bm(f);a+=` ${p}`}let l;try{l=i.parse(a)}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 Wm(t,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Wm(t,s);let u={...c,assignments:[...t.assignments,...c.assignments],redirections:[...c.redirections,...t.redirections],line:t.line};if(o&&t.args.length>0&&(u={...u,args:[...u.args,...t.args]},u.args.length>0)){let f=u.args[0];if(Fm(f)){let p=Mm(f);if(p&&Um(e,p)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Xl(e,h,n);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw n.delete(r),i}}function Wm(e,t){let n=t;for(let a of e.args){let o=Bm(a);n+=` ${o}`}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 Bm(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}St();Ct();Xt();async function wg(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=[],a=!1,o="",l=!1;for(let u of t.parts)if(u.type==="Literal"){let f=u.value;if(!a){let p=f.indexOf("=(");p!==-1&&(a=!0,f=f.slice(p+2))}if(a){f.endsWith(")")&&(f=f.slice(0,-1));let p=f.split(/(\s+)/);for(let h of p)/^\s+$/.test(h)?(o||l)&&(i.push(o),o="",l=!1):h&&(o+=h)}}else if(a)if(u.type==="BraceExpansion")if(/^\[.+\]=/.test(o))o+=Br({type:"Word",parts:[u]});else{(o||l)&&(i.push(o),o="",l=!1);let p=await cn(e,{type:"Word",parts:[u]});i.push(...p.values)}else{(u.type==="SingleQuoted"||u.type==="DoubleQuoted"||u.type==="Escaped")&&(l=!0);let f=await ie(e,{type:"Word",parts:[u]});o+=f}(o||l)&&i.push(o);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 bg(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 w=g.value.indexOf("+=");if(w!==-1){let b=g.value.slice(0,w);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)){n=d,r=w,s=!0;break}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=d,r=w,s=!0;break}}let y=g.value.indexOf("=");if(y!==-1&&(y===0||g.value[y-1]!=="+")){let b=g.value.slice(0,y);if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(b)||/^[a-zA-Z_][a-zA-Z0-9_]*\[[^\]]+\]$/.test(b)){n=d,r=y;break}}}}if(n===-1)return null;let i=t.parts.slice(0,n),a=t.parts[n];if(a.type!=="Literal")return null;let o=s?2:1,l=a.value.slice(0,r),c=a.value.slice(r+o),u=t.parts.slice(n+1),f="";for(let d of i)f+=await ie(e,{type:"Word",parts:[d]});f+=l;let p={type:"Word",parts:c!==""?[{type:"Literal",value:c},...u]:u},h=p.parts.length>0?await ie(e,p):"";return`${f}${s?"+=":"="}${h}`}var Xx=["tar","yq","xan","sqlite3","python3","python"];function xg(e){return Xx.includes(e)}ye();ye();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 B(e,t,n){return{stdout:e,stderr:t,exitCode:n}}function Je(e){return{stdout:"",stderr:"",exitCode:e?0:1}}function On(e,t,n="",r=""){throw new te(e,t,n,r)}function xc(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new pn;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 pt(n)}async function Ec(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 a=t.slice(i);if(a.length===0||a[0]==="~"?n=e.state.env.get("HOME")||"/":a[0]==="-"?(n=e.state.previousDir,r=!0):n=a[0],!n.startsWith("/")&&!n.startsWith("./")&&!n.startsWith("../")&&n!=="."&&n!==".."){let f=e.state.env.get("CDPATH");if(f){let p=f.split(":").filter(h=>h);for(let h of p){let m=h.startsWith("/")?`${h}/${n}`:`${e.state.cwd}/${h}/${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
|
|
792
792
|
`)}}let u=c||"/";if(s)try{u=await e.fs.realpath(u)}catch{}return e.state.previousDir=e.state.cwd,e.state.cwd=u,e.state.env.set("PWD",e.state.cwd),e.state.env.set("OLDPWD",e.state.previousDir),ge(r?`${u}
|
|
793
|
-
`:"")}Xe();
|
|
793
|
+
`:"")}Xe();dt();Xe();Me();St();Ct();Xt();function Ac(e,t){return e.fs.resolvePath(e.state.cwd,t)}var Yx=["-e","-a","-f","-d","-r","-w","-x","-s","-L","-h","-k","-g","-u","-G","-O","-b","-c","-p","-S","-t","-N"];function ua(e){return Yx.includes(e)}async function fa(e,t,n){let r=Ac(e,n);switch(t){case"-e":case"-a":return e.fs.exists(r);case"-f":return await e.fs.exists(r)?(await e.fs.stat(r)).isFile:!1;case"-d":return await e.fs.exists(r)?(await e.fs.stat(r)).isDirectory:!1;case"-r":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&256)!==0:!1;case"-w":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&128)!==0:!1;case"-x":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&64)!==0:!1;case"-s":return await e.fs.exists(r)?(await e.fs.stat(r)).size>0:!1;case"-L":case"-h":try{return(await e.fs.lstat(r)).isSymbolicLink}catch{return!1}case"-k":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&512)!==0:!1;case"-g":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&1024)!==0:!1;case"-u":return await e.fs.exists(r)?((await e.fs.stat(r)).mode&2048)!==0:!1;case"-G":case"-O":return e.fs.exists(r);case"-b":return!1;case"-c":return["/dev/null","/dev/zero","/dev/random","/dev/urandom","/dev/tty","/dev/stdin","/dev/stdout","/dev/stderr"].includes(r);case"-p":return!1;case"-S":return!1;case"-t":return!1;case"-N":return e.fs.exists(r);default:return!1}}var Jx=["-nt","-ot","-ef"];function pa(e){return Jx.includes(e)}async function ha(e,t,n,r){let s=Ac(e,n),i=Ac(e,r);switch(t){case"-nt":try{let a=await e.fs.stat(s),o=await e.fs.stat(i);return a.mtime>o.mtime}catch{return!1}case"-ot":try{let a=await e.fs.stat(s),o=await e.fs.stat(i);return a.mtime<o.mtime}catch{return!1}case"-ef":try{if(!await e.fs.exists(s)||!await e.fs.exists(i))return!1;let a=e.fs.resolvePath(e.state.cwd,s),o=e.fs.resolvePath(e.state.cwd,i);return a===o}catch{return!1}default:return!1}}var eE=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]);function da(e){return eE.has(e)}function ma(e,t,n){switch(e){case"-eq":return t===n;case"-ne":return t!==n;case"-lt":return t<n;case"-le":return t<=n;case"-gt":return t>n;case"-ge":return t>=n}}function Ts(e){return e==="="||e==="=="||e==="!="}function ga(e,t,n,r=!1,s=!1,i=!1){if(r){let o=Zr(t,n,s,i);return e==="!="?!o:o}if(s){let o=t.toLowerCase()===n.toLowerCase();return e==="!="?!o:o}let a=t===n;return e==="!="?!a:a}var tE=new Set(["-z","-n"]);function ya(e){return tE.has(e)}function wa(e,t){switch(e){case"-z":return t==="";case"-n":return t!==""}}dt();Xe();St();Xt();async function ba(e,t){let n=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(n){let r=n[1],s=n[2];if(e.state.associativeArrays?.has(r)){let o=s;return(o.startsWith("'")&&o.endsWith("'")||o.startsWith('"')&&o.endsWith('"'))&&(o=o.slice(1,-1)),o=o.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(l,c)=>e.state.env.get(c)||""),e.state.env.has(`${r}_${o}`)}let a;try{let o=new ce,l=Ae(o,s);a=await ne(e,l.expression)}catch{if(/^-?\d+$/.test(s))a=Number.parseInt(s,10);else{let o=e.state.env.get(s);a=o?Number.parseInt(o,10):0}}if(a<0){let o=Ye(e,r),l=e.state.currentLine;if(o.length===0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
|
|
794
794
|
`,!1;if(a=Math.max(...o)+1+a,a<0)return e.state.expansionStderr=(e.state.expansionStderr||"")+`bash: line ${l}: ${r}: bad array subscript
|
|
795
|
-
`,!1}return e.state.env.has(`${r}_${a}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?sn(e,t).length>0:Ye(e,t).length>0}async function Hn(e,t){switch(t.type){case"CondBinary":{let n=await ie(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),s;if(t.operator==="=~")if(r){let i=await ie(e,t.right);s=zr(i)}else s=await dc(e,t.right);else Ts(t.operator)&&!r?s=await mc(e,t.right):s=await ie(e,t.right);if(Ts(t.operator)){let i=e.state.shoptOptions.nocasematch;return ga(t.operator,n,s,!r,i,!0)}if(da(t.operator))return ma(t.operator,await Ag(e,n),await Ag(e,s));if(pa(t.operator))return ha(e,t.operator,n,s);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,a=
|
|
795
|
+
`,!1}return e.state.env.has(`${r}_${a}`)}return e.state.env.has(t)?!0:e.state.associativeArrays?.has(t)?sn(e,t).length>0:Ye(e,t).length>0}async function Hn(e,t){switch(t.type){case"CondBinary":{let n=await ie(e,t.left),r=t.right.parts.length>0&&t.right.parts.every(i=>i.type==="SingleQuoted"||i.type==="DoubleQuoted"||i.type==="Escaped"&&t.operator!=="=~"),s;if(t.operator==="=~")if(r){let i=await ie(e,t.right);s=zr(i)}else s=await dc(e,t.right);else Ts(t.operator)&&!r?s=await mc(e,t.right):s=await ie(e,t.right);if(Ts(t.operator)){let i=e.state.shoptOptions.nocasematch;return ga(t.operator,n,s,!r,i,!0)}if(da(t.operator))return ma(t.operator,await Ag(e,n),await Ag(e,s));if(pa(t.operator))return ha(e,t.operator,n,s);switch(t.operator){case"=~":try{let i=e.state.shoptOptions.nocasematch,a=iE(s),l=V(a,i?"i":"").match(n);if(wn(e,"BASH_REMATCH"),l)for(let c=0;c<l.length;c++)e.state.env.set(`BASH_REMATCH_${c}`,l[c]||"");return l!==null}catch{throw new Error("syntax error in regular expression")}case"<":return n<s;case">":return n>s;default:return!1}}case"CondUnary":{let n=await ie(e,t.operand);return ua(t.operator)?fa(e,t.operator,n):ya(t.operator)?wa(t.operator,n):t.operator==="-v"?await ba(e,n):t.operator==="-o"?Cc(e,n):!1}case"CondNot":return e.state.shoptOptions.extglob&&t.operand.type==="CondGroup"&&t.operand.expression.type==="CondWord"?`!(${await ie(e,t.operand.expression.word)})`!=="":!await Hn(e,t.operand);case"CondAnd":return await Hn(e,t.left)?await Hn(e,t.right):!1;case"CondOr":return await Hn(e,t.left)?!0:await Hn(e,t.right);case"CondGroup":return await Hn(e,t.expression);case"CondWord":return await ie(e,t.word)!=="";default:return!1}}async function Ps(e,t){if(t.length===0)return B("","",1);if(t.length===1)return Je(!!t[0]);if(t.length===2){let r=t[0],s=t[1];return r==="("?W(`test: '(' without matching ')'
|
|
796
796
|
`,2):ua(r)?Je(await fa(e,r,s)):ya(r)?Je(wa(r,s)):r==="!"?Je(!s):r==="-v"?Je(await ba(e,s)):r==="-o"?Je(Cc(e,s)):r==="="||r==="=="||r==="!="||r==="<"||r===">"||r==="-eq"||r==="-ne"||r==="-lt"||r==="-le"||r==="-gt"||r==="-ge"||r==="-nt"||r==="-ot"||r==="-ef"?W(`test: ${r}: unary operator expected
|
|
797
797
|
`,2):B("","",1)}if(t.length===3){let r=t[0],s=t[1],i=t[2];if(Ts(s))return Je(ga(s,r,i));if(da(s)){let a=xa(r),o=xa(i);return!a.valid||!o.valid?B("","",2):Je(ma(s,a.value,o.value))}if(pa(s))return Je(await ha(e,s,r,i));switch(s){case"-a":return Je(r!==""&&i!=="");case"-o":return Je(r!==""||i!=="");case">":return Je(r>i);case"<":return Je(r<i)}if(r==="!"){let a=await Ps(e,[s,i]);return B("",a.stderr,a.exitCode===0?1:a.exitCode===1?0:a.exitCode)}if(r==="("&&i===")")return Je(s!=="")}if(t.length===4){if(t[0]==="!"){let r=await Ps(e,t.slice(1));return B("",r.stderr,r.exitCode===0?1:r.exitCode===1?0:r.exitCode)}if(t[0]==="("&&t[3]===")")return Ps(e,[t[1],t[2]])}let n=await Cg(e,t,0);return n.pos<t.length?W(`test: too many arguments
|
|
798
|
-
`,2):Je(n.value)}async function Cg(e,t,n){return
|
|
799
|
-
`)&&!r&&!s){a&&(t.push(n),n="",a=!1);continue}n+=o,a=!0}return a&&t.push(n),t}function Ea(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]!=="["){n++;continue}n++;let r="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)r+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&e[n]!=="]"&&e[n]!=="=";)r+=e[n],n++;for(;n<e.length&&e[n]!=="]";)n++;if(e[n]==="]"&&n++,e[n]!=="=")continue;n++;let s="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)e[n]==="\\"&&n+1<e.length&&n++,s+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;t.push([r,s])}return t}function $g(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:An(t[2])};let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(n)return{name:n[1],isArray:!1,arrayIndex:n[2],value:n[3]};if(e.includes("=")){let r=e.indexOf("=");return{name:e.slice(0,r),isArray:!1,value:e.slice(r+1)}}return{name:e,isArray:!1}}async function
|
|
798
|
+
`,2):Je(n.value)}async function Cg(e,t,n){return nE(e,t,n)}async function nE(e,t,n){let{value:r,pos:s}=await Eg(e,t,n);for(;t[s]==="-o";){let i=await Eg(e,t,s+1);r=r||i.value,s=i.pos}return{value:r,pos:s}}async function Eg(e,t,n){let{value:r,pos:s}=await Sc(e,t,n);for(;t[s]==="-a";){let i=await Sc(e,t,s+1);r=r&&i.value,s=i.pos}return{value:r,pos:s}}async function Sc(e,t,n){if(t[n]==="!"){let{value:r,pos:s}=await Sc(e,t,n+1);return{value:!r,pos:s}}return rE(e,t,n)}async function rE(e,t,n){let r=t[n];if(r==="("){let{value:i,pos:a}=await Cg(e,t,n+1);return{value:i,pos:t[a]===")"?a+1:a}}let s=t[n+1];if(Ts(s)){let i=r,a=t[n+2]??"";return{value:ga(s,i,a),pos:n+3}}if(da(s)){let i=xa(r),a=xa(t[n+2]??"0");return!i.valid||!a.valid?{value:!1,pos:n+3}:{value:ma(s,i.value,a.value),pos:n+3}}if(pa(s)){let i=r,a=t[n+2]??"";return{value:await ha(e,s,i,a),pos:n+3}}if(ua(r)){let i=t[n+1]??"";return{value:await fa(e,r,i),pos:n+2}}if(ya(r)){let i=t[n+1]??"";return{value:wa(r,i),pos:n+2}}if(r==="-v"){let i=t[n+1]??"";return{value:await ba(e,i),pos:n+2}}if(r==="-o"){let i=t[n+1]??"";return{value:Cc(e,i),pos:n+2}}return{value:r!==void 0&&r!=="",pos:n+1}}function Zr(e,t,n=!1,r=!1){let s=`^${Ng(t,r)}$`;return V(s,n?"is":"s").test(e)}function Ng(e,t){let n="";for(let r=0;r<e.length;r++){let s=e[r];if(t&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<e.length&&e[r+1]==="("){let i=kg(e,r+1);if(i!==-1){let a=e.slice(r+2,i),o=vg(a),l=o.map(u=>Ng(u,t)),c=l.length>0?l.join("|"):"(?:)";if(s==="@")n+=`(?:${c})`;else if(s==="*")n+=`(?:${c})*`;else if(s==="+")n+=`(?:${c})+`;else if(s==="?")n+=`(?:${c})?`;else if(s==="!")if(i<e.length-1){let f=o.map(h=>Ig(h,t));if(f.every(h=>h!==null)&&f.every(h=>h===f[0])&&f[0]!==null){let h=f[0];if(h===0)n+="(?:.+)";else{let m=[];h>0&&m.push(`.{0,${h-1}}`),m.push(`.{${h+1},}`),m.push(`(?!(?:${c})).{${h}}`),n+=`(?:${m.join("|")})`}}else n+=`(?:(?!(?:${c})).)*?`}else n+=`(?!(?:${c})$).*`;r=i;continue}}if(s==="\\")if(r+1<e.length){let i=e[r+1];/[\\^$.|+(){}[\]*?]/.test(i)?n+=`\\${i}`:n+=i,r++}else n+="\\\\";else if(s==="*")n+=".*";else if(s==="?")n+=".";else if(s==="["){let i=e.indexOf("]",r+1);i!==-1?(n+=e.slice(r,i+1),r=i):n+="\\["}else/[\\^$.|+(){}]/.test(s)?n+=`\\${s}`:n+=s}return n}function kg(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 vg(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 Ig(e,t){let n=0,r=0;for(;r<e.length;){let s=e[r];if(t&&(s==="@"||s==="*"||s==="+"||s==="?"||s==="!")&&r+1<e.length&&e[r+1]==="("){let i=kg(e,r+1);if(i!==-1){if(s==="@"){let a=e.slice(r+2,i),l=vg(a).map(c=>Ig(c,t));if(l.every(c=>c!==null)&&l.every(c=>c===l[0])){n+=l[0],r=i+1;continue}return null}return null}}if(s==="*")return null;if(s==="?"){n+=1,r++;continue}if(s==="["){let i=e.indexOf("]",r+1);if(i!==-1){n+=1,r=i+1;continue}n+=1,r++;continue}if(s==="\\"){n+=1,r+=2;continue}n+=1,r++}return n}function Cc(e,t){let r=new Map([["errexit",()=>e.state.options.errexit===!0],["nounset",()=>e.state.options.nounset===!0],["pipefail",()=>e.state.options.pipefail===!0],["xtrace",()=>e.state.options.xtrace===!0],["e",()=>e.state.options.errexit===!0],["u",()=>e.state.options.nounset===!0],["x",()=>e.state.options.xtrace===!0]]).get(t);return r?r():!1}async function Ag(e,t){if(t=t.trim(),t==="")return 0;if(/^[+-]?(\d+#[a-zA-Z0-9@_]+|0[xX][0-9a-fA-F]+|0[0-7]+|\d+)$/.test(t))return Sg(t);try{let n=new ce,r=Ae(n,t);return await ne(e,r.expression)}catch{return Sg(t)}}function sE(e,t){let n=0;for(let r of e){let s;if(r>="0"&&r<="9")s=r.charCodeAt(0)-48;else if(r>="a"&&r<="z")s=r.charCodeAt(0)-97+10;else if(r>="A"&&r<="Z")s=r.charCodeAt(0)-65+36;else if(r==="@")s=62;else if(r==="_")s=63;else return Number.NaN;if(s>=t)return Number.NaN;n=n*t+s}return n}function Sg(e){if(e=e.trim(),e==="")return 0;let t=!1;e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1));let n,r=e.match(/^(\d+)#([a-zA-Z0-9@_]+)$/);if(r){let s=Number.parseInt(r[1],10);s>=2&&s<=64?n=sE(r[2],s):n=0}else/^0[xX][0-9a-fA-F]+$/.test(e)?n=Number.parseInt(e,16):/^0[0-7]+$/.test(e)?n=Number.parseInt(e,8):n=Number.parseInt(e,10);return Number.isNaN(n)&&(n=0),t?-n:n}function xa(e){if(e=e.trim(),e==="")return{value:0,valid:!0};let t=!1;if(e.startsWith("-")?(t=!0,e=e.slice(1)):e.startsWith("+")&&(e=e.slice(1)),!/^\d+$/.test(e))return{value:0,valid:!1};let n=Number.parseInt(e,10);return Number.isNaN(n)?{value:0,valid:!1}:{value:t?-n:n,valid:!0}}function iE(e){let t="",n=0;for(;n<e.length;)if(e[n]==="\\"&&n+1<e.length)t+=e[n]+e[n+1],n+=2;else if(e[n]==="["){let r=aE(e,n);t+=r.converted,n=r.endIndex}else t+=e[n],n++;return t}function aE(e,t){let n=t+1,r="[";n<e.length&&(e[n]==="^"||e[n]==="!")&&(r+="^",n++);let s=!1;n<e.length&&e[n]==="]"&&(s=!0,n++);let i=!1;n<e.length&&e[n]==="["&&n+1<e.length&&e[n+1]!==":"&&(i=!0,n++);let a="",o=!1;for(;n<e.length;){let l=e[n];if(l==="]"){o=!0,n++;break}if(l==="["&&n+1<e.length&&e[n+1]===":"){let c=e.indexOf(":]",n+2);if(c!==-1){let u=e.slice(n+2,c);a+=oE(u),n=c+2;continue}}if(l==="["&&n+1<e.length){let c=e[n+1];if(c==="."||c==="="){let u=`${c}]`,f=e.indexOf(u,n+2);if(f!==-1){let p=e.slice(n+2,f);a+=p,n=f+2;continue}}}if(l==="\\"&&n+1<e.length){a+=l+e[n+1],n+=2;continue}a+=l,n++}return o?(s&&(r+="\\]"),i&&(r+="\\["),r+=a,r+="]",{converted:r,endIndex:n}):{converted:"\\[",endIndex:t+1}}function oE(e){return 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"]]).get(e)??""}Ct();dt();Xe();St();Bn();function An(e){let t=[],n="",r=!1,s=!1,i=!1,a=!1;for(let o of e){if(i){n+=o,i=!1,a=!0;continue}if(o==="\\"){i=!0;continue}if(o==="'"&&!s){r||(a=!0),r=!r;continue}if(o==='"'&&!r){s||(a=!0),s=!s;continue}if((o===" "||o===" "||o===`
|
|
799
|
+
`)&&!r&&!s){a&&(t.push(n),n="",a=!1);continue}n+=o,a=!0}return a&&t.push(n),t}function Ea(e){let t=[],n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if(e[n]!=="["){n++;continue}n++;let r="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)r+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&e[n]!=="]"&&e[n]!=="=";)r+=e[n],n++;for(;n<e.length&&e[n]!=="]";)n++;if(e[n]==="]"&&n++,e[n]!=="=")continue;n++;let s="";if(e[n]==="'"||e[n]==='"'){let i=e[n];for(n++;n<e.length&&e[n]!==i;)e[n]==="\\"&&n+1<e.length&&n++,s+=e[n],n++;e[n]===i&&n++}else for(;n<e.length&&!/\s/.test(e[n]);)s+=e[n],n++;t.push([r,s])}return t}function $g(e){let t=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(t)return{name:t[1],isArray:!0,arrayElements:An(t[2])};let n=e.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(n)return{name:n[1],isArray:!1,arrayIndex:n[2],value:n[3]};if(e.includes("=")){let r=e.indexOf("=");return{name:e.slice(0,r),isArray:!1,value:e.slice(r+1)}}return{name:e,isArray:!1}}async function lE(e,t){try{let n=new ce,r=Ae(n,t);return await ne(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}async function Og(e,t,n={}){let{name:r,isArray:s,arrayElements:i,value:a,arrayIndex:o}=t,{makeReadonly:l=!1,checkReadonly:c=!0}=n;if(c){let u=it(e,r);if(u)return u}if(s&&i){for(let u=0;u<i.length;u++)e.state.env.set(`${r}_${u}`,i[u]);e.state.env.set(`${r}__length`,String(i.length))}else if(o!==void 0&&a!==void 0){let u=await lE(e,o);e.state.env.set(`${r}_${u}`,a);let f=parseInt(e.state.env.get(`${r}__length`)??"0",10);u>=f&&e.state.env.set(`${r}__length`,String(u+1))}else a!==void 0&&e.state.env.set(r,a);return l&&Lt(e,r),null}function jn(e,t){e.state.localVarDepth=e.state.localVarDepth||new Map,e.state.localVarDepth.set(t,e.state.callDepth)}function Kr(e,t){return e.state.localVarDepth?.get(t)}function Aa(e,t){e.state.localVarDepth?.delete(t)}function Rg(e,t,n){e.state.localVarStack=e.state.localVarStack||new Map;let r=e.state.localVarStack.get(t)||[];r.push({value:n,scopeIndex:e.state.localScopes.length-1}),e.state.localVarStack.set(t,r)}function Sa(e,t){let n=e.state.localVarStack?.get(t);if(!(!n||n.length===0))return n.pop()}function Tg(e,t){if(e.state.localVarStack)for(let[n,r]of e.state.localVarStack.entries()){for(;r.length>0&&r[r.length-1].scopeIndex===t;)r.pop();r.length===0&&e.state.localVarStack.delete(n)}}ye();Ct();var Nc=new Set([":",".","break","continue","eval","exec","exit","export","readonly","return","set","shift","trap","unset"]);function Pg(e){return Nc.has(e)}var kc=new Set(["if","then","else","elif","fi","case","esac","for","select","while","until","do","done","in","function","{","}","time","[[","]]","!"]),Qr=new Set([":","true","false","cd","export","unset","exit","local","set","break","continue","return","eval","shift","getopts","compgen","complete","compopt","pushd","popd","dirs","source",".","read","mapfile","readarray","declare","typeset","readonly","let","command","shopt","exec","test","[","echo","printf","pwd","alias","unalias","type","hash","ulimit","umask","trap","times","wait","kill","jobs","fg","bg","disown","suspend","fc","history","help","enable","builtin","caller"]);Ct();async function ur(e,t,n,r){try{if((await e.fs.stat(t)).isDirectory)return`bash: ${n}: Is a directory
|
|
800
800
|
`;if(r.checkNoclobber&&e.state.options.noclobber&&!r.isClobber&&n!=="/dev/null")return`bash: ${n}: cannot overwrite existing file
|
|
801
|
-
`}catch{}return null}function at(e){let n=Math.min(e.length,8192);for(let r=0;r<n;r++)if(e.charCodeAt(r)>255)return"utf8";return"binary"}function
|
|
802
|
-
`};n.set(r,await ie(e,s.target))}else{let a=await Rs(e,s.target);if("error"in a)return{targets:n,error:a.error};n.set(r,a.target)}}return{targets:n}}function
|
|
801
|
+
`}catch{}return null}function at(e){let n=Math.min(e.length,8192);for(let r=0;r<n;r++)if(e.charCodeAt(r)>255)return"utf8";return"binary"}function cE(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),a=s+r+1,o=t.slice(a),l=o.indexOf(":");if(l===-1)return null;let c=Number.parseInt(o.slice(0,l),10);if(Number.isNaN(c)||c<0)return null;let u=o.slice(l+1);return{path:i,position:c,content:u}}async function Dg(e,t){let n=new Map;for(let r=0;r<t.length;r++){let s=t[r];if(s.target.type==="HereDoc")continue;if(s.operator===">&"||s.operator==="<&"){if(Os(e,s.target))return{targets:n,error:`bash: $@: ambiguous redirect
|
|
802
|
+
`};n.set(r,await ie(e,s.target))}else{let a=await Rs(e,s.target);if("error"in a)return{targets:n,error:a.error};n.set(r,a.target)}}return{targets:n}}function uE(e){e.state.nextFd===void 0&&(e.state.nextFd=10);let t=e.state.nextFd;return e.state.nextFd++,t}async function Ca(e,t){for(let n of t){if(!n.fdVariable)continue;if(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),(n.operator===">&"||n.operator==="<&")&&n.target.type==="Word"&&await ie(e,n.target)==="-"){let i=e.state.env.get(n.fdVariable);if(i!==void 0){let a=Number.parseInt(i,10);Number.isNaN(a)||e.state.fileDescriptors.delete(a)}continue}let r=uE(e);if(e.state.env.set(n.fdVariable,String(r)),n.target.type==="Word"){let s=await ie(e,n.target);if(n.operator===">&"||n.operator==="<&"){let i=Number.parseInt(s,10);if(!Number.isNaN(i)){let a=e.state.fileDescriptors.get(i);a!==void 0&&e.state.fileDescriptors.set(r,a);continue}}if(n.operator===">"||n.operator===">>"||n.operator===">|"||n.operator==="&>"||n.operator==="&>>"){let i=e.fs.resolvePath(e.state.cwd,s);(n.operator===">"||n.operator===">|"||n.operator==="&>")&&await e.fs.writeFile(i,"","binary"),e.state.fileDescriptors.set(r,`__file__:${i}`)}else if(n.operator==="<<<")e.state.fileDescriptors.set(r,`${s}
|
|
803
803
|
`);else if(n.operator==="<"||n.operator==="<>")try{let i=e.fs.resolvePath(e.state.cwd,s),a=await e.fs.readFile(i);e.state.fileDescriptors.set(r,a)}catch{return B("",`bash: ${s}: No such file or directory
|
|
804
804
|
`,1)}}}return null}async function Sn(e,t){for(let n of t){if(n.target.type==="HereDoc")continue;let r=n.operator===">&";if(n.operator!==">"&&n.operator!==">|"&&n.operator!=="&>"&&!r)continue;let s;if(r){if(s=await ie(e,n.target),s==="-"||!Number.isNaN(Number.parseInt(s,10))||n.fd!=null)continue}else{let o=await Rs(e,n.target);if("error"in o)return B("",o.error,1);s=o.target}let i=e.fs.resolvePath(e.state.cwd,s),a=n.operator===">|";if(i.includes("\0"))return B("",`bash: ${s}: No such file or directory
|
|
805
805
|
`,1);try{let o=await e.fs.stat(i);if(o.isDirectory)return B("",`bash: ${s}: Is a directory
|
|
@@ -812,15 +812,15 @@ Gid: ${s} ${s} ${s} ${s}
|
|
|
812
812
|
`,a=1;break}if(f==="/dev/null")i="";else{let d=e.fs.resolvePath(e.state.cwd,f),g=await ur(e,d,f,{checkNoclobber:!0,isClobber:m});if(g){i+=g,a=1;break}await e.fs.writeFile(d,i,at(i)),i=""}}break}case">>":{let h=u.fd??1;if(h===1){if(f==="/dev/stdout")break;if(f==="/dev/stderr"){i+=s,s="";break}if(f==="/dev/full"){i+=`bash: echo: write error: No space left on device
|
|
813
813
|
`,a=1,s="";break}let m=e.fs.resolvePath(e.state.cwd,f),d=await ur(e,m,f,{});if(d){i+=d,a=1,s="";break}await e.fs.appendFile(m,s,at(s)),s=""}else if(h===2){if(f==="/dev/stderr")break;if(f==="/dev/stdout"){s+=i,i="";break}if(f==="/dev/full"){i+=`bash: echo: write error: No space left on device
|
|
814
814
|
`,a=1;break}let m=e.fs.resolvePath(e.state.cwd,f),d=await ur(e,m,f,{});if(d){i+=d,a=1;break}await e.fs.appendFile(m,i,at(i)),i=""}break}case">&":case"<&":{let h=u.fd??1;if(f==="-")break;if(f.endsWith("-")){let m=f.slice(0,-1),d=Number.parseInt(m,10);if(!Number.isNaN(d)){let g=e.state.fileDescriptors?.get(d);g!==void 0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(h,g),d>=3&&e.state.fileDescriptors?.delete(d)):d===1||d===2?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(h,`__dupout__:${d}`)):d===0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(h,`__dupin__:${d}`)):d>=3&&(i+=`bash: ${d}: Bad file descriptor
|
|
815
|
-
`,a=1)}break}if(f==="2"||f==="&2")h===1&&(i+=s,s="");else if(f==="1"||f==="&1")s+=i,i="";else{let m=Number.parseInt(f,10);if(Number.isNaN(m)){if(u.operator===">&"){let d=e.fs.resolvePath(e.state.cwd,f),g=await ur(e,d,f,{checkNoclobber:!0});if(g){i=g,a=1,s="";break}if(u.fd==null){let w=s+i;await e.fs.writeFile(d,w,at(w)),s="",i=""}else h===1?(await e.fs.writeFile(d,s,at(s)),s=""):h===2&&(await e.fs.writeFile(d,i,at(i)),i="")}}else{let d=e.state.fileDescriptors?.get(m);if(d?.startsWith("__file__:")){let g=d.slice(9);h===1?(await e.fs.appendFile(g,s,at(s)),s=""):h===2&&(await e.fs.appendFile(g,i,at(i)),i="")}else if(d?.startsWith("__rw__:")){let g=
|
|
815
|
+
`,a=1)}break}if(f==="2"||f==="&2")h===1&&(i+=s,s="");else if(f==="1"||f==="&1")s+=i,i="";else{let m=Number.parseInt(f,10);if(Number.isNaN(m)){if(u.operator===">&"){let d=e.fs.resolvePath(e.state.cwd,f),g=await ur(e,d,f,{checkNoclobber:!0});if(g){i=g,a=1,s="";break}if(u.fd==null){let w=s+i;await e.fs.writeFile(d,w,at(w)),s="",i=""}else h===1?(await e.fs.writeFile(d,s,at(s)),s=""):h===2&&(await e.fs.writeFile(d,i,at(i)),i="")}}else{let d=e.state.fileDescriptors?.get(m);if(d?.startsWith("__file__:")){let g=d.slice(9);h===1?(await e.fs.appendFile(g,s,at(s)),s=""):h===2&&(await e.fs.appendFile(g,i,at(i)),i="")}else if(d?.startsWith("__rw__:")){let g=cE(d);g&&(h===1?(await e.fs.appendFile(g.path,s,at(s)),s=""):h===2&&(await e.fs.appendFile(g.path,i,at(i)),i=""))}else if(d?.startsWith("__dupout__:")){let g=Number.parseInt(d.slice(11),10);if(g!==1)if(g===2)h===1&&(i+=s,s="");else{let w=e.state.fileDescriptors?.get(g);if(w?.startsWith("__file__:")){let y=w.slice(9);h===1?(await e.fs.appendFile(y,s,at(s)),s=""):h===2&&(await e.fs.appendFile(y,i,at(i)),i="")}}}else d?.startsWith("__dupin__:")?(i+=`bash: ${m}: Bad file descriptor
|
|
816
816
|
`,a=1,s=""):m>=3&&(i+=`bash: ${m}: Bad file descriptor
|
|
817
817
|
`,a=1,s="")}}break}case"&>":{if(f==="/dev/full"){i=`bash: echo: write error: No space left on device
|
|
818
818
|
`,a=1,s="";break}let h=e.fs.resolvePath(e.state.cwd,f),m=await ur(e,h,f,{checkNoclobber:!0});if(m){i=m,a=1,s="";break}let d=s+i;await e.fs.writeFile(h,d,at(d)),s="",i="";break}case"&>>":{if(f==="/dev/full"){i=`bash: echo: write error: No space left on device
|
|
819
819
|
`,a=1,s="";break}let h=e.fs.resolvePath(e.state.cwd,f),m=await ur(e,h,f,{});if(m){i=m,a=1,s="";break}let d=s+i;await e.fs.appendFile(h,d,at(d)),s="",i="";break}}}}let o=e.state.fileDescriptors?.get(1);if(o){if(o==="__dupout__:2")i+=s,s="";else if(o.startsWith("__file__:")){let c=o.slice(9);await e.fs.appendFile(c,s,at(s)),s=""}else if(o.startsWith("__file_append__:")){let c=o.slice(16);await e.fs.appendFile(c,s,at(s)),s=""}}let l=e.state.fileDescriptors?.get(2);if(l){if(l==="__dupout__:1")s+=i,i="";else if(l.startsWith("__file__:")){let c=l.slice(9);await e.fs.appendFile(c,i,at(i)),i=""}else if(l.startsWith("__file_append__:")){let c=l.slice(16);await e.fs.appendFile(c,i,at(i)),i=""}}return B(s,i,a)}function _g(e,t){if(e.state.options.posix&&Nc.has(t.name)){let r=`bash: line ${e.state.currentLine}: \`${t.name}': is a special builtin
|
|
820
|
-
`;throw new pe(2,"",r)}let n={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,n),de}async function
|
|
820
|
+
`;throw new pe(2,"",r)}let n={...t,sourceFile:t.sourceFile??e.state.currentSource??"main"};return e.state.functions.set(t.name,n),de}async function fE(e,t){let n="";for(let r of t)if((r.operator==="<<"||r.operator==="<<-")&&r.target.type==="HereDoc"){let s=r.target,i=await ie(e,s.content);s.stripTabs&&(i=i.split(`
|
|
821
821
|
`).map(o=>o.replace(/^\t+/,"")).join(`
|
|
822
822
|
`)),(r.fd??0)===0&&(n=i)}else if(r.operator==="<<<"&&r.target.type==="Word")n=`${await ie(e,r.target)}
|
|
823
|
-
`;else if(r.operator==="<"&&r.target.type==="Word"){let s=await ie(e,r.target),i=e.fs.resolvePath(e.state.cwd,s);try{n=await e.fs.readFile(i)}catch{}}return n}async function Na(e,t,n,r="",s){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,On(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(s??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??"main"),e.state.localScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let i=new Map;for(let c=0;c<n.length;c++)i.set(String(c+1),e.state.env.get(String(c+1))),e.state.env.set(String(c+1),n[c]);i.set("@",e.state.env.get("@")),i.set("#",e.state.env.get("#")),e.state.env.set("@",n.join(" ")),e.state.env.set("#",String(n.length));let a=()=>{let c=e.state.localScopes.length-1,u=e.state.localScopes.pop();if(u)for(let[f,p]of u)p===void 0?e.state.env.delete(f):e.state.env.set(f,p);if(Tg(e,c),e.state.fullyUnsetLocals)for(let[f,p]of e.state.fullyUnsetLocals.entries())p===c&&e.state.fullyUnsetLocals.delete(f);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let f=e.state.localExportedVars.pop();if(f)for(let p of f)e.state.exportedVars?.delete(p)}for(let[f,p]of i)p===void 0?e.state.env.delete(f):e.state.env.set(f,p);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},{targets:o,error:l}=await Dg(e,t.redirections);if(l)return a(),B("",l,1);try{let c=await
|
|
823
|
+
`;else if(r.operator==="<"&&r.target.type==="Word"){let s=await ie(e,r.target),i=e.fs.resolvePath(e.state.cwd,s);try{n=await e.fs.readFile(i)}catch{}}return n}async function Na(e,t,n,r="",s){e.state.callDepth++,e.state.callDepth>e.limits.maxCallDepth&&(e.state.callDepth--,On(`${t.name}: maximum recursion depth (${e.limits.maxCallDepth}) exceeded, increase executionLimits.maxCallDepth`,"recursion")),e.state.funcNameStack||(e.state.funcNameStack=[]),e.state.callLineStack||(e.state.callLineStack=[]),e.state.sourceStack||(e.state.sourceStack=[]),e.state.funcNameStack.unshift(t.name),e.state.callLineStack.unshift(s??e.state.currentLine),e.state.sourceStack.unshift(t.sourceFile??"main"),e.state.localScopes.push(new Map),e.state.localExportedVars||(e.state.localExportedVars=[]),e.state.localExportedVars.push(new Set);let i=new Map;for(let c=0;c<n.length;c++)i.set(String(c+1),e.state.env.get(String(c+1))),e.state.env.set(String(c+1),n[c]);i.set("@",e.state.env.get("@")),i.set("#",e.state.env.get("#")),e.state.env.set("@",n.join(" ")),e.state.env.set("#",String(n.length));let a=()=>{let c=e.state.localScopes.length-1,u=e.state.localScopes.pop();if(u)for(let[f,p]of u)p===void 0?e.state.env.delete(f):e.state.env.set(f,p);if(Tg(e,c),e.state.fullyUnsetLocals)for(let[f,p]of e.state.fullyUnsetLocals.entries())p===c&&e.state.fullyUnsetLocals.delete(f);if(e.state.localExportedVars&&e.state.localExportedVars.length>0){let f=e.state.localExportedVars.pop();if(f)for(let p of f)e.state.exportedVars?.delete(p)}for(let[f,p]of i)p===void 0?e.state.env.delete(f):e.state.env.set(f,p);e.state.funcNameStack?.shift(),e.state.callLineStack?.shift(),e.state.sourceStack?.shift(),e.state.callDepth--},{targets:o,error:l}=await Dg(e,t.redirections);if(l)return a(),B("",l,1);try{let c=await fE(e,t.redirections),u=r||c,f=await e.executeCommand(t.body,u);return a(),ze(e,f,t.redirections,o)}catch(c){if(a(),c instanceof ct){let u=B(c.stdout,c.stderr,c.exitCode);return ze(e,u,t.redirections,o)}throw c}}var Fg=["!","[[","]]","case","do","done","elif","else","esac","fi","for","function","if","in","then","time","until","while","{","}"],Ic=[".",":","[","alias","bg","bind","break","builtin","caller","cd","command","compgen","complete","compopt","continue","declare","dirs","disown","echo","enable","eval","exec","exit","export","false","fc","fg","getopts","hash","help","history","jobs","kill","let","local","logout","mapfile","popd","printf","pushd","pwd","read","readarray","readonly","return","set","shift","shopt","source","suspend","test","times","trap","true","type","typeset","ulimit","umask","unalias","unset","wait"],pE=["autocd","assoc_expand_once","cdable_vars","cdspell","checkhash","checkjobs","checkwinsize","cmdhist","compat31","compat32","compat40","compat41","compat42","compat43","compat44","complete_fullquote","direxpand","dirspell","dotglob","execfail","expand_aliases","extdebug","extglob","extquote","failglob","force_fignore","globasciiranges","globstar","gnu_errfmt","histappend","histreedit","histverify","hostcomplete","huponexit","inherit_errexit","interactive_comments","lastpipe","lithist","localvar_inherit","localvar_unset","login_shell","mailwarn","no_empty_cmd_completion","nocaseglob","nocasematch","nullglob","progcomp","progcomp_alias","promptvars","restricted_shell","shift_verbose","sourcepath","xpg_echo"],hE=Ic;async function $c(e,t){let n=[],r=null,s="",i="",a=null,o=!1,l=!1,c=!1,u=null,f=null,p=null,h=[],m=["alias","arrayvar","binding","builtin","command","directory","disabled","enabled","export","file","function","group","helptopic","hostname","job","keyword","running","service","setopt","shopt","signal","stopped","user","variable"];for(let x=0;x<t.length;x++){let S=t[x];if(S==="-v")n.push("variable");else if(S==="-e")n.push("export");else if(S==="-f")n.push("file");else if(S==="-d")n.push("directory");else if(S==="-k")n.push("keyword");else if(S==="-A"){if(x++,x>=t.length)return W(`compgen: -A: option requires an argument
|
|
824
824
|
`,2);let $=t[x];if(!m.includes($))return W(`compgen: ${$}: invalid action name
|
|
825
825
|
`,2);n.push($)}else if(S==="-W"){if(x++,x>=t.length)return W(`compgen: -W: option requires an argument
|
|
826
826
|
`,2);r=t[x]}else if(S==="-P"){if(x++,x>=t.length)return W(`compgen: -P: option requires an argument
|
|
@@ -831,15 +831,15 @@ Gid: ${s} ${s} ${s} ${s}
|
|
|
831
831
|
`,2);f=t[x]}else if(S==="-C"){if(x++,x>=t.length)return W(`compgen: -C: option requires an argument
|
|
832
832
|
`,2);p=t[x]}else if(S==="-X"){if(x++,x>=t.length)return W(`compgen: -X: option requires an argument
|
|
833
833
|
`,2);u=t[x]}else if(S==="-G"){if(x++,x>=t.length)return W(`compgen: -G: option requires an argument
|
|
834
|
-
`,2)}else if(S==="--"){h.push(...t.slice(x+1));break}else S.startsWith("-")||h.push(S)}a=h[0]??null;let d=[];if(l){let x=await vc(e,a);d.push(...x)}if(c){let x=await Lg(e,a);d.push(...x)}for(let x of n)if(x==="variable"){let S=
|
|
834
|
+
`,2)}else if(S==="--"){h.push(...t.slice(x+1));break}else S.startsWith("-")||h.push(S)}a=h[0]??null;let d=[];if(l){let x=await vc(e,a);d.push(...x)}if(c){let x=await Lg(e,a);d.push(...x)}for(let x of n)if(x==="variable"){let S=dE(e,a);d.push(...S)}else if(x==="export"){let S=mE(e,a);d.push(...S)}else if(x==="function"){let S=gE(e,a);d.push(...S)}else if(x==="builtin"){let S=yE(a);d.push(...S)}else if(x==="keyword"){let S=wE(a);d.push(...S)}else if(x==="alias"){let S=bE(e,a);d.push(...S)}else if(x==="shopt"){let S=xE(a);d.push(...S)}else if(x==="helptopic"){let S=EE(a);d.push(...S)}else if(x==="directory"){let S=await vc(e,a);d.push(...S)}else if(x==="file"){let S=await Lg(e,a);d.push(...S)}else if(x==="user"){let S=AE(a);d.push(...S)}else if(x==="command"){let S=await SE(e,a);d.push(...S)}if(r!==null)try{let x=await CE(e,r),S=NE(e,x);for(let $ of S)(a===null||$.startsWith(a))&&d.push($)}catch{return B("","",1)}if(o){let x=await vc(e,a);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 $=new Map;for(let F of e.state.env.keys())(F==="COMPREPLY"||F.startsWith("COMPREPLY_")||F==="COMPREPLY__length")&&($.set(F,e.state.env.get(F)),e.state.env.delete(F));let O=["compgen",h[0]??"",""];try{let F=await Na(e,x,O,"");if(F.exitCode!==0)return Xr(e,S),Xr(e,$),B("",F.stderr,1);g=F.stdout;let R=kE(e);d.push(...R)}catch{return Xr(e,S),Xr(e,$),B("","",1)}Xr(e,S),Xr(e,$)}}if(p!==null)try{let x=rn(p),S=await e.executeScript(x);if(S.exitCode!==0)return B("",S.stderr,S.exitCode);if(S.stdout){let $=S.stdout.split(`
|
|
835
835
|
`);for(let O of $)O.length>0&&d.push(O)}}catch(x){if(x.name==="ParseException")return W(`compgen: -C: ${x.message}
|
|
836
836
|
`,2);throw x}let w=d;if(u!==null){let x=u.startsWith("!"),S=x?u.slice(1):u;w=d.filter($=>{let O=Zr($,S,!1,!0);return x?O:!O})}if(w.length===0&&a!==null)return B(g,"",1);let y=w.map(x=>`${s}${x}${i}`).join(`
|
|
837
837
|
`),b=g+(y?`${y}
|
|
838
|
-
`:"");return ge(b)}function
|
|
839
|
-
`;if(n.length===0)return[t];let r=new Set(n.split("")),s=[],i="",a=0;for(;a<t.length;){let o=t[a];if(o==="\\"&&a+1<t.length){let l=t[a+1];i+=l,a+=2}else r.has(o)?(i.length>0&&(s.push(i),i=""),a++):(i+=o,a++)}return i.length>0&&s.push(i),s}function Xr(e,t){for(let[n,r]of t)r===void 0?e.state.env.delete(n):e.state.env.set(n,r)}function
|
|
838
|
+
`:"");return ge(b)}function dE(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 mE(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 gE(e,t){let n=Array.from(e.state.functions.keys());return t!==null&&(n=n.filter(r=>r.startsWith(t))),n.sort()}function yE(e){let t=[...Ic];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function wE(e){let t=[...Fg];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function bE(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 xE(e){let t=[...pE];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function EE(e){let t=[...hE];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}async function vc(e,t){let n=[];try{let r=e.state.cwd,s=t??"";if(t){let a=t.lastIndexOf("/");if(a!==-1){let o=t.slice(0,a)||"/";s=t.slice(a+1),o.startsWith("/")?r=o:r=`${e.state.cwd}/${o}`}}let i=await e.fs.readdir(r);for(let a of i){let o=`${r}/${a}`;try{if((await e.fs.stat(o)).isDirectory&&(!s||a.startsWith(s)))if(t?.includes("/")){let c=t.lastIndexOf("/"),u=t.slice(0,c+1);n.push(u+a)}else n.push(a)}catch{}}}catch{}return n.sort()}async function Lg(e,t){let n=[];try{let r=e.state.cwd,s=t??"";if(t){let a=t.lastIndexOf("/");if(a!==-1){let o=t.slice(0,a)||"/";s=t.slice(a+1),o.startsWith("/")?r=o:r=`${e.state.cwd}/${o}`}}let i=await e.fs.readdir(r);for(let a of i)if(!s||a.startsWith(s))if(t?.includes("/")){let o=t.lastIndexOf("/"),l=t.slice(0,o+1);n.push(l+a)}else n.push(a)}catch{}return n.sort()}function AE(e){return["root","nobody"]}async function SE(e,t){let n=new Set;for(let i of Ic)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 Fg)n.add(i);let r=e.state.env.get("PATH")??"/usr/bin:/bin";for(let i of r.split(":"))if(i)try{let a=await e.fs.readdir(i);for(let o of a)n.add(o)}catch{}let s=Array.from(n);return t!==null&&(s=s.filter(i=>i.startsWith(t))),s.sort()}async function CE(e,t){let r=new ce().parseWordFromString(t,!1,!1);return await ie(e,r)}function NE(e,t){let n=e.state.env.get("IFS")??`
|
|
839
|
+
`;if(n.length===0)return[t];let r=new Set(n.split("")),s=[],i="",a=0;for(;a<t.length;){let o=t[a];if(o==="\\"&&a+1<t.length){let l=t[a+1];i+=l,a+=2}else r.has(o)?(i.length>0&&(s.push(i),i=""),a++):(i+=o,a++)}return i.length>0&&s.push(i),s}function Xr(e,t){for(let[n,r]of t)r===void 0?e.state.env.delete(n):e.state.env.set(n,r)}function kE(e){let t=[];if(e.state.env.get("COMPREPLY__length")!==void 0){let s=oe(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 vE=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function Rc(e,t){e.state.completionSpecs||(e.state.completionSpecs=new Map);let n=!1,r=!1,s=!1,i,a,o,l=[],c=[],u=[];for(let f=0;f<t.length;f++){let p=t[f];if(p==="-p")n=!0;else if(p==="-r")r=!0;else if(p==="-D")s=!0;else if(p==="-W"){if(f++,f>=t.length)return W(`complete: -W: option requires an argument
|
|
840
840
|
`,2);i=t[f]}else if(p==="-F"){if(f++,f>=t.length)return W(`complete: -F: option requires an argument
|
|
841
841
|
`,2);a=t[f]}else if(p==="-o"){if(f++,f>=t.length)return W(`complete: -o: option requires an argument
|
|
842
|
-
`,2);let h=t[f];if(!
|
|
842
|
+
`,2);let h=t[f];if(!vE.includes(h))return W(`complete: ${h}: invalid option name
|
|
843
843
|
`,2);l.push(h)}else if(p==="-A"){if(f++,f>=t.length)return W(`complete: -A: option requires an argument
|
|
844
844
|
`,2);c.push(t[f])}else if(p==="-C"){if(f++,f>=t.length)return W(`complete: -C: option requires an argument
|
|
845
845
|
`,2);o=t[f]}else if(p==="-G"){if(f++,f>=t.length)return W(`complete: -G: option requires an argument
|
|
@@ -860,7 +860,7 @@ Gid: ${s} ${s} ${s} ${s}
|
|
|
860
860
|
`,2);i.push(c)}else if(l==="--"){a.push(...t.slice(o+1));break}else!l.startsWith("-")&&!l.startsWith("+")&&a.push(l)}if(n){let o=e.state.completionSpecs.get("__default__")??{isDefault:!0},l=new Set(o.options??[]);for(let c of s)l.add(c);for(let c of i)l.delete(c);return o.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__default__",o),ge("")}if(r){let o=e.state.completionSpecs.get("__empty__")??{},l=new Set(o.options??[]);for(let c of s)l.add(c);for(let c of i)l.delete(c);return o.options=l.size>0?Array.from(l):void 0,e.state.completionSpecs.set("__empty__",o),ge("")}if(a.length>0){for(let o of a){let l=e.state.completionSpecs.get(o)??{},c=new Set(l.options??[]);for(let u of s)c.add(u);for(let u of i)c.delete(u);l.options=c.size>0?Array.from(c):void 0,e.state.completionSpecs.set(o,l)}return ge("")}return W(`compopt: not currently executing completion function
|
|
861
861
|
`,1)}ye();function Pc(e,t){if(e.state.loopDepth===0){if(e.state.parentHasLoopContext)throw new pn;return de}if(t.length>1)throw new pe(1,"",`bash: continue: too many arguments
|
|
862
862
|
`);let n=1;if(t.length>0){let r=Number.parseInt(t[0],10);if(Number.isNaN(r)||r<1)throw new pe(1,"",`bash: continue: ${t[0]}: numeric argument required
|
|
863
|
-
`);n=r}throw new ht(n)}
|
|
863
|
+
`);n=r}throw new ht(n)}dt();Xe();St();Xt();an();Bn();function qe(e,t){let n=e.state.env.get("HOME")||"/home/user";return t.split(":").map(i=>i==="~"?n:i==="~root"?"/root":i.startsWith("~/")?n+i.slice(1):i.startsWith("~root/")?`/root${i.slice(5)}`:i).join(":")}Xt();an();function Dc(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!0}return!1}function _c(e){let t="$'";for(let n=0;n<e.length;n++){let r=e[n],s=e.charCodeAt(n);s===7?t+="\\a":s===8?t+="\\b":s===9?t+="\\t":s===10?t+="\\n":s===11?t+="\\v":s===12?t+="\\f":s===13?t+="\\r":s===27?t+="\\e":s===39?t+="\\'":s===92?t+="\\\\":s<32||s===127?t+=`\\${s.toString(8).padStart(3,"0")}`:t+=r}return t+="'",t}function ka(e){return Dc(e)?_c(e):/^[a-zA-Z0-9_/.:\-@%+,=]*$/.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function fr(e){return Dc(e)?_c(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Lc(e){return Dc(e)?_c(e):`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Ug(e,t){let n="";return e.state.integerVars?.has(t)&&(n+="i"),e.state.lowercaseVars?.has(t)&&(n+="l"),Te(e,t)&&(n+="n"),e.state.readonlyVars?.has(t)&&(n+="r"),e.state.uppercaseVars?.has(t)&&(n+="u"),e.state.exportedVars?.has(t)&&(n+="x"),n===""?"--":`-${n}`}function Fc(e){return e===""?"''":/[\s'\\]/.test(e)?`'${e.replace(/'/g,"'\\''")}'`:e}function Wg(e,t){let n="",r="",s=!1;for(let i of t){let a=Ug(e,i);if(e.state.associativeArrays?.has(i)){let u=sn(e,i);if(u.length===0)n+=`declare -A ${i}=()
|
|
864
864
|
`;else{let f=u.map(p=>{let h=e.state.env.get(`${i}_${p}`)??"",m=Fc(h);return`['${p}']=${m}`});n+=`declare -A ${i}=(${f.join(" ")})
|
|
865
865
|
`}continue}let l=Ye(e,i);if(l.length>0){let u=l.map(f=>{let p=e.state.env.get(`${i}_${f}`)??"";return`[${f}]=${fr(p)}`});n+=`declare -a ${i}=(${u.join(" ")})
|
|
866
866
|
`;continue}if(e.state.env.has(`${i}__length`)){n+=`declare -a ${i}=()
|
|
@@ -877,7 +877,7 @@ Gid: ${s} ${s} ${s} ${s}
|
|
|
877
877
|
`}}return ge(t)}function Hg(e){let t="",n=new Set;for(let s of e.state.env.keys()){if(s.startsWith("BASH_"))continue;if(s.endsWith("__length")){let a=s.slice(0,-8);e.state.associativeArrays?.has(a)||n.add(a);continue}let i=s.lastIndexOf("_");if(i>0){let a=s.slice(0,i),o=s.slice(i+1);/^\d+$/.test(o)&&(e.state.associativeArrays?.has(a)||n.add(a))}}let r=Array.from(n).sort();for(let s of r){let i=Ye(e,s);if(i.length===0)t+=`declare -a ${s}=()
|
|
878
878
|
`;else{let a=i.map(o=>{let l=e.state.env.get(`${s}_${o}`)??"";return`[${o}]=${fr(l)}`});t+=`declare -a ${s}=(${a.join(" ")})
|
|
879
879
|
`}}return ge(t)}function jg(e){let t="",n=new Set;for(let s of e.state.env.keys()){if(s.startsWith("BASH_"))continue;if(s.endsWith("__length")){let a=s.slice(0,-8);n.add(a);continue}let i=s.lastIndexOf("_");if(i>0){let a=s.slice(0,i),o=s.slice(i+1);if(/^\d+$/.test(o)||e.state.associativeArrays?.has(a)){n.add(a);continue}}n.add(s)}let r=Array.from(n).sort();for(let s of r){if(e.state.associativeArrays?.has(s)||Ye(e,s).length>0||e.state.env.has(`${s}__length`))continue;let o=e.state.env.get(s);o!==void 0&&(t+=`${s}=${ka(o)}
|
|
880
|
-
`)}return ge(t)}function Mc(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function Ds(e,t){return e.state.integerVars?.has(t)??!1}function Uc(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function
|
|
880
|
+
`)}return ge(t)}function Mc(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function Ds(e,t){return e.state.integerVars?.has(t)??!1}function Uc(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function IE(e,t){return e.state.lowercaseVars?.has(t)??!1}function Wc(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function $E(e,t){return e.state.uppercaseVars?.has(t)??!1}function Yr(e,t,n){return IE(e,t)?n.toLowerCase():$E(e,t)?n.toUpperCase():n}async function Gg(e,t){try{let n=new ce,r=Ae(n,t),s=await ne(e,r.expression);return String(s)}catch{return"0"}}function OE(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 a=e.slice(i,r);if(r++,e[r]!=="=")return null;r++;let o=e.slice(r);return{name:n,indexExpr:a,value:o}}async function Bc(e,t){let n=!1,r=!1,s=!1,i=!1,a=!1,o=!1,l=!1,c=!1,u=!1,f=!1,p=!1,h=!1,m=!1,d=!1,g=!1,w=[];for(let R=0;R<t.length;R++){let z=t[R];if(z==="-a")n=!0;else if(z==="-A")r=!0;else if(z==="-r")s=!0;else if(z==="-x")i=!0;else if(z==="-p")a=!0;else if(z==="-n")o=!0;else if(z==="+n")l=!0;else if(z==="+a")c=!0;else if(z==="+x")u=!0;else if(z==="--"){w.push(...t.slice(R+1));break}else if(z.startsWith("+")){for(let k of z.slice(1))if(k==="n")l=!0;else if(k==="a")c=!0;else if(k==="x")u=!0;else if(k!=="r"){if(k!=="i"){if(!(k==="f"||k==="F"))return B("",`bash: typeset: +${k}: invalid option
|
|
881
881
|
`,2)}}}else if(z==="-i")f=!0;else if(z==="-l")p=!0;else if(z==="-u")h=!0;else if(z==="-f")m=!0;else if(z==="-F")d=!0;else if(z==="-g")g=!0;else if(z.startsWith("-"))for(let k of z.slice(1))if(k==="a")n=!0;else if(k==="A")r=!0;else if(k==="r")s=!0;else if(k==="x")i=!0;else if(k==="p")a=!0;else if(k==="n")o=!0;else if(k==="i")f=!0;else if(k==="l")p=!0;else if(k==="u")h=!0;else if(k==="f")m=!0;else if(k==="F")d=!0;else if(k==="g")g=!0;else return B("",`bash: typeset: -${k}: invalid option
|
|
882
882
|
`,2);else w.push(z)}let b=e.state.localScopes.length>0&&!g,x=R=>{if(!b)return;let z=e.state.localScopes[e.state.localScopes.length-1];z.has(R)||z.set(R,e.state.env.get(R))},S=R=>{if(!b)return;let z=e.state.localScopes[e.state.localScopes.length-1];z.has(R)||z.set(R,e.state.env.get(R));let k=`${R}_`;for(let P of e.state.env.keys())P.startsWith(k)&&!P.includes("__")&&(z.has(P)||z.set(P,e.state.env.get(P)));let N=`${R}__length`;e.state.env.has(N)&&!z.has(N)&&z.set(N,e.state.env.get(N))},$=R=>{b&&jn(e,R)};if(d){if(w.length===0){let k=Array.from(e.state.functions.keys()).sort(),N="";for(let P of k)N+=`declare -f ${P}
|
|
883
883
|
`;return ge(N)}let R=!0,z="";for(let k of w)e.state.functions.has(k)?z+=`${k}
|
|
@@ -887,16 +887,16 @@ Gid: ${s} ${s} ${s} ${s}
|
|
|
887
887
|
}
|
|
888
888
|
`;return ge(z)}let R=!0;for(let z of w)e.state.functions.has(z)||(R=!1);return B("","",R?0:1)}if(a&&w.length>0)return Wg(e,w);if(a&&w.length===0)return Bg(e,{filterExport:i,filterReadonly:s,filterNameref:o,filterIndexedArray:n,filterAssocArray:r});if(w.length===0&&r&&!a)return zg(e);if(w.length===0&&n&&!a)return Hg(e);if(w.length===0&&!a)return jg(e);let O="",F=0;for(let R of w){let z=R.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(z&&!c){let v=z[1],T=z[2];if(r&&Ye(e,v).length>0){O+=`bash: declare: ${v}: cannot convert indexed to associative array
|
|
889
889
|
`,F=1;continue}if((n||!r&&!n)&&e.state.associativeArrays?.has(v)){O+=`bash: declare: ${v}: cannot convert associative to indexed array
|
|
890
|
-
`,F=1;continue}if(S(v),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(v)),wn(e,v),e.state.env.delete(v),e.state.env.delete(`${v}__length`),r&&T.includes("[")){let L=Ea(T);for(let[ue,re]of L){let ee=qe(e,re);e.state.env.set(`${v}_${ue}`,ee)}}else if(r){let L=An(T);for(let ue=0;ue<L.length;ue+=2){let re=L[ue],ee=ue+1<L.length?qe(e,L[ue+1]):"";e.state.env.set(`${v}_${re}`,ee)}}else{let L=An(T);if(L.some(re=>/^\[[^\]]+\]=/.test(re))){let re=0;for(let ee of L){let H=ee.match(/^\[([^\]]+)\]=(.*)$/);if(H){let X=H[1],Ee=H[2],ae=qe(e,Ee),ke;if(/^-?\d+$/.test(X))ke=Number.parseInt(X,10);else try{let j=new ce,ve=Ae(j,X);ke=await ne(e,ve.expression)}catch{ke=0}e.state.env.set(`${v}_${ke}`,ae),re=ke+1}else{let X=qe(e,ee);e.state.env.set(`${v}_${re}`,X),re++}}}else{for(let re=0;re<L.length;re++)e.state.env.set(`${v}_${re}`,L[re]);e.state.env.set(`${v}__length`,String(L.length))}}$(v),s&&Lt(e,v),i&&on(e,v);continue}if(l){let v=R.includes("=")?R.slice(0,R.indexOf("=")):R;if(Zm(e,v),!R.includes("="))continue}if(u){let v=R.includes("=")?R.slice(0,R.indexOf("=")):R;if(na(e,v),!R.includes("="))continue}let k=
|
|
890
|
+
`,F=1;continue}if(S(v),r&&(e.state.associativeArrays??=new Set,e.state.associativeArrays.add(v)),wn(e,v),e.state.env.delete(v),e.state.env.delete(`${v}__length`),r&&T.includes("[")){let L=Ea(T);for(let[ue,re]of L){let ee=qe(e,re);e.state.env.set(`${v}_${ue}`,ee)}}else if(r){let L=An(T);for(let ue=0;ue<L.length;ue+=2){let re=L[ue],ee=ue+1<L.length?qe(e,L[ue+1]):"";e.state.env.set(`${v}_${re}`,ee)}}else{let L=An(T);if(L.some(re=>/^\[[^\]]+\]=/.test(re))){let re=0;for(let ee of L){let H=ee.match(/^\[([^\]]+)\]=(.*)$/);if(H){let X=H[1],Ee=H[2],ae=qe(e,Ee),ke;if(/^-?\d+$/.test(X))ke=Number.parseInt(X,10);else try{let j=new ce,ve=Ae(j,X);ke=await ne(e,ve.expression)}catch{ke=0}e.state.env.set(`${v}_${ke}`,ae),re=ke+1}else{let X=qe(e,ee);e.state.env.set(`${v}_${re}`,X),re++}}}else{for(let re=0;re<L.length;re++)e.state.env.set(`${v}_${re}`,L[re]);e.state.env.set(`${v}__length`,String(L.length))}}$(v),s&&Lt(e,v),i&&on(e,v);continue}if(l){let v=R.includes("=")?R.slice(0,R.indexOf("=")):R;if(Zm(e,v),!R.includes("="))continue}if(u){let v=R.includes("=")?R.slice(0,R.indexOf("=")):R;if(na(e,v),!R.includes("="))continue}let k=OE(R);if(k){let{name:v,indexExpr:T,value:L}=k,ue=it(e,v);if(ue)return ue;S(v);let re;try{let H=new ce,X=Ae(H,T);re=await ne(e,X.expression)}catch{let H=parseInt(T,10);re=Number.isNaN(H)?0:H}e.state.env.set(`${v}_${re}`,L);let ee=parseInt(e.state.env.get(`${v}__length`)??"0",10);re>=ee&&e.state.env.set(`${v}__length`,String(re+1)),$(v),s&&Lt(e,v),i&&on(e,v);continue}let N=R.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(N&&!c){let v=N[1],T=N[2],L=it(e,v);if(L)return L;S(v);let ue=An(T);if(e.state.associativeArrays?.has(v)){let re=Ea(T);for(let[ee,H]of re){let X=qe(e,H);e.state.env.set(`${v}_${ee}`,X)}}else{let re=Ye(e,v),ee=0,H=e.state.env.get(v);re.length===0&&H!==void 0?(e.state.env.set(`${v}_0`,H),e.state.env.delete(v),ee=1):re.length>0&&(ee=Math.max(...re)+1);for(let Ee=0;Ee<ue.length;Ee++)e.state.env.set(`${v}_${ee+Ee}`,qe(e,ue[Ee]));let X=ee+ue.length;e.state.env.set(`${v}__length`,String(X))}$(v),s&&Lt(e,v),i&&on(e,v);continue}let P=R.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(P){let v=P[1],T=qe(e,P[2]),L=it(e,v);if(L)return L;x(v),f&&Mc(e,v),p&&Uc(e,v),h&&Wc(e,v);let re=Ye(e,v).length>0||e.state.associativeArrays?.has(v);if(Ds(e,v)){let ee=e.state.env.get(v)??"0",H=parseInt(ee,10)||0,X=parseInt(await Gg(e,T),10)||0;T=String(H+X),e.state.env.set(v,T)}else if(re){T=Yr(e,v,T);let ee=`${v}_0`,H=e.state.env.get(ee)??"";e.state.env.set(ee,H+T)}else{T=Yr(e,v,T);let ee=e.state.env.get(v)??"";e.state.env.set(v,ee+T)}$(v),s&&Lt(e,v),i&&on(e,v),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(v));continue}if(R.includes("=")){let v=R.indexOf("="),T=R.slice(0,v),L=R.slice(v+1);if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(T)){O+=`bash: typeset: \`${T}': not a valid identifier
|
|
891
891
|
`,F=1;continue}let ue=it(e,T);if(ue)return ue;if(x(T),o){if(L!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(L)){O+=`bash: declare: \`${L}': invalid variable name for name reference
|
|
892
|
-
`,F=1;continue}e.state.env.set(T,L),vn(e,T),L!==""&&ea(e,L)&&ic(e,T),$(T),s&&Lt(e,T),i&&on(e,T);continue}if(f&&Mc(e,T),p&&Uc(e,T),h&&Wc(e,T),Ds(e,T)&&(L=await Gg(e,L)),L=Yr(e,T,L),Te(e,T)){let re=
|
|
892
|
+
`,F=1;continue}e.state.env.set(T,L),vn(e,T),L!==""&&ea(e,L)&&ic(e,T),$(T),s&&Lt(e,T),i&&on(e,T);continue}if(f&&Mc(e,T),p&&Uc(e,T),h&&Wc(e,T),Ds(e,T)&&(L=await Gg(e,L)),L=Yr(e,T,L),Te(e,T)){let re=At(e,T);re&&re!==T?e.state.env.set(re,L):e.state.env.set(T,L)}else e.state.env.set(T,L);$(T),s&&Lt(e,T),i&&on(e,T),e.state.options.allexport&&!u&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(T))}else{let v=R;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(v)){O+=`bash: typeset: \`${v}': not a valid identifier
|
|
893
893
|
`,F=1;continue}if(n||r?S(v):x(v),o){vn(e,v);let L=e.state.env.get(v);L!==void 0&&L!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(L)?Km(e,v):L&&ea(e,L)&&ic(e,v),$(v),s&&Lt(e,v),i&&on(e,v);continue}if(f&&Mc(e,v),p&&Uc(e,v),h&&Wc(e,v),r){if(Ye(e,v).length>0){O+=`bash: declare: ${v}: cannot convert indexed to associative array
|
|
894
894
|
`,F=1;continue}e.state.associativeArrays??=new Set,e.state.associativeArrays.add(v)}let T=Array.from(e.state.env.keys()).some(L=>L.startsWith(`${v}_`)&&!L.startsWith(`${v}__length`));!e.state.env.has(v)&&!T&&(n||r?e.state.env.set(`${v}__length`,"0"):(e.state.declaredVars??=new Set,e.state.declaredVars.add(v))),$(v),s&&Lt(e,v),i&&on(e,v)}}return B("",O,F)}async function zc(e,t){let n=!1,r=!1,s=!1,i=[];for(let a=0;a<t.length;a++){let o=t[a];if(o==="-a")n=!0;else if(o==="-A")r=!0;else if(o==="-p")s=!0;else if(o==="--"){i.push(...t.slice(a+1));break}else o.startsWith("-")||i.push(o)}if(i.length===0){let a="",o=Array.from(e.state.readonlyVars||[]).sort();for(let l of o){let c=e.state.env.get(l);if(c!==void 0){let u=c.replace(/\\/g,"\\\\").replace(/"/g,'\\"');a+=`declare -r ${l}="${u}"
|
|
895
|
-
`}}return ge(a)}for(let a of i){let o=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(o){let f=o[1],p=o[2],h=it(e,f);if(h)return h;let m=An(p);if(e.state.associativeArrays?.has(f)){let d=Ea(p);for(let[g,w]of d){let y=qe(e,w);e.state.env.set(`${f}_${g}`,y)}}else{let d=Ye(e,f),g=0,w=e.state.env.get(f);d.length===0&&w!==void 0?(e.state.env.set(`${f}_0`,w),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}`,qe(e,m[b]));let y=g+m.length;e.state.env.set(`${f}__length`,String(y))}Lt(e,f);continue}let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(l){let f=l[1],p=qe(e,l[2]),h=it(e,f);if(h)return h;let m=e.state.env.get(f)??"";e.state.env.set(f,m+p),Lt(e,f);continue}let c=$g(a);if(c.value===void 0&&!c.isArray){Lt(e,c.name);continue}let u=await Og(e,c,{makeReadonly:!0});if(u)return u}return de}function Hc(e){return e.state.directoryStack??=[],e.state.directoryStack}function _s(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function
|
|
895
|
+
`}}return ge(a)}for(let a of i){let o=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(o){let f=o[1],p=o[2],h=it(e,f);if(h)return h;let m=An(p);if(e.state.associativeArrays?.has(f)){let d=Ea(p);for(let[g,w]of d){let y=qe(e,w);e.state.env.set(`${f}_${g}`,y)}}else{let d=Ye(e,f),g=0,w=e.state.env.get(f);d.length===0&&w!==void 0?(e.state.env.set(`${f}_0`,w),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}`,qe(e,m[b]));let y=g+m.length;e.state.env.set(`${f}__length`,String(y))}Lt(e,f);continue}let l=a.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(l){let f=l[1],p=qe(e,l[2]),h=it(e,f);if(h)return h;let m=e.state.env.get(f)??"";e.state.env.set(f,m+p),Lt(e,f);continue}let c=$g(a);if(c.value===void 0&&!c.isArray){Lt(e,c.name);continue}let u=await Og(e,c,{makeReadonly:!0});if(u)return u}return de}function Hc(e){return e.state.directoryStack??=[],e.state.directoryStack}function _s(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function RE(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 jc(e,t){let n=Hc(e),r;for(let o=0;o<t.length;o++){let l=t[o];if(l==="--"){if(o+1<t.length){if(r!==void 0)return W(`bash: pushd: too many arguments
|
|
896
896
|
`,2);r=t[o+1],o++}}else{if(l.startsWith("-")&&l!=="-")return W(`bash: pushd: ${l}: invalid option
|
|
897
897
|
`,2);if(r!==void 0)return W(`bash: pushd: too many arguments
|
|
898
898
|
`,2);r=l}}if(r===void 0){if(n.length<2)return W(`bash: pushd: no other directory
|
|
899
|
-
`,1);let o=n[0];n[0]=n[1],n[1]=o,r=n[0]}let s;if(r.startsWith("/"))s=r;else if(r===".."){let o=e.state.cwd.split("/").filter(l=>l);o.pop(),s=`/${o.join("/")}`}else r==="."?s=e.state.cwd:r.startsWith("~")?s=(e.state.env.get("HOME")||"/")+r.slice(1):s=`${e.state.cwd}/${r}`;s=
|
|
899
|
+
`,1);let o=n[0];n[0]=n[1],n[1]=o,r=n[0]}let s;if(r.startsWith("/"))s=r;else if(r===".."){let o=e.state.cwd.split("/").filter(l=>l);o.pop(),s=`/${o.join("/")}`}else r==="."?s=e.state.cwd:r.startsWith("~")?s=(e.state.env.get("HOME")||"/")+r.slice(1):s=`${e.state.cwd}/${r}`;s=RE(s);try{if(!(await e.fs.stat(s)).isDirectory)return W(`bash: pushd: ${r}: Not a directory
|
|
900
900
|
`,1)}catch{return W(`bash: pushd: ${r}: No such file or directory
|
|
901
901
|
`,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")||"",a=`${[s,...n].map(o=>_s(o,i)).join(" ")}
|
|
902
902
|
`;return ge(a)}function Gc(e,t){let n=Hc(e);for(let a of t)if(a!=="--")return a.startsWith("-")&&a!=="-"?W(`bash: popd: ${a}: invalid option
|
|
@@ -1282,15 +1282,15 @@ eval: usage: eval [arg ...]
|
|
|
1282
1282
|
Exit Status:
|
|
1283
1283
|
Returns the status of the last ID; fails if ID is invalid or an invalid
|
|
1284
1284
|
option is given.`]]]),qg=[...Vg.keys()].sort();function Qc(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
|
|
1285
|
-
`,2)}s++}else r.push(l),s++}if(r.length===0)return
|
|
1285
|
+
`,2)}s++}else r.push(l),s++}if(r.length===0)return PE();let i="",a=!1,o="";for(let l of r){let c=TE(l);if(c.length===0){o+=`bash: help: no help topics match \`${l}'. Try \`help help' or \`man -k ${l}' or \`info ${l}'.
|
|
1286
1286
|
`,a=!0;continue}for(let u of c){let f=Vg.get(u);if(!f)continue;let[p,h]=f;n?i+=`${u}: ${p}
|
|
1287
1287
|
`:i+=`${u}: ${p}
|
|
1288
1288
|
${h}
|
|
1289
|
-
`}}return{exitCode:a?1:0,stdout:i,stderr:o}}function
|
|
1289
|
+
`}}return{exitCode:a?1:0,stdout:i,stderr:o}}function TE(e){let t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,"."),n=V(`^${t}$`);return qg.filter(r=>n.test(r))}function PE(){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=qg.slice(),r=Math.ceil(n.length/2);for(let s=0;s<r;s++){let i=n[s]||"",a=n[s+r]||"",o=i.padEnd(t);e.push(a?`${o}${a}`:i)}return ge(`${e.join(`
|
|
1290
1290
|
`)}
|
|
1291
|
-
`)}Xe();
|
|
1292
|
-
`);let n=
|
|
1293
|
-
`)}return B("","",r===0?1:0)}
|
|
1291
|
+
`)}Xe();St();function DE(e){let t=[],n="",r=0;for(let s of e){for(let i of s)i==="("?r++:i===")"&&r--;n?n+=` ${s}`:n=s,r===0&&(t.push(n),n="")}return n&&t.push(n),t}async function Xc(e,t){if(t.length===0)return W(`bash: let: expression expected
|
|
1292
|
+
`);let n=DE(t),r=0;for(let s of n)try{let a=rn(`(( ${s} ))`).statements[0];if(a&&a.pipelines.length>0&&a.pipelines[0].commands.length>0){let o=a.pipelines[0].commands[0];o.type==="ArithmeticCommand"&&(r=await ne(e,o.expression.expression))}}catch(i){return W(`bash: let: ${s}: ${i.message}
|
|
1293
|
+
`)}return B("","",r===0?1:0)}dt();Xe();St();Xt();an();Bn();async function Yc(e,t){if(e.state.localScopes.length===0)return W(`bash: local: can only be used in a function
|
|
1294
1294
|
`);let n=e.state.localScopes[e.state.localScopes.length-1],r="",s=0,i=!1,a=!1,o=!1,l=[];for(let c of t)if(c==="-n")i=!0;else if(c==="-a")a=!0;else if(c==="-p")o=!0;else if(c.startsWith("-")&&!c.includes("="))for(let u of c.slice(1))u==="n"?i=!0:u==="a"?a=!0:u==="p"&&(o=!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 p=e.state.env.get(f);p!==void 0&&(c+=`${f}=${p}
|
|
1295
1295
|
`)}return B(c,"",0)}for(let c of l){let u,f,p=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)=\((.*)\)$/s);if(p){u=p[1];let w=p[2];if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
|
|
1296
1296
|
`,s=1;continue}if(it(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 y=`${u}_`;for(let x of e.state.env.keys())x.startsWith(y)&&!x.includes("__")&&e.state.env.delete(x);let b=An(w);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)),jn(e,u),i&&vn(e,u);continue}let h=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=\((.*)\)$/s);if(h){u=h[1];let w=h[2];if(it(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let O=`${u}_`;for(let R of e.state.env.keys())R.startsWith(O)&&!R.includes("__")&&(n.has(R)||n.set(R,e.state.env.get(R)));let F=`${u}__length`;e.state.env.has(F)&&!n.has(F)&&n.set(F,e.state.env.get(F))}let y=An(w),b=Ye(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 O=0;O<y.length;O++)e.state.env.set(`${u}_${x+O}`,qe(e,y[O]));let $=x+y.length;e.state.env.set(`${u}__length`,String($)),jn(e,u),i&&vn(e,u);continue}let m=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\+=(.*)$/);if(m){u=m[1];let w=qe(e,m[2]);it(e,u,"bash"),n.has(u)||n.set(u,e.state.env.get(u));let y=e.state.env.get(u)??"";e.state.env.set(u,y+w),jn(e,u),i&&vn(e,u);continue}let d=c.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([^\]]+)\]=(.*)$/s);if(d){u=d[1];let w=d[2],y=qe(e,d[3]);if(it(e,u,"bash"),!n.has(u)){n.set(u,e.state.env.get(u));let S=`${u}_`;for(let O of e.state.env.keys())O.startsWith(S)&&!O.includes("__")&&(n.has(O)||n.set(O,e.state.env.get(O)));let $=`${u}__length`;e.state.env.has($)&&!n.has($)&&n.set($,e.state.env.get($))}let b;try{let S=new ce,$=Ae(S,w);b=await ne(e,$.expression)}catch{let S=parseInt(w,10);b=Number.isNaN(S)?0:S}e.state.env.set(`${u}_${b}`,y);let x=parseInt(e.state.env.get(`${u}__length`)??"0",10);b>=x&&e.state.env.set(`${u}__length`,String(b+1)),jn(e,u),i&&vn(e,u);continue}if(c.includes("=")){let w=c.indexOf("=");u=c.slice(0,w),f=qe(e,c.slice(w+1))}else u=c;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){r+=`bash: local: \`${c}': not a valid identifier
|
|
@@ -1299,8 +1299,8 @@ ${h}
|
|
|
1299
1299
|
`,s=0,i=0,a=0,o=!1,l="MAPFILE",c=0;for(;c<t.length;){let y=t[c];y==="-d"&&c+1<t.length?(r=t[c+1]===""?"\0":t[c+1]||`
|
|
1300
1300
|
`,c+=2):y==="-n"&&c+1<t.length?(s=Number.parseInt(t[c+1],10)||0,c+=2):y==="-O"&&c+1<t.length?(i=Number.parseInt(t[c+1],10)||0,c+=2):y==="-s"&&c+1<t.length?(a=Number.parseInt(t[c+1],10)||0,c+=2):y==="-t"?(o=!0,c++):y==="-u"||y==="-C"||y==="-c"?c+=2:(y.startsWith("-")||(l=y),c++)}let u=n;!u&&e.state.groupStdin!==void 0&&(u=e.state.groupStdin);let f=[],p=u,h=0,m=0,d=e.limits?.maxArrayElements??1e5;for(;p.length>0;){let y=p.indexOf(r);if(y===-1){if(p.length>0){if(m<a)m++;else if(s===0||h<s){if(i+h>=d)return B("",`mapfile: array element limit exceeded (${d})
|
|
1301
1301
|
`,1);let S=p,$=S.indexOf("\0");$!==-1&&(S=S.substring(0,$)),f.push(S),h++}}break}let b=p.substring(0,y),x=b.indexOf("\0");if(x!==-1&&(b=b.substring(0,x)),!o&&r!=="\0"&&(b+=r),p=p.substring(y+r.length),m<a){m++;continue}if(s>0&&h>=s)break;if(i+h>=d)return B("",`mapfile: array element limit exceeded (${d})
|
|
1302
|
-
`,1);f.push(b),h++}i===0&&wn(e,l);for(let y=0;y<f.length;y++)e.state.env.set(`${l}_${i+y}`,f[y]);let g=parseInt(e.state.env.get(`${l}__length`)||"0",10),w=i+f.length;return e.state.env.set(`${l}__length`,String(Math.max(g,w))),e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=""),B("","",0)}Xt();jt();function
|
|
1303
|
-
`,a="",o=-1,l=-1,c=null,u=-1,f=-1,p=[],h=0,m=!1,d=(k,N)=>{let P=1;for(;P<k.length;){let v=k[P];if(v==="r")s=!0,P++;else if(v==="s")P++;else{if(v==="d")return P+1<k.length?(i=k.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(i=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(v==="n"){if(P+1<k.length){let T=k.substring(P+1);return o=Number.parseInt(T,10),(Number.isNaN(o)||o<0)&&(m=!0,o=0),{nextArgIndex:N+1}}else if(N+1<t.length)return o=Number.parseInt(t[N+1],10),(Number.isNaN(o)||o<0)&&(m=!0,o=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(v==="N"){if(P+1<k.length){let T=k.substring(P+1);return l=Number.parseInt(T,10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:N+1}}else if(N+1<t.length)return l=Number.parseInt(t[N+1],10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else{if(v==="a")return P+1<k.length?(c=k.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(c=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(v==="p")return P+1<k.length?(a=k.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(a=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(v==="u"){if(P+1<k.length){let T=k.substring(P+1);return u=Number.parseInt(T,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:N+1}}else if(N+1<t.length)return u=Number.parseInt(t[N+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(v==="t"){if(P+1<k.length){let T=k.substring(P+1);return f=Number.parseFloat(T),Number.isNaN(f)&&(f=0),{nextArgIndex:N+1}}else if(N+1<t.length)return f=Number.parseFloat(t[N+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(v==="e"||v==="i"||v==="P"){if(v==="i"&&N+1<t.length)return{nextArgIndex:N+2};P++}else P++}}}return{nextArgIndex:N+1}};for(;h<t.length;){let k=t[h];if(k.startsWith("-")&&k.length>1&&k!=="--"){let N=d(k,h);if(N.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(N.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};h=N.nextArgIndex}else if(k==="--")for(h++;h<t.length;)p.push(t[h]),h++;else p.push(k),h++}if(m)return B("","",1);if(p.length===0&&c===null&&p.push("REPLY"),f===0){if(c)wn(e,c);else{for(let k of p)e.state.env.set(k,"");p.length===0&&e.state.env.set("REPLY","")}return B("","",0)}if(f<0&&f!==-1)return B("","",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 w=i===""?"\0":i,y="",b=0,x=!0,S=k=>{if(u>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(u,g.substring(k));else if(r>=0&&e.state.fileDescriptors){let N=e.state.fileDescriptors.get(r);if(N?.startsWith("__rw__:")){let P=
|
|
1302
|
+
`,1);f.push(b),h++}i===0&&wn(e,l);for(let y=0;y<f.length;y++)e.state.env.set(`${l}_${i+y}`,f[y]);let g=parseInt(e.state.env.get(`${l}__length`)||"0",10),w=i+f.length;return e.state.env.set(`${l}__length`,String(Math.max(g,w))),e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=""),B("","",0)}Xt();jt();function _E(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),a=s+r+1,o=t.slice(a),l=o.indexOf(":");if(l===-1)return null;let c=Number.parseInt(o.slice(0,l),10);if(Number.isNaN(c)||c<0)return null;let u=o.slice(l+1);return{path:i,position:c,content:u}}function LE(e,t,n){return`__rw__:${e.length}:${e}:${t}:${n}`}function eu(e,t,n,r=-1){let s=!1,i=`
|
|
1303
|
+
`,a="",o=-1,l=-1,c=null,u=-1,f=-1,p=[],h=0,m=!1,d=(k,N)=>{let P=1;for(;P<k.length;){let v=k[P];if(v==="r")s=!0,P++;else if(v==="s")P++;else{if(v==="d")return P+1<k.length?(i=k.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(i=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(v==="n"){if(P+1<k.length){let T=k.substring(P+1);return o=Number.parseInt(T,10),(Number.isNaN(o)||o<0)&&(m=!0,o=0),{nextArgIndex:N+1}}else if(N+1<t.length)return o=Number.parseInt(t[N+1],10),(Number.isNaN(o)||o<0)&&(m=!0,o=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(v==="N"){if(P+1<k.length){let T=k.substring(P+1);return l=Number.parseInt(T,10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:N+1}}else if(N+1<t.length)return l=Number.parseInt(t[N+1],10),(Number.isNaN(l)||l<0)&&(m=!0,l=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else{if(v==="a")return P+1<k.length?(c=k.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(c=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(v==="p")return P+1<k.length?(a=k.substring(P+1),{nextArgIndex:N+1}):N+1<t.length?(a=t[N+1],{nextArgIndex:N+2}):{nextArgIndex:N+1};if(v==="u"){if(P+1<k.length){let T=k.substring(P+1);return u=Number.parseInt(T,10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:N+1}}else if(N+1<t.length)return u=Number.parseInt(t[N+1],10),Number.isNaN(u)||u<0?{nextArgIndex:-2}:{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(v==="t"){if(P+1<k.length){let T=k.substring(P+1);return f=Number.parseFloat(T),Number.isNaN(f)&&(f=0),{nextArgIndex:N+1}}else if(N+1<t.length)return f=Number.parseFloat(t[N+1]),Number.isNaN(f)&&(f=0),{nextArgIndex:N+2};return{nextArgIndex:N+1}}else if(v==="e"||v==="i"||v==="P"){if(v==="i"&&N+1<t.length)return{nextArgIndex:N+2};P++}else P++}}}return{nextArgIndex:N+1}};for(;h<t.length;){let k=t[h];if(k.startsWith("-")&&k.length>1&&k!=="--"){let N=d(k,h);if(N.nextArgIndex===-1)return{stdout:"",stderr:"",exitCode:2};if(N.nextArgIndex===-2)return{stdout:"",stderr:"",exitCode:1};h=N.nextArgIndex}else if(k==="--")for(h++;h<t.length;)p.push(t[h]),h++;else p.push(k),h++}if(m)return B("","",1);if(p.length===0&&c===null&&p.push("REPLY"),f===0){if(c)wn(e,c);else{for(let k of p)e.state.env.set(k,"");p.length===0&&e.state.env.set("REPLY","")}return B("","",0)}if(f<0&&f!==-1)return B("","",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 w=i===""?"\0":i,y="",b=0,x=!0,S=k=>{if(u>=0&&e.state.fileDescriptors)e.state.fileDescriptors.set(u,g.substring(k));else if(r>=0&&e.state.fileDescriptors){let N=e.state.fileDescriptors.get(r);if(N?.startsWith("__rw__:")){let P=_E(N);if(P){let v=P.position+k;e.state.fileDescriptors.set(r,LE(P.path,v,P.content))}}}else e.state.groupStdin!==void 0&&!n&&(e.state.groupStdin=g.substring(k))};if(l>=0){let k=Math.min(l,g.length);y=g.substring(0,k),b=k,x=k>=l,S(b);let N=p[0]||"REPLY";e.state.env.set(N,y);for(let P=1;P<p.length;P++)e.state.env.set(p[P],"");return B("","",x?0:1)}else if(o>=0){let k=0,N=0,P=!1;for(;N<g.length&&k<o;){let v=g[N];if(v===w){b=N+1,P=!0;break}if(!s&&v==="\\"&&N+1<g.length){let T=g[N+1];if(T===w&&w===`
|
|
1304
1304
|
`){N+=2,b=N;continue}if(T===w){N+=2,k++,y+=T,b=N;continue}y+=T,N+=2,k++,b=N}else y+=v,N++,k++,b=N}x=k>=o||P,S(b)}else{b=0;let k=0;for(;k<g.length;){let N=g[k];if(N===w){b=k+w.length,x=!0;break}if(!s&&N==="\\"&&k+1<g.length){let P=g[k+1];if(P===`
|
|
1305
1305
|
`){k+=2;continue}if(P===w){y+=P,k+=2;continue}y+=N,y+=P,k+=2;continue}y+=N,k++}if(k>=g.length&&(x=!1,b=k,y.length===0&&g.length===0)){for(let N of p)e.state.env.set(N,"");return c&&wn(e,c),B("","",1)}S(b)}w===`
|
|
1306
1306
|
`&&y.endsWith(`
|
|
@@ -1322,9 +1322,9 @@ Options:
|
|
|
1322
1322
|
+o pipefail Disable pipefail
|
|
1323
1323
|
-o xtrace Same as -x
|
|
1324
1324
|
+o xtrace Disable xtrace
|
|
1325
|
-
`,Zg=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]]),Kg=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]]),Qg=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],Xg=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function Yg(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,Wr(e))}function
|
|
1325
|
+
`,Zg=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]]),Kg=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]]),Qg=["errexit","nounset","pipefail","verbose","xtrace","posix","allexport","noclobber","noglob","noexec","vi","emacs"],Xg=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"];function Yg(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,Wr(e))}function FE(e,t){return t+1<e.length&&!e[t+1].startsWith("-")&&!e[t+1].startsWith("+")}function ME(e,t){let n=Ye(e,t);if(n.length===0)return`${t}=()`;let r=n.map(s=>{let i=e.state.env.get(`${t}_${s}`)??"";return`[${s}]=${fr(i)}`});return`${t}=(${r.join(" ")})`}function UE(e){return/^[a-zA-Z0-9_]+$/.test(e)?e:`"${e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function WE(e,t){let n=sn(e,t);if(n.length===0)return`${t}=()`;let r=n.map(s=>{let i=e.state.env.get(`${t}_${s}`)??"";return`[${UE(s)}]=${fr(i)}`});return`${t}=(${r.join(" ")} )`}function BE(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 zE(e){return e.state.associativeArrays??new Set}function ru(e,t){if(t.includes("--help"))return ge($a);if(t.length===0){let r=BE(e),s=zE(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},a=[];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])||a.push([l,c])}let o=[];for(let[l,c]of a.sort(([u],[f])=>u<f?-1:u>f?1:0))o.push(`${l}=${ka(c)}`);for(let l of[...r].sort((c,u)=>c<u?-1:c>u?1:0))o.push(ME(e,l));for(let l of[...s].sort((c,u)=>c<u?-1:c>u?1:0))o.push(WE(e,l));return o.sort((l,c)=>{let u=l.split("=")[0],f=c.split("=")[0];return u<f?-1:u>f?1:0}),ge(o.length>0?`${o.join(`
|
|
1326
1326
|
`)}
|
|
1327
|
-
`:"")}let n=0;for(;n<t.length;){let r=t[n];if((r==="-o"||r==="+o")&&
|
|
1327
|
+
`:"")}let n=0;for(;n<t.length;){let r=t[n];if((r==="-o"||r==="+o")&&FE(t,n)){let s=t[n+1];if(!Kg.has(s)){let i=`bash: set: ${s}: invalid option name
|
|
1328
1328
|
${$a}`;if(e.state.options.posix)throw new Bt(1,"",i);return W(i)}Yg(e,Kg.get(s)??null,r==="-o"),n+=2;continue}if(r==="-o"){let s=Qg.map(o=>`${o.padEnd(16)}${e.state.options[o]?"on":"off"}`),i=Xg.map(o=>`${o.padEnd(16)}off`),a=[...s,...i].sort();return ge(`${a.join(`
|
|
1329
1329
|
`)}
|
|
1330
1330
|
`)}if(r==="+o"){let s=Qg.map(o=>`set ${e.state.options[o]?"-o":"+o"} ${o}`),i=Xg.map(o=>`set +o ${o}`),a=[...s,...i].sort();return ge(`${a.join(`
|
|
@@ -1336,28 +1336,28 @@ ${$a}`;if(e.state.options.posix)throw new Bt(1,"",s);return W(s)}return nu(e,t.s
|
|
|
1336
1336
|
`;if(e.state.options.posix)throw new Bt(1,"",a);return W(a)}if(n===0)return de;let s=[];for(let a=1;a<=r;a++)s.push(e.state.env.get(String(a))||"");let i=s.slice(n);for(let a=1;a<=r;a++)e.state.env.delete(String(a));for(let a=0;a<i.length;a++)e.state.env.set(String(a+1),i[a]);return e.state.env.set("#",String(i.length)),e.state.env.set("@",i.join(" ")),de}Xe();ye();async function iu(e,t){let n=t;if(n.length>0&&n[0]==="--"&&(n=n.slice(1)),n.length===0)return B("",`bash: source: filename argument required
|
|
1337
1337
|
`,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 p=e.fs.resolvePath(e.state.cwd,`${f}/${r}`);try{if((await e.fs.stat(p)).isDirectory)continue;i=await e.fs.readFile(p),s=p;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
|
|
1338
1338
|
`);let a=new Map;if(n.length>1){for(let u=1;u<=9;u++)a.set(String(u),e.state.env.get(String(u)));a.set("#",e.state.env.get("#")),a.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 o=e.state.currentSource,l=()=>{if(e.state.sourceDepth--,e.state.currentSource=o,n.length>1)for(let[c,u]of a)u===void 0?e.state.env.delete(c):e.state.env.set(c,u)};e.state.sourceDepth++,e.state.currentSource=r;try{let c=rn(i),u=await e.executeScript(c);return l(),u}catch(c){if(l(),c instanceof pe)throw c;if(c instanceof ct)return B(c.stdout,c.stderr,c.exitCode);if(c.name==="ParseException")return W(`bash: ${r}: ${c.message}
|
|
1339
|
-
`);throw c}}
|
|
1339
|
+
`);throw c}}dt();Xe();St();Dt();Ct();an();Bn();function Jg(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function HE(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function e6(e,t){if(HE(t))return null;try{let n=new ce,r=Ae(n,t);return await ne(e,r.expression)}catch{let n=parseInt(t,10);return Number.isNaN(n)?0:n}}function t6(e,t){if(e.state.localVarStack?.has(t)){let r=Sa(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)Aa(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),au(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),Aa(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 a=!1;for(let o=r-1;o>=0;o--)if(e.state.localScopes[o].has(t)){e.state.localVarDepth&&e.state.localVarDepth.set(t,o+1),a=!0;break}return a||Aa(e,t),!0}}return!1}function au(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 n6(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 ie(e,s)}if(t.includes("$")){let r=new ce().parseWordFromString(t,!1,!1);return ie(e,r)}return t}async function ou(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 p=c[1],h=c[2];if(h==="@"||h==="*"){let b=oe(e,p);for(let[x]of b)e.state.env.delete(`${p}_${x}`);e.state.env.delete(p);continue}let m=e.state.associativeArrays?.has(p);if(m){let b=await n6(e,h);e.state.env.delete(`${p}_${b}`);continue}let d=In(e,p),g=e.state.declaredVars?.has(p);if((e.state.env.has(p)||g)&&!d&&!m){r+=`bash: unset: ${p}: not an array variable
|
|
1340
1340
|
`,s=1;continue}let y=await e6(e,h);if(y===null&&d){r+=`bash: unset: ${h}: not a valid identifier
|
|
1341
1341
|
`,s=1;continue}if(y===null)continue;if(y<0){let b=oe(e,p),x=b.length,S=e.state.currentLine;if(x===0){r+=`bash: line ${S}: unset: [${y}]: bad array subscript
|
|
1342
1342
|
`,s=1;continue}let $=x+y;if($<0){r+=`bash: line ${S}: unset: [${y}]: bad array subscript
|
|
1343
1343
|
`,s=1;continue}let O=b[$][0];e.state.env.delete(`${p}_${O}`);continue}e.state.env.delete(`${p}_${y}`);continue}if(!Jg(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
1344
|
-
`,s=1;continue}let u=i;if(Te(e,i)){let p=
|
|
1344
|
+
`,s=1;continue}let u=i;if(Te(e,i)){let p=At(e,i);p&&p!==i&&(u=p)}if(En(e,u)){r+=`bash: unset: ${u}: cannot unset: readonly variable
|
|
1345
1345
|
`,s=1;continue}let f=Kr(e,u);if(f!==void 0&&f!==e.state.callDepth)t6(e,u);else if(e.state.fullyUnsetLocals?.has(u))e.state.env.delete(u);else if(f!==void 0){let p=e.state.accessedTempEnvVars?.has(u),h=e.state.mutatedTempEnvVars?.has(u);if((p||h)&&e.state.localVarStack?.has(u)){let m=Sa(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 au(e,u)||e.state.env.delete(u);e.state.exportedVars?.delete(u);continue}let a=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(a){let c=a[1],u=a[2];if(u==="@"||u==="*"){let d=oe(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 n6(e,u);e.state.env.delete(`${c}_${d}`);continue}let p=In(e,c);if(e.state.env.has(c)&&!p&&!f){r+=`bash: unset: ${c}: not an array variable
|
|
1346
1346
|
`,s=1;continue}let m=await e6(e,u);if(m===null&&p){r+=`bash: unset: ${u}: not a valid identifier
|
|
1347
1347
|
`,s=1;continue}if(m===null)continue;if(m<0){let d=oe(e,c),g=d.length,w=e.state.currentLine;if(g===0){r+=`bash: line ${w}: unset: [${m}]: bad array subscript
|
|
1348
1348
|
`,s=1;continue}let y=g+m;if(y<0){r+=`bash: line ${w}: unset: [${m}]: bad array subscript
|
|
1349
1349
|
`,s=1;continue}let b=d[y][0];e.state.env.delete(`${c}_${b}`);continue}e.state.env.delete(`${c}_${m}`);continue}if(!Jg(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
1350
|
-
`,s=1;continue}let o=i;if(Te(e,i)){let c=
|
|
1351
|
-
`,s=1;continue}let l=Kr(e,o);if(l!==void 0&&l!==e.state.callDepth)t6(e,o);else if(e.state.fullyUnsetLocals?.has(o))e.state.env.delete(o);else if(l!==void 0){let c=e.state.accessedTempEnvVars?.has(o),u=e.state.mutatedTempEnvVars?.has(o);if((c||u)&&e.state.localVarStack?.has(o)){let f=Sa(e,o);f?f.value===void 0?e.state.env.delete(o):e.state.env.set(o,f.value):e.state.env.delete(o)}else e.state.env.delete(o)}else au(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(i)}return B("",r,s)}var lu=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],
|
|
1352
|
-
`}}}l++}else break}for(;l<t.length;)o.push(t[l]),l++;if(a)return
|
|
1350
|
+
`,s=1;continue}let o=i;if(Te(e,i)){let c=At(e,i);c&&c!==i&&(o=c)}if(En(e,o)){r+=`bash: unset: ${o}: cannot unset: readonly variable
|
|
1351
|
+
`,s=1;continue}let l=Kr(e,o);if(l!==void 0&&l!==e.state.callDepth)t6(e,o);else if(e.state.fullyUnsetLocals?.has(o))e.state.env.delete(o);else if(l!==void 0){let c=e.state.accessedTempEnvVars?.has(o),u=e.state.mutatedTempEnvVars?.has(o);if((c||u)&&e.state.localVarStack?.has(o)){let f=Sa(e,o);f?f.value===void 0?e.state.env.delete(o):e.state.env.set(o,f.value):e.state.env.delete(o)}else e.state.env.delete(o)}else au(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(i)}return B("",r,s)}var lu=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],jE=["autocd","cdable_vars","cdspell","checkhash","checkjobs","checkwinsize","cmdhist","compat31","compat32","compat40","compat41","compat42","compat43","compat44","complete_fullquote","direxpand","dirspell","execfail","extdebug","extquote","force_fignore","globasciiranges","gnu_errfmt","histappend","histreedit","histverify","hostcomplete","huponexit","inherit_errexit","interactive_comments","lithist","localvar_inherit","localvar_unset","login_shell","mailwarn","no_empty_cmd_completion","progcomp","progcomp_alias","promptvars","restricted_shell","shift_verbose","sourcepath"];function Oa(e){return lu.includes(e)}function GE(e){return jE.includes(e)}function r6(e,t){let n=!1,r=!1,s=!1,i=!1,a=!1,o=[],l=0;for(;l<t.length;){let p=t[l];if(p==="--"){l++;break}if(p.startsWith("-")&&p.length>1){for(let h=1;h<p.length;h++){let m=p[h];switch(m){case"s":n=!0;break;case"u":r=!0;break;case"p":s=!0;break;case"q":i=!0;break;case"o":a=!0;break;default:return{exitCode:2,stdout:"",stderr:`shopt: -${m}: invalid option
|
|
1352
|
+
`}}}l++}else break}for(;l<t.length;)o.push(t[l]),l++;if(a)return VE(e,o,n,r,s,i);if(n&&r)return{exitCode:1,stdout:"",stderr:`shopt: cannot set and unset shell options simultaneously
|
|
1353
1353
|
`};if(o.length===0){if(n||r){let h=[];for(let m of lu){let d=e.state.shoptOptions[m];n&&d?h.push(s?`shopt -s ${m}`:`${m} on`):r&&!d&&h.push(s?`shopt -u ${m}`:`${m} off`)}return{exitCode:0,stdout:h.length>0?`${h.join(`
|
|
1354
1354
|
`)}
|
|
1355
1355
|
`:"",stderr:""}}let p=[];for(let h of lu){let m=e.state.shoptOptions[h];p.push(s?`shopt ${m?"-s":"-u"} ${h}`:`${h} ${m?"on":"off"}`)}return{exitCode:0,stdout:`${p.join(`
|
|
1356
1356
|
`)}
|
|
1357
|
-
`,stderr:""}}let c=!1,u="",f=[];for(let p of o){if(!Oa(p)&&!
|
|
1357
|
+
`,stderr:""}}let c=!1,u="",f=[];for(let p of o){if(!Oa(p)&&!GE(p)){u+=`shopt: ${p}: invalid shell option name
|
|
1358
1358
|
`,c=!0;continue}if(n)Oa(p)&&(e.state.shoptOptions[p]=!0,$l(e));else if(r)Oa(p)&&(e.state.shoptOptions[p]=!1,$l(e));else if(Oa(p)){let h=e.state.shoptOptions[p];i?h||(c=!0):s?(f.push(`shopt ${h?"-s":"-u"} ${p}`),h||(c=!0)):(f.push(`${p} ${h?"on":"off"}`),h||(c=!0))}else i?c=!0:s?(f.push(`shopt -u ${p}`),c=!0):(f.push(`${p} off`),c=!0)}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`
|
|
1359
1359
|
`)}
|
|
1360
|
-
`:"",stderr:u}}function
|
|
1360
|
+
`:"",stderr:u}}function VE(e,t,n,r,s,i){let a=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"]]),o=["braceexpand","errtrace","functrace","hashall","histexpand","history","ignoreeof","interactive-comments","keyword","monitor","nolog","notify","onecmd","physical","privileged"],l=[...a.keys(),...o].sort();if(t.length===0){let p=[];for(let h of l){let m=o.includes(h),d=a.get(h),g=m||!d?!1:e.state.options[d];n&&!g||r&&g||p.push(s?`set ${g?"-o":"+o"} ${h}`:`${h} ${g?"on":"off"}`)}return{exitCode:0,stdout:p.length>0?`${p.join(`
|
|
1361
1361
|
`)}
|
|
1362
1362
|
`:"",stderr:""}}let c=!1,u="",f=[];for(let p of t){let h=a.has(p),m=o.includes(p);if(!h&&!m){u+=`shopt: ${p}: invalid option name
|
|
1363
1363
|
`,c=!0;continue}if(m){n||r||(i?c=!0:s?(f.push(`set +o ${p}`),c=!0):(f.push(`${p} off`),c=!0));continue}let d=a.get(p);if(d)if(n)d==="vi"?e.state.options.emacs=!1:d==="emacs"&&(e.state.options.vi=!1),e.state.options[d]=!0,Wr(e);else if(r)e.state.options[d]=!1,Wr(e);else{let g=e.state.options[d];i?g||(c=!0):s?(f.push(`set ${g?"-o":"+o"} ${p}`),g||(c=!0)):(f.push(`${p} ${g?"on":"off"}`),g||(c=!0))}}return{exitCode:c?1:0,stdout:f.length>0?`${f.join(`
|
|
@@ -1386,7 +1386,7 @@ ${e} ()
|
|
|
1386
1386
|
{
|
|
1387
1387
|
${n}
|
|
1388
1388
|
}
|
|
1389
|
-
`}function Ls(e){if(Array.isArray(e))return e.map(t=>Ls(t)).join("; ");if(e.type==="Statement"){let t=[];for(let n=0;n<e.pipelines.length;n++){let r=e.pipelines[n];t.push(
|
|
1389
|
+
`}function Ls(e){if(Array.isArray(e))return e.map(t=>Ls(t)).join("; ");if(e.type==="Statement"){let t=[];for(let n=0;n<e.pipelines.length;n++){let r=e.pipelines[n];t.push(qE(r)),e.operators[n]&&t.push(e.operators[n])}return t.join(" ")}if(e.type==="SimpleCommand"){let t=e,n=[];t.name&&n.push(a6(t.name));for(let r of t.args)n.push(a6(r));return n.join(" ")}return e.type==="Group"?`{ ${e.body.map(r=>Ls(r)).join("; ")}; }`:"..."}function qE(e){let t=e.commands.map(n=>Ls(n));return(e.negated?"! ":"")+t.join(" | ")}function a6(e){let t="";for(let n of e.parts)n.type==="Literal"?t+=n.value:n.type==="DoubleQuoted"?t+=`"${n.parts.map(r=>o6(r)).join("")}"`:n.type==="SingleQuoted"?t+=`'${n.value}'`:t+=o6(n);return t}function o6(e){let t=e;return t.type==="Literal"?t.value??"":t.type==="Variable"?`$${t.name}`:""}async function c6(e,t,n,r){let s="",i="",a=0;for(let o of t){if(!o){a=1;continue}let l=e.state.env.get(`BASH_ALIAS_${o}`);if(l!==void 0)r?s+=`${o} is an alias for "${l}"
|
|
1390
1390
|
`:s+=`alias ${o}='${l}'
|
|
1391
1391
|
`;else if(kc.has(o))r?s+=`${o} is a shell keyword
|
|
1392
1392
|
`:s+=`${o}
|
|
@@ -1400,53 +1400,53 @@ ${e} ()
|
|
|
1400
1400
|
`),a=1)}else if(e.commands.has(o)){let u=(e.state.env.get("PATH")??"/usr/bin:/bin").split(":"),f=null;for(let p of u){if(!p)continue;let h=`${p}/${o}`;try{let m=await e.fs.stat(h);if(!m.isDirectory&&(m.mode&73)!==0){f=h;break}}catch{}}f||(f=`/usr/bin/${o}`),r?s+=`${o} is ${f}
|
|
1401
1401
|
`:s+=`${f}
|
|
1402
1402
|
`}else r&&(i+=`${o}: not found
|
|
1403
|
-
`),a=1}return B(s,i,a)}async function u6(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 a=`${s.startsWith("/")?s:e.fs.resolvePath(e.state.cwd,s)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).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 f6(e,t,n,r,s,i,a,o){let{ctx:l,runCommand:c}=e;if(l.coverage&&Qr.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return Zc(l,n);if(t==="unset")return ou(l,n);if(t==="exit")return qc(l,n);if(t==="local")return Yc(l,n);if(t==="set")return ru(l,n);if(t==="break")return xc(l,n);if(t==="continue")return Pc(l,n);if(t==="return")return tu(l,n);if(t==="eval"&&l.state.options.posix)return va(l,n,s);if(t==="shift")return su(l,n);if(t==="getopts")return Ia(l,n);if(t==="compgen")return $c(l,n);if(t==="complete")return Rc(l,n);if(t==="compopt")return Tc(l,n);if(t==="pushd")return await jc(l,n);if(t==="popd")return Gc(l,n);if(t==="dirs")return Vc(l,n);if(t==="source"||t===".")return iu(l,n);if(t==="read")return eu(l,n,s,o);if(t==="mapfile"||t==="readarray")return Jc(l,n,s);if(t==="declare"||t==="typeset")return Bc(l,n);if(t==="readonly")return zc(l,n);if(!i){let u=l.state.functions.get(t);if(u)return Na(l,u,n,s)}if(t==="eval")return va(l,n,s);if(t==="cd")return await Ec(l,n);if(t===":"||t==="true")return de;if(t==="false")return Je(!1);if(t==="let")return Xc(l,n);if(t==="command")return
|
|
1403
|
+
`),a=1}return B(s,i,a)}async function u6(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 a=`${s.startsWith("/")?s:e.fs.resolvePath(e.state.cwd,s)}/${t}`;if(await e.fs.exists(a)){try{if((await e.fs.stat(a)).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 f6(e,t,n,r,s,i,a,o){let{ctx:l,runCommand:c}=e;if(l.coverage&&Qr.has(t)&&l.coverage.hit(`bash:builtin:${t}`),t==="export")return Zc(l,n);if(t==="unset")return ou(l,n);if(t==="exit")return qc(l,n);if(t==="local")return Yc(l,n);if(t==="set")return ru(l,n);if(t==="break")return xc(l,n);if(t==="continue")return Pc(l,n);if(t==="return")return tu(l,n);if(t==="eval"&&l.state.options.posix)return va(l,n,s);if(t==="shift")return su(l,n);if(t==="getopts")return Ia(l,n);if(t==="compgen")return $c(l,n);if(t==="complete")return Rc(l,n);if(t==="compopt")return Tc(l,n);if(t==="pushd")return await jc(l,n);if(t==="popd")return Gc(l,n);if(t==="dirs")return Vc(l,n);if(t==="source"||t===".")return iu(l,n);if(t==="read")return eu(l,n,s,o);if(t==="mapfile"||t==="readarray")return Jc(l,n,s);if(t==="declare"||t==="typeset")return Bc(l,n);if(t==="readonly")return zc(l,n);if(!i){let u=l.state.functions.get(t);if(u)return Na(l,u,n,s)}if(t==="eval")return va(l,n,s);if(t==="cd")return await Ec(l,n);if(t===":"||t==="true")return de;if(t==="false")return Je(!1);if(t==="let")return Xc(l,n);if(t==="command")return ZE(e,n,s);if(t==="builtin")return KE(e,n,s);if(t==="shopt")return r6(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 l6(l,n,u=>u6(l,u),u=>Ra(l,u));if(t==="hash")return Kc(l,n);if(t==="help")return Qc(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 Ps(l,u)}return null}async function ZE(e,t,n){let{ctx:r,runCommand:s}=e;if(t.length===0)return de;let i=!1,a=!1,o=!1,l=t;for(;l.length>0&&l[0].startsWith("-");){let f=l[0];if(f==="--"){l=l.slice(1);break}for(let p of f.slice(1))p==="p"?i=!0:p==="V"?a=!0:p==="v"&&(o=!0);l=l.slice(1)}if(l.length===0)return de;if(o||a)return await c6(r,l,o,a);let[c,...u]=l;return s(c,u,[],n,!0,i,-1)}async function KE(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(!Qr.has(i))return W(`bash: builtin: ${i}: not a shell builtin
|
|
1404
1404
|
`);let[,...a]=s;return r(i,a,[],n,!0,!1,-1)}async function p6(e,t,n,r,s){let{ctx:i,buildExportedEnv:a,executeUserScript:o}=e,c=await s6(i,t,s?"/usr/bin:/bin":void 0);if(!c)return xg(t)?W(`bash: ${t}: command not available in browser environments. Exclude '${t}' from your commands or use the Node.js bundle.
|
|
1405
1405
|
`,127):W(`bash: ${t}: command not found
|
|
1406
1406
|
`,127);if("error"in c)return c.error==="permission_denied"?W(`bash: ${t}: Permission denied
|
|
1407
1407
|
`,126):W(`bash: ${t}: No such file or directory
|
|
1408
1408
|
`,127);if("script"in c)return t.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,c.path)),await o(c.path,n,r);let{cmd:u,path:f}=c;t.includes("/")||(i.state.hashTable||(i.state.hashTable=new Map),i.state.hashTable.set(t,f));let p=r||i.state.groupStdin||"",h=a(),m={fs:i.fs,cwd:i.state.cwd,env:i.state.env,exportedEnv:h,stdin:p,limits:i.limits,exec:i.execFn,fetch:i.fetch,getRegisteredCommands:()=>Array.from(i.commands.keys()),sleep:i.sleep,trace:i.trace,fileDescriptors:i.state.fileDescriptors,xpgEcho:i.state.shoptOptions.xpg_echo,coverage:i.coverage};try{return await u.execute(n,m)}catch(d){if(d instanceof te)throw d;return W(`${t}: ${Ue(d)}
|
|
1409
|
-
`)}}
|
|
1410
|
-
`,exitCode:1}}ye();zt();async function Ta(e,t,n="",r=""){let s=n,i=r,a=0;try{for(let o of t){let l=await e.executeStatement(o);s+=l.stdout,i+=l.stderr,a=l.exitCode}}catch(o){if(js(o)||o instanceof
|
|
1409
|
+
`)}}St();ye();Ct();async function cu(e,t){let n=e.state.inCondition;e.state.inCondition=!0;let r="",s="",i=0;try{for(let a of t){let o=await e.executeStatement(a);r+=o.stdout,s+=o.stderr,i=o.exitCode}}finally{e.state.inCondition=n}return{stdout:r,stderr:s,exitCode:i}}ye();zt();function Fs(e,t,n,r){if(e instanceof pt)return t+=e.stdout,n+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=n,{action:"rethrow",stdout:t,stderr:n,error:e}):{action:"break",stdout:t,stderr:n};if(e instanceof ht)return t+=e.stdout,n+=e.stderr,e.levels>1&&r>1?(e.levels--,e.stdout=t,e.stderr=n,{action:"rethrow",stdout:t,stderr:n,error:e}):{action:"continue",stdout:t,stderr:n};if(e instanceof ct||e instanceof vt||e instanceof pe||e instanceof te)return e.prependOutput(t,n),{action:"rethrow",stdout:t,stderr:n,error:e};let s=Ue(e);return{action:"error",stdout:t,stderr:`${n}${s}
|
|
1410
|
+
`,exitCode:1}}ye();zt();async function Ta(e,t,n="",r=""){let s=n,i=r,a=0;try{for(let o of t){let l=await e.executeStatement(o);s+=l.stdout,i+=l.stderr,a=l.exitCode}}catch(o){if(js(o)||o instanceof vt||o instanceof pe||o instanceof te||o instanceof pn)throw o.prependOutput(s,i),o;return{stdout:s,stderr:`${i}${Ue(o)}
|
|
1411
1411
|
`,exitCode:1}}return{stdout:s,stderr:i,exitCode:a}}async function h6(e,t){let n="",r="";for(let s of t.clauses){let i=await cu(e,s.condition);if(n+=i.stdout,r+=i.stderr,i.exitCode===0)return Ta(e,s.body,n,r)}return t.elseBody?Ta(e,t.elseBody,n,r):B(n,r,0)}async function d6(e,t){let n=await Sn(e,t.redirections);if(n)return n;let r="",s="",i=0,a=0;if(!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t.variable))return W(`bash: \`${t.variable}': not a valid identifier
|
|
1412
1412
|
`);let o=[];if(t.words===null)o=(e.state.env.get("@")||"").split(" ").filter(Boolean);else if(t.words.length===0)o=[];else try{for(let c of t.words){let u=await cn(e,c);o.push(...u.values)}}catch(c){if(c instanceof fn)return{stdout:"",stderr:c.stderr,exitCode:1};throw c}e.state.loopDepth++;try{for(let c of o){a++,a>e.limits.maxLoopIterations&&On(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,s),e.state.env.set(t.variable,c);try{for(let u of t.body){let f=await e.executeStatement(u);r+=f.stdout,s+=f.stderr,i=f.exitCode}}catch(u){let f=Fs(u,r,s,e.state.loopDepth);if(r=f.stdout,s=f.stderr,f.action==="break")break;if(f.action==="continue")continue;if(f.action==="error"){let p=B(r,s,f.exitCode??1);return ze(e,p,t.redirections)}throw f.error}}}finally{e.state.loopDepth--}let l=B(r,s,i);return ze(e,l,t.redirections)}async function m6(e,t){let n=await Sn(e,t.redirections);if(n)return n;let r=t.line;r!==void 0&&(e.state.currentLine=r);let s="",i="",a=0,o=0;t.init&&await ne(e,t.init.expression),e.state.loopDepth++;try{for(;o++,o>e.limits.maxLoopIterations&&On(`for loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",s,i),!(t.condition&&(r!==void 0&&(e.state.currentLine=r),await ne(e,t.condition.expression)===0));){try{for(let c of t.body){let u=await e.executeStatement(c);s+=u.stdout,i+=u.stderr,a=u.exitCode}}catch(c){let u=Fs(c,s,i,e.state.loopDepth);if(s=u.stdout,i=u.stderr,u.action==="break")break;if(u.action==="continue"){t.update&&await ne(e,t.update.expression);continue}if(u.action==="error"){let f=B(s,i,u.exitCode??1);return ze(e,f,t.redirections)}throw u.error}t.update&&await ne(e,t.update.expression)}}finally{e.state.loopDepth--}let l=B(s,i,a);return ze(e,l,t.redirections)}async function g6(e,t,n=""){let r="",s="",i=0,a=0,o=n;for(let c of t.redirections)if((c.operator==="<<"||c.operator==="<<-")&&c.target.type==="HereDoc"){let u=c.target,f=await ie(e,u.content);u.stripTabs&&(f=f.split(`
|
|
1413
1413
|
`).map(p=>p.replace(/^\t+/,"")).join(`
|
|
1414
1414
|
`)),o=f}else if(c.operator==="<<<"&&c.target.type==="Word")o=`${await ie(e,c.target)}
|
|
1415
1415
|
`;else if(c.operator==="<"&&c.target.type==="Word")try{let u=await ie(e,c.target),f=e.fs.resolvePath(e.state.cwd,u);o=await e.fs.readFile(f)}catch{let u=await ie(e,c.target);return W(`bash: ${u}: No such file or directory
|
|
1416
|
-
`)}let l=e.state.groupStdin;o&&(e.state.groupStdin=o),e.state.loopDepth++;try{for(;;){a++,a>e.limits.maxLoopIterations&&On(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,s);let c=0,u=!1,f=!1,p=e.state.inCondition;e.state.inCondition=!0;try{for(let h of t.condition){let m=await e.executeStatement(h);r+=m.stdout,s+=m.stderr,c=m.exitCode}}catch(h){if(h instanceof pt){if(r+=h.stdout,s+=h.stderr,h.levels>1&&e.state.loopDepth>1)throw h.levels--,h.stdout=r,h.stderr=s,e.state.inCondition=p,h;u=!0}else if(h instanceof ht){if(r+=h.stdout,s+=h.stderr,h.levels>1&&e.state.loopDepth>1)throw h.levels--,h.stdout=r,h.stderr=s,e.state.inCondition=p,h;f=!0}else throw e.state.inCondition=p,h}finally{e.state.inCondition=p}if(u)break;if(!f){if(c!==0)break;try{for(let h of t.body){let m=await e.executeStatement(h);r+=m.stdout,s+=m.stderr,i=m.exitCode}}catch(h){let m=Fs(h,r,s,e.state.loopDepth);if(r=m.stdout,s=m.stderr,m.action==="break")break;if(m.action==="continue")continue;if(m.action==="error")return B(r,s,m.exitCode??1);throw m.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=l}return B(r,s,i)}async function y6(e,t){let n="",r="",s=0,i=0;e.state.loopDepth++;try{for(;;){i++,i>e.limits.maxLoopIterations&&On(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r);let a=await cu(e,t.condition);if(n+=a.stdout,r+=a.stderr,a.exitCode===0)break;try{for(let o of t.body){let l=await e.executeStatement(o);n+=l.stdout,r+=l.stderr,s=l.exitCode}}catch(o){let l=Fs(o,n,r,e.state.loopDepth);if(n=l.stdout,r=l.stderr,l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return B(n,r,l.exitCode??1);throw l.error}}}finally{e.state.loopDepth--}return B(n,r,s)}async function w6(e,t){let n=await Sn(e,t.redirections);if(n)return n;let r="",s="",i=0,a=await ie(e,t.word),o=!1;for(let c=0;c<t.items.length;c++){let u=t.items[c],f=o;if(!o)for(let p of u.patterns){let h=await ie(e,p);hc(p)&&(h=_t(h));let m=e.state.shoptOptions.nocasematch,d=e.state.shoptOptions.extglob;if(Zr(a,h,m,d)){f=!0;break}}if(f){let p=await Ta(e,u.body,r,s);if(r=p.stdout,s=p.stderr,i=p.exitCode,u.terminator===";;")break;u.terminator===";&"?o=!0:o=!1}else o=!1}let l=B(r,s,i);return ze(e,l,t.redirections)}ye();
|
|
1417
|
-
`,t||x6}}function
|
|
1416
|
+
`)}let l=e.state.groupStdin;o&&(e.state.groupStdin=o),e.state.loopDepth++;try{for(;;){a++,a>e.limits.maxLoopIterations&&On(`while loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",r,s);let c=0,u=!1,f=!1,p=e.state.inCondition;e.state.inCondition=!0;try{for(let h of t.condition){let m=await e.executeStatement(h);r+=m.stdout,s+=m.stderr,c=m.exitCode}}catch(h){if(h instanceof pt){if(r+=h.stdout,s+=h.stderr,h.levels>1&&e.state.loopDepth>1)throw h.levels--,h.stdout=r,h.stderr=s,e.state.inCondition=p,h;u=!0}else if(h instanceof ht){if(r+=h.stdout,s+=h.stderr,h.levels>1&&e.state.loopDepth>1)throw h.levels--,h.stdout=r,h.stderr=s,e.state.inCondition=p,h;f=!0}else throw e.state.inCondition=p,h}finally{e.state.inCondition=p}if(u)break;if(!f){if(c!==0)break;try{for(let h of t.body){let m=await e.executeStatement(h);r+=m.stdout,s+=m.stderr,i=m.exitCode}}catch(h){let m=Fs(h,r,s,e.state.loopDepth);if(r=m.stdout,s=m.stderr,m.action==="break")break;if(m.action==="continue")continue;if(m.action==="error")return B(r,s,m.exitCode??1);throw m.error}}}}finally{e.state.loopDepth--,e.state.groupStdin=l}return B(r,s,i)}async function y6(e,t){let n="",r="",s=0,i=0;e.state.loopDepth++;try{for(;;){i++,i>e.limits.maxLoopIterations&&On(`until loop: too many iterations (${e.limits.maxLoopIterations}), increase executionLimits.maxLoopIterations`,"iterations",n,r);let a=await cu(e,t.condition);if(n+=a.stdout,r+=a.stderr,a.exitCode===0)break;try{for(let o of t.body){let l=await e.executeStatement(o);n+=l.stdout,r+=l.stderr,s=l.exitCode}}catch(o){let l=Fs(o,n,r,e.state.loopDepth);if(n=l.stdout,r=l.stderr,l.action==="break")break;if(l.action==="continue")continue;if(l.action==="error")return B(n,r,l.exitCode??1);throw l.error}}}finally{e.state.loopDepth--}return B(n,r,s)}async function w6(e,t){let n=await Sn(e,t.redirections);if(n)return n;let r="",s="",i=0,a=await ie(e,t.word),o=!1;for(let c=0;c<t.items.length;c++){let u=t.items[c],f=o;if(!o)for(let p of u.patterns){let h=await ie(e,p);hc(p)&&(h=_t(h));let m=e.state.shoptOptions.nocasematch,d=e.state.shoptOptions.extglob;if(Zr(a,h,m,d)){f=!0;break}}if(f){let p=await Ta(e,u.body,r,s);if(r=p.stdout,s=p.stderr,i=p.exitCode,u.terminator===";;")break;u.terminator===";&"?o=!0:o=!1}else o=!1}let l=B(r,s,i);return ze(e,l,t.redirections)}ye();Ct();function uu(e,t){if(e.parts.length!==1)return!1;let n=e.parts[0];return n.type!=="Literal"?!1:t.includes(n.value)}function b6(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),a=s+r+1,o=t.slice(a),l=o.indexOf(":");if(l===-1)return null;let c=Number.parseInt(o.slice(0,l),10);if(Number.isNaN(c)||c<0)return null;let u=o.slice(l+1);return{path:i,position:c,content:u}}Xe();Ct();var x6="+ ";async function E6(e){let t=e.state.env.get("PS4");if(t===void 0)return x6;if(t==="")return"";try{let r=new ce().parseWordFromString(t,!1,!1);return await ie(e,r)}catch{return e.state.expansionStderr=`${e.state.expansionStderr||""}bash: ${t}: bad substitution
|
|
1417
|
+
`,t||x6}}function QE(e){return e.map(t=>XE(t)).join(" ")}function XE(e){if(e==="")return"''";if(!/[\s'"\\$`!*?[\]{}|&;<>()~#\n\t]/.test(e))return e;let n=/[\x00-\x1f\x7f]/.test(e),r=e.includes(`
|
|
1418
1418
|
`),s=e.includes(" "),i=e.includes("\\"),a=e.includes("'");if(n||r||s||i){let l="";for(let c of e){let u=c.charCodeAt(0);c===`
|
|
1419
|
-
`?l+="\\n":c===" "?l+="\\t":c==="\\"?l+="\\\\":c==="'"?l+="'":c==='"'?l+='"':u<32||u===127?u<256?l+=`\\x${u.toString(16).padStart(2,"0")}`:l+=`\\u${u.toString(16).padStart(4,"0")}`:l+=c}return`$'${l}'`}return a?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function A6(e,t,n){if(!e.state.options.xtrace)return"";let r=await E6(e),s=[t,...n],i=
|
|
1419
|
+
`?l+="\\n":c===" "?l+="\\t":c==="\\"?l+="\\\\":c==="'"?l+="'":c==='"'?l+='"':u<32||u===127?u<256?l+=`\\x${u.toString(16).padStart(2,"0")}`:l+=`\\u${u.toString(16).padStart(4,"0")}`:l+=c}return`$'${l}'`}return a?`"${e.replace(/([\\$`"])/g,"\\$1")}"`:`'${e}'`}async function A6(e,t,n){if(!e.state.options.xtrace)return"";let r=await E6(e),s=[t,...n],i=QE(s);return`${r}${i}
|
|
1420
1420
|
`}async function S6(e,t,n){return e.state.options.xtrace?`${await E6(e)}${t}=${n}
|
|
1421
|
-
`:""}ye();async function C6(e,t,n){let r=t.timed?performance.now():0,s="",i=de,a=0,o=[],l="",c=t.commands.length>1,u=e.state.lastArg;for(let p=0;p<t.commands.length;p++){let h=t.commands[p],m=p===t.commands.length-1,d=p===0;c&&(e.state.lastArg="",d||(e.state.groupStdin=void 0));let w=c&&(!m||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,y;try{y=await n(h,s)}catch(b){if(b instanceof
|
|
1421
|
+
`:""}ye();async function C6(e,t,n){let r=t.timed?performance.now():0,s="",i=de,a=0,o=[],l="",c=t.commands.length>1,u=e.state.lastArg;for(let p=0;p<t.commands.length;p++){let h=t.commands[p],m=p===t.commands.length-1,d=p===0;c&&(e.state.lastArg="",d||(e.state.groupStdin=void 0));let w=c&&(!m||!e.state.shoptOptions.lastpipe)?new Map(e.state.env):null,y;try{y=await n(h,s)}catch(b){if(b instanceof wt)y={stdout:b.stdout,stderr:b.stderr,exitCode:1};else if(b instanceof pe&&t.commands.length>1)y={stdout:b.stdout,stderr:b.stderr,exitCode:b.exitCode};else if(b instanceof vt&&t.commands.length>1)y={stdout:b.stdout,stderr:b.stderr,exitCode:b.exitCode};else throw w&&(e.state.env=w),b}w&&(e.state.env=w),o.push(y.exitCode),y.exitCode!==0&&(a=y.exitCode),m?i=y:(t.pipeStderr?.[p]??!1?s=y.stderr+y.stdout:(s=y.stdout,l+=y.stderr),i={stdout:"",stderr:"",exitCode:y.exitCode})}if(l&&(i={...i,stderr:l+i.stderr}),t.commands.length>1||t.commands.length===1&&t.commands[0].type==="SimpleCommand"){for(let p of e.state.env.keys())p.startsWith("PIPESTATUS_")&&e.state.env.delete(p);for(let p=0;p<o.length;p++)e.state.env.set(`PIPESTATUS_${p}`,String(o[p]));e.state.env.set("PIPESTATUS__length",String(o.length))}if(e.state.options.pipefail&&a!==0&&(i={...i,exitCode:a}),t.negated&&(i={...i,exitCode:i.exitCode===0?1:0}),t.timed){let h=(performance.now()-r)/1e3,m=Math.floor(h/60),d=h%60,g;t.timePosix?g=`real ${h.toFixed(2)}
|
|
1422
1422
|
user 0.00
|
|
1423
1423
|
sys 0.00
|
|
1424
1424
|
`:g=`
|
|
1425
1425
|
real ${`${m}m${d.toFixed(3)}s`}
|
|
1426
1426
|
user 0m0.000s
|
|
1427
1427
|
sys 0m0.000s
|
|
1428
|
-
`,i={...i,stderr:i.stderr+g}}return c&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}
|
|
1429
|
-
`,1)};let l=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(l){let u=await
|
|
1430
|
-
`,1)};if(Te(e,n)){let u=lr(e,n);if(u===void 0||u==="")throw new pe(1,"","");let f=
|
|
1428
|
+
`,i={...i,stderr:i.stderr+g}}return c&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}dt();Xe();St();ye();Ct();Xt();an();Bn();async function N6(e,t){let n=new Map,r="";for(let s of t.assignments){let i=s.name;if(s.array){let u=await YE(e,t,i,s.array,s.append,n);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:u.error};if(r+=u.xtraceOutput,u.continueToNext)continue}let a=s.value?await ie(e,s.value):"";if(i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[\]$/))return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:B("",`bash: ${i}: bad array subscript
|
|
1429
|
+
`,1)};let l=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(l){let u=await rA(e,t,l[1],l[2],a,s.append,n);if(u.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:u.error};if(u.continueToNext)continue}let c=await iA(e,t,i,a,s.append,n);if(c.error)return{continueToNext:!1,xtraceOutput:r,tempAssignments:n,error:c.error};r+=c.xtraceOutput,c.continueToNext}return{continueToNext:!1,xtraceOutput:r,tempAssignments:n}}async function YE(e,t,n,r,s,i){let a="";if(/\[.+\]$/.test(n))return{continueToNext:!1,xtraceOutput:"",error:B("",`bash: ${n}: cannot assign list to array member
|
|
1430
|
+
`,1)};if(Te(e,n)){let u=lr(e,n);if(u===void 0||u==="")throw new pe(1,"","");let f=At(e,n);if(f&&/^[a-zA-Z_][a-zA-Z0-9_]*\[@\]$/.test(f))return{continueToNext:!1,xtraceOutput:"",error:B("",`bash: ${n}: cannot assign list to array member
|
|
1431
1431
|
`,1)}}if(En(e,n)){if(t.name)return a+=`bash: ${n}: readonly variable
|
|
1432
|
-
`,{continueToNext:!0,xtraceOutput:a};let u=it(e,n);if(u)return{continueToNext:!1,xtraceOutput:"",error:u}}let o=e.state.associativeArrays?.has(n),l=
|
|
1433
|
-
`)}}async function
|
|
1434
|
-
`,1)};o=f}}if(En(e,o)){if(t.name)return{continueToNext:!0,xtraceOutput:""};let f=it(e,o);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let l=e.state.associativeArrays?.has(o),c;if(l)c=await k6(e,o,r);else{let f=await
|
|
1432
|
+
`,{continueToNext:!0,xtraceOutput:a};let u=it(e,n);if(u)return{continueToNext:!1,xtraceOutput:"",error:u}}let o=e.state.associativeArrays?.has(n),l=JE(r),c=()=>{let u=`${n}_`;for(let f of e.state.env.keys())f.startsWith(u)&&!f.includes("__")&&e.state.env.delete(f);e.state.env.delete(n)};if(o&&l?await eA(e,t,n,r,s,c,u=>{a+=u}):l?await tA(e,n,r,s,c):await nA(e,n,r,s,c),t.name){i.set(n,e.state.env.get(n));let f=`(${r.map(p=>Br(p)).join(" ")})`;e.state.env.set(n,f)}return{continueToNext:!0,xtraceOutput:a}}function JE(e){return e.some(t=>{if(t.parts.length>=2){let n=t.parts[0],r=t.parts[1];if(n.type!=="Glob"||!n.pattern.startsWith("["))return!1;if(n.pattern==="["&&(r.type==="DoubleQuoted"||r.type==="SingleQuoted")){if(t.parts.length<3)return!1;let s=t.parts[2];return s.type!=="Literal"?!1:s.value.startsWith("]=")||s.value.startsWith("]+=")}return r.type!=="Literal"?!1:r.value.startsWith("]")?r.value.startsWith("]=")||r.value.startsWith("]+="):n.pattern.endsWith("]")?r.value.startsWith("=")||r.value.startsWith("+="):!1}return!1})}async function eA(e,t,n,r,s,i,a){let o=[];for(let l of r){let c=nc(l);if(c){let{key:u,valueParts:f,append:p}=c,h;f.length>0?h=await ie(e,{type:"Word",parts:f}):h="",h=qe(e,h),o.push({type:"keyed",key:u,value:h,append:p})}else{let u=await ie(e,l);o.push({type:"invalid",expandedValue:u})}}s||i();for(let l of o)if(l.type==="keyed")if(l.append){let c=e.state.env.get(`${n}_${l.key}`)??"";e.state.env.set(`${n}_${l.key}`,c+l.value)}else e.state.env.set(`${n}_${l.key}`,l.value);else{let c=t.line??e.state.currentLine??1;a(`bash: line ${c}: ${n}: ${l.expandedValue}: must use subscript when assigning associative array
|
|
1433
|
+
`)}}async function tA(e,t,n,r,s){let i=[];for(let o of n){let l=nc(o);if(l){let{key:c,valueParts:u,append:f}=l,p;u.length>0?p=await ie(e,{type:"Word",parts:u}):p="",p=qe(e,p),i.push({type:"keyed",indexExpr:c,value:p,append:f})}else{let c=await cn(e,o);i.push({type:"non-keyed",values:c.values})}}r||s();let a=0;for(let o of i)if(o.type==="keyed"){let l;try{let c=new ce,u=Ae(c,o.indexExpr);l=await ne(e,u.expression,!1)}catch{if(/^-?\d+$/.test(o.indexExpr))l=Number.parseInt(o.indexExpr,10);else{let c=e.state.env.get(o.indexExpr);l=c?Number.parseInt(c,10):0,Number.isNaN(l)&&(l=0)}}if(o.append){let c=e.state.env.get(`${t}_${l}`)??"";e.state.env.set(`${t}_${l}`,c+o.value)}else e.state.env.set(`${t}_${l}`,o.value);a=l+1}else for(let l of o.values)e.state.env.set(`${t}_${a++}`,l)}async function nA(e,t,n,r,s){let i=[];for(let o of n){let l=await cn(e,o);i.push(...l.values)}let a=0;if(r){let o=oe(e,t);if(o.length>0)a=Math.max(...o.map(([c])=>typeof c=="number"?c:0))+1;else{let l=e.state.env.get(t);l!==void 0&&(e.state.env.set(`${t}_0`,l),e.state.env.delete(t),a=1)}}else s();for(let o=0;o<i.length;o++)e.state.env.set(`${t}_${a+o}`,i[o]);r||e.state.env.set(`${t}__length`,String(i.length))}async function rA(e,t,n,r,s,i,a){let o=n;if(Te(e,n)){let f=At(e,n);if(f&&f!==n){if(f.includes("["))return{continueToNext:!1,xtraceOutput:"",error:B("",`bash: \`${f}': not a valid identifier
|
|
1434
|
+
`,1)};o=f}}if(En(e,o)){if(t.name)return{continueToNext:!0,xtraceOutput:""};let f=it(e,o);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let l=e.state.associativeArrays?.has(o),c;if(l)c=await k6(e,o,r);else{let f=await sA(e,o,r);if(f.error)return{continueToNext:!1,xtraceOutput:"",error:f.error};c=`${o}_${f.index}`}let u=i?(e.state.env.get(c)||"")+s:s;if(t.name)a.set(c,e.state.env.get(c)),e.state.env.set(c,u);else{let f=Kr(e,o);if(f!==void 0&&f===e.state.callDepth&&e.state.localScopes.length>0){let p=e.state.localScopes[e.state.localScopes.length-1];p.has(c)||p.set(c,e.state.env.get(c))}e.state.env.set(c,u)}return{continueToNext:!0,xtraceOutput:""}}async function k6(e,t,n){let r;if(n.startsWith("'")&&n.endsWith("'"))r=n.slice(1,-1);else if(n.startsWith('"')&&n.endsWith('"')){let s=n.slice(1,-1),a=new ce().parseWordFromString(s,!0,!1);r=await ie(e,a)}else if(n.includes("$")){let i=new ce().parseWordFromString(n,!1,!1);r=await ie(e,i)}else r=n;return`${t}_${r}`}async function sA(e,t,n){let r=n;n.startsWith('"')&&n.endsWith('"')&&n.length>=2&&(r=n.slice(1,-1));let s;if(/^-?\d+$/.test(r))s=Number.parseInt(r,10);else{try{let i=new ce,a=Ae(i,r);s=await ne(e,a.expression,!1)}catch(i){if(i instanceof Re){let l=`bash: line ${e.state.currentLine}: ${n}: ${i.message}
|
|
1435
1435
|
`;if(i.fatal)throw new pe(1,"",l);return{index:0,error:B("",l,1)}}let a=e.state.env.get(n);s=a?Number.parseInt(a,10):0}Number.isNaN(s)&&(s=0)}if(s<0){let i=oe(e,t);if(i.length===0){let o=e.state.currentLine;return{index:0,error:B("",`bash: line ${o}: ${t}[${n}]: bad array subscript
|
|
1436
1436
|
`,1)}}if(s=Math.max(...i.map(([o])=>typeof o=="number"?o:0))+1+s,s<0){let o=e.state.currentLine;return{index:0,error:B("",`bash: line ${o}: ${t}[${n}]: bad array subscript
|
|
1437
|
-
`,1)}}}return{index:s}}async function
|
|
1437
|
+
`,1)}}}return{index:s}}async function iA(e,t,n,r,s,i){let a="",o=n,l=null;if(Te(e,n)){let f=Xm(e,n,r);if(f===void 0)return{continueToNext:!1,xtraceOutput:"",error:B("",`bash: ${n}: circular name reference
|
|
1438
1438
|
`,1)};if(f===null)return{continueToNext:!0,xtraceOutput:""};o=f;let p=o.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);p&&(l={arrayName:p[1],subscriptExpr:p[2]},o=p[1])}if(En(e,o)){if(t.name)return a+=`bash: ${o}: readonly variable
|
|
1439
|
-
`,{continueToNext:!0,xtraceOutput:a};let f=it(e,o);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(Ds(e,o))try{let f=new ce;if(s){let h=`(${e.state.env.get(o)||"0"}) + (${r})`,m=Ae(f,h);c=String(await ne(e,m.expression))}else{let p=Ae(f,r);c=String(await ne(e,p.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(
|
|
1439
|
+
`,{continueToNext:!0,xtraceOutput:a};let f=it(e,o);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(Ds(e,o))try{let f=new ce;if(s){let h=`(${e.state.env.get(o)||"0"}) + (${r})`,m=Ae(f,h);c=String(await ne(e,m.expression))}else{let p=Ae(f,r);c=String(await ne(e,p.expression))}}catch{c="0"}else{let{isArray:f}=await Promise.resolve().then(()=>(Ct(),yc)),p=f(e,o)?`${o}_0`:o;c=s?(e.state.env.get(p)||"")+r:r}c=Yr(e,o,c),a+=await S6(e,o,c);let u=o;if(l)u=await aA(e,l);else{let{isArray:f}=await Promise.resolve().then(()=>(Ct(),yc));f(e,o)&&(u=`${o}_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(o)),e.state.tempEnvBindings?.some(f=>f.has(o))&&(e.state.mutatedTempEnvVars=e.state.mutatedTempEnvVars||new Set,e.state.mutatedTempEnvVars.add(o))),{continueToNext:!1,xtraceOutput:a}}async function aA(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return k6(e,n,r);let i;if(/^-?\d+$/.test(r))i=Number.parseInt(r,10);else{try{let a=new ce,o=Ae(a,r);i=await ne(e,o.expression,!1)}catch{let a=e.state.env.get(r);i=a?Number.parseInt(a,10):0}Number.isNaN(i)&&(i=0)}if(i<0){let a=oe(e,n);a.length>0&&(i=Math.max(...a.map(l=>l[0]))+1+i)}return`${n}_${i}`}Xe();ye();Ct();zt();async function v6(e,t,n,r){let s=await Sn(e,t.redirections);if(s)return s;let i=new Map(e.state.env),a=e.state.cwd,o={...e.state.options},l=new Map(e.state.functions),c=e.state.localScopes,u=e.state.localVarStack,f=e.state.localVarDepth,p=e.state.fullyUnsetLocals;if(e.state.localScopes=c.map(O=>new Map(O)),u){e.state.localVarStack=new Map;for(let[O,F]of u.entries())e.state.localVarStack.set(O,F.map(R=>({...R})))}f&&(e.state.localVarDepth=new Map(f)),p&&(e.state.fullyUnsetLocals=new Map(p));let h=e.state.loopDepth,m=e.state.parentHasLoopContext;e.state.parentHasLoopContext=h>0,e.state.loopDepth=0;let d=e.state.lastArg,g=e.state.bashPid;e.state.bashPid=e.state.nextVirtualPid++;let w=e.state.groupStdin;n&&(e.state.groupStdin=n);let y="",b="",x=0,S=()=>{e.state.env=i,e.state.cwd=a,e.state.options=o,e.state.functions=l,e.state.localScopes=c,e.state.localVarStack=u,e.state.localVarDepth=f,e.state.fullyUnsetLocals=p,e.state.loopDepth=h,e.state.parentHasLoopContext=m,e.state.groupStdin=w,e.state.bashPid=g,e.state.lastArg=d};try{for(let O of t.body){let F=await r(O);y+=F.stdout,b+=F.stderr,x=F.exitCode}}catch(O){if(S(),O instanceof te)throw O;if(O instanceof pn){y+=O.stdout,b+=O.stderr;let R=B(y,b,0);return ze(e,R,t.redirections)}if(O instanceof pt||O instanceof ht){y+=O.stdout,b+=O.stderr;let R=B(y,b,0);return ze(e,R,t.redirections)}if(O instanceof pe){y+=O.stdout,b+=O.stderr;let R=B(y,b,O.exitCode);return ze(e,R,t.redirections)}if(O instanceof ct){y+=O.stdout,b+=O.stderr;let R=B(y,b,O.exitCode);return ze(e,R,t.redirections)}if(O instanceof vt){let R=B(y+O.stdout,b+O.stderr,O.exitCode);return ze(e,R,t.redirections)}let F=B(y,`${b}${Ue(O)}
|
|
1440
1440
|
`,1);return ze(e,F,t.redirections)}S();let $=B(y,b,x);return ze(e,$,t.redirections)}async function I6(e,t,n,r){let s="",i="",a=0,o=await Ca(e,t.redirections);if(o)return o;let l=n;for(let f of t.redirections)if((f.operator==="<<"||f.operator==="<<-")&&f.target.type==="HereDoc"){let p=f.target,h=await ie(e,p.content);p.stripTabs&&(h=h.split(`
|
|
1441
1441
|
`).map(d=>d.replace(/^\t+/,"")).join(`
|
|
1442
1442
|
`));let m=f.fd??0;m!==0?(e.state.fileDescriptors||(e.state.fileDescriptors=new Map),e.state.fileDescriptors.set(m,h)):l=h}else if(f.operator==="<<<"&&f.target.type==="Word")l=`${await ie(e,f.target)}
|
|
1443
1443
|
`;else if(f.operator==="<"&&f.target.type==="Word")try{let p=await ie(e,f.target),h=e.fs.resolvePath(e.state.cwd,p);l=await e.fs.readFile(h)}catch{let p=await ie(e,f.target);return B("",`bash: ${p}: No such file or directory
|
|
1444
|
-
`,1)}let c=e.state.groupStdin;l&&(e.state.groupStdin=l);try{for(let f of t.body){let p=await r(f);s+=p.stdout,i+=p.stderr,a=p.exitCode}}catch(f){if(e.state.groupStdin=c,f instanceof te)throw f;if(js(f)||f instanceof
|
|
1444
|
+
`,1)}let c=e.state.groupStdin;l&&(e.state.groupStdin=l);try{for(let f of t.body){let p=await r(f);s+=p.stdout,i+=p.stderr,a=p.exitCode}}catch(f){if(e.state.groupStdin=c,f instanceof te)throw f;if(js(f)||f instanceof vt||f instanceof pe)throw f.prependOutput(s,i),f;return B(s,`${i}${Ue(f)}
|
|
1445
1445
|
`,1)}e.state.groupStdin=c;let u=B(s,i,a);return ze(e,u,t.redirections)}async function $6(e,t,n,r,s){let i;try{i=await e.fs.readFile(t)}catch{return W(`bash: ${t}: No such file or directory
|
|
1446
1446
|
`,127)}if(i.startsWith("#!")){let g=i.indexOf(`
|
|
1447
1447
|
`);g!==-1&&(i=i.slice(g+1))}let a=new Map(e.state.env),o=e.state.cwd,l={...e.state.options},c=e.state.loopDepth,u=e.state.parentHasLoopContext,f=e.state.lastArg,p=e.state.bashPid,h=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=a,e.state.cwd=o,e.state.options=l,e.state.loopDepth=c,e.state.parentHasLoopContext=u,e.state.lastArg=f,e.state.bashPid=p,e.state.groupStdin=h,e.state.currentSource=m};try{let w=new ce().parse(i),y=await s(w);return d(),y}catch(g){if(d(),g instanceof pe||g instanceof te)throw g;if(g.name==="ParseException")return W(`bash: ${t}: ${g.message}
|
|
1448
|
-
`);throw g}}var Ms=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,coverage:t.coverage}}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 a=this.ctx.state.env.get(i);a!==void 0&&(s[i]=a)}return s}async executeScript(t){let n="",r="",s=0;for(let i of t.statements)try{let a=await this.executeStatement(i);n+=a.stdout,r+=a.stderr,s=a.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}catch(a){if(a instanceof pe)throw a.prependOutput(n,r),a;if(a instanceof Bt)return n+=a.stdout,r+=a.stderr,s=a.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:
|
|
1449
|
-
`);let s=0,i=-1,a=!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 p=await this.executePipeline(u);n+=p.stdout,r+=p.stderr,s=p.exitCode,i=c,a=u.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}let o=i<t.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=o||a||l,this.ctx.state.options.errexit&&s!==0&&i===t.pipelines.length-1&&!a&&!this.ctx.state.inCondition&&!l)throw new
|
|
1448
|
+
`);throw g}}var Ms=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,coverage:t.coverage}}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 a=this.ctx.state.env.get(i);a!==void 0&&(s[i]=a)}return s}async executeScript(t){let n="",r="",s=0;for(let i of t.statements)try{let a=await this.executeStatement(i);n+=a.stdout,r+=a.stderr,s=a.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}catch(a){if(a instanceof pe)throw a.prependOutput(n,r),a;if(a instanceof Bt)return n+=a.stdout,r+=a.stderr,s=a.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:xt(this.ctx.state.env)};if(a instanceof te)throw a;if(a instanceof vt)return n+=a.stdout,r+=a.stderr,s=a.exitCode,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:xt(this.ctx.state.env)};if(a instanceof yt)return n+=a.stdout,r+=a.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:xt(this.ctx.state.env)};if(a instanceof wt)return n+=a.stdout,r+=a.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s)),{stdout:n,stderr:r,exitCode:s,env:xt(this.ctx.state.env)};if(a instanceof Re){n+=a.stdout,r+=a.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(a instanceof yr){n+=a.stdout,r+=a.stderr,s=1,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s));continue}if(a instanceof pt||a instanceof ht){if(this.ctx.state.loopDepth>0)throw a.prependOutput(n,r),a;n+=a.stdout,r+=a.stderr;continue}throw a instanceof ct&&a.prependOutput(n,r),a}return{stdout:n,stderr:r,exitCode:s,env:xt(this.ctx.state.env)}}async executeUserScript(t,n,r=""){return $6(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&&On(`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}
|
|
1449
|
+
`);let s=0,i=-1,a=!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 p=await this.executePipeline(u);n+=p.stdout,r+=p.stderr,s=p.exitCode,i=c,a=u.negated,this.ctx.state.lastExitCode=s,this.ctx.state.env.set("?",String(s))}let o=i<t.pipelines.length-1,l=this.ctx.state.errexitSafe;if(this.ctx.state.errexitSafe=o||a||l,this.ctx.state.options.errexit&&s!==0&&i===t.pipelines.length-1&&!a&&!this.ctx.state.inCondition&&!l)throw new vt(s,n,r);return B(n,r,s)}async executePipeline(t){return C6(this.ctx,t,(n,r)=>this.executeCommand(n,r))}async executeCommand(t,n){switch(this.ctx.coverage?.hit(`bash:cmd:${t.type}`),t.type){case"SimpleCommand":return this.executeSimpleCommand(t,n);case"If":return h6(this.ctx,t);case"For":return d6(this.ctx,t);case"CStyleFor":return m6(this.ctx,t);case"While":return g6(this.ctx,t,n);case"Until":return y6(this.ctx,t);case"Case":return w6(this.ctx,t);case"Subshell":return this.executeSubshell(t,n);case"Group":return this.executeGroup(t,n);case"FunctionDef":return _g(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 fn)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 $=this.expandAlias(x);if($===x)break;x=$,S--}this.aliasExpansionStack.clear(),x!==t&&(t=x)}this.ctx.state.expansionStderr="";let r=await N6(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 Sn(this.ctx,t.redirections);if(S)return S;let $=B("",i,0);return ze(this.ctx,$,t.redirections)}this.ctx.state.lastArg="";let x=(this.ctx.state.expansionStderr||"")+i;return this.ctx.state.expansionStderr="",B("",x,this.ctx.state.lastExitCode)}let a=t.name&&uu(t.name,["local","declare","typeset","export","readonly"]),o=Array.from(s.keys());if(o.length>0&&!a){this.ctx.state.tempExportedVars=this.ctx.state.tempExportedVars||new Set;for(let x of o)this.ctx.state.tempExportedVars.add(x)}let l=await Ca(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,$=await ie(this.ctx,S.content);S.stripTabs&&($=$.split(`
|
|
1450
1450
|
`).map(F=>F.replace(/^\t+/,"")).join(`
|
|
1451
1451
|
`));let O=x.fd??0;O!==0?(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),this.ctx.state.fileDescriptors.set(O,$)):n=$;continue}if(x.operator==="<<<"&&x.target.type==="Word"){n=`${await ie(this.ctx,x.target)}
|
|
1452
1452
|
`;continue}if(x.operator==="<"&&x.target.type==="Word")try{let S=await ie(this.ctx,x.target),$=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);n=await this.ctx.fs.readFile($)}catch{let S=await ie(this.ctx,x.target);for(let[$,O]of s)O===void 0?this.ctx.state.env.delete($):this.ctx.state.env.set($,O);return W(`bash: ${S}: No such file or directory
|
|
@@ -1454,40 +1454,40 @@ sys 0m0.000s
|
|
|
1454
1454
|
`,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 ie(this.ctx,x.target),$=x.fd??(x.operator==="<"||x.operator==="<>"?0:1);switch(this.ctx.state.fileDescriptors||(this.ctx.state.fileDescriptors=new Map),x.operator){case">":case">|":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);await this.ctx.fs.writeFile(O,"","utf8"),this.ctx.state.fileDescriptors.set($,`__file__:${O}`);break}case">>":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);this.ctx.state.fileDescriptors.set($,`__file_append__:${O}`);break}case"<":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);try{let F=await this.ctx.fs.readFile(O);this.ctx.state.fileDescriptors.set($,F)}catch{return W(`bash: ${S}: No such file or directory
|
|
1455
1455
|
`)}break}case"<>":{let O=this.ctx.fs.resolvePath(this.ctx.state.cwd,S);try{let F=await this.ctx.fs.readFile(O);this.ctx.state.fileDescriptors.set($,`__rw__:${O.length}:${O}:0:${F}`)}catch{await this.ctx.fs.writeFile(O,"","utf8"),this.ctx.state.fileDescriptors.set($,`__rw__:${O.length}:${O}:0:`)}break}case">&":{if(S==="-")this.ctx.state.fileDescriptors.delete($);else if(S.endsWith("-")){let O=S.slice(0,-1),F=Number.parseInt(O,10);if(!Number.isNaN(F)){let R=this.ctx.state.fileDescriptors.get(F);R!==void 0?this.ctx.state.fileDescriptors.set($,R):this.ctx.state.fileDescriptors.set($,`__dupout__:${F}`),this.ctx.state.fileDescriptors.delete(F)}}else{let O=Number.parseInt(S,10);Number.isNaN(O)||this.ctx.state.fileDescriptors.set($,`__dupout__:${O}`)}break}case"<&":{if(S==="-")this.ctx.state.fileDescriptors.delete($);else if(S.endsWith("-")){let O=S.slice(0,-1),F=Number.parseInt(O,10);if(!Number.isNaN(F)){let R=this.ctx.state.fileDescriptors.get(F);R!==void 0?this.ctx.state.fileDescriptors.set($,R):this.ctx.state.fileDescriptors.set($,`__dupin__:${F}`),this.ctx.state.fileDescriptors.delete(F)}}else{let O=Number.parseInt(S,10);Number.isNaN(O)||this.ctx.state.fileDescriptors.set($,`__dupin__:${O}`)}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 A6(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,p,n,!1,!1,c)}catch(x){if(x instanceof pt||x instanceof ht)g=x,d=de;else throw x}let w=i+m;if(w&&(d={...d,stderr:w+d.stderr}),d=await ze(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 y=Pg(u)&&u!=="unset"&&u!=="eval";if(!this.ctx.state.options.posix||!y)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,a=!1,o=-1){let l={ctx:this.ctx,runCommand:(u,f,p,h,m,d,g)=>this.runCommand(u,f,p,h,m,d,g),buildExportedEnv:()=>this.buildExportedEnv(),executeUserScript:(u,f,p)=>this.executeUserScript(u,f,p)},c=await f6(l,t,n,r,s,i,a,o);return c!==null?c:p6(l,t,n,s,a)}aliasExpansionStack=new Set;expandAlias(t){return Xl(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return Ra(this.ctx,t)}async executeSubshell(t,n=""){return v6(this.ctx,t,n,r=>this.executeStatement(r))}async executeGroup(t,n=""){return I6(this.ctx,t,n,r=>this.executeStatement(r))}async executeArithmeticCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await Sn(this.ctx,t.redirections);if(n)return n;try{let r=await ne(this.ctx,t.expression.expression),s=Je(r!==0);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),ze(this.ctx,s,t.redirections)}catch(r){let s=W(`bash: arithmetic expression: ${r.message}
|
|
1456
1456
|
`);return ze(this.ctx,s,t.redirections)}}async executeConditionalCommand(t){t.line!==void 0&&(this.ctx.state.currentLine=t.line);let n=await Sn(this.ctx,t.redirections);if(n)return n;try{let r=await Hn(this.ctx,t.expression),s=Je(r);return this.ctx.state.expansionStderr&&(s={...s,stderr:this.ctx.state.expansionStderr+s.stderr},this.ctx.state.expansionStderr=""),ze(this.ctx,s,t.redirections)}catch(r){let s=r instanceof Re?1:2,i=W(`bash: conditional expression: ${r.message}
|
|
1457
|
-
`,s);return ze(this.ctx,i,t.redirections)}}};var Ft={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 O6(e){return e?{maxCallDepth:e.maxCallDepth??Ft.maxCallDepth,maxCommandCount:e.maxCommandCount??Ft.maxCommandCount,maxLoopIterations:e.maxLoopIterations??Ft.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??Ft.maxAwkIterations,maxSedIterations:e.maxSedIterations??Ft.maxSedIterations,maxJqIterations:e.maxJqIterations??Ft.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??Ft.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??Ft.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??Ft.maxGlobOperations,maxStringLength:e.maxStringLength??Ft.maxStringLength,maxArrayElements:e.maxArrayElements??Ft.maxArrayElements,maxHeredocSize:e.maxHeredocSize??Ft.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??Ft.maxSubstitutionDepth}:{...Ft}}function R6(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function
|
|
1457
|
+
`,s);return ze(this.ctx,i,t.redirections)}}};var Ft={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 O6(e){return e?{maxCallDepth:e.maxCallDepth??Ft.maxCallDepth,maxCommandCount:e.maxCommandCount??Ft.maxCommandCount,maxLoopIterations:e.maxLoopIterations??Ft.maxLoopIterations,maxAwkIterations:e.maxAwkIterations??Ft.maxAwkIterations,maxSedIterations:e.maxSedIterations??Ft.maxSedIterations,maxJqIterations:e.maxJqIterations??Ft.maxJqIterations,maxSqliteTimeoutMs:e.maxSqliteTimeoutMs??Ft.maxSqliteTimeoutMs,maxPythonTimeoutMs:e.maxPythonTimeoutMs??Ft.maxPythonTimeoutMs,maxGlobOperations:e.maxGlobOperations??Ft.maxGlobOperations,maxStringLength:e.maxStringLength??Ft.maxStringLength,maxArrayElements:e.maxArrayElements??Ft.maxArrayElements,maxHeredocSize:e.maxHeredocSize??Ft.maxHeredocSize,maxSubstitutionDepth:e.maxSubstitutionDepth??Ft.maxSubstitutionDepth}:{...Ft}}function R6(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function oA(e){let t=R6(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function lA(e,t){let n=R6(e);if(!n)return!1;let r=oA(t);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function fu(e,t){return!t||t.length===0?!1:t.some(n=>lA(e,n))}var Jr=class extends Error{constructor(t){super(`Network access denied: URL not in allow-list: ${t}`),this.name="NetworkAccessDeniedError"}},es=class extends Error{constructor(t){super(`Too many redirects (max: ${t})`),this.name="TooManyRedirectsError"}},ts=class extends Error{constructor(t){super(`Redirect target not in allow-list: ${t}`),this.name="RedirectNotAllowedError"}},Pa=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}},Us=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var cA=20,uA=3e4,fA=10485760,pA=["GET","HEAD"],hA=new Set(["GET","HEAD","OPTIONS"]),dA=new Set([301,302,303,307,308]);function pu(e){let t=e.maxRedirects??cA,n=e.timeoutMs??uA,r=e.maxResponseSize??fA,s=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??pA;function i(l){if(!e.dangerouslyAllowFullInternetAccess&&!fu(l,e.allowedUrlPrefixes??[]))throw new Jr(l)}function a(l){if(e.dangerouslyAllowFullInternetAccess)return;let c=l.toUpperCase();if(!s.includes(c))throw new Pa(c,s)}async function o(l,c={}){let u=c.method?.toUpperCase()??"GET";i(l),a(u);let f=l,p=0,h=c.followRedirects??!0,m=c.timeoutMs!==void 0?Math.min(c.timeoutMs,n):n;for(;;){let d=new AbortController,g=setTimeout(()=>d.abort(),m);try{let w={method:u,headers:c.headers,signal:d.signal,redirect:"manual"};c.body&&!hA.has(u)&&(w.body=c.body);let y=await fetch(f,w);if(dA.has(y.status)&&h){let b=y.headers.get("location");if(!b)return await T6(y,f,r);let x=new URL(b,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!fu(x,e.allowedUrlPrefixes??[]))throw new ts(x);if(p++,p>t)throw new es(t);f=x;continue}return await T6(y,f,r)}finally{clearTimeout(g)}}}return o}async function T6(e,t,n){let r=Object.create(null);if(e.headers.forEach((i,a)=>{r[a.toLowerCase()]=i}),n>0){let i=e.headers.get("content-length");if(i){let a=parseInt(i,10);if(!Number.isNaN(a)&&a>n)throw new Us(n)}}let s;if(n>0&&e.body){let i=e.body.getReader(),a=new TextDecoder,o=[],l=0;for(;;){let{done:c,value:u}=await i.read();if(c)break;if(l+=u.byteLength,l>n)throw i.cancel(),new Us(n);o.push(a.decode(u,{stream:!0}))}o.push(a.decode()),s=o.join("")}else s=await e.text();return{status:e.status,statusText:e.statusText,headers:r,body:s,url:t}}Fn();Xe();function P6(){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"},{prop:"SharedArrayBuffer",target:globalThis,violationType:"shared_array_buffer",strategy:"throw",reason:"SharedArrayBuffer could enable side-channel communication or timing attacks"},{prop:"Atomics",target:globalThis,violationType:"atomics",strategy:"throw",reason:"Atomics could enable side-channel communication or timing attacks"}];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 Ws=!0;function D6(){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 du=null;if(!Ws)try{let{createRequire:e}=await import("node:module");du=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 mA=`
|
|
1458
1458
|
|
|
1459
|
-
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,
|
|
1460
|
-
`)}function L6(e){let t=[];for(let r=0;r<e.pipelines.length;r++)t.push(
|
|
1461
|
-
${s}${n.delimiter}`}return e.operator==="<<<"?`${t}<<< ${
|
|
1462
|
-
`)}function
|
|
1459
|
+
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,mt=class extends Error{violation;constructor(t,n){super(t+mA),this.violation=n,this.name="SecurityViolationError"}},Mt=!Ws&&du?new du:null,gA=1e3,hu={enabled:!0,auditMode:!1};function yA(e){return e===void 0?{...hu,enabled:!1}:typeof e=="boolean"?{...hu,enabled:e}:{...hu,...e}}var Da=class e{static instance=null;config;refCount=0;originalDescriptors=[];violations=[];activationTime=0;totalActiveTimeMs=0;constructor(t){this.config=t}static getInstance(t){return e.instance||(e.instance=new e(yA(t))),e.instance}static resetInstance(){e.instance&&(e.instance.forceDeactivate(),e.instance=null)}static isInSandboxedContext(){return Mt?Mt?.getStore()?.sandboxActive===!0:!1}static getCurrentExecutionId(){if(Mt)return Mt?.getStore()?.executionId}updateConfig(t){this.config={...this.config,...t}}activate(){if(Ws||!this.config.enabled){let n=D6();return{run:r=>r(),deactivate:()=>{},executionId:n}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=D6();return{run:n=>Mt.run({sandboxActive:!0,executionId:t},n),deactivate:()=>{this.refCount--,this.refCount===0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount<0&&(this.refCount=0)},executionId:t}}forceDeactivate(){this.refCount>0&&(this.restorePatches(),this.totalActiveTimeMs+=Date.now()-this.activationTime),this.refCount=0}isActive(){return this.refCount>0}getStats(){return{violationsBlocked:this.violations.length,violations:[...this.violations],activeTimeMs:this.totalActiveTimeMs+(this.refCount>0?Date.now()-this.activationTime:0),refCount:this.refCount}}clearViolations(){this.violations=[]}getPathForTarget(t,n){return t===globalThis?`globalThis.${n}`:t===process?`process.${n}`:t===Error?`Error.${n}`:t===Function.prototype?`Function.prototype.${n}`:t===Object.prototype?`Object.prototype.${n}`:`<object>.${n}`}shouldBlock(){return Ws||this.config.auditMode||!Mt?!1:Mt?.getStore()?.sandboxActive===!0}recordViolation(t,n,r){let s={timestamp:Date.now(),type:t,message:r,path:n,stack:new Error().stack,executionId:Mt?.getStore()?.executionId};if(this.violations.length<gA&&this.violations.push(s),this.config.onViolation)try{this.config.onViolation(s)}catch(i){console.debug("[DefenseInDepthBox] onViolation callback threw:",i instanceof Error?i.message:i)}return s}createBlockingProxy(t,n,r){let s=this;return new Proxy(t,{apply(i,a,o){if(s.shouldBlock()){let l=`${n} is blocked during script execution`,c=s.recordViolation(r,n,l);throw new mt(l,c)}return s.config.auditMode&&Mt?.getStore()?.sandboxActive===!0&&s.recordViolation(r,n,`${n} called (audit mode)`),Reflect.apply(i,a,o)},construct(i,a,o){if(s.shouldBlock()){let l=`${n} constructor is blocked during script execution`,c=s.recordViolation(r,n,l);throw new mt(l,c)}return s.config.auditMode&&Mt?.getStore()?.sandboxActive===!0&&s.recordViolation(r,n,`${n} constructor called (audit mode)`),Reflect.construct(i,a,o)}})}createBlockingObjectProxy(t,n,r){let s=this;return new Proxy(t,{get(i,a,o){if(s.shouldBlock()){let l=`${n}.${String(a)}`,c=`${l} is blocked during script execution`,u=s.recordViolation(r,l,c);throw new mt(c,u)}if(s.config.auditMode&&Mt?.getStore()?.sandboxActive===!0){let l=`${n}.${String(a)}`;s.recordViolation(r,l,`${l} accessed (audit mode)`)}return Reflect.get(i,a,o)},set(i,a,o,l){if(s.shouldBlock()){let c=`${n}.${String(a)}`,u=`${c} modification is blocked during script execution`,f=s.recordViolation(r,c,u);throw new mt(u,f)}return Reflect.set(i,a,o,l)},ownKeys(i){if(s.shouldBlock()){let a=`${n} enumeration is blocked during script execution`,o=s.recordViolation(r,n,a);throw new mt(a,o)}return Reflect.ownKeys(i)},getOwnPropertyDescriptor(i,a){if(s.shouldBlock()){let o=`${n}.${String(a)}`,l=`${o} descriptor access is blocked during script execution`,c=s.recordViolation(r,o,l);throw new mt(l,c)}return Reflect.getOwnPropertyDescriptor(i,a)},has(i,a){if(s.shouldBlock()){let o=`${n}.${String(a)}`,l=`${o} existence check is blocked during script execution`,c=s.recordViolation(r,o,l);throw new mt(l,c)}return Reflect.has(i,a)}})}applyPatches(){let t=P6();for(let n of t)this.applyPatch(n);this.protectConstructorChain(),this.protectErrorPrepareStackTrace(),this.protectModuleLoad(),this.protectProcessMainModule()}protectConstructorChain(){this.patchPrototypeConstructor(Function.prototype,"Function.prototype.constructor","function_constructor");try{let t=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"AsyncFunction.prototype.constructor","async_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch AsyncFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(function*(){}).constructor;t&&t!==Function&&this.patchPrototypeConstructor(t.prototype,"GeneratorFunction.prototype.constructor","generator_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch GeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}try{let t=Object.getPrototypeOf(async function*(){}).constructor,n=Object.getPrototypeOf(async()=>{}).constructor;t&&t!==Function&&t!==n&&this.patchPrototypeConstructor(t.prototype,"AsyncGeneratorFunction.prototype.constructor","async_generator_function_constructor")}catch(t){console.debug("[DefenseInDepthBox] Could not patch AsyncGeneratorFunction.prototype.constructor:",t instanceof Error?t.message:t)}}protectErrorPrepareStackTrace(){let t=this;try{let n=Object.getOwnPropertyDescriptor(Error,"prepareStackTrace");this.originalDescriptors.push({target:Error,prop:"prepareStackTrace",descriptor:n});let r=n?.value;Object.defineProperty(Error,"prepareStackTrace",{get(){return r},set(s){if(t.shouldBlock()){let i="Error.prepareStackTrace modification is blocked during script execution",a=t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace",i);throw new mt(i,a)}t.config.auditMode&&Mt?.getStore()?.sandboxActive===!0&&t.recordViolation("error_prepare_stack_trace","Error.prepareStackTrace","Error.prepareStackTrace set (audit mode)"),r=s},configurable:!0})}catch(n){console.debug("[DefenseInDepthBox] Could not protect Error.prepareStackTrace:",n instanceof Error?n.message:n)}}patchPrototypeConstructor(t,n,r){let s=this;try{let i=Object.getOwnPropertyDescriptor(t,"constructor");this.originalDescriptors.push({target:t,prop:"constructor",descriptor:i});let a=i?.value;Object.defineProperty(t,"constructor",{get(){if(s.shouldBlock()){let o=`${n} access is blocked during script execution`,l=s.recordViolation(r,n,o);throw new mt(o,l)}return s.config.auditMode&&Mt?.getStore()?.sandboxActive===!0&&s.recordViolation(r,n,`${n} accessed (audit mode)`),a},set(o){if(s.shouldBlock()){let l=`${n} modification is blocked during script execution`,c=s.recordViolation(r,n,l);throw new mt(l,c)}Object.defineProperty(this,"constructor",{value:o,writable:!0,configurable:!0})},configurable:!0})}catch(i){console.debug(`[DefenseInDepthBox] Could not patch ${n}:`,i instanceof Error?i.message:i)}}protectProcessMainModule(){if(typeof process>"u")return;let t=this;try{let n=Object.getOwnPropertyDescriptor(process,"mainModule");this.originalDescriptors.push({target:process,prop:"mainModule",descriptor:n});let r=n?.value;r!==void 0&&Object.defineProperty(process,"mainModule",{get(){if(t.shouldBlock()){let s="process.mainModule access is blocked during script execution",i=t.recordViolation("process_main_module","process.mainModule",s);throw new mt(s,i)}return t.config.auditMode&&Mt?.getStore()?.sandboxActive===!0&&t.recordViolation("process_main_module","process.mainModule","process.mainModule accessed (audit mode)"),r},set(s){if(t.shouldBlock()){let i="process.mainModule modification is blocked during script execution",a=t.recordViolation("process_main_module","process.mainModule",i);throw new mt(i,a)}Object.defineProperty(process,"mainModule",{value:s,writable:!0,configurable:!0})},configurable:!0})}catch(n){console.debug("[DefenseInDepthBox] Could not protect process.mainModule:",n instanceof Error?n.message:n)}}protectModuleLoad(){if(!Ws)try{let t=null;if(typeof process<"u"){let a=process.mainModule;a&&typeof a=="object"&&(t=a.constructor)}if(!t&&typeof zs<"u"&&typeof zs.main<"u"&&(t=zs.main.constructor),!t||typeof t._load!="function")return;let n=t._load,r=Object.getOwnPropertyDescriptor(t,"_load");this.originalDescriptors.push({target:t,prop:"_load",descriptor:r});let i=this.createBlockingProxy(n,"Module._load","module_load");Object.defineProperty(t,"_load",{value:i,writable:!0,configurable:!0})}catch(t){console.debug("[DefenseInDepthBox] Could not protect Module._load:",t instanceof Error?t.message:t)}}applyPatch(t){let{target:n,prop:r,violationType:s,strategy:i}=t;try{let a=n[r];if(a===void 0)return;let o=Object.getOwnPropertyDescriptor(n,r);if(this.originalDescriptors.push({target:n,prop:r,descriptor:o}),i==="freeze")typeof a=="object"&&a!==null&&Object.freeze(a);else{let l=this.getPathForTarget(n,r),c=typeof a=="function"?this.createBlockingProxy(a,l,s):this.createBlockingObjectProxy(a,l,s);Object.defineProperty(n,r,{value:c,writable:!0,configurable:!0})}}catch(a){let o=this.getPathForTarget(n,r);console.debug(`[DefenseInDepthBox] Could not patch ${o}:`,a instanceof Error?a.message:a)}}restorePatches(){for(let t=this.originalDescriptors.length-1;t>=0;t--){let{target:n,prop:r,descriptor:s}=this.originalDescriptors[t];try{s?Object.defineProperty(n,r,s):delete n[r]}catch(i){let a=this.getPathForTarget(n,r);console.debug(`[DefenseInDepthBox] Could not restore ${a}:`,i instanceof Error?i.message:i)}}this.originalDescriptors=[]}};function _6(e){return hr(e)}function hr(e){return e.statements.map(L6).join(`
|
|
1460
|
+
`)}function L6(e){let t=[];for(let r=0;r<e.pipelines.length;r++)t.push(wA(e.pipelines[r])),r<e.operators.length&&t.push(e.operators[r]);let n=t.join(" ");return e.background&&(n+=" &"),n}function wA(e){let t=[];e.timed&&t.push(e.timePosix?"time -p":"time"),e.negated&&t.push("!");let n=[];for(let s=0;s<e.commands.length;s++)if(n.push(F6(e.commands[s])),s<e.commands.length-1){let i=e.pipeStderr?.[s];n.push(i?"|&":"|")}return(t.length>0?`${t.join(" ")} `:"")+n.join(" ")}function F6(e){switch(e.type){case"SimpleCommand":return bA(e);case"If":return IA(e);case"For":return $A(e);case"CStyleFor":return OA(e);case"While":return RA(e);case"Until":return TA(e);case"Case":return PA(e);case"Subshell":return _A(e);case"Group":return LA(e);case"ArithmeticCommand":return FA(e);case"ConditionalCommand":return MA(e);case"FunctionDef":return UA(e);default:{let t=e;throw new Error(`Unsupported command type: ${t.type}`)}}}function bA(e){let t=[];for(let n of e.assignments)t.push(xA(n));e.name&&t.push(Nt(e.name));for(let n of e.args)t.push(Nt(n));for(let n of e.redirections)t.push(W6(n));return t.join(" ")}function xA(e){let t=e.append?"+=":"=";if(e.array){let n=e.array.map(Nt).join(" ");return`${e.name}${t}(${n})`}return e.value?`${e.name}${t}${Nt(e.value)}`:`${e.name}${t}`}function Nt(e){return e.parts.map(t=>_a(t,!1)).join("")}function Gn(e){return e.parts.map(t=>_a(t,!0)).join("")}function _a(e,t){switch(e.type){case"Literal":return t?AA(e.value):EA(e.value);case"SingleQuoted":return`'${e.value}'`;case"DoubleQuoted":return`"${e.parts.map(n=>_a(n,!0)).join("")}"`;case"Escaped":return`\\${e.value}`;case"ParameterExpansion":return M6(e);case"CommandSubstitution":return e.legacy?`\`${hr(e.body)}\``:`$(${hr(e.body)})`;case"ArithmeticExpansion":return`$((${Le(e.expression.expression)}))`;case"ProcessSubstitution":return e.direction==="input"?`<(${hr(e.body)})`:`>(${hr(e.body)})`;case"BraceExpansion":return kA(e);case"TildeExpansion":return e.user!==null?`~${e.user}`:"~";case"Glob":return e.pattern;default:{let n=e;throw new Error(`Unsupported word part type: ${n.type}`)}}}function EA(e){return e.replace(/[\s\\'"`!|&;()<>{}[\]*?~#]/g,"\\$&")}function AA(e){return e.replace(/[$`"\\]/g,"\\$&")}function SA(e,t){return e.parts.map(n=>CA(n,t)).join("")}function CA(e,t){switch(e.type){case"Literal":return t?e.value:e.value.replace(/[$`]/g,"\\$&");case"Escaped":return`\\${e.value}`;case"ParameterExpansion":return M6(e);case"CommandSubstitution":return e.legacy?`\`${hr(e.body)}\``:`$(${hr(e.body)})`;case"ArithmeticExpansion":return`$((${Le(e.expression.expression)}))`;default:return _a(e,!1)}}function M6(e){return e.operation?`\${${U6(e.parameter,e.operation)}}`:NA(e.parameter)?`\${${e.parameter}}`:`$${e.parameter}`}function NA(e){return!(/^[?#@*$!\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function U6(e,t){switch(t.type){case"Length":return`#${e}`;case"LengthSliceError":return`#${e}:`;case"BadSubstitution":return t.text;case"DefaultValue":return`${e}${t.checkEmpty?":":""}-${Gn(t.word)}`;case"AssignDefault":return`${e}${t.checkEmpty?":":""}=${Gn(t.word)}`;case"ErrorIfUnset":return`${e}${t.checkEmpty?":":""}?${t.word?Gn(t.word):""}`;case"UseAlternative":return`${e}${t.checkEmpty?":":""}+${Gn(t.word)}`;case"Substring":{let n=Le(t.offset.expression);return t.length?`${e}:${n}:${Le(t.length.expression)}`:`${e}:${n}`}case"PatternRemoval":{let n=t.side==="prefix"?"#":"%",r=t.greedy?`${n}${n}`:n;return`${e}${r}${Gn(t.pattern)}`}case"PatternReplacement":{let n="/";t.all?n="//":t.anchor==="start"?n="/#":t.anchor==="end"&&(n="/%");let r=t.replacement?`/${Gn(t.replacement)}`:"";return`${e}${n}${Gn(t.pattern)}${r}`}case"CaseModification":{let n=t.direction==="upper"?"^":",",r=t.all?`${n}${n}`:n,s=t.pattern?Gn(t.pattern):"";return`${e}${r}${s}`}case"Transform":return`${e}@${t.operator}`;case"Indirection":return t.innerOp?`!${U6(e,t.innerOp)}`:`!${e}`;case"ArrayKeys":return`!${t.array}[${t.star?"*":"@"}]`;case"VarNamePrefix":return`!${t.prefix}${t.star?"*":"@"}`;default:{let n=t;throw new Error(`Unsupported parameter operation type: ${n.type}`)}}}function kA(e){return`{${e.items.map(vA).join(",")}}`}function vA(e){if(e.type==="Word")return Nt(e.word);let t=e.startStr??String(e.start),n=e.endStr??String(e.end);return e.step!==void 0?`${t}..${n}..${e.step}`:`${t}..${n}`}function W6(e){let t=e.fdVariable?`{${e.fdVariable}}`:e.fd!==null?String(e.fd):"";if(e.operator==="<<"||e.operator==="<<-"){let n=e.target,r=n.quoted?`'${n.delimiter}'`:n.delimiter,s=SA(n.content,n.quoted);return`${t}${e.operator}${r}
|
|
1461
|
+
${s}${n.delimiter}`}return e.operator==="<<<"?`${t}<<< ${Nt(e.target)}`:e.operator==="&>"||e.operator==="&>>"?`${e.operator} ${Nt(e.target)}`:`${t}${e.operator} ${Nt(e.target)}`}function un(e){return e.length===0?"":` ${e.map(W6).join(" ")}`}function Yt(e){return e.map(L6).join(`
|
|
1462
|
+
`)}function IA(e){let t=[];for(let n=0;n<e.clauses.length;n++){let r=e.clauses[n],s=n===0?"if":"elif";t.push(`${s} ${Yt(r.condition)}; then
|
|
1463
1463
|
${Yt(r.body)}`)}return e.elseBody&&t.push(`else
|
|
1464
1464
|
${Yt(e.elseBody)}`),`${t.join(`
|
|
1465
1465
|
`)}
|
|
1466
|
-
fi${un(e.redirections)}`}function
|
|
1466
|
+
fi${un(e.redirections)}`}function $A(e){let t;if(e.words===null)t=`for ${e.variable}`;else{let n=e.words.map(Nt).join(" ");t=`for ${e.variable} in ${n}`}return`${t}; do
|
|
1467
1467
|
${Yt(e.body)}
|
|
1468
|
-
done${un(e.redirections)}`}function
|
|
1468
|
+
done${un(e.redirections)}`}function OA(e){let t=e.init?Le(e.init.expression):"",n=e.condition?Le(e.condition.expression):"",r=e.update?Le(e.update.expression):"";return`for ((${t}; ${n}; ${r})); do
|
|
1469
1469
|
${Yt(e.body)}
|
|
1470
|
-
done${un(e.redirections)}`}function
|
|
1470
|
+
done${un(e.redirections)}`}function RA(e){return`while ${Yt(e.condition)}; do
|
|
1471
1471
|
${Yt(e.body)}
|
|
1472
|
-
done${un(e.redirections)}`}function
|
|
1472
|
+
done${un(e.redirections)}`}function TA(e){return`until ${Yt(e.condition)}; do
|
|
1473
1473
|
${Yt(e.body)}
|
|
1474
|
-
done${un(e.redirections)}`}function
|
|
1475
|
-
`);return`case ${
|
|
1474
|
+
done${un(e.redirections)}`}function PA(e){let t=e.items.map(DA).join(`
|
|
1475
|
+
`);return`case ${Nt(e.word)} in
|
|
1476
1476
|
${t}
|
|
1477
|
-
esac${un(e.redirections)}`}function
|
|
1477
|
+
esac${un(e.redirections)}`}function DA(e){let t=e.patterns.map(Nt).join(" | "),n=Yt(e.body);return n?`${t})
|
|
1478
1478
|
${n}
|
|
1479
1479
|
${e.terminator}`:`${t})
|
|
1480
|
-
${e.terminator}`}function
|
|
1480
|
+
${e.terminator}`}function _A(e){return`(${Yt(e.body)})${un(e.redirections)}`}function LA(e){return`{ ${Yt(e.body)}; }${un(e.redirections)}`}function FA(e){return`((${Le(e.expression.expression)}))${un(e.redirections)}`}function MA(e){return`[[ ${pr(e.expression)} ]]${un(e.redirections)}`}function UA(e){let t=F6(e.body);return`${e.name}() ${t}${un(e.redirections)}`}function Le(e){switch(e.type){case"ArithNumber":return String(e.value);case"ArithVariable":return e.hasDollarPrefix?`$${e.name}`:e.name;case"ArithSpecialVar":return`$${e.name}`;case"ArithBinary":return`${Le(e.left)} ${e.operator} ${Le(e.right)}`;case"ArithUnary":return e.prefix?`${e.operator}${Le(e.operand)}`:`${Le(e.operand)}${e.operator}`;case"ArithTernary":return`${Le(e.condition)} ? ${Le(e.consequent)} : ${Le(e.alternate)}`;case"ArithAssignment":return`${e.subscript?`${e.variable}[${Le(e.subscript)}]`:e.stringKey!==void 0?`${e.variable}[${e.stringKey}]`:e.variable} ${e.operator} ${Le(e.value)}`;case"ArithDynamicAssignment":return`${e.subscript?`${Le(e.target)}[${Le(e.subscript)}]`:Le(e.target)} ${e.operator} ${Le(e.value)}`;case"ArithDynamicElement":return`${Le(e.nameExpr)}[${Le(e.subscript)}]`;case"ArithGroup":return`(${Le(e.expression)})`;case"ArithNested":return`$((${Le(e.expression)}))`;case"ArithCommandSubst":return`$(${e.command})`;case"ArithBracedExpansion":return`\${${e.content}}`;case"ArithArrayElement":return e.stringKey!==void 0?`${e.array}[${e.stringKey}]`:e.index?`${e.array}[${Le(e.index)}]`:e.array;case"ArithDynamicBase":return`\${${e.baseExpr}}#${e.value}`;case"ArithDynamicNumber":return`\${${e.prefix}}${e.suffix}`;case"ArithConcat":return e.parts.map(Le).join("");case"ArithDoubleSubscript":return`${e.array}[${Le(e.index)}]`;case"ArithNumberSubscript":return`${e.number}[${e.errorToken}]`;case"ArithSyntaxError":return e.errorToken;case"ArithSingleQuote":return`'${e.content}'`;default:{let t=e;throw new Error(`Unsupported arithmetic expression type: ${t.type}`)}}}function pr(e){switch(e.type){case"CondBinary":return`${Nt(e.left)} ${e.operator} ${Nt(e.right)}`;case"CondUnary":return`${e.operator} ${Nt(e.operand)}`;case"CondNot":return`! ${pr(e.operand)}`;case"CondAnd":return`${pr(e.left)} && ${pr(e.right)}`;case"CondOr":return`${pr(e.left)} || ${pr(e.right)}`;case"CondGroup":return`( ${pr(e.expression)} )`;case"CondWord":return Nt(e.word);default:{let t=e;throw new Error(`Unsupported conditional expression type: ${t.type}`)}}}var mu=class{fs;commands=new Map;useDefaultLayout=!1;limits;secureFetch;sleepFn;traceFn;logger;defenseInDepthConfig;coverageWriter;transformPlugins=[];state;constructor(t={}){let n=t.fs??new sr(t.files);this.fs=n,this.useDefaultLayout=!t.cwd&&!t.files;let r=t.cwd||(this.useDefaultLayout?"/home/user":"/"),s=new Map([["HOME",this.useDefaultLayout?"/home/user":"/"],["PATH","/usr/bin:/bin"],["IFS",`
|
|
1481
1481
|
`],["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=O6({...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=pu(t.network)),this.sleepFn=t.sleep,this.traceFn=t.trace,this.logger=t.logger,this.defenseInDepthConfig=t.defenseInDepth,this.coverageWriter=t.coverage,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,virtualPid:t.processInfo?.pid??1,virtualPpid:t.processInfo?.ppid??0,virtualUid:t.processInfo?.uid??1e3,virtualGid:t.processInfo?.gid??1e3,bashPid:t.processInfo?.pid??1,nextVirtualPid:(t.processInfo?.pid??1)+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",vl(this.state.options)),this.state.env.set("BASHOPTS",Il(this.state.shoptOptions)),q0(n,this.useDefaultLayout,{pid:this.state.virtualPid,ppid:this.state.virtualPpid,uid:this.state.virtualUid,gid:this.state.virtualGid}),r!=="/"&&n instanceof sr)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let i of U0(t.commands))this.registerCommand(i);if(t.network)for(let i of W0())this.registerCommand(i);if(t.python)for(let i of B0())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)z0(i)?this.registerCommand(H0(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
|
|
1482
1482
|
# Built-in command: ${t.name}
|
|
1483
1483
|
`;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.
|
|
1484
|
-
`,exitCode:1,env:nn(this.state.env,n?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:nn(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 a=new Map(this.state.env);if(n?.env)for(let[f,p]of Object.entries(n.env))a.set(f,p);s!==void 0&&a.set("PWD",s);let o={...this.state,env:a,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:n?.stdin},l=t;n?.rawScript||(l=B6(t));let u=(this.defenseInDepthConfig?Da.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let p=rn(l),h;if(this.transformPlugins.length>0){let y=Object.create(null);for(let b of this.transformPlugins){let x=b.transform({ast:p,metadata:y});p=x.ast,x.metadata&&(y={...y,...x.metadata})}h=y}let m={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},w=await new Ms(m,o).executeScript(p);return h&&(w.metadata=h),this.logResult(w)};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:nn(this.state.env,n?.env)});if(f instanceof Bt)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:nn(this.state.env,n?.env)});if(f instanceof Re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:nn(this.state.env,n?.env)});if(f instanceof te)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:te.EXIT_CODE,env:nn(this.state.env,n?.env)});if(f instanceof
|
|
1484
|
+
`,exitCode:1,env:nn(this.state.env,n?.env)};if(!t.trim())return{stdout:"",stderr:"",exitCode:0,env:nn(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 a=new Map(this.state.env);if(n?.env)for(let[f,p]of Object.entries(n.env))a.set(f,p);s!==void 0&&a.set("PWD",s);let o={...this.state,env:a,cwd:i,functions:new Map(this.state.functions),localScopes:[...this.state.localScopes],options:{...this.state.options},hashTable:this.state.hashTable,groupStdin:n?.stdin},l=t;n?.rawScript||(l=B6(t));let u=(this.defenseInDepthConfig?Da.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let p=rn(l),h;if(this.transformPlugins.length>0){let y=Object.create(null);for(let b of this.transformPlugins){let x=b.transform({ast:p,metadata:y});p=x.ast,x.metadata&&(y={...y,...x.metadata})}h=y}let m={fs:this.fs,commands:this.commands,limits:this.limits,exec:this.exec.bind(this),fetch:this.secureFetch,sleep:this.sleepFn,trace:this.traceFn,coverage:this.coverageWriter},w=await new Ms(m,o).executeScript(p);return h&&(w.metadata=h),this.logResult(w)};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:nn(this.state.env,n?.env)});if(f instanceof Bt)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:f.exitCode,env:nn(this.state.env,n?.env)});if(f instanceof Re)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:1,env:nn(this.state.env,n?.env)});if(f instanceof te)return this.logResult({stdout:f.stdout,stderr:f.stderr,exitCode:te.EXIT_CODE,env:nn(this.state.env,n?.env)});if(f instanceof mt)return this.logResult({stdout:"",stderr:`bash: security violation: ${f.message}
|
|
1485
1485
|
`,exitCode:1,env:nn(this.state.env,n?.env)});if(f.name==="ParseException")return this.logResult({stdout:"",stderr:`bash: syntax error: ${f.message}
|
|
1486
1486
|
`,exitCode:2,env:nn(this.state.env,n?.env)});if(f instanceof Ln)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
1487
1487
|
`,exitCode:2,env:nn(this.state.env,n?.env)});if(f instanceof RangeError)return this.logResult({stdout:"",stderr:`bash: ${f.message}
|
|
1488
|
-
`,exitCode:1,env:nn(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
|
|
1488
|
+
`,exitCode:1,env:nn(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 xt(this.state.env)}registerTransformPlugin(t){this.transformPlugins.push(t)}transform(t){let n=B6(t),r=rn(n),s=Object.create(null);for(let i of this.transformPlugins){let a=i.transform({ast:r,metadata:s});r=a.ast,a.metadata&&(s={...s,...a.metadata})}return{script:_6(r),ast:r,metadata:s}}};function B6(e){let t=e.split(`
|
|
1489
1489
|
`),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 a=i.trimStart();n.push(a);let o=/<<(-?)\s*(['"]?)([\w-]+)\2/g;for(let l of a.matchAll(o)){let c=l[1]==="-",u=l[3];r.push({delimiter:u,stripTabs:c})}}return n.join(`
|
|
1490
|
-
`)}export{mu as Bash,sr as InMemoryFs,Jr as NetworkAccessDeniedError,ts as RedirectNotAllowedError,es as TooManyRedirectsError,
|
|
1490
|
+
`)}export{mu as Bash,sr as InMemoryFs,Jr as NetworkAccessDeniedError,ts as RedirectNotAllowedError,es as TooManyRedirectsError,Eb as defineCommand,bb as getCommandNames,xb as getNetworkCommandNames};
|
|
1491
1491
|
/*! Bundled license information:
|
|
1492
1492
|
|
|
1493
1493
|
re2js/build/index.esm.js:
|