just-bash 2.10.1 → 2.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/just-bash.js +173 -173
- package/dist/bin/shell/shell.js +82 -82
- package/dist/bundle/browser.js +135 -135
- package/dist/bundle/index.js +124 -124
- package/package.json +1 -1
package/dist/bundle/browser.js
CHANGED
|
@@ -36,7 +36,7 @@ Notes:
|
|
|
36
36
|
`}},te=class extends yt{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
37
|
`}},pn=class extends yt{name="SubshellExitError";constructor(t="",n=""){super("subshell exit",t,n)}};Bt=class extends yt{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 Au(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 qs(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 Ua=I(()=>{"use strict"});function Nu(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=i7(r,a,n);o!==null?(s+=o,i+=2):(s+=e[i],i++)}else s+=e[i],i++;return s}function s7(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 i7(e,t,n){let r=s7(e,n),s=(l,c=2)=>String(l).padStart(c,"0"),i=ku(r.year,r.month,r.day),a=Su(r.year,r.month,r.day,r.weekday,0),o=Su(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(Cu(r.year,r.month,r.day)%100);case"G":return String(Cu(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
|
-
`;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(l7(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 a7(e,n);case"Z":return o7(e,n);case"%":return"%";default:return null}}function a7(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 o7(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 ku(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 Su(e,t,n,r,s){let i=ku(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 l7(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 Cu(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 vu=I(()=>{"use strict"});var $u={};K($u,{flagsForFuzzing:()=>E7,printfCommand:()=>f7});import{sprintf as wr}from"sprintf-js";function c7(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 p7(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=Nu(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:
|
|
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(l7(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 a7(e,n);case"Z":return o7(e,n);case"%":return"%";default:return null}}function a7(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 o7(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 ku(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 Su(e,t,n,r,s){let i=ku(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 l7(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 Cu(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 vu=I(()=>{"use strict"});var $u={};K($u,{flagsForFuzzing:()=>E7,printfCommand:()=>f7});import{sprintf as wr}from"sprintf-js";function c7(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 p7(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=Nu(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}=h7(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 h7(e,t,n){let r=!1,s="";switch(t){case"d":case"i":{let i=Zs(n);return r=Jt,r&&(s=`printf: ${n}: invalid number
|
|
40
40
|
`),{value:Iu(e,i),parseError:r,parseErrMsg:s}}case"o":{let i=Zs(n);return r=Jt,r&&(s=`printf: ${n}: invalid number
|
|
41
41
|
`),{value:d7(e,i),parseError:r,parseErrMsg:s}}case"u":{let i=Zs(n);r=Jt,r&&(s=`printf: ${n}: invalid number
|
|
42
42
|
`);let a=i<0?i>>>0:i;return{value:Iu(e.replace("u","d"),a),parseError:r,parseErrMsg:s}}case"x":case"X":{let i=Zs(n);return r=Jt,r&&(s=`printf: ${n}: invalid number
|
|
@@ -47,30 +47,30 @@ Notes:
|
|
|
47
47
|
`,exitCode:2};let n=null,r=0;for(;r<e.length;){let a=e[r];if(a==="--"){r++;break}if(a==="-v"){if(r+1>=e.length)return{stdout:"",stderr:`printf: -v: option requires an argument
|
|
48
48
|
`,exitCode:1};if(n=e[r+1],!/^[a-zA-Z_][a-zA-Z0-9_]*(\[[^\]]+\])?$/.test(n))return{stdout:"",stderr:`printf: \`${n}': not a valid identifier
|
|
49
49
|
`,exitCode:2};r+=2}else{if(a.startsWith("-")&&a!=="-")break;break}}if(r>=e.length)return{stdout:"",stderr:`printf: usage: printf format [arguments]
|
|
50
|
-
`,exitCode:1};let s=e[r],i=e.slice(r+1);try{let a=qs(s),o="",l=0,c=!1,u="",f=t.env.get("TZ"),p=t.limits?.maxStringLength;do{let{result:h,argsConsumed:m,error:d,errMsg:g,stopped:
|
|
50
|
+
`,exitCode:1};let s=e[r],i=e.slice(r+1);try{let a=qs(s),o="",l=0,c=!1,u="",f=t.env.get("TZ"),p=t.limits?.maxStringLength;do{let{result:h,argsConsumed:m,error:d,errMsg:g,stopped:w}=p7(a,i,l,f);if(o+=h,p!==void 0&&p>0&&o.length>p)throw new te(`printf: output size limit exceeded (${p} bytes)`,"string_length");if(l+=m,d&&(c=!0,g&&(u=g)),w)break}while(l<i.length&&l>0);if(l===0&&i.length>0,n){let h=n.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(['"]?)(.+?)\2\]$/);if(h){let m=h[1],d=h[3];d=d.replace(/\$([a-zA-Z_][a-zA-Z0-9_]*)/g,(g,w)=>t.env.get(w)??""),t.env.set(`${m}_${d}`,o)}else t.env.set(n,o);return{stdout:"",stderr:u,exitCode:c?1:0}}return{stdout:o,stderr:u,exitCode:c?1:0}}catch(a){if(a instanceof te)throw a;return{stdout:"",stderr:`printf: ${Ue(a)}
|
|
51
51
|
`,exitCode:1}}}};Jt=!1;E7={name:"printf",flags:[{flag:"-v",type:"value",valueHint:"string"}],stdinType:"none",needsArgs:!0}});var Pu={};K(Pu,{flagsForFuzzing:()=>k7,lsCommand:()=>C7});import{minimatch as Ru}from"minimatch";function Ks(e){if(e<1024)return String(e);if(e<1024*1024){let n=e/1024;return n<10?`${n.toFixed(1)}K`:`${Math.round(n)}K`}if(e<1024*1024*1024){let n=e/1048576;return n<10?`${n.toFixed(1)}M`:`${Math.round(n)}M`}let t=e/(1024*1024*1024);return t<10?`${t.toFixed(1)}G`:`${Math.round(t)}G`}function Qs(e){let n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],r=String(e.getDate()).padStart(2," "),s=new Date,i=new Date(s.getTime()-4320*60*60*1e3);if(e>i){let o=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0");return`${n} ${r} ${o}:${l}`}let a=e.getFullYear();return`${n} ${r} ${a}`}async function N7(e,t,n,r,s,i=!1,a=!1,o=!1){let l=n||r,c=t.fs.getAllPaths(),u=t.fs.resolvePath(t.cwd,"."),f=[];for(let p of c){let h=p.startsWith(u)&&p.slice(u.length+1)||p;if(Ru(h,e)||Ru(p,e)){let m=h.split("/").pop()||h;if(!l&&m.startsWith("."))continue;f.push(h||p)}}if(f.length===0)return{stdout:"",stderr:`ls: ${e}: No such file or directory
|
|
52
|
-
`,exitCode:2};if(o){let p=[];for(let h of f){let m=t.fs.resolvePath(t.cwd,h);try{let d=await t.fs.stat(m);p.push({path:h,size:d.size??0})}catch{p.push({path:h,size:0})}}p.sort((h,m)=>m.size-h.size),f.length=0,f.push(...p.map(h=>h.path))}else f.sort();if(i&&f.reverse(),s){let p=[];for(let h of f){let m=t.fs.resolvePath(t.cwd,h);try{let d=await t.fs.stat(m),g=d.isDirectory?"drwxr-xr-x":"-rw-r--r--",
|
|
52
|
+
`,exitCode:2};if(o){let p=[];for(let h of f){let m=t.fs.resolvePath(t.cwd,h);try{let d=await t.fs.stat(m);p.push({path:h,size:d.size??0})}catch{p.push({path:h,size:0})}}p.sort((h,m)=>m.size-h.size),f.length=0,f.push(...p.map(h=>h.path))}else f.sort();if(i&&f.reverse(),s){let p=[];for(let h of f){let m=t.fs.resolvePath(t.cwd,h);try{let d=await t.fs.stat(m),g=d.isDirectory?"drwxr-xr-x":"-rw-r--r--",w=d.isDirectory?"/":"",y=d.size??0,b=a?Ks(y).padStart(5):String(y).padStart(5),x=d.mtime??new Date(0),S=Qs(x);p.push(`${g} 1 user user ${b} ${S} ${h}${w}`)}catch{p.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${h}`)}}return{stdout:`${p.join(`
|
|
53
53
|
`)}
|
|
54
54
|
`,stderr:"",exitCode:0}}return{stdout:`${f.join(`
|
|
55
55
|
`)}
|
|
56
|
-
`,stderr:"",exitCode:0}}async function Tu(e,t,n,r,s,i,a,o=!1,l=!1,c=!1,u=!1){let f=n||r,p=t.fs.resolvePath(t.cwd,e);try{let h=await t.fs.stat(p);if(!h.isDirectory){if(s){let g=h.size??0,
|
|
56
|
+
`,stderr:"",exitCode:0}}async function Tu(e,t,n,r,s,i,a,o=!1,l=!1,c=!1,u=!1){let f=n||r,p=t.fs.resolvePath(t.cwd,e);try{let h=await t.fs.stat(p);if(!h.isDirectory){if(s){let g=h.size??0,w=l?Ks(g).padStart(5):String(g).padStart(5),y=h.mtime??new Date(0),b=Qs(y);return{stdout:`-rw-r--r-- 1 user user ${w} ${b} ${e}
|
|
57
57
|
`,stderr:"",exitCode:0}}return{stdout:`${e}
|
|
58
|
-
`,stderr:"",exitCode:0}}let m=await t.fs.readdir(p);if(f||(m=m.filter(g=>!g.startsWith("."))),c){let g=[];for(let
|
|
58
|
+
`,stderr:"",exitCode:0}}let m=await t.fs.readdir(p);if(f||(m=m.filter(g=>!g.startsWith("."))),c){let g=[];for(let w of m){let y=p==="/"?`/${w}`:`${p}/${w}`;try{let b=await t.fs.stat(y);g.push({name:w,size:b.size??0})}catch{g.push({name:w,size:0})}}g.sort((w,y)=>y.size-w.size),m=g.map(w=>w.name)}else m.sort();n&&(m=[".","..",...m]),o&&m.reverse();let d="";if((i||a)&&(d+=`${e}:
|
|
59
59
|
`),s){d+=`total ${m.length}
|
|
60
|
-
`;let g=m.filter(x=>x==="."||x===".."),
|
|
61
|
-
`;let
|
|
60
|
+
`;let g=m.filter(x=>x==="."||x===".."),w=m.filter(x=>x!=="."&&x!=="..");for(let x of g)d+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${x}
|
|
61
|
+
`;let y=[];for(let x=0;x<w.length;x+=100){let S=w.slice(x,x+100),$=await Promise.all(S.map(async O=>{let F=p==="/"?`/${O}`:`${p}/${O}`;try{let R=await t.fs.stat(F),z=R.isDirectory?"drwxr-xr-x":"-rw-r--r--",k=R.isDirectory?"/":"",N=R.size??0,P=l?Ks(N).padStart(5):String(N).padStart(5),v=R.mtime??new Date(0),T=Qs(v);return{name:O,line:`${z} 1 user user ${P} ${T} ${O}${k}
|
|
62
62
|
`}}catch{return{name:O,line:`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${O}
|
|
63
|
-
`}}}));
|
|
63
|
+
`}}}));y.push(...$)}let b=new Map(w.map((x,S)=>[x,S]));y.sort((x,S)=>(b.get(x.name)??0)-(b.get(S.name)??0));for(let{line:x}of y)d+=x}else d+=m.join(`
|
|
64
64
|
`)+(m.length?`
|
|
65
|
-
`:"");if(i){let g=m.filter(b=>b!=="."&&b!==".."),
|
|
65
|
+
`:"");if(i){let g=m.filter(b=>b!=="."&&b!==".."),w=[];if(t.fs.readdirWithFileTypes)w=(await t.fs.readdirWithFileTypes(p)).filter(x=>x.isDirectory&&g.includes(x.name)).map(x=>({name:x.name,isDirectory:!0}));else for(let b=0;b<g.length;b+=100){let x=g.slice(b,b+100),S=await Promise.all(x.map(async $=>{let O=p==="/"?`/${$}`:`${p}/${$}`;try{let F=await t.fs.stat(O);return{name:$,isDirectory:F.isDirectory}}catch{return{name:$,isDirectory:!1}}}));w.push(...S.filter($=>$.isDirectory))}w.sort((b,x)=>b.name.localeCompare(x.name)),o&&w.reverse();let y=[];for(let b=0;b<w.length;b+=100){let x=w.slice(b,b+100),S=await Promise.all(x.map(async $=>{let O=e==="."?`./${$.name}`:`${e}/${$.name}`,F=await Tu(O,t,n,r,s,i,!1,o,l,c,!0);return{name:$.name,result:F}}));y.push(...S)}y.sort((b,x)=>b.name.localeCompare(x.name)),o&&y.reverse();for(let{result:b}of y)d+=`
|
|
66
66
|
`,d+=b.stdout}return{stdout:d,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`ls: ${e}: No such file or directory
|
|
67
|
-
`,exitCode:2}}}var A7,S7,C7,k7,Du=I(()=>{"use strict";Ze();mr();se();A7={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},S7={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},C7={name:"ls",async execute(e,t){if(U(e))return M(A7);let n=be("ls",e,S7);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.showAlmostAll,i=n.result.flags.longFormat,a=n.result.flags.humanReadable,o=n.result.flags.recursive,l=n.result.flags.reverse,c=n.result.flags.sortBySize,u=n.result.flags.directoryOnly,f=n.result.flags.sortByTime;n.result.flags.onePerLine;let p=n.result.positional;p.length===0&&p.push(".");let h="",m="",d=0;for(let g=0;g<p.length;g++){let
|
|
67
|
+
`,exitCode:2}}}var A7,S7,C7,k7,Du=I(()=>{"use strict";Ze();mr();se();A7={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},S7={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},C7={name:"ls",async execute(e,t){if(U(e))return M(A7);let n=be("ls",e,S7);if(!n.ok)return n.error;let r=n.result.flags.showAll,s=n.result.flags.showAlmostAll,i=n.result.flags.longFormat,a=n.result.flags.humanReadable,o=n.result.flags.recursive,l=n.result.flags.reverse,c=n.result.flags.sortBySize,u=n.result.flags.directoryOnly,f=n.result.flags.sortByTime;n.result.flags.onePerLine;let p=n.result.positional;p.length===0&&p.push(".");let h="",m="",d=0;for(let g=0;g<p.length;g++){let w=p[g];if(g>0&&h&&!h.endsWith(`
|
|
68
68
|
|
|
69
69
|
`)&&(h+=`
|
|
70
|
-
`),u){let
|
|
71
|
-
`}else h+=`${
|
|
72
|
-
`}catch{m+=`ls: cannot access '${
|
|
73
|
-
`,d=2}continue}if(
|
|
70
|
+
`),u){let y=t.fs.resolvePath(t.cwd,w);try{let b=await t.fs.stat(y);if(i){let x=b.isDirectory?"drwxr-xr-x":"-rw-r--r--",S=b.isDirectory?"/":"",$=b.size??0,O=a?Ks($).padStart(5):String($).padStart(5),F=b.mtime??new Date(0),R=Qs(F);h+=`${x} 1 user user ${O} ${R} ${w}${S}
|
|
71
|
+
`}else h+=`${w}
|
|
72
|
+
`}catch{m+=`ls: cannot access '${w}': No such file or directory
|
|
73
|
+
`,d=2}continue}if(w.includes("*")||w.includes("?")||w.includes("[")){let y=await N7(w,t,r,s,i,l,a,c);h+=y.stdout,m+=y.stderr,y.exitCode!==0&&(d=y.exitCode)}else{let y=await Tu(w,t,r,s,i,o,p.length>1,l,a,c);h+=y.stdout,m+=y.stderr,y.exitCode!==0&&(d=y.exitCode)}}return{stdout:h,stderr:m,exitCode:d}}};k7={name:"ls",flags:[{flag:"-a",type:"boolean"},{flag:"-A",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-S",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-1",type:"boolean"}],needsFiles:!0}});var _u={};K(_u,{flagsForFuzzing:()=>$7,mkdirCommand:()=>I7});var v7,I7,$7,Lu=I(()=>{"use strict";zt();Ze();v7={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},I7={name:"mkdir",async execute(e,t){let n=be("mkdir",e,v7);if(!n.ok)return n.error;let r=n.result.flags.recursive,s=n.result.flags.verbose,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`mkdir: missing operand
|
|
74
74
|
`,exitCode:1};let a="",o="",l=0;for(let c of i)try{let u=t.fs.resolvePath(t.cwd,c);await t.fs.mkdir(u,{recursive:r}),s&&(a+=`mkdir: created directory '${c}'
|
|
75
75
|
`)}catch(u){let f=Ue(u);f.includes("ENOENT")||f.includes("no such file")?o+=`mkdir: cannot create directory '${c}': No such file or directory
|
|
76
76
|
`:f.includes("EEXIST")||f.includes("already exists")?o+=`mkdir: cannot create directory '${c}': File exists
|
|
@@ -100,13 +100,13 @@ Options:
|
|
|
100
100
|
`:l+=`rm: cannot remove '${u}': ${p}
|
|
101
101
|
`,c=1}}return{stdout:o,stderr:l,exitCode:c}}},W7={name:"rm",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0}});var Vu={};K(Vu,{cpCommand:()=>H7,flagsForFuzzing:()=>j7});var B7,z7,H7,j7,Gu=I(()=>{"use strict";zt();Ze();se();B7={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},z7={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},H7={name:"cp",async execute(e,t){if(U(e))return M(B7);let n=be("cp",e,z7);if(!n.ok)return n.error;let r=n.result.flags.recursive||n.result.flags.recursiveUpper,s=n.result.flags.noClobber,i=n.result.flags.preserve,a=n.result.flags.verbose,o=n.result.positional;if(o.length<2)return{stdout:"",stderr:`cp: missing destination file operand
|
|
102
102
|
`,exitCode:1};let l=o.pop()??"",c=o,u=t.fs.resolvePath(t.cwd,l),f="",p="",h=0,m=!1;try{m=(await t.fs.stat(u)).isDirectory}catch{}if(c.length>1&&!m)return{stdout:"",stderr:`cp: target '${l}' is not a directory
|
|
103
|
-
`,exitCode:1};for(let d of c)try{let g=t.fs.resolvePath(t.cwd,d),
|
|
104
|
-
`,h=1;continue}if(s)try{await t.fs.stat(
|
|
105
|
-
`)}catch(g){let
|
|
106
|
-
`:p+=`cp: cannot copy '${d}': ${
|
|
103
|
+
`,exitCode:1};for(let d of c)try{let g=t.fs.resolvePath(t.cwd,d),w=await t.fs.stat(g),y=u;if(m){let b=d.split("/").pop()||d;y=u==="/"?`/${b}`:`${u}/${b}`}if(w.isDirectory&&!r){p+=`cp: -r not specified; omitting directory '${d}'
|
|
104
|
+
`,h=1;continue}if(s)try{await t.fs.stat(y);continue}catch{}await t.fs.cp(g,y,{recursive:r}),a&&(f+=`'${d}' -> '${y}'
|
|
105
|
+
`)}catch(g){let w=Ue(g);w.includes("ENOENT")||w.includes("no such file")?p+=`cp: cannot stat '${d}': No such file or directory
|
|
106
|
+
`:p+=`cp: cannot copy '${d}': ${w}
|
|
107
107
|
`,h=1}return{stdout:f,stderr:p,exitCode:h}}},j7={name:"cp",flags:[{flag:"-r",type:"boolean"},{flag:"-R",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-p",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2}});var qu={};K(qu,{flagsForFuzzing:()=>Z7,mvCommand:()=>q7});var V7,G7,q7,Z7,Zu=I(()=>{"use strict";zt();Ze();se();V7={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},G7={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},q7={name:"mv",async execute(e,t){if(U(e))return M(V7);let n=be("mv",e,G7);if(!n.ok)return n.error;let r=n.result.flags.force,s=n.result.flags.noClobber,i=n.result.flags.verbose,a=n.result.positional;if(s&&(r=!1),a.length<2)return{stdout:"",stderr:`mv: missing destination file operand
|
|
108
108
|
`,exitCode:1};let o=a.pop()??"",l=a,c=t.fs.resolvePath(t.cwd,o),u="",f="",p=0,h=!1;try{h=(await t.fs.stat(c)).isDirectory}catch{}if(l.length>1&&!h)return{stdout:"",stderr:`mv: target '${o}' is not a directory
|
|
109
|
-
`,exitCode:1};for(let m of l)try{let d=t.fs.resolvePath(t.cwd,m),g=c;if(h){let
|
|
109
|
+
`,exitCode:1};for(let m of l)try{let d=t.fs.resolvePath(t.cwd,m),g=c;if(h){let w=m.split("/").pop()||m;g=c==="/"?`/${w}`:`${c}/${w}`}if(s)try{await t.fs.stat(g);continue}catch{}if(await t.fs.mv(d,g),i){let w=h?`${o}/${m.split("/").pop()||m}`:o;u+=`renamed '${m}' -> '${w}'
|
|
110
110
|
`}}catch(d){let g=Ue(d);g.includes("ENOENT")||g.includes("no such file")?f+=`mv: cannot stat '${m}': No such file or directory
|
|
111
111
|
`:f+=`mv: cannot move '${m}': ${g}
|
|
112
112
|
`,p=1}return{stdout:u,stderr:f,exitCode:p}}},Z7={name:"mv",flags:[{flag:"-f",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-v",type:"boolean"}],needsArgs:!0,minArgs:2}});var Ku={};K(Ku,{flagsForFuzzing:()=>X7,lnCommand:()=>Q7});var K7,Q7,X7,Qu=I(()=>{"use strict";se();K7={name:"ln",summary:"make links between files",usage:"ln [OPTIONS] TARGET LINK_NAME",options:["-s create a symbolic link instead of a hard link","-f remove existing destination files","-n treat LINK_NAME as a normal file if it is a symbolic link to a directory","-v print name of each linked file"," --help display this help and exit"]},Q7={name:"ln",async execute(e,t){if(U(e))return M(K7);let n=!1,r=!1,s=!1,i=0;for(;i<e.length&&e[i].startsWith("-");){let f=e[i];if(f==="-s"||f==="--symbolic")n=!0,i++;else if(f==="-f"||f==="--force")r=!0,i++;else if(f==="-v"||f==="--verbose")s=!0,i++;else if(f==="-n"||f==="--no-dereference")i++;else if(/^-[sfvn]+$/.test(f))f.includes("s")&&(n=!0),f.includes("f")&&(r=!0),f.includes("v")&&(s=!0),i++;else if(f==="--"){i++;break}else return{stdout:"",stderr:`ln: invalid option -- '${f.slice(1)}'
|
|
@@ -145,8 +145,8 @@ Options:
|
|
|
145
145
|
`&&(a++,a===t)){i++;break}i--}i<0&&(i=0);let o=e.slice(i);return e[s-1]===`
|
|
146
146
|
`?o:`${o}
|
|
147
147
|
`}var Ba=I(()=>{"use strict";se()});var of={};K(of,{flagsForFuzzing:()=>ly,headCommand:()=>oy});var ay,oy,ly,lf=I(()=>{"use strict";se();Ba();ay={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},oy={name:"head",async execute(e,t){if(U(e))return M(ay);let n=Xs(e,"head");if(!n.ok)return n.error;let{lines:r,bytes:s}=n.options;return Ys(t,n.options,"head",i=>sf(i,r,s))}},ly={name:"head",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}});var cf={};K(cf,{flagsForFuzzing:()=>fy,tailCommand:()=>uy});var cy,uy,fy,uf=I(()=>{"use strict";Ba();se();cy={name:"tail",summary:"output the last part of files",usage:"tail [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the last NUM bytes","-n, --lines=NUM print the last NUM lines (default 10)","-n +NUM print starting from line NUM","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},uy={name:"tail",async execute(e,t){if(U(e))return M(cy);let n=Xs(e,"tail");if(!n.ok)return n.error;let{lines:r,bytes:s,fromLine:i}=n.options;return Ys(t,n.options,"tail",a=>af(a,r,s,i??!1))}},fy={name:"tail",flags:[{flag:"-n",type:"value",valueHint:"number"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-q",type:"boolean"},{flag:"-v",type:"boolean"}],stdinType:"text",needsFiles:!0}});var pf={};K(pf,{flagsForFuzzing:()=>my,wcCommand:()=>dy});function ff(e){let t=e.length,n=0,r=0,s=!1;for(let i=0;i<t;i++){let a=e[i];a===`
|
|
148
|
-
`?(n++,s&&(r++,s=!1)):a===" "||a===" "||a==="\r"?s&&(r++,s=!1):s=!0}return s&&r++,{lines:n,words:r,chars:t}}function za(e,t,n,r,s,i){let a=[];t&&a.push(String(e.lines).padStart(i)),n&&a.push(String(e.words).padStart(i)),r&&a.push(String(e.chars).padStart(i));let o=a.join(" ");return s&&(o+=` ${s}`),o}var py,hy,dy,my,hf=I(()=>{"use strict";Ze();Zn();se();py={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},hy={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},dy={name:"wc",async execute(e,t){if(U(e))return M(py);let n=be("wc",e,hy);if(!n.ok)return n.error;let{lines:r,words:s}=n.result.flags,i=n.result.flags.bytes||n.result.flags.chars,a=n.result.positional;!r&&!s&&!i&&(r=s=i=!0);let o=await qn(t,a,{cmdName:"wc",stopOnError:!1});if(a.length===0){let
|
|
149
|
-
`,stderr:"",exitCode:0}}let l=[],c=0,u=0,f=0;for(let{filename:
|
|
148
|
+
`?(n++,s&&(r++,s=!1)):a===" "||a===" "||a==="\r"?s&&(r++,s=!1):s=!0}return s&&r++,{lines:n,words:r,chars:t}}function za(e,t,n,r,s,i){let a=[];t&&a.push(String(e.lines).padStart(i)),n&&a.push(String(e.words).padStart(i)),r&&a.push(String(e.chars).padStart(i));let o=a.join(" ");return s&&(o+=` ${s}`),o}var py,hy,dy,my,hf=I(()=>{"use strict";Ze();Zn();se();py={name:"wc",summary:"print newline, word, and byte counts for each file",usage:"wc [OPTION]... [FILE]...",options:["-c, --bytes print the byte counts","-m, --chars print the character counts","-l, --lines print the newline counts","-w, --words print the word counts"," --help display this help and exit"]},hy={lines:{short:"l",long:"lines",type:"boolean"},words:{short:"w",long:"words",type:"boolean"},bytes:{short:"c",long:"bytes",type:"boolean"},chars:{short:"m",long:"chars",type:"boolean"}},dy={name:"wc",async execute(e,t){if(U(e))return M(py);let n=be("wc",e,hy);if(!n.ok)return n.error;let{lines:r,words:s}=n.result.flags,i=n.result.flags.bytes||n.result.flags.chars,a=n.result.positional;!r&&!s&&!i&&(r=s=i=!0);let o=await qn(t,a,{cmdName:"wc",stopOnError:!1});if(a.length===0){let w=ff(o.files[0].content);return{stdout:`${za(w,r,s,i,"",0)}
|
|
149
|
+
`,stderr:"",exitCode:0}}let l=[],c=0,u=0,f=0;for(let{filename:w,content:y}of o.files){let b=ff(y);c+=b.lines,u+=b.words,f+=b.chars,l.push({filename:w,stats:b})}let p=a.length>1?c:Math.max(...l.map(w=>w.stats.lines)),h=a.length>1?u:Math.max(...l.map(w=>w.stats.words)),m=a.length>1?f:Math.max(...l.map(w=>w.stats.chars)),d=a.length>1?3:0;r&&(d=Math.max(d,String(p).length)),s&&(d=Math.max(d,String(h).length)),i&&(d=Math.max(d,String(m).length));let g="";for(let{filename:w,stats:y}of l)g+=`${za(y,r,s,i,w,d)}
|
|
150
150
|
`;return a.length>1&&(g+=`${za({lines:c,words:u,chars:f},r,s,i,"total",d)}
|
|
151
151
|
`),{stdout:g,stderr:o.stderr,exitCode:o.exitCode}}};my={name:"wc",flags:[{flag:"-l",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-m",type:"boolean"}],stdinType:"text",needsFiles:!0}});var mf={};K(mf,{flagsForFuzzing:()=>by,statCommand:()=>wy});function df(e,t){let n=t?"d":"-",r=[e&256?"r":"-",e&128?"w":"-",e&64?"x":"-",e&32?"r":"-",e&16?"w":"-",e&8?"x":"-",e&4?"r":"-",e&2?"w":"-",e&1?"x":"-"];return n+r.join("")}var gy,yy,wy,by,gf=I(()=>{"use strict";Ze();se();gy={name:"stat",summary:"display file or file system status",usage:"stat [OPTION]... FILE...",options:["-c FORMAT use the specified FORMAT instead of the default"," --help display this help and exit"]},yy={format:{short:"c",type:"string"}},wy={name:"stat",async execute(e,t){if(U(e))return M(gy);let n=be("stat",e,yy);if(!n.ok)return n.error;let r=n.result.flags.format??null,s=n.result.positional;if(s.length===0)return{stdout:"",stderr:`stat: missing operand
|
|
152
152
|
`,exitCode:1};let i="",a="",o=!1;for(let l of s){let c=t.fs.resolvePath(t.cwd,l);try{let u=await t.fs.stat(c);if(r){let f=r,p=u.mode.toString(8),h=df(u.mode,u.isDirectory);f=f.replace(/%n/g,l),f=f.replace(/%N/g,`'${l}'`),f=f.replace(/%s/g,String(u.size)),f=f.replace(/%F/g,u.isDirectory?"directory":"regular file"),f=f.replace(/%a/g,p),f=f.replace(/%A/g,h),f=f.replace(/%u/g,"1000"),f=f.replace(/%U/g,"user"),f=f.replace(/%g/g,"1000"),f=f.replace(/%G/g,"group"),i+=`${f}
|
|
@@ -170,42 +170,42 @@ Options:
|
|
|
170
170
|
`))&&(t.op=_.Op.ANY_CHAR);break;case _.Op.CHAR_CLASS:n.op===_.Op.LITERAL?t.runes=new hn(t.runes).appendLiteral(n.runes[0],n.flags).toArray():t.runes=new hn(t.runes).appendClass(n.runes).toArray();break;case _.Op.LITERAL:if(n.runes[0]===t.runes[0]&&n.flags===t.flags)break;t.op=_.Op.CHAR_CLASS,t.runes=new hn().appendLiteral(t.runes[0],t.flags).appendLiteral(n.runes[0],n.flags).toArray();break}}static parseEscape(t){let n=t.pos();if(t.skip(1),!t.more())throw new De(e.ERR_TRAILING_BACKSLASH);let r=t.pop();e:switch(r){case D.CODES.get("1"):case D.CODES.get("2"):case D.CODES.get("3"):case D.CODES.get("4"):case D.CODES.get("5"):case D.CODES.get("6"):case D.CODES.get("7"):if(!t.more()||t.peek()<D.CODES.get("0")||t.peek()>D.CODES.get("7"))break;case D.CODES.get("0"):{let s=r-D.CODES.get("0");for(let i=1;i<3&&!(!t.more()||t.peek()<D.CODES.get("0")||t.peek()>D.CODES.get("7"));i++)s=s*8+t.peek()-D.CODES.get("0"),t.skip(1);return s}case D.CODES.get("x"):{if(!t.more())break;if(r=t.pop(),r===D.CODES.get("{")){let a=0,o=0;for(;;){if(!t.more())break e;if(r=t.pop(),r===D.CODES.get("}"))break;let l=Ne.unhex(r);if(l<0||(o=o*16+l,o>he.MAX_RUNE))break e;a++}if(a===0)break e;return o}let s=Ne.unhex(r);if(!t.more())break;r=t.pop();let i=Ne.unhex(r);if(s<0||i<0)break;return s*16+i}case D.CODES.get("a"):return D.CODES.get("\x07");case D.CODES.get("f"):return D.CODES.get("\f");case D.CODES.get("n"):return D.CODES.get(`
|
|
171
171
|
`);case D.CODES.get("r"):return D.CODES.get("\r");case D.CODES.get("t"):return D.CODES.get(" ");case D.CODES.get("v"):return D.CODES.get("\v");default:if(r<=he.MAX_ASCII&&!Ne.isalnum(r))return r;break}throw new De(e.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new De(e.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt("\\")?e.parseEscape(t):t.pop()}static concatRunes(t,n){return[...t,...n]}constructor(t,n=0){this.wholeRegexp=t,this.flags=n,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null,this.numRegexp=0,this.numRunes=0,this.repeats=0,this.height=null,this.size=null}newRegexp(t){let n=this.free;return n!==null&&n.subs!==null&&n.subs.length>0?(this.free=n.subs[0],n.reinit(),n.op=t):(n=new _(t),this.numRegexp+=1),n}reuse(t){this.height!==null&&Object.prototype.hasOwnProperty.call(this.height,t)&&delete this.height[t],t.subs!==null&&t.subs.length>0&&(t.subs[0]=this.free),this.free=t}checkLimits(t){if(this.numRunes>e.MAX_RUNES)throw new De(e.ERR_LARGE);this.checkSize(t),this.checkHeight(t)}checkSize(t){if(this.size===null){if(this.repeats===0&&(this.repeats=1),t.op===_.Op.REPEAT){let n=t.max;n===-1&&(n=t.min),n<=0&&(n=1),n>e.MAX_SIZE/this.repeats?this.repeats=e.MAX_SIZE:this.repeats*=n}if(this.numRegexp<e.MAX_SIZE/this.repeats)return;this.size={};for(let n of this.stack)this.checkSize(n)}if(this.calcSize(t,!0)>e.MAX_SIZE)throw new De(e.ERR_LARGE)}calcSize(t,n=!1){if(!n&&Object.prototype.hasOwnProperty.call(this.size,t))return this.size[t];let r=0;switch(t.op){case _.Op.LITERAL:{r=t.runes.length;break}case _.Op.CAPTURE:case _.Op.STAR:{r=2+this.calcSize(t.subs[0]);break}case _.Op.PLUS:case _.Op.QUEST:{r=1+this.calcSize(t.subs[0]);break}case _.Op.CONCAT:{for(let s of t.subs)r=r+this.calcSize(s);break}case _.Op.ALTERNATE:{for(let s of t.subs)r=r+this.calcSize(s);t.subs.length>1&&(r=r+t.subs.length-1);break}case _.Op.REPEAT:{let s=this.calcSize(t.subs[0]);if(t.max===-1){t.min===0?r=2+s:r=1+t.min*s;break}r=t.max*s+(t.max-t.min);break}}return r=Math.max(1,r),this.size[t]=r,r}checkHeight(t){if(!(this.numRegexp<e.MAX_HEIGHT)){if(this.height===null){this.height={};for(let n of this.stack)this.checkHeight(n)}if(this.calcHeight(t,!0)>e.MAX_HEIGHT)throw new De(e.ERR_NESTING_DEPTH)}}calcHeight(t,n=!1){if(!n&&Object.prototype.hasOwnProperty.call(this.height,t))return this.height[t];let r=1;for(let s of t.subs){let i=this.calcHeight(s);r<1+i&&(r=1+i)}return this.height[t]=r,r}pop(){return this.stack.pop()}popToPseudo(){let t=this.stack.length,n=t;for(;n>0&&!_.isPseudoOp(this.stack[n-1].op);)n--;let r=this.stack.slice(n,t);return this.stack=this.stack.slice(0,n),r}push(t){if(this.numRunes+=t.runes.length,t.op===_.Op.CHAR_CLASS&&t.runes.length===2&&t.runes[0]===t.runes[1]){if(this.maybeConcat(t.runes[0],this.flags&-2))return null;t.op=_.Op.LITERAL,t.runes=[t.runes[0]],t.flags=this.flags&-2}else if(t.op===_.Op.CHAR_CLASS&&t.runes.length===4&&t.runes[0]===t.runes[1]&&t.runes[2]===t.runes[3]&&he.simpleFold(t.runes[0])===t.runes[2]&&he.simpleFold(t.runes[2])===t.runes[0]||t.op===_.Op.CHAR_CLASS&&t.runes.length===2&&t.runes[0]+1===t.runes[1]&&he.simpleFold(t.runes[0])===t.runes[1]&&he.simpleFold(t.runes[1])===t.runes[0]){if(this.maybeConcat(t.runes[0],this.flags|Q.FOLD_CASE))return null;t.op=_.Op.LITERAL,t.runes=[t.runes[0]],t.flags=this.flags|Q.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(t),this.checkLimits(t),t}maybeConcat(t,n){let r=this.stack.length;if(r<2)return!1;let s=this.stack[r-1],i=this.stack[r-2];return s.op!==_.Op.LITERAL||i.op!==_.Op.LITERAL||(s.flags&Q.FOLD_CASE)!==(i.flags&Q.FOLD_CASE)?!1:(i.runes=e.concatRunes(i.runes,s.runes),t>=0?(s.runes=[t],s.flags=n,!0):(this.pop(),this.reuse(s),!1))}newLiteral(t,n){let r=this.newRegexp(_.Op.LITERAL);return r.flags=n,(n&Q.FOLD_CASE)!==0&&(t=e.minFoldRune(t)),r.runes=[t],r}literal(t){this.push(this.newLiteral(t,this.flags))}op(t){let n=this.newRegexp(t);return n.flags=this.flags,this.push(n)}repeat(t,n,r,s,i,a){let o=this.flags;if((o&Q.PERL_X)!==0&&(i.more()&&i.lookingAt("?")&&(i.skip(1),o^=Q.NON_GREEDY),a!==-1))throw new De(e.ERR_INVALID_REPEAT_OP,i.from(a));let l=this.stack.length;if(l===0)throw new De(e.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));let c=this.stack[l-1];if(_.isPseudoOp(c.op))throw new De(e.ERR_MISSING_REPEAT_ARGUMENT,i.from(s));let u=this.newRegexp(t);if(u.min=n,u.max=r,u.flags=o,u.subs=[c],this.stack[l-1]=u,this.checkLimits(u),t===_.Op.REPEAT&&(n>=2||r>=2)&&!this.repeatIsValid(u,1e3))throw new De(e.ERR_INVALID_REPEAT_SIZE,i.from(s))}repeatIsValid(t,n){if(t.op===_.Op.REPEAT){let r=t.max;if(r===0)return!0;if(r<0&&(r=t.min),r>n)return!1;r>0&&(n=Math.trunc(n/r))}for(let r of t.subs)if(!this.repeatIsValid(r,n))return!1;return!0}concat(){this.maybeConcat(-1,0);let t=this.popToPseudo();return t.length===0?this.push(this.newRegexp(_.Op.EMPTY_MATCH)):this.push(this.collapse(t,_.Op.CONCAT))}alternate(){let t=this.popToPseudo();return t.length>0&&this.cleanAlt(t[t.length-1]),t.length===0?this.push(this.newRegexp(_.Op.NO_MATCH)):this.push(this.collapse(t,_.Op.ALTERNATE))}cleanAlt(t){t.op===_.Op.CHAR_CLASS&&(t.runes=new hn(t.runes).cleanClass().toArray(),t.runes.length===2&&t.runes[0]===0&&t.runes[1]===he.MAX_RUNE?(t.runes=[],t.op=_.Op.ANY_CHAR):t.runes.length===4&&t.runes[0]===0&&t.runes[1]===D.CODES.get(`
|
|
172
172
|
`)-1&&t.runes[2]===D.CODES.get(`
|
|
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
|
|
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 Ja(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=xf.has(s)?xf.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=_f.has(i)?_f.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)}},to=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}},no=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=eo.parse(t,n),i=s.maxCap();s=Ya.simplify(s);let a=Xa.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 to}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(Ve.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()?Ve.fromUTF16(t.asCharSequence(),0,r):Ve.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(Ve.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=Ve.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(Ve.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:t.slice(n[0],n[1])}findUTF8Index(t){let n=this.doExecute(Ve.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:n.slice(0,2)}find(t){let n=this.doExecute(Ve.fromUTF16(t),0,Q.UNANCHORED,2);return n===null?"":t.substring(n[0],n[1])}findIndex(t){return this.doExecute(Ve.fromUTF16(t),0,Q.UNANCHORED,2)}findUTF8Submatch(t){let n=this.doExecute(Ve.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(Ve.fromUTF8(t),0,Q.UNANCHORED,this.prog.numCap))}findSubmatch(t){let n=this.doExecute(Ve.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(Ve.fromUTF16(t),0,Q.UNANCHORED,this.prog.numCap))}findAllUTF8(t,n){let r=this.allMatches(Ve.fromUTF8(t),n,s=>t.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(t,n){let r=this.allMatches(Ve.fromUTF8(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAll(t,n){let r=this.allMatches(Ve.fromUTF16(t),n,s=>t.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(t,n){let r=this.allMatches(Ve.fromUTF16(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(t,n){let r=this.allMatches(Ve.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(Ve.fromUTF8(t),n);return r.length===0?null:r}findAllSubmatch(t,n){let r=this.allMatches(Ve.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(Ve.fromUTF16(t),n);return r.length===0?null:r}},ro=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 ro.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 Va("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=no.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 xy(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 Ey(e){return Tn.translateRegExp(e)}function G(e,t=""){return new ti(e,t)}var ti,Cn,Mf=I(()=>{"use strict";Ff();ti=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=Ey(t),s=xy(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";Mf()});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=Uf.get(i);return a||(a=Ay(s,r.ignoreCase),Uf.set(i,a)),a.test(e)}function Ay(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+="$",G(n,t?"i":"")}var Uf,so=I(()=>{"use strict";Me();Uf=new Map});function Wf(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:y=!1,multiline:w=!1,kResetGroup:b}=n;if(w)return Sy(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)}},to=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}},no=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=eo.parse(t,n),i=s.maxCap();s=Ya.simplify(s);let a=Xa.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 to}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(Ve.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()?Ve.fromUTF16(t.asCharSequence(),0,r):Ve.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(Ve.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=Ve.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(Ve.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:t.slice(n[0],n[1])}findUTF8Index(t){let n=this.doExecute(Ve.fromUTF8(t),0,Q.UNANCHORED,2);return n===null?null:n.slice(0,2)}find(t){let n=this.doExecute(Ve.fromUTF16(t),0,Q.UNANCHORED,2);return n===null?"":t.substring(n[0],n[1])}findIndex(t){return this.doExecute(Ve.fromUTF16(t),0,Q.UNANCHORED,2)}findUTF8Submatch(t){let n=this.doExecute(Ve.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(Ve.fromUTF8(t),0,Q.UNANCHORED,this.prog.numCap))}findSubmatch(t){let n=this.doExecute(Ve.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(Ve.fromUTF16(t),0,Q.UNANCHORED,this.prog.numCap))}findAllUTF8(t,n){let r=this.allMatches(Ve.fromUTF8(t),n,s=>t.slice(s[0],s[1]));return r.length===0?null:r}findAllUTF8Index(t,n){let r=this.allMatches(Ve.fromUTF8(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAll(t,n){let r=this.allMatches(Ve.fromUTF16(t),n,s=>t.substring(s[0],s[1]));return r.length===0?null:r}findAllIndex(t,n){let r=this.allMatches(Ve.fromUTF16(t),n,s=>s.slice(0,2));return r.length===0?null:r}findAllUTF8Submatch(t,n){let r=this.allMatches(Ve.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(Ve.fromUTF8(t),n);return r.length===0?null:r}findAllSubmatch(t,n){let r=this.allMatches(Ve.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(Ve.fromUTF16(t),n);return r.length===0?null:r}},ro=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 ro.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 Va("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=no.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 xy(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 Ey(e){return Tn.translateRegExp(e)}function G(e,t=""){return new ti(e,t)}var ti,Cn,Mf=I(()=>{"use strict";Ff();ti=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=Ey(t),s=xy(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";Mf()});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=Uf.get(i);return a||(a=Ay(s,r.ignoreCase),Uf.set(i,a)),a.test(e)}function Ay(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+="$",G(n,t?"i":"")}var Uf,so=I(()=>{"use strict";Me();Uf=new Map});function Wf(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 Sy(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
|
-
`,matched:N>0,matchCount:N}}if(c===0&&u===0&&!
|
|
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 J=t.exec(ue);J!==null;J=t.exec(ue)){let H=b!==void 0?J[b]??"":J[0],X=g!==null?Wf(g,J):H,Ee=o?`${o}:`:"";d&&(Ee+=`${T+J.index}:`),s&&(Ee+=`${L+1}:`),h&&(Ee+=`${J.index+1}:`),N.push(Ee+X),J[0].length===0&&t.lastIndex++}}else if(m){t.lastIndex=0;for(let J=t.exec(ue);J!==null;J=t.exec(ue)){let H=o?`${o}:`:"";d&&(H+=`${T+J.index}:`),s&&(H+=`${L+1}:`),h&&(H+=`${J.index+1}:`),N.push(H+ue),J[0].length===0&&t.lastIndex++}}else{t.lastIndex=0;let J=t.exec(ue),H=J?J.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]),Wf(g,j)}));let Ee=o?`${o}:`:"";d&&(Ee+=`${T+(J?J.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
|
`)}
|
|
179
|
-
`:"",matched:P,matchCount:v}}if(
|
|
179
|
+
`:"",matched:P,matchCount:v}}if(w){let N=[],P=!1,v=0;for(let T=0;T<$;T++){let L=x[T];t.lastIndex=0;let re=t.test(L)!==r;re&&(P=!0,v++);let J=re?":":"-",H=o?`${o}${J}`:"";s&&(H+=`${T+1}${J}`),N.push(H+L)}return{output:N.length>0?`${N.join(`
|
|
180
180
|
`)}
|
|
181
181
|
`:"",matched:P,matchCount:v}}let O=[],F=0,R=new Set,z=-1,k=[];for(let N=0;N<$&&!(f>0&&F>=f);N++)t.lastIndex=0,t.test(x[N])!==r&&(k.push(N),F++);for(let N of k){let P=Math.max(0,N-c);z>=0&&P>z+1&&O.push(p);for(let T=P;T<N;T++)if(!R.has(T)){R.add(T),z=T;let L=x[T];s&&(L=`${T+1}-${L}`),o&&(L=`${o}-${L}`),O.push(L)}if(!R.has(N)){R.add(N),z=N;let T=x[N];if(l){t.lastIndex=0;for(let L=t.exec(T);L!==null;L=t.exec(T)){let ue=b!==void 0?L[b]??"":L[0],re=g!==null?g:ue,J=o?`${o}:`:"";s&&(J+=`${N+1}:`),h&&(J+=`${L.index+1}:`),O.push(J+re),L[0].length===0&&t.lastIndex++}}else{let L=T;s&&(L=`${N+1}:${L}`),o&&(L=`${o}:${L}`),O.push(L)}}let v=Math.min($-1,N+u);for(let T=N+1;T<=v;T++)if(!R.has(T)){R.add(T),z=T;let L=x[T];s&&(L=`${T+1}-${L}`),o&&(L=`${o}-${L}`),O.push(L)}}return{output:O.length>0?`${O.join(`
|
|
182
182
|
`)}
|
|
183
|
-
`:"",matched:F>0,matchCount:F}}function Sy(e,t,n){let{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:a,filename:o,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:p,showColumn:h,showByteOffset:m,replace:d,kResetGroup:g}=n,
|
|
184
|
-
`),w
|
|
183
|
+
`:"",matched:F>0,matchCount:F}}function Sy(e,t,n){let{invertMatch:r,showLineNumbers:s,countOnly:i,countMatches:a,filename:o,onlyMatching:l,beforeContext:c,afterContext:u,maxCount:f,contextSeparator:p,showColumn:h,showByteOffset:m,replace:d,kResetGroup:g}=n,w=e.split(`
|
|
184
|
+
`),y=w.length,b=y>0&&w[y-1]===""?y-1:y,x=[0];for(let k=0;k<e.length;k++)e[k]===`
|
|
185
185
|
`&&x.push(k+1);let S=k=>{let N=0;for(let P=0;P<x.length&&!(x[P]>k);P++)N=P;return N},$=k=>{let N=S(k);return k-x[N]+1},O=[];t.lastIndex=0;for(let k=t.exec(e);k!==null&&!(f>0&&O.length>=f);k=t.exec(e)){let N=S(k.index),P=S(k.index+Math.max(0,k[0].length-1)),v=g!==void 0?k[g]??"":k[0];O.push({startLine:N,endLine:P,byteOffset:k.index,column:$(k.index),matchText:v}),k[0].length===0&&t.lastIndex++}if(i||a){let k;if(a)k=r?0:O.length;else{let P=new Set;for(let v of O)for(let T=v.startLine;T<=v.endLine;T++)P.add(T);k=r?b-P.size:P.size}return{output:`${o?`${o}:${k}`:String(k)}
|
|
186
|
-
`,matched:k>0,matchCount:k}}if(r){let k=new Set;for(let P of O)for(let v=P.startLine;v<=P.endLine;v++)k.add(v);let N=[];for(let P=0;P<b;P++)if(!k.has(P)){let v=
|
|
186
|
+
`,matched:k>0,matchCount:k}}if(r){let k=new Set;for(let P of O)for(let v=P.startLine;v<=P.endLine;v++)k.add(v);let N=[];for(let P=0;P<b;P++)if(!k.has(P)){let v=w[P];s&&(v=`${P+1}:${v}`),o&&(v=`${o}:${v}`),N.push(v)}return{output:N.length>0?`${N.join(`
|
|
187
187
|
`)}
|
|
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=
|
|
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 Bf=I(()=>{"use strict"});function zf(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=Cy.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=zf(e),n=n.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),t.mode==="perl"){n=Ny(n),n=ky(n),n=vy(n);let a=Ry(n);n=a.pattern,r=a.kResetGroup}break}default:n=zf(e),n=Dy(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:G(n,i),kResetGroup:r}}function Ny(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 ky(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function vy(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=Iy(e,n);if(l!==-1){let c=e.slice(o+1,l),u=$y(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 Iy(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 $y(e,t,n){let r=e;return t.includes("i")&&(r=Oy(r)),r}function Oy(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 Ry(e){let t=Ty(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),s=Py(n);return{pattern:`(?:${n})(${r})`,kResetGroup:s+1}}function Ty(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 Py(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 io(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 Dy(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 Cy,Hf=I(()=>{"use strict";Me();Cy=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 ao=I(()=>{"use strict";Bf();Hf()});var ri={};K(ri,{egrepCommand:()=>My,egrepFlagsForFuzzing:()=>By,fgrepCommand:()=>Fy,fgrepFlagsForFuzzing:()=>Wy,flagsForFuzzing:()=>Uy,grepCommand:()=>oo});async function jf(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 jf(l,t,n,r);else if(t){let f=t.replace(/^\//,"");xt(o,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function Ly(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 jf(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 ni(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 ni(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 ni(h,t,n,r,s);o.push(...m)}}}catch{}return o}var _y,oo,Fy,My,Uy,Wy,By,si=I(()=>{"use strict";so();se();ao();_y={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"]},oo={name:"grep",async execute(e,t){if(U(e))return M(_y);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,y=0,w=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=")){y=parseInt(X.slice(12),10);continue}let Ee=X.match(/^-m(\d+)$/);if(Ee){y=parseInt(Ee[1],10);continue}if(X==="-m"&&H+1<e.length){y=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"?w=j:ae[1]==="C"&&(w=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"?w=j:(w=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 Bf=I(()=>{"use strict"});function zf(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=Cy.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=zf(e),n=n.replace(/\(\?P<([^>]+)>/g,"(?<$1>"),t.mode==="perl"){n=Ny(n),n=ky(n),n=vy(n);let a=Ry(n);n=a.pattern,r=a.kResetGroup}break}default:n=zf(e),n=Dy(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:G(n,i),kResetGroup:r}}function Ny(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 ky(e){return e.replace(/\\x\{([0-9A-Fa-f]+)\}/g,"\\u{$1}")}function vy(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=Iy(e,n);if(l!==-1){let c=e.slice(o+1,l),u=$y(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 Iy(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 $y(e,t,n){let r=e;return t.includes("i")&&(r=Oy(r)),r}function Oy(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 Ry(e){let t=Ty(e);if(t===-1)return{pattern:e};let n=e.slice(0,t),r=e.slice(t+2),s=Py(n);return{pattern:`(?:${n})(${r})`,kResetGroup:s+1}}function Ty(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 Py(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 io(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 Dy(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 Cy,Hf=I(()=>{"use strict";Me();Cy=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 ao=I(()=>{"use strict";Bf();Hf()});var ri={};K(ri,{egrepCommand:()=>My,egrepFlagsForFuzzing:()=>By,fgrepCommand:()=>Fy,fgrepFlagsForFuzzing:()=>Wy,flagsForFuzzing:()=>Uy,grepCommand:()=>oo});async function jf(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 jf(l,t,n,r);else if(t){let f=t.replace(/^\//,"");xt(o,f,{stripQuotes:!0})&&r.push(l)}}}catch{}}async function Ly(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 jf(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 ni(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 ni(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 ni(h,t,n,r,s);o.push(...m)}}}catch{}return o}var _y,oo,Fy,My,Uy,Wy,By,si=I(()=>{"use strict";so();se();ao();_y={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"]},oo={name:"grep",async execute(e,t){if(U(e))return M(_y);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
|
-
`,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:
|
|
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
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 Ly(H,t);if(l)for(let Ee of X){let ae=await ni(Ee.path,t,x,S,$,Ee.isFile);L.push(...ae)}else L.push(...X)}else if(l){let X=await ni(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=>xt(j,ve,{stripQuotes:!0}))||x.length>0&&!l&&!x.some(ve=>xt(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
|
-
`};let je=await t.fs.readFile(ve),et=Ar(je,z,{invertMatch:s,showLineNumbers:r,countOnly:i,filename:ue?ke:"",onlyMatching:m,beforeContext:
|
|
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}
|
|
197
197
|
`:i&&!a&&(N+=j.output)}}let J;return T?J=2:o?J=N.length>0?0:1:J=v?0:1,g?{stdout:"",stderr:"",exitCode:J}:{stdout:N,stderr:P,exitCode:J}}};Fy={name:"fgrep",async execute(e,t){return oo.execute(["-F",...e],t)}},My={name:"egrep",async execute(e,t){return oo.execute(["-E",...e],t)}},Uy={name:"grep",flags:[{flag:"-E",type:"boolean"},{flag:"-F",type:"boolean"},{flag:"-P",type:"boolean"},{flag:"-i",type:"boolean"},{flag:"-v",type:"boolean"},{flag:"-w",type:"boolean"},{flag:"-x",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-l",type:"boolean"},{flag:"-L",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-o",type:"boolean"},{flag:"-q",type:"boolean"},{flag:"-r",type:"boolean"},{flag:"-m",type:"value",valueHint:"number"},{flag:"-A",type:"value",valueHint:"number"},{flag:"-B",type:"value",valueHint:"number"},{flag:"-C",type:"value",valueHint:"number"},{flag:"-e",type:"value",valueHint:"pattern"}],stdinType:"text",needsArgs:!0},Wy={name:"fgrep",flags:[],stdinType:"text",needsArgs:!0},By={name:"egrep",flags:[],stdinType:"text",needsArgs:!0}});function Gf(){let e=[];for(let[t,n]of Object.entries(Vf).sort()){let r=[];for(let s of n.extensions)r.push(`*${s}`);for(let s of n.globs)r.push(s);e.push(`${t}: ${r.join(", ")}`)}return`${e.join(`
|
|
198
198
|
`)}
|
|
199
199
|
`}var Vf,as,lo=I(()=>{"use strict";Me();Vf={js:{extensions:[".js",".mjs",".cjs",".jsx"],globs:[]},ts:{extensions:[".ts",".tsx",".mts",".cts"],globs:[]},html:{extensions:[".html",".htm",".xhtml"],globs:[]},css:{extensions:[".css",".scss",".sass",".less"],globs:[]},json:{extensions:[".json",".jsonc",".json5"],globs:[]},xml:{extensions:[".xml",".xsl",".xslt"],globs:[]},c:{extensions:[".c",".h"],globs:[]},cpp:{extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx",".h"],globs:[]},rust:{extensions:[".rs"],globs:[]},go:{extensions:[".go"],globs:[]},zig:{extensions:[".zig"],globs:[]},java:{extensions:[".java"],globs:[]},kotlin:{extensions:[".kt",".kts"],globs:[]},scala:{extensions:[".scala",".sc"],globs:[]},clojure:{extensions:[".clj",".cljc",".cljs",".edn"],globs:[]},py:{extensions:[".py",".pyi",".pyw"],globs:[]},rb:{extensions:[".rb",".rake",".gemspec"],globs:["Rakefile","Gemfile"]},php:{extensions:[".php",".phtml",".php3",".php4",".php5"],globs:[]},perl:{extensions:[".pl",".pm",".pod",".t"],globs:[]},lua:{extensions:[".lua"],globs:[]},sh:{extensions:[".sh",".bash",".zsh",".fish"],globs:[".bashrc",".zshrc",".profile"]},bat:{extensions:[".bat",".cmd"],globs:[]},ps:{extensions:[".ps1",".psm1",".psd1"],globs:[]},yaml:{extensions:[".yaml",".yml"],globs:[]},toml:{extensions:[".toml"],globs:["Cargo.toml","pyproject.toml"]},ini:{extensions:[".ini",".cfg",".conf"],globs:[]},csv:{extensions:[".csv",".tsv"],globs:[]},md:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},markdown:{extensions:[".md",".mdx",".markdown",".mdown",".mkd"],globs:[]},rst:{extensions:[".rst"],globs:[]},txt:{extensions:[".txt",".text"],globs:[]},tex:{extensions:[".tex",".ltx",".sty",".cls"],globs:[]},sql:{extensions:[".sql"],globs:[]},graphql:{extensions:[".graphql",".gql"],globs:[]},proto:{extensions:[".proto"],globs:[]},make:{extensions:[".mk",".mak"],globs:["Makefile","GNUmakefile","makefile"]},docker:{extensions:[],globs:["Dockerfile","Dockerfile.*","*.dockerfile"]},tf:{extensions:[".tf",".tfvars"],globs:[]}},as=class{types;constructor(){this.types=new Map(Object.entries(Vf).map(([t,n])=>[t,{extensions:[...n.extensions],globs:[...n.globs]}]))}addType(t){let n=t.indexOf(":");if(n===-1)return;let r=t.slice(0,n),s=t.slice(n+1);if(s.startsWith("include:")){let i=s.slice(8),a=this.types.get(i);if(a){let o=this.types.get(r)||{extensions:[],globs:[]};o.extensions.push(...a.extensions),o.globs.push(...a.globs),this.types.set(r,o)}}else{let i=this.types.get(r)||{extensions:[],globs:[]};if(s.startsWith("*.")&&!s.slice(2).includes("*")){let a=s.slice(1);i.extensions.includes(a)||i.extensions.push(a)}else i.globs.includes(s)||i.globs.push(s);this.types.set(r,i)}}clearType(t){let n=this.types.get(t);n&&(n.extensions=[],n.globs=[])}getType(t){return this.types.get(t)}getAllTypes(){return this.types}matchesType(t,n){let r=t.toLowerCase();for(let s of n){if(s==="all"){if(this.matchesAnyType(t))return!0;continue}let i=this.types.get(s);if(i){for(let a of i.extensions)if(r.endsWith(a))return!0;for(let a of i.globs)if(a.includes("*")){let o=a.replace(/\./g,"\\.").replace(/\*/g,".*");if(G(`^${o}$`,"i").test(t))return!0}else if(r===a.toLowerCase())return!0}}return!1}matchesAnyType(t){let n=t.toLowerCase();for(let r of this.types.values()){for(let s of r.extensions)if(n.endsWith(s))return!0;for(let s of r.globs)if(s.includes("*")){let i=s.replace(/\./g,"\\.").replace(/\*/g,".*");if(G(`^${i}$`,"i").test(t))return!0}else if(n===s.toLowerCase())return!0}return!1}}});function qf(){return{ignoreCase:!1,caseSensitive:!1,smartCase:!0,fixedStrings:!1,wordRegexp:!1,lineRegexp:!1,invertMatch:!1,multiline:!1,multilineDotall:!1,patterns:[],patternFiles:[],count:!1,countMatches:!1,files:!1,filesWithMatches:!1,filesWithoutMatch:!1,stats:!1,onlyMatching:!1,maxCount:0,lineNumber:!0,noFilename:!1,withFilename:!1,nullSeparator:!1,byteOffset:!1,column:!1,vimgrep:!1,replace:null,afterContext:0,beforeContext:0,contextSeparator:"--",quiet:!1,heading:!1,passthru:!1,includeZero:!1,sort:"path",json:!1,globs:[],iglobs:[],globCaseInsensitive:!1,types:[],typesNot:[],typeAdd:[],typeClear:[],hidden:!1,noIgnore:!1,noIgnoreDot:!1,noIgnoreVcs:!1,ignoreFiles:[],maxDepth:1/0,maxFilesize:0,followSymlinks:!1,searchZip:!1,searchBinary:!1,preprocessor:null,preprocessorGlobs:[]}}var Zf=I(()=>{"use strict"});function zy(e){let t=e.match(/^(\d+)([KMG])?$/i);if(!t)return 0;let n=parseInt(t[1],10);switch((t[2]||"").toUpperCase()){case"K":return n*1024;case"M":return n*1024*1024;case"G":return n*1024*1024*1024;default:return n}}function Hy(e){return/^\d+[KMG]?$/i.test(e)?null:{stdout:"",stderr:`rg: invalid --max-filesize value: ${e}
|
|
200
|
-
`,exitCode:1}}function Kf(e){return null}function Gy(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function qy(e,t,n){let r=e[t];for(let s of Qf){if(r.startsWith(`--${s.long}=`)){let i=r.slice(`--${s.long}=`.length),a=ii(n,s,i);return a?{newIndex:t,error:a}:{newIndex:t}}if(s.short&&r.startsWith(`-${s.short}`)&&r.length>2){let i=r.slice(2),a=ii(n,s,i);return a?{newIndex:t,error:a}:{newIndex:t}}if(s.short&&r===`-${s.short}`||r===`--${s.long}`){if(t+1>=e.length)return null;let i=e[t+1],a=ii(n,s,i);return a?{newIndex:t+1,error:a}:{newIndex:t+1}}}return null}function Zy(e){return Qf.find(t=>t.short===e)}function ii(e,t,n){if(t.validate){let s=t.validate(n);if(s)return s}let r=t.parse?t.parse(n):n;t.multi?e[t.target].push(r):e[t.target]=r}function Ky(e,t){let n=e[t];if(n==="--sort"&&t+1<e.length){let r=e[t+1];if(r==="path"||r==="none")return{value:r,newIndex:t+1}}if(n.startsWith("--sort=")){let r=n.slice(7);if(r==="path"||r==="none")return{value:r,newIndex:t}}return null}function Qy(e,t){let n=e[t],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:t}:(n==="-A"||n==="-B"||n==="-C")&&t+1<e.length?{flag:n[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function Xy(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function Xf(e){let t=qf(),n=null,r=[],s=-1,i=-1,a=-1,o=!1;for(let l=0;l<e.length;l++){let c=e[l];if(c.startsWith("-")&&c!=="-"){let u=Qy(e,l);if(u){let{flag:g,value:
|
|
201
|
-
`,exitCode:1}};if(g.length===1){let
|
|
202
|
-
`);for(let r of n){let s=r.replace(/\s+$/,"");if(!s||s.startsWith("#"))continue;let i=!1;s.startsWith("!")&&(i=!0,s=s.slice(1));let a=!1;s.endsWith("/")&&(a=!0,s=s.slice(0,-1));let o=!1;s.startsWith("/")?(o=!0,s=s.slice(1)):s.includes("/")&&!s.startsWith("**/")&&(o=!0);let l=this.patternToRegex(s,o);this.patterns.push({pattern:r,regex:l,negated:i,directoryOnly:a,rooted:o})}}patternToRegex(t,n){let r="";n?r="^":r="(?:^|/)";let s=0;for(;s<t.length;){let i=t[s];if(i==="*")t[s+1]==="*"?t[s+2]==="/"?(r+="(?:.*/)?",s+=3):(s+2>=t.length,r+=".*",s+=2):(r+="[^/]*",s++);else if(i==="?")r+="[^/]",s++;else if(i==="["){let a=s+1;for(a<t.length&&t[a]==="!"&&a++,a<t.length&&t[a]==="]"&&a++;a<t.length&&t[a]!=="]";)a++;if(a<t.length){let o=t.slice(s,a+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),r+=o,s=a+1}else r+="\\[",s++}else i==="/"?(r+="/",s++):(r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s++)}return r+="(?:/.*)?$",G(r)}matches(t,n){let r=t.replace(/^\.\//,"");r=r.replace(/^\//,"");let s=!1;for(let i of this.patterns)i.directoryOnly&&!n||i.regex.test(r)&&(s=!i.negated);return s}isWhitelisted(t,n){let r=t.replace(/^\.\//,"");r=r.replace(/^\//,"");for(let s of this.patterns)if(!(s.directoryOnly&&!n)&&s.negated&&s.regex.test(r))return!0;return!1}getBasePath(){return this.basePath}},ls=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(t,n,r=!1,s=!1){this.fs=t,this.skipDotIgnore=r,this.skipVcsIgnore=s}async load(t){let n=[],r=t;for(;;){n.unshift(r);let i=this.fs.resolvePath(r,"..");if(i===r)break;r=i}let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let i of n){this.loadedDirs.add(i);for(let a of s){let o=this.fs.resolvePath(i,a);try{let l=await this.fs.readFile(o),c=new os(i);c.parse(l),this.parsers.push(c)}catch{}}}}async loadForDirectory(t){if(this.loadedDirs.has(t))return;this.loadedDirs.add(t);let n=[];this.skipVcsIgnore||n.push(".gitignore"),this.skipDotIgnore||n.push(".rgignore",".ignore");for(let r of n){let s=this.fs.resolvePath(t,r);try{let i=await this.fs.readFile(s),a=new os(t);a.parse(i),this.parsers.push(a)}catch{}}}addPatternsFromContent(t,n){let r=new os(n);r.parse(t),this.parsers.push(r)}matches(t,n){for(let r of this.parsers){let s=r.getBasePath();if(!t.startsWith(s))continue;let i=t.slice(s.length).replace(/^\//,"");if(r.matches(i,n))return!0}return!1}isWhitelisted(t,n){for(let r of this.parsers){let s=r.getBasePath();if(!t.startsWith(s))continue;let i=t.slice(s.length).replace(/^\//,"");if(r.isWhitelisted(i,n))return!0}return!1}static isCommonIgnored(t){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(t)}}});import{gunzipSync as Yy}from"node:zlib";function Jy(e){return e.length>=2&&e[0]===31&&e[1]===139}function e4(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r==="["&&!t?t=!0:r==="]"&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}async function e1(e){let{ctx:t,options:n,paths:r,explicitLineNumbers:s}=e;for(let g of n.globs){let
|
|
203
|
-
`,exitCode:1}}if(n.files){let g=[...n.patterns,...r];return r4(t,g,n)}let i=[...n.patterns];for(let g of n.patternFiles)try{let
|
|
204
|
-
`).filter(b=>b.length>0);i.push(...
|
|
200
|
+
`,exitCode:1}}function Kf(e){return null}function Gy(e){e.hidden?e.searchBinary=!0:e.noIgnore?e.hidden=!0:e.noIgnore=!0}function qy(e,t,n){let r=e[t];for(let s of Qf){if(r.startsWith(`--${s.long}=`)){let i=r.slice(`--${s.long}=`.length),a=ii(n,s,i);return a?{newIndex:t,error:a}:{newIndex:t}}if(s.short&&r.startsWith(`-${s.short}`)&&r.length>2){let i=r.slice(2),a=ii(n,s,i);return a?{newIndex:t,error:a}:{newIndex:t}}if(s.short&&r===`-${s.short}`||r===`--${s.long}`){if(t+1>=e.length)return null;let i=e[t+1],a=ii(n,s,i);return a?{newIndex:t+1,error:a}:{newIndex:t+1}}}return null}function Zy(e){return Qf.find(t=>t.short===e)}function ii(e,t,n){if(t.validate){let s=t.validate(n);if(s)return s}let r=t.parse?t.parse(n):n;t.multi?e[t.target].push(r):e[t.target]=r}function Ky(e,t){let n=e[t];if(n==="--sort"&&t+1<e.length){let r=e[t+1];if(r==="path"||r==="none")return{value:r,newIndex:t+1}}if(n.startsWith("--sort=")){let r=n.slice(7);if(r==="path"||r==="none")return{value:r,newIndex:t}}return null}function Qy(e,t){let n=e[t],r=n.match(/^-([ABC])(\d+)$/);return r?{flag:r[1],value:parseInt(r[2],10),newIndex:t}:(n==="-A"||n==="-B"||n==="-C")&&t+1<e.length?{flag:n[1],value:parseInt(e[t+1],10),newIndex:t+1}:null}function Xy(e){let t=e.match(/^-m(\d+)$/);return t?parseInt(t[1],10):null}function Xf(e){let t=qf(),n=null,r=[],s=-1,i=-1,a=-1,o=!1;for(let l=0;l<e.length;l++){let c=e[l];if(c.startsWith("-")&&c!=="-"){let u=Qy(e,l);if(u){let{flag:g,value:w,newIndex:y}=u;g==="A"?s=Math.max(s,w):g==="B"?i=Math.max(i,w):a=w,l=y;continue}let f=Xy(c);if(f!==null){t.maxCount=f;continue}let p=qy(e,l,t);if(p){if(p.error)return{success:!1,error:p.error};l=p.newIndex;continue}let h=Ky(e,l);if(h){t.sort=h.value,l=h.newIndex;continue}let m=c.startsWith("--")?[c]:c.slice(1).split(""),d=!1;for(let g of m){if(Vy.has(g)){t.lineNumber=!0,o=!0;continue}if(g==="u"||g==="--unrestricted"){Gy(t);continue}if(g==="P"||g==="--pcre2")return{success:!1,error:{stdout:"",stderr:`rg: PCRE2 is not supported. Use standard regex syntax instead.
|
|
201
|
+
`,exitCode:1}};if(g.length===1){let y=Zy(g);if(y){if(l+1>=e.length)return{success:!1,error:Y("rg",`-${g}`)};let b=ii(t,y,e[l+1]);if(b)return{success:!1,error:b};l++,d=!0;continue}}let w=jy.get(g);if(w){w(t);continue}if(g.startsWith("--"))return{success:!1,error:Y("rg",g)};if(g.length===1)return{success:!1,error:Y("rg",`-${g}`)}}}else n===null&&t.patterns.length===0&&t.patternFiles.length===0?n=c:r.push(c)}return(s>=0||a>=0)&&(t.afterContext=Math.max(s>=0?s:0,a>=0?a:0)),(i>=0||a>=0)&&(t.beforeContext=Math.max(i>=0?i:0,a>=0?a:0)),n!==null&&t.patterns.push(n),(t.column||t.vimgrep)&&(o=!0),{success:!0,options:t,paths:r,explicitLineNumbers:o}}var Qf,jy,Vy,Yf=I(()=>{"use strict";se();Zf();Qf=[{short:"g",long:"glob",target:"globs",multi:!0},{long:"iglob",target:"iglobs",multi:!0},{short:"t",long:"type",target:"types",multi:!0,validate:Kf},{short:"T",long:"type-not",target:"typesNot",multi:!0,validate:Kf},{long:"type-add",target:"typeAdd",multi:!0},{long:"type-clear",target:"typeClear",multi:!0},{short:"m",long:"max-count",target:"maxCount",parse:parseInt},{short:"e",long:"regexp",target:"patterns",multi:!0},{short:"f",long:"file",target:"patternFiles",multi:!0},{short:"r",long:"replace",target:"replace"},{short:"d",long:"max-depth",target:"maxDepth",parse:parseInt},{long:"max-filesize",target:"maxFilesize",parse:zy,validate:Hy},{long:"context-separator",target:"contextSeparator"},{short:"j",long:"threads",target:"maxDepth",parse:()=>1/0},{long:"ignore-file",target:"ignoreFiles",multi:!0},{long:"pre",target:"preprocessor"},{long:"pre-glob",target:"preprocessorGlobs",multi:!0}],jy=new Map([["i",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["--ignore-case",e=>{e.ignoreCase=!0,e.caseSensitive=!1,e.smartCase=!1}],["s",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["--case-sensitive",e=>{e.caseSensitive=!0,e.ignoreCase=!1,e.smartCase=!1}],["S",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["--smart-case",e=>{e.smartCase=!0,e.ignoreCase=!1,e.caseSensitive=!1}],["F",e=>{e.fixedStrings=!0}],["--fixed-strings",e=>{e.fixedStrings=!0}],["w",e=>{e.wordRegexp=!0}],["--word-regexp",e=>{e.wordRegexp=!0}],["x",e=>{e.lineRegexp=!0}],["--line-regexp",e=>{e.lineRegexp=!0}],["v",e=>{e.invertMatch=!0}],["--invert-match",e=>{e.invertMatch=!0}],["U",e=>{e.multiline=!0}],["--multiline",e=>{e.multiline=!0}],["--multiline-dotall",e=>{e.multilineDotall=!0,e.multiline=!0}],["c",e=>{e.count=!0}],["--count",e=>{e.count=!0}],["--count-matches",e=>{e.countMatches=!0}],["l",e=>{e.filesWithMatches=!0}],["--files",e=>{e.files=!0}],["--files-with-matches",e=>{e.filesWithMatches=!0}],["--files-without-match",e=>{e.filesWithoutMatch=!0}],["--stats",e=>{e.stats=!0}],["o",e=>{e.onlyMatching=!0}],["--only-matching",e=>{e.onlyMatching=!0}],["q",e=>{e.quiet=!0}],["--quiet",e=>{e.quiet=!0}],["N",e=>{e.lineNumber=!1}],["--no-line-number",e=>{e.lineNumber=!1}],["H",e=>{e.withFilename=!0}],["--with-filename",e=>{e.withFilename=!0}],["I",e=>{e.noFilename=!0}],["--no-filename",e=>{e.noFilename=!0}],["0",e=>{e.nullSeparator=!0}],["--null",e=>{e.nullSeparator=!0}],["b",e=>{e.byteOffset=!0}],["--byte-offset",e=>{e.byteOffset=!0}],["--column",e=>{e.column=!0,e.lineNumber=!0}],["--no-column",e=>{e.column=!1}],["--vimgrep",e=>{e.vimgrep=!0,e.column=!0,e.lineNumber=!0}],["--json",e=>{e.json=!0}],["--hidden",e=>{e.hidden=!0}],["--no-ignore",e=>{e.noIgnore=!0}],["--no-ignore-dot",e=>{e.noIgnoreDot=!0}],["--no-ignore-vcs",e=>{e.noIgnoreVcs=!0}],["L",e=>{e.followSymlinks=!0}],["--follow",e=>{e.followSymlinks=!0}],["z",e=>{e.searchZip=!0}],["--search-zip",e=>{e.searchZip=!0}],["a",e=>{e.searchBinary=!0}],["--text",e=>{e.searchBinary=!0}],["--heading",e=>{e.heading=!0}],["--passthru",e=>{e.passthru=!0}],["--include-zero",e=>{e.includeZero=!0}],["--glob-case-insensitive",e=>{e.globCaseInsensitive=!0}]]),Vy=new Set(["n","--line-number"])});async function co(e,t,n=!1,r=!1,s=[]){let i=new ls(e,t,n,r);await i.load(t);for(let a of s)try{let o=e.resolvePath(t,a),l=await e.readFile(o);i.addPatternsFromContent(l,t)}catch{}return i}var os,ls,Jf=I(()=>{"use strict";Me();os=class{patterns=[];basePath;constructor(t="/"){this.basePath=t}parse(t){let n=t.split(`
|
|
202
|
+
`);for(let r of n){let s=r.replace(/\s+$/,"");if(!s||s.startsWith("#"))continue;let i=!1;s.startsWith("!")&&(i=!0,s=s.slice(1));let a=!1;s.endsWith("/")&&(a=!0,s=s.slice(0,-1));let o=!1;s.startsWith("/")?(o=!0,s=s.slice(1)):s.includes("/")&&!s.startsWith("**/")&&(o=!0);let l=this.patternToRegex(s,o);this.patterns.push({pattern:r,regex:l,negated:i,directoryOnly:a,rooted:o})}}patternToRegex(t,n){let r="";n?r="^":r="(?:^|/)";let s=0;for(;s<t.length;){let i=t[s];if(i==="*")t[s+1]==="*"?t[s+2]==="/"?(r+="(?:.*/)?",s+=3):(s+2>=t.length,r+=".*",s+=2):(r+="[^/]*",s++);else if(i==="?")r+="[^/]",s++;else if(i==="["){let a=s+1;for(a<t.length&&t[a]==="!"&&a++,a<t.length&&t[a]==="]"&&a++;a<t.length&&t[a]!=="]";)a++;if(a<t.length){let o=t.slice(s,a+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),r+=o,s=a+1}else r+="\\[",s++}else i==="/"?(r+="/",s++):(r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s++)}return r+="(?:/.*)?$",G(r)}matches(t,n){let r=t.replace(/^\.\//,"");r=r.replace(/^\//,"");let s=!1;for(let i of this.patterns)i.directoryOnly&&!n||i.regex.test(r)&&(s=!i.negated);return s}isWhitelisted(t,n){let r=t.replace(/^\.\//,"");r=r.replace(/^\//,"");for(let s of this.patterns)if(!(s.directoryOnly&&!n)&&s.negated&&s.regex.test(r))return!0;return!1}getBasePath(){return this.basePath}},ls=class{parsers=[];fs;skipDotIgnore;skipVcsIgnore;loadedDirs=new Set;constructor(t,n,r=!1,s=!1){this.fs=t,this.skipDotIgnore=r,this.skipVcsIgnore=s}async load(t){let n=[],r=t;for(;;){n.unshift(r);let i=this.fs.resolvePath(r,"..");if(i===r)break;r=i}let s=[];this.skipVcsIgnore||s.push(".gitignore"),this.skipDotIgnore||s.push(".rgignore",".ignore");for(let i of n){this.loadedDirs.add(i);for(let a of s){let o=this.fs.resolvePath(i,a);try{let l=await this.fs.readFile(o),c=new os(i);c.parse(l),this.parsers.push(c)}catch{}}}}async loadForDirectory(t){if(this.loadedDirs.has(t))return;this.loadedDirs.add(t);let n=[];this.skipVcsIgnore||n.push(".gitignore"),this.skipDotIgnore||n.push(".rgignore",".ignore");for(let r of n){let s=this.fs.resolvePath(t,r);try{let i=await this.fs.readFile(s),a=new os(t);a.parse(i),this.parsers.push(a)}catch{}}}addPatternsFromContent(t,n){let r=new os(n);r.parse(t),this.parsers.push(r)}matches(t,n){for(let r of this.parsers){let s=r.getBasePath();if(!t.startsWith(s))continue;let i=t.slice(s.length).replace(/^\//,"");if(r.matches(i,n))return!0}return!1}isWhitelisted(t,n){for(let r of this.parsers){let s=r.getBasePath();if(!t.startsWith(s))continue;let i=t.slice(s.length).replace(/^\//,"");if(r.isWhitelisted(i,n))return!0}return!1}static isCommonIgnored(t){return new Set(["node_modules",".git",".svn",".hg","__pycache__",".pytest_cache",".mypy_cache","venv",".venv",".next",".nuxt",".cargo"]).has(t)}}});import{gunzipSync as Yy}from"node:zlib";function Jy(e){return e.length>=2&&e[0]===31&&e[1]===139}function e4(e){let t=!1;for(let n=0;n<e.length;n++){let r=e[n];r==="["&&!t?t=!0:r==="]"&&t&&(t=!1)}return t?`rg: glob '${e}' has an unclosed character class`:null}async function e1(e){let{ctx:t,options:n,paths:r,explicitLineNumbers:s}=e;for(let g of n.globs){let w=g.startsWith("!")?g.slice(1):g,y=e4(w);if(y)return{stdout:"",stderr:`${y}
|
|
203
|
+
`,exitCode:1}}if(n.files){let g=[...n.patterns,...r];return r4(t,g,n)}let i=[...n.patterns];for(let g of n.patternFiles)try{let w;if(g==="-")w=t.stdin;else{let b=t.fs.resolvePath(t.cwd,g);w=await t.fs.readFile(b)}let y=w.split(`
|
|
204
|
+
`).filter(b=>b.length>0);i.push(...y)}catch{return{stdout:"",stderr:`rg: ${g}: No such file or directory
|
|
205
205
|
`,exitCode:2}}if(i.length===0)return n.patternFiles.length>0?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`rg: no pattern given
|
|
206
206
|
`,exitCode:2};let a=r.length===0?["."]:r,o=t4(n,i),l,c;try{let g=n4(i,n,o);l=g.regex,c=g.kResetGroup}catch{return{stdout:"",stderr:`rg: invalid regex: ${i.join(", ")}
|
|
207
207
|
`,exitCode:2}}let u=null;n.noIgnore||(u=await co(t.fs,t.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let f=new as;for(let g of n.typeClear)f.clearType(g);for(let g of n.typeAdd)f.addType(g);let{files:p,singleExplicitFile:h}=await t1(t,a,n,u,f);if(p.length===0)return{stdout:"",stderr:"",exitCode:1};let m=!n.noFilename&&(n.withFilename||!h||p.length>1),d=n.lineNumber;return s||(h&&p.length===1&&(d=!1),n.onlyMatching&&(d=!1)),a4(t,p,l,n,m,d,c)}function t4(e,t){return e.caseSensitive?!1:e.ignoreCase?!0:e.smartCase?!t.some(n=>/[A-Z]/.test(n)):!1}function n4(e,t,n){let r;return e.length===1?r=e[0]:r=e.map(s=>t.fixedStrings?s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):`(?:${s})`).join("|"),is(r,{mode:t.fixedStrings&&e.length===1?"fixed":"perl",ignoreCase:n,wholeWord:t.wordRegexp,lineRegexp:t.lineRegexp,multiline:t.multiline,multilineDotall:t.multilineDotall})}async function t1(e,t,n,r,s){let i=[],a=0,o=0;for(let c of t){let u=e.fs.resolvePath(e.cwd,c);try{let f=await e.fs.stat(u);if(f.isFile){if(a++,n.maxFilesize>0&&f.size>n.maxFilesize)continue;r1(c,n,r,u,s)&&i.push(c)}else f.isDirectory&&(o++,await n1(e,c,u,0,n,r,s,i))}catch{}}return{files:n.sort==="path"?i.sort():i,singleExplicitFile:a===1&&o===0}}async function n1(e,t,n,r,s,i,a,o){if(!(r>=s.maxDepth)){i&&await i.loadForDirectory(n);try{let l=e.fs.readdirWithFileTypes?await e.fs.readdirWithFileTypes(n):(await e.fs.readdir(n)).map(c=>({name:c,isFile:void 0}));for(let c of l){let u=c.name;if(!s.noIgnore&&ls.isCommonIgnored(u))continue;let f=u.startsWith("."),p=t==="."?u:t==="./"?`./${u}`:t.endsWith("/")?`${t}${u}`:`${t}/${u}`,h=e.fs.resolvePath(n,u),m,d,g=!1;if(c.isFile!==void 0&&"isDirectory"in c){let b=c;if(g=b.isSymbolicLink===!0,g&&!s.followSymlinks)continue;if(g&&s.followSymlinks)try{let x=await e.fs.stat(h);m=x.isFile,d=x.isDirectory}catch{continue}else m=b.isFile,d=b.isDirectory}else try{let b=e.fs.lstat?await e.fs.lstat(h):await e.fs.stat(h);if(g=b.isSymbolicLink===!0,g&&!s.followSymlinks)continue;let x=g&&s.followSymlinks?await e.fs.stat(h):b;m=x.isFile,d=x.isDirectory}catch{continue}if(!i?.matches(h,d)&&!(f&&!s.hidden&&!i?.isWhitelisted(h,d))){if(d)await n1(e,p,h,r+1,s,i,a,o);else if(m){if(s.maxFilesize>0)try{if((await e.fs.stat(h)).size>s.maxFilesize)continue}catch{continue}r1(p,s,i,h,a)&&o.push(p)}}}}catch{}}}function r1(e,t,n,r,s){let i=e.split("/").pop()||e;if(n?.matches(r,!1)||t.types.length>0&&!s.matchesType(i,t.types)||t.typesNot.length>0&&s.matchesType(i,t.typesNot))return!1;if(t.globs.length>0){let a=t.globCaseInsensitive,o=t.globs.filter(c=>!c.startsWith("!")),l=t.globs.filter(c=>c.startsWith("!")).map(c=>c.slice(1));if(o.length>0){let c=!1;for(let u of o)if(tn(i,u,a)||tn(e,u,a)){c=!0;break}if(!c)return!1}for(let c of l)if(c.startsWith("/")){let u=c.slice(1);if(tn(e,u,a))return!1}else if(tn(i,c,a)||tn(e,c,a))return!1}if(t.iglobs.length>0){let a=t.iglobs.filter(l=>!l.startsWith("!")),o=t.iglobs.filter(l=>l.startsWith("!")).map(l=>l.slice(1));if(a.length>0){let l=!1;for(let c of a)if(tn(i,c,!0)||tn(e,c,!0)){l=!0;break}if(!l)return!1}for(let l of o)if(l.startsWith("/")){let c=l.slice(1);if(tn(e,c,!0))return!1}else if(tn(i,l,!0)||tn(e,l,!0))return!1}return!0}function tn(e,t,n=!1){let r="^";for(let s=0;s<t.length;s++){let i=t[s];if(i==="*")t[s+1]==="*"?(r+=".*",s++):r+="[^/]*";else if(i==="?")r+="[^/]";else if(i==="["){let a=s+1;for(a<t.length&&t[a]==="!"&&a++,a<t.length&&t[a]==="]"&&a++;a<t.length&&t[a]!=="]";)a++;if(a<t.length){let o=t.slice(s,a+1);o.startsWith("[!")&&(o=`[^${o.slice(2)}`),r+=o,s=a}else r+="\\["}else r+=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}return r+="$",G(r,n?"i":"").test(e)}async function r4(e,t,n){let r=null;n.noIgnore||(r=await co(e.fs,e.cwd,n.noIgnoreDot,n.noIgnoreVcs,n.ignoreFiles));let s=new as;for(let c of n.typeClear)s.clearType(c);for(let c of n.typeAdd)s.addType(c);let i=t.length===0?["."]:t,{files:a}=await t1(e,i,n,r,s);if(a.length===0)return{stdout:"",stderr:"",exitCode:1};if(n.quiet)return{stdout:"",stderr:"",exitCode:0};let o=n.nullSeparator?"\0":`
|
|
208
|
-
`;return{stdout:a.map(c=>c+o).join(""),stderr:"",exitCode:0}}function s4(e,t){if(t.length===0)return!0;for(let n of t)if(tn(e,n,!1))return!0;return!1}async function i4(e,t,n,r){try{if(r.preprocessor&&e.exec){let a=n.split("/").pop()||n;if(s4(a,r.preprocessorGlobs)){let o=await e.exec(`${r.preprocessor} "${t}"`,{cwd:e.cwd});if(o.exitCode===0&&o.stdout){let l=o.stdout.slice(0,8192);return{content:o.stdout,isBinary:l.includes("\0")}}}}if(r.searchZip&&n.endsWith(".gz")){let a=await e.fs.readFileBuffer(t);if(Jy(a))try{let o=Yy(a),l=new TextDecoder().decode(o),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await e.fs.readFile(t),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function a4(e,t,n,r,s,i,a){let o="",l=!1,c=[],u=0,f=0,p=0,h=50;e:for(let g=0;g<t.length;g+=h){let
|
|
208
|
+
`;return{stdout:a.map(c=>c+o).join(""),stderr:"",exitCode:0}}function s4(e,t){if(t.length===0)return!0;for(let n of t)if(tn(e,n,!1))return!0;return!1}async function i4(e,t,n,r){try{if(r.preprocessor&&e.exec){let a=n.split("/").pop()||n;if(s4(a,r.preprocessorGlobs)){let o=await e.exec(`${r.preprocessor} "${t}"`,{cwd:e.cwd});if(o.exitCode===0&&o.stdout){let l=o.stdout.slice(0,8192);return{content:o.stdout,isBinary:l.includes("\0")}}}}if(r.searchZip&&n.endsWith(".gz")){let a=await e.fs.readFileBuffer(t);if(Jy(a))try{let o=Yy(a),l=new TextDecoder().decode(o),c=l.slice(0,8192);return{content:l,isBinary:c.includes("\0")}}catch{return null}}let s=await e.fs.readFile(t),i=s.slice(0,8192);return{content:s,isBinary:i.includes("\0")}}catch{return null}}async function a4(e,t,n,r,s,i,a){let o="",l=!1,c=[],u=0,f=0,p=0,h=50;e:for(let g=0;g<t.length;g+=h){let w=t.slice(g,g+h),y=await Promise.all(w.map(async b=>{let x=e.fs.resolvePath(e.cwd,b),S=await i4(e,x,b,r);if(!S)return null;let{content:$,isBinary:O}=S;if(p+=$.length,O&&!r.searchBinary)return null;let F=s&&!r.heading?b:"",R=Ar($,n,{invertMatch:r.invertMatch,showLineNumbers:i,countOnly:r.count,countMatches:r.countMatches,filename:F,onlyMatching:r.onlyMatching,beforeContext:r.beforeContext,afterContext:r.afterContext,maxCount:r.maxCount,contextSeparator:r.contextSeparator,showColumn:r.column,vimgrep:r.vimgrep,showByteOffset:r.byteOffset,replace:r.replace!==null?io(r.replace):null,passthru:r.passthru,multiline:r.multiline,kResetGroup:a});return r.json&&R.matched?{file:b,result:R,content:$,isBinary:!1}:{file:b,result:R}}));for(let b of y){if(!b)continue;let{file:x,result:S}=b;if(S.matched){if(l=!0,f++,u+=S.matchCount,r.quiet&&!r.json)break e;if(r.json&&!r.quiet){let $=b.content||"";c.push(JSON.stringify({type:"begin",data:{path:{text:x}}}));let O=$.split(`
|
|
209
209
|
`);n.lastIndex=0;let F=0;for(let R=0;R<O.length;R++){let z=O[R];n.lastIndex=0;let k=[];for(let N=n.exec(z);N!==null;N=n.exec(z)){let P={match:{text:N[0]},start:N.index,end:N.index+N[0].length};r.replace!==null&&(P.replacement={text:r.replace}),k.push(P),N[0].length===0&&n.lastIndex++}if(k.length>0){let N={type:"match",data:{path:{text:x},lines:{text:`${z}
|
|
210
210
|
`},line_number:R+1,absolute_offset:F,submatches:k}};c.push(JSON.stringify(N))}F+=z.length+1}c.push(JSON.stringify({type:"end",data:{path:{text:x},binary_offset:null,stats:{elapsed:{secs:0,nanos:0,human:"0s"},searches:1,searches_with_match:1,bytes_searched:$.length,bytes_printed:0,matched_lines:S.matchCount,matches:S.matchCount}}}))}else if(r.filesWithMatches){let $=r.nullSeparator?"\0":`
|
|
211
211
|
`;o+=`${x}${$}`}else r.filesWithoutMatch||(r.heading&&!r.noFilename&&(o+=`${x}
|
|
@@ -269,8 +269,8 @@ ${c}`,t.lineNumber=n.currentLineIndex+t.linesConsumedInCycle+1}else{t.quit=!0;br
|
|
|
269
269
|
${c}`}else s.push(c)}let i=s.join(`
|
|
270
270
|
`),o=new yo([i],t||r).parse();if(!o.error&&o.commands.length>0){let l=y4(o.commands);if(l)return{commands:[],error:l,silentMode:n,extendedRegexMode:r}}return{...o,silentMode:n,extendedRegexMode:r}}function y4(e){let t=new Set;h1(e,t);let n=d1(e,t);if(n)return`undefined label '${n}'`}function h1(e,t){for(let n of e)n.type==="label"?t.add(n.name):n.type==="group"&&h1(n.commands,t)}function d1(e,t){for(let n of e){if((n.type==="branch"||n.type==="branchOnSubst"||n.type==="branchOnNoSubst")&&n.label&&!t.has(n.label))return n.label;if(n.type==="group"){let r=d1(n.commands,t);if(r)return r}}}var yo,m1=I(()=>{"use strict";f1();yo=class{scripts;tokens=[];pos=0;extendedRegex=!1;constructor(t,n=!1){this.scripts=t,this.extendedRegex=n}parse(){let t=[];for(let n of this.scripts){let r=new ai(n);for(this.tokens=r.tokenize(),this.pos=0;!this.isAtEnd();){if(this.check(ee.NEWLINE)||this.check(ee.SEMICOLON)){this.advance();continue}let s=this.parseCommand();if(s.error)return{commands:[],error:s.error};s.command&&t.push(s.command)}}return{commands:t}}parseCommand(){let t=this.parseAddressRange();if(t?.error)return{command:null,error:t.error};let n=t?.address;for(this.check(ee.NEGATION)&&(this.advance(),n&&(n.negated=!0));this.check(ee.NEWLINE)||this.check(ee.SEMICOLON);)this.advance();if(this.isAtEnd())return n&&(n.start!==void 0||n.end!==void 0)?{command:null,error:"command expected"}:{command:null};let r=this.peek();switch(r.type){case ee.COMMAND:return this.parseSimpleCommand(r,n);case ee.SUBSTITUTE:return this.parseSubstituteFromToken(r,n);case ee.TRANSLITERATE:return this.parseTransliterateFromToken(r,n);case ee.LABEL_DEF:return this.advance(),{command:{type:"label",name:r.label||""}};case ee.BRANCH:return this.advance(),{command:{type:"branch",address:n,label:r.label}};case ee.BRANCH_ON_SUBST:return this.advance(),{command:{type:"branchOnSubst",address:n,label:r.label}};case ee.BRANCH_ON_NO_SUBST:return this.advance(),{command:{type:"branchOnNoSubst",address:n,label:r.label}};case ee.TEXT_CMD:return this.advance(),this.parseTextCommand(r,n);case ee.FILE_READ:return this.advance(),{command:{type:"readFile",address:n,filename:r.filename||""}};case ee.FILE_READ_LINE:return this.advance(),{command:{type:"readFileLine",address:n,filename:r.filename||""}};case ee.FILE_WRITE:return this.advance(),{command:{type:"writeFile",address:n,filename:r.filename||""}};case ee.FILE_WRITE_LINE:return this.advance(),{command:{type:"writeFirstLine",address:n,filename:r.filename||""}};case ee.EXECUTE:return this.advance(),{command:{type:"execute",address:n,command:r.command}};case ee.VERSION:return this.advance(),{command:{type:"version",address:n,minVersion:r.label}};case ee.LBRACE:return this.parseGroup(n);case ee.RBRACE:return{command:null};case ee.ERROR:return{command:null,error:`invalid command: ${r.value}`};default:return n&&(n.start!==void 0||n.end!==void 0)?{command:null,error:"command expected"}:{command:null}}}parseSimpleCommand(t,n){this.advance();let r=t.value;switch(r){case"p":return{command:{type:"print",address:n}};case"P":return{command:{type:"printFirstLine",address:n}};case"d":return{command:{type:"delete",address:n}};case"D":return{command:{type:"deleteFirstLine",address:n}};case"h":return{command:{type:"hold",address:n}};case"H":return{command:{type:"holdAppend",address:n}};case"g":return{command:{type:"get",address:n}};case"G":return{command:{type:"getAppend",address:n}};case"x":return{command:{type:"exchange",address:n}};case"n":return{command:{type:"next",address:n}};case"N":return{command:{type:"nextAppend",address:n}};case"q":return{command:{type:"quit",address:n}};case"Q":return{command:{type:"quitSilent",address:n}};case"z":return{command:{type:"zap",address:n}};case"=":return{command:{type:"lineNumber",address:n}};case"l":return{command:{type:"list",address:n}};case"F":return{command:{type:"printFilename",address:n}};default:return{command:null,error:`unknown command: ${r}`}}}parseSubstituteFromToken(t,n){this.advance();let r=t.flags||"",s,i=r.match(/(\d+)/);return i&&(s=parseInt(i[1],10)),{command:{type:"substitute",address:n,pattern:t.pattern||"",replacement:t.replacement||"",global:r.includes("g"),ignoreCase:r.includes("i")||r.includes("I"),printOnMatch:r.includes("p"),nthOccurrence:s,extendedRegex:this.extendedRegex}}}parseTransliterateFromToken(t,n){this.advance();let r=t.source||"",s=t.dest||"";return r.length!==s.length?{command:null,error:"transliteration sets must have same length"}:{command:{type:"transliterate",address:n,source:r,dest:s}}}parseTextCommand(t,n){let r=t.value,s=t.text||"";switch(r){case"a":return{command:{type:"append",address:n,text:s}};case"i":return{command:{type:"insert",address:n,text:s}};case"c":return{command:{type:"change",address:n,text:s}};default:return{command:null,error:`unknown text command: ${r}`}}}parseGroup(t){this.advance();let n=[];for(;!this.isAtEnd()&&!this.check(ee.RBRACE);){if(this.check(ee.NEWLINE)||this.check(ee.SEMICOLON)){this.advance();continue}let r=this.parseCommand();if(r.error)return{command:null,error:r.error};r.command&&n.push(r.command)}return this.check(ee.RBRACE)?(this.advance(),{command:{type:"group",address:t,commands:n}}):{command:null,error:"unmatched brace in grouped commands"}}parseAddressRange(){let t=this.parseAddress();if(t===void 0)return;let n;if(this.check(ee.RELATIVE_OFFSET))n={offset:this.advance().offset||0};else if(this.check(ee.COMMA)&&(this.advance(),n=this.parseAddress(),n===void 0))return{error:"expected context address"};return{address:{start:t,end:n}}}parseAddress(){let t=this.peek();switch(t.type){case ee.NUMBER:return this.advance(),t.value;case ee.DOLLAR:return this.advance(),"$";case ee.PATTERN:return this.advance(),{pattern:t.pattern||t.value};case ee.STEP:return this.advance(),{first:t.first||0,step:t.step||0};case ee.RELATIVE_OFFSET:return this.advance(),{offset:t.offset||0};default:return}}peek(){return this.tokens[this.pos]||{type:ee.EOF,value:"",line:0,column:0}}advance(){return this.isAtEnd()||this.pos++,this.tokens[this.pos-1]}check(t){return this.peek().type===t}isAtEnd(){return this.peek().type===ee.EOF}}});var g1={};K(g1,{flagsForFuzzing:()=>x4,sedCommand:()=>b4});async function wo(e,t,n,r={}){let{limits:s,filename:i,fs:a,cwd:o,coverage:l}=r,c=e.endsWith(`
|
|
271
271
|
`),u=e.split(`
|
|
272
|
-
`);u.length>0&&u[u.length-1]===""&&u.pop();let f=u.length,p="",h,m=!1,d=s?.maxStringLength??0,g=F=>{if(p+=F,d>0&&p.length>d)throw new te(`sed: output size limit exceeded (${d} bytes)`,"string_length")},
|
|
273
|
-
`)),S.set(J,0)}let H=x.get(J),X=S.get(J);H&&X!==void 0&&X<H.length&&(R.appendBuffer.push(H[X]),S.set(J,X+1))}}catch{}}for(let re of R.pendingFileWrites){let J=a.resolvePath(o,re.filename),H=$.get(J)||"";$.set(J,H+re.content)}}}while(R.restartCycle&&!R.deleted&&!R.quit&&!R.quitSilent);if(F+=R.linesConsumedInCycle,
|
|
272
|
+
`);u.length>0&&u[u.length-1]===""&&u.pop();let f=u.length,p="",h,m=!1,d=s?.maxStringLength??0,g=F=>{if(p+=F,d>0&&p.length>d)throw new te(`sed: output size limit exceeded (${d} bytes)`,"string_length")},w="",y,b=new Map,x=new Map,S=new Map,$=new Map,O=s?{maxIterations:s.maxSedIterations}:void 0;for(let F=0;F<u.length;F++){let R={...c1(f,i,b),patternSpace:u[F],holdSpace:w,lastPattern:y,lineNumber:F+1,totalLines:f,substitutionMade:!1,coverage:l},z={lines:u,currentLineIndex:F},k=0,N=1e4;R.linesConsumedInCycle=0;do{if(k++,k>N)break;if(R.restartCycle=!1,R.pendingFileReads=[],R.pendingFileWrites=[],go(t,R,z,O),a&&o){for(let re of R.pendingFileReads){let J=a.resolvePath(o,re.filename);try{if(re.wholeFile){let H=await a.readFile(J);R.appendBuffer.push(H.replace(/\n$/,""))}else{if(!x.has(J)){let Ee=await a.readFile(J);x.set(J,Ee.split(`
|
|
273
|
+
`)),S.set(J,0)}let H=x.get(J),X=S.get(J);H&&X!==void 0&&X<H.length&&(R.appendBuffer.push(H[X]),S.set(J,X+1))}}catch{}}for(let re of R.pendingFileWrites){let J=a.resolvePath(o,re.filename),H=$.get(J)||"";$.set(J,H+re.content)}}}while(R.restartCycle&&!R.deleted&&!R.quit&&!R.quitSilent);if(F+=R.linesConsumedInCycle,w=R.holdSpace,y=R.lastPattern,!n)for(let re of R.nCommandOutput)g(`${re}
|
|
274
274
|
`);let P=R.lineNumberOutput.length>0;for(let re of R.lineNumberOutput)g(`${re}
|
|
275
275
|
`);let v=[],T=[];for(let re of R.appendBuffer)re.startsWith("__INSERT__")?v.push(re.slice(10)):T.push(re);for(let re of v)g(`${re}
|
|
276
276
|
`);let L=!1;!R.deleted&&!R.quitSilent?n?R.printed&&(g(`${R.patternSpace}
|
|
@@ -307,17 +307,17 @@ Addresses:
|
|
|
307
307
|
$ last line
|
|
308
308
|
/regexp/ lines matching regexp
|
|
309
309
|
N,M range from line N to M
|
|
310
|
-
first~step every step-th line starting at first`};b4={name:"sed",async execute(e,t){if(U(e))return M(w4);let n=[],r=[],s=!1,i=!1,a=!1,o=[];for(let m=0;m<e.length;m++){let d=e[m];if(d==="-n"||d==="--quiet"||d==="--silent")s=!0;else if(d==="-i"||d==="--in-place")i=!0;else if(d.startsWith("-i"))i=!0;else if(d==="-E"||d==="-r"||d==="--regexp-extended")a=!0;else if(d==="-e")m+1<e.length&&n.push(e[++m]);else if(d==="-f")m+1<e.length&&r.push(e[++m]);else{if(d.startsWith("--"))return Y("sed",d);if(d==="-")o.push(d);else if(d.startsWith("-")&&d.length>1){for(let g of d.slice(1))if(g!=="n"&&g!=="e"&&g!=="f"&&g!=="i"&&g!=="E"&&g!=="r")return Y("sed",`-${g}`);d.includes("n")&&(s=!0),d.includes("i")&&(i=!0),(d.includes("E")||d.includes("r"))&&(a=!0),d.includes("e")&&!d.includes("n")&&!d.includes("i")&&m+1<e.length&&n.push(e[++m]),d.includes("f")&&!d.includes("e")&&m+1<e.length&&r.push(e[++m])}else!d.startsWith("-")&&n.length===0&&r.length===0?n.push(d):d.startsWith("-")||o.push(d)}}for(let m of r){let d=t.fs.resolvePath(t.cwd,m);try{let g=await t.fs.readFile(d);for(let
|
|
311
|
-
`)){let w
|
|
310
|
+
first~step every step-th line starting at first`};b4={name:"sed",async execute(e,t){if(U(e))return M(w4);let n=[],r=[],s=!1,i=!1,a=!1,o=[];for(let m=0;m<e.length;m++){let d=e[m];if(d==="-n"||d==="--quiet"||d==="--silent")s=!0;else if(d==="-i"||d==="--in-place")i=!0;else if(d.startsWith("-i"))i=!0;else if(d==="-E"||d==="-r"||d==="--regexp-extended")a=!0;else if(d==="-e")m+1<e.length&&n.push(e[++m]);else if(d==="-f")m+1<e.length&&r.push(e[++m]);else{if(d.startsWith("--"))return Y("sed",d);if(d==="-")o.push(d);else if(d.startsWith("-")&&d.length>1){for(let g of d.slice(1))if(g!=="n"&&g!=="e"&&g!=="f"&&g!=="i"&&g!=="E"&&g!=="r")return Y("sed",`-${g}`);d.includes("n")&&(s=!0),d.includes("i")&&(i=!0),(d.includes("E")||d.includes("r"))&&(a=!0),d.includes("e")&&!d.includes("n")&&!d.includes("i")&&m+1<e.length&&n.push(e[++m]),d.includes("f")&&!d.includes("e")&&m+1<e.length&&r.push(e[++m])}else!d.startsWith("-")&&n.length===0&&r.length===0?n.push(d):d.startsWith("-")||o.push(d)}}for(let m of r){let d=t.fs.resolvePath(t.cwd,m);try{let g=await t.fs.readFile(d);for(let w of g.split(`
|
|
311
|
+
`)){let y=w.trim();y&&!y.startsWith("#")&&n.push(y)}}catch{return{stdout:"",stderr:`sed: couldn't open file ${m}: No such file or directory
|
|
312
312
|
`,exitCode:1}}}if(n.length===0)return{stdout:"",stderr:`sed: no script specified
|
|
313
313
|
`,exitCode:1};let{commands:l,error:c,silentMode:u}=p1(n,a);if(c)return{stdout:"",stderr:`sed: ${c}
|
|
314
314
|
`,exitCode:1};let f=!!(s||u);if(i){if(o.length===0)return{stdout:"",stderr:`sed: -i requires at least one file argument
|
|
315
|
-
`,exitCode:1};for(let m of o){if(m==="-")continue;let d=t.fs.resolvePath(t.cwd,m);try{let g=await t.fs.readFile(d),
|
|
316
|
-
`,exitCode:
|
|
315
|
+
`,exitCode:1};for(let m of o){if(m==="-")continue;let d=t.fs.resolvePath(t.cwd,m);try{let g=await t.fs.readFile(d),w=await wo(g,l,f,{limits:t.limits,filename:m,fs:t.fs,cwd:t.cwd,coverage:t.coverage});if(w.errorMessage)return{stdout:"",stderr:`${w.errorMessage}
|
|
316
|
+
`,exitCode:w.exitCode??1};await t.fs.writeFile(d,w.output)}catch(g){return g instanceof te?{stdout:"",stderr:`sed: ${g.message}
|
|
317
317
|
`,exitCode:te.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory
|
|
318
318
|
`,exitCode:1}}}return{stdout:"",stderr:"",exitCode:0}}let p="";if(o.length===0){p=t.stdin;try{let m=await wo(p,l,f,{limits:t.limits,fs:t.fs,cwd:t.cwd,coverage:t.coverage});return{stdout:m.output,stderr:m.errorMessage?`${m.errorMessage}
|
|
319
319
|
`:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof te)return{stdout:"",stderr:`sed: ${m.message}
|
|
320
|
-
`,exitCode:te.EXIT_CODE};throw m}}let h=!1;for(let m of o){let d;if(m==="-")h?d="":(d=t.stdin,h=!0);else{let g=t.fs.resolvePath(t.cwd,m);try{d=await t.fs.readFile(g)}catch(
|
|
320
|
+
`,exitCode:te.EXIT_CODE};throw m}}let h=!1;for(let m of o){let d;if(m==="-")h?d="":(d=t.stdin,h=!0);else{let g=t.fs.resolvePath(t.cwd,m);try{d=await t.fs.readFile(g)}catch(w){return w instanceof te?{stdout:"",stderr:`sed: ${w.message}
|
|
321
321
|
`,exitCode:te.EXIT_CODE}:{stdout:"",stderr:`sed: ${m}: No such file or directory
|
|
322
322
|
`,exitCode:1}}}p.length>0&&d.length>0&&!p.endsWith(`
|
|
323
323
|
`)&&(p+=`
|
|
@@ -325,7 +325,7 @@ Addresses:
|
|
|
325
325
|
`:"",exitCode:m.exitCode??0}}catch(m){if(m instanceof te)return{stdout:"",stderr:`sed: ${m.message}
|
|
326
326
|
`,exitCode:te.EXIT_CODE};throw m}}},x4={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 Et(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 oi(...e){return Object.assign(Object.create(null),...e)}var Pn=I(()=>{"use strict"});function bo(e={}){let{fieldSep:t=S4,maxIterations:n=E4,maxRecursionDepth:r=A4,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 E4,A4,S4,w1=I(()=>{"use strict";Me();E4=1e4,A4=100,S4=new Cn(/\s+/)});function b1(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 x1=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 li(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 A1(e,t){return e?e.type==="variable"?e.name:e.type==="field"?`$${Math.floor(Zt(await t.evalExpr(e.index)))}`:"$0":"$0"}function S1(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 C1(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 C4(e,t,n){return e.length===0?t.line.length:ut(await n.evalExpr(e[0])).length}async function N4(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 k4(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 v4(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=G(l.pattern);else{let c=ut(await n.evalExpr(l));a=c===" "?G("\\s+"):c}}else t.FS===" "&&(a=G("\\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 I4(e,t,n){if(e.length<2)return 0;let r=await li(e[0],n),s=ut(await n.evalExpr(e[1])),i=await A1(e[2],n),a=S1(i,t);try{let l=G(r).replace(a,N1(s)),c=l!==a?1:0;return C1(i,l,t),c}catch{return 0}}async function $4(e,t,n){if(e.length<2)return 0;let r=await li(e[0],n),s=ut(await n.evalExpr(e[1])),i=await A1(e[2],n),a=S1(i,t);try{let o=G(r,"g"),l=o.match(a),c=l?l.length:0,u=o.replace(a,N1(s));return C1(i,u,t),c}catch{return 0}}function N1(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 O4(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 li(e[1],n);try{let a=G(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 R4(e,t,n){if(e.length<3)return"";let r=await li(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 G(r,"g").replace(a,(u,...f)=>E1(s,u,f.slice(0,-2)));{let c=0;return G(r,"g").replace(a,(f,...p)=>(c++,c===l?E1(s,f,p.slice(0,-2)):f))}}catch{return a}}function E1(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
|
-
`,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 T4(e,t,n){return e.length===0?"":ut(await n.evalExpr(e[0])).toLowerCase()}async function P4(e,t,n){return e.length===0?"":ut(await n.evalExpr(e[0])).toUpperCase()}async function D4(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 ci(r,s)}async function _4(e,t,n){return e.length===0?0:Math.floor(Zt(await n.evalExpr(e[0])))}async function L4(e,t,n){return e.length===0?0:Math.sqrt(Zt(await n.evalExpr(e[0])))}async function F4(e,t,n){return e.length===0?0:Math.sin(Zt(await n.evalExpr(e[0])))}async function M4(e,t,n){return e.length===0?0:Math.cos(Zt(await n.evalExpr(e[0])))}async function U4(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 W4(e,t,n){return e.length===0?0:Math.log(Zt(await n.evalExpr(e[0])))}async function B4(e,t,n){return e.length===0?1:Math.exp(Zt(await n.evalExpr(e[0])))}function z4(e,t,n){return t.random?t.random():Math.random()}async function H4(e,t,n){let r=e.length>0?Zt(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=r,r}function j4(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function xo(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}function ci(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,
|
|
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 T4(e,t,n){return e.length===0?"":ut(await n.evalExpr(e[0])).toLowerCase()}async function P4(e,t,n){return e.length===0?"":ut(await n.evalExpr(e[0])).toUpperCase()}async function D4(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 ci(r,s)}async function _4(e,t,n){return e.length===0?0:Math.floor(Zt(await n.evalExpr(e[0])))}async function L4(e,t,n){return e.length===0?0:Math.sqrt(Zt(await n.evalExpr(e[0])))}async function F4(e,t,n){return e.length===0?0:Math.sin(Zt(await n.evalExpr(e[0])))}async function M4(e,t,n){return e.length===0?0:Math.cos(Zt(await n.evalExpr(e[0])))}async function U4(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 W4(e,t,n){return e.length===0?0:Math.log(Zt(await n.evalExpr(e[0])))}async function B4(e,t,n){return e.length===0?1:Math.exp(Zt(await n.evalExpr(e[0])))}function z4(e,t,n){return t.random?t.random():Math.random()}async function H4(e,t,n){let r=e.length>0?Zt(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=r,r}function j4(e,t){return()=>{throw new Error(`${e}() is not supported - ${t}`)}}function xo(e){return()=>{throw new Error(`function '${e}()' is not implemented`)}}function ci(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
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,k1,Eo=I(()=>{"use strict";Me();Qn=1e4;k1=new Map([["length",C4],["substr",N4],["index",k4],["split",v4],["sub",I4],["gsub",$4],["match",O4],["gensub",R4],["tolower",T4],["toupper",P4],["sprintf",D4],["int",_4],["sqrt",L4],["sin",F4],["cos",M4],["atan2",U4],["log",W4],["exp",B4],["rand",z4],["srand",H4],["system",j4("system","shell execution not allowed in sandboxed environment")],["close",()=>0],["fflush",()=>0],["systime",xo("systime")],["mktime",xo("mktime")],["strftime",xo("strftime")]])});function At(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 Ao(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 G(e).test(t)}catch{return!1}}var Cr=I(()=>{"use strict";Me()});function v1(e,t){return t===""?[]:e.FS===" "?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function ui(e,t){return t===0?e.line:t<0||t>e.fields.length?"":e.fields[t-1]??""}function So(e,t,n){if(t===0)e.line=$e(n),e.fields=v1(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=v1(e,t),e.NF=e.fields.length}function I1(e,t){if(e.FS=t,t===" ")e.fieldSep=new Cn(/\s+/);else try{e.fieldSep=G(t)}catch{e.fieldSep=G(t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}}var fi=I(()=>{"use strict";Me();Cr()});function pi(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":I1(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 hi(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 Co(e,t,n,r){let s=us(e,t);e.arrays[s]||(e.arrays[s]=Object.create(null)),e.arrays[s][n]=r}function $1(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 O1(e,t,n){let r=us(e,t);e.arrays[r]&&delete e.arrays[r][n]}function R1(e,t){let n=us(e,t);delete e.arrays[n]}var No=I(()=>{"use strict";fi();Cr()});function T1(e){ko=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 V4(e,t);case"variable":return pi(e,t.name);case"array_access":return G4(e,t);case"binary":return q4(e,t);case"unary":return Q4(e,t);case"ternary":return At(await le(e,t.condition))?await le(e,t.consequent):await le(e,t.alternate);case"call":return X4(e,t.name,t.args);case"assignment":return J4(e,t);case"pre_increment":return e3(e,t.operand);case"pre_decrement":return t3(e,t.operand);case"post_increment":return n3(e,t.operand);case"post_decrement":return r3(e,t.operand);case"in":return s3(e,t.key,t.array);case"getline":return i3(e,t.variable,t.file,t.command);case"tuple":return l3(e,t.elements);default:return""}}async function V4(e,t){let n=Math.floor(He(await le(e,t.index)));return ui(e,n)}async function G4(e,t){let n=$e(await le(e,t.key));return hi(e,t.array,n)}async function q4(e,t){let n=t.operator;if(n==="||")return At(await le(e,t.left))||At(await le(e,t.right))?1:0;if(n==="&&")return At(await le(e,t.left))&&At(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 G(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 G(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(Z4(n))return K4(r,s,n);let i=He(r),a=He(s);return b1(i,a,n)}function Z4(e){return["<","<=",">",">=","==","!="].includes(e)}function K4(e,t,n){let r=Ao(e),s=Ao(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 Q4(e,t){let n=await le(e,t.operand);switch(t.operator){case"!":return At(n)?0:1;case"-":return-He(n);case"+":return+He(n);default:return n}}async function X4(e,t,n){let r=k1.get(t);if(r)return r(n,e,{evalExpr:i=>le(e,i)});let s=e.functions.get(t);return s?Y4(e,s,n):""}async function Y4(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,ko&&await ko(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 J4(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=ui(e,c)}else if(r.type==="variable")a=pi(e,r.name);else{let c=$e(await le(e,r.key));a=hi(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)));So(e,a,i)}else if(r.type==="variable")kr(e,r.name,i);else{let a=$e(await le(e,r.key));Co(e,r.array,a,i)}return i}async function di(e,t,n,r){let s;if(t.type==="field"){let i=Math.floor(He(await le(e,t.index)));s=He(ui(e,i)),So(e,i,s+n)}else if(t.type==="variable")s=He(pi(e,t.name)),kr(e,t.name,s+n);else{let i=$e(await le(e,t.key));s=He(hi(e,t.array,i)),Co(e,t.array,i,s+n)}return r?s+n:s}async function e3(e,t){return di(e,t,1,!0)}async function t3(e,t){return di(e,t,-1,!0)}async function n3(e,t){return di(e,t,1,!1)}async function r3(e,t){return di(e,t,-1,!1)}async function s3(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 $1(e,n,r)?1:0}async function i3(e,t,n,r){if(r)return a3(e,t,r);if(n)return o3(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 a3(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 o3(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
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 l3(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 ko,vo=I(()=>{"use strict";ye();Me();x1();Eo();fi();Cr();No();ko=null});function Io(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),c3(e))break}function c3(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 u3(e,t.args,t.output);break;case"printf":await f3(e,t.format,t.args,t.output);break;case"if":await p3(e,t);break;case"while":await h3(e,t);break;case"do_while":await d3(e,t);break;case"for":await m3(e,t);break;case"for_in":await g3(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 y3(e,t.target);break}}async function u3(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(ci(e.OFMT,[a])):r.push($e(a))}let s=r.join(e.OFS)+e.ORS;n?await P1(e,n.redirect,n.file,s):(e.output+=s,Io(e))}async function f3(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=ci(s,i);r?await P1(e,r.redirect,r.file,a):(e.output+=a,Io(e))}async function P1(e,t,n,r){if(!e.fs||!e.cwd){e.output+=r,Io(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 p3(e,t){At(await le(e,t.condition))?await Xn(e,t.consequent):t.alternate&&await Xn(e,t.alternate)}async function h3(e,t){let n=0;for(;At(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 d3(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(At(await le(e,t.condition)))}async function m3(e,t){t.init&&await le(e,t.init);let n=0;for(;!t.condition||At(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 g3(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 y3(e,t){if(t.type==="array_access"){let n=$e(await le(e,t.key));O1(e,t.array,n)}else t.type==="variable"&&R1(e,t.name)}var D1=I(()=>{"use strict";ye();Eo();vo();Cr();No();T1(vr)});var fs,_1=I(()=>{"use strict";vo();fi();D1();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 At(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 At(await le(this.ctx,t.expression));default:return!1}}}});var L1=I(()=>{"use strict";w1();_1()});function b3(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,w3,mi,F1=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={}));w3=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]]);mi=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===`
|
|
@@ -336,13 +336,13 @@ Addresses:
|
|
|
336
336
|
`,line:t,column:n}):r==='"'?this.readString():r==="/"&&this.canBeRegex()?this.readRegex():this.isDigit(r)||r==="."&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(r)||r==="_"?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,A.NEWLINE,A.SEMICOLON,A.LBRACE,A.RBRACE,A.LPAREN,A.LBRACKET,A.COMMA,A.ASSIGN,A.PLUS_ASSIGN,A.MINUS_ASSIGN,A.STAR_ASSIGN,A.SLASH_ASSIGN,A.PERCENT_ASSIGN,A.CARET_ASSIGN,A.AND,A.OR,A.NOT,A.MATCH,A.NOT_MATCH,A.QUESTION,A.COLON,A.LT,A.GT,A.LE,A.GE,A.EQ,A.NE,A.PLUS,A.MINUS,A.STAR,A.PERCENT,A.CARET,A.PRINT,A.PRINTF,A.IF,A.WHILE,A.DO,A.FOR,A.RETURN]).has(this.lastTokenType)}readString(){let t=this.line,n=this.column;this.advance();let r="";for(;this.pos<this.input.length&&this.peek()!=='"';)if(this.peek()==="\\"){this.advance();let s=this.advance();switch(s){case"n":r+=`
|
|
337
337
|
`;break;case"t":r+=" ";break;case"r":r+="\r";break;case"f":r+="\f";break;case"b":r+="\b";break;case"v":r+="\v";break;case"a":r+="\x07";break;case"\\":r+="\\";break;case'"':r+='"';break;case"/":r+="/";break;case"x":{let i="";for(;i.length<2&&/[0-9a-fA-F]/.test(this.peek());)i+=this.advance();i.length>0?r+=String.fromCharCode(parseInt(i,16)):r+="x";break}default:if(/[0-7]/.test(s)){let i=s;for(;i.length<3&&/[0-7]/.test(this.peek());)i+=this.advance();r+=String.fromCharCode(parseInt(i,8))}else r+=s}}else r+=this.advance();return this.peek()==='"'&&this.advance(),{type:A.STRING,value:r,line:t,column:n}}readRegex(){let t=this.line,n=this.column;this.advance();let r="";for(;this.pos<this.input.length&&this.peek()!=="/";)if(this.peek()==="\\")r+=this.advance(),this.pos<this.input.length&&(r+=this.advance());else{if(this.peek()===`
|
|
338
338
|
`)break;r+=this.advance()}return this.peek()==="/"&&this.advance(),r=b3(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=w3.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 z1(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(gi(e));e.check(Z.COMMA);)e.advance(),t.push(gi(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 gi(e){return x3(e)?$o(e,!0):$o(e,!1)}function $o(e,t){let n=t?e.parseTernary():E3(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=$o(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 x3(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 E3(e){let t=M1(e);for(;e.check(Z.OR);){e.advance();let n=M1(e);t={type:"binary",operator:"||",left:t,right:n}}return t}function M1(e){let t=U1(e);for(;e.check(Z.AND);){e.advance();let n=U1(e);t={type:"binary",operator:"&&",left:t,right:n}}return t}function U1(e){let t=A3(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 A3(e){let t=W1(e);for(;S3(e)&&!C3(e);){let n=W1(e);t={type:"binary",operator:" ",left:t,right:n}}return t}function W1(e){let t=B1(e);for(;e.match(Z.MATCH,Z.NOT_MATCH);){let n=e.advance().type===Z.MATCH?"~":"!~",r=B1(e);t={type:"binary",operator:n,left:t,right:r}}return t}function B1(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 S3(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 C3(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 H1(e){e.expect(Z.PRINTF);let t=e.check(Z.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():gi(e),r=[];for(;e.check(Z.COMMA);)e.advance(),t&&e.skipNewlines(),r.push(t?e.parseExpression():gi(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,j1=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 yi,V1=I(()=>{"use strict";F1();j1();yi=class{tokens=[];pos=0;parse(t){let n=new mi(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)?z1(this):this.check(A.PRINTF)?H1(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 Z1={};K(Z1,{awkCommand2:()=>k3,flagsForFuzzing:()=>v3});function Oo(e){return e.replace(/\\t/g," ").replace(/\\n/g,`
|
|
339
|
-
`).replace(/\\r/g,"\r").replace(/\\b/g,"\b").replace(/\\f/g,"\f").replace(/\\a/g,"\x07").replace(/\\v/g,"\v").replace(/\\\\/g,"\\")}function G1(e){if(e===" ")return G("\\s+");if(/[[\](){}.*+?^$|\\]/.test(e))try{return G(e)}catch{return G(q1(e))}return G(q1(e))}function q1(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var N3,k3,v3,K1=I(()=>{"use strict";Pn();ye();Me();se();L1();V1();N3={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"]},k3={name:"awk",async execute(e,t){if(U(e))return M(N3);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=Oo(e[++d]),n=G1(r),i=d+1;else if(g.startsWith("-F"))r=Oo(g.slice(2)),n=G1(r),i=d+1;else if(g==="-v"&&d+1<e.length){let
|
|
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 G("\\s+");if(/[[\](){}.*+?^$|\\]/.test(e))try{return G(e)}catch{return G(q1(e))}return G(q1(e))}function q1(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var N3,k3,v3,K1=I(()=>{"use strict";Pn();ye();Me();se();L1();V1();N3={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"]},k3={name:"awk",async execute(e,t){if(U(e))return M(N3);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=Oo(e[++d]),n=G1(r),i=d+1;else if(g.startsWith("-F"))r=Oo(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=Oo(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 yi,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
|
|
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=bo({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=Et(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
|
-
`);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),
|
|
345
|
-
`,exitCode:
|
|
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}
|
|
345
|
+
`,exitCode:w}}}};v3={name:"awk",flags:[{flag:"-F",type:"value",valueHint:"delimiter"},{flag:"-v",type:"value",valueHint:"string"}],stdinType:"text",needsArgs:!0}});function Q1(e){let t=e.trim(),n=t.match(/^([+-]?\d*\.?\d+)\s*([kmgtpeKMGTPE])?[iI]?[bB]?$/);if(!n){let a=parseFloat(t);return Number.isNaN(a)?0:a}let r=parseFloat(n[1]),s=(n[2]||"").toLowerCase(),i=I3.get(s)??1;return r*i}function X1(e){let t=e.trim().toLowerCase().slice(0,3);return $3.get(t)??0}function O3(e,t){let n=e.split(/(\d+)/),r=t.split(/(\d+)/),s=Math.max(n.length,r.length);for(let i=0;i<s;i++){let a=n[i]||"",o=r[i]||"",l=/^\d+$/.test(a)?parseInt(a,10):null,c=/^\d+$/.test(o)?parseInt(o,10):null;if(l!==null&&c!==null){if(l!==c)return l-c}else if(a!==o)return a.localeCompare(o)}return 0}function Y1(e){return e.replace(/[^a-zA-Z0-9\s]/g,"")}function Ro(e,t,n){let r=n!==null?n:/\s+/,s=e.split(r),i=t.startField-1;if(i>=s.length)return"";if(t.endField===void 0){let l=s[i]||"";return t.startChar!==void 0&&(l=l.slice(t.startChar-1)),t.ignoreLeading&&(l=l.trimStart()),l}let a=Math.min(t.endField-1,s.length-1),o="";for(let l=i;l<=a&&l<s.length;l++){let c=s[l]||"";if(l===i&&t.startChar!==void 0&&(c=c.slice(t.startChar-1)),l===a&&t.endChar!==void 0){let u=l===i&&t.startChar!==void 0?t.endChar-t.startChar+1:t.endChar;c=c.slice(0,u)}l>i&&(o+=n||" "),o+=c}return t.ignoreLeading&&(o=o.trimStart()),o}function J1(e,t,n){let r=e,s=t;if(n.dictionaryOrder&&(r=Y1(r),s=Y1(s)),n.ignoreCase&&(r=r.toLowerCase(),s=s.toLowerCase()),n.monthSort){let i=X1(r),a=X1(s);return i-a}if(n.humanNumeric){let i=Q1(r),a=Q1(s);return i-a}if(n.versionSort)return O3(r,s);if(n.numeric){let i=parseFloat(r)||0,a=parseFloat(s)||0;return i-a}return r.localeCompare(s)}function ep(e){let{keys:t,fieldDelimiter:n,numeric:r,ignoreCase:s,reverse:i,humanNumeric:a,versionSort:o,dictionaryOrder:l,monthSort:c,ignoreLeadingBlanks:u,stable:f}=e;return(p,h)=>{let m=p,d=h;if(u&&(m=m.trimStart(),d=d.trimStart()),t.length===0){let w=J1(m,d,{numeric:r,ignoreCase:s,humanNumeric:a,versionSort:o,dictionaryOrder:l,monthSort:c});if(w!==0)return i?-w:w;if(!f){let y=p.localeCompare(h);return i?-y:y}return 0}for(let g of t){let w=Ro(m,g,n),y=Ro(d,g,n);g.ignoreLeading&&(w=w.trimStart(),y=y.trimStart());let b={numeric:g.numeric??r,ignoreCase:g.ignoreCase??s,humanNumeric:g.humanNumeric??a,versionSort:g.versionSort??o,dictionaryOrder:g.dictionaryOrder??l,monthSort:g.monthSort??c},x=g.reverse??i,S=J1(w,y,b);if(S!==0)return x?-S:S}if(!f){let g=p.localeCompare(h);return i?-g:g}return 0}}function tp(e,t){if(t.keys.length===0){if(t.ignoreCase){let s=new Set;return e.filter(i=>{let a=i.toLowerCase();return s.has(a)?!1:(s.add(a),!0)})}return[...new Set(e)]}let n=t.keys[0],r=new Set;return e.filter(s=>{let i=Ro(s,n,t.fieldDelimiter);return(n.ignoreCase??t.ignoreCase)&&(i=i.toLowerCase()),r.has(i)?!1:(r.add(i),!0)})}var I3,$3,np=I(()=>{"use strict";I3=new Map([["",1],["k",1024],["m",1048576],["g",1073741824],["t",1099511627776],["p",0x4000000000000],["e",1152921504606847e3]]),$3=new Map([["jan",1],["feb",2],["mar",3],["apr",4],["may",5],["jun",6],["jul",7],["aug",8],["sep",9],["oct",10],["nov",11],["dec",12]])});function wi(e){let t={startField:1},n="",r=e,s=r.match(/([bdfhMnrV]+)$/);s&&(n=s[1],r=r.slice(0,-n.length)),n.includes("n")&&(t.numeric=!0),n.includes("r")&&(t.reverse=!0),n.includes("f")&&(t.ignoreCase=!0),n.includes("b")&&(t.ignoreLeading=!0),n.includes("h")&&(t.humanNumeric=!0),n.includes("V")&&(t.versionSort=!0),n.includes("d")&&(t.dictionaryOrder=!0),n.includes("M")&&(t.monthSort=!0);let i=r.split(",");if(i.length===0||i[0]==="")return null;let a=i[0].split("."),o=parseInt(a[0],10);if(Number.isNaN(o)||o<1)return null;if(t.startField=o,a.length>1&&a[1]){let l=parseInt(a[1],10);!Number.isNaN(l)&&l>=1&&(t.startChar=l)}if(i.length>1&&i[1]){let l=i[1],c=l.match(/([bdfhMnrV]+)$/);if(c){let f=c[1];f.includes("n")&&(t.numeric=!0),f.includes("r")&&(t.reverse=!0),f.includes("f")&&(t.ignoreCase=!0),f.includes("b")&&(t.ignoreLeading=!0),f.includes("h")&&(t.humanNumeric=!0),f.includes("V")&&(t.versionSort=!0),f.includes("d")&&(t.dictionaryOrder=!0),f.includes("M")&&(t.monthSort=!0),l=l.slice(0,-f.length)}let u=l.split(".");if(u[0]){let f=parseInt(u[0],10);if(!Number.isNaN(f)&&f>=1&&(t.endField=f),u.length>1&&u[1]){let p=parseInt(u[1],10);!Number.isNaN(p)&&p>=1&&(t.endChar=p)}}}return t}var rp=I(()=>{"use strict"});var sp={};K(sp,{flagsForFuzzing:()=>P3,sortCommand:()=>T3});var R3,T3,P3,ip=I(()=>{"use strict";Zn();se();np();rp();R3={name:"sort",summary:"sort lines of text files",usage:"sort [OPTION]... [FILE]...",options:["-b, --ignore-leading-blanks ignore leading blanks","-d, --dictionary-order consider only blanks and alphanumeric characters","-f, --ignore-case fold lower case to upper case characters","-h, --human-numeric-sort compare human readable numbers (e.g., 2K 1G)","-M, --month-sort compare (unknown) < 'JAN' < ... < 'DEC'","-n, --numeric-sort compare according to string numerical value","-r, --reverse reverse the result of comparisons","-V, --version-sort natural sort of (version) numbers within text","-c, --check check for sorted input; do not sort","-o, --output=FILE write result to FILE instead of stdout","-s, --stable stabilize sort by disabling last-resort comparison","-u, --unique output only unique lines","-k, --key=KEYDEF sort via a key; KEYDEF gives location and type","-t, --field-separator=SEP use SEP as field separator"," --help display this help and exit"],description:`KEYDEF is F[.C][OPTS][,F[.C][OPTS]]
|
|
346
346
|
F is a field number (1-indexed)
|
|
347
347
|
C is a character position within the field (1-indexed)
|
|
348
348
|
OPTS can be: b d f h M n r V (per-key modifiers)
|
|
@@ -357,11 +357,11 @@ Examples:
|
|
|
357
357
|
`,exitCode:1};return{stdout:"",stderr:"",exitCode:0}}a.sort(o),n.unique&&(a=tp(a,n));let l=a.length>0?`${a.join(`
|
|
358
358
|
`)}
|
|
359
359
|
`:"";if(n.outputFile){let c=t.fs.resolvePath(t.cwd,n.outputFile);return await t.fs.writeFile(c,l),{stdout:"",stderr:"",exitCode:0}}return{stdout:l,stderr:"",exitCode:0}}},P3={name:"sort",flags:[{flag:"-r",type:"boolean"},{flag:"-n",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-V",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-M",type:"boolean"},{flag:"-b",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"-k",type:"value",valueHint:"string"},{flag:"-t",type:"value",valueHint:"delimiter"},{flag:"-o",type:"value",valueHint:"path"}],stdinType:"text",needsFiles:!0}});var ap={};K(ap,{flagsForFuzzing:()=>F3,uniqCommand:()=>L3});var D3,_3,L3,F3,op=I(()=>{"use strict";Ze();Zn();se();D3={name:"uniq",summary:"report or omit repeated lines",usage:"uniq [OPTION]... [INPUT [OUTPUT]]",options:["-c, --count prefix lines by the number of occurrences","-d, --repeated only print duplicate lines","-i, --ignore-case ignore case when comparing","-u, --unique only print unique lines"," --help display this help and exit"]},_3={count:{short:"c",long:"count",type:"boolean"},duplicatesOnly:{short:"d",long:"repeated",type:"boolean"},uniqueOnly:{short:"u",long:"unique",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},L3={name:"uniq",async execute(e,t){if(U(e))return M(D3);let n=be("uniq",e,_3);if(!n.ok)return n.error;let{count:r,duplicatesOnly:s,uniqueOnly:i,ignoreCase:a}=n.result.flags,o=n.result.positional,l=await gr(t,o,{cmdName:"uniq"});if(!l.ok)return l.error;let u=l.content.split(`
|
|
360
|
-
`);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],p=u[0],h=1,m=(y
|
|
361
|
-
`:g+=`${
|
|
360
|
+
`);if(u.length>0&&u[u.length-1]===""&&u.pop(),u.length===0)return{stdout:"",stderr:"",exitCode:0};let f=[],p=u[0],h=1,m=(w,y)=>a?w.toLowerCase()===y.toLowerCase():w===y;for(let w=1;w<u.length;w++)m(u[w],p)?h++:(f.push({line:p,count:h}),p=u[w],h=1);f.push({line:p,count:h});let d=f;s?d=f.filter(w=>w.count>1):i&&(d=f.filter(w=>w.count===1));let g="";for(let{line:w,count:y}of d)r?g+=`${String(y).padStart(4)} ${w}
|
|
361
|
+
`:g+=`${w}
|
|
362
362
|
`;return{stdout:g,stderr:"",exitCode:0}}},F3={name:"uniq",flags:[{flag:"-c",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-u",type:"boolean"},{flag:"-i",type:"boolean"}],stdinType:"text",needsFiles:!0}});var lp={};K(lp,{commCommand:()=>U3,flagsForFuzzing:()=>W3});var M3,U3,W3,cp=I(()=>{"use strict";se();M3={name:"comm",summary:"compare two sorted files line by line",usage:"comm [OPTION]... FILE1 FILE2",options:["-1 suppress column 1 (lines unique to FILE1)","-2 suppress column 2 (lines unique to FILE2)","-3 suppress column 3 (lines that appear in both files)"," --help display this help and exit"]},U3={name:"comm",async execute(e,t){if(U(e))return M(M3);let n=!1,r=!1,s=!1,i=[];for(let g of e)if(g==="-1")n=!0;else if(g==="-2")r=!0;else if(g==="-3")s=!0;else if(g==="-12"||g==="-21")n=!0,r=!0;else if(g==="-13"||g==="-31")n=!0,s=!0;else if(g==="-23"||g==="-32")r=!0,s=!0;else if(g==="-123"||g==="-132"||g==="-213"||g==="-231"||g==="-312"||g==="-321")n=!0,r=!0,s=!0;else{if(g.startsWith("-")&&g!=="-")return Y("comm",g);i.push(g)}if(i.length!==2)return{stdout:"",stderr:`comm: missing operand
|
|
363
363
|
Try 'comm --help' for more information.
|
|
364
|
-
`,exitCode:1};let a=async g=>{if(g==="-")return t.stdin;try{let
|
|
364
|
+
`,exitCode:1};let a=async g=>{if(g==="-")return t.stdin;try{let w=t.fs.resolvePath(t.cwd,g);return await t.fs.readFile(w)}catch{return null}},o=await a(i[0]);if(o===null)return{stdout:"",stderr:`comm: ${i[0]}: No such file or directory
|
|
365
365
|
`,exitCode:1};let l=await a(i[1]);if(l===null)return{stdout:"",stderr:`comm: ${i[1]}: No such file or directory
|
|
366
366
|
`,exitCode:1};let c=o.split(`
|
|
367
367
|
`),u=l.split(`
|
|
@@ -372,7 +372,7 @@ Try 'comm --help' for more information.
|
|
|
372
372
|
`),p++):(s||(h+=`${d}${c[f]}
|
|
373
373
|
`),f++,p++);return{stdout:h,stderr:"",exitCode:0}}},W3={name:"comm",flags:[{flag:"-1",type:"boolean"},{flag:"-2",type:"boolean"},{flag:"-3",type:"boolean"}],needsArgs:!0,minArgs:2}});var up={};K(up,{cutCommand:()=>j3,flagsForFuzzing:()=>V3});function z3(e){let t=[],n=e.split(",");for(let r of n)if(r.includes("-")){let[s,i]=r.split("-");t.push({start:s?parseInt(s,10):1,end:i?parseInt(i,10):null})}else{let s=parseInt(r,10);t.push({start:s,end:s})}return t}function H3(e,t){let n=[];for(let r of t){let s=r.start-1,i=r.end===null?e.length:r.end;for(let a=s;a<i&&a<e.length;a++)a>=0&&!n.includes(e[a])&&n.push(e[a])}return n}var B3,j3,V3,fp=I(()=>{"use strict";Zn();se();B3={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};j3={name:"cut",async execute(e,t){if(U(e))return M(B3);let n=" ",r=null,s=null,i=!1,a=[];for(let p=0;p<e.length;p++){let h=e[p];if(h==="-d")n=e[++p]||" ";else if(h.startsWith("-d"))n=h.slice(2);else if(h==="-f")r=e[++p];else if(h.startsWith("-f"))r=h.slice(2);else if(h==="-c")s=e[++p];else if(h.startsWith("-c"))s=h.slice(2);else if(h==="-s"||h==="--only-delimited")i=!0;else{if(h.startsWith("--"))return Y("cut",h);if(h.startsWith("-")){let m=!1;for(let d of h.slice(1))if(d==="s")i=!0;else if(!"dfc".includes(d)){m=!0;break}if(m)return Y("cut",h)}else a.push(h)}}if(!r&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
|
|
374
374
|
`,exitCode:1};let o=await gr(t,a,{cmdName:"cut"});if(!o.ok)return o.error;let c=o.content.split(`
|
|
375
|
-
`);c.length>0&&c[c.length-1]===""&&c.pop();let u=z3(r||s||"1"),f="";for(let p of c)if(s){let h=p.split(""),m=[];for(let d of u){let g=d.start-1,
|
|
375
|
+
`);c.length>0&&c[c.length-1]===""&&c.pop();let u=z3(r||s||"1"),f="";for(let p of c)if(s){let h=p.split(""),m=[];for(let d of u){let g=d.start-1,w=d.end===null?h.length:d.end;for(let y=g;y<w&&y<h.length;y++)y>=0&&m.push(h[y])}f+=`${m.join("")}
|
|
376
376
|
`}else{if(i&&!p.includes(n))continue;let h=p.split(n),m=H3(h,u);f+=`${m.join(n)}
|
|
377
377
|
`}return{stdout:f,stderr:"",exitCode:0}}},V3={name:"cut",flags:[{flag:"-d",type:"value",valueHint:"delimiter"},{flag:"-f",type:"value",valueHint:"string"},{flag:"-c",type:"value",valueHint:"string"},{flag:"-s",type:"boolean"}],stdinType:"text",needsFiles:!0}});var hp={};K(hp,{flagsForFuzzing:()=>K3,pasteCommand:()=>Z3});function pp(e,t){if(e.length===0)return"";if(e.length===1)return e[0];let n=e[0];for(let r=1;r<e.length;r++){let s=(r-1)%t.length;n+=t[s]+e[r]}return n}var G3,q3,Z3,K3,dp=I(()=>{"use strict";Ze();se();G3={name:"paste",summary:"merge lines of files",usage:"paste [OPTION]... [FILE]...",description:["Write lines consisting of the sequentially corresponding lines from","each FILE, separated by TABs, to standard output.","","With no FILE, or when FILE is -, read standard input."],options:["-d, --delimiters=LIST reuse characters from LIST instead of TABs","-s, --serial paste one file at a time instead of in parallel"," --help display this help and exit"],examples:["paste file1 file2 Merge file1 and file2 side by side","paste -d, file1 file2 Use comma as delimiter","paste -s file1 Paste all lines of file1 on one line","paste - - < file Paste pairs of lines from file"]},q3={delimiter:{short:"d",long:"delimiters",type:"string",default:" "},serial:{short:"s",long:"serial",type:"boolean"}},Z3={name:"paste",async execute(e,t){if(U(e))return M(G3);let n=be("paste",e,q3);if(!n.ok)return n.error;let r=n.result.flags.delimiter,s=n.result.flags.serial,i=n.result.positional;if(i.length===0)return{stdout:"",stderr:`usage: paste [-s] [-d delimiters] file ...
|
|
378
378
|
`,exitCode:1};let a=t.stdin?t.stdin.split(`
|
|
@@ -474,10 +474,10 @@ Try 'comm --help' for more information.
|
|
|
474
474
|
`};n.suffixLength=u,s++}else if(c==="-d"||c==="--numeric-suffixes")n.useNumericSuffix=!0,s++;else if(c.startsWith("--additional-suffix="))n.additionalSuffix=c.slice(20),s++;else if(c==="--additional-suffix"&&s+1<e.length)n.additionalSuffix=e[s+1],s+=2;else if(c==="--"){r.push(...e.slice(s+1));break}else{if(c.startsWith("-")&&c!=="-")return Y("split",c);r.push(c),s++}}let i="-",a="x";r.length>=1&&(i=r[0]),r.length>=2&&(a=r[1]);let o;if(i==="-")o=t.stdin??"";else{let c=t.fs.resolvePath(t.cwd,i),u=await t.fs.readFile(c);if(u===null)return{exitCode:1,stdout:"",stderr:`split: ${i}: No such file or directory
|
|
475
475
|
`};o=u}if(o==="")return{exitCode:0,stdout:"",stderr:""};let l;switch(n.mode){case"lines":l=O8(o,n.lines);break;case"bytes":l=R8(o,n.bytes);break;case"chunks":l=T8(o,n.chunks);break;default:return n.mode}for(let c=0;c<l.length;c++){let u=l[c];if(!u.hasContent)continue;let f=$8(c,n.useNumericSuffix,n.suffixLength),p=`${a}${f}${n.additionalSuffix}`,h=t.fs.resolvePath(t.cwd,p);await t.fs.writeFile(h,u.content)}return{exitCode:0,stdout:"",stderr:""}}},D8={name:"split",flags:[{flag:"-l",type:"value",valueHint:"number"},{flag:"-b",type:"value",valueHint:"string"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-d",type:"boolean"},{flag:"-a",type:"value",valueHint:"number"}],needsFiles:!0}});var Bp={};K(Bp,{column:()=>W8,flagsForFuzzing:()=>B8});function Wp(e,t,n){return t?n?e.split(t):e.split(t).filter(r=>r.length>0):n?e.split(/[ \t]/):e.split(/[ \t]+/).filter(r=>r.length>0)}function F8(e){let t=[];for(let n of e)for(let r=0;r<n.length;r++){let s=n[r].length;(t[r]===void 0||s>t[r])&&(t[r]=s)}return t}function M8(e,t){if(e.length===0)return"";let n=F8(e),r=[];for(let s of e){let i=[];for(let a=0;a<s.length;a++)a===s.length-1?i.push(s[a]):i.push(s[a].padEnd(n[a]));r.push(i.join(t))}return r.join(`
|
|
476
476
|
`)}function U8(e,t,n){if(e.length===0)return"";let r=Math.max(...e.map(c=>c.length)),s=n.length,i=r+s,a=Math.max(1,Math.floor((t+s)/i)),o=Math.ceil(e.length/a),l=[];for(let c=0;c<o;c++){let u=[];for(let f=0;f<a;f++){let p=f*o+c;p<e.length&&(f===a-1||(f+1)*o+c>=e.length?u.push(e[p]):u.push(e[p].padEnd(r)))}l.push(u.join(n))}return l.join(`
|
|
477
|
-
`)}var _8,L8,W8,B8,zp=I(()=>{"use strict";Ze();se();_8={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},L8={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};W8={name:"column",execute:async(e,t)=>{if(U(e))return M(_8);let n=be("column",e,L8);if(!n.ok)return n.error;let{table:r,separator:s,outputSep:i,width:a,noMerge:o}=n.result.flags,l=n.result.positional,c=i??" ",u;if(l.length===0)u=t.stdin??"";else{let d=[];for(let g of l)if(g==="-")d.push(t.stdin??"");else{let
|
|
478
|
-
`};d.push(
|
|
477
|
+
`)}var _8,L8,W8,B8,zp=I(()=>{"use strict";Ze();se();_8={name:"column",summary:"columnate lists",usage:"column [OPTION]... [FILE]...",description:"Format input into multiple columns. By default, fills rows first. Use -t to create a table based on whitespace-delimited input.",options:["-t Create a table (determine columns from input)","-s SEP Input field delimiter (default: whitespace)","-o SEP Output field delimiter (default: two spaces)","-c WIDTH Output width for fill mode (default: 80)","-n Don't merge multiple adjacent delimiters"],examples:["ls | column # Fill columns with ls output","cat data | column -t # Format as table","column -t -s ',' file # Format CSV as table","column -c 40 file # Fill 40-char wide columns"]},L8={table:{short:"t",long:"table",type:"boolean"},separator:{short:"s",type:"string"},outputSep:{short:"o",type:"string"},width:{short:"c",type:"number",default:80},noMerge:{short:"n",type:"boolean"}};W8={name:"column",execute:async(e,t)=>{if(U(e))return M(_8);let n=be("column",e,L8);if(!n.ok)return n.error;let{table:r,separator:s,outputSep:i,width:a,noMerge:o}=n.result.flags,l=n.result.positional,c=i??" ",u;if(l.length===0)u=t.stdin??"";else{let d=[];for(let g of l)if(g==="-")d.push(t.stdin??"");else{let w=t.fs.resolvePath(t.cwd,g),y=await t.fs.readFile(w);if(y===null)return{exitCode:1,stdout:"",stderr:`column: ${g}: No such file or directory
|
|
478
|
+
`};d.push(y)}u=d.join("")}if(u===""||u.trim()==="")return{exitCode:0,stdout:"",stderr:""};let f=u.split(`
|
|
479
479
|
`);u.endsWith(`
|
|
480
|
-
`)&&f[f.length-1]===""&&f.pop();let h=f.filter(d=>d.trim().length>0),m;if(r){let d=h.map(g=>Wp(g,s,o));m=M8(d,c)}else{let d=[];for(let g of h){let
|
|
480
|
+
`)&&f[f.length-1]===""&&f.pop();let h=f.filter(d=>d.trim().length>0),m;if(r){let d=h.map(g=>Wp(g,s,o));m=M8(d,c)}else{let d=[];for(let g of h){let w=Wp(g,s,o);d.push(...w)}m=U8(d,a,c)}return m.length>0&&(m+=`
|
|
481
481
|
`),{exitCode:0,stdout:m,stderr:""}}},B8={name:"column",flags:[{flag:"-t",type:"boolean"},{flag:"-s",type:"value",valueHint:"delimiter"},{flag:"-o",type:"value",valueHint:"string"},{flag:"-c",type:"value",valueHint:"number"},{flag:"-n",type:"boolean"}],stdinType:"text",needsFiles:!0}});var Hp={};K(Hp,{flagsForFuzzing:()=>q8,join:()=>G8});function H8(e,t){return t?e.split(t):e.split(/[ \t]+/).filter(n=>n.length>0)}function j8(e,t,n,r){let s=H8(e,t),i=s[n-1]??"";return r&&(i=i.toLowerCase()),{fields:s,joinKey:i,original:e}}function To(e,t,n){let r=n.separator??" ";if(n.outputFormat){let a=[];for(let{file:o,field:l}of n.outputFormat){let c=o===1?e:t;c&&l===0?a.push(c.joinKey):c&&c.fields[l-1]!==void 0?a.push(c.fields[l-1]):a.push(n.emptyString)}return a.join(r)}let s=[],i=e?.joinKey??t?.joinKey??"";if(s.push(i),e)for(let a=0;a<e.fields.length;a++)a!==n.field1-1&&s.push(e.fields[a]);if(t)for(let a=0;a<t.fields.length;a++)a!==n.field2-1&&s.push(t.fields[a]);return s.join(r)}function V8(e){let t=e.split(","),n=[];for(let r of t){let s=r.trim().match(/^(\d+)\.(\d+)$/);if(!s)return null;let i=Number.parseInt(s[1],10),a=Number.parseInt(s[2],10);if(i!==1&&i!==2)return null;n.push({file:i,field:a})}return n}var z8,G8,q8,jp=I(()=>{"use strict";se();z8={name:"join",summary:"join lines of two files on a common field",usage:"join [OPTION]... FILE1 FILE2",description:"For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks.",options:["-1 FIELD Join on this FIELD of file 1 (default: 1)","-2 FIELD Join on this FIELD of file 2 (default: 1)","-t CHAR Use CHAR as input and output field separator","-a FILENUM Also print unpairable lines from file FILENUM (1 or 2)","-v FILENUM Like -a but only output unpairable lines","-e STRING Replace missing fields with STRING","-o FORMAT Output format (comma-separated list of FILENUM.FIELD)","-i Ignore case when comparing fields"],examples:["join file1 file2 # Join on first field","join -1 2 -2 1 file1 file2 # Join file1 col 2 with file2 col 1","join -t ',' file1.csv file2.csv # Join CSV files","join -a 1 file1 file2 # Left outer join"]};G8={name:"join",execute:async(e,t)=>{if(U(e))return M(z8);let n={field1:1,field2:1,separator:null,printUnpairable:new Set,onlyUnpairable:new Set,emptyString:"",outputFormat:null,ignoreCase:!1},r=[],s=0;for(;s<e.length;){let p=e[s];if(p==="-1"&&s+1<e.length){let h=Number.parseInt(e[s+1],10);if(Number.isNaN(h)||h<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${e[s+1]}'
|
|
482
482
|
`};n.field1=h,s+=2}else if(p==="-2"&&s+1<e.length){let h=Number.parseInt(e[s+1],10);if(Number.isNaN(h)||h<1)return{exitCode:1,stdout:"",stderr:`join: invalid field number: '${e[s+1]}'
|
|
483
483
|
`};n.field2=h,s+=2}else if((p==="-t"||p==="--field-separator")&&s+1<e.length)n.separator=e[s+1],s+=2;else if(p.startsWith("-t")&&p.length>2)n.separator=p.slice(2),s++;else if(p==="-a"&&s+1<e.length){let h=Number.parseInt(e[s+1],10);if(h!==1&&h!==2)return{exitCode:1,stdout:"",stderr:`join: invalid file number: '${e[s+1]}'
|
|
@@ -493,8 +493,8 @@ Try 'comm --help' for more information.
|
|
|
493
493
|
`:"",stderr:""}}},q8={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 Vp={};K(Vp,{flagsForFuzzing:()=>X8,teeCommand:()=>Q8});var Z8,K8,Q8,X8,Gp=I(()=>{"use strict";Ze();se();Z8={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"]},K8={append:{short:"a",long:"append",type:"boolean"}},Q8={name:"tee",async execute(e,t){if(U(e))return M(Z8);let n=be("tee",e,K8);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
494
|
`,o=1}return{stdout:i,stderr:a,exitCode:o}}},X8={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:xt(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:xt(r,n,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let n=e.ignoreCase?"i":"";return{matches:G(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 qp(e){let t={terminalDirName:null,requiredExtension:null};if(!e)return t;let n=Y8(e);if(J8(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 Y8(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 J8(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 Zp(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:xt(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:xt(n,i,e.ignoreCase),pruned:!1,printed:!1}}case"regex":try{let i=e.ignoreCase?"i":"";return{matches:G(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 Kp(e,t){if(!e||!t.isDirectory)return{shouldPrune:!1};if(!Dn(e))return Po(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 Po(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 Po(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?Po(e.right,t):{shouldPrune:!1}}return{shouldPrune:!1}}case"not":return{shouldPrune:!1};default:return{shouldPrune:!1}}}var Qp=I(()=>{"use strict";Me();so()});function Xp(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
|
-
`,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let i=e9(n);return i.error?{expr:null,pathIndex:s,error:i.error,actions:r}:{expr:i.expr,pathIndex:s,actions:r}}function e9(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 Yp=I(()=>{"use strict"});var eh={};K(eh,{findCommand:()=>i9,flagsForFuzzing:()=>u9});function t9(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function n9(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 a9(e,t){let n=qs(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]=Au(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=o9(t.mode,t.isDirectory),s++;break;case"t":{let u=new Date(t.mtime);c=l9(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(t.mtime);c=c9(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 o9(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 l9(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 c9(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 Jp,r9,s9,i9,u9,th=I(()=>{"use strict";se();Ua();Qp();Yp();Jp=500;r9={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"]},s9=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),i9={name:"find",async execute(e,t){if(U(e))return M(r9);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):s9.has(P)?(a=!0,N++):(P.startsWith("-")||P==="("||P==="\\("||P==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:o,error:l,actions:c}=Xp(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,
|
|
497
|
-
`,g=1;continue}let v=t9(),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 Gn=Date.now();ve=await t.fs.stat(X),v.statCalls++,v.statTime+=Date.now()-Gn}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=Kp(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 Gn=Date.now();if(R&&t.fs.readdirWithFileTypes){if(st=await t.fs.readdirWithFileTypes(X),tt=st.map(vt=>vt.name),v.readdirCalls++,v.readdirTime+=Date.now()-Gn,ns)et=st.map((vt,Gt)=>({path:X==="/"?`/${vt.name}`:`${X}/${vt.name}`,depth:Ee+1,typeInfo:{isFile:vt.isFile,isDirectory:vt.isDirectory},resultIndex:Gt}));else if(Wt){let vt=$.requiredExtension;et=st.filter(Gt=>Gt.isFile&&(!vt||Gt.name.endsWith(vt))).map((Gt,H6)=>({path:X==="/"?`/${Gt.name}`:`${X}/${Gt.name}`,depth:Ee+1,typeInfo:{isFile:Gt.isFile,isDirectory:Gt.isDirectory},resultIndex:H6}))}}else tt=await t.fs.readdir(X),v.readdirCalls++,v.readdirTime+=Date.now()-Gn,ns&&(et=tt.map((vt,Gt)=>({path:X==="/"?`/${vt}`:`${X}/${vt}`,depth:Ee+1,resultIndex:Gt})))}let zs=ke?(ve?.size??0)===0:tt!==null&&tt.length===0,dr=nt;if(!i&&o!==null&&!nt&&O){let Gn=Date.now(),vt={name:Fe,relativePath:je,isFile:ke,isDirectory:j,isEmpty:zs,mtime:ve?.mtime?.getTime()??Date.now(),size:ve?.size??0,mode:ve?.mode??420,newerRefTimes:
|
|
496
|
+
`,actions:[]};if(n.length===0){s++;continue}break}s++}if(n.length===0)return{expr:null,pathIndex:s,actions:r};let i=e9(n);return i.error?{expr:null,pathIndex:s,error:i.error,actions:r}:{expr:i.expr,pathIndex:s,actions:r}}function e9(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 Yp=I(()=>{"use strict"});var eh={};K(eh,{findCommand:()=>i9,flagsForFuzzing:()=>u9});function t9(){return{readdirCalls:0,readdirTime:0,statCalls:0,statTime:0,evalCalls:0,evalTime:0,nodeCount:0,batchCount:0,batchTime:0,earlyPrunes:0}}function n9(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 a9(e,t){let n=qs(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]=Au(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=o9(t.mode,t.isDirectory),s++;break;case"t":{let u=new Date(t.mtime);c=l9(u),s++;break}case"T":{if(s+1<n.length){let u=n[s+1],f=new Date(t.mtime);c=c9(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 o9(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 l9(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 c9(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 Jp,r9,s9,i9,u9,th=I(()=>{"use strict";se();Ua();Qp();Yp();Jp=500;r9={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"]},s9=new Set(["-name","-iname","-path","-ipath","-regex","-iregex","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),i9={name:"find",async execute(e,t){if(U(e))return M(r9);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):s9.has(P)?(a=!0,N++):(P.startsWith("-")||P==="("||P==="\\("||P==="!")&&(a=!0)}n.length===0&&n.push(".");let{expr:o,error:l,actions:c}=Xp(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=Zp(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),$=qp(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=t9(),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 Gn=Date.now();ve=await t.fs.stat(X),v.statCalls++,v.statTime+=Date.now()-Gn}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=Kp(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 Gn=Date.now();if(R&&t.fs.readdirWithFileTypes){if(st=await t.fs.readdirWithFileTypes(X),tt=st.map(vt=>vt.name),v.readdirCalls++,v.readdirTime+=Date.now()-Gn,ns)et=st.map((vt,Gt)=>({path:X==="/"?`/${vt.name}`:`${X}/${vt.name}`,depth:Ee+1,typeInfo:{isFile:vt.isFile,isDirectory:vt.isDirectory},resultIndex:Gt}));else if(Wt){let vt=$.requiredExtension;et=st.filter(Gt=>Gt.isFile&&(!vt||Gt.name.endsWith(vt))).map((Gt,H6)=>({path:X==="/"?`/${Gt.name}`:`${X}/${Gt.name}`,depth:Ee+1,typeInfo:{isFile:Gt.isFile,isDirectory:Gt.isDirectory},resultIndex:H6}))}}else tt=await t.fs.readdir(X),v.readdirCalls++,v.readdirTime+=Date.now()-Gn,ns&&(et=tt.map((vt,Gt)=>({path:X==="/"?`/${vt}`:`${X}/${vt}`,depth:Ee+1,resultIndex:Gt})))}let zs=ke?(ve?.size??0)===0:tt!==null&&tt.length===0,dr=nt;if(!i&&o!==null&&!nt&&O){let Gn=Date.now(),vt={name:Fe,relativePath:je,isFile:ke,isDirectory:j,isEmpty:zs,mtime:ve?.mtime?.getTime()??Date.now(),size:ve?.size??0,mode:ve?.mode??420,newerRefTimes:y};dr=Kt(o,vt).pruned,v.evalCalls++,v.evalTime+=Date.now()-Gn}return{relativePath:je,name:Fe,isFile:ke,isDirectory:j,isEmpty:zs,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,Jp),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,Jp),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 Fa=[];for(let zs of nt.children){let dr=ke++;Fa.push(dr),j.push({item:zs,orderIndex:dr})}ve.set(Ut,Fa)}}}Fe(0)}return H}let J=await re();if(p.push(...J.paths),m.push(...J.printfData),t.trace){let H=Date.now()-T;n9(t.trace,v,H),t.trace({category:"find",name:"searchPath",durationMs:H,details:{path:N,resultsFound:J.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+=a9(N.format,P);break;case"exec":if(!t.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
@@ -518,12 +518,12 @@ basename OPTION... NAME...`,options:["-a, --multiple support multiple argument
|
|
|
518
518
|
`}}}catch{}return i}var y9,w9,b9,E9,lh=I(()=>{"use strict";Ze();mr();se();y9={name:"tree",summary:"list contents of directories in a tree-like format",usage:"tree [OPTION]... [DIRECTORY]...",options:["-a include hidden files","-d list directories only","-L LEVEL limit depth of directory tree","-f print full path prefix for each file"," --help display this help and exit"]},w9={showHidden:{short:"a",type:"boolean"},directoriesOnly:{short:"d",type:"boolean"},fullPath:{short:"f",type:"boolean"},maxDepth:{short:"L",type:"number"}},b9={name:"tree",async execute(e,t){if(U(e))return M(y9);let n=be("tree",e,w9);if(!n.ok)return n.error;let r={showHidden:n.result.flags.showHidden,directoriesOnly:n.result.flags.directoriesOnly,maxDepth:n.result.flags.maxDepth??null,fullPath:n.result.flags.fullPath},s=n.result.positional;s.length===0&&s.push(".");let i="",a="",o=0,l=0;for(let c of s){let u=await x9(t,c,r,"",0);i+=u.output,a+=u.stderr,o+=u.dirCount,l+=u.fileCount}return i+=`
|
|
519
519
|
${o} director${o===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"s"}`),i+=`
|
|
520
520
|
`,{stdout:i,stderr:a,exitCode:a?1:0}}};E9={name:"tree",flags:[{flag:"-a",type:"boolean"},{flag:"-d",type:"boolean"},{flag:"-f",type:"boolean"},{flag:"-L",type:"value",valueHint:"number"}],needsFiles:!0}});var uh={};K(uh,{duCommand:()=>C9,flagsForFuzzing:()=>N9});async function ch(e,t,n,r,s){let i={output:"",totalSize:0,stderr:""};try{let a=await e.fs.stat(t);if(!a.isDirectory)return i.totalSize=a.size,(r.allFiles||s===0)&&(i.output=Ei(a.size,r.humanReadable)+" "+n+`
|
|
521
|
-
`),i;let o=0,l=[];if(e.fs.readdirWithFileTypes){let f=await e.fs.readdirWithFileTypes(t),p=f.filter(m=>m.isFile),h=f.filter(m=>m.isDirectory);for(let m=0;m<p.length;m+=100){let d=p.slice(m,m+100),g=await Promise.all(d.map(async
|
|
521
|
+
`),i;let o=0,l=[];if(e.fs.readdirWithFileTypes){let f=await e.fs.readdirWithFileTypes(t),p=f.filter(m=>m.isFile),h=f.filter(m=>m.isDirectory);for(let m=0;m<p.length;m+=100){let d=p.slice(m,m+100),g=await Promise.all(d.map(async w=>{let y=t==="/"?`/${w.name}`:`${t}/${w.name}`;try{let b=await e.fs.stat(y);return{name:w.name,isDirectory:!1,size:b.size}}catch{return{name:w.name,isDirectory:!1,size:0}}}));l.push(...g)}l.push(...h.map(m=>({name:m.name,isDirectory:!0})))}else{let f=await e.fs.readdir(t);for(let p=0;p<f.length;p+=100){let h=f.slice(p,p+100),m=await Promise.all(h.map(async d=>{let g=t==="/"?`/${d}`:`${t}/${d}`;try{let w=await e.fs.stat(g);return{name:d,isDirectory:w.isDirectory,size:w.isDirectory?void 0:w.size}}catch{return{name:d,isDirectory:!1,size:0}}}));l.push(...m)}}l.sort((f,p)=>f.name.localeCompare(p.name));let c=l.filter(f=>!f.isDirectory);for(let f of c){let p=f.size??0;if(o+=p,r.allFiles&&!r.summarize){let h=n==="."?f.name:`${n}/${f.name}`;i.output+=Ei(p,r.humanReadable)+" "+h+`
|
|
522
522
|
`}}let u=l.filter(f=>f.isDirectory);for(let f=0;f<u.length;f+=100){let p=u.slice(f,f+100),h=await Promise.all(p.map(async m=>{let d=t==="/"?`/${m.name}`:`${t}/${m.name}`,g=n==="."?m.name:`${n}/${m.name}`;return{name:m.name,result:await ch(e,d,g,r,s+1)}}));h.sort((m,d)=>m.name.localeCompare(d.name));for(let{result:m}of h)o+=m.totalSize,r.summarize||(r.maxDepth===null||s+1<=r.maxDepth)&&(i.output+=m.output)}i.totalSize=o,(r.summarize||r.maxDepth===null||s<=r.maxDepth)&&(i.output+=`${Ei(o,r.humanReadable)} ${n}
|
|
523
523
|
`)}catch{i.stderr=`du: cannot read directory '${n}': Permission denied
|
|
524
524
|
`}return i}function Ei(e,t){return t?e<1024?`${e}`:e<1024*1024?`${(e/1024).toFixed(1)}K`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)}M`:`${(e/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(e/1024)||1)}var A9,S9,C9,N9,fh=I(()=>{"use strict";Ze();mr();se();A9={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},S9={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},C9={name:"du",async execute(e,t){if(U(e))return M(A9);let n=be("du",e,S9);if(!n.ok)return n.error;let r={allFiles:n.result.flags.allFiles,humanReadable:n.result.flags.humanReadable,summarize:n.result.flags.summarize,grandTotal:n.result.flags.grandTotal,maxDepth:n.result.flags.maxDepth??null},s=n.result.positional;s.length===0&&s.push(".");let i="",a="",o=0;for(let l of s){let c=t.fs.resolvePath(t.cwd,l);try{await t.fs.stat(c);let u=await ch(t,c,l,r,0);i+=u.output,o+=u.totalSize,a+=u.stderr}catch{a+=`du: cannot access '${l}': No such file or directory
|
|
525
525
|
`}}return r.grandTotal&&s.length>0&&(i+=`${Ei(o,r.humanReadable)} total
|
|
526
|
-
`),{stdout:i,stderr:a,exitCode:a?1:0}}};N9={name:"du",flags:[{flag:"-a",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"--max-depth",type:"value",valueHint:"number"}],needsFiles:!0}});var Do={};K(Do,{envCommand:()=>v9,flagsForFuzzing:()=>O9,printenvCommand:()=>$9,printenvFlagsForFuzzing:()=>R9});var k9,v9,I9,$9,O9,R9,_o=I(()=>{"use strict";se();k9={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},v9={name:"env",async execute(e,t){if(U(e))return M(k9);let n=!1,r=[],s=new Map,i=-1;for(let m=0;m<e.length;m++){let d=e[m];if(d==="-i"||d==="--ignore-environment")n=!0;else if(d==="-u"&&m+1<e.length)r.push(e[++m]);else if(d.startsWith("-u"))r.push(d.slice(2));else if(d.startsWith("--unset="))r.push(d.slice(8));else{if(d.startsWith("--")&&d!=="--")return Y("env",d);if(d.startsWith("-")&&d!=="-"){for(let g of d.slice(1))if(g!=="i"&&g!=="u")return Y("env",`-${g}`);d.includes("i")&&(n=!0)}else if(d.includes("=")&&i===-1){let g=d.indexOf("="),
|
|
526
|
+
`),{stdout:i,stderr:a,exitCode:a?1:0}}};N9={name:"du",flags:[{flag:"-a",type:"boolean"},{flag:"-h",type:"boolean"},{flag:"-s",type:"boolean"},{flag:"-c",type:"boolean"},{flag:"--max-depth",type:"value",valueHint:"number"}],needsFiles:!0}});var Do={};K(Do,{envCommand:()=>v9,flagsForFuzzing:()=>O9,printenvCommand:()=>$9,printenvFlagsForFuzzing:()=>R9});var k9,v9,I9,$9,O9,R9,_o=I(()=>{"use strict";se();k9={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},v9={name:"env",async execute(e,t){if(U(e))return M(k9);let n=!1,r=[],s=new Map,i=-1;for(let m=0;m<e.length;m++){let d=e[m];if(d==="-i"||d==="--ignore-environment")n=!0;else if(d==="-u"&&m+1<e.length)r.push(e[++m]);else if(d.startsWith("-u"))r.push(d.slice(2));else if(d.startsWith("--unset="))r.push(d.slice(8));else{if(d.startsWith("--")&&d!=="--")return Y("env",d);if(d.startsWith("-")&&d!=="-"){for(let g of d.slice(1))if(g!=="i"&&g!=="u")return Y("env",`-${g}`);d.includes("i")&&(n=!0)}else if(d.includes("=")&&i===-1){let g=d.indexOf("="),w=d.slice(0,g),y=d.slice(g+1);s.set(w,y)}else{i=m;break}}}let a;if(n)a=new Map(s);else{a=new Map(t.env);for(let m of r)a.delete(m);for(let[m,d]of s)a.set(m,d)}if(i===-1){let m=[];for(let[d,g]of a)m.push(`${d}=${g}`);return{stdout:m.join(`
|
|
527
527
|
`)+(m.length>0?`
|
|
528
528
|
`:""),stderr:"",exitCode:0}}if(!t.exec)return{stdout:"",stderr:`env: command execution not supported in this context
|
|
529
529
|
`,exitCode:1};let o=e.slice(i),l=o[0],u=o.slice(1).map(m=>/[\s"'\\$`!*?[\]{}|&;<>()]/.test(m)?`'${m.replace(/'/g,"'\\''")}'`:m),f=["command",l,...u].join(" "),p=Object.entries(s).map(([m,d])=>`${m}="${d}"`).join(" "),h=p?`${p} ${f}`:f;return t.exec(h,{cwd:t.cwd})}},I9={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},$9={name:"printenv",async execute(e,t){if(U(e))return M(I9);let n=e.filter(i=>!i.startsWith("-"));if(n.length===0){let i=[];for(let[a,o]of t.env)i.push(`${a}=${o}`);return{stdout:i.join(`
|
|
@@ -536,15 +536,15 @@ ${o} director${o===1?"y":"ies"}`,r.directoriesOnly||(i+=`, ${l} file${l===1?"":"
|
|
|
536
536
|
`,exitCode:1}}else{let i=r.slice(0,s),a=r.slice(s+1);(a.startsWith("'")&&a.endsWith("'")||a.startsWith('"')&&a.endsWith('"'))&&(a=a.slice(1,-1)),t.env.set(Ir+i,a)}}return{stdout:"",stderr:"",exitCode:0}}},D9={name:"unalias",async execute(e,t){if(U(e))return M({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(e.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
|
|
537
537
|
`,exitCode:1};if(e[0]==="-a"){for(let i of t.env.keys())i.startsWith(Ir)&&t.env.delete(i);return{stdout:"",stderr:"",exitCode:0}}let n=e[0]==="--"?e.slice(1):e,r=!1,s="";for(let i of n){let a=Ir+i;t.env.get(a)?t.env.delete(a):(s+=`unalias: ${i}: not found
|
|
538
538
|
`,r=!0)}return{stdout:"",stderr:s,exitCode:r?1:0}}},_9={name:"alias",flags:[]},L9={name:"unalias",flags:[{flag:"-a",type:"boolean"}]}});var hh={};K(hh,{flagsForFuzzing:()=>U9,historyCommand:()=>M9});var F9,ph,M9,U9,dh=I(()=>{"use strict";se();F9={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},ph="BASH_HISTORY",M9={name:"history",async execute(e,t){if(U(e))return M(F9);let n=t.env.get(ph)||"[]",r;try{r=JSON.parse(n)}catch{r=[]}if(e[0]==="-c")return t.env.set(ph,"[]"),{stdout:"",stderr:"",exitCode:0};let s=r.length;e[0]&&/^\d+$/.test(e[0])&&(s=Math.min(parseInt(e[0],10),r.length));let i=r.length-s,a="";for(let o=i;o<r.length;o++){let l=(o+1).toString().padStart(5," ");a+=`${l} ${r[o]}
|
|
539
|
-
`}return{stdout:a,stderr:"",exitCode:0}}},U9={name:"history",flags:[{flag:"-c",type:"boolean"}]}});var mh={};K(mh,{flagsForFuzzing:()=>z9,xargsCommand:()=>B9});var W9,B9,z9,gh=I(()=>{"use strict";se();W9={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},B9={name:"xargs",async execute(e,t){if(U(e))return M(W9);let n=null,r=null,s=null,i=null,a=!1,o=!1,l=!1,c=0;for(let
|
|
540
|
-
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=
|
|
539
|
+
`}return{stdout:a,stderr:"",exitCode:0}}},U9={name:"history",flags:[{flag:"-c",type:"boolean"}]}});var mh={};K(mh,{flagsForFuzzing:()=>z9,xargsCommand:()=>B9});var W9,B9,z9,gh=I(()=>{"use strict";se();W9={name:"xargs",summary:"build and execute command lines from standard input",usage:"xargs [OPTION]... [COMMAND [INITIAL-ARGS]]",options:["-I REPLACE replace occurrences of REPLACE with input","-d DELIM use DELIM as input delimiter (e.g., -d '\\n' for newline)","-n NUM use at most NUM arguments per command line","-P NUM run at most NUM processes at a time","-0, --null items are separated by null, not whitespace","-t, --verbose print commands before executing","-r, --no-run-if-empty do not run command if input is empty"," --help display this help and exit"]},B9={name:"xargs",async execute(e,t){if(U(e))return M(W9);let n=null,r=null,s=null,i=null,a=!1,o=!1,l=!1,c=0;for(let y=0;y<e.length;y++){let b=e[y];if(b==="-I"&&y+1<e.length)n=e[++y],c=y+1;else if(b==="-d"&&y+1<e.length)r=e[++y].replace(/\\n/g,`
|
|
540
|
+
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\0/g,"\0").replace(/\\\\/g,"\\"),c=y+1;else if(b==="-n"&&y+1<e.length)s=parseInt(e[++y],10),c=y+1;else if(b==="-P"&&y+1<e.length)i=parseInt(e[++y],10),c=y+1;else if(b==="-0"||b==="--null")a=!0,c=y+1;else if(b==="-t"||b==="--verbose")o=!0,c=y+1;else if(b==="-r"||b==="--no-run-if-empty")l=!0,c=y+1;else{if(b.startsWith("--"))return Y("xargs",b);if(b.startsWith("-")&&b.length>1){for(let x of b.slice(1))if(!"0tr".includes(x))return Y("xargs",`-${x}`);b.includes("0")&&(a=!0),b.includes("t")&&(o=!0),b.includes("r")&&(l=!0),c=y+1}else if(!b.startsWith("-")){c=y;break}}}let u=e.slice(c);u.length===0&&u.push("echo");let f;if(a?f=t.stdin.split("\0").filter(y=>y.length>0):r!==null?f=t.stdin.replace(/\n$/,"").split(r).filter(b=>b.length>0):f=t.stdin.split(/\s+/).map(y=>y.trim()).filter(y=>y.length>0),f.length===0)return l?{stdout:"",stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0};let p="",h="",m=0,d=y=>/[\s"'\\$`!*?[\]{}();&|<>#]/.test(y)?`"${y.replace(/([\\"`$])/g,"\\$1")}"`:y,g=async y=>{let b=y.map(d).join(" ");return o&&(h+=`${b}
|
|
541
541
|
`),t.exec?t.exec(b,{cwd:t.cwd}):{stdout:`${b}
|
|
542
|
-
`,stderr:"",exitCode:0}},
|
|
542
|
+
`,stderr:"",exitCode:0}},w=async y=>{if(i!==null&&i>1)for(let b=0;b<y.length;b+=i){let x=y.slice(b,b+i),S=await Promise.all(x.map(g));for(let $ of S)p+=$.stdout,h+=$.stderr,$.exitCode!==0&&(m=$.exitCode)}else for(let b of y){let x=await g(b);p+=x.stdout,h+=x.stderr,x.exitCode!==0&&(m=x.exitCode)}};if(n!==null){let y=f.map(b=>u.map(x=>x.replaceAll(n,b)));await w(y)}else if(s!==null){let y=[];for(let b=0;b<f.length;b+=s){let x=f.slice(b,b+s);y.push([...u,...x])}await w(y)}else{let y=[...u,...f],b=await g(y);p+=b.stdout,h+=b.stderr,m=b.exitCode}return{stdout:p,stderr:h,exitCode:m}}},z9={name:"xargs",flags:[{flag:"-I",type:"value",valueHint:"string"},{flag:"-d",type:"value",valueHint:"delimiter"},{flag:"-n",type:"value",valueHint:"number"},{flag:"-0",type:"boolean"},{flag:"-t",type:"boolean"},{flag:"-r",type:"boolean"}],stdinType:"text"}});var Mo={};K(Mo,{falseCommand:()=>j9,falseFlagsForFuzzing:()=>G9,flagsForFuzzing:()=>V9,trueCommand:()=>H9});var H9,j9,V9,G9,Uo=I(()=>{"use strict";H9={name:"true",async execute(){return{stdout:"",stderr:"",exitCode:0}}},j9={name:"false",async execute(){return{stdout:"",stderr:"",exitCode:1}}},V9={name:"true",flags:[]},G9={name:"false",flags:[]}});var yh={};K(yh,{clearCommand:()=>Z9,flagsForFuzzing:()=>K9});var q9,Z9,K9,wh=I(()=>{"use strict";se();q9={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},Z9={name:"clear",async execute(e,t){return U(e)?M(q9):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}},K9={name:"clear",flags:[]}});var Wo={};K(Wo,{bashCommand:()=>Q9,flagsForFuzzing:()=>Y9,shCommand:()=>X9,shFlagsForFuzzing:()=>J9});async function $r(e,t,n,r){if(!r.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
|
|
543
543
|
`,exitCode:1};let s=oi(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 bh,Q9,X9,Y9,J9,Bo=I(()=>{"use strict";Pn();se();bh={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).']},Q9={name:"bash",async execute(e,t){if(U(e))return M(bh);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}}}},X9={name:"sh",async execute(e,t){if(U(e))return M({...bh,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}}}};Y9={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},J9={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function Ie(e){return!xh.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 zo(...e){return Object.assign(Object.create(null),...e)}var xh,Ak,Nn=I(()=>{"use strict";xh=new Set(["__proto__","constructor","prototype"]),Ak=new Set([...xh,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function Ho(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))?oi(...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 Eh=I(()=>{"use strict";Pn();Nn()});function jo(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 y=d;y<g;y++)p.push(y)}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,y=m;if(y!==0)if(y>0)for(let w=d;w<g;w+=y)f.push(w);else for(let w=d;w>g;w+=y)f.push(w)}return f}case"limit":return n.length<2?[]:s(e,n[0],r).flatMap(c=>{let u=c;if(u<0)throw new Error("limit doesn't support negative count");if(u===0)return[];let f;try{f=i(e,n[1],r)}catch(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 Ah=I(()=>{"use strict"});function Vo(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,y=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,y??0))}else throw new Error("strftime/1 requires parsed datetime inputs");let l=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],c=["January","February","March","April","May","June","July","August","September","October","November","December"],u=(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(),y=Date.UTC(c,0,1),w=Math.floor((d.getTime()-y)/(1440*60*1e3));return[[c,u-1,f,p,h,m,g,w]]}}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 Sh=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 Ai(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=Ai(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=Ai(i[c],a[c]);if(u!==0)return u}}return 0}function Si(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=>Si(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)&&Si(n[s],r[s]))}return!1}var Ci=I(()=>{"use strict";Nn()});function qo(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??e5;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 e5,Ch=I(()=>{"use strict";Ci();e5=2e3});function Zo(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 Nh=I(()=>{"use strict"});function Ko(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 kh=I(()=>{"use strict"});function Qo(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 vh=I(()=>{"use strict";Nn()});function Xo(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??t5;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 t5,Ih=I(()=>{"use strict";Nn();Ci();t5=2e3});function Yo(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 $h=I(()=>{"use strict"});function Jo(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 Oh=I(()=>{"use strict";Nn()});function el(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 G(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[...G(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[G(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=G(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=G(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[G(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[G(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 Rh=I(()=>{"use strict";Me()});function tl(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 Th=I(()=>{"use strict"});var Ph=I(()=>{"use strict";Eh();Ah();Sh();Ch();Nh();kh();vh();Ih();$h();Oh();Rh();Th()});function Ni(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]=Ni(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,Ni(a,s,n)),i}function ki(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]=ki(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,ki(i[s],r)),i}return e}var Dh=I(()=>{"use strict";Nn()});function s5(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??n5,maxDepth:e?.limits?.maxDepth??Fh},env:e?.env,coverage:e?.coverage}}function $i(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 $i(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=V(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=$i(s,i.keyVar,o));let l=ys(s,i.pattern,o);if(l===null)return null;s=l}return s}}}function i5(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:nl(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 nl(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=nl(e,t.left);return n===null?null:nl(n,t.right)}return t.type==="Identity"?e:null}function _h(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...V(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(...V(e,t.right,n))}catch(s){if(s instanceof te)throw s;return r}return r}return V(e,t,n)}function V(e,t,n){let r=n&&"vars"in n?n:s5(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?V(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?V(e,t.base,r):[e]).flatMap(i=>V(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?V(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?V(e,t.start,r):[0],l=t.end?V(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=Lh(h,a),g=Lh(m,a);return Array.isArray(i),i.slice(d,g)}))});case"Iterate":return(t.base?V(e,t.base,r):[e]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=V(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(...V(o,t.right,l))}else a.push(...V(o,t.right,r))}catch(l){throw l instanceof Tr?l.withPrependedResults(a):l}return a}case"Comma":{let s=V(e,t.left,r),i=V(e,t.right,r);return[...s,...i]}case"Literal":return[t.value];case"Array":return t.elements?[V(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]:V(e,i.key,r),o=V(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 V(e,t.expr,r);case"BinaryOp":return l5(e,t.op,t.left,t.right,r);case"UnaryOp":return V(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 V(e,t.cond,r).flatMap(i=>{if(Qt(i))return V(e,t.then,r);for(let a of t.elifs)if(V(e,a.cond,r).some(Qt))return V(e,a.then,r);return t.else?V(e,t.else,r):[e]});case"Try":try{return V(e,t.body,r)}catch(s){if(t.catch){let i=s instanceof Ii?s.value:s instanceof Error?s.message:String(s);return V(i,t.catch,r)}return[]}case"Call":return Mh(e,t.name,t.args,r);case"VarBind":return V(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?[]:V(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 V(e,t.expr,r)}catch{return[]}case"StringInterp":return[t.parts.map(i=>typeof i=="string"?i:V(e,i,r).map(o=>typeof o=="string"?o:JSON.stringify(o)).join("")).join("")];case"UpdateOp":return[a5(e,t.path,t.op,t.value,r)];case"Reduce":{let s=V(e,t.expr,r),i=V(e,t.init,r)[0],a=r.limits.maxDepth??Fh;for(let o of s){let l;if(t.pattern){if(l=ys(r,t.pattern,o),l===null)continue}else l=$i(r,t.varName,o);if(i=V(i,t.update,l)[0],Rr(i,a+1)>a)return[null]}return[i]}case"Foreach":{let s=V(e,t.expr,r),i=V(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=$i(r,t.varName,o);if(i=V(i,t.update,l)[0],t.extract){let c=V(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 V(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 V(e,t.body,a)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function Lh(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function a5(e,t,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return V(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"?zo(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=V(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=V(e,r,s);return i(l,c[0]??null)})}function o5(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=V(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=V(i,a.base,n)[0],f=r(u,{type:"Index",index:a.index},o);return r(i,a.base,f)}let c=V(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=V(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=V(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=V(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 y=V(e,m.index,n)[0];if(typeof y=="number"&&Array.isArray(h)){let w=[...h],b=y<0?w.length+y:y;return b>=0&&b<w.length&&(w[b]=d),w}if(typeof y=="string"&&h&&typeof h=="object"&&!Array.isArray(h)){if(!Ie(y))return h;let w=Ke(h);return Pe(w,y,d),w}return h}case"Pipe":{let g=V(h,m.left,n)[0],y=u(g,m.right,d);return u(h,m.left,y)}default:return h}};var o=u;let l=a.left,c=a.right,f=V(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 l5(e,t,n,r,s){if(t==="and")return V(e,n,s).flatMap(l=>Qt(l)?V(e,r,s).map(u=>Qt(u)):[!1]);if(t==="or")return V(e,n,s).flatMap(l=>Qt(l)?[!0]:V(e,r,s).map(u=>Qt(u)));if(t==="//"){let l=V(e,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:V(e,r,s)}let i=V(e,n,s),a=V(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)?zo(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 Mh(e,t,n,r){let s=r5.get(t);if(s)return typeof e=="number"?[s(e)]:[null];let i=Ko(e,t,n,r,V);if(i!==null)return i;let a=el(e,t,n,r,V);if(a!==null)return a;let o=Vo(e,t,n,r,V);if(o!==null)return o;let l=qo(e,t,r.limits.maxDepth);if(l!==null)return l;let c=tl(e,t);if(c!==null)return c;let u=Xo(e,t,n,r,V);if(u!==null)return u;let f=Ho(e,t,n,r,V,_h,Ai,Qt,Si,te);if(f!==null)return f;let p=Yo(e,t,n,r,V,Qt,Ni,ki,o5,vi);if(p!==null)return p;let h=Zo(e,t,n,r,V,Or);if(h!==null)return h;let m=jo(e,t,n,r,V,_h,Qt,te);if(m!==null)return m;let d=Qo(e,t,n,r,V,Qt,i5,Mh);if(d!==null)return d;let g=Jo(e,t,n,r,V,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 y=n.length>0?V(e,n[0],r)[0]:e;throw new Ii(y)}case"env":return[r.env?Et(r.env):Object.create(null)];case"debug":return[e];case"input_line_number":return[1];default:{let y=`${t}/${n.length}`,w=r.funcs?.get(y);if(w){let b=w.closure??r.funcs??new Map,x=new Map(b);x.set(y,w);for(let $=0;$<w.params.length;$++){let O=w.params[$],F=n[$];if(F){let R=V(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 V(e,w.body,S)}throw new Error(`Unknown function: ${t}`)}}}function vi(e,t,n,r,s){if(t.type==="Comma"){let o=t;vi(e,o.left,n,r,s),vi(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=V(e,t.left,n);for(let c of l)vi(c,t.right,n,[...r,...o],s);return}}V(e,t,n).length>0&&s.push(r)}var Tr,Ii,n5,Fh,r5,Uh=I(()=>{"use strict";Pn();ye();Ph();Dh();Nn();Ci();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])}},Ii=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},n5=1e4,Fh=2e3,r5=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 Bh(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}}}};Y9={name:"bash",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"},J9={name:"sh",flags:[{flag:"-c",type:"value",valueHint:"string"}],stdinType:"text"}});function Ie(e){return!xh.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 zo(...e){return Object.assign(Object.create(null),...e)}var xh,Ak,Nn=I(()=>{"use strict";xh=new Set(["__proto__","constructor","prototype"]),Ak=new Set([...xh,"__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])});function Ho(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))?oi(...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 Eh=I(()=>{"use strict";Pn();Nn()});function jo(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 Ah=I(()=>{"use strict"});function Vo(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 Sh=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 Ai(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=Ai(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=Ai(i[c],a[c]);if(u!==0)return u}}return 0}function Si(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=>Si(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)&&Si(n[s],r[s]))}return!1}var Ci=I(()=>{"use strict";Nn()});function qo(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??e5;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 e5,Ch=I(()=>{"use strict";Ci();e5=2e3});function Zo(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 Nh=I(()=>{"use strict"});function Ko(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 kh=I(()=>{"use strict"});function Qo(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 vh=I(()=>{"use strict";Nn()});function Xo(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??t5;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 t5,Ih=I(()=>{"use strict";Nn();Ci();t5=2e3});function Yo(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 $h=I(()=>{"use strict"});function Jo(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 Oh=I(()=>{"use strict";Nn()});function el(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 G(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[...G(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[G(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=G(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=G(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[G(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[G(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 Rh=I(()=>{"use strict";Me()});function tl(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 Th=I(()=>{"use strict"});var Ph=I(()=>{"use strict";Eh();Ah();Sh();Ch();Nh();kh();vh();Ih();$h();Oh();Rh();Th()});function Ni(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]=Ni(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,Ni(a,s,n)),i}function ki(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]=ki(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,ki(i[s],r)),i}return e}var Dh=I(()=>{"use strict";Nn()});function s5(e){return{vars:new Map,limits:{maxIterations:e?.limits?.maxIterations??n5,maxDepth:e?.limits?.maxDepth??Fh},env:e?.env,coverage:e?.coverage}}function $i(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 $i(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=V(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=$i(s,i.keyVar,o));let l=ys(s,i.pattern,o);if(l===null)return null;s=l}return s}}}function i5(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:nl(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 nl(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=nl(e,t.left);return n===null?null:nl(n,t.right)}return t.type==="Identity"?e:null}function _h(e,t,n){if(t.type==="Comma"){let r=[];try{r.push(...V(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(...V(e,t.right,n))}catch(s){if(s instanceof te)throw s;return r}return r}return V(e,t,n)}function V(e,t,n){let r=n&&"vars"in n?n:s5(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?V(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?V(e,t.base,r):[e]).flatMap(i=>V(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?V(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?V(e,t.start,r):[0],l=t.end?V(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=Lh(h,a),g=Lh(m,a);return Array.isArray(i),i.slice(d,g)}))});case"Iterate":return(t.base?V(e,t.base,r):[e]).flatMap(i=>Array.isArray(i)?i:i&&typeof i=="object"?Object.values(i):[]);case"Pipe":{let s=V(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(...V(o,t.right,l))}else a.push(...V(o,t.right,r))}catch(l){throw l instanceof Tr?l.withPrependedResults(a):l}return a}case"Comma":{let s=V(e,t.left,r),i=V(e,t.right,r);return[...s,...i]}case"Literal":return[t.value];case"Array":return t.elements?[V(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]:V(e,i.key,r),o=V(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 V(e,t.expr,r);case"BinaryOp":return l5(e,t.op,t.left,t.right,r);case"UnaryOp":return V(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 V(e,t.cond,r).flatMap(i=>{if(Qt(i))return V(e,t.then,r);for(let a of t.elifs)if(V(e,a.cond,r).some(Qt))return V(e,a.then,r);return t.else?V(e,t.else,r):[e]});case"Try":try{return V(e,t.body,r)}catch(s){if(t.catch){let i=s instanceof Ii?s.value:s instanceof Error?s.message:String(s);return V(i,t.catch,r)}return[]}case"Call":return Mh(e,t.name,t.args,r);case"VarBind":return V(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?[]:V(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 V(e,t.expr,r)}catch{return[]}case"StringInterp":return[t.parts.map(i=>typeof i=="string"?i:V(e,i,r).map(o=>typeof o=="string"?o:JSON.stringify(o)).join("")).join("")];case"UpdateOp":return[a5(e,t.path,t.op,t.value,r)];case"Reduce":{let s=V(e,t.expr,r),i=V(e,t.init,r)[0],a=r.limits.maxDepth??Fh;for(let o of s){let l;if(t.pattern){if(l=ys(r,t.pattern,o),l===null)continue}else l=$i(r,t.varName,o);if(i=V(i,t.update,l)[0],Rr(i,a+1)>a)return[null]}return[i]}case"Foreach":{let s=V(e,t.expr,r),i=V(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=$i(r,t.varName,o);if(i=V(i,t.update,l)[0],t.extract){let c=V(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 V(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 V(e,t.body,a)}default:{let s=t;throw new Error(`Unknown AST node type: ${s.type}`)}}}function Lh(e,t){return e<0?Math.max(0,t+e):Math.min(e,t)}function a5(e,t,n,r,s){function i(l,c){switch(n){case"=":return c;case"|=":return V(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"?zo(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=V(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=V(e,r,s);return i(l,c[0]??null)})}function o5(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=V(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=V(i,a.base,n)[0],f=r(u,{type:"Index",index:a.index},o);return r(i,a.base,f)}let c=V(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=V(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=V(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=V(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=V(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=V(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=V(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 l5(e,t,n,r,s){if(t==="and")return V(e,n,s).flatMap(l=>Qt(l)?V(e,r,s).map(u=>Qt(u)):[!1]);if(t==="or")return V(e,n,s).flatMap(l=>Qt(l)?[!0]:V(e,r,s).map(u=>Qt(u)));if(t==="//"){let l=V(e,n,s).filter(c=>c!=null&&c!==!1);return l.length>0?l:V(e,r,s)}let i=V(e,n,s),a=V(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)?zo(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 Mh(e,t,n,r){let s=r5.get(t);if(s)return typeof e=="number"?[s(e)]:[null];let i=Ko(e,t,n,r,V);if(i!==null)return i;let a=el(e,t,n,r,V);if(a!==null)return a;let o=Vo(e,t,n,r,V);if(o!==null)return o;let l=qo(e,t,r.limits.maxDepth);if(l!==null)return l;let c=tl(e,t);if(c!==null)return c;let u=Xo(e,t,n,r,V);if(u!==null)return u;let f=Ho(e,t,n,r,V,_h,Ai,Qt,Si,te);if(f!==null)return f;let p=Yo(e,t,n,r,V,Qt,Ni,ki,o5,vi);if(p!==null)return p;let h=Zo(e,t,n,r,V,Or);if(h!==null)return h;let m=jo(e,t,n,r,V,_h,Qt,te);if(m!==null)return m;let d=Qo(e,t,n,r,V,Qt,i5,Mh);if(d!==null)return d;let g=Jo(e,t,n,r,V,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?V(e,n[0],r)[0]:e;throw new Ii(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=V(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 V(e,y.body,S)}throw new Error(`Unknown function: ${t}`)}}}function vi(e,t,n,r,s){if(t.type==="Comma"){let o=t;vi(e,o.left,n,r,s),vi(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=V(e,t.left,n);for(let c of l)vi(c,t.right,n,[...r,...o],s);return}}V(e,t,n).length>0&&s.push(r)}var Tr,Ii,n5,Fh,r5,Uh=I(()=>{"use strict";Pn();ye();Ph();Dh();Nn();Ci();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])}},Ii=class extends Error{value;constructor(t){super(typeof t=="string"?t:JSON.stringify(t)),this.value=t,this.name="JqError"}},n5=1e4,Fh=2e3,r5=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 Bh(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=Wh.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 zh(e){let t=Bh(e);return new rl(t).parse()}var Wh,Oi,rl,Hh=I(()=>{"use strict";Wh=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"]]),Oi=new Set(Wh.values());rl=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"||Oi.has(r.type)?r.pos===n.pos+1:!1}isIdentLike(){let t=this.peek().type;return t==="IDENT"||Oi.has(t)}consumeFieldNameAfterDot(t){let n=this.peek();return n.type==="STRING"?this.advance().value:(n.type==="IDENT"||Oi.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"||Oi.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=Bh(a),l=new e(o);n.push(l.parse())}else r+=t[s],s++;return r&&n.push(r),{type:"StringInterp",parts:n}}}});var jh=I(()=>{"use strict";Uh();Hh()});var Gh={};K(Gh,{flagsForFuzzing:()=>f5,jqCommand:()=>u5});function Vh(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(",")}]`:`[
|
|
@@ -553,8 +553,8 @@ ${e.map(l=>a.repeat(i+1)+ws(l,!1,!1,r,s,i+1)).join(`,
|
|
|
553
553
|
${a.repeat(i)}]`;if(typeof e=="object"){let o=Object.keys(e);return r&&(o=o.sort()),o.length===0?"{}":t?`{${o.map(c=>`${JSON.stringify(c)}:${ws(e[c],!0,!1,r,s)}`).join(",")}}`:`{
|
|
554
554
|
${o.map(c=>{let u=ws(e[c],!1,!1,r,s,i+1);return`${a.repeat(i+1)}${JSON.stringify(c)}: ${u}`}).join(`,
|
|
555
555
|
`)}
|
|
556
|
-
${a.repeat(i)}}`}return String(e)}var c5,u5,f5,qh=I(()=>{"use strict";ye();Zn();se();jh();c5={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};u5={name:"jq",async execute(e,t){if(U(e))return M(c5);let n=!1,r=!1,s=!1,i=!1,a=!1,o=!1,l=!1,c=!1,u=".",f=!1,p=[];for(let m=0;m<e.length;m++){let d=e[m];if(d==="-r"||d==="--raw-output")n=!0;else if(d==="-c"||d==="--compact-output")r=!0;else if(d==="-e"||d==="--exit-status")s=!0;else if(d==="-s"||d==="--slurp")i=!0;else if(d==="-n"||d==="--null-input")a=!0;else if(d==="-j"||d==="--join-output")o=!0;else if(!(d==="-a"||d==="--ascii")){if(d==="-S"||d==="--sort-keys")l=!0;else if(!(d==="-C"||d==="--color")){if(!(d==="-M"||d==="--monochrome"))if(d==="--tab")c=!0;else if(d==="-")p.push("-");else{if(d.startsWith("--"))return Y("jq",d);if(d.startsWith("-")){for(let g of d.slice(1))if(g==="r")n=!0;else if(g==="c")r=!0;else if(g==="e")s=!0;else if(g==="s")i=!0;else if(g==="n")a=!0;else if(g==="j")o=!0;else if(g!=="a"){if(g==="S")l=!0;else if(g!=="C"){if(g!=="M")return Y("jq",`-${g}`)}}}else f?p.push(d):(u=d,f=!0)}}}}let h=[];if(!a)if(p.length===0||p.length===1&&p[0]==="-")h.push({source:"stdin",content:t.stdin});else{let m=await qn(t,p,{cmdName:"jq",stopOnError:!0});if(m.exitCode!==0)return{stdout:"",stderr:m.stderr,exitCode:2};h=m.files.map(d=>({source:d.filename||"stdin",content:d.content}))}try{let m=zh(u),d=[],g={limits:t.limits?{maxIterations:t.limits.maxJqIterations}:void 0,env:t.env,coverage:t.coverage};if(a)d=V(null,m,g);else if(i){let $=[];for(let{content:O}of h){let F=O.trim();F&&$.push(...Vh(F))}d=V($,m,g)}else for(let{content:$}of h){let O=$.trim();if(!O)continue;let F=Vh(O);for(let R of F)d.push(...V(R,m,g))}let
|
|
557
|
-
`,b=
|
|
556
|
+
${a.repeat(i)}}`}return String(e)}var c5,u5,f5,qh=I(()=>{"use strict";ye();Zn();se();jh();c5={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input","-j, --join-output don't print newlines after each output","-a, --ascii force ASCII output","-S, --sort-keys sort object keys","-C, --color colorize output (ignored)","-M, --monochrome monochrome output (ignored)"," --tab use tabs for indentation"," --help display this help and exit"]};u5={name:"jq",async execute(e,t){if(U(e))return M(c5);let n=!1,r=!1,s=!1,i=!1,a=!1,o=!1,l=!1,c=!1,u=".",f=!1,p=[];for(let m=0;m<e.length;m++){let d=e[m];if(d==="-r"||d==="--raw-output")n=!0;else if(d==="-c"||d==="--compact-output")r=!0;else if(d==="-e"||d==="--exit-status")s=!0;else if(d==="-s"||d==="--slurp")i=!0;else if(d==="-n"||d==="--null-input")a=!0;else if(d==="-j"||d==="--join-output")o=!0;else if(!(d==="-a"||d==="--ascii")){if(d==="-S"||d==="--sort-keys")l=!0;else if(!(d==="-C"||d==="--color")){if(!(d==="-M"||d==="--monochrome"))if(d==="--tab")c=!0;else if(d==="-")p.push("-");else{if(d.startsWith("--"))return Y("jq",d);if(d.startsWith("-")){for(let g of d.slice(1))if(g==="r")n=!0;else if(g==="c")r=!0;else if(g==="e")s=!0;else if(g==="s")i=!0;else if(g==="n")a=!0;else if(g==="j")o=!0;else if(g!=="a"){if(g==="S")l=!0;else if(g!=="C"){if(g!=="M")return Y("jq",`-${g}`)}}}else f?p.push(d):(u=d,f=!0)}}}}let h=[];if(!a)if(p.length===0||p.length===1&&p[0]==="-")h.push({source:"stdin",content:t.stdin});else{let m=await qn(t,p,{cmdName:"jq",stopOnError:!0});if(m.exitCode!==0)return{stdout:"",stderr:m.stderr,exitCode:2};h=m.files.map(d=>({source:d.filename||"stdin",content:d.content}))}try{let m=zh(u),d=[],g={limits:t.limits?{maxIterations:t.limits.maxJqIterations}:void 0,env:t.env,coverage:t.coverage};if(a)d=V(null,m,g);else if(i){let $=[];for(let{content:O}of h){let F=O.trim();F&&$.push(...Vh(F))}d=V($,m,g)}else for(let{content:$}of h){let O=$.trim();if(!O)continue;let F=Vh(O);for(let R of F)d.push(...V(R,m,g))}let w=d.map($=>ws($,r,n,l,c)),y=o?"":`
|
|
557
|
+
`,b=w.join(y),x=t.limits?.maxStringLength;if(x!==void 0&&x>0&&b.length>x)throw new te(`jq: output size limit exceeded (${x} bytes)`,"string_length");let S=s&&(d.length===0||d.every($=>$==null||$===!1))?1:0;return{stdout:b?o?b:`${b}
|
|
558
558
|
`:"",stderr:"",exitCode:S}}catch(m){if(m instanceof te)return{stdout:"",stderr:`jq: ${m.message}
|
|
559
559
|
`,exitCode:te.EXIT_CODE};let d=m.message;return d.includes("Unknown function")?{stdout:"",stderr:`jq: error: ${d}
|
|
560
560
|
`,exitCode:3}:{stdout:"",stderr:`jq: parse error: ${d}
|
|
@@ -604,18 +604,18 @@ sys 0.00
|
|
|
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
|
-
`,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("-"),
|
|
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
608
|
`:"",stderr:"",exitCode:0}}},U5={name:"seq",flags:[{flag:"-s",type:"value",valueHint:"string"},{flag:"-w",type:"boolean"}],needsArgs:!0}});var ud={};K(ud,{exprCommand:()=>W5,flagsForFuzzing:()=>z5});function B5(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=G(`^${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=G(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 W5,z5,fd=I(()=>{"use strict";Me();W5={name:"expr",async execute(e,t){if(e.length===0)return{stdout:"",stderr:`expr: missing operand
|
|
609
609
|
`,exitCode:2};try{let n=B5(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}}}};z5={name:"expr",flags:[],needsArgs:!0}});function j5(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,
|
|
611
|
+
`,exitCode:2}}}};z5={name:"expr",flags:[],needsArgs:!0}});function j5(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 pd(e,t){if(e==="md5")return j5(t);let n=H5.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
|
-
`)){let g=d.match(/^([a-fA-F0-9]+)\s+[* ]?(.+)$/);if(!g)continue;let[,y
|
|
614
|
-
`,f++;continue}let x=await pd(t,b)===
|
|
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
|
+
`,f++;continue}let x=await pd(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 pd(t,p)} ${f}
|
|
618
|
-
`}return{stdout:c,stderr:"",exitCode:u}}}}var H5,Ti=I(()=>{"use strict";se();H5=new Map([["sha1","SHA-1"],["sha256","SHA-256"]])});var hd={};K(hd,{flagsForFuzzing:()=>G5,md5sumCommand:()=>V5});var V5,G5,dd=I(()=>{"use strict";Ti();V5=Pr("md5sum","md5","compute MD5 message digest"),G5={name:"md5sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var md={};K(md,{flagsForFuzzing:()=>Z5,sha1sumCommand:()=>q5});var q5,Z5,gd=I(()=>{"use strict";Ti();q5=Pr("sha1sum","sha1","compute SHA1 message digest"),Z5={name:"sha1sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var yd={};K(yd,{flagsForFuzzing:()=>Q5,sha256sumCommand:()=>K5});var K5,Q5,wd=I(()=>{"use strict";Ti();K5=Pr("sha256sum","sha256","compute SHA256 message digest"),Q5={name:"sha256sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var bd=js(sl=>{sl.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)};sl.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 xd(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):Y5(e);case"utf-16le":return J5(e);case"ascii":return ew(e);case"latin1":case"iso-8859-1":return tw(e);case"windows-1252":return nw(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function Y5(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 J5(e){let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function ew(e){return String.fromCharCode(...e.map(t=>t&127))}function tw(e){return String.fromCharCode(...e)}function nw(e){let t="";for(let n of e)n>=128&&n<=159&&il[n]?t+=il[n]:t+=String.fromCharCode(n);return t}var il,X5,Ed=I(()=>{il={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"},X5={};for(let[e,t]of Object.entries(il))X5[t]=Number.parseInt(e)});function $t(e){return new DataView(e.buffer,e.byteOffset)}var Ad,Sd,Ge,Dr,Qe,Cd,Nd,kd,Ot,bs=I(()=>{Ad=yu(bd(),1);Ed();Sd={len:1,get(e,t){return $t(e).getUint8(t)},put(e,t,n){return $t(e).setUint8(t,n),t+1}},Ge={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}},Cd={len:4,get(e,t){return $t(e).getUint32(t)},put(e,t,n){return $t(e).setUint32(t,n),t+4}},Nd={len:4,get(e,t){return $t(e).getInt32(t)},put(e,t,n){return $t(e).setInt32(t,n),t+4}},kd={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 xd(r,this.encoding)}}});var sw,We,Jn,xs=I(()=>{sw="End-Of-Stream",We=class extends Error{constructor(){super(sw),this.name="EndOfStreamError"}},Jn=class extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}});var vd=I(()=>{});var er,Pi=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 Id=I(()=>{xs();vd();Pi()});var Di,$d=I(()=>{Pi();Di=class extends er{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var Es,al=I(()=>{$d();Es=class extends Di{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,ol=I(()=>{xs();Pi();_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 ll(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 Od=I(()=>{al();ol()});var tr=I(()=>{xs();Id();al();ol();Od()});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 aw,_i,Rd=I(()=>{As();tr();aw=256e3,_i=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(aw,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 Li,Td=I(()=>{tr();As();Li=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 Fi,Pd=I(()=>{tr();As();Fi=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 Dd(e,t){let n=ll(e),r=t??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new _i(n,r)}function _d(e,t){return new Li(e,t)}function Ld(e,t){return new Fi(e,t)}var Fd=I(()=>{tr();Rd();Td();Pd();tr();As()});var Ud=js((vI,Md)=>{var Lr=1e3,Fr=Lr*60,Mr=Fr*60,nr=Mr*24,lw=nr*7,cw=nr*365.25;Md.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return uw(e);if(n==="number"&&isFinite(e))return t.long?pw(e):fw(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function uw(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*cw;case"weeks":case"week":case"w":return n*lw;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 fw(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 pw(e){var t=Math.abs(e);return t>=nr?Mi(e,t,nr,"day"):t>=Mr?Mi(e,t,Mr,"hour"):t>=Fr?Mi(e,t,Fr,"minute"):t>=Lr?Mi(e,t,Lr,"second"):e+" ms"}function Mi(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}});var Bd=js((II,Wd)=>{function hw(e){n.debug=n,n.default=n,n.coerce=l,n.disable=a,n.enable=s,n.enabled=o,n.humanize=Ud(),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 y=d,w=Number(new Date),b=w-(f||w);y.diff=b,y.prev=f,y.curr=w,f=w,g[0]=n.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let x=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,($,O)=>{if($==="%%")return"%";x++;let F=n.formatters[O];if(typeof F=="function"){let R=g[x];$=F.call(y,R),g.splice(x,1),x--}return $}),n.formatArgs.call(y,g),(y.log||n.log).apply(y,g)}return d.namespace=u,d.useColors=n.useColors(),d.color=n.selectColor(u),d.extend=r,d.destroy=n.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>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}Wd.exports=hw});var zd=js((Rt,Ui)=>{Rt.formatArgs=mw;Rt.save=gw;Rt.load=yw;Rt.useColors=dw;Rt.storage=ww();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 dw(){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 mw(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ui.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 gw(e){try{e?Rt.storage.setItem("debug",e):Rt.storage.removeItem("debug")}catch{}}function yw(){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 ww(){try{return localStorage}catch{}}Ui.exports=Bd()(Rt);var{formatters:bw}=Ui.exports;bw.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var rr,cl,Hd,jd,Vd,Gd=I(()=>{bs();rr={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},cl={get(e){return{signature:Qe.get(e,0),compressedSize:Qe.get(e,8),uncompressedSize:Qe.get(e,12)}},len:16},Hd={get(e){let t=Ge.get(e,6);return{signature:Qe.get(e,0),minVersion:Ge.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,8),compressedSize:Qe.get(e,18),uncompressedSize:Qe.get(e,22),filenameLength:Ge.get(e,26),extraFieldLength:Ge.get(e,28),filename:null}},len:30},jd={get(e){return{signature:Qe.get(e,0),nrOfThisDisk:Ge.get(e,4),nrOfThisDiskWithTheStart:Ge.get(e,6),nrOfEntriesOnThisDisk:Ge.get(e,8),nrOfEntriesOfSize:Ge.get(e,10),sizeOfCd:Qe.get(e,12),offsetOfStartOfCd:Qe.get(e,16),zipFileCommentLength:Ge.get(e,20)}},len:22},Vd={get(e){let t=Ge.get(e,8);return{signature:Qe.get(e,0),minVersion:Ge.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,10),compressedSize:Qe.get(e,20),uncompressedSize:Qe.get(e,24),filenameLength:Ge.get(e,28),extraFieldLength:Ge.get(e,30),fileCommentLength:Ge.get(e,32),relativeOffsetOfLocalHeader:Qe.get(e,42),filename:null}},len:46}});function Zd(e){let t=new Uint8Array(Qe.len);return Qe.put(t,0,e),t}function Ew(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 Aw(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 qd,gn,ul,xw,Wi,Ss,Kd=I(()=>{bs();qd=yu(zd(),1);Gd();gn=(0,qd.default)("tokenizer:inflate"),ul=256*1024,xw=Zd(rr.DataDescriptor),Wi=Zd(rr.EndOfCentralDirectory),Ss=class e{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(ul)}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]===Wi[0]&&r[s+1]===Wi[1]&&r[s+2]===Wi[2]&&r[s+3]===Wi[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(jd,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let a=await this.tokenizer.readToken(Vd);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=ul;gn("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===ul;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=Ew(this.syncBuffer.subarray(0,l),xw);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,Aw(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(cl)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-cl.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(Hd);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,Qd=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 Xd=I(()=>{Kd();Qd()});function fl(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 MI,UI,WI,Yd=I(()=>{MI={utf8:new globalThis.TextDecoder("utf8")},UI=new globalThis.TextEncoder,WI=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});function Jd(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 e0(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 t0,n0=I(()=>{bs();t0={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}});var r0,s0,i0=I(()=>{r0=["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"],s0=["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 a0(e,t){return new dl(t).fromBuffer(e)}function hl(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 pl,dl,KI,QI,o0=I(()=>{bs();Fd();Xd();Yd();n0();i0();pl=4100;dl=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(_d(n,this.tokenizerOptions))}async fromBlob(t){let n=Ld(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(t){let n=Dd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(t,n){let{sampleSize:r=pl}=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(Jd(t,n?.encoding),n)}detectConfident=async t=>{if(this.buffer=new Uint8Array(pl),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(t0);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=hl(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=hl(o))}else{i=i.slice(0,Math.max(0,a));let o=i.lastIndexOf('"'),l=i.slice(Math.max(0,o+1));n=hl(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(Sd),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:fl(u),len:fl(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 H5,Ti=I(()=>{"use strict";se();H5=new Map([["sha1","SHA-1"],["sha256","SHA-256"]])});var hd={};K(hd,{flagsForFuzzing:()=>G5,md5sumCommand:()=>V5});var V5,G5,dd=I(()=>{"use strict";Ti();V5=Pr("md5sum","md5","compute MD5 message digest"),G5={name:"md5sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var md={};K(md,{flagsForFuzzing:()=>Z5,sha1sumCommand:()=>q5});var q5,Z5,gd=I(()=>{"use strict";Ti();q5=Pr("sha1sum","sha1","compute SHA1 message digest"),Z5={name:"sha1sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var yd={};K(yd,{flagsForFuzzing:()=>Q5,sha256sumCommand:()=>K5});var K5,Q5,wd=I(()=>{"use strict";Ti();K5=Pr("sha256sum","sha256","compute SHA256 message digest"),Q5={name:"sha256sum",flags:[{flag:"-c",type:"boolean"}],needsFiles:!0}});var bd=js(sl=>{sl.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)};sl.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 xd(e,t="utf-8"){switch(t.toLowerCase()){case"utf-8":case"utf8":return typeof globalThis.TextDecoder<"u"?new globalThis.TextDecoder("utf-8").decode(e):Y5(e);case"utf-16le":return J5(e);case"ascii":return ew(e);case"latin1":case"iso-8859-1":return tw(e);case"windows-1252":return nw(e);default:throw new RangeError(`Encoding '${t}' not supported`)}}function Y5(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 J5(e){let t="";for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function ew(e){return String.fromCharCode(...e.map(t=>t&127))}function tw(e){return String.fromCharCode(...e)}function nw(e){let t="";for(let n of e)n>=128&&n<=159&&il[n]?t+=il[n]:t+=String.fromCharCode(n);return t}var il,X5,Ed=I(()=>{il={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"},X5={};for(let[e,t]of Object.entries(il))X5[t]=Number.parseInt(e)});function $t(e){return new DataView(e.buffer,e.byteOffset)}var Ad,Sd,Ge,Dr,Qe,Cd,Nd,kd,Ot,bs=I(()=>{Ad=yu(bd(),1);Ed();Sd={len:1,get(e,t){return $t(e).getUint8(t)},put(e,t,n){return $t(e).setUint8(t,n),t+1}},Ge={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}},Cd={len:4,get(e,t){return $t(e).getUint32(t)},put(e,t,n){return $t(e).setUint32(t,n),t+4}},Nd={len:4,get(e,t){return $t(e).getInt32(t)},put(e,t,n){return $t(e).setInt32(t,n),t+4}},kd={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 xd(r,this.encoding)}}});var sw,We,Jn,xs=I(()=>{sw="End-Of-Stream",We=class extends Error{constructor(){super(sw),this.name="EndOfStreamError"}},Jn=class extends Error{constructor(t="The operation was aborted"){super(t),this.name="AbortError"}}});var vd=I(()=>{});var er,Pi=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 Id=I(()=>{xs();vd();Pi()});var Di,$d=I(()=>{Pi();Di=class extends er{constructor(t){super(),this.reader=t}async abort(){return this.close()}async close(){this.reader.releaseLock()}}});var Es,al=I(()=>{$d();Es=class extends Di{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,ol=I(()=>{xs();Pi();_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 ll(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 Od=I(()=>{al();ol()});var tr=I(()=>{xs();Id();al();ol();Od()});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 aw,_i,Rd=I(()=>{As();tr();aw=256e3,_i=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(aw,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 Li,Td=I(()=>{tr();As();Li=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 Fi,Pd=I(()=>{tr();As();Fi=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 Dd(e,t){let n=ll(e),r=t??{},s=r.onClose;return r.onClose=async()=>{if(await n.close(),s)return s()},new _i(n,r)}function _d(e,t){return new Li(e,t)}function Ld(e,t){return new Fi(e,t)}var Fd=I(()=>{tr();Rd();Td();Pd();tr();As()});var Ud=js((vI,Md)=>{var Lr=1e3,Fr=Lr*60,Mr=Fr*60,nr=Mr*24,lw=nr*7,cw=nr*365.25;Md.exports=function(e,t){t=t||{};var n=typeof e;if(n==="string"&&e.length>0)return uw(e);if(n==="number"&&isFinite(e))return t.long?pw(e):fw(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function uw(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*cw;case"weeks":case"week":case"w":return n*lw;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 fw(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 pw(e){var t=Math.abs(e);return t>=nr?Mi(e,t,nr,"day"):t>=Mr?Mi(e,t,Mr,"hour"):t>=Fr?Mi(e,t,Fr,"minute"):t>=Lr?Mi(e,t,Lr,"second"):e+" ms"}function Mi(e,t,n,r){var s=t>=n*1.5;return Math.round(e/n)+" "+r+(s?"s":"")}});var Bd=js((II,Wd)=>{function hw(e){n.debug=n,n.default=n,n.coerce=l,n.disable=a,n.enable=s,n.enabled=o,n.humanize=Ud(),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}Wd.exports=hw});var zd=js((Rt,Ui)=>{Rt.formatArgs=mw;Rt.save=gw;Rt.load=yw;Rt.useColors=dw;Rt.storage=ww();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 dw(){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 mw(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ui.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 gw(e){try{e?Rt.storage.setItem("debug",e):Rt.storage.removeItem("debug")}catch{}}function yw(){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 ww(){try{return localStorage}catch{}}Ui.exports=Bd()(Rt);var{formatters:bw}=Ui.exports;bw.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var rr,cl,Hd,jd,Vd,Gd=I(()=>{bs();rr={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},cl={get(e){return{signature:Qe.get(e,0),compressedSize:Qe.get(e,8),uncompressedSize:Qe.get(e,12)}},len:16},Hd={get(e){let t=Ge.get(e,6);return{signature:Qe.get(e,0),minVersion:Ge.get(e,4),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,8),compressedSize:Qe.get(e,18),uncompressedSize:Qe.get(e,22),filenameLength:Ge.get(e,26),extraFieldLength:Ge.get(e,28),filename:null}},len:30},jd={get(e){return{signature:Qe.get(e,0),nrOfThisDisk:Ge.get(e,4),nrOfThisDiskWithTheStart:Ge.get(e,6),nrOfEntriesOnThisDisk:Ge.get(e,8),nrOfEntriesOfSize:Ge.get(e,10),sizeOfCd:Qe.get(e,12),offsetOfStartOfCd:Qe.get(e,16),zipFileCommentLength:Ge.get(e,20)}},len:22},Vd={get(e){let t=Ge.get(e,8);return{signature:Qe.get(e,0),minVersion:Ge.get(e,6),dataDescriptor:!!(t&8),compressedMethod:Ge.get(e,10),compressedSize:Qe.get(e,20),uncompressedSize:Qe.get(e,24),filenameLength:Ge.get(e,28),extraFieldLength:Ge.get(e,30),fileCommentLength:Ge.get(e,32),relativeOffsetOfLocalHeader:Qe.get(e,42),filename:null}},len:46}});function Zd(e){let t=new Uint8Array(Qe.len);return Qe.put(t,0,e),t}function Ew(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 Aw(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 qd,gn,ul,xw,Wi,Ss,Kd=I(()=>{bs();qd=yu(zd(),1);Gd();gn=(0,qd.default)("tokenizer:inflate"),ul=256*1024,xw=Zd(rr.DataDescriptor),Wi=Zd(rr.EndOfCentralDirectory),Ss=class e{constructor(t){this.tokenizer=t,this.syncBuffer=new Uint8Array(ul)}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]===Wi[0]&&r[s+1]===Wi[1]&&r[s+2]===Wi[2]&&r[s+3]===Wi[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(jd,n),s=[];this.tokenizer.setPosition(r.offsetOfStartOfCd);for(let i=0;i<r.nrOfEntriesOfSize;++i){let a=await this.tokenizer.readToken(Vd);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=ul;gn("Compressed-file-size unknown, scanning for next data-descriptor-signature....");let c=-1;for(;c<0&&l===ul;){l=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),c=Ew(this.syncBuffer.subarray(0,l),xw);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,Aw(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(cl)).signature!==134695760)throw new Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-cl.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(Hd);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,Qd=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 Xd=I(()=>{Kd();Qd()});function fl(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 MI,UI,WI,Yd=I(()=>{MI={utf8:new globalThis.TextDecoder("utf8")},UI=new globalThis.TextEncoder,WI=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"))});function Jd(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 e0(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 t0,n0=I(()=>{bs();t0={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4}});var r0,s0,i0=I(()=>{r0=["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"],s0=["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 a0(e,t){return new dl(t).fromBuffer(e)}function hl(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 pl,dl,KI,QI,o0=I(()=>{bs();Fd();Xd();Yd();n0();i0();pl=4100;dl=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(_d(n,this.tokenizerOptions))}async fromBlob(t){let n=Ld(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async fromStream(t){let n=Dd(t,this.tokenizerOptions);try{return await this.fromTokenizer(n)}finally{await n.close()}}async toDetectionStream(t,n){let{sampleSize:r=pl}=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(Jd(t,n?.encoding),n)}detectConfident=async t=>{if(this.buffer=new Uint8Array(pl),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(t0);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=hl(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=hl(o))}else{i=i.slice(0,Math.max(0,a));let o=i.lastIndexOf('"'),l=i.slice(Math.max(0,o+1));n=hl(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(Sd),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:fl(u),len:fl(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(Nd),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(kd))}}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})&&e0(this.buffer))return{ext:"tar",mime:"application/x-tar"};if(this.check([255,254])){let n="utf-16le";return this.checkString("<?xml ",{offset:2,encoding:n})?{ext:"xml",mime:"application/xml"}:this.check([255,14],{offset:2})&&this.checkString("SketchUp Model",{offset:4,encoding:n})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:this.checkString(`Windows Registry Editor Version 5.00\r
|
|
621
621
|
`,{offset:2,encoding:n})?{ext:"reg",mime:"application/x-ms-regedit"}:void 0}if(this.checkString("-----BEGIN PGP MESSAGE-----"))return{ext:"pgp",mime:"application/pgp-encrypted"}};detectImprecise=async t=>{if(this.buffer=new Uint8Array(pl),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:Ge);switch(this.tokenizer.ignore(10),n){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"};default:}}async readTiffIFD(t){let n=await this.tokenizer.readToken(t?Dr:Ge);for(let r=0;r<n;++r){let s=await this.readTiffTag(t);if(s)return s}}async readTiffHeader(t){let n=(t?Dr:Ge).get(this.buffer,2),r=(t?Cd: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:Ge).get(this.buffer,8),a=(t?Dr:Ge).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"}}}},KI=new Set(r0),QI=new Set(s0)});var l0={};K(l0,{fileCommand:()=>Ow,flagsForFuzzing:()=>Rw});function kw(e,t){let n=Nw.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 vw(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 Iw(e,t){if(e.startsWith("#!")){let c=e.split(`
|
|
@@ -655,7 +655,7 @@ Otherwise, lists all available commands.
|
|
|
655
655
|
`:"",stderr:"",exitCode:0}}var Vw,Gw,y0=I(()=>{"use strict";Vw={name:"tac",execute:jw},Gw={name:"tac",flags:[],stdinType:"text",needsFiles:!0}});var w0={};K(w0,{flagsForFuzzing:()=>Kw,hostname:()=>Zw});async function qw(e,t){return{stdout:`localhost
|
|
656
656
|
`,stderr:"",exitCode:0}}var Zw,Kw,b0=I(()=>{"use strict";Zw={name:"hostname",execute:qw},Kw={name:"hostname",flags:[]}});var x0={};K(x0,{flagsForFuzzing:()=>Yw,whoami:()=>Xw});async function Qw(e,t){return{stdout:`user
|
|
657
657
|
`,stderr:"",exitCode:0}}var Xw,Yw,E0=I(()=>{"use strict";Xw={name:"whoami",execute:Qw},Yw={name:"whoami",flags:[]}});var A0={};K(A0,{flagsForFuzzing:()=>tb,od:()=>eb});async function Jw(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
|
-
`,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],
|
|
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
660
|
`:"",stderr:"",exitCode:0}}var eb,tb,S0=I(()=>{"use strict";eb={name:"od",execute:Jw},tb={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 zi={};K(zi,{flagsForFuzzing:()=>pb,gunzipCommand:()=>ub,gunzipFlagsForFuzzing:()=>hb,gzipCommand:()=>cb,zcatCommand:()=>fb,zcatFlagsForFuzzing:()=>db});import{constants as ml,gunzipSync as gl,gzipSync as C0}from"node:zlib";function N0(e){return e.best?ml.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?ml.Z_BEST_SPEED:ml.Z_DEFAULT_COMPRESSION}function k0(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 ab(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 Bi(e){return e.length>=2&&e[0]===31&&e[1]===139}async function v0(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(!Bi(c))return n.quiet?{stdout:"",stderr:"",exitCode:1}:{stdout:"",stderr:`${r}: stdin: not in gzip format
|
|
661
661
|
`,exitCode:1};try{let u=gl(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}
|
|
@@ -728,7 +728,7 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
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]!==`
|
|
729
729
|
`;)a++;let o=s.slice(t,a);return this.pos=a,this.column=r+(a-t),{type:E.COMMENT,value:o,start:t,end:a,line:n,column:r}}readWord(t,n,r){let s=this.input,i=s.length,a=this.pos,o=a;for(;a<i;){let b=s[a];if(b===" "||b===" "||b===`
|
|
730
730
|
`||b===";"||b==="&"||b==="|"||b==="("||b===")"||b==="<"||b===">"||b==="'"||b==='"'||b==="\\"||b==="$"||b==="`"||b==="{"||b==="}"||b==="~"||b==="*"||b==="?"||b==="[")break;a++}if(a>o){let b=s[a];if(!(b==="("&&a>o&&"@*+?!".includes(s[a-1]))){if(a>=i||b===" "||b===" "||b===`
|
|
731
|
-
`||b===";"||b==="&"||b==="|"||b==="("||b===")"||b==="<"||b===">"){let x=s.slice(o,a);this.pos=a,this.column=r+(a-o);let S=K0.get(x);if(S!==void 0)return{type:S,value:x,start:t,end:a,line:n,column:r};let $=X0(x);return $>0&&Q0(x.slice(0,$))?{type:E.ASSIGNMENT_WORD,value:x,start:t,end:a,line:n,column:r}:/^[0-9]+$/.test(x)?{type:E.NUMBER,value:x,start:t,end:a,line:n,column:r}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(x)?{type:E.NAME,value:x,start:t,end:a,line:n,column:r,quoted:!1,singleQuoted:!1}:{type:E.WORD,value:x,start:t,end:a,line:n,column:r,quoted:!1,singleQuoted:!1}}}}a=this.pos;let l=this.column,c=this.line,u="",f=!1,p=!1,h=!1,m=!1,d=s[a]==='"'||s[a]==="'",g=!1,
|
|
731
|
+
`||b===";"||b==="&"||b==="|"||b==="("||b===")"||b==="<"||b===">"){let x=s.slice(o,a);this.pos=a,this.column=r+(a-o);let S=K0.get(x);if(S!==void 0)return{type:S,value:x,start:t,end:a,line:n,column:r};let $=X0(x);return $>0&&Q0(x.slice(0,$))?{type:E.ASSIGNMENT_WORD,value:x,start:t,end:a,line:n,column:r}:/^[0-9]+$/.test(x)?{type:E.NUMBER,value:x,start:t,end:a,line:n,column:r}:/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(x)?{type:E.NAME,value:x,start:t,end:a,line:n,column:r,quoted:!1,singleQuoted:!1}:{type:E.WORD,value:x,start:t,end:a,line:n,column:r,quoted:!1,singleQuoted:!1}}}}a=this.pos;let l=this.column,c=this.line,u="",f=!1,p=!1,h=!1,m=!1,d=s[a]==='"'||s[a]==="'",g=!1,w=0;for(;a<i;){let b=s[a];if(!h&&!m){if(b==="("&&u.length>0&&"@*+?!".includes(u[u.length-1])){let x=this.scanExtglobPattern(a);if(x!==null){u+=x.content,a=x.end,l+=x.content.length;continue}}if(b==="["&&w===0){if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(u)){let x=a+1<i?s[a+1]:"";if(x==="^"||x==="!"){u+=b,a++,l++;continue}w=1,u+=b,a++,l++;continue}}else if(b==="["&&w>0){u.length>0&&u[u.length-1]!=="\\"&&w++,u+=b,a++,l++;continue}else if(b==="]"&&w>0){u.length>0&&u[u.length-1]!=="\\"&&w--,u+=b,a++,l++;continue}if(w>0){if(b===`
|
|
732
732
|
`)break;u+=b,a++,l++;continue}if(b===" "||b===" "||b===`
|
|
733
733
|
`||b===";"||b==="&"||b==="|"||b==="("||b===")"||b==="<"||b===">")break}if(b==="$"&&a+1<i&&s[a+1]==="'"&&!h&&!m){for(u+="$'",a+=2,l+=2;a<i&&s[a]!=="'";)s[a]==="\\"&&a+1<i?(u+=s[a]+s[a+1],a+=2,l+=2):(u+=s[a],a++,l++);a<i&&(u+="'",a++,l++);continue}if(b==="$"&&a+1<i&&s[a+1]==='"'&&!h&&!m){a++,l++,m=!0,f=!0,u===""&&(d=!0),a++,l++;continue}if(b==="'"&&!m){if(h)if(h=!1,!d||g)u+=b;else{let x=a+1<i?s[a+1]:"";x&&!Y0(x)&&x!=="'"&&(x==='"'?(g=!0,u+=b,p=!1,f=!1):(g=!0,u+=b))}else h=!0,d&&!g?(p=!0,f=!0):u+=b;a++,l++;continue}if(b==='"'&&!h){if(m)if(m=!1,!d||g)u+=b;else{let x=a+1<i?s[a+1]:"";x&&!Y0(x)&&x!=='"'&&(x==="'"?(g=!0,u+=b,p=!1,f=!1):(g=!0,u+=b))}else m=!0,d&&!g?f=!0:u+=b;a++,l++;continue}if(b==="\\"&&!h&&a+1<i){let x=s[a+1];if(x===`
|
|
734
734
|
`){a+=2,c++,l=1;continue}if(m){if(x==='"'||x==="\\"||x==="$"||x==="`"||x===`
|
|
@@ -741,7 +741,7 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
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
|
|
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=K0.get(u);if(!f&&y!==void 0)return{type:y,value:u,start:t,end:a,line:n,column:r};if(!d){let b=X0(u);if(b>0&&Q0(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}:Fb(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+=`
|
|
@@ -759,9 +759,9 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
759
759
|
`){t+=2;continue}if(/\s/.test(e[t])){t++;continue}break}return t}function ks(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 rm(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 sm(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
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 im(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,am=I(()=>{"use strict";Gi=["=","+=","-=","*=","/=","%=","<<=",">>=","&=","|=","^="]});function Mb(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=Mb(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 Ub(e,t,n)}function Ub(e,t,n){let{expr:r,pos:s}=vs(e,t,n);for(s=Be(t,s);t[s]===",";){if(s++,Pt(t,s))return Tt(",",s);let{expr:a,pos:o}=vs(e,t,s);r={type:"ArithBinary",operator:",",left:r,right:a},s=Be(t,o)}return{expr:r,pos:s}}function vs(e,t,n){let{expr:r,pos:s}=Wb(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 Wb(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.slice(s,s+2)==="&&";){if(s+=2,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]==="|"&&t[s+1]!=="|";){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]==="^";){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[s]==="&"&&t[s+1]!=="&";){if(s++,Pt(t,s))return Tt("&",s);let{expr:a,pos:o}=fm(e,t,s);r={type:"ArithBinary",operator:"&",left:r,right:a},s=o}return{expr:r,pos:s}}function fm(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}=Dl(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}=Dl(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}=Dl(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else break;return{expr:r,pos:s}}function Dl(e,t,n){let{expr:r,pos:s}=hm(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}=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}=dm(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}=dm(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}return{expr:r,pos:s}}function dm(e,t,n){let{expr:r,pos:s}=qi(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}=qi(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}=qi(e,t,s);r={type:"ArithBinary",operator:i,left:r,right:a},s=o}else break;return{expr:r,pos:s}}function qi(e,t,n){let{expr:r,pos:s}=_l(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}=qi(e,t,i);return{expr:{type:"ArithBinary",operator:"**",left:r,right:o},pos:l}}return{expr:r,pos:s}}function _l(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}=_l(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}=_l(e,t,r);return{expr:{type:"ArithUnary",operator:s,operand:i,prefix:!0},pos:a}}return zb(e,t,r)}function Bb(e,t){let n=e[t];return n==="$"||n==="`"}function zb(e,t,n){let{expr:r,pos:s}=mm(e,t,n,!1),i=[r];for(;Bb(t,s);){let{expr:o,pos:l}=mm(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}=vs(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 mm(e,t,n,r=!1){let s=Be(t,n),i=rm(Ht,e,t,s);if(i)return i;let a=sm(t,s);if(a)return a;let o=im(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:ks(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}=vs(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}=vs(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
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 mt=I(()=>{"use strict";ye();am()});function Hb(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 wm(e,t,n){let r=n+1;for(;r<t.length&&/[a-zA-Z0-9_-]/.test(t[r]);)r++;return r}function Ll(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 bm(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 xm(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=jb(t,r);a===-1?(s+=i,r++):(s+=t.slice(r,a+1),r=a+1)}else break}return{pattern:s,endIndex:r}}function jb(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 Em(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+=Hb(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 Fl(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ae(e,n)}function ym(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 Am(e,t,n,r){let s=Ll(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:ym(i).map(u=>({type:"Word",word:q.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:ym(i).map(u=>({type:"Word",word:q.word([q.literal(u)])}))},endIndex:s+1}:null}function Ml(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(Ml(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 Sm(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 Ul=I(()=>{"use strict";ar();mt();Fn()});function Zi(e){let t=e.current(),n=t.type;if(n===E.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:tm.has(r.type)}if(n===E.FD_VARIABLE){let r=e.peek(1);return nm.has(r.type)}return em.has(n)}function Ki(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=Sm(e,r.type);if(r.type===E.DLESS||r.type===E.DLESSDASH)return Vb(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 Vb(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 Nm(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(E.ASSIGNMENT_WORD)||Zi(e);)e.checkIterationLimit(),e.check(E.ASSIGNMENT_WORD)?n.push(Gb(e)):i.push(Ki(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(),Zi(e))i.push(Ki(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=Wl(e);e.expect(E.RPAREN);let h=p.map(d=>Ml(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=Wl(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=Wl(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 Wl(e){let t=[];for(e.skipNewlines();!e.check(E.RPAREN,E.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):qb.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var qb,km=I(()=>{"use strict";ar();Fn();ir();Ul();qb=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 Bl(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 zl(e,t){let n=e.expect(E.FOR);if(e.check(E.DPAREN_START))return Kb(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 Kb(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 Hl(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 jl(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 Vl(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=Qb(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 Qb(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 ql(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 vm=I(()=>{"use strict";ar();mt();Fn()});function Im(e){return e.isWord()||e.check(E.LBRACE)||e.check(E.RBRACE)||e.check(E.ASSIGNMENT_WORD)}function $m(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 Kl(e){return e.skipNewlines(),ex(e)}function ex(e){let t=Om(e);for(e.skipNewlines();e.check(E.OR_OR);){e.advance(),e.skipNewlines();let n=Om(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function Om(e){let t=Zl(e);for(e.skipNewlines();e.check(E.AND_AND);){e.advance(),e.skipNewlines();let n=Zl(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function Zl(e){return e.skipNewlines(),e.check(E.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:Zl(e)}):tx(e)}function tx(e){if(e.check(E.LPAREN)){e.advance();let t=Kl(e);return e.expect(E.RPAREN),{type:"CondGroup",expression:t}}if(Im(e)){let t=e.current(),n=t.value;if(Yb.includes(n)&&!t.quoted){if(e.advance(),e.check(E.DBRACK_END)&&e.error(`Expected operand after ${n}`),Im(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()&&Jb.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=nx(e):s==="=="||s==="!="?i=$m(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=$m(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function nx(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 Yb,Jb,Rm=I(()=>{"use strict";Fn();Yb=["-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"],Jb=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function sx(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 ix(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 ax(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=Ll(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=Ql(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=Ql(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=Ql(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 Ql(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 y=or(e,t,i),w=t.slice(i,y),b=Mn(e,w,!1,!1,!0,!1,s,!1,!1,!0),x=q.word(b.length>0?b:[q.literal("")]);if(l==="-")return{operation:{type:"DefaultValue",word:x,checkEmpty:!0},endIndex:y};if(l==="=")return{operation:{type:"AssignDefault",word:x,checkEmpty:!0},endIndex:y};if(l==="?")return{operation:{type:"ErrorIfUnset",word:x,checkEmpty:!0},endIndex:y};if(l==="+")return{operation:{type:"UseAlternative",word:x,checkEmpty:!0},endIndex:y}}i++;let c=or(e,t,i),u=t.slice(i,c),f=-1,p=0,h=0;for(let g=0;g<u.length;g++){let y=u[g];if(y==="("||y==="[")p++;else if(y===")"||y==="]")p--;else if(y==="?"&&p===0)h++;else if(y===":"&&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:Fl(e,m),length:d!==null?Fl(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=bm(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,y=or(e,t,g),w=t.slice(g,y),b=Mn(e,w,!1,!1,!1);m=q.word(b.length>0?b:[q.literal("")]),d=y}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 Xl(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==="{"?ax(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?ix(e,t,n):{part:q.literal("$"),endIndex:s}}function Tm(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}=Xl(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 ox(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}=Xl(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=Tm(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=Tm(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===`
|
|
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+=Hb(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 Fl(e,t){let n=t.trim();return n===""?{type:"ArithmeticExpression",expression:{type:"ArithNumber",value:0}}:Ae(e,n)}function ym(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 Am(e,t,n,r){let s=Ll(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:ym(i).map(u=>({type:"Word",word:q.word(r(e,u,!1,!1,!1))}))},endIndex:s+1}:i.includes(",")?{part:{type:"BraceExpansion",items:ym(i).map(u=>({type:"Word",word:q.word([q.literal(u)])}))},endIndex:s+1}:null}function Ml(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(Ml(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 Sm(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 Ul=I(()=>{"use strict";ar();mt();Fn()});function Zi(e){let t=e.current(),n=t.type;if(n===E.NUMBER){let r=e.peek(1);return t.end!==r.start?!1:tm.has(r.type)}if(n===E.FD_VARIABLE){let r=e.peek(1);return nm.has(r.type)}return em.has(n)}function Ki(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=Sm(e,r.type);if(r.type===E.DLESS||r.type===E.DLESSDASH)return Vb(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 Vb(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 Nm(e){let t=e.current().line,n=[],r=null,s=[],i=[];for(;e.check(E.ASSIGNMENT_WORD)||Zi(e);)e.checkIterationLimit(),e.check(E.ASSIGNMENT_WORD)?n.push(Gb(e)):i.push(Ki(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(),Zi(e))i.push(Ki(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=Wl(e);e.expect(E.RPAREN);let h=p.map(d=>Ml(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=Wl(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=Wl(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 Wl(e){let t=[];for(e.skipNewlines();!e.check(E.RPAREN,E.EOF);)e.checkIterationLimit(),e.isWord()?t.push(e.parseWord()):qb.has(e.current().type)?e.error(`syntax error near unexpected token \`${e.current().value}'`):e.advance(),e.skipNewlines();return t}var qb,km=I(()=>{"use strict";ar();Fn();ir();Ul();qb=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 Bl(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 zl(e,t){let n=e.expect(E.FOR);if(e.check(E.DPAREN_START))return Kb(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 Kb(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 Hl(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 jl(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 Vl(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=Qb(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 Qb(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 ql(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 vm=I(()=>{"use strict";ar();mt();Fn()});function Im(e){return e.isWord()||e.check(E.LBRACE)||e.check(E.RBRACE)||e.check(E.ASSIGNMENT_WORD)}function $m(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 Kl(e){return e.skipNewlines(),ex(e)}function ex(e){let t=Om(e);for(e.skipNewlines();e.check(E.OR_OR);){e.advance(),e.skipNewlines();let n=Om(e);t={type:"CondOr",left:t,right:n},e.skipNewlines()}return t}function Om(e){let t=Zl(e);for(e.skipNewlines();e.check(E.AND_AND);){e.advance(),e.skipNewlines();let n=Zl(e);t={type:"CondAnd",left:t,right:n},e.skipNewlines()}return t}function Zl(e){return e.skipNewlines(),e.check(E.BANG)?(e.advance(),e.skipNewlines(),{type:"CondNot",operand:Zl(e)}):tx(e)}function tx(e){if(e.check(E.LPAREN)){e.advance();let t=Kl(e);return e.expect(E.RPAREN),{type:"CondGroup",expression:t}}if(Im(e)){let t=e.current(),n=t.value;if(Yb.includes(n)&&!t.quoted){if(e.advance(),e.check(E.DBRACK_END)&&e.error(`Expected operand after ${n}`),Im(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()&&Jb.includes(e.current().value)){let s=e.advance().value,i;return s==="=~"?i=nx(e):s==="=="||s==="!="?i=$m(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=$m(e);return{type:"CondBinary",operator:"==",left:r,right:s}}return{type:"CondWord",word:r}}e.error("Expected conditional expression")}function nx(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 Yb,Jb,Rm=I(()=>{"use strict";Fn();Yb=["-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"],Jb=["==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]});function sx(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 ix(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 ax(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=Ll(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=Ql(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=Ql(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=Ql(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 Ql(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:Fl(e,m),length:d!==null?Fl(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=bm(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 Xl(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==="{"?ax(e,t,n,r):/[a-zA-Z_0-9@*#?$!-]/.test(i)?ix(e,t,n):{part:q.literal("$"),endIndex:s}}function Tm(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}=Xl(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 ox(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}=Xl(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=Tm(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=Tm(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==="}",
|
|
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}=ox(e,t,f+1);u.push(d),f=g+1;continue}if(m==="$"&&t[f+1]==="'"){h();let{part:d,endIndex:g}=Em(e,t,f+2);u.push(d),f=g;continue}if(m==="$"){h();let{part:d,endIndex:g}=Xl(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=wm(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=sx(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}=xm(e,t,f);u.push({type:"Glob",pattern:d}),f=g;continue}if(m==="{"&&!s&&!o){let d=Am(e,t,f,Mn);if(d){h(),u.push(d.part),f=d.endIndex;continue}}p+=m,f++}return h(),u}var Pm=I(()=>{"use strict";ar();mt();ir();Ul()});function Dm(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 _m(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 Lm(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
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 Fm=I(()=>{"use strict";ar()});function rn(e){return new ce().parse(e)}var ce,Xe=I(()=>{"use strict";ar();mt();km();vm();Rm();Pm();Fn();Fm();ir();ir();ce=class e{tokens=[];pos=0;pendingHeredocs=[];parseIterations=0;parseDepth=0;_input="";getInput(){return this._input}checkIterationLimit(){if(this.parseIterations++,this.parseIterations>J0)throw new lt("Maximum parse iterations exceeded (possible infinite loop)",this.current().line,this.current().column)}enterDepth(){if(this.parseDepth++,this.parseDepth>Pl)throw new lt(`Maximum parser nesting depth exceeded (${Pl})`,this.current().line,this.current().column);return()=>{this.parseDepth--}}parse(t){if(t.length>Rl)throw new lt(`Input too large: ${t.length} bytes exceeds limit of ${Rl}`,1,1);this._input=t;let n=new Vi(t);if(this.tokens=n.tokenize(),this.tokens.length>Tl)throw new lt(`Too many tokens: ${this.tokens.length} exceeds limit of ${Tl}`,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)?Bl(this):this.check(E.FOR)?zl(this):this.check(E.WHILE)?Hl(this):this.check(E.UNTIL)?jl(this):this.check(E.CASE)?Vl(this):this.check(E.LPAREN)?Gl(this):this.check(E.LBRACE)?ql(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():Nm(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 _m(t,n,()=>new e,r=>this.error(r))}parseBacktickSubstitution(t,n,r=!1){return Lm(t,n,r,()=>new e,s=>this.error(s))}isDollarDparenSubshell(t,n){return Dm(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=Kl(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 ql(this,{skipRedirections:n});if(this.check(E.LPAREN))return Gl(this,{skipRedirections:n});if(this.check(E.IF))return Bl(this,{skipRedirections:n});if(this.check(E.FOR))return zl(this,{skipRedirections:n});if(this.check(E.WHILE))return Hl(this,{skipRedirections:n});if(this.check(E.UNTIL))return jl(this,{skipRedirections:n});if(this.check(E.CASE))return Vl(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(;Zi(this);){this.checkIterationLimit();let n=this.pos;if(t.push(Ki(this)),this.pos===n)break}return t}parseArithmeticExpression(t){return Ae(this,t)}}});function Jl(e){return ux.get(e)??""}function Hm(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 jm(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=Jl(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+="$",G(t)}function ec(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 tc(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 ux,Vm=I(()=>{"use strict";Me();ux=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,Qi=I(()=>{"use strict";ye();Me();mr();Vm();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=Hm(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 jm(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 G(`^${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=ec(t,s+1);if(a!==-1){let o=t.slice(s+2,a),l=tc(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=Jl(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=ec(t,r+1);if(a!==-1){if(i==="@"){let o=t.slice(r+2,a),c=tc(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 nc(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 fx(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 Is(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),fx(l)&&(t=!0),(l.operation?.type==="VarNamePrefix"||l.operation?.type==="ArrayKeys")&&(a=!0),l.operation?.type==="Indirection"&&(o=!0)),l.type==="Glob"&&nc(l.pattern)&&(i=!0)}return{hasQuoted:t,hasCommandSub:n,hasArrayVar:r,hasArrayAtExpansion:s,hasParamExpansion:i,hasVarNamePrefixExpansion:a,hasIndirection:o}}var Xi=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 Yi(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function rc(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=Yi(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:px(p)}):l.push(p)}return{key:r,valueParts:l,append:o}}function px(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 Ji(e){let t=rt(e);if(t==="")return!0;for(let n of t)if(n!==" "&&n!==" "&&n!==`
|
|
@@ -769,23 +769,23 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
769
769
|
`?"\\n":t).join("")}function fe(e){let t=e.get("IFS");return t===void 0?" ":t[0]||""}function dx(e){return hx.includes(e)}function sc(e){let t=new Set,n=new Set;for(let r of e)dx(r)?t.add(r):n.add(r);return{whitespace:t,nonWhitespace:n}}function ic(e,t,n,r){if(t==="")return e===""?{words:[],wordStarts:[]}:{words:[e],wordStarts:[0]};let{whitespace:s,nonWhitespace:i}=sc(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 ea(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}=sc(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 ea(e,t).words}function mx(e,t){for(let n of e)if(t.has(n))return!0;return!1}function Zm(e,t,n){if(t==="")return e;let{whitespace:r,nonWhitespace:s}=sc(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(!mx(o,s))return o}return a}var hx,jt=I(()=>{"use strict";hx=`
|
|
770
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 Km(e,t){e.state.namerefs?.delete(t),e.state.boundNamerefs?.delete(t),e.state.invalidNamerefs?.delete(t)}function Qm(e,t){e.state.invalidNamerefs??=new Set,e.state.invalidNamerefs.add(t)}function Xm(e,t){return e.state.invalidNamerefs?.has(t)??!1}function ac(e,t){e.state.boundNamerefs??=new Set,e.state.boundNamerefs.add(t)}function ta(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 St(e,t,n=100){if(!Te(e,t)||Xm(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 Ym(e,t,n,r=100){if(!Te(e,t)||Xm(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)&&ta(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 gx(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(process.pid);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":{let{ppid:a}=Ns();return String(a)}case"UID":{let{uid:a}=Ns();return String(a)}case"EUID":return String(process.geteuid?.()??Ns().uid);case"RANDOM":return String(Math.floor(Math.random()*32768));case"SECONDS":return String(Math.floor((Date.now()-e.state.startTime)/1e3));case"BASH_VERSION":return 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 wt("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 wt("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 wt("BASH_SOURCE");return""}}if(/^[a-zA-Z_][a-zA-Z0-9_]*\[\]$/.test(t))throw new bt(`\${${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=St(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=Yi(o);f=gx(e,f);let p=e.state.env.get(`${a}_${f}`);if(p===void 0&&n&&e.state.options.nounset)throw new wt(`${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=Yi(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();vl();Ct();ye();Xt();jt();an()});async function Jm(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 oc(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 e2=I(()=>{"use strict";Dt()});function yx(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<na;u+=a,f++)o.push(c(u));else for(let u=e,f=0;u>=t&&f<na;u-=a,f++)o.push(c(u));return o}function wx(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<na;p+=a,h++)f.push(String.fromCharCode(p));else for(let p=s,h=0;p>=i&&h<na;p-=a,h++)f.push(String.fromCharCode(p));return f}function lc(e,t,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:yx(e,t,n,r,s),literal:`{${e}..${t}${i}}`}:typeof e=="string"&&typeof t=="string"?{expanded:wx(e,t,n),literal:`{${e}..${t}${i}}`}:{expanded:null,literal:`{${e}..${t}${i}}`}}var na,t2=I(()=>{"use strict";ye();na=1e4});function n2(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 r2=I(()=>{"use strict"});function xn(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function cc(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=bx(e,s+1);if(a!==-1){let o=e.slice(s+2,a),c=xx(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=Ex(e,s);if(a===-1)r+="\\[",s++;else{let o=e.slice(s+1,a);r+=Ax(o),s=a+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function bx(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 xx(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 Ex(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 Ax(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+=Cx(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 Cx(e){return Sx.get(e)??""}var Sx,Vr=I(()=>{"use strict";Sx=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 G(`^${t}`,"s").replace(e,"");let s=G(`${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 Gr(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 Nx(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 $s(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 y="",w=r+1;for(;w<t.length&&w<r+4&&t[w]>="0"&&t[w]<="7";)y+=t[w],w++;let b=Number.parseInt(y,8)%256;n+=String.fromCharCode(b),r=w;continue}switch(g){case"\\":n+="\\",r+=2;break;case"a":n+="\x07",r+=2;break;case"e":n+="\x1B",r+=2;break;case"n":n+=`
|
|
773
|
-
`,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
|
|
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=Yi(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();vl();Ct();ye();Xt();jt();an()});async function Jm(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 oc(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 e2=I(()=>{"use strict";Dt()});function yx(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<na;u+=a,f++)o.push(c(u));else for(let u=e,f=0;u>=t&&f<na;u-=a,f++)o.push(c(u));return o}function wx(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<na;p+=a,h++)f.push(String.fromCharCode(p));else for(let p=s,h=0;p>=i&&h<na;p-=a,h++)f.push(String.fromCharCode(p));return f}function lc(e,t,n,r,s){let i=n!==void 0?`..${n}`:"";return typeof e=="number"&&typeof t=="number"?{expanded:yx(e,t,n,r,s),literal:`{${e}..${t}${i}}`}:typeof e=="string"&&typeof t=="string"?{expanded:wx(e,t,n),literal:`{${e}..${t}${i}}`}:{expanded:null,literal:`{${e}..${t}${i}}`}}var na,t2=I(()=>{"use strict";ye();na=1e4});function n2(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 r2=I(()=>{"use strict"});function xn(e,t){return!!(/[*?[]/.test(e)||t&&/[@*+?!]\(/.test(e))}function cc(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=bx(e,s+1);if(a!==-1){let o=e.slice(s+2,a),c=xx(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=Ex(e,s);if(a===-1)r+="\\[",s++;else{let o=e.slice(s+1,a);r+=Ax(o),s=a+1}}else/[\^$.|+(){}]/.test(i)?(r+=`\\${i}`,s++):(r+=i,s++)}return r}function bx(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 xx(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 Ex(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 Ax(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+=Cx(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 Cx(e){return Sx.get(e)??""}var Sx,Vr=I(()=>{"use strict";Sx=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 G(`^${t}`,"s").replace(e,"");let s=G(`${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 Gr(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 Nx(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 $s(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+=Nx(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 uc=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 fc=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 ra(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 sa=I(()=>{"use strict";an();Bn()});async function s2(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 i2(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 a2(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 o2(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 l2(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 G(`^${i}`,"s").replace(t,"");let o=G(`${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 c2(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=G(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 u2(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 f2(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 p2(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=G(`^(?:${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 h2(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 $s(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 d2(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 m2(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 g2(e,t){e.coverage?.hit("bash:expansion:var_name_prefix");let n=Gr(e,t.prefix);return t.star?n.join(fe(e.state.env)):n.join(" ")}function y2(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 w2=I(()=>{"use strict";mt();Xe();Me();Ct();ye();jt();an();jr();Vr();cr();uc();fc();Dt();sa()});function b2(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 x2(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 ia(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 pc(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=kx(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 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){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 E2(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 vx(e,o);n+=_t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=x2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await ia(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 ia(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 vx(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=x2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await ia(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 ia(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 A2=I(()=>{"use strict";Xe();ye();Hr()});function S2(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 C2=I(()=>{"use strict"});async function Ix(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 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!=="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 Ix(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=G(m,c.all?"g":"");for(let y of f)d.push(g.replace(y,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 k2(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 v2=I(()=>{"use strict";Me();jt();jr();Vr();cr();Dt()});async function I2(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 $2(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 y=g.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(y){a=d,o=y[1],l=y[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="",y=e.state.shoptOptions.extglob;if(d.pattern)for(let w of d.pattern.parts)if(w.type==="Glob")g+=me(w.pattern,d.greedy,y);else if(w.type==="Literal")g+=me(w.value,d.greedy,y);else if(w.type==="SingleQuoted"||w.type==="Escaped")g+=xe(w.value);else if(w.type==="DoubleQuoted"){let b=await s(e,w.parts);g+=xe(b)}else if(w.type==="ParameterExpansion"){let b=await r(e,w);g+=me(b,d.greedy,y)}else{let b=await r(e,w);g+=xe(b)}h=h.map(w=>$n(w,g,d.side,d.greedy))}else if(c?.type==="PatternReplacement"){let d=c,g="";if(d.pattern)for(let b of d.pattern.parts)if(b.type==="Glob")g+=me(b.pattern,!0,e.state.shoptOptions.extglob);else if(b.type==="Literal")g+=me(b.value,!0,e.state.shoptOptions.extglob);else if(b.type==="SingleQuoted"||b.type==="Escaped")g+=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 y=d.replacement?await s(e,d.replacement.parts):"",w=g;d.anchor==="start"?w=`^${g}`:d.anchor==="end"&&(w=`${g}$`);try{let b=G(w,d.all?"g":"");h=h.map(x=>b.replace(x,y))}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 O2(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 R2=I(()=>{"use strict";Me();jt();jr();Vr();cr();Dt()});async function T2(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(([y])=>typeof y=="number"&&y>=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 P2(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=$s(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])=>$s(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 D2=I(()=>{"use strict";ye();jt();uc();fc();Dt();sa()});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")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 L2(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 F2=I(()=>{"use strict";an();Dt()});async function M2(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 $x(e,p,u,f,o.innerOp);if(o.innerOp.type==="DefaultValue"||o.innerOp.type==="UseAlternative"||o.innerOp.type==="AssignDefault"||o.innerOp.type==="ErrorIfUnset")return Ox(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},y=e.state.env.get("_indirect_elem_");e.state.env.set("_indirect_elem_",d);try{let w=await r(e,g,!0);m.push(w)}finally{y!==void 0?e.state.env.set("_indirect_elem_",y):e.state.env.delete("_indirect_elem_")}}return f?{values:[m.join(fe(e.state.env))],quoted:!0}:{values:m,quoted:!0}}if(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 $x(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 Ox(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 U2(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 y=d.map(([,w])=>w);return m?{values:[y.join(fe(e.state.env))],quoted:!0}:{values:y,quoted:!0}}let g=e.state.env.get(h);return g!==void 0?{values:[g],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}async function W2(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]==="*",y=oe(e,d);if(y.length>0){let b=y.map(([,x])=>x);return g?{values:[b.join(fe(e.state.env))],quoted:!0}:{values:b,quoted:!0}}let w=e.state.env.get(d);return w!==void 0?{values:[w],quoted:!0}:{values:[],quoted:!0}}return{values:[],quoted:!1}}var B2=I(()=>{"use strict";Ct();ye();jt();Dt();sa()});function z2(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 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 b=s.parts[w];if(b.type==="ParameterExpansion"&&(b.parameter==="@"||b.parameter==="*")&&b.operation?.type==="Substring"){i=w,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 w=1;w<=f;w++)p.push(e.state.env.get(String(w))||"");let h=e.state.env.get("0")||"bash",m;if(c<=0){let w=[h,...p],b=w.length+c;if(b<0)m=[];else{let x=c<0?b:0;if(u!==void 0){let S=u<0?w.length+u:x+u;m=w.slice(x,Math.max(x,S))}else m=w.slice(x)}}else{let w=c-1;if(w>=p.length)m=[];else if(u!==void 0){let b=u<0?p.length+u:w+u;m=p.slice(w,Math.max(w,b))}else m=p.slice(w)}let d="";for(let w=0;w<i;w++)d+=await r(e,s.parts[w]);let g="";for(let w=i+1;w<s.parts.length;w++)g+=await r(e,s.parts[w]);if(m.length===0){let w=d+g;return{values:w?[w]:[],quoted:!0}}if(a){let w=fe(e.state.env);return{values:[d+m.join(w)+g],quoted:!0}}return m.length===1?{values:[d+m[0]+g],quoted:!0}:{values:[d+m[0],...m.slice(1,-1),m[m.length-1]+g],quoted:!0}}async function 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 y=0;y<s.parts.length;y++){let w=s.parts[y];if(w.type==="ParameterExpansion"&&(w.parameter==="@"||w.parameter==="*")&&w.operation?.type==="PatternReplacement"){i=y,a=w.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=z2(e),u="";for(let y=0;y<i;y++)u+=await n(e,s.parts[y]);let f="";for(let y=i+1;y<s.parts.length;y++)f+=await n(e,s.parts[y]);if(c.length===0){let y=u+f;return{values:y?[y]:[],quoted:!0}}let p="";if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")p+=me(y.pattern,!0,e.state.shoptOptions.extglob);else if(y.type==="Literal")p+=me(y.value,!0,e.state.shoptOptions.extglob);else if(y.type==="SingleQuoted"||y.type==="Escaped")p+=xe(y.value);else if(y.type==="DoubleQuoted"){let w=await r(e,y.parts);p+=xe(w)}else if(y.type==="ParameterExpansion"){let w=await n(e,y);p+=me(w,!0,e.state.shoptOptions.extglob)}else{let w=await n(e,y);p+=xe(w)}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 y=G(m,l.all?"g":"");for(let w of c)d.push(y.replace(w,h))}catch{d.push(...c)}if(a){let y=fe(e.state.env);return{values:[u+d.join(y)+f],quoted:!0}}return d.length===1?{values:[u+d[0]+f],quoted:!0}:{values:[u+d[0],...d.slice(1,-1),d[d.length-1]+f],quoted:!0}}async function V2(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 y=s.parts[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){i=g,a=y.parameter==="*";break}}if(i===-1)return null;let l=s.parts[i].operation,c=z2(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 y=await r(e,g.parts);p+=xe(y)}else if(g.type==="ParameterExpansion"){let y=await n(e,g);p+=me(y,l.greedy,h)}else{let y=await n(e,g);p+=xe(y)}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 q2=I(()=>{"use strict";Me();jt();jr();Vr();cr()});function Rx(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 aa(e,t){if(e.state.options.noglob)return t;let n=Rx(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 Z2(e,t,n,r){let s=-1,i="",a=!1;for(let w=0;w<t.length;w++){let b=t[w];if(b.type==="ParameterExpansion"&&b.operation?.type==="PatternReplacement"){let x=b.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(x){s=w,i=x[1],a=x[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="";if(l.pattern)for(let w of l.pattern.parts)if(w.type==="Glob")f+=me(w.pattern,!0,e.state.shoptOptions.extglob);else if(w.type==="Literal")f+=me(w.value,!0,e.state.shoptOptions.extglob);else if(w.type==="SingleQuoted"||w.type==="Escaped")f+=xe(w.value);else if(w.type==="DoubleQuoted"){let b=await n(e,w.parts);f+=xe(b)}else if(w.type==="ParameterExpansion"){let b=await r(e,w);f+=me(b,!0,e.state.shoptOptions.extglob)}else{let b=await r(e,w);f+=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 w=G(h,l.all?"g":"");for(let b of u)m.push(w.replace(b,p))}catch{m.push(...u)}let d=rt(e.state.env),g=ft(e.state.env);if(a){let w=fe(e.state.env),b=m.join(w);return g?{values:b?[b]:[],quoted:!1}:{values:_e(b,d),quoted:!1}}if(g)return{values:m,quoted:!1};let y=[];for(let w of m)w===""?y.push(""):y.push(..._e(w,d));return{values:y,quoted:!1}}async function K2(e,t,n,r){let s=-1,i="",a=!1;for(let y=0;y<t.length;y++){let w=t[y];if(w.type==="ParameterExpansion"&&w.operation?.type==="PatternRemoval"){let b=w.parameter.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[([@*])\]$/);if(b){s=y,i=b[1],a=b[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="",p=e.state.shoptOptions.extglob;if(l.pattern)for(let y of l.pattern.parts)if(y.type==="Glob")f+=me(y.pattern,l.greedy,p);else if(y.type==="Literal")f+=me(y.value,l.greedy,p);else if(y.type==="SingleQuoted"||y.type==="Escaped")f+=xe(y.value);else if(y.type==="DoubleQuoted"){let w=await n(e,y.parts);f+=xe(w)}else if(y.type==="ParameterExpansion"){let w=await r(e,y);f+=me(w,l.greedy,p)}else{let w=await r(e,y);f+=xe(w)}let h=[];for(let y of u)h.push($n(y,f,l.side,l.greedy));let m=rt(e.state.env),d=ft(e.state.env);if(a){let y=fe(e.state.env),w=h.join(y);return d?{values:w?[w]:[],quoted:!1}:{values:_e(w,m),quoted:!1}}if(d)return{values:h,quoted:!1};let g=[];for(let y of h)y===""?g.push(""):g.push(..._e(y,m));return{values:g,quoted:!1}}async function Q2(e,t,n,r){let s=-1,i=!1;for(let g=0;g<t.length;g++){let y=t[g];if(y.type==="ParameterExpansion"&&(y.parameter==="@"||y.parameter==="*")&&y.operation?.type==="PatternRemoval"){s=g,i=y.parameter==="*";break}}if(s===-1)return null;let 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 y=await n(e,g.parts);u+=xe(y)}else if(g.type==="ParameterExpansion"){let y=await r(e,g);u+=me(y,o.greedy,f)}else{let y=await r(e,g);u+=xe(y)}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),y=p.join(g);return m?{values:y?[y]:[],quoted:!1}:{values:_e(y,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 X2(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),y=ft(e.state.env);if(h.length===0){let b=m+d;return b?y?{values:[b],quoted:!1}:{values:_e(b,g),quoted:!1}:{values:[],quoted:!1}}let w;if(i){let b=fe(e.state.env),x=m+h.join(b)+d;y?w=x?[x]:[]:w=_e(x,g)}else if(y)h.length===1?w=[m+h[0]+d]:w=[m+h[0],...h.slice(1,-1),h[h.length-1]+d];else{w=[];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==="")w.push("");else{let S=_e(x,g);w.push(...S)}}}return{values:await aa(e,w),quoted:!1}}async function Y2(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=Ji(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 aa(e,l),quoted:!1}}async function J2(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=Ji(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 aa(e,u),quoted:!1}}function eg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=Gr(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 tg(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 ng(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=Ji(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 aa(e,f),quoted:!1}}var rg=I(()=>{"use strict";Me();Qi();ye();jt();jr();Hr();Vr();cr();Dt()});async function ag(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}=Is(r),p=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(p&&p.length>1)return Tx(e,p,s);let h=await Px(e,r,o,c,u,n);if(h!==null)return h;let m=await _x(e,r,n);if(m!==null)return m;let d=await Lx(e,r,n);if(d!==null)return d;let g=await Mx(e,r,n.expandPart);if(g!==null)return ig(e,g);if((i||a||l)&&!ft(e.state.env)){let w=rt(e.state.env),b=n.buildIfsCharClassPattern(w),x=await n.smartWordSplit(e,r,w,b,n.expandPart);return ig(e,x)}let y=await n.expandWordAsync(e,t);return Ux(e,t,r,y,s,n.expandWordForGlobbing)}async function Tx(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 oa(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function Px(e,t,n,r,s,i){if(n){let a=_2(e,t);if(a!==null)return a}{let a=L2(e,t);if(a!==null)return a}{let a=await I2(e,t);if(a!==null)return a}{let a=await $2(e,t,n,i.expandPart,i.expandWordPartsAsync);if(a!==null)return a}{let a=await O2(e,t,n,i.expandPart);if(a!==null)return a}{let a=await T2(e,t,i.evaluateArithmetic);if(a!==null)return a}{let a=P2(e,t);if(a!==null)return a}{let a=await N2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}{let a=await k2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let a=Dx(e,t);if(a!==null)return a}{let a=await M2(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(a!==null)return a}{let a=await U2(e,t);if(a!==null)return a}{let a=await W2(e,t);if(a!==null)return a}return null}function Dx(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=Gr(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 _x(e,t,n){{let r=await H2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await j2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await V2(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 Lx(e,t,n){{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.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await X2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await Y2(e,t);if(r!==null)return r}{let r=await J2(e,t);if(r!==null)return r}{let r=eg(e,t);if(r!==null)return r}{let r=tg(e,t);if(r!==null)return r}{let r=await ng(e,t,n.expandPart);if(r!==null)return r}return null}function sg(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 Fx(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 Mx(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(sg(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=sg(l);if(c&&l.type==="DoubleQuoted"){let u=await Fx(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 ig(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 oa(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function oa(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 Ux(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 oa(e,o);if(c.length>0&&c[0]!==o)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=cc(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 oa(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=cc(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 og=I(()=>{"use strict";Qi();ye();jt();Xi();v2();R2();D2();F2();Hr();B2();cr();q2();rg();Dt()});async function cg(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 Wx(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function Bx(e,t){if(t.type!=="ParameterExpansion")return null;let n=await cg(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>Wx(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function zx(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?nc(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&Gm(e))}async function ug(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 cg(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 lg(e,h,n,r,s)}let i=[],a=!1;for(let p of t){let h=zx(p),m=p.type==="DoubleQuoted"||p.type==="SingleQuoted",d=h?await Bx(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 lg(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}=ea(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 Hx(e,t){return e.length>0&&t.includes(e[0])}async function lg(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{Hx(u.value,n)&&o!==""&&(a.push(o),o="",l=!0);let{words:p,hadTrailingDelimiter:h}=ea(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 fg=I(()=>{"use strict";Dt();jt();Xi()});function pg(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function hg(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var dg=I(()=>{"use strict"});var wc={};K(wc,{escapeGlobChars:()=>_t,escapeRegexChars:()=>zr,expandRedirectTarget:()=>Ts,expandWord:()=>ie,expandWordForPattern:()=>gc,expandWordForRegex:()=>mc,expandWordWithGlob:()=>cn,getArrayElements:()=>oe,getVariable:()=>Se,hasQuotedMultiValueAt:()=>Rs,isArray:()=>In,isWordFullyQuoted:()=>dc});function Os(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 Vt(e,s,n));return r.join("")}function jx(e){return hg(e)}function dc(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!jx(t))return!1;return!0}function Vx(e,t,n=!1){let r=pg(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 pc(e,t.pattern);default:return null}}async function ie(e,t){return yc(e,t)}async function mc(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 Vt(e,r);n.push(zr(s))}else n.push(await Vt(e,r));return n.join("")}async function gc(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 Vt(e,r));return n.join("")}async function mg(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"?b2(r.pattern)?n.push(await E2(e,r.pattern)):n.push(pc(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await Vt(e,r));return n.join("")}function ca(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&ca(t.parts))return!0;return!1}async function gg(e,t,n={count:0}){if(n.count>hc)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=lc(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 gg(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 Vt(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>hc)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>hc)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 yg(e,t){let n=t.parts;if(!ca(n))return[await ie(e,t)];let r=await gg(e,n),s=[];for(let i of r){let a=[];for(let o of i)typeof o=="string"?a.push(o):a.push(await Vt(e,o));s.push(S2(e,a.join("")))}return s}function qx(){return{expandWordAsync:yc,expandWordForGlobbing:mg,expandWordWithBracesAsync:yg,expandWordPartsAsync:ln,expandPart:Vt,expandParameterAsync:la,hasBraceExpansion:ca,evaluateArithmetic:ne,buildIfsCharClassPattern:qm,smartWordSplit:ug}}async function cn(e,t){return ag(e,t,qx())}function Zx(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function Rs(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 Ts(e,t){if(Rs(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 d2(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 m2(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 g2(e,t){e.coverage?.hit("bash:expansion:var_name_prefix");let n=Gr(e,t.prefix);return t.star?n.join(fe(e.state.env)):n.join(" ")}function y2(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 w2=I(()=>{"use strict";mt();Xe();Me();Ct();ye();jt();an();jr();Vr();cr();uc();fc();Dt();sa()});function b2(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 x2(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 ia(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 pc(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=kx(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 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){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 E2(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 vx(e,o);n+=_t(l),r=i+1;continue}}if(s==="$"&&r+1<t.length&&t[r+1]==="("){let i=x2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await ia(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 ia(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 vx(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=x2(t,r+2);if(i!==-1){let a=t.slice(r+2,i),o=await ia(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 ia(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 A2=I(()=>{"use strict";Xe();ye();Hr()});function S2(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 C2=I(()=>{"use strict"});async function Ix(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 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!=="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 Ix(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=G(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 k2(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 v2=I(()=>{"use strict";Me();jt();jr();Vr();cr();Dt()});async function I2(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 $2(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=G(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 O2(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 R2=I(()=>{"use strict";Me();jt();jr();Vr();cr();Dt()});async function T2(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 P2(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=$s(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])=>$s(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 D2=I(()=>{"use strict";ye();jt();uc();fc();Dt();sa()});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")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 L2(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 F2=I(()=>{"use strict";an();Dt()});async function M2(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 $x(e,p,u,f,o.innerOp);if(o.innerOp.type==="DefaultValue"||o.innerOp.type==="UseAlternative"||o.innerOp.type==="AssignDefault"||o.innerOp.type==="ErrorIfUnset")return Ox(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 $x(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 Ox(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 U2(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 W2(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 B2=I(()=>{"use strict";Ct();ye();jt();Dt();sa()});function z2(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 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 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 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 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=z2(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=G(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 V2(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=z2(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 q2=I(()=>{"use strict";Me();jt();jr();Vr();cr()});function Rx(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 aa(e,t){if(e.state.options.noglob)return t;let n=Rx(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 Z2(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=G(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 K2(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 Q2(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 X2(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 aa(e,y),quoted:!1}}async function Y2(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=Ji(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 aa(e,l),quoted:!1}}async function J2(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=Ji(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 aa(e,u),quoted:!1}}function eg(e,t){if(t.length!==1||t[0].type!=="ParameterExpansion"||t[0].operation?.type!=="VarNamePrefix")return null;let n=t[0].operation,r=Gr(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 tg(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 ng(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=Ji(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 aa(e,f),quoted:!1}}var rg=I(()=>{"use strict";Me();Qi();ye();jt();jr();Hr();Vr();cr();Dt()});async function ag(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}=Is(r),p=n.hasBraceExpansion(r)?await n.expandWordWithBracesAsync(e,t):null;if(p&&p.length>1)return Tx(e,p,s);let h=await Px(e,r,o,c,u,n);if(h!==null)return h;let m=await _x(e,r,n);if(m!==null)return m;let d=await Lx(e,r,n);if(d!==null)return d;let g=await Mx(e,r,n.expandPart);if(g!==null)return ig(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 ig(e,x)}let w=await n.expandWordAsync(e,t);return Ux(e,t,r,w,s,n.expandWordForGlobbing)}async function Tx(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 oa(e,s);r.push(...i)}else r.push(s);return{values:r,quoted:!1}}async function Px(e,t,n,r,s,i){if(n){let a=_2(e,t);if(a!==null)return a}{let a=L2(e,t);if(a!==null)return a}{let a=await I2(e,t);if(a!==null)return a}{let a=await $2(e,t,n,i.expandPart,i.expandWordPartsAsync);if(a!==null)return a}{let a=await O2(e,t,n,i.expandPart);if(a!==null)return a}{let a=await T2(e,t,i.evaluateArithmetic);if(a!==null)return a}{let a=P2(e,t);if(a!==null)return a}{let a=await N2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}{let a=await k2(e,t,i.expandWordPartsAsync,i.expandPart);if(a!==null)return a}if(r&&t.length===1&&t[0].type==="DoubleQuoted"){let a=Dx(e,t);if(a!==null)return a}{let a=await M2(e,t,s,i.expandParameterAsync,i.expandWordPartsAsync);if(a!==null)return a}{let a=await U2(e,t);if(a!==null)return a}{let a=await W2(e,t);if(a!==null)return a}return null}function Dx(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=Gr(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 _x(e,t,n){{let r=await H2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await j2(e,t,n.expandPart,n.expandWordPartsAsync);if(r!==null)return r}{let r=await V2(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 Lx(e,t,n){{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.expandWordPartsAsync,n.expandPart);if(r!==null)return r}{let r=await X2(e,t,n.evaluateArithmetic,n.expandPart);if(r!==null)return r}{let r=await Y2(e,t);if(r!==null)return r}{let r=await J2(e,t);if(r!==null)return r}{let r=eg(e,t);if(r!==null)return r}{let r=tg(e,t);if(r!==null)return r}{let r=await ng(e,t,n.expandPart);if(r!==null)return r}return null}function sg(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 Fx(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 Mx(e,t,n){if(t.length<2)return null;let r=!1;for(let l of t)if(sg(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=sg(l);if(c&&l.type==="DoubleQuoted"){let u=await Fx(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 ig(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 oa(e,r);n.push(...s)}else n.push(r);return{values:n,quoted:!1}}async function oa(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 Ux(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 oa(e,o);if(c.length>0&&c[0]!==o)return{values:c,quoted:!1};if(c.length===0)return{values:[],quoted:!1}}let l=cc(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 oa(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=cc(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 og=I(()=>{"use strict";Qi();ye();jt();Xi();v2();R2();D2();F2();Hr();B2();cr();q2();rg();Dt()});async function cg(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 Wx(e){return e.type==="SingleQuoted"?!0:e.type==="DoubleQuoted"?e.parts.every(n=>n.type==="Literal"):!1}async function Bx(e,t){if(t.type!=="ParameterExpansion")return null;let n=await cg(e,t);if(!n||n.length<=1)return null;let r=n.some(i=>Wx(i)),s=n.some(i=>i.type==="Literal"||i.type==="ParameterExpansion"||i.type==="CommandSubstitution"||i.type==="ArithmeticExpansion");return r&&s?n:null}function zx(e){return e.type==="DoubleQuoted"||e.type==="SingleQuoted"||e.type==="Literal"?!1:e.type==="Glob"?nc(e.pattern):!(!(e.type==="ParameterExpansion"||e.type==="CommandSubstitution"||e.type==="ArithmeticExpansion")||e.type==="ParameterExpansion"&&Gm(e))}async function ug(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 cg(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 lg(e,h,n,r,s)}let i=[],a=!1;for(let p of t){let h=zx(p),m=p.type==="DoubleQuoted"||p.type==="SingleQuoted",d=h?await Bx(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 lg(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}=ea(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 Hx(e,t){return e.length>0&&t.includes(e[0])}async function lg(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{Hx(u.value,n)&&o!==""&&(a.push(o),o="",l=!0);let{words:p,hadTrailingDelimiter:h}=ea(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 fg=I(()=>{"use strict";Dt();jt();Xi()});function pg(e){switch(e.type){case"Literal":return e.value;case"SingleQuoted":return e.value;case"Escaped":return e.value;default:return null}}function hg(e){switch(e.type){case"SingleQuoted":case"Escaped":case"DoubleQuoted":return!0;case"Literal":return e.value==="";default:return!1}}var dg=I(()=>{"use strict"});var wc={};K(wc,{escapeGlobChars:()=>_t,escapeRegexChars:()=>zr,expandRedirectTarget:()=>Ts,expandWord:()=>ie,expandWordForPattern:()=>gc,expandWordForRegex:()=>mc,expandWordWithGlob:()=>cn,getArrayElements:()=>oe,getVariable:()=>Se,hasQuotedMultiValueAt:()=>Rs,isArray:()=>In,isWordFullyQuoted:()=>dc});function Os(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 Vt(e,s,n));return r.join("")}function jx(e){return hg(e)}function dc(e){if(e.parts.length===0)return!0;for(let t of e.parts)if(!jx(t))return!1;return!0}function Vx(e,t,n=!1){let r=pg(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 pc(e,t.pattern);default:return null}}async function ie(e,t){return yc(e,t)}async function mc(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 Vt(e,r);n.push(zr(s))}else n.push(await Vt(e,r));return n.join("")}async function gc(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 Vt(e,r));return n.join("")}async function mg(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"?b2(r.pattern)?n.push(await E2(e,r.pattern)):n.push(pc(e,r.pattern)):r.type==="Literal"?n.push(r.value):n.push(await Vt(e,r));return n.join("")}function ca(e){for(let t of e)if(t.type==="BraceExpansion"||t.type==="DoubleQuoted"&&ca(t.parts))return!0;return!1}async function gg(e,t,n={count:0}){if(n.count>hc)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=lc(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 gg(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 Vt(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>hc)return r;let c=[];for(let u of r)for(let f of i){if(n.count++,n.count>hc)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 yg(e,t){let n=t.parts;if(!ca(n))return[await ie(e,t)];let r=await gg(e,n),s=[];for(let i of r){let a=[];for(let o of i)typeof o=="string"?a.push(o):a.push(await Vt(e,o));s.push(S2(e,a.join("")))}return s}function qx(){return{expandWordAsync:yc,expandWordForGlobbing:mg,expandWordWithBracesAsync:yg,expandWordPartsAsync:ln,expandPart:Vt,expandParameterAsync:la,hasBraceExpansion:ca,evaluateArithmetic:ne,buildIfsCharClassPattern:qm,smartWordSplit:ug}}async function cn(e,t){return ag(e,t,qx())}function Zx(e){for(let t of e){if(t.type==="ParameterExpansion")return t.parameter;if(t.type==="Literal")return t.value}return""}function Rs(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 Ts(e,t){if(Rs(e,t))return{error:`bash: $@: ambiguous redirect
|
|
780
780
|
`};let n=t.parts,{hasQuoted:r}=Is(n);if(ca(n)&&(await yg(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
781
|
`};let s=await yc(e,t),{hasParamExpansion:i,hasCommandSub:a}=Is(n);if((i||a)&&!r&&!ft(e.state.env)){let f=rt(e.state.env);if(_e(s,f).length>1)return{error:`bash: $${Zx(n)}: ambiguous redirect
|
|
782
782
|
`}}if(r||e.state.options.noglob)return{target:s};let l=await mg(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 yc(e,t){let n=t.parts,r=n.length;if(r===1){let a=await Vt(e,n[0]);return Os(a,e.limits.maxStringLength,"word expansion"),a}let s=[];for(let a=0;a<r;a++)s.push(await Vt(e,n[a]));let i=s.join("");return Os(i,e.limits.maxStringLength,"word expansion"),i}async function Vt(e,t,n=!1){if(t.type==="ParameterExpansion")return la(e,t,n);let r=Vx(e,t,n);if(r!==null)return r;switch(t.type){case"DoubleQuoted":{let s=[];for(let i of t.parts)s.push(await Vt(e,i,!0));return s.join("")}case"CommandSubstitution":{let s=n2(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 Os(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 Os(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 Os(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 Jm(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=lc(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 la(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 oc(e,h);r=`${p}[${d}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&Te(e,r)){let p=St(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
|
|
784
|
+
`}}async function yc(e,t){let n=t.parts,r=n.length;if(r===1){let a=await Vt(e,n[0]);return Os(a,e.limits.maxStringLength,"word expansion"),a}let s=[];for(let a=0;a<r;a++)s.push(await Vt(e,n[a]));let i=s.join("");return Os(i,e.limits.maxStringLength,"word expansion"),i}async function Vt(e,t,n=!1){if(t.type==="ParameterExpansion")return la(e,t,n);let r=Vx(e,t,n);if(r!==null)return r;switch(t.type){case"DoubleQuoted":{let s=[];for(let i of t.parts)s.push(await Vt(e,i,!0));return s.join("")}case"CommandSubstitution":{let s=n2(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 Os(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 Os(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 Os(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 Jm(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=lc(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 la(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 oc(e,h);r=`${p}[${d}]`}}else if(/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(r)&&Te(e,r)){let p=St(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 oc(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}=y2(e,r,o,n),f={value:o,isUnset:l,isEmpty:c,effectiveValue:u,inDoubleQuotes:n};switch(s.type){case"DefaultValue":return s2(e,s,f,ln);case"AssignDefault":return i2(e,r,s,f,ln);case"ErrorIfUnset":return a2(e,r,s,f,ln);case"UseAlternative":return o2(e,s,f,ln);case"PatternRemoval":return l2(e,o,s,ln,Vt);case"PatternReplacement":return c2(e,o,s,ln,Vt);case"Length":return u2(e,r,o);case"LengthSliceError":throw new bt(r);case"BadSubstitution":throw new bt(s.text);case"Substring":return f2(e,r,o,s);case"CaseModification":return p2(e,o,s,ln,la);case"Transform":return h2(e,r,o,l,s);case"Indirection":return d2(e,r,o,l,s,la,n);case"ArrayKeys":return m2(e,s);case"VarNamePrefix":return g2(e,s);default:return o}}var Gx,hc,Nt=I(()=>{"use strict";mt();Xe();Qi();Ct();ye();Xi();e2();t2();r2();Hr();w2();A2();C2();Dt();og();fg();jt();an();dg();Hr();Dt();Gx=1e4,hc=1e5});function Kx(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 wg(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 Qx(e,t){switch(t){case"-":return-e;case"+":return+e;case"!":return e===0?1:0;case"~":return~e;default:return e}}async function Xx(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 Yx(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 bc(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 xc(e,t,n=new Set){if(n.has(t))return 0;n.add(t);let r=await Xx(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 xc(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 ua(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 xc(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 ua(e,t.content);return Number.parseInt(r,10)||0}case"ArithDynamicBase":{let r=await ua(e,t.baseExpr),s=Number.parseInt(r,10);if(s<2||s>64)return 0;let i=`${s}#${t.value}`;return ks(i)}case"ArithDynamicNumber":{let s=await ua(e,t.prefix)+t.suffix;return ks(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 bc(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
786
|
`,0;i=f}let a=`${t.array}_${i}`,o=e.state.env.get(a);if(o!==void 0)return bc(e,o);if(i===0){let l=e.state.env.get(t.array);if(l!==void 0)return bc(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 Kx(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 Qx(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=wg(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 xc(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=wg(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?Yx(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 ua(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 Sl=[{name:"echo",load:async()=>(await Promise.resolve().then(()=>(bu(),wu))).echoCommand},{name:"cat",load:async()=>(await Promise.resolve().then(()=>(Eu(),xu))).catCommand},{name:"printf",load:async()=>(await Promise.resolve().then(()=>(Ou(),$u))).printfCommand},{name:"ls",load:async()=>(await Promise.resolve().then(()=>(Du(),Pu))).lsCommand},{name:"mkdir",load:async()=>(await Promise.resolve().then(()=>(Lu(),_u))).mkdirCommand},{name:"rmdir",load:async()=>(await Promise.resolve().then(()=>(Wu(),Uu))).rmdirCommand},{name:"touch",load:async()=>(await Promise.resolve().then(()=>(zu(),Bu))).touchCommand},{name:"rm",load:async()=>(await Promise.resolve().then(()=>(ju(),Hu))).rmCommand},{name:"cp",load:async()=>(await Promise.resolve().then(()=>(Gu(),Vu))).cpCommand},{name:"mv",load:async()=>(await Promise.resolve().then(()=>(Zu(),qu))).mvCommand},{name:"ln",load:async()=>(await Promise.resolve().then(()=>(Qu(),Ku))).lnCommand},{name:"chmod",load:async()=>(await Promise.resolve().then(()=>(Ju(),Yu))).chmodCommand},{name:"pwd",load:async()=>(await Promise.resolve().then(()=>(tf(),ef))).pwdCommand},{name:"readlink",load:async()=>(await Promise.resolve().then(()=>(rf(),nf))).readlinkCommand},{name:"head",load:async()=>(await Promise.resolve().then(()=>(lf(),of))).headCommand},{name:"tail",load:async()=>(await Promise.resolve().then(()=>(uf(),cf))).tailCommand},{name:"wc",load:async()=>(await Promise.resolve().then(()=>(hf(),pf))).wcCommand},{name:"stat",load:async()=>(await Promise.resolve().then(()=>(gf(),mf))).statCommand},{name:"grep",load:async()=>(await Promise.resolve().then(()=>(si(),ri))).grepCommand},{name:"fgrep",load:async()=>(await Promise.resolve().then(()=>(si(),ri))).fgrepCommand},{name:"egrep",load:async()=>(await Promise.resolve().then(()=>(si(),ri))).egrepCommand},{name:"rg",load:async()=>(await Promise.resolve().then(()=>(a1(),i1))).rgCommand},{name:"sed",load:async()=>(await Promise.resolve().then(()=>(y1(),g1))).sedCommand},{name:"awk",load:async()=>(await Promise.resolve().then(()=>(K1(),Z1))).awkCommand2},{name:"sort",load:async()=>(await Promise.resolve().then(()=>(ip(),sp))).sortCommand},{name:"uniq",load:async()=>(await Promise.resolve().then(()=>(op(),ap))).uniqCommand},{name:"comm",load:async()=>(await Promise.resolve().then(()=>(cp(),lp))).commCommand},{name:"cut",load:async()=>(await Promise.resolve().then(()=>(fp(),up))).cutCommand},{name:"paste",load:async()=>(await Promise.resolve().then(()=>(dp(),hp))).pasteCommand},{name:"tr",load:async()=>(await Promise.resolve().then(()=>(yp(),gp))).trCommand},{name:"rev",load:async()=>(await Promise.resolve().then(()=>(bp(),wp))).rev},{name:"nl",load:async()=>(await Promise.resolve().then(()=>(Ap(),Ep))).nl},{name:"fold",load:async()=>(await Promise.resolve().then(()=>(Np(),Cp))).fold},{name:"expand",load:async()=>(await Promise.resolve().then(()=>(Ip(),vp))).expand},{name:"unexpand",load:async()=>(await Promise.resolve().then(()=>(Tp(),Rp))).unexpand},{name:"strings",load:async()=>(await Promise.resolve().then(()=>(Lp(),_p))).strings},{name:"split",load:async()=>(await Promise.resolve().then(()=>(Up(),Mp))).split},{name:"column",load:async()=>(await Promise.resolve().then(()=>(zp(),Bp))).column},{name:"join",load:async()=>(await Promise.resolve().then(()=>(jp(),Hp))).join},{name:"tee",load:async()=>(await Promise.resolve().then(()=>(Gp(),Vp))).teeCommand},{name:"find",load:async()=>(await Promise.resolve().then(()=>(th(),eh))).findCommand},{name:"basename",load:async()=>(await Promise.resolve().then(()=>(rh(),nh))).basenameCommand},{name:"dirname",load:async()=>(await Promise.resolve().then(()=>(ih(),sh))).dirnameCommand},{name:"tree",load:async()=>(await Promise.resolve().then(()=>(lh(),oh))).treeCommand},{name:"du",load:async()=>(await Promise.resolve().then(()=>(fh(),uh))).duCommand},{name:"env",load:async()=>(await Promise.resolve().then(()=>(_o(),Do))).envCommand},{name:"printenv",load:async()=>(await Promise.resolve().then(()=>(_o(),Do))).printenvCommand},{name:"alias",load:async()=>(await Promise.resolve().then(()=>(Fo(),Lo))).aliasCommand},{name:"unalias",load:async()=>(await Promise.resolve().then(()=>(Fo(),Lo))).unaliasCommand},{name:"history",load:async()=>(await Promise.resolve().then(()=>(dh(),hh))).historyCommand},{name:"xargs",load:async()=>(await Promise.resolve().then(()=>(gh(),mh))).xargsCommand},{name:"true",load:async()=>(await Promise.resolve().then(()=>(Uo(),Mo))).trueCommand},{name:"false",load:async()=>(await Promise.resolve().then(()=>(Uo(),Mo))).falseCommand},{name:"clear",load:async()=>(await Promise.resolve().then(()=>(wh(),yh))).clearCommand},{name:"bash",load:async()=>(await Promise.resolve().then(()=>(Bo(),Wo))).bashCommand},{name:"sh",load:async()=>(await Promise.resolve().then(()=>(Bo(),Wo))).shCommand},{name:"jq",load:async()=>(await Promise.resolve().then(()=>(qh(),Gh))).jqCommand},{name:"base64",load:async()=>(await Promise.resolve().then(()=>(Qh(),Kh))).base64Command},{name:"diff",load:async()=>(await Promise.resolve().then(()=>(Jh(),Yh))).diffCommand},{name:"date",load:async()=>(await Promise.resolve().then(()=>(td(),ed))).dateCommand},{name:"sleep",load:async()=>(await Promise.resolve().then(()=>(rd(),nd))).sleepCommand},{name:"timeout",load:async()=>(await Promise.resolve().then(()=>(id(),sd))).timeoutCommand},{name:"time",load:async()=>(await Promise.resolve().then(()=>(od(),ad))).timeCommand},{name:"seq",load:async()=>(await Promise.resolve().then(()=>(cd(),ld))).seqCommand},{name:"expr",load:async()=>(await Promise.resolve().then(()=>(fd(),ud))).exprCommand},{name:"md5sum",load:async()=>(await Promise.resolve().then(()=>(dd(),hd))).md5sumCommand},{name:"sha1sum",load:async()=>(await Promise.resolve().then(()=>(gd(),md))).sha1sumCommand},{name:"sha256sum",load:async()=>(await Promise.resolve().then(()=>(wd(),yd))).sha256sumCommand},{name:"file",load:async()=>(await Promise.resolve().then(()=>(c0(),l0))).fileCommand},{name:"html-to-markdown",load:async()=>(await Promise.resolve().then(()=>(f0(),u0))).htmlToMarkdownCommand},{name:"help",load:async()=>(await Promise.resolve().then(()=>(h0(),p0))).helpCommand},{name:"which",load:async()=>(await Promise.resolve().then(()=>(m0(),d0))).whichCommand},{name:"tac",load:async()=>(await Promise.resolve().then(()=>(y0(),g0))).tac},{name:"hostname",load:async()=>(await Promise.resolve().then(()=>(b0(),w0))).hostname},{name:"whoami",load:async()=>(await Promise.resolve().then(()=>(E0(),x0))).whoami},{name:"od",load:async()=>(await Promise.resolve().then(()=>(S0(),A0))).od},{name:"gzip",load:async()=>(await Promise.resolve().then(()=>(Hi(),zi))).gzipCommand},{name:"gunzip",load:async()=>(await Promise.resolve().then(()=>(Hi(),zi))).gunzipCommand},{name:"zcat",load:async()=>(await Promise.resolve().then(()=>(Hi(),zi))).zcatCommand}],xb=[],U0=[{name:"curl",load:async()=>(await Promise.resolve().then(()=>(F0(),L0))).curlCommand}],M0=new Map;function Cl(e){return{name:e.name,async execute(t,n){let r=M0.get(e.name);return r||(r=await e.load(),M0.set(e.name,r)),n.coverage,r.execute(t,n)}}}function Eb(){return Sl.map(e=>e.name)}function Ab(){return U0.map(e=>e.name)}function W0(e){return(e?Sl.filter(n=>e.includes(n.name)):Sl).map(Cl)}function B0(){return U0.map(Cl)}function z0(){return xb.map(Cl)}function H0(e){return"load"in e&&typeof e.load=="function"}function Sb(e,t){return{name:e,execute:t}}function j0(e){let t=null;return{name:e.name,async execute(n,r){return t||(t=await e.load()),t.execute(n,r)}}}var Cb=new TextEncoder,Nb=new TextDecoder;function Nl(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 Cb.encode(e)}function V0(e,t){if(t==="base64")return btoa(String.fromCharCode(...e));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 Nb.decode(e)}function ji(e){if(e!=null)return typeof e=="string"?e:e.encoding??void 0}var Ur=new TextEncoder;function kb(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):kb(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=ji(r),o=Nl(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=ji(n);return V0(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=ji(r),o=Nl(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")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}};vl();function vb(e){let t=e;return typeof t.mkdirSync=="function"&&typeof t.writeFileSync=="function"}function Ib(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 $b(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 Ob(e){e.mkdirSync("/proc/self/fd",{recursive:!0}),e.writeFileSync("/proc/version",`${q0}
|
|
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",kl):e.writeFileSync("/proc/self/status",kl()),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 Z0(e,t){vb(e)&&(Ib(e,t),$b(e),Ob(e))}Pn();ye();var Rb=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Tb=["braceexpand","hashall","interactive-comments"];function Il(e){let t=[],n=[...Tb.map(r=>({name:r,enabled:!0})),...Rb.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",Il(e.state.options))}var Pb=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function $l(e){let t=[];for(let n of Pb)e[n]&&t.push(n);return t.join(":")}function Ol(e){e.state.env.set("BASHOPTS",$l(e.state.shoptOptions))}Pn();ir();Xe();ir();var cx="BASH_ALIAS_";function Mm(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Um(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Wm(e,t){return e.env.get(`${cx}${t}`)}function Yl(e,t,n){if(!t.name||!Mm(t.name))return t;let r=Um(t.name);if(!r)return t;let s=Wm(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=zm(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 Bm(t,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Bm(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(Mm(f)){let p=Um(f);if(p&&Wm(e,p)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Yl(e,h,n);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw n.delete(r),i}}function Bm(e,t){let n=t;for(let a of e.args){let o=zm(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 zm(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}Ct();Nt();Xt();async function bg(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 xg(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
|
|
788
|
+
`),e.writeFileLazy?e.writeFileLazy("/proc/self/status",kl):e.writeFileSync("/proc/self/status",kl()),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 Z0(e,t){vb(e)&&(Ib(e,t),$b(e),Ob(e))}Pn();ye();var Rb=["allexport","errexit","noglob","noclobber","noexec","nounset","pipefail","posix","verbose","xtrace"],Tb=["braceexpand","hashall","interactive-comments"];function Il(e){let t=[],n=[...Tb.map(r=>({name:r,enabled:!0})),...Rb.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",Il(e.state.options))}var Pb=["dotglob","expand_aliases","extglob","failglob","globskipdots","globstar","lastpipe","nocaseglob","nocasematch","nullglob","xpg_echo"];function $l(e){let t=[];for(let n of Pb)e[n]&&t.push(n);return t.join(":")}function Ol(e){e.state.env.set("BASHOPTS",$l(e.state.shoptOptions))}Pn();ir();Xe();ir();var cx="BASH_ALIAS_";function Mm(e){return e.parts.length!==1?!1:e.parts[0].type==="Literal"}function Um(e){if(e.parts.length!==1)return null;let t=e.parts[0];return t.type==="Literal"?t.value:null}function Wm(e,t){return e.env.get(`${cx}${t}`)}function Yl(e,t,n){if(!t.name||!Mm(t.name))return t;let r=Um(t.name);if(!r)return t;let s=Wm(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=zm(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 Bm(t,s);let c=l.statements[0].pipelines[0].commands[0];if(c.type!=="SimpleCommand")return Bm(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(Mm(f)){let p=Um(f);if(p&&Wm(e,p)){let h={type:"SimpleCommand",name:f,args:u.args.slice(1),assignments:[],redirections:[]},m=Yl(e,h,n);m!==h&&(u={...u,name:m.name,args:[...m.args]})}}}return u}catch(i){throw n.delete(r),i}}function Bm(e,t){let n=t;for(let a of e.args){let o=zm(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 zm(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}Ct();Nt();Xt();async function bg(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 xg(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 Jx=["tar","yq","xan","sqlite3","python3","python"];function Eg(e){return Jx.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 Ec(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 Ac(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
|
|
@@ -812,7 +812,7 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
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
|
|
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=fE(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
|
|
@@ -833,8 +833,8 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
833
833
|
`,2);u=t[x]}else if(S==="-G"){if(x++,x>=t.length)return W(`compgen: -G: option requires an argument
|
|
834
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 Ic(e,a);d.push(...x)}if(c){let x=await Fg(e,a);d.push(...x)}for(let x of n)if(x==="variable"){let S=gE(e,a);d.push(...S)}else if(x==="export"){let S=yE(e,a);d.push(...S)}else if(x==="function"){let S=wE(e,a);d.push(...S)}else if(x==="builtin"){let S=bE(a);d.push(...S)}else if(x==="keyword"){let S=xE(a);d.push(...S)}else if(x==="alias"){let S=EE(e,a);d.push(...S)}else if(x==="shopt"){let S=AE(a);d.push(...S)}else if(x==="helptopic"){let S=SE(a);d.push(...S)}else if(x==="directory"){let S=await Ic(e,a);d.push(...S)}else if(x==="file"){let S=await Fg(e,a);d.push(...S)}else if(x==="user"){let S=CE(a);d.push(...S)}else if(x==="command"){let S=await NE(e,a);d.push(...S)}if(r!==null)try{let x=await kE(e,r),S=vE(e,x);for(let $ of S)(a===null||$.startsWith(a))&&d.push($)}catch{return B("","",1)}if(o){let x=await Ic(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 ka(e,x,O,"");if(F.exitCode!==0)return Xr(e,S),Xr(e,$),B("",F.stderr,1);g=F.stdout;let R=IE(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
|
-
`,2);throw x}let
|
|
837
|
-
`),b=g+(
|
|
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
|
+
`),b=g+(y?`${y}
|
|
838
838
|
`:"");return ge(b)}function gE(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 yE(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 wE(e,t){let n=Array.from(e.state.functions.keys());return t!==null&&(n=n.filter(r=>r.startsWith(t))),n.sort()}function bE(e){let t=[...$c];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function xE(e){let t=[...Mg];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function EE(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 AE(e){let t=[...dE];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}function SE(e){let t=[...mE];return e!==null&&(t=t.filter(n=>n.startsWith(e))),t.sort()}async function Ic(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 Fg(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 CE(e){return["root","nobody"]}async function NE(e,t){let n=new Set;for(let i of $c)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 Mg)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 kE(e,t){let r=new ce().parseWordFromString(t,!1,!1);return await ie(e,r)}function vE(e,t){let n=e.state.env.get("IFS")??`
|
|
839
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 IE(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 $E=["bashdefault","default","dirnames","filenames","noquote","nosort","nospace","plusdirs"];function Tc(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
|
|
@@ -867,9 +867,9 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
867
867
|
`;continue}let c=e.state.env.get(i);if(c!==void 0)n+=`declare ${a} ${i}=${Fc(c)}
|
|
868
868
|
`;else{let u=e.state.declaredVars?.has(i),f=e.state.localVarDepth?.has(i);u||f?n+=`declare ${a} ${i}
|
|
869
869
|
`:(r+=`bash: declare: ${i}: not found
|
|
870
|
-
`,s=!0)}}return B(n,r,s?1:0)}function zg(e,t){let{filterExport:n,filterReadonly:r,filterNameref:s,filterIndexedArray:i,filterAssocArray:a}=t,o=n||r||s||i||a,l="",c=new Set;for(let f of e.state.env.keys()){if(f.startsWith("BASH_"))continue;if(f.endsWith("__length")){let h=f.slice(0,-8);c.add(h);continue}let p=f.lastIndexOf("_");if(p>0){let h=f.slice(0,p),m=f.slice(p+1);if(/^\d+$/.test(m)||e.state.associativeArrays?.has(h)){c.add(h);continue}}c.add(f)}if(e.state.localVarDepth)for(let f of e.state.localVarDepth.keys())c.add(f);if(e.state.associativeArrays)for(let f of e.state.associativeArrays)c.add(f);let u=Array.from(c).sort();for(let f of u){let p=Wg(e,f),h=e.state.associativeArrays?.has(f),m=Ye(e,f),d=!h&&(m.length>0||e.state.env.has(`${f}__length`));if(o&&(a&&!h||i&&!d||n&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||s&&!Te(e,f)))continue;if(h){let
|
|
871
|
-
`;else{let w
|
|
872
|
-
`}continue}if(m.length>0){let
|
|
870
|
+
`,s=!0)}}return B(n,r,s?1:0)}function zg(e,t){let{filterExport:n,filterReadonly:r,filterNameref:s,filterIndexedArray:i,filterAssocArray:a}=t,o=n||r||s||i||a,l="",c=new Set;for(let f of e.state.env.keys()){if(f.startsWith("BASH_"))continue;if(f.endsWith("__length")){let h=f.slice(0,-8);c.add(h);continue}let p=f.lastIndexOf("_");if(p>0){let h=f.slice(0,p),m=f.slice(p+1);if(/^\d+$/.test(m)||e.state.associativeArrays?.has(h)){c.add(h);continue}}c.add(f)}if(e.state.localVarDepth)for(let f of e.state.localVarDepth.keys())c.add(f);if(e.state.associativeArrays)for(let f of e.state.associativeArrays)c.add(f);let u=Array.from(c).sort();for(let f of u){let p=Wg(e,f),h=e.state.associativeArrays?.has(f),m=Ye(e,f),d=!h&&(m.length>0||e.state.env.has(`${f}__length`));if(o&&(a&&!h||i&&!d||n&&!e.state.exportedVars?.has(f)||r&&!e.state.readonlyVars?.has(f)||s&&!Te(e,f)))continue;if(h){let w=sn(e,f);if(w.length===0)l+=`declare -A ${f}=()
|
|
871
|
+
`;else{let y=w.map(b=>{let x=e.state.env.get(`${f}_${b}`)??"",S=Mc(x);return`['${b}']=${S}`});l+=`declare -A ${f}=(${y.join(" ")})
|
|
872
|
+
`}continue}if(m.length>0){let w=m.map(y=>{let b=e.state.env.get(`${f}_${y}`)??"";return`[${y}]=${fr(b)}`});l+=`declare -a ${f}=(${w.join(" ")})
|
|
873
873
|
`;continue}if(e.state.env.has(`${f}__length`)){l+=`declare -a ${f}=()
|
|
874
874
|
`;continue}let g=e.state.env.get(f);g!==void 0&&(l+=`declare ${p} ${f}=${Fc(g)}
|
|
875
875
|
`)}return ge(l)}function Hg(e){let t="",n=Array.from(e.state.associativeArrays??[]).sort();for(let r of n){let s=sn(e,r);if(s.length===0)t+=`declare -A ${r}=()
|
|
@@ -877,22 +877,22 @@ Gid: ${r} ${r} ${r} ${r}
|
|
|
877
877
|
`}}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);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 Vg(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}=${va(o)}
|
|
880
|
-
`)}return ge(t)}function Uc(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function _s(e,t){return e.state.integerVars?.has(t)??!1}function Wc(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function OE(e,t){return e.state.lowercaseVars?.has(t)??!1}function Bc(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function RE(e,t){return e.state.uppercaseVars?.has(t)??!1}function Yr(e,t,n){return OE(e,t)?n.toLowerCase():RE(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 TE(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 zc(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,
|
|
880
|
+
`)}return ge(t)}function Uc(e,t){e.state.integerVars??=new Set,e.state.integerVars.add(t)}function _s(e,t){return e.state.integerVars?.has(t)??!1}function Wc(e,t){e.state.lowercaseVars??=new Set,e.state.lowercaseVars.add(t),e.state.uppercaseVars?.delete(t)}function OE(e,t){return e.state.lowercaseVars?.has(t)??!1}function Bc(e,t){e.state.uppercaseVars??=new Set,e.state.uppercaseVars.add(t),e.state.lowercaseVars?.delete(t)}function RE(e,t){return e.state.uppercaseVars?.has(t)??!1}function Yr(e,t,n){return OE(e,t)?n.toLowerCase():RE(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 TE(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 zc(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
|
-
`,2);else
|
|
883
|
-
`;return ge(N)}let R=!0,z="";for(let k of
|
|
884
|
-
`:R=!1;return B(z,"",R?0:1)}if(m){if(
|
|
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
|
+
`;return ge(N)}let R=!0,z="";for(let k of w)e.state.functions.has(k)?z+=`${k}
|
|
884
|
+
`:R=!1;return B(z,"",R?0:1)}if(m){if(w.length===0){let z="",k=Array.from(e.state.functions.keys()).sort();for(let N of k)z+=`${N} ()
|
|
885
885
|
{
|
|
886
886
|
# function body
|
|
887
887
|
}
|
|
888
|
-
`;return ge(z)}let R=!0;for(let z of
|
|
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 Bg(e,w);if(a&&w.length===0)return zg(e,{filterExport:i,filterReadonly:s,filterNameref:o,filterIndexedArray:n,filterAssocArray:r});if(w.length===0&&r&&!a)return Hg(e);if(w.length===0&&n&&!a)return jg(e);if(w.length===0&&!a)return Vg(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
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=Aa(T);for(let[ue,re]of L){let J=qe(e,re);e.state.env.set(`${v}_${ue}`,J)}}else if(r){let L=An(T);for(let ue=0;ue<L.length;ue+=2){let re=L[ue],J=ue+1<L.length?qe(e,L[ue+1]):"";e.state.env.set(`${v}_${re}`,J)}}else{let L=An(T);if(L.some(re=>/^\[[^\]]+\]=/.test(re))){let re=0;for(let J of L){let H=J.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,J);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(Km(e,v),!R.includes("="))continue}if(u){let v=R.includes("=")?R.slice(0,R.indexOf("=")):R;if(ra(e,v),!R.includes("="))continue}let k=TE(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 J=parseInt(e.state.env.get(`${v}__length`)??"0",10);re>=J&&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=Aa(T);for(let[J,H]of re){let X=qe(e,H);e.state.env.set(`${v}_${J}`,X)}}else{let re=Ye(e,v),J=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),J=1):re.length>0&&(J=Math.max(...re)+1);for(let Ee=0;Ee<ue.length;Ee++)e.state.env.set(`${v}_${J+Ee}`,qe(e,ue[Ee]));let X=J+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&&Uc(e,v),p&&Wc(e,v),h&&Bc(e,v);let re=Ye(e,v).length>0||e.state.associativeArrays?.has(v);if(_s(e,v)){let J=e.state.env.get(v)??"0",H=parseInt(J,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 J=`${v}_0`,H=e.state.env.get(J)??"";e.state.env.set(J,H+T)}else{T=Yr(e,v,T);let J=e.state.env.get(v)??"";e.state.env.set(v,J+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
892
|
`,F=1;continue}e.state.env.set(T,L),vn(e,T),L!==""&&ta(e,L)&&ac(e,T),$(T),s&&Lt(e,T),i&&on(e,T);continue}if(f&&Uc(e,T),p&&Wc(e,T),h&&Bc(e,T),_s(e,T)&&(L=await Gg(e,L)),L=Yr(e,T,L),Te(e,T)){let re=St(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)?Qm(e,v):L&&ta(e,L)&&ac(e,v),$(v),s&&Lt(e,v),i&&on(e,v);continue}if(f&&Uc(e,v),p&&Wc(e,v),h&&Bc(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 Hc(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=Aa(p);for(let[g,
|
|
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=Aa(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=Og(a);if(c.value===void 0&&!c.isArray){Lt(e,c.name);continue}let u=await Rg(e,c,{makeReadonly:!0});if(u)return u}return de}function jc(e){return e.state.directoryStack??=[],e.state.directoryStack}function Ls(e,t){return t&&e===t?"~":t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function PE(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 Vc(e,t){let n=jc(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
|
|
@@ -926,16 +926,16 @@ eval: usage: eval [arg ...]
|
|
|
926
926
|
`,1);c++}else l.push(m),c++}if(n)return e.state.hashTable.clear(),de;if(r){if(l.length===0)return W(`bash: hash: -d: option requires an argument
|
|
927
927
|
`,1);let m=!1,d="";for(let g of l)e.state.hashTable.has(g)?e.state.hashTable.delete(g):(d+=`bash: hash: ${g}: not found
|
|
928
928
|
`,m=!0);return m?W(d,1):de}if(a){if(l.length===0)return W(`bash: hash: -t: option requires an argument
|
|
929
|
-
`,1);let m="",d=!1,g="";for(let
|
|
930
|
-
`:m+=`${
|
|
931
|
-
`:(g+=`bash: hash: ${
|
|
929
|
+
`,1);let m="",d=!1,g="";for(let w of l){let y=e.state.hashTable.get(w);y?l.length>1?m+=`${w} ${y}
|
|
930
|
+
`:m+=`${y}
|
|
931
|
+
`:(g+=`bash: hash: ${w}: not found
|
|
932
932
|
`,d=!0)}return d?{exitCode:1,stdout:m,stderr:g}:ge(m)}if(i){if(l.length===0)return W(`bash: hash: usage: hash [-lr] [-p pathname] [-dt] [name ...]
|
|
933
933
|
`,1);let m=l[0];return e.state.hashTable.set(m,o),de}if(l.length===0){if(e.state.hashTable.size===0)return ge(`hash: hash table empty
|
|
934
934
|
`);let m="";if(s)for(let[d,g]of e.state.hashTable)m+=`builtin hash -p ${g} ${d}
|
|
935
935
|
`;else{m=`hits command
|
|
936
936
|
`;for(let[,d]of e.state.hashTable)m+=` 1 ${d}
|
|
937
937
|
`}return ge(m)}let u=!1,f="",h=(e.state.env.get("PATH")||"/usr/bin:/bin").split(":");for(let m of l){if(m.includes("/")){f+=`bash: hash: ${m}: cannot use / in name
|
|
938
|
-
`,u=!0;continue}let d=!1;for(let g of h){if(!g)continue;let
|
|
938
|
+
`,u=!0;continue}let d=!1;for(let g of h){if(!g)continue;let w=`${g}/${m}`;if(await e.fs.exists(w)){e.state.hashTable.set(m,w),d=!0;break}}d||(f+=`bash: hash: ${m}: not found
|
|
939
939
|
`,u=!0)}return u?W(f,1):de}Me();var qg=new Map([[":",[": [arguments]",`Null command.
|
|
940
940
|
No effect; the command does nothing.
|
|
941
941
|
Exit Status:
|
|
@@ -1292,20 +1292,20 @@ ${h}
|
|
|
1292
1292
|
`);let n=LE(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
1293
|
`)}return B("","",r===0?1:0)}mt();Xe();Ct();Xt();an();Bn();async function Jc(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
|
-
`)}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
|
|
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
|
|
1297
|
-
`,s=1;continue}let g=n.has(u);if(f!==void 0){let
|
|
1298
|
-
`,s=1;continue}e.state.env.set(u,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(u))}else{let
|
|
1299
|
-
`,s=0,i=0,a=0,o=!1,l="MAPFILE",c=0;for(;c<t.length;){let
|
|
1300
|
-
`,c+=2):
|
|
1301
|
-
`,1);let S=p,$=S.indexOf("\0");$!==-1&&(S=S.substring(0,$)),f.push(S),h++}}break}let b=p.substring(0,
|
|
1302
|
-
`,1);f.push(b),h++}i===0&&wn(e,l);for(let
|
|
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
|
|
1304
|
-
`){N+=2,b=N;continue}if(T===
|
|
1305
|
-
`){k+=2;continue}if(P===
|
|
1306
|
-
`&&
|
|
1307
|
-
`)&&(
|
|
1308
|
-
`,1);wn(e,c);for(let P=0;P<k.length;P++)e.state.env.set(`${c}_${P}`,$(k[P]));return B("","",x?0:1)}let F=p.length,{words:R,wordStarts:z}=ic(
|
|
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
|
+
`,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
|
|
1297
|
+
`,s=1;continue}let g=n.has(u);if(f!==void 0){let w=e.state.env.get(u);if(e.state.tempEnvBindings){let y=e.state.accessedTempEnvVars?.has(u),b=e.state.mutatedTempEnvVars?.has(u);if(!y&&!b)for(let x=e.state.tempEnvBindings.length-1;x>=0;x--){let S=e.state.tempEnvBindings[x];if(S.has(u)){w=S.get(u);break}}}Tg(e,u,w)}if(!g){let w=e.state.env.get(u);if(e.state.tempEnvBindings)for(let y=e.state.tempEnvBindings.length-1;y>=0;y--){let b=e.state.tempEnvBindings[y];if(b.has(u)){w=b.get(u);break}}if(n.set(u,w),a){let y=`${u}_`;for(let x of e.state.env.keys())x.startsWith(y)&&!x.includes("__")&&(n.has(x)||n.set(x,e.state.env.get(x)));let b=`${u}__length`;e.state.env.has(b)&&!n.has(b)&&n.set(b,e.state.env.get(b))}}if(a&&f===void 0){let w=`${u}_`;for(let y of e.state.env.keys())y.startsWith(w)&&!y.includes("__")&&e.state.env.delete(y);e.state.env.set(`${u}__length`,"0")}else if(f!==void 0){if(it(e,u,"bash"),i&&f!==""&&!/^[a-zA-Z_][a-zA-Z0-9_]*(\[.+\])?$/.test(f)){r+=`bash: local: \`${f}': invalid variable name for name reference
|
|
1298
|
+
`,s=1;continue}e.state.env.set(u,f),e.state.options.allexport&&(e.state.exportedVars=e.state.exportedVars||new Set,e.state.exportedVars.add(u))}else{let w=e.state.tempEnvBindings?.some(y=>y.has(u));!g&&!w&&e.state.env.delete(u)}jn(e,u),i&&vn(e,u)}return B("",r,s)}Xt();function eu(e,t,n){let r=`
|
|
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
|
+
`,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
|
+
`,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 FE(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 ME(e,t,n){return`__rw__:${e.length}:${e}:${t}:${n}`}function tu(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=FE(N);if(P){let v=P.position+k;e.state.fileDescriptors.set(r,ME(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
|
+
`){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
|
+
`){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
|
+
`&&y.endsWith(`
|
|
1307
|
+
`)&&(y=y.slice(0,-1));let $=k=>s?k:k.replace(/\\(.)/g,"$1");if(p.length===1&&p[0]==="REPLY")return e.state.env.set("REPLY",$(y)),B("","",x?0:1);let O=rt(e.state.env);if(c){let{words:k}=ic(y,O,void 0,s),N=e.limits?.maxArrayElements??1e5;if(k.length>N)return B("",`read: array element limit exceeded (${N})
|
|
1308
|
+
`,1);wn(e,c);for(let P=0;P<k.length;P++)e.state.env.set(`${c}_${P}`,$(k[P]));return B("","",x?0:1)}let F=p.length,{words:R,wordStarts:z}=ic(y,O,F,s);for(let k=0;k<p.length;k++){let N=p[k];if(k<p.length-1)e.state.env.set(N,$(R[k]??""));else if(k<z.length){let P=y.substring(z[k]);P=Zm(P,O,s),P=$(P),e.state.env.set(N,P)}else e.state.env.set(N,"")}return B("","",x?0:1)}ye();function nu(e,t){if(e.state.callDepth===0&&e.state.sourceDepth===0)return W("bash: return: can only `return' from a function or sourced script\n");let n=e.state.lastExitCode;if(t.length>0){let r=t[0],s=Number.parseInt(r,10);if(r===""||Number.isNaN(s)||!/^-?\d+$/.test(r))return W(`bash: return: ${r}: numeric argument required
|
|
1309
1309
|
`,2);n=(s%256+256)%256}throw new ct(n)}ye();Xt();var Oa=`set: usage: set [-eux] [+eux] [-o option] [+o option]
|
|
1310
1310
|
Options:
|
|
1311
1311
|
-e Exit immediately if a command exits with non-zero status
|
|
@@ -1337,16 +1337,16 @@ ${Oa}`;if(e.state.options.posix)throw new Bt(1,"",s);return W(s)}return ru(e,t.s
|
|
|
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
1339
|
`);throw c}}mt();Xe();Ct();Dt();Nt();an();Bn();function e6(e){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e)}function VE(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')}async function t6(e,t){if(VE(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 n6(e,t){if(e.state.localVarStack?.has(t)){let r=Ca(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)Sa(e,t),e.state.localVarStack?.delete(t),e.state.fullyUnsetLocals=e.state.fullyUnsetLocals||new Map,e.state.fullyUnsetLocals.set(t,r.scopeIndex),ou(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),Sa(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||Sa(e,t),!0}}return!1}function ou(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 r6(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 lu(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 r6(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
|
-
`,s=1;continue}let
|
|
1341
|
-
`,s=1;continue}if(
|
|
1342
|
-
`,s=1;continue}let $=x+
|
|
1343
|
-
`,s=1;continue}let O=b[$][0];e.state.env.delete(`${p}_${O}`);continue}e.state.env.delete(`${p}_${
|
|
1340
|
+
`,s=1;continue}let y=await t6(e,h);if(y===null&&d){r+=`bash: unset: ${h}: not a valid identifier
|
|
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
|
+
`,s=1;continue}let $=x+y;if($<0){r+=`bash: line ${S}: unset: [${y}]: bad array subscript
|
|
1343
|
+
`,s=1;continue}let O=b[$][0];e.state.env.delete(`${p}_${O}`);continue}e.state.env.delete(`${p}_${y}`);continue}if(!e6(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
1344
1344
|
`,s=1;continue}let u=i;if(Te(e,i)){let p=St(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)n6(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=Ca(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 ou(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 r6(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 t6(e,u);if(m===null&&p){r+=`bash: unset: ${u}: not a valid identifier
|
|
1347
|
-
`,s=1;continue}if(m===null)continue;if(m<0){let d=oe(e,c),g=d.length,
|
|
1348
|
-
`,s=1;continue}let
|
|
1349
|
-
`,s=1;continue}let b=d[
|
|
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
|
+
`,s=1;continue}let y=g+m;if(y<0){r+=`bash: line ${w}: unset: [${m}]: bad array subscript
|
|
1349
|
+
`,s=1;continue}let b=d[y][0];e.state.env.delete(`${c}_${b}`);continue}e.state.env.delete(`${c}_${m}`);continue}if(!e6(i)){r+=`bash: unset: \`${i}': not a valid identifier
|
|
1350
1350
|
`,s=1;continue}let o=i;if(Te(e,i)){let c=St(e,i);c&&c!==i&&(o=c)}if(En(e,o)){r+=`bash: unset: ${o}: cannot unset: readonly variable
|
|
1351
1351
|
`,s=1;continue}let l=Kr(e,o);if(l!==void 0&&l!==e.state.callDepth)n6(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=Ca(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 ou(e,o)||e.state.env.delete(o);e.state.exportedVars?.delete(o),e.state.functions.delete(i)}return B("",r,s)}var cu=["extglob","dotglob","nullglob","failglob","globstar","globskipdots","nocaseglob","nocasematch","expand_aliases","lastpipe","xpg_echo"],GE=["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 Ra(e){return cu.includes(e)}function qE(e){return GE.includes(e)}function s6(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
1352
|
`}}}l++}else break}for(;l<t.length;)o.push(t[l]),l++;if(a)return ZE(e,o,n,r,s,i);if(n&&r)return{exitCode:1,stdout:"",stderr:`shopt: cannot set and unset shell options simultaneously
|
|
@@ -1364,13 +1364,13 @@ ${Oa}`;if(e.state.options.posix)throw new Bt(1,"",s);return W(s)}return ru(e,t.s
|
|
|
1364
1364
|
`)}
|
|
1365
1365
|
`:"",stderr:u}}async function i6(e,t,n){if(t.includes("/")){let a=e.fs.resolvePath(e.state.cwd,t);if(!await e.fs.exists(a))return{error:"not_found",path:a};let o=a.split("/").pop()||t,l=e.commands.get(o);try{let c=await e.fs.stat(a);return c.isDirectory?{error:"permission_denied",path:a}:l?{cmd:l,path:a}:(c.mode&73)!==0?{script:!0,path:a}:{error:"permission_denied",path:a}}catch{return{error:"not_found",path:a}}}if(!n&&e.state.hashTable){let a=e.state.hashTable.get(t);if(a)if(await e.fs.exists(a)){let o=e.commands.get(t);if(o)return{cmd:o,path:a};try{let l=await e.fs.stat(a);if(!l.isDirectory&&(l.mode&73)!==0)return{script:!0,path:a}}catch{}}else e.state.hashTable.delete(t)}let s=(n??e.state.env.get("PATH")??"/usr/bin:/bin").split(":");for(let a of s){if(!a)continue;let l=`${a.startsWith("/")?a:e.fs.resolvePath(e.state.cwd,a)}/${t}`;if(await e.fs.exists(l))try{let c=await e.fs.stat(l);if(c.isDirectory)continue;let u=(c.mode&73)!==0,f=e.commands.get(t),p=a==="/bin"||a==="/usr/bin";if(f&&p)return{cmd:f,path:l};if(u){if(f&&!p)return{script:!0,path:l};if(!f)return{script:!0,path:l}}}catch{}}if(!await e.fs.exists("/usr/bin")){let a=e.commands.get(t);if(a)return{cmd:a,path:`/usr/bin/${t}`}}return null}async function Ta(e,t){let n=[];if(t.includes("/")){let i=e.fs.resolvePath(e.state.cwd,t);if(await e.fs.exists(i))try{let a=await e.fs.stat(i);a.isDirectory||(a.mode&73)!==0&&n.push(t)}catch{}return n}let s=(e.state.env.get("PATH")||"/usr/bin:/bin").split(":");for(let i of s){if(!i)continue;let o=`${i.startsWith("/")?i:e.fs.resolvePath(e.state.cwd,i)}/${t}`;if(await e.fs.exists(o)){try{if((await e.fs.stat(o)).isDirectory)continue}catch{continue}n.push(i.startsWith("/")?o:`${i}/${t}`)}}return n}ye();zt();async function c6(e,t,n,r){let s=!1,i=!1,a=!1,o=!1,l=!1,c=[];for(let d of t)if(d.startsWith("-")&&d.length>1)for(let g of d.slice(1))g==="t"?s=!0:g==="p"?i=!0:g==="P"?a=!0:g==="a"?o=!0:g==="f"&&(l=!0);else c.push(d);let u="",f="",p=0,h=!1,m=!1;for(let d of c){let g=!1;if(a){if(o){let $=await r(d);if($.length>0){for(let O of $)u+=`${O}
|
|
1366
1366
|
`;h=!0,g=!0}}else{let $=await n(d);$&&(u+=`${$}
|
|
1367
|
-
`,h=!0,g=!0)}g||(m=!0);continue}let
|
|
1367
|
+
`,h=!0,g=!0)}g||(m=!0);continue}let w=!l&&e.state.functions.has(d);if(o&&w){if(!i)if(s)u+=`function
|
|
1368
1368
|
`;else{let $=e.state.functions.get(d),O=$?a6(d,$):`${d} is a function
|
|
1369
|
-
`;u+=O}g=!0}let
|
|
1370
|
-
`:u+=`${d} is aliased to \`${
|
|
1369
|
+
`;u+=O}g=!0}let y=e.state.env.get(`BASH_ALIAS_${d}`);if(y!==void 0&&(o||!g)&&(i||(s?u+=`alias
|
|
1370
|
+
`:u+=`${d} is aliased to \`${y}'
|
|
1371
1371
|
`),g=!0,!o)||vc.has(d)&&(o||!g)&&(i||(s?u+=`keyword
|
|
1372
1372
|
`:u+=`${d} is a shell keyword
|
|
1373
|
-
`),g=!0,!o))continue;if(!o&&
|
|
1373
|
+
`),g=!0,!o))continue;if(!o&&w&&!g){if(!i)if(s)u+=`function
|
|
1374
1374
|
`;else{let $=e.state.functions.get(d),O=$?a6(d,$):`${d} is a function
|
|
1375
1375
|
`;u+=O}g=!0;continue}if(!(Qr.has(d)&&(o||!g)&&(i||(s?u+=`builtin
|
|
1376
1376
|
`:u+=`${d} is a shell builtin
|
|
@@ -1418,14 +1418,14 @@ ${e} ()
|
|
|
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
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 S6(e,t,n){if(!e.state.options.xtrace)return"";let r=await A6(e),s=[t,...n],i=YE(s);return`${r}${i}
|
|
1420
1420
|
`}async function C6(e,t,n){return e.state.options.xtrace?`${await A6(e)}${t}=${n}
|
|
1421
|
-
`:""}ye();async function N6(e,t,n){let r=t.timed?performance.now():0,s="",i=de,a=0,o=[],l=t.commands.length>1,
|
|
1421
|
+
`:""}ye();async function N6(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 bt)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 It&&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
|
-
`:
|
|
1425
|
-
real ${`${
|
|
1424
|
+
`:g=`
|
|
1425
|
+
real ${`${m}m${d.toFixed(3)}s`}
|
|
1426
1426
|
user 0m0.000s
|
|
1427
1427
|
sys 0m0.000s
|
|
1428
|
-
`,i={...i,stderr:i.stderr+
|
|
1428
|
+
`,i={...i,stderr:i.stderr+g}}return c&&!e.state.shoptOptions.lastpipe&&(e.state.lastArg=u),i}mt();Xe();Ct();ye();Nt();Xt();an();Bn();async function k6(e,t){let n=new Map,r="";for(let s of t.assignments){let i=s.name;if(s.array){let u=await eA(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
1429
|
`,1)};let l=i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)\[(.+)\]$/);if(l){let u=await iA(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 oA(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 eA(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
1430
|
`,1)};if(Te(e,n)){let u=lr(e,n);if(u===void 0||u==="")throw new pe(1,"","");let f=St(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
|
|
@@ -1436,15 +1436,15 @@ sys 0m0.000s
|
|
|
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
1437
|
`,1)}}}return{index:s}}async function oA(e,t,n,r,s,i){let a="",o=n,l=null;if(Te(e,n)){let f=Ym(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(_s(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(()=>(Nt(),wc)),p=f(e,o)?`${o}_0`:o;c=s?(e.state.env.get(p)||"")+r:r}c=Yr(e,o,c),a+=await C6(e,o,c);let u=o;if(l)u=await lA(e,l);else{let{isArray:f}=await Promise.resolve().then(()=>(Nt(),wc));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 lA(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return v6(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();Nt();zt();async function I6(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
|
|
1440
|
-
`,1);return ze(e,F,t.redirections)}S();let $=B(
|
|
1439
|
+
`,{continueToNext:!0,xtraceOutput:a};let f=it(e,o);if(f)return{continueToNext:!1,xtraceOutput:"",error:f}}let c;if(_s(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(()=>(Nt(),wc)),p=f(e,o)?`${o}_0`:o;c=s?(e.state.env.get(p)||"")+r:r}c=Yr(e,o,c),a+=await C6(e,o,c);let u=o;if(l)u=await lA(e,l);else{let{isArray:f}=await Promise.resolve().then(()=>(Nt(),wc));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 lA(e,t){let{arrayName:n,subscriptExpr:r}=t;if(e.state.associativeArrays?.has(n))return v6(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();Nt();zt();async function I6(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 It){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
|
+
`,1);return ze(e,F,t.redirections)}S();let $=B(y,b,x);return ze(e,$,t.redirections)}async function $6(e,t,n,r){let s="",i="",a=0,o=await Na(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
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(Vs(f)||f instanceof It||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 O6(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
|
-
`);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
|
|
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
1448
|
`);throw g}}var Us=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:Et(this.ctx.state.env)};if(a instanceof te)throw a;if(a instanceof It)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:Et(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:Et(this.ctx.state.env)};if(a instanceof bt)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:Et(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:Et(this.ctx.state.env)}}async executeUserScript(t,n,r=""){return O6(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
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 It(s,n,r);return B(n,r,s)}async executePipeline(t){return N6(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 d6(this.ctx,t);case"For":return m6(this.ctx,t);case"CStyleFor":return g6(this.ctx,t);case"While":return y6(this.ctx,t,n);case"Until":return w6(this.ctx,t);case"Case":return b6(this.ctx,t);case"Subshell":return this.executeSubshell(t,n);case"Group":return this.executeGroup(t,n);case"FunctionDef":return Lg(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 k6(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&&fu(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 Na(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(`
|
|
@@ -1452,9 +1452,9 @@ sys 0m0.000s
|
|
|
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
|
|
1453
1453
|
`)}if(x.operator==="<&"&&x.target.type==="Word"){let S=await ie(this.ctx,x.target),$=Number.parseInt(S,10);if(!Number.isNaN($)&&this.ctx.state.fileDescriptors){let O=this.ctx.state.fileDescriptors.get($);if(O!==void 0)if(O.startsWith("__rw__:")){let F=x6(O);F&&(n=F.content.slice(F.position),c=$)}else O.startsWith("__file__:")||O.startsWith("__file_append__:")||(n=O)}}}let u=await ie(this.ctx,t.name),f=[],p=[];if(fu(t.name,["local","declare","typeset","export","readonly"])&&(u==="local"||u==="declare"||u==="typeset"||u==="export"||u==="readonly"))for(let x of t.args){let S=await bg(this.ctx,x);if(S)f.push(S),p.push(!0);else{let $=await xg(this.ctx,x);if($!==null)f.push($),p.push(!0);else{let O=await cn(this.ctx,x);for(let F of O.values)f.push(F),p.push(O.quoted)}}}else for(let x of t.args){let S=await cn(this.ctx,x);for(let $ of S.values)f.push($),p.push(S.quoted)}if(!u){if(t.name.parts.every(S=>S.type==="CommandSubstitution"||S.type==="ParameterExpansion"||S.type==="ArithmeticExpansion")){if(f.length>0){let S=f.shift();return p.shift(),await this.runCommand(S,f,p,n,!1,!1,c)}return B("","",this.ctx.state.lastExitCode)}return W(`bash: : command not found
|
|
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
|
-
`)}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 S6(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
|
|
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 S6(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=Dg(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 p6(l,t,n,r,s,i,a,o);return c!==null?c:h6(l,t,n,s,a)}aliasExpansionStack=new Set;expandAlias(t){return Yl(this.ctx.state,t,this.aliasExpansionStack)}async findCommandInPath(t){return Ta(this.ctx,t)}async executeSubshell(t,n=""){return I6(this.ctx,t,n,r=>this.executeStatement(r))}async executeGroup(t,n=""){return $6(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 R6(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 T6(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function cA(e){let t=T6(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function uA(e,t){let n=T6(e);if(!n)return!1;let r=cA(t);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function pu(e,t){return!t||t.length===0?!1:t.some(n=>uA(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"}},Da=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}},Ws=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var fA=20,pA=3e4,hA=10485760,dA=["GET","HEAD"],mA=new Set(["GET","HEAD","OPTIONS"]),gA=new Set([301,302,303,307,308]);function hu(e){let t=e.maxRedirects??fA,n=e.timeoutMs??pA,r=e.maxResponseSize??hA,s=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??dA;function i(l){if(!e.dangerouslyAllowFullInternetAccess&&!pu(l,e.allowedUrlPrefixes??[]))throw new Jr(l)}function a(l){if(e.dangerouslyAllowFullInternetAccess)return;let c=l.toUpperCase();if(!s.includes(c))throw new Da(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
|
|
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 R6(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 T6(e){try{let t=new URL(e);return{origin:t.origin,pathname:t.pathname,href:t.href}}catch{return null}}function cA(e){let t=T6(e);return t?{origin:t.origin,pathPrefix:t.pathname}:null}function uA(e,t){let n=T6(e);if(!n)return!1;let r=cA(t);return!r||n.origin!==r.origin?!1:r.pathPrefix==="/"||r.pathPrefix===""?!0:n.pathname.startsWith(r.pathPrefix)}function pu(e,t){return!t||t.length===0?!1:t.some(n=>uA(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"}},Da=class extends Error{constructor(t,n){super(`HTTP method '${t}' not allowed. Allowed methods: ${n.join(", ")}`),this.name="MethodNotAllowedError"}},Ws=class extends Error{constructor(t){super(`Response body too large (max: ${t} bytes)`),this.name="ResponseTooLargeError"}};var fA=20,pA=3e4,hA=10485760,dA=["GET","HEAD"],mA=new Set(["GET","HEAD","OPTIONS"]),gA=new Set([301,302,303,307,308]);function hu(e){let t=e.maxRedirects??fA,n=e.timeoutMs??pA,r=e.maxResponseSize??hA,s=e.dangerouslyAllowFullInternetAccess?["GET","HEAD","POST","PUT","DELETE","PATCH","OPTIONS"]:e.allowedMethods??dA;function i(l){if(!e.dangerouslyAllowFullInternetAccess&&!pu(l,e.allowedUrlPrefixes??[]))throw new Jr(l)}function a(l){if(e.dangerouslyAllowFullInternetAccess)return;let c=l.toUpperCase();if(!s.includes(c))throw new Da(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&&!mA.has(u)&&(w.body=c.body);let y=await fetch(f,w);if(gA.has(y.status)&&h){let b=y.headers.get("location");if(!b)return await P6(y,f,r);let x=new URL(b,f).href;if(!e.dangerouslyAllowFullInternetAccess&&!pu(x,e.allowedUrlPrefixes??[]))throw new ts(x);if(p++,p>t)throw new es(t);f=x;continue}return await P6(y,f,r)}finally{clearTimeout(g)}}}return o}async function P6(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 Ws(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 Ws(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 D6(){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 Bs=!0;function _6(){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 mu=null;if(!Bs)try{let{createRequire:e}=await import("node:module");mu=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 yA=`
|
|
1458
1458
|
|
|
1459
1459
|
This is a defense-in-depth measure and indicates a bug in just-bash. Please report this at security@vercel.com`,gt=class extends Error{violation;constructor(t,n){super(t+yA),this.violation=n,this.name="SecurityViolationError"}},Mt=!Bs&&mu?new mu:null,wA=1e3,du={enabled:!0,auditMode:!1};function bA(e){return e===void 0?{...du,enabled:!1}:typeof e=="boolean"?{...du,enabled:e}:{...du,...e}}var _a=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(bA(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(Bs||!this.config.enabled){let n=_6();return{run:r=>r(),deactivate:()=>{},executionId:n}}this.refCount++,this.refCount===1&&(this.applyPatches(),this.activationTime=Date.now());let t=_6();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 Bs||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<wA&&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 gt(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 gt(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 gt(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 gt(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 gt(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 gt(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 gt(l,c)}return Reflect.has(i,a)}})}applyPatches(){let t=D6();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 gt(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 gt(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 gt(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 gt(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 gt(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(!Bs)try{let t=null;if(typeof process<"u"){let a=process.mainModule;a&&typeof a=="object"&&(t=a.constructor)}if(!t&&typeof Hs<"u"&&typeof Hs.main<"u"&&(t=Hs.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 L6(e){return hr(e)}function hr(e){return e.statements.map(F6).join(`
|
|
1460
1460
|
`)}function F6(e){let t=[];for(let r=0;r<e.pipelines.length;r++)t.push(xA(e.pipelines[r])),r<e.operators.length&&t.push(e.operators[r]);let n=t.join(" ");return e.background&&(n+=" &"),n}function xA(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(M6(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 M6(e){switch(e.type){case"SimpleCommand":return EA(e);case"If":return OA(e);case"For":return RA(e);case"CStyleFor":return TA(e);case"While":return PA(e);case"Until":return DA(e);case"Case":return _A(e);case"Subshell":return FA(e);case"Group":return MA(e);case"ArithmeticCommand":return UA(e);case"ConditionalCommand":return WA(e);case"FunctionDef":return BA(e);default:{let t=e;throw new Error(`Unsupported command type: ${t.type}`)}}}function EA(e){let t=[];for(let n of e.assignments)t.push(AA(n));e.name&&t.push(kt(e.name));for(let n of e.args)t.push(kt(n));for(let n of e.redirections)t.push(B6(n));return t.join(" ")}function AA(e){let t=e.append?"+=":"=";if(e.array){let n=e.array.map(kt).join(" ");return`${e.name}${t}(${n})`}return e.value?`${e.name}${t}${kt(e.value)}`:`${e.name}${t}`}function kt(e){return e.parts.map(t=>La(t,!1)).join("")}function Vn(e){return e.parts.map(t=>La(t,!0)).join("")}function La(e,t){switch(e.type){case"Literal":return t?CA(e.value):SA(e.value);case"SingleQuoted":return`'${e.value}'`;case"DoubleQuoted":return`"${e.parts.map(n=>La(n,!0)).join("")}"`;case"Escaped":return`\\${e.value}`;case"ParameterExpansion":return U6(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 IA(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 SA(e){return e.replace(/[\s\\'"`!|&;()<>{}[\]*?~#]/g,"\\$&")}function CA(e){return e.replace(/[$`"\\]/g,"\\$&")}function NA(e,t){return e.parts.map(n=>kA(n,t)).join("")}function kA(e,t){switch(e.type){case"Literal":return t?e.value:e.value.replace(/[$`]/g,"\\$&");case"Escaped":return`\\${e.value}`;case"ParameterExpansion":return U6(e);case"CommandSubstitution":return e.legacy?`\`${hr(e.body)}\``:`$(${hr(e.body)})`;case"ArithmeticExpansion":return`$((${Le(e.expression.expression)}))`;default:return La(e,!1)}}function U6(e){return e.operation?`\${${W6(e.parameter,e.operation)}}`:vA(e.parameter)?`\${${e.parameter}}`:`$${e.parameter}`}function vA(e){return!(/^[?#@*$!\-0-9]$/.test(e)||/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(e))}function W6(e,t){switch(t.type){case"Length":return`#${e}`;case"LengthSliceError":return`#${e}:`;case"BadSubstitution":return t.text;case"DefaultValue":return`${e}${t.checkEmpty?":":""}-${Vn(t.word)}`;case"AssignDefault":return`${e}${t.checkEmpty?":":""}=${Vn(t.word)}`;case"ErrorIfUnset":return`${e}${t.checkEmpty?":":""}?${t.word?Vn(t.word):""}`;case"UseAlternative":return`${e}${t.checkEmpty?":":""}+${Vn(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}${Vn(t.pattern)}`}case"PatternReplacement":{let n="/";t.all?n="//":t.anchor==="start"?n="/#":t.anchor==="end"&&(n="/%");let r=t.replacement?`/${Vn(t.replacement)}`:"";return`${e}${n}${Vn(t.pattern)}${r}`}case"CaseModification":{let n=t.direction==="upper"?"^":",",r=t.all?`${n}${n}`:n,s=t.pattern?Vn(t.pattern):"";return`${e}${r}${s}`}case"Transform":return`${e}@${t.operator}`;case"Indirection":return t.innerOp?`!${W6(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 IA(e){return`{${e.items.map($A).join(",")}}`}function $A(e){if(e.type==="Word")return kt(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 B6(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=NA(n.content,n.quoted);return`${t}${e.operator}${r}
|
|
@@ -1481,7 +1481,7 @@ ${e.terminator}`}function FA(e){return`(${Yt(e.body)})${un(e.redirections)}`}fun
|
|
|
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=R6({...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=hu(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,bashPid:process.pid,nextVirtualPid:process.pid+1,currentLine:1,options:{errexit:!1,pipefail:!1,nounset:!1,xtrace:!1,verbose:!1,posix:!1,allexport:!1,noclobber:!1,noglob:!1,noexec:!1,vi:!1,emacs:!1},shoptOptions:{extglob:!1,dotglob:!1,nullglob:!1,failglob:!1,globstar:!1,globskipdots:!0,nocaseglob:!1,nocasematch:!1,expand_aliases:!1,lastpipe:!1,xpg_echo:!1},inCondition:!1,loopDepth:0,exportedVars:new Set(["HOME","PATH","PWD","OLDPWD",...Object.keys(t.env||{})]),readonlyVars:new Set(["SHELLOPTS","BASHOPTS"]),hashTable:new Map},this.state.env.set("SHELLOPTS",Il(this.state.options)),this.state.env.set("BASHOPTS",$l(this.state.shoptOptions)),Z0(n,this.useDefaultLayout),r!=="/"&&n instanceof sr)try{n.mkdirSync(r,{recursive:!0})}catch{}for(let i of W0(t.commands))this.registerCommand(i);if(t.network)for(let i of B0())this.registerCommand(i);if(t.python)for(let i of z0())this.registerCommand(i);if(t.customCommands)for(let i of t.customCommands)H0(i)?this.registerCommand(j0(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=z6(t));let u=(this.defenseInDepthConfig?_a.getInstance(this.defenseInDepthConfig):null)?.activate();try{let f=async()=>{let p=rn(l),h;if(this.transformPlugins.length>0){let
|
|
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=z6(t));let u=(this.defenseInDepthConfig?_a.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 Us(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 gt)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}
|