@preventive/triage 1.0.0-alpha.32 → 1.0.0-alpha.34
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/client/linked-findings.js +5 -4
- package/common/bundle-metadata.js +4 -3
- package/common/bundle-source-links.d.ts +2 -1
- package/common/bundle-source-links.js +133 -6
- package/common/bundle-sources.d.ts +2 -0
- package/common/bundle-sources.js +2 -4
- package/common/managed/repository-alias.ts +65 -0
- package/common/managed/routes.js +20 -1
- package/common/managed/triage.ts +2 -2
- package/out/client-managed-import.js +51 -46
- package/out/client-managed.js +252 -72
- package/out/client-sync.js +14 -14
- package/out/graph.js +11 -11
- package/out/index.html +1 -0
- package/out/terminal.js +169 -169
- package/out/view.css +1 -1
- package/out/view.js +417 -201
- package/package.json +23 -17
- package/server-managed/activity.ts +15 -1
- package/server-managed/brotli.ts +3 -3
- package/server-managed/bundle-advisories.ts +8 -3
- package/server-managed/bundle-advisory-inventory.ts +27 -25
- package/server-managed/bundle-build-worker.js +45 -9
- package/server-managed/bundle-build.ts +35 -11
- package/server-managed/bundle-cache.ts +1 -1
- package/server-managed/bundle.ts +17 -1
- package/server-managed/config.ts +7 -2
- package/server-managed/db-methods.ts +170 -49
- package/server-managed/db-neon.ts +59 -4
- package/server-managed/db-schema.ts +12 -3
- package/server-managed/db.ts +9 -1
- package/server-managed/github-issue-links.ts +127 -0
- package/server-managed/github-issues.ts +1 -1
- package/server-managed/http-response.ts +7 -1
- package/server-managed/http.ts +248 -80
- package/server-managed/index.ts +4 -0
- package/server-managed/link-reports.ts +158 -0
- package/server-managed/managed-issues.ts +31 -3
- package/server-managed/management.ts +17 -4
- package/server-managed/object-storage-disk.ts +7 -3
- package/server-managed/object-storage-vercel.ts +6 -2
- package/server-managed/object-storage.ts +3 -2
- package/server-managed/public-workspace.ts +5 -2
- package/server-managed/report-sources.ts +6 -5
- package/server-managed/report-store.ts +47 -0
- package/server-managed/repository-aliases.ts +91 -0
- package/server-managed/revisions.ts +2 -2
- package/server-managed/sql.ts +3 -2
- package/server-managed/storage-encryption.ts +72 -6
- package/server-managed/storage-maintenance.ts +64 -49
- package/server-managed/storage-payload.ts +11 -10
- package/server-managed/storage-stores.ts +3 -1
- package/server-managed/storage.ts +17 -0
- package/server-managed/team-feed.ts +3 -3
- package/server-managed/team-reports.ts +24 -15
- package/server-managed/upstream-cache.ts +73 -0
- package/server-managed/workspace-shares.ts +16 -12
package/out/terminal.js
CHANGED
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
var
|
|
1
|
+
var wm=Object.defineProperty;var bm=(e,t)=>{for(var n in t)wm(e,n,{get:t[n],enumerable:!0})};var ta=globalThis[Symbol.for("@rray/frontend")];if(!ta)throw new Error("@rray/frontend global not installed; view.js must run before lazy bundles import this wrapper");var{LitElement:na,html:De,nothing:ei,unsafeCSS:ra,render:VE,StateElement:KE,classMap:JE,repeat:oa,styleMap:QE}=ta;var F=(e="")=>({stdout:e,stderr:"",exitCode:0}),x=(e,t=1)=>({stdout:"",stderr:e.endsWith(`
|
|
2
2
|
`)?e:e+`
|
|
3
|
-
`,exitCode:t}),pe=(e,t=1)=>x(`usage: ${e}`,t);var ia=Symbol("unsupported");function O(e){if(e==null)return null;try{return e[ia]??null}catch{return null}}function v(e,t,n,r,o=1){return ie(x(r,o),e,t,n,r)}function ie(e,t,n,r,o){return Object.defineProperty(e,ia,{value:{kind:t,command:n,detail:r,message:o},enumerable:!1,configurable:!0}),e}function K(e,t,n,r){let o=O(e);return o?v(o.kind,t,o.detail,n,r):x(n,r)}var b=class extends Error{constructor(t,n,r){super(r),this.name="UnsupportedError",ie(this,t,null,n,r)}};function ei(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let o=JSON.stringify([n.kind,r,n.detail]);e.has(o)||(e.add(o),t.push(Object.freeze(n)))}}}var{Buffer:sa}=globalThis,aa=sa&&!sa.TYPED_ARRAY_SUPPORT;var ua=e=>e&&(aa||`${e}`.includes("[native code]"));!aa&&ua(()=>{})&&(ua=()=>!1);function ti(e,t){let n=e.length;for(let r=0;r<n;r++)t[r]=e.charCodeAt(r);return t}var kn=null,Ot=!1,la=!1,Ae=new TextEncoder,Oe=new TextDecoder("utf-8",{ignoreBOM:!0}),ni=new TextDecoder("latin1",{ignoreBOM:!0});var ri=globalThis.Buffer;function Zt(e){if(!(e&&e instanceof Uint8Array))throw new TypeError("Expected an Uint8Array")}var Yt="Input is not a string",oi="Input is not well-formed Unicode";function et(e,t){switch(t){case"uint8":if(e.constructor!==Uint8Array)throw new Error("Unexpected");return e;case"arraybuffer":if(e.byteLength!==e.buffer.byteLength)throw new Error("Unexpected");return e.buffer;case"buffer":return e.length<=64?ri.from(e):ri.from(e.buffer,e.byteOffset,e.byteLength)}throw new TypeError("Unexpected format")}function fa(e,t){switch(t){case"uint8":return e.length<=64||e.byteOffset!==0||e.byteLength!==e.buffer.byteLength?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case"arraybuffer":return e.buffer.byteLength===e.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);case"buffer":if(e.constructor!==ri)throw new Error("Unexpected");return e}throw new TypeError("Unexpected format")}var vm=Oe,Sm=Oe?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):null,{isWellFormed:da}=String.prototype;function Em(e,t,n){if(t||e.length===n.length)return n;if(da){if(da.call(e))return n;throw new TypeError(oi)}let r=0,o=n.length-3;for(;r<=o;){let i=n.indexOf(239,r);if(i===-1||i>o)break;if(r=i+1,n[i+1]===191&&n[i+2]===189){if(null)try{if(encodeURI(e)!==null)return n}catch{}else if(e===ii(n))return n;throw new TypeError(oi)}}return n}function pa(e,t=!1){if(typeof e!="string")throw new TypeError(Yt);return e.length===0?new Uint8Array:Ae||!null?Em(e,t,Ae.encode(e)):null(e,t)}function ii(e,t=!1){return Zt(e),e.byteLength===0?"":Oe||!null?t?vm.decode(e):Sm.decode(e):null(e,t)}var ha=(e,t="uint8")=>et(pa(e,!1),t),A=(e,t="uint8")=>et(pa(e,!0),t),si=e=>ii(e,!1),ma=e=>ii(e,!0);function B(e){try{return ha(e)}catch(t){throw t instanceof TypeError?new b("feature","unpaired surrogate","unpaired UTF-16 surrogates cannot be encoded as UTF-8"):t}}var $m=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Ar(e){for(let t=0;t<e.length;){let n=$m(e[t]),r=n===1?e[t]:n===0?-1:Am(e,t,n);yield r,t+=r<0?1:n}}var Nm=[0,0,128,2048,65536];function Am(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let o=1;o<n;o++){if((e[t+o]&192)!==128)return-1;r=r<<6|e[t+o]&63}return r<Nm[n]||r>1114111||r>=55296&&r<=57343?-1:r}var ui=e=>ma(e);function me(e){let t;try{t=si(e)}catch{}return t}function vn(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((r,o)=>r+o.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function W(e){try{return si(e)}catch{throw new b("feature","partial UTF-8 byte sequence","byte output that is not valid UTF-8 cannot be represented by this string-based terminal")}}function Or(e){if(Object.keys(e).length>0)throw new TypeError("Unexpected extra options")}var g$=Object.getPrototypeOf(Uint8Array);var wa=globalThis.atob,ya=Uint8Array.prototype.toBase64,ga=8192,Om=ya&&wa;function ai(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return"";if(Om&&r>=256&&r<1e8&&e.toBase64===ya&&e.BYTES_PER_ELEMENT===1){let i=t===0&&n===e.length?e:e.subarray(t,n);return wa(i.toBase64())}if(r>ga){let i="";for(let s=t;s<n;){let u=Math.min(n,s+ga);i+=String.fromCharCode.apply(String,e.subarray(s,u)),s=u}return i}let o=t===0&&n===e.length?e:e.subarray(t,n);return String.fromCharCode.apply(String,o)}var Cr=kn?e=>e.byteLength>=768&&!la?kn.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):Oe.decode(e):ni?e=>ni.decode(e):e=>ai(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var ba=e=>ti(e,new Uint8Array(e.length)),Cm=Ot&&Ae?.encodeInto,Ir=Cm?(e,t)=>{let n=new Uint8Array(e.length+4),r=Ae.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw new SyntaxError(t);return n.subarray(0,e.length)}:kn?(e,t)=>{let n=kn.from(e,"utf8");if(n.length!==e.length)throw new SyntaxError(t);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}:(e,t)=>{let n=Ae.encode(e);if(n.length!==e.length)throw new SyntaxError(t);return n};var di={};bm(di,{E_CHAR:()=>Vt,E_LAST:()=>li,E_LENGTH:()=>$a,E_PADDING:()=>Ea,fromBase64:()=>ci,toBase64:()=>fi});var xa=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],ka=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],va={},Sa={},Vt="Invalid character in base64 input",Ea="Invalid base64 padding",$a="Invalid base64 length",li="Invalid last chunk";function fi(e,t,n){let r=e.length/3|0,o=r*3,i="",s=0,u=t?ka:xa,a=t?Sa:va;if(!a.pairs)if(a.pairs=[],Oe){a.codepairs=new Uint16Array(4096);let h=a.codepairs,m=new Uint8Array(h.buffer,h.byteOffset,h.byteLength);for(let g=0;g<64;g++){let w=u[g].charCodeAt(0);for(let y=0;y<64;y++)m[g<<7|y<<1]=m[y<<7|(g<<1)+1]=w}}else{let h=a.pairs;for(let m=0;m<64;m++)for(let g=0;g<64;g++)h.push(`${u[m]}${u[g]}`)}let{pairs:l,codepairs:f}=a;if(Oe){let h=new Uint16Array(r*2),m=0;for(let g=e.length-11;s<g;s+=12,m+=8){let w=e[s],y=e[s+1],k=e[s+2],S=e[s+3],I=e[s+4],M=e[s+5],C=e[s+6],H=e[s+7],Y=e[s+8],D=e[s+9],de=e[s+10],Xt=e[s+11];h[m]=f[w<<4|y>>4],h[m+1]=f[(y&15)<<8|k],h[m+2]=f[S<<4|I>>4],h[m+3]=f[(I&15)<<8|M],h[m+4]=f[C<<4|H>>4],h[m+5]=f[(H&15)<<8|Y],h[m+6]=f[D<<4|de>>4],h[m+7]=f[(de&15)<<8|Xt]}for(let g=e.length-2;s<g;s+=3,m+=2){let w=e[s],y=e[s+1],k=e[s+2];h[m]=f[w<<4|y>>4],h[m+1]=f[(y&15)<<8|k]}i=Cr(h)}else for(;s<o;s+=3){let h=e[s],m=e[s+1],g=e[s+2];i+=l[h<<4|m>>4],i+=l[(m&15)<<8|g]}let c=0,d=2,p=e.length;for(;s<p;s++){let h=e[s];i+=u[c|h>>d],d===6&&(d=0,i+=u[h&63]),c=h<<6-d&63,d+=2}return d!==2&&(i+=u[c]),n&&(i+=["","==","="][p-o]),i}var Im=Ae?128:65536;function ci(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,o=n%4,i=n-o;if(o===1)throw new SyntaxError($a);if(r>3||r!==0&&e.length%4!==0)throw new SyntaxError(Ea);let s=t?ka:xa,u=t?Sa:va;u.fromMap||(u.fromMap=new Int8Array(Im).fill(-1),s.forEach((h,m)=>u.fromMap[h.charCodeAt(0)]=m));let a=u.fromMap,l=new Uint8Array(Math.floor(n*3/4)),f=0,c=0;if(Ae){let h=Ir(e,Vt);for(;c<i;c+=4){let m=h[c],g=h[c+1],w=h[c+2],y=h[c+3],k=a[m]<<18|a[g]<<12|a[w]<<6|a[y];if(k<0)throw new SyntaxError(Vt);l[f]=k>>16,l[f+1]=k>>8&255,l[f+2]=k&255,f+=3}}else for(;c<i;c+=4){let h=e.charCodeAt(c),m=e.charCodeAt(c+1),g=e.charCodeAt(c+2),w=e.charCodeAt(c+3),y=a[h]<<18|a[m]<<12|a[g]<<6|a[w];if(y<0)throw new SyntaxError(Vt);l[f]=y>>16,l[f+1]=y>>8&255,l[f+2]=y&255,f+=3}if(o<2)return l;let d=a[e.charCodeAt(c++)]<<6|a[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(Vt);if(l[f++]=d>>4,o<3){if(d&15)throw new SyntaxError(li);return l}let p=a[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(Vt);if(l[f++]=d<<4&255|p>>2,p&3)throw new SyntaxError(li);return l}var{Buffer:Ct,atob:Ta,btoa:Fa}=globalThis,La=Ct&&!Ct.TYPED_ARRAY_SUPPORT,{toBase64:Na}=Uint8Array.prototype,{E_CHAR:Sn,E_PADDING:$n,E_LENGTH:Tm,E_LAST:Fm}=di,Lm=Fa&&Ot,_m=Ta&&Ot,Rm=e=>e.constructor===Ct&&Ct.isBuffer(e),Mm=e=>Rm(e)?e:Ct.from(e.buffer,e.byteOffset,e.byteLength);function Aa(e,t){if(t)return e;let n=e.indexOf("=",e.length-3);return n===-1?e:e.slice(0,n)}function Oa(e,t){return t&&e.length%4!==0?e+"=".repeat(4-e.length%4):e}var Pm=e=>Na&&e.toBase64===Na;function pi(e,{padding:t=!0}={}){return Zt(e),Pm(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):La?Aa(Mm(e).base64Slice(0,e.byteLength),t):Lm?Aa(Fa(ai(e)),t):fi(e,!1,t)}function Nn(e,t){if(typeof t=="string"&&(t={format:t}),!t)return Ca(e,!1,"both","uint8",null);let{format:n="uint8",padding:r="both",...o}=t;return Ca(e,!1,r,n,o)}function Ca(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Yt);o!==null&&Or(o);let i=n==="both"?e.endsWith("="):void 0;if(n===!0||i===!0){if(e.length%4!==0)throw new SyntaxError($n);if(e[e.length-3]==="=")throw new SyntaxError($n)}else if(n===!1||i===!1){if(e.length%4===1)throw new SyntaxError(Tm);if(n===!1&&e.endsWith("="))throw new SyntaxError("Did not expect padding in base64 input")}else throw new TypeError("Invalid padding option");return En(e,t,n,r)}var Dm=/[\t\n\f\r ]/;function Ia(e,t){let n=e.indexOf("=",e.length-3),r=n>=0?e.length-n:0,o=e.length-r,i=o%4,s=t.length-(o-i)/4*3;return i===0&&s===0||i===2&&s===1||i===3&&s===2}var En;Uint8Array.fromBase64?En=(e,t,n,r)=>{let o=t?"base64url":"base64",i;if(n===!0)i=Uint8Array.fromBase64(e,{alphabet:o,lastChunkHandling:"strict"});else try{let s=e.length%4>0?`${e}${"=".repeat(4-e.length%4)}`:e;i=Uint8Array.fromBase64(s,{alphabet:o,lastChunkHandling:"strict"})}catch(s){throw Dm.test(e)?new SyntaxError(Sn):s}if(!Ia(e,i))throw new SyntaxError(Sn);return et(i,r)}:La?En=(e,t,n,r)=>{let o=Ct.byteLength(e,"base64"),i=Ct.allocUnsafeSlow(o);if(i.base64Write(e)!==o)throw new SyntaxError($n);let s=t?i.base64urlSlice(0,i.length):i.base64Slice(0,i.length);if(e!==s){if(n===!t)throw new SyntaxError($n);if(Oa(e,!0)!==Oa(s,t))throw new SyntaxError($n)}return fa(i,r)}:_m?En=(e,t,n,r)=>{let o;if(t){if(/[\t\n\f\r +/]/.test(e))throw new SyntaxError(Sn);e=e.replaceAll("-","+").replaceAll("_","/")}try{o=ba(Ta(e))}catch{throw new SyntaxError(Sn)}if(!t&&!Ia(e,o))throw new SyntaxError(Sn);if(o.length%3!==0){let i=pi(o.subarray(-(o.length%3))),s=e.length%4===0?e.slice(-4):e.slice(-(e.length%4)).padEnd(4,"=");if(i!==s)throw new SyntaxError(Fm)}return et(o,r)}:En=(e,t,n,r)=>et(ci(e,t),r);function An(e){let t=e.startsWith("/"),n=e.split("/").filter(Boolean),r=[];for(let o of n)if(o!=="."){if(o===".."){r.length>0&&r.at(-1)!==".."?r.pop():t||r.push("..");continue}r.push(o)}return t?"/"+r.join("/"):r.length===0?".":r.join("/")}function Z(e,t){return t.startsWith("/")?An(t):An(e+"/"+t)}var Bm=40,Tr=(e,t)=>e.isLink?.(t)===!0;function E(e,t,n,{follow:r=!0}={}){let o=ze(e,t,n,{follow:r});return o.error?{path:null,error:o.error}:t.endsWith("/")&&!n.isDir(o.path)?{path:null,error:"Not a directory"}:{path:o.path,error:null}}function ze(e,t,n,{follow:r=!0,lenient:o=!1}={}){if(t===""||t.includes("\0"))return{path:"/",error:"No such file or directory",rest:[]};let i=(t.startsWith("/")?t:e+"/"+t).split("/").filter(Boolean),s=r||t.endsWith("/"),u=Bm,a="/";for(;i.length>0;){let f=i.shift();if(!n.isDir(a)){if(!o){let d=n.isFile(a)||Tr(n,a)?"Not a directory":"No such file or directory";return{path:a,error:d,rest:[f,...i]}}f===".."?a=ye(a):f!=="."&&(a=Te(a,f));continue}if(f===".."){a=ye(a);continue}if(f!=="."&&(a=Te(a,f)),!Tr(n,a)||n.isDir(a)||i.length===0&&!s)continue;if(u--===0)return{path:a,error:"Too many levels of symbolic links",rest:[...i]};let c=n.readLink(a);a=c.startsWith("/")?"/":ye(a),i.unshift(...c.split("/").filter(Boolean),...c.endsWith("/")?["."]:[])}let l=!n.isDir(a)&&!n.isFile(a)&&!Tr(n,a);return{path:a,error:l?"No such file or directory":null,rest:[]}}var se=(e,t,n,r=!0)=>n===""||n.includes("\0")?Z(t,n):ze(t,n,e,{follow:r,lenient:!0}).path;function tt(e,t,n,r=E(e,t,n)){if(r.path!==null)return null;if(t===""||t.includes("\0")||t.endsWith("/")||r.error!=="No such file or directory")return r.error;let o=ze(e,t,n);return o.rest.length>0?o.error:n.isDir(ye(o.path))?null:"Not a directory"}function ye(e){let t=An(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return n<0?".":n===0?"/":t.slice(0,n)}function nt(e){let t=An(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return t.slice(n+1)}function j(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e.codePointAt(n)-t.codePointAt(n);return e.length-t.length}function Te(e,t){return e==="/"?"/"+t:e+"/"+t}function He(e,t){return e==="/"?t.slice(1):t.slice(e.length+1)}function Ra(e,t="/"){let n=new Map,r=new Map;for(let[u,a]of Wm(e)){let l=String(u),f=qm(a,l);if(f===null)continue;if(l.includes("\0"))throw new TypeError("createTerminal: source paths must not contain NUL characters");let c=An("/"+l),d=t==="/"?c:c==="/"?t:t+c;f.link===void 0?(n.set(d,f.content),r.delete(d)):(r.set(d,f.link),n.delete(d))}let o=new Map([["/",{dirs:[],files:[],links:[]}]]);_a(o,t);for(let[u,a]of[["files",n],["links",r]])for(let l of a.keys()){let f=l.lastIndexOf("/"),c=l.slice(0,f)||"/";_a(o,c),o.get(c)[u].push(l==="/"?"/":l.slice(f+1))}for(let u of o.values())u.dirs.sort(j),u.files.sort(j),u.links.sort(j);let i=(u,a=!1)=>{let l=n.get(u);if(!(l instanceof Fr))return l;let f;try{f=l.decode()}catch(c){if(!(c instanceof SyntaxError))throw c;if(a)return;throw new b("feature","base64 source",`${JSON.stringify(u)} declares base64 that does not decode, so its bytes cannot be read`)}return n.set(u,f),f},s={isFile:u=>n.has(u),isDir:u=>o.has(u),isLink:u=>r.has(u),readLink:u=>r.get(u),readFile:u=>{let a=i(u);return a===void 0||typeof a=="string"?a:rt(a,JSON.stringify(u))},readBytes:(u,a=!1)=>{let l=i(u);return typeof l!="string"?l:a?A(l):B(l)},fileSize:u=>o.has(u)?void 0:r.has(u)?B(r.get(u)).length:n.has(u)?Um(n.get(u)):void 0,sameFileContents:(u,a)=>jm(i(u,!0),i(a,!0)),exactBytes:u=>hi(i(u,!0)),isBytes:u=>typeof n.get(u)=="object",isEmptyFile:u=>{let a=n.get(u);return typeof a=="string"?a==="":a?.length===0},listDir:u=>{let a=o.get(u);if(!a)throw new Error(`not a directory: ${u}`);return a},walkFiles:u=>Gm(s,u)};return s}var Um=e=>typeof e=="string"?B(e).length:e.length,hi=e=>typeof e=="string"?e.isWellFormed()?B(e):void 0:e;function rt(e,t,n="reading them as text"){let r=me(e);if(r===void 0)throw new b("feature","binary file",`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var On=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r]);function jm(e,t){return e===void 0||t===void 0?!1:typeof e=="string"&&typeof t=="string"?e===t:On(hi(e),hi(t))}function Wm(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}function qm(e,t){if(typeof e=="string")return{content:e};if(ArrayBuffer.isView(e))return{content:Hm(e,t)};if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e instanceof ArrayBuffer)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(e.format!==void 0||e.data!==void 0)return{content:zm(e,t)};if(e.type===void 0&&e.target===void 0)return null;let n=JSON.stringify(t);if(e.type!=="link")throw new TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(e.type??null)}; the only declaration is { type: 'link', target }`);let{target:r}=e;if(typeof r!="string"||r===""||r.includes("\0"))throw new TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{link:r}}function zm(e,t){let n=JSON.stringify(t);if(e.format!=="base64")throw new TypeError(`createTerminal: source ${n} declares format ${JSON.stringify(e.format??null)}; the only format is { format: 'base64', data }`);if(typeof e.data!="string")throw new TypeError(`createTerminal: source ${n} must declare its base64 as a string in \`data\``);return new Fr(e.data)}var Fr=class{constructor(t){this.text=t;let n=t.endsWith("==")?2:t.endsWith("=")?1:0;this.length=Math.floor((t.length-n)*3/4)}decode(){return Nn(this.text)}};function Hm(e,t){if(e.BYTES_PER_ELEMENT!==1)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is a ${e[Symbol.toStringTag]??"view"}; declare a file's bytes as a Uint8Array`);return new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice()}function*Fe(e,t,n=Number.POSITIVE_INFINITY,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:"file",depth:0};return}if(!e.isDir(t)){Tr(e,t)&&(yield{path:t,kind:"link",depth:0});return}let o=[{path:t,kind:"dir",depth:0}];for(;o.length;){let i=o.pop();if(yield i,i.kind!=="dir"||i.depth>=n||!r(i.path))continue;let{dirs:s,files:u,links:a=[]}=e.listDir(i.path),l=s.length-1,f=u.length-1,c=a.length-1;for(;l>=0||f>=0||c>=0;){let d=l>=0?"dir":null,p=l>=0?s[l]:null;f>=0&&(p===null||j(u[f],p)>=0)&&(d="file",p=u[f]),c>=0&&(p===null||j(a[c],p)>=0)&&(d="link",p=a[c]),d==="dir"?l--:d==="file"?f--:c--,o.push({path:Te(i.path,p),kind:d,depth:i.depth+1})}}}function*Gm(e,t){for(let n of Fe(e,t))n.kind==="file"&&(yield n.path)}function _a(e,t){let n=[],r=t;for(;r!=="/"&&!e.has(r);)n.push(r),r=r.slice(0,r.lastIndexOf("/"))||"/";for(let o=n.length-1;o>=0;o--){let i=n[o];e.set(i,{dirs:[],files:[],links:[]});let s=i.lastIndexOf("/");e.get(i.slice(0,s)||"/").dirs.push(i.slice(s+1))}}var It={__proto__:null,alpha:"A-Za-z",digit:"0-9",alnum:"0-9A-Za-z",upper:"A-Z",lower:"a-z",space:" \\t\\n\\v\\f\\r",blank:" \\t",punct:"!-\\/:-@\\[-`{-~",xdigit:"0-9A-Fa-f",cntrl:"\\x00-\\x1F\\x7F",print:"\\x20-\\x7E",graph:"\\x21-\\x7E",word:"0-9A-Za-z_"},mi={__proto__:null};for(let[e,t]of Object.entries(It)){let n=new RegExp(`[${t}]`,"u"),r=[];for(let o=0;o<128;o++){if(!n.test(String.fromCodePoint(o)))continue;let i=r.at(-1);i&&i[1]===o-1?i[1]=o:r.push([o,o])}mi[e]=r}var Lr=32767;function Ma(e,t){if(e>Lr||t!==void 0&&t>Lr)throw new Error("Regular expression too big")}function Pa(e,t,n=!1){let r=t+1;e[r]==="^"&&r++;let o=!0,i=!1;for(;r<e.length;){let s=e[r];if(s==="]"&&!o)return r;if(o=!1,s==="["&&":.=".includes(e[r+1]??"")){let l=e[r+1],f=e.indexOf(l+"]",r+2);if(f===-1)throw new Error("Unmatched [, [^, [:, [., or [=");if(l===":"&&!(e.slice(r+2,f)in It))throw new Error("Invalid character class name");if(l!==":"&&n&&/\P{ASCII}/u.test(e.slice(r+2,f)))throw new Error("Invalid collation character");r=f+2,i=l!==".";continue}if(s==="-"&&i&&r+1<e.length&&e[r+1]!=="]")throw new Error("Invalid range end");let u=s==="\\"&&r+1<e.length?2:1;if(e[r+u]==="-"&&e[r+u+1]!==void 0&&e[r+u+1]!=="]"){let l=r+u+1,f=e[l]==="["?e[l+1]:void 0;if(f===":"||f==="=")throw new Error("Invalid range end");let c=f==="."?e.indexOf(".]",l+2):-1;if(f==="."&&c===-1)throw new Error("Unmatched [, [^, [:, [., or [=");let d=f==="."?l+2:l+(e[l]==="\\"?1:0);if(n&&(e.codePointAt(r+u-1)>127||e.codePointAt(d)>127))throw new Error("Invalid collation character");r=c===-1?l+(e[l]==="\\"?2:1):c+2,i=!0;continue}r+=u,i=!1}throw new Error("Unmatched [, [^, [:, [., or [=")}function Kt(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let o=n.classes?n.classes.body(r[1]):It[r[1]];if(o===void 0){if(n?.unknown!=="empty")throw new Error(`invalid character class \`[:${r[1]}:]\``);return{body:"",end:t+r[0].length}}return{body:o,end:t+r[0].length}}var _r={alpha:"1t:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,3:3,3:7,2:1,2:1,1:0,8:0,4:1,1:4,2:b,a:0,4:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,4:4,4:1,2:1,4:0,7:3,1:0,7:f,b:2,1:8,1:2,1:l,1:6,1:1,1:4,3:8,1:2,1:1,3:0,f:3,2:9,9:3,4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x6d:1:1:1,1ee9:q:w:1,1fcw:14:14:1,1fhs:10:14:1,1fn4:b:13:1,1fng:f:13:1,1fnw:7:13:1,1fo4:2:13:1,1h1c:1f:1s:1,1jfk:w:w:1,20cg:w:w:1,2olc:y:y:1";var ee="C.UTF-8",Rr="only the C.UTF-8 locale is supported",wi=e=>typeof e=="string"&&/^C\.UTF-?8$/iu.test(e),Xm=new Set(["LANG","LC_ALL","LC_CTYPE"]);function Wa(e){if(e.locale===void 0||wi(e.locale))return ee;throw new TypeError(`createTerminal: ${Rr} (got ${JSON.stringify(e.locale)})`)}function qa(e,t){if(!(Xm.has(e)?wi(t)||e!=="LANG"&&t==="":wi(t)||t==="C"||t==="POSIX"||t===""))throw new b("feature",e,`${e}: ${Rr}`)}var Mr=e=>e==="C"||e==="POSIX",le=e=>Mr(e.locale);function Ua(e){let t=[],n=-1;for(let r of e.split(",")){let[o,i]=r.split(":").map(u=>parseInt(u,36)),s=n+1+o;t.push([s,s+i]),n=s+i}return t}function Zm(e){let t=e.findIndex(([n])=>n>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function gi(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):e<128?"\\x"+e.toString(16).padStart(2,"0"):String.fromCodePoint(e)}var Ym=e=>e.map(([t,n])=>t===n?gi(t):`${gi(t)}-${gi(n)}`).join("");function Vm(e,t){let n=e.length-1,r=0;for(;r<=n;){let o=r+n>>1;if(t<e[o][0])n=o-1;else if(t>e[o][1])r=o+1;else return!0}return!1}var Pr=e=>e==="upper"||e==="lower"?"alpha":e,Km=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],Tt=/[\u1C80-\u1C88]/u;function ja(e){let t=new Map;for(let n of e.split(",")){let[r,o,i,s]=n.split(":").map(u=>parseInt(u,36));for(let u=0;u<o;u++)t.set(r+u*s,r+u*s+i)}return t}var za=(e,t)=>({up:e,low:t,folds:new Map});function Jm(){let e=new Map,t=new Map;for(let n=97;n<=122;n++)e.set(n,n-32),t.set(n-32,n);return za(e,t)}function Qm(e){let t=[];for(let[n,r]of e.sort((o,i)=>o[0]-i[0])){let o=t.at(-1);o&&n<=o[1]+1?o[1]=Math.max(o[1],r):t.push([n,r])}return t}function Ha(e,t,n,r,o){let i=new Map,s=new Map,u=null,a=c=>(s.has(c)||s.set(c,n(c)),s.get(c)),l=()=>u??=o(),f={name:e,multibyte:t,ranges:a,body(c){return i.has(c)||i.set(c,r(c,a(c))),i.get(c)},has(c,d){let p=a(c);return p!==void 0&&Vm(p,d)},assertions(){if(f.js)return f.js;let c=f.body("space"),d=`[${f.body("word")}]`;return f.js={__proto__:null,"<":`(?<!${d})(?=${d})`,">":`(?<=${d})(?!${d})`,boundary:`(?:(?<!${d})(?=${d})|(?<=${d})(?!${d}))`,inside:`(?:(?<=${d})(?=${d})|(?<!${d})(?!${d}))`,word:d,nonWord:`[^${f.body("word")}]`,space:`[${c}]`,nonSpace:`[^${c}]`},f.js},up:c=>l().up.get(c)??c,low:c=>l().low.get(c)??c,fold(c){let{folds:d}=l(),p=d.get(c);if(p===void 0){let h=f.up(c),m=f.low(h),g=new Set([c,h]);m!==h&&f.up(m)===h&&g.add(m);for(let w of Km)f.up(w)===h&&g.add(w);p=[...g].sort((w,y)=>w-y),d.set(c,p)}return p},foldRange(c,d){let{up:p}=l(),h=p.get(c)??c,m=p.get(d)??d;if(h>m)return null;let g=[],w=[];for(let[S,I]of p){let M=S>=h&&S<=m;M!==(I>=h&&I<=m)&&(M?g:w).push(S)}let y=[],k=h;for(let S of g.sort((I,M)=>I-M))S>k&&y.push([k,S-1]),k=S+1;return k<=m&&y.push([k,m]),Qm([...y,...w.map(S=>[S,S])])}};return f}var e0=Ha("C",!1,e=>mi[e],e=>It[e],Jm),t0=Ha(ee,!0,e=>e==="word"?Zm(Ua(_r.alnum)):Object.hasOwn(_r,e)?Ua(_r[e]):void 0,(e,t)=>t===void 0?void 0:Ym(t),()=>za(ja(Da),ja(Ba)));function re(e){if(e===ee)return t0;if(Mr(e))return e0;throw new b("feature","locale",`matching in the ${e} locale is not supported`)}var ue=(1n<<63n)-1n,ot=-ue-1n,it=(1n<<64n)-1n;function P(e,t,n,r){let o=E(e.cwd,n,e.fs,r);return R(e,t,n,o.error),o}function R(e,t,n,r){if(r!=="No such file or directory"||typeof n!="string")return;let o=n.startsWith("/"),i=o?"/":e.cwd,s=n.replace(/^\/+/u,""),u=new Set;for(let f of new Set(["/",e.mount??"/",e.home??"/"])){if(f===i)continue;let c=E(f,s,e.fs);c.error||u.add(c.path)}if(!u.size)return;let a=o?"":` from cwd ${JSON.stringify(e.cwd)}`,l=`${o?"absolute":"relative"} path ${JSON.stringify(n)} was not found${a}`;e.notes?.add(`${t}: ${l}. ${n0(e,u)}`)}function n0(e,t){let n=[...t].sort(j),r=n.map(u=>JSON.stringify(u));if(n.length===1)return`A ${e.fs.isDir(n[0])?"dir":"file"} exists at ${r[0]}.`;let i=n.every(u=>!e.fs.isDir(u)&&e.fs.isFile(u))&&n.some(u=>!e.fs.sameFileContents(n[0],u)),s=`${r.slice(0,-1).join(", ")} and ${r.at(-1)}`;return`${n.length===2?"Both":"All"} of ${s} exist${i?", and they differ in contents":""}.`}function Jt(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(".")&&e.add(Z(t,r))},emit(t,n,r,o=""){gt(t,{command:n,action:"omitted",noun:["hidden entry","hidden entries"],explanation:r,context:o,paths:e})}}}var Ga=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function Xa(e,t){for(let n of t.split(`
|
|
4
|
-
`))Ga.test(n)&&e.discarded?.add(n)}function yi(e,t,n){let r=new Map;for(let o of e){if(t.includes(o))continue;let{command:i,operand:s,reason:u}=Ga.exec(o).groups,a=/'([^']*)'$/u.exec(s)?.[1]??s;if([...n].some(f=>f.includes(JSON.stringify(a))))continue;let l=`${i}: ${u}`;r.has(l)||r.set(l,new Set),r.get(l).add(a)}return[...r].map(([o,i])=>`${o}: ${[...i].map(s=>JSON.stringify(s)).join(", ")}.`)}function Za(e,t){return e==="status"?null:{name:t,search:e==="search"}}function Ya(){let e=null,t=0;return{skip(n,r){!t&&n&&(e={...n,exitCode:r}),t++},flush(n){if(t&&e){let r=t===1?"the command":`the ${t} commands`,o=e.search&&e.exitCode===1?" A search that selects no lines exits 1, which is not a failure.":"";n.add(`${e.name}: exited ${e.exitCode}, so ${r} after && did not run.${o}`)}e=null,t=0}}}function gt(e,t){
|
|
3
|
+
`,exitCode:t}),pe=(e,t=1)=>x(`usage: ${e}`,t);var ia=Symbol("unsupported");function O(e){if(e==null)return null;try{return e[ia]??null}catch{return null}}function v(e,t,n,r,o=1){return ie(x(r,o),e,t,n,r)}function ie(e,t,n,r,o){return Object.defineProperty(e,ia,{value:{kind:t,command:n,detail:r,message:o},enumerable:!1,configurable:!0}),e}function K(e,t,n,r){let o=O(e);return o?v(o.kind,t,o.detail,n,r):x(n,r)}var y=class extends Error{constructor(t,n,r){super(r),this.name="UnsupportedError",ie(this,t,null,n,r)}};function ti(){let e=new Set,t=[];return{entries:t,add(n,r=n.command){let o=JSON.stringify([n.kind,r,n.detail]);e.has(o)||(e.add(o),t.push(Object.freeze(n)))}}}var{Buffer:sa}=globalThis,aa=sa&&!sa.TYPED_ARRAY_SUPPORT;var ua=e=>e&&(aa||`${e}`.includes("[native code]"));!aa&&ua(()=>{})&&(ua=()=>!1);function ni(e,t){let n=e.length;for(let r=0;r<n;r++)t[r]=e.charCodeAt(r);return t}var kn=null,Ot=!1,la=!1,Ae=new TextEncoder,Oe=new TextDecoder("utf-8",{ignoreBOM:!0}),ri=new TextDecoder("latin1",{ignoreBOM:!0});var oi=globalThis.Buffer;function Zt(e){if(!(e&&e instanceof Uint8Array))throw new TypeError("Expected an Uint8Array")}var Yt="Input is not a string",ii="Input is not well-formed Unicode";function et(e,t){switch(t){case"uint8":if(e.constructor!==Uint8Array)throw new Error("Unexpected");return e;case"arraybuffer":if(e.byteLength!==e.buffer.byteLength)throw new Error("Unexpected");return e.buffer;case"buffer":return e.length<=64?oi.from(e):oi.from(e.buffer,e.byteOffset,e.byteLength)}throw new TypeError("Unexpected format")}function fa(e,t){switch(t){case"uint8":return e.length<=64||e.byteOffset!==0||e.byteLength!==e.buffer.byteLength?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength);case"arraybuffer":return e.buffer.byteLength===e.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);case"buffer":if(e.constructor!==oi)throw new Error("Unexpected");return e}throw new TypeError("Unexpected format")}var km=Oe,vm=Oe?new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}):null,{isWellFormed:da}=String.prototype;function Sm(e,t,n){if(t||e.length===n.length)return n;if(da){if(da.call(e))return n;throw new TypeError(ii)}let r=0,o=n.length-3;for(;r<=o;){let i=n.indexOf(239,r);if(i===-1||i>o)break;if(r=i+1,n[i+1]===191&&n[i+2]===189){if(null)try{if(encodeURI(e)!==null)return n}catch{}else if(e===si(n))return n;throw new TypeError(ii)}}return n}function pa(e,t=!1){if(typeof e!="string")throw new TypeError(Yt);return e.length===0?new Uint8Array:Ae||!null?Sm(e,t,Ae.encode(e)):null(e,t)}function si(e,t=!1){return Zt(e),e.byteLength===0?"":Oe||!null?t?km.decode(e):vm.decode(e):null(e,t)}var ha=(e,t="uint8")=>et(pa(e,!1),t),A=(e,t="uint8")=>et(pa(e,!0),t),ui=e=>si(e,!1),ma=e=>si(e,!0);function B(e){try{return ha(e)}catch(t){throw t instanceof TypeError?new y("feature","unpaired surrogate","unpaired UTF-16 surrogates cannot be encoded as UTF-8"):t}}var Em=e=>e<128?1:e>=194&&e<=223?2:e>=224&&e<=239?3:e>=240&&e<=244?4:0;function*Ar(e){for(let t=0;t<e.length;){let n=Em(e[t]),r=n===1?e[t]:n===0?-1:Nm(e,t,n);yield r,t+=r<0?1:n}}var $m=[0,0,128,2048,65536];function Nm(e,t,n){if(t+n>e.length)return-1;let r=e[t]&127>>n;for(let o=1;o<n;o++){if((e[t+o]&192)!==128)return-1;r=r<<6|e[t+o]&63}return r<$m[n]||r>1114111||r>=55296&&r<=57343?-1:r}var ai=e=>ma(e);function me(e){let t;try{t=ui(e)}catch{}return t}function vn(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((r,o)=>r+o.length,0)),n=0;for(let r of e)t.set(r,n),n+=r.length;return t}function W(e){try{return ui(e)}catch{throw new y("feature","partial UTF-8 byte sequence","byte output that is not valid UTF-8 cannot be represented by this string-based terminal")}}function Or(e){if(Object.keys(e).length>0)throw new TypeError("Unexpected extra options")}var g$=Object.getPrototypeOf(Uint8Array);var wa=globalThis.atob,ba=Uint8Array.prototype.toBase64,ga=8192,Am=ba&&wa;function li(e,t=0,n=e.length){t|=0,n|=0;let r=n-t;if(r===0)return"";if(Am&&r>=256&&r<1e8&&e.toBase64===ba&&e.BYTES_PER_ELEMENT===1){let i=t===0&&n===e.length?e:e.subarray(t,n);return wa(i.toBase64())}if(r>ga){let i="";for(let s=t;s<n;){let u=Math.min(n,s+ga);i+=String.fromCharCode.apply(String,e.subarray(s,u)),s=u}return i}let o=t===0&&n===e.length?e:e.subarray(t,n);return String.fromCharCode.apply(String,o)}var Cr=kn?e=>e.byteLength>=768&&!la?kn.from(e.buffer,e.byteOffset,e.byteLength).latin1Slice(0,e.byteLength):Oe.decode(e):ri?e=>ri.decode(e):e=>li(e instanceof Uint8Array?e:new Uint8Array(e.buffer,e.byteOffset,e.byteLength));var ya=e=>ni(e,new Uint8Array(e.length)),Om=Ot&&Ae?.encodeInto,Ir=Om?(e,t)=>{let n=new Uint8Array(e.length+4),r=Ae.encodeInto(e,n);if(r.read!==e.length||r.written!==e.length)throw new SyntaxError(t);return n.subarray(0,e.length)}:kn?(e,t)=>{let n=kn.from(e,"utf8");if(n.length!==e.length)throw new SyntaxError(t);return new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}:(e,t)=>{let n=Ae.encode(e);if(n.length!==e.length)throw new SyntaxError(t);return n};var pi={};bm(pi,{E_CHAR:()=>Vt,E_LAST:()=>fi,E_LENGTH:()=>$a,E_PADDING:()=>Ea,fromBase64:()=>di,toBase64:()=>ci});var xa=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],ka=[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],va={},Sa={},Vt="Invalid character in base64 input",Ea="Invalid base64 padding",$a="Invalid base64 length",fi="Invalid last chunk";function ci(e,t,n){let r=e.length/3|0,o=r*3,i="",s=0,u=t?ka:xa,a=t?Sa:va;if(!a.pairs)if(a.pairs=[],Oe){a.codepairs=new Uint16Array(4096);let h=a.codepairs,m=new Uint8Array(h.buffer,h.byteOffset,h.byteLength);for(let g=0;g<64;g++){let w=u[g].charCodeAt(0);for(let b=0;b<64;b++)m[g<<7|b<<1]=m[b<<7|(g<<1)+1]=w}}else{let h=a.pairs;for(let m=0;m<64;m++)for(let g=0;g<64;g++)h.push(`${u[m]}${u[g]}`)}let{pairs:l,codepairs:f}=a;if(Oe){let h=new Uint16Array(r*2),m=0;for(let g=e.length-11;s<g;s+=12,m+=8){let w=e[s],b=e[s+1],k=e[s+2],S=e[s+3],I=e[s+4],M=e[s+5],C=e[s+6],H=e[s+7],Y=e[s+8],D=e[s+9],de=e[s+10],Xt=e[s+11];h[m]=f[w<<4|b>>4],h[m+1]=f[(b&15)<<8|k],h[m+2]=f[S<<4|I>>4],h[m+3]=f[(I&15)<<8|M],h[m+4]=f[C<<4|H>>4],h[m+5]=f[(H&15)<<8|Y],h[m+6]=f[D<<4|de>>4],h[m+7]=f[(de&15)<<8|Xt]}for(let g=e.length-2;s<g;s+=3,m+=2){let w=e[s],b=e[s+1],k=e[s+2];h[m]=f[w<<4|b>>4],h[m+1]=f[(b&15)<<8|k]}i=Cr(h)}else for(;s<o;s+=3){let h=e[s],m=e[s+1],g=e[s+2];i+=l[h<<4|m>>4],i+=l[(m&15)<<8|g]}let c=0,d=2,p=e.length;for(;s<p;s++){let h=e[s];i+=u[c|h>>d],d===6&&(d=0,i+=u[h&63]),c=h<<6-d&63,d+=2}return d!==2&&(i+=u[c]),n&&(i+=["","==","="][p-o]),i}var Cm=Ae?128:65536;function di(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,o=n%4,i=n-o;if(o===1)throw new SyntaxError($a);if(r>3||r!==0&&e.length%4!==0)throw new SyntaxError(Ea);let s=t?ka:xa,u=t?Sa:va;u.fromMap||(u.fromMap=new Int8Array(Cm).fill(-1),s.forEach((h,m)=>u.fromMap[h.charCodeAt(0)]=m));let a=u.fromMap,l=new Uint8Array(Math.floor(n*3/4)),f=0,c=0;if(Ae){let h=Ir(e,Vt);for(;c<i;c+=4){let m=h[c],g=h[c+1],w=h[c+2],b=h[c+3],k=a[m]<<18|a[g]<<12|a[w]<<6|a[b];if(k<0)throw new SyntaxError(Vt);l[f]=k>>16,l[f+1]=k>>8&255,l[f+2]=k&255,f+=3}}else for(;c<i;c+=4){let h=e.charCodeAt(c),m=e.charCodeAt(c+1),g=e.charCodeAt(c+2),w=e.charCodeAt(c+3),b=a[h]<<18|a[m]<<12|a[g]<<6|a[w];if(b<0)throw new SyntaxError(Vt);l[f]=b>>16,l[f+1]=b>>8&255,l[f+2]=b&255,f+=3}if(o<2)return l;let d=a[e.charCodeAt(c++)]<<6|a[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(Vt);if(l[f++]=d>>4,o<3){if(d&15)throw new SyntaxError(fi);return l}let p=a[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(Vt);if(l[f++]=d<<4&255|p>>2,p&3)throw new SyntaxError(fi);return l}var{Buffer:Ct,atob:Ta,btoa:Fa}=globalThis,La=Ct&&!Ct.TYPED_ARRAY_SUPPORT,{toBase64:Na}=Uint8Array.prototype,{E_CHAR:Sn,E_PADDING:$n,E_LENGTH:Im,E_LAST:Tm}=pi,Fm=Fa&&Ot,Lm=Ta&&Ot,_m=e=>e.constructor===Ct&&Ct.isBuffer(e),Rm=e=>_m(e)?e:Ct.from(e.buffer,e.byteOffset,e.byteLength);function Aa(e,t){if(t)return e;let n=e.indexOf("=",e.length-3);return n===-1?e:e.slice(0,n)}function Oa(e,t){return t&&e.length%4!==0?e+"=".repeat(4-e.length%4):e}var Mm=e=>Na&&e.toBase64===Na;function hi(e,{padding:t=!0}={}){return Zt(e),Mm(e)?t?e.toBase64():e.toBase64({omitPadding:!t}):La?Aa(Rm(e).base64Slice(0,e.byteLength),t):Fm?Aa(Fa(li(e)),t):ci(e,!1,t)}function Nn(e,t){if(typeof t=="string"&&(t={format:t}),!t)return Ca(e,!1,"both","uint8",null);let{format:n="uint8",padding:r="both",...o}=t;return Ca(e,!1,r,n,o)}function Ca(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Yt);o!==null&&Or(o);let i=n==="both"?e.endsWith("="):void 0;if(n===!0||i===!0){if(e.length%4!==0)throw new SyntaxError($n);if(e[e.length-3]==="=")throw new SyntaxError($n)}else if(n===!1||i===!1){if(e.length%4===1)throw new SyntaxError(Im);if(n===!1&&e.endsWith("="))throw new SyntaxError("Did not expect padding in base64 input")}else throw new TypeError("Invalid padding option");return En(e,t,n,r)}var Pm=/[\t\n\f\r ]/;function Ia(e,t){let n=e.indexOf("=",e.length-3),r=n>=0?e.length-n:0,o=e.length-r,i=o%4,s=t.length-(o-i)/4*3;return i===0&&s===0||i===2&&s===1||i===3&&s===2}var En;Uint8Array.fromBase64?En=(e,t,n,r)=>{let o=t?"base64url":"base64",i;if(n===!0)i=Uint8Array.fromBase64(e,{alphabet:o,lastChunkHandling:"strict"});else try{let s=e.length%4>0?`${e}${"=".repeat(4-e.length%4)}`:e;i=Uint8Array.fromBase64(s,{alphabet:o,lastChunkHandling:"strict"})}catch(s){throw Pm.test(e)?new SyntaxError(Sn):s}if(!Ia(e,i))throw new SyntaxError(Sn);return et(i,r)}:La?En=(e,t,n,r)=>{let o=Ct.byteLength(e,"base64"),i=Ct.allocUnsafeSlow(o);if(i.base64Write(e)!==o)throw new SyntaxError($n);let s=t?i.base64urlSlice(0,i.length):i.base64Slice(0,i.length);if(e!==s){if(n===!t)throw new SyntaxError($n);if(Oa(e,!0)!==Oa(s,t))throw new SyntaxError($n)}return fa(i,r)}:Lm?En=(e,t,n,r)=>{let o;if(t){if(/[\t\n\f\r +/]/.test(e))throw new SyntaxError(Sn);e=e.replaceAll("-","+").replaceAll("_","/")}try{o=ya(Ta(e))}catch{throw new SyntaxError(Sn)}if(!t&&!Ia(e,o))throw new SyntaxError(Sn);if(o.length%3!==0){let i=hi(o.subarray(-(o.length%3))),s=e.length%4===0?e.slice(-4):e.slice(-(e.length%4)).padEnd(4,"=");if(i!==s)throw new SyntaxError(Tm)}return et(o,r)}:En=(e,t,n,r)=>et(di(e,t),r);function An(e){let t=e.startsWith("/"),n=e.split("/").filter(Boolean),r=[];for(let o of n)if(o!=="."){if(o===".."){r.length>0&&r.at(-1)!==".."?r.pop():t||r.push("..");continue}r.push(o)}return t?"/"+r.join("/"):r.length===0?".":r.join("/")}function Z(e,t){return t.startsWith("/")?An(t):An(e+"/"+t)}var Dm=40,Tr=(e,t)=>e.isLink?.(t)===!0;function E(e,t,n,{follow:r=!0}={}){let o=ze(e,t,n,{follow:r});return o.error?{path:null,error:o.error}:t.endsWith("/")&&!n.isDir(o.path)?{path:null,error:"Not a directory"}:{path:o.path,error:null}}function ze(e,t,n,{follow:r=!0,lenient:o=!1}={}){if(t===""||t.includes("\0"))return{path:"/",error:"No such file or directory",rest:[]};let i=(t.startsWith("/")?t:e+"/"+t).split("/").filter(Boolean),s=r||t.endsWith("/"),u=Dm,a="/";for(;i.length>0;){let f=i.shift();if(!n.isDir(a)){if(!o){let d=n.isFile(a)||Tr(n,a)?"Not a directory":"No such file or directory";return{path:a,error:d,rest:[f,...i]}}f===".."?a=be(a):f!=="."&&(a=Te(a,f));continue}if(f===".."){a=be(a);continue}if(f!=="."&&(a=Te(a,f)),!Tr(n,a)||n.isDir(a)||i.length===0&&!s)continue;if(u--===0)return{path:a,error:"Too many levels of symbolic links",rest:[...i]};let c=n.readLink(a);a=c.startsWith("/")?"/":be(a),i.unshift(...c.split("/").filter(Boolean),...c.endsWith("/")?["."]:[])}let l=!n.isDir(a)&&!n.isFile(a)&&!Tr(n,a);return{path:a,error:l?"No such file or directory":null,rest:[]}}var se=(e,t,n,r=!0)=>n===""||n.includes("\0")?Z(t,n):ze(t,n,e,{follow:r,lenient:!0}).path;function tt(e,t,n,r=E(e,t,n)){if(r.path!==null)return null;if(t===""||t.includes("\0")||t.endsWith("/")||r.error!=="No such file or directory")return r.error;let o=ze(e,t,n);return o.rest.length>0?o.error:n.isDir(be(o.path))?null:"Not a directory"}function be(e){let t=An(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return n<0?".":n===0?"/":t.slice(0,n)}function nt(e){let t=An(e);if(t==="/")return"/";let n=t.lastIndexOf("/");return t.slice(n+1)}function j(e,t){for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e.codePointAt(n)-t.codePointAt(n);return e.length-t.length}function Te(e,t){return e==="/"?"/"+t:e+"/"+t}function He(e,t){return e==="/"?t.slice(1):t.slice(e.length+1)}function Ra(e,t="/"){let n=new Map,r=new Map;for(let[u,a]of jm(e)){let l=String(u),f=Wm(a,l);if(f===null)continue;if(l.includes("\0"))throw new TypeError("createTerminal: source paths must not contain NUL characters");let c=An("/"+l),d=t==="/"?c:c==="/"?t:t+c;f.link===void 0?(n.set(d,f.content),r.delete(d)):(r.set(d,f.link),n.delete(d))}let o=new Map([["/",{dirs:[],files:[],links:[]}]]);_a(o,t);for(let[u,a]of[["files",n],["links",r]])for(let l of a.keys()){let f=l.lastIndexOf("/"),c=l.slice(0,f)||"/";_a(o,c),o.get(c)[u].push(l==="/"?"/":l.slice(f+1))}for(let u of o.values())u.dirs.sort(j),u.files.sort(j),u.links.sort(j);let i=(u,a=!1)=>{let l=n.get(u);if(!(l instanceof Fr))return l;let f;try{f=l.decode()}catch(c){if(!(c instanceof SyntaxError))throw c;if(a)return;throw new y("feature","base64 source",`${JSON.stringify(u)} declares base64 that does not decode, so its bytes cannot be read`)}return n.set(u,f),f},s={isFile:u=>n.has(u),isDir:u=>o.has(u),isLink:u=>r.has(u),readLink:u=>r.get(u),readFile:u=>{let a=i(u);return a===void 0||typeof a=="string"?a:rt(a,JSON.stringify(u))},readBytes:(u,a=!1)=>{let l=i(u);return typeof l!="string"?l:a?A(l):B(l)},fileSize:u=>o.has(u)?void 0:r.has(u)?B(r.get(u)).length:n.has(u)?Bm(n.get(u)):void 0,sameFileContents:(u,a)=>Um(i(u,!0),i(a,!0)),exactBytes:u=>mi(i(u,!0)),isBytes:u=>typeof n.get(u)=="object",isEmptyFile:u=>{let a=n.get(u);return typeof a=="string"?a==="":a?.length===0},listDir:u=>{let a=o.get(u);if(!a)throw new Error(`not a directory: ${u}`);return a},walkFiles:u=>Hm(s,u)};return s}var Bm=e=>typeof e=="string"?B(e).length:e.length,mi=e=>typeof e=="string"?e.isWellFormed()?B(e):void 0:e;function rt(e,t,n="reading them as text"){let r=me(e);if(r===void 0)throw new y("feature","binary file",`${t} holds bytes that spell no text, and ${n} is not supported`);return r}var On=(e,t)=>e!==void 0&&t!==void 0&&e.length===t.length&&e.every((n,r)=>n===t[r]);function Um(e,t){return e===void 0||t===void 0?!1:typeof e=="string"&&typeof t=="string"?e===t:On(mi(e),mi(t))}function jm(e){try{return Map.prototype.entries.call(e)}catch{return Object.entries(e??{})}}function Wm(e,t){if(typeof e=="string")return{content:e};if(ArrayBuffer.isView(e))return{content:zm(e,t)};if(e===null||typeof e!="object"||Array.isArray(e))return null;if(e instanceof ArrayBuffer)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is an ArrayBuffer; declare a file's bytes as a Uint8Array over it`);if(e.format!==void 0||e.data!==void 0)return{content:qm(e,t)};if(e.type===void 0&&e.target===void 0)return null;let n=JSON.stringify(t);if(e.type!=="link")throw new TypeError(`createTerminal: source ${n} declares type ${JSON.stringify(e.type??null)}; the only declaration is { type: 'link', target }`);let{target:r}=e;if(typeof r!="string"||r===""||r.includes("\0"))throw new TypeError(`createTerminal: link ${n} must declare a non-empty target without NUL characters`);return{link:r}}function qm(e,t){let n=JSON.stringify(t);if(e.format!=="base64")throw new TypeError(`createTerminal: source ${n} declares format ${JSON.stringify(e.format??null)}; the only format is { format: 'base64', data }`);if(typeof e.data!="string")throw new TypeError(`createTerminal: source ${n} must declare its base64 as a string in \`data\``);return new Fr(e.data)}var Fr=class{constructor(t){this.text=t;let n=t.endsWith("==")?2:t.endsWith("=")?1:0;this.length=Math.floor((t.length-n)*3/4)}decode(){return Nn(this.text)}};function zm(e,t){if(e.BYTES_PER_ELEMENT!==1)throw new TypeError(`createTerminal: source ${JSON.stringify(t)} is a ${e[Symbol.toStringTag]??"view"}; declare a file's bytes as a Uint8Array`);return new Uint8Array(e.buffer,e.byteOffset,e.byteLength).slice()}function*Fe(e,t,n=Number.POSITIVE_INFINITY,r=()=>!0){if(e.isFile(t)){yield{path:t,kind:"file",depth:0};return}if(!e.isDir(t)){Tr(e,t)&&(yield{path:t,kind:"link",depth:0});return}let o=[{path:t,kind:"dir",depth:0}];for(;o.length;){let i=o.pop();if(yield i,i.kind!=="dir"||i.depth>=n||!r(i.path))continue;let{dirs:s,files:u,links:a=[]}=e.listDir(i.path),l=s.length-1,f=u.length-1,c=a.length-1;for(;l>=0||f>=0||c>=0;){let d=l>=0?"dir":null,p=l>=0?s[l]:null;f>=0&&(p===null||j(u[f],p)>=0)&&(d="file",p=u[f]),c>=0&&(p===null||j(a[c],p)>=0)&&(d="link",p=a[c]),d==="dir"?l--:d==="file"?f--:c--,o.push({path:Te(i.path,p),kind:d,depth:i.depth+1})}}}function*Hm(e,t){for(let n of Fe(e,t))n.kind==="file"&&(yield n.path)}function _a(e,t){let n=[],r=t;for(;r!=="/"&&!e.has(r);)n.push(r),r=r.slice(0,r.lastIndexOf("/"))||"/";for(let o=n.length-1;o>=0;o--){let i=n[o];e.set(i,{dirs:[],files:[],links:[]});let s=i.lastIndexOf("/");e.get(i.slice(0,s)||"/").dirs.push(i.slice(s+1))}}var It={__proto__:null,alpha:"A-Za-z",digit:"0-9",alnum:"0-9A-Za-z",upper:"A-Z",lower:"a-z",space:" \\t\\n\\v\\f\\r",blank:" \\t",punct:"!-\\/:-@\\[-`{-~",xdigit:"0-9A-Fa-f",cntrl:"\\x00-\\x1F\\x7F",print:"\\x20-\\x7E",graph:"\\x21-\\x7E",word:"0-9A-Za-z_"},gi={__proto__:null};for(let[e,t]of Object.entries(It)){let n=new RegExp(`[${t}]`,"u"),r=[];for(let o=0;o<128;o++){if(!n.test(String.fromCodePoint(o)))continue;let i=r.at(-1);i&&i[1]===o-1?i[1]=o:r.push([o,o])}gi[e]=r}var Lr=32767;function Ma(e,t){if(e>Lr||t!==void 0&&t>Lr)throw new Error("Regular expression too big")}function Pa(e,t,n=!1){let r=t+1;e[r]==="^"&&r++;let o=!0,i=!1;for(;r<e.length;){let s=e[r];if(s==="]"&&!o)return r;if(o=!1,s==="["&&":.=".includes(e[r+1]??"")){let l=e[r+1],f=e.indexOf(l+"]",r+2);if(f===-1)throw new Error("Unmatched [, [^, [:, [., or [=");if(l===":"&&!(e.slice(r+2,f)in It))throw new Error("Invalid character class name");if(l!==":"&&n&&/\P{ASCII}/u.test(e.slice(r+2,f)))throw new Error("Invalid collation character");r=f+2,i=l!==".";continue}if(s==="-"&&i&&r+1<e.length&&e[r+1]!=="]")throw new Error("Invalid range end");let u=s==="\\"&&r+1<e.length?2:1;if(e[r+u]==="-"&&e[r+u+1]!==void 0&&e[r+u+1]!=="]"){let l=r+u+1,f=e[l]==="["?e[l+1]:void 0;if(f===":"||f==="=")throw new Error("Invalid range end");let c=f==="."?e.indexOf(".]",l+2):-1;if(f==="."&&c===-1)throw new Error("Unmatched [, [^, [:, [., or [=");let d=f==="."?l+2:l+(e[l]==="\\"?1:0);if(n&&(e.codePointAt(r+u-1)>127||e.codePointAt(d)>127))throw new Error("Invalid collation character");r=c===-1?l+(e[l]==="\\"?2:1):c+2,i=!0;continue}r+=u,i=!1}throw new Error("Unmatched [, [^, [:, [., or [=")}function Kt(e,t,n={}){let r=/^\[:([a-z]+):\]/u.exec(e.slice(t));if(!r)return null;let o=n.classes?n.classes.body(r[1]):It[r[1]];if(o===void 0){if(n?.unknown!=="empty")throw new Error(`invalid character class \`[:${r[1]}:]\``);return{body:"",end:t+r[0].length}}return{body:o,end:t+r[0].length}}var _r={alpha:"1t:p,6:p,1b:0,a:0,4:0,5:m,1:u,1:cp,4:b,e:4,7:0,1:0,2e:0,16:4,1:1,2:3,1:0,6:0,1:2,1:0,1:j,1:2a,1:3u,8:4l,1:11,2:0,6:14,13:d,1:0,1:1,1:1,1:0,8:q,4:3,t:a,5:1j,1:g,4:2t,1:7,4:7,4:f,2:0,g:1b,d:2s,e:16,9:1,4:0,5:n,2:i,j:o,7:a,5:n,1:5,h:15,a:b,3:6,6:23,1:f,1:2,4:e,2:9,1:i,1:7,2:1,2:l,1:6,1:0,3:3,3:7,2:1,2:1,1:0,8:0,4:1,1:4,2:b,a:0,4:2,1:5,4:1,2:l,1:6,1:1,1:1,1:1,4:4,4:1,2:1,4:0,7:3,1:0,7:f,b:2,1:8,1:2,1:l,1:6,1:1,1:4,3:8,1:2,1:1,3:0,f:3,2:9,9:3,4:2,1:7,2:1,2:l,1:6,1:1,1:4,3:7,2:1,2:1,9:1,4:1,1:4,2:9,1:0,g:1,1:5,3:2,1:3,3:1,1:0,1:1,3:1,3:2,3:b,4:4,3:2,1:2,3:0,6:0,e:9,g:c,1:2,1:m,1:f,3:7,1:2,1:2,8:1,1:2,2:0,2:3,2:9,g:3,1:7,1:2,1:m,1:9,1:4,3:7,1:2,1:2,8:1,6:1,1:3,2:9,1:2,c:c,1:2,1:14,2:7,1:2,1:2,1:0,5:3,7:4,2:9,a:5,1:2,1:h,3:n,1:8,1:0,2:6,8:5,1:0,1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:8:-8:1,694:8:-8:1,69k:2:-8:1,69m:2:-22:1,69o:1:-9:1,6a0:4:-2e:1,6a4:1:-9:1,6ag:2:-8:1,6ai:2:-2s:1,6aw:2:-8:1,6ay:2:-34:1,6b0:1:-7:1,6bc:2:-3k:1,6be:2:-3i:1,6bg:1:-9:1,6jq:1:-5st:1,6ju:1:-6gv:1,6jv:1:-6di:1,6k2:1:s:1,6lc:g:g:1,6mb:1:1:1,792:q:q:1,8ow:1c:1c:1,8rk:1:1:1,8rm:1:-8af:1,8rn:1:-2xy:1,8ro:1:-89z:1,8rr:3:1:2,8rx:1:-8bg:1,8ry:1:-8al:1,8rz:1:-8bj:1,8s0:1:-8bi:1,8s2:1:1:1,8s5:1:1:1,8se:2:-8cf:1,8sg:1e:1:2,8vf:2:1:2,8vm:1:1:1,wu8:n:1:2,ww0:e:1:2,x0i:7:1:2,x0y:v:1:2,x2x:2:1:2,x31:1:-r9g:1,x32:5:1:2,x3f:1:1:1,x3h:1:-wmg:1,x3k:2:1:2,x3q:a:1:2,x4a:1:-wn8:1,x4b:1:-wnj:1,x4c:1:-wnf:1,x4d:1:-wn5:1,x4e:1:-wn8:1,x4g:1:-wlu:1,x4h:1:-wmi:1,x4i:1:-wlx:1,x4j:1:ps:1,x4k:8:1:2,x50:1:-1c:1,x51:1:-wn7:1,x52:1:-raw:1,x53:2:1:2,x5c:1:1:1,x5i:2:1:2,x6d:1:1:1,1ee9:q:w:1,1fcw:14:14:1,1fhs:10:14:1,1fn4:b:13:1,1fng:f:13:1,1fnw:7:13:1,1fo4:2:13:1,1h1c:1f:1s:1,1jfk:w:w:1,20cg:w:w:1,2olc:y:y:1";var ee="C.UTF-8",Rr="only the C.UTF-8 locale is supported",bi=e=>typeof e=="string"&&/^C\.UTF-?8$/iu.test(e),Gm=new Set(["LANG","LC_ALL","LC_CTYPE"]);function Wa(e){if(e.locale===void 0||bi(e.locale))return ee;throw new TypeError(`createTerminal: ${Rr} (got ${JSON.stringify(e.locale)})`)}function qa(e,t){if(!(Gm.has(e)?bi(t)||e!=="LANG"&&t==="":bi(t)||t==="C"||t==="POSIX"||t===""))throw new y("feature",e,`${e}: ${Rr}`)}var Mr=e=>e==="C"||e==="POSIX",le=e=>Mr(e.locale);function Ua(e){let t=[],n=-1;for(let r of e.split(",")){let[o,i]=r.split(":").map(u=>parseInt(u,36)),s=n+1+o;t.push([s,s+i]),n=s+i}return t}function Xm(e){let t=e.findIndex(([n])=>n>95);return[...e.slice(0,t),[95,95],...e.slice(t)]}function wi(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):e<128?"\\x"+e.toString(16).padStart(2,"0"):String.fromCodePoint(e)}var Zm=e=>e.map(([t,n])=>t===n?wi(t):`${wi(t)}-${wi(n)}`).join("");function Ym(e,t){let n=e.length-1,r=0;for(;r<=n;){let o=r+n>>1;if(t<e[o][0])n=o-1;else if(t>e[o][1])r=o+1;else return!0}return!1}var Pr=e=>e==="upper"||e==="lower"?"alpha":e,Vm=[181,305,383,453,456,459,498,837,962,976,977,981,982,1008,1009,1010,1013,7835,8126],Tt=/[\u1C80-\u1C88]/u;function ja(e){let t=new Map;for(let n of e.split(",")){let[r,o,i,s]=n.split(":").map(u=>parseInt(u,36));for(let u=0;u<o;u++)t.set(r+u*s,r+u*s+i)}return t}var za=(e,t)=>({up:e,low:t,folds:new Map});function Km(){let e=new Map,t=new Map;for(let n=97;n<=122;n++)e.set(n,n-32),t.set(n-32,n);return za(e,t)}function Jm(e){let t=[];for(let[n,r]of e.sort((o,i)=>o[0]-i[0])){let o=t.at(-1);o&&n<=o[1]+1?o[1]=Math.max(o[1],r):t.push([n,r])}return t}function Ha(e,t,n,r,o){let i=new Map,s=new Map,u=null,a=c=>(s.has(c)||s.set(c,n(c)),s.get(c)),l=()=>u??=o(),f={name:e,multibyte:t,ranges:a,body(c){return i.has(c)||i.set(c,r(c,a(c))),i.get(c)},has(c,d){let p=a(c);return p!==void 0&&Ym(p,d)},assertions(){if(f.js)return f.js;let c=f.body("space"),d=`[${f.body("word")}]`;return f.js={__proto__:null,"<":`(?<!${d})(?=${d})`,">":`(?<=${d})(?!${d})`,boundary:`(?:(?<!${d})(?=${d})|(?<=${d})(?!${d}))`,inside:`(?:(?<=${d})(?=${d})|(?<!${d})(?!${d}))`,word:d,nonWord:`[^${f.body("word")}]`,space:`[${c}]`,nonSpace:`[^${c}]`},f.js},up:c=>l().up.get(c)??c,low:c=>l().low.get(c)??c,fold(c){let{folds:d}=l(),p=d.get(c);if(p===void 0){let h=f.up(c),m=f.low(h),g=new Set([c,h]);m!==h&&f.up(m)===h&&g.add(m);for(let w of Vm)f.up(w)===h&&g.add(w);p=[...g].sort((w,b)=>w-b),d.set(c,p)}return p},foldRange(c,d){let{up:p}=l(),h=p.get(c)??c,m=p.get(d)??d;if(h>m)return null;let g=[],w=[];for(let[S,I]of p){let M=S>=h&&S<=m;M!==(I>=h&&I<=m)&&(M?g:w).push(S)}let b=[],k=h;for(let S of g.sort((I,M)=>I-M))S>k&&b.push([k,S-1]),k=S+1;return k<=m&&b.push([k,m]),Jm([...b,...w.map(S=>[S,S])])}};return f}var Qm=Ha("C",!1,e=>gi[e],e=>It[e],Km),e0=Ha(ee,!0,e=>e==="word"?Xm(Ua(_r.alnum)):Object.hasOwn(_r,e)?Ua(_r[e]):void 0,(e,t)=>t===void 0?void 0:Zm(t),()=>za(ja(Da),ja(Ba)));function re(e){if(e===ee)return e0;if(Mr(e))return Qm;throw new y("feature","locale",`matching in the ${e} locale is not supported`)}var ue=(1n<<63n)-1n,ot=-ue-1n,it=(1n<<64n)-1n;function P(e,t,n,r){let o=E(e.cwd,n,e.fs,r);return R(e,t,n,o.error),o}function R(e,t,n,r){if(r!=="No such file or directory"||typeof n!="string")return;let o=n.startsWith("/"),i=o?"/":e.cwd,s=n.replace(/^\/+/u,""),u=new Set;for(let f of new Set(["/",e.mount??"/",e.home??"/"])){if(f===i)continue;let c=E(f,s,e.fs);c.error||u.add(c.path)}if(!u.size)return;let a=o?"":` from cwd ${JSON.stringify(e.cwd)}`,l=`${o?"absolute":"relative"} path ${JSON.stringify(n)} was not found${a}`;e.notes?.add(`${t}: ${l}. ${t0(e,u)}`)}function t0(e,t){let n=[...t].sort(j),r=n.map(u=>JSON.stringify(u));if(n.length===1)return`A ${e.fs.isDir(n[0])?"dir":"file"} exists at ${r[0]}.`;let i=n.every(u=>!e.fs.isDir(u)&&e.fs.isFile(u))&&n.some(u=>!e.fs.sameFileContents(n[0],u)),s=`${r.slice(0,-1).join(", ")} and ${r.at(-1)}`;return`${n.length===2?"Both":"All"} of ${s} exist${i?", and they differ in contents":""}.`}function Jt(){let e=new Set;return{add:t=>e.add(t),collect(t,n){for(let r of n)r.startsWith(".")&&e.add(Z(t,r))},emit(t,n,r,o=""){gt(t,{command:n,action:"omitted",noun:["hidden entry","hidden entries"],explanation:r,context:o,paths:e})}}}var Ga=/^(?<command>[^:]+): (?<operand>.+): (?<reason>no such file or directory|not a directory|is a directory)$/iu;function Xa(e,t){for(let n of t.split(`
|
|
4
|
+
`))Ga.test(n)&&e.discarded?.add(n)}function yi(e,t,n){let r=new Map;for(let o of e){if(t.includes(o))continue;let{command:i,operand:s,reason:u}=Ga.exec(o).groups,a=/'([^']*)'$/u.exec(s)?.[1]??s;if([...n].some(f=>f.includes(JSON.stringify(a))))continue;let l=`${i}: ${u}`;r.has(l)||r.set(l,new Set),r.get(l).add(a)}return[...r].map(([o,i])=>`${o}: ${[...i].map(s=>JSON.stringify(s)).join(", ")}.`)}function Za(e,t){return e==="status"?null:{name:t,search:e==="search"}}function Ya(){let e=null,t=0;return{skip(n,r){!t&&n&&(e={...n,exitCode:r}),t++},flush(n){if(t&&e){let r=t===1?"the command":`the ${t} commands`,o=e.search&&e.exitCode===1?" A search that selects no lines exits 1, which is not a failure.":"";n.add(`${e.name}: exited ${e.exitCode}, so ${r} after && did not run.${o}`)}e=null,t=0}}}function gt(e,t){n0(e,t,t.paths.size,t.paths)}function n0(e,{command:t,action:n,noun:r,explanation:o="",context:i=""},s,u){if(!s)return;let a=s<10?": "+[...u].sort(j).map(f=>JSON.stringify(f)).join(", "):"",l=Array.isArray(r)?r[s===1?0:1]:r;e.add(`${t}: ${n} ${s} ${l}${i}${a}.${o?" "+o:""}`)}function he(e,t=`
|
|
5
5
|
`){if(e==="")return[];let n=e.split(t);return n.at(-1)===""&&n.pop(),n}var ge=(e,t=`
|
|
6
6
|
`)=>e.length===0?"":e.join(t)+t;function Ge(e,t=`
|
|
7
|
-
`){let n=[];for(let r=0;r<e.length;){let o=e.indexOf(t,r),i=o<0?e.length:o+t.length;n.push(e.slice(r,i)),r=i}return n}function q(e,t="",n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&rt(e.stdinBytes,Dr(null,e)),e.stdinLeft=t,e.stdinBytes=r}function st(e,t,n,r="",o={}){let i=[],s="",u=r,a=o.read??"text",l=a==="bytes"||a==="loose-bytes",f=l?"bytes":"content",c=p=>l?a==="loose-bytes"?A(p):B(p):p,d=(p,h)=>{if(l){p.bytes=Be(n.fs,h,a==="loose-bytes");return}if(a==="text"||n.fs.isBytes?.(h)!==!0){p.content=n.fs.readFile(h);return}p.bytes=n.fs.readBytes(h),p.content=a==="maybe-text"?me(p.bytes):void 0};for(let p of t){let h={name:p,[f]:c(""),kind:"file"},m;if(p==="/dev/stdin"&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),h[f]=c(n.stdinOrigin);else if(p==="-"||p==="/dev/stdin"){let g=u===r?n.stdinBytes??null:null;Object.assign(h,g===null?Va(u,a,l):Ka(g,a,l,e,n)),h.shared=!0,u="",q(n,"",!0)}else if(p!=="/dev/null"){let g=P(n,e,p);g.error?(h.kind="missing",m=g.error):n.fs.isDir(g.path)?(h.kind="dir",o.noRead||(m="Is a directory")):d(h,g.path)}if(i.push(h),m&&(s+=
|
|
8
|
-
`}function Be(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let o=e.readFile(t);if(o!==void 0)return n?A(o):B(o)}function wt(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:me(n),bytes:n}}function te(e,t,n,r,o){if(t.length===0){let i=r.stdinBytes??null;q(r,"",!0);let s=o?.read,u=s==="bytes"||s==="loose-bytes",a=[{name:null,kind:"file",...i===null?Va(n,s,u):Ka(i,s,u,e,r)}];return{inputs:a,entries:a,stderr:"",failed:!1}}return st(e,t,r,n,o)}var Va=(e,t,n)=>n?{bytes:t==="loose-bytes"?A(e):B(e)}:{content:e};function Ka(e,t,n,r,o){return n||t==="as-held"?{bytes:e}:t==="maybe-text"?{bytes:e,content:me(e)}:{content:rt(e,Dr(null,o))}}function Dr(e,t){return e===null||e==="-"||e==="/dev/stdin"?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):"standard input":JSON.stringify(E(t.cwd,e,t.fs).path??e)}function Ja(e,t,n,r){let o=te(e,t,n,r);return{content:o.inputs.map(i=>i.content).join(""),stderr:o.stderr,failed:o.failed}}var ne=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:t.failed?1:0});function be(e,t,n=e,{max:r=1/0,digitsOnly:o=!1}={}){if(typeof e!="string"||!(o?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:x(`${t}: invalid count: ${n}`)};let i=Number(e);return i>r?{error:x(`${t}: out of range: ${n}`)}:{value:Math.min(i,Number.MAX_SAFE_INTEGER)}}function Qa(e,t){if(typeof e!="string")return{error:x(`${t}: invalid count: ${e}`)};let n=e[0]==="+"||e[0]==="-"?e[0]:"",r=n==="-"?e.slice(1):e,o=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),i=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!o&&!i)return{error:x(`${t}: invalid count: ${e}`)};let s=o?.[2]??(i?r:""),u=xi(BigInt(o?.[1]??"1"),s,t,e);return u.error?u:{...u,sign:n}}function xi(e,t,n,r){let o=1n;t==="b"?o=512n:t&&(o=(t.length===2?1000n:1024n)**BigInt("KMGTPEZYRQ".indexOf(t[0].toUpperCase())+1));let i=e*o;return i>it?{error:x(`${n}: count out of range: ${r}`)}:{value:Number(i>BigInt(Number.MAX_SAFE_INTEGER)?BigInt(Number.MAX_SAFE_INTEGER):i)}}function V(e){try{let t=e?.message;return typeof t=="string"&&t!==""?t:String(e)}catch{return"threw a value with no message"}}var ut=e=>e==="/tmp"||e.startsWith("/tmp/");function el(e){let t=new Map,n=new Map,r=new Set(["/tmp"]),o,i=e.listDir("/"),s={dirs:[...i.dirs,"tmp"].sort(j),files:i.files,links:i.links??[]},u=f0(r,t,n),a=u.reshaped,l=(c,d)=>{if(!c.startsWith("/tmp/"))throw new Error("writable overlay paths must start with /tmp/");t.has(c)||a(),n.delete(c),t.set(c,d)},f={observeIo:c=>{o=c},fileIdentity:c=>t.get(c),fileSize:c=>t.get(c)?.bytes.length??(n.has(c)?B(n.get(c)).length:e.fileSize(c)),readIdentity:c=>(o?.read(c),W(c.bytes)),isFile:c=>t.has(c)||e.isFile(c),isDir:c=>r.has(c)||e.isDir(c),isLink:c=>n.has(c)||e.isLink?.(c)===!0,readLink:c=>n.get(c)??e.readLink?.(c),...i0(e,t,c=>o?.read(c)),sameFileContents:(c,d)=>c0(e,t,c,d),listDir:c=>c==="/"?s:r.has(c)?u.of(c):e.listDir(c),*walkFiles(c){for(let d of Fe(f,c))d.kind==="file"&&(yield d.path)},openWritable(c,d,p=!1){let h=se(f,c,d);if(h!=="/tmp"&&!h.startsWith("/tmp/"))return null;Cn(f,c,d);let m=t.get(h);return m?p||(o?.write(m),m.bytes=new Uint8Array):(m={bytes:new Uint8Array},l(h,m)),p0(h,m,p,()=>o?.write(m))},makeWritableDir:(c,d)=>s0(f,{dirs:r,files:t,links:n,reshaped:a},c,d),makeWritableLink:(c,d,p)=>u0(f,{links:n,reshaped:a},c,d,p),removeWritableDir:(c,d)=>l0(f,{dirs:r,reshaped:a},c,d),copyWritable(c,d,p){let h=se(f,c,p);if(!h.startsWith("/tmp/"))return!1;Cn(f,c,p);let m=t.get(d);if(d===h||m&&m===t.get(h))throw new Error("source and destination are the same file");o?.read(m??d);let g=m?m.bytes:Be(e,d);return f.openWritable(c,p).writeBytes(g),!0},replaceWritable:(c,d,p,h)=>a0(f,{files:t,links:n,put:l},c,d,p,h),removeWritable(c,d){let p=se(f,c,d,!1);if(p!=="/tmp"&&!p.startsWith("/tmp/"))return!1;let h=E(c,d,f,{follow:!1});if(h.error)throw Xe(d,h.error);if(f.isDir(h.path))throw new Error(`${d}: Is a directory`);return n.delete(h.path)||t.delete(h.path),a(),!0}};return f}function i0(e,t,n){return{readFile:r=>{let o=t.get(r);return n(o??r),o?rt(o.bytes,JSON.stringify(r)):e.readFile(r)},readBytes:(r,o=!1)=>{let i=t.get(r);return n(i??r),i?i.bytes:Be(e,r,o)},exactBytes:r=>t.get(r)?.bytes??e.exactBytes(r),isEmptyFile:r=>{let o=t.get(r);return o?o.bytes.length===0:e.isEmptyFile(r)},isBytes:r=>t.has(r)||e.isBytes?.(r)===!0}}function s0(e,t,n,r){let o=se(e,n,r,!1);if(o!=="/tmp"&&!o.startsWith("/tmp/"))return!1;if(t.dirs.has(o))return!0;if(Cn(e,n,r),t.files.has(o)||t.links.has(o))throw new Error(`${r}: File exists`);return t.dirs.add(o),t.reshaped(),!0}function u0(e,t,n,r,o){let i=se(e,n,r,!1);return i.startsWith("/tmp/")?(d0(e,n,r),t.links.set(i,o),t.reshaped(),!0):!1}function a0(e,t,n,r,o,i){let s=se(e,n,r,!1),u=i===void 0?null:se(e,n,i,!1);if(!s.startsWith("/tmp/")||u!==null&&!u.startsWith("/tmp/"))return!1;Cn(e,n,r);let a=t.files.get(s),l=t.links.get(s);if(!a&&l===void 0)throw Xe(r,"No such file or directory");u!==null&&Cn(e,n,i);let f={bytes:B(o)};return l===void 0?u!==null&&t.put(u,a):(t.links.delete(s),u!==null&&(t.links.set(u,l),t.files.delete(u))),t.put(s,f),!0}function l0(e,t,n,r){let o=se(e,n,r,!1);if(o!=="/tmp"&&!o.startsWith("/tmp/"))return!1;let i=E(n,r,e);if(i.error)throw Xe(r,i.error);if(!t.dirs.has(i.path))throw new Error(`${r}: Not a directory`);if(i.path==="/tmp")throw new Error(`${r}: Device or resource busy`);let{dirs:s,files:u,links:a}=e.listDir(i.path);if(s.length||u.length||a.length)throw new Error(`${r}: Directory not empty`);return t.dirs.delete(i.path),t.reshaped(),!0}function f0(e,t,n){let r=new Map,o=(i,s)=>[...i].filter(u=>u.startsWith(s)&&!u.slice(s.length).includes("/")).map(u=>u.slice(s.length)).sort(j);return{reshaped:()=>{r=new Map},of(i){let s=r.get(i);if(s)return s;let u={dirs:o(e,i+"/"),files:o(t.keys(),i+"/"),links:o(n.keys(),i+"/")};return r.set(i,u),u}}}function c0(e,t,n,r){let o=t.get(n),i=t.get(r);if(!o&&!i)return e.sameFileContents(n,r);let s=(u,a)=>a?a.bytes:e.exactBytes(u);return On(s(n,o),s(r,i))}function Cn(e,t,n){let r=ze(t,n,e);if(r.error===null){if(e.isDir(r.path))throw new Error(`${n}: Is a directory`);if(n.endsWith("/"))throw Xe(n,"Not a directory");return}if(r.rest.length>0||n.endsWith("/")||n.includes("\0"))throw Xe(n,r.error);if(!e.isDir(ye(r.path)))throw Xe(n,"No such file or directory")}function d0(e,t,n){if(n===""||n.includes("\0"))throw Xe(n,"No such file or directory");let r=ze(t,n,e,{follow:!1});if(r.error===null)throw Xe(n,"File exists");if(r.rest.length>0||n.endsWith("/"))throw Xe(n,r.error);if(!e.isDir(ye(r.path)))throw Xe(n,"Not a directory")}function Xe(e,t){return Object.assign(new Error(`${e}: ${t}`),{path:e,fsError:t})}function p0(e,t,n,r){let o=0,i=s=>{let u=t.bytes,a=n?u.length:o,l=Math.max(u.length,a+s.length),f=u.buffer;f.byteLength<l&&(f=new ArrayBuffer(Math.max(l,f.byteLength*2)),new Uint8Array(f).set(u));let c=new Uint8Array(f,0,l);c.set(s,a),t.bytes=c,o=a+s.length};return{path:e,identity:t,get position(){return n?t.bytes.length:o},write(s){s!==""&&(r(),i(B(s)))},writeBytes(s){s.length!==0&&(r(),i(s))}}}var tl=["cwd","home","user","inherit"];function nl(e,t){let n=In(t,"mount","/"),r=In(t,"home",n),o=In(t,"cwd",n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!=="/tmp/")throw new TypeError("createTerminal: writable must be '/tmp/', false, or undefined");let i=t.writable==="/tmp/";if(i&&(n==="/"||n==="/tmp"||n.startsWith("/tmp/")))throw new Error("createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'");let s=Ra(e,n);return{fs:i?el(s):s,cwd:o,home:r,mount:n,writable:i,locale:Wa(t)}}function rl(e,t){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`fork: options must be an object (got ${t===null?"null":Array.isArray(t)?"an array":typeof t})`);for(let n of Object.keys(t))if(!tl.includes(n))throw new Error(`fork: unknown option \`${n}\` (known: ${tl.join(", ")}; the sources, the mount, the /tmp/ overlay and the commands come from the parent)`);if(t.inherit!==void 0&&typeof t.inherit!="boolean")throw new TypeError(`fork: inherit must be true or false (got ${t.inherit===null?"null":typeof t.inherit})`);return{cwd:In(t,"cwd",e.cwd,"fork",e.cwd),home:In(t,"home",e.home,"fork",e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function In(e,t,n,r="createTerminal",o="/"){let i=e[t]===void 0?n:e[t];if(typeof i!="string"||i.includes("\0"))throw new TypeError(`${r}: ${t} must be a string without NUL characters`);return Z(o,i)}function xe(e,t=0,n=e.value.length){return{value:e.value.slice(t,n),mask:e.mask===null?null:e.mask.slice(t,n),...e.empty?{empty:e.empty.filter(r=>r>=t&&r<=n).map(r=>r-t)}:{}}}function Tn(e){let t=/^([A-Za-z_][A-Za-z0-9_]*)=/u.exec(e.value);return!t||e.mask!==null&&/[12]/u.test(e.mask.slice(0,t[0].length))||e.empty?.some(n=>n<t[0].length)?null:{name:t[1],end:t[0].length}}var ol=(e,t)=>e.mask===null?"0":e.mask[t];function il(e,t=!1){let n=new Set;if(!e.value.includes("~"))return n;let r=e.value,o=u=>ol(e,u)==="0",i=t?null:Tn(e)?.end??null,s=u=>t===!0||i!==null&&u>=i;for(let u=0;u<r.length;u++){let a=u===0||u===i||s(u)&&r[u-1]===":"&&o(u-1),l=s(u)||t==="parameterAssign";if(!a||r[u]!=="~"||!o(u)||!h0(e,u,l))continue;let f=r[u+1];if(f&&f!=="/"&&f!==":"&&o(u+1))throw new b("feature","tilde prefix","named-user and directory-stack tilde prefixes are not supported");(f===void 0||o(u+1)&&(f==="/"||f===":"&&l))&&n.add(u)}return n}function h0(e,t,n){for(let r=t;r<=e.value.length;r++){if(e.empty?.includes(r))return!1;if(r===e.value.length)return!0;if(ol(e,r)!=="0")return!1;if(e.value[r]==="/"||n&&e.value[r]===":")return!0}return!0}function sl(...e){let t="",n="",r=[];for(let o of e){for(let i of o.empty??[])r.push(t.length+i);t+=o.value,n+=o.mask??"0".repeat(o.value.length)}return{value:t,mask:e.every(o=>o.mask===null)?null:n,...r.length?{empty:r}:{}}}var Qt=64;function at(e,t){let n="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(o!=="\\"){n+=o;continue}let i=e[r+1];if(i==="`")throw new b("feature","\\`","nested backtick command substitution is not supported; use `$( )` instead");if(i==="$"||i==="\\"){n+=i,r++;continue}if(i===`
|
|
9
|
-
`){r++;continue}n+=o}throw new Error("unterminated backtick substitution")}var ul=()=>({value:"",quoted:!1,started:!1}),al=()=>new
|
|
7
|
+
`){let n=[];for(let r=0;r<e.length;){let o=e.indexOf(t,r),i=o<0?e.length:o+t.length;n.push(e.slice(r,i)),r=i}return n}function q(e,t="",n=!1,r=null){e.io?.read(e.stdinHandle?.identity),!n&&e.stdinBytes&&rt(e.stdinBytes,Dr(null,e)),e.stdinLeft=t,e.stdinBytes=r}function st(e,t,n,r="",o={}){let i=[],s="",u=r,a=o.read??"text",l=a==="bytes"||a==="loose-bytes",f=l?"bytes":"content",c=p=>l?a==="loose-bytes"?A(p):B(p):p,d=(p,h)=>{if(l){p.bytes=Be(n.fs,h,a==="loose-bytes");return}if(a==="text"||n.fs.isBytes?.(h)!==!0){p.content=n.fs.readFile(h);return}p.bytes=n.fs.readBytes(h),p.content=a==="maybe-text"?me(p.bytes):void 0};for(let p of t){let h={name:p,[f]:c(""),kind:"file"},m;if(p==="/dev/stdin"&&n.stdinFile)n.io?.read(n.stdinHandle?.identity),h[f]=c(n.stdinOrigin);else if(p==="-"||p==="/dev/stdin"){let g=u===r?n.stdinBytes??null:null;Object.assign(h,g===null?Va(u,a,l):Ka(g,a,l,e,n)),h.shared=!0,u="",q(n,"",!0)}else if(p!=="/dev/null"){let g=P(n,e,p);g.error?(h.kind="missing",m=g.error):n.fs.isDir(g.path)?(h.kind="dir",o.noRead||(m="Is a directory")):d(h,g.path)}if(i.push(h),m&&(s+=xi(e,p,m,h.kind==="dir")),h.kind!=="file"&&(o.stopOnError||h.kind==="dir"&&o.stopOnDir))break}return{inputs:i.filter(p=>p.kind==="file"),entries:i,stderr:s,failed:s!==""}}var r0={head:["cannot open '%s' for reading: %r","error reading '%s': Is a directory"],tail:["cannot open '%s' for reading: %r","error reading '%s': Is a directory"],sort:["cannot read: %s: %r","read failed: %s: Is a directory"],sed:["can't read %s: %r","read error on %s: Is a directory"],tac:["failed to open '%s' for reading: %r","%s: read error: Invalid argument"],base32:[null,"read error: Is a directory"],base64:[null,"read error: Is a directory"],uniq:[null,"error reading '%s': Is a directory"]};function xi(e,t,n,r=!1){let o=r0[e]?.[r?1:0],i=o?o.replace(/%[sr]/gu,s=>s==="%s"?t:n):`${t}: ${n}`;return`${e}: ${i}
|
|
8
|
+
`}function Be(e,t,n=!1){let r=e.readBytes?.(t,n);if(r!==void 0)return r;let o=e.readFile(t);if(o!==void 0)return n?A(o):B(o)}function wt(e,t){if(e.isBytes?.(t)!==!0)return{text:e.readFile(t),bytes:void 0};let n=e.readBytes(t);return{text:me(n),bytes:n}}function te(e,t,n,r,o){if(t.length===0){let i=r.stdinBytes??null;q(r,"",!0);let s=o?.read,u=s==="bytes"||s==="loose-bytes",a=[{name:null,kind:"file",...i===null?Va(n,s,u):Ka(i,s,u,e,r)}];return{inputs:a,entries:a,stderr:"",failed:!1}}return st(e,t,r,n,o)}var Va=(e,t,n)=>n?{bytes:t==="loose-bytes"?A(e):B(e)}:{content:e};function Ka(e,t,n,r,o){return n||t==="as-held"?{bytes:e}:t==="maybe-text"?{bytes:e,content:me(e)}:{content:rt(e,Dr(null,o))}}function Dr(e,t){return e===null||e==="-"||e==="/dev/stdin"?t.stdinHandle?.path?JSON.stringify(t.stdinHandle.path):"standard input":JSON.stringify(E(t.cwd,e,t.fs).path??e)}function Ja(e,t,n,r){let o=te(e,t,n,r);return{content:o.inputs.map(i=>i.content).join(""),stderr:o.stderr,failed:o.failed}}var ne=(e,t)=>({stdout:e,stderr:t.stderr,exitCode:t.failed?1:0});function ye(e,t,n=e,{max:r=1/0,digitsOnly:o=!1}={}){if(typeof e!="string"||!(o?/^\d+$/u:/^[ \t\n\r\f\v]*\+?\d+$/u).test(e))return{error:x(`${t}: invalid count: ${n}`)};let i=Number(e);return i>r?{error:x(`${t}: out of range: ${n}`)}:{value:Math.min(i,Number.MAX_SAFE_INTEGER)}}function Qa(e,t){if(typeof e!="string")return{error:x(`${t}: invalid count: ${e}`)};let n=e[0]==="+"||e[0]==="-"?e[0]:"",r=n==="-"?e.slice(1):e,o=/^[ \t\n\r\v\f]*\+?(\d+)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(r),i=!n&&/^(?:b|[kKMGTPEZYRQ](?:i?B)?)$/u.test(r);if(!o&&!i)return{error:x(`${t}: invalid count: ${e}`)};let s=o?.[2]??(i?r:""),u=ki(BigInt(o?.[1]??"1"),s,t,e);return u.error?u:{...u,sign:n}}function ki(e,t,n,r){let o=1n;t==="b"?o=512n:t&&(o=(t.length===2?1000n:1024n)**BigInt("KMGTPEZYRQ".indexOf(t[0].toUpperCase())+1));let i=e*o;return i>it?{error:x(`${n}: count out of range: ${r}`)}:{value:Number(i>BigInt(Number.MAX_SAFE_INTEGER)?BigInt(Number.MAX_SAFE_INTEGER):i)}}function V(e){try{let t=e?.message;return typeof t=="string"&&t!==""?t:String(e)}catch{return"threw a value with no message"}}var ut=e=>e==="/tmp"||e.startsWith("/tmp/");function el(e){let t=new Map,n=new Map,r=new Set(["/tmp"]),o,i=e.listDir("/"),s={dirs:[...i.dirs,"tmp"].sort(j),files:i.files,links:i.links??[]},u=l0(r,t,n),a=u.reshaped,l=(c,d)=>{if(!c.startsWith("/tmp/"))throw new Error("writable overlay paths must start with /tmp/");t.has(c)||a(),n.delete(c),t.set(c,d)},f={observeIo:c=>{o=c},fileIdentity:c=>t.get(c),fileSize:c=>t.get(c)?.bytes.length??(n.has(c)?B(n.get(c)).length:e.fileSize(c)),readIdentity:c=>(o?.read(c),W(c.bytes)),isFile:c=>t.has(c)||e.isFile(c),isDir:c=>r.has(c)||e.isDir(c),isLink:c=>n.has(c)||e.isLink?.(c)===!0,readLink:c=>n.get(c)??e.readLink?.(c),...o0(e,t,c=>o?.read(c)),sameFileContents:(c,d)=>f0(e,t,c,d),listDir:c=>c==="/"?s:r.has(c)?u.of(c):e.listDir(c),*walkFiles(c){for(let d of Fe(f,c))d.kind==="file"&&(yield d.path)},openWritable(c,d,p=!1){let h=se(f,c,d);if(h!=="/tmp"&&!h.startsWith("/tmp/"))return null;Cn(f,c,d);let m=t.get(h);return m?p||(o?.write(m),m.bytes=new Uint8Array):(m={bytes:new Uint8Array},l(h,m)),d0(h,m,p,()=>o?.write(m))},makeWritableDir:(c,d)=>i0(f,{dirs:r,files:t,links:n,reshaped:a},c,d),makeWritableLink:(c,d,p)=>s0(f,{links:n,reshaped:a},c,d,p),removeWritableDir:(c,d)=>a0(f,{dirs:r,reshaped:a},c,d),copyWritable(c,d,p){let h=se(f,c,p);if(!h.startsWith("/tmp/"))return!1;Cn(f,c,p);let m=t.get(d);if(d===h||m&&m===t.get(h))throw new Error("source and destination are the same file");o?.read(m??d);let g=m?m.bytes:Be(e,d);return f.openWritable(c,p).writeBytes(g),!0},replaceWritable:(c,d,p,h)=>u0(f,{files:t,links:n,put:l},c,d,p,h),removeWritable(c,d){let p=se(f,c,d,!1);if(p!=="/tmp"&&!p.startsWith("/tmp/"))return!1;let h=E(c,d,f,{follow:!1});if(h.error)throw Xe(d,h.error);if(f.isDir(h.path))throw new Error(`${d}: Is a directory`);return n.delete(h.path)||t.delete(h.path),a(),!0}};return f}function o0(e,t,n){return{readFile:r=>{let o=t.get(r);return n(o??r),o?rt(o.bytes,JSON.stringify(r)):e.readFile(r)},readBytes:(r,o=!1)=>{let i=t.get(r);return n(i??r),i?i.bytes:Be(e,r,o)},exactBytes:r=>t.get(r)?.bytes??e.exactBytes(r),isEmptyFile:r=>{let o=t.get(r);return o?o.bytes.length===0:e.isEmptyFile(r)},isBytes:r=>t.has(r)||e.isBytes?.(r)===!0}}function i0(e,t,n,r){let o=se(e,n,r,!1);if(o!=="/tmp"&&!o.startsWith("/tmp/"))return!1;if(t.dirs.has(o))return!0;if(Cn(e,n,r),t.files.has(o)||t.links.has(o))throw new Error(`${r}: File exists`);return t.dirs.add(o),t.reshaped(),!0}function s0(e,t,n,r,o){let i=se(e,n,r,!1);return i.startsWith("/tmp/")?(c0(e,n,r),t.links.set(i,o),t.reshaped(),!0):!1}function u0(e,t,n,r,o,i){let s=se(e,n,r,!1),u=i===void 0?null:se(e,n,i,!1);if(!s.startsWith("/tmp/")||u!==null&&!u.startsWith("/tmp/"))return!1;Cn(e,n,r);let a=t.files.get(s),l=t.links.get(s);if(!a&&l===void 0)throw Xe(r,"No such file or directory");u!==null&&Cn(e,n,i);let f={bytes:B(o)};return l===void 0?u!==null&&t.put(u,a):(t.links.delete(s),u!==null&&(t.links.set(u,l),t.files.delete(u))),t.put(s,f),!0}function a0(e,t,n,r){let o=se(e,n,r,!1);if(o!=="/tmp"&&!o.startsWith("/tmp/"))return!1;let i=E(n,r,e);if(i.error)throw Xe(r,i.error);if(!t.dirs.has(i.path))throw new Error(`${r}: Not a directory`);if(i.path==="/tmp")throw new Error(`${r}: Device or resource busy`);let{dirs:s,files:u,links:a}=e.listDir(i.path);if(s.length||u.length||a.length)throw new Error(`${r}: Directory not empty`);return t.dirs.delete(i.path),t.reshaped(),!0}function l0(e,t,n){let r=new Map,o=(i,s)=>[...i].filter(u=>u.startsWith(s)&&!u.slice(s.length).includes("/")).map(u=>u.slice(s.length)).sort(j);return{reshaped:()=>{r=new Map},of(i){let s=r.get(i);if(s)return s;let u={dirs:o(e,i+"/"),files:o(t.keys(),i+"/"),links:o(n.keys(),i+"/")};return r.set(i,u),u}}}function f0(e,t,n,r){let o=t.get(n),i=t.get(r);if(!o&&!i)return e.sameFileContents(n,r);let s=(u,a)=>a?a.bytes:e.exactBytes(u);return On(s(n,o),s(r,i))}function Cn(e,t,n){let r=ze(t,n,e);if(r.error===null){if(e.isDir(r.path))throw new Error(`${n}: Is a directory`);if(n.endsWith("/"))throw Xe(n,"Not a directory");return}if(r.rest.length>0||n.endsWith("/")||n.includes("\0"))throw Xe(n,r.error);if(!e.isDir(be(r.path)))throw Xe(n,"No such file or directory")}function c0(e,t,n){if(n===""||n.includes("\0"))throw Xe(n,"No such file or directory");let r=ze(t,n,e,{follow:!1});if(r.error===null)throw Xe(n,"File exists");if(r.rest.length>0||n.endsWith("/"))throw Xe(n,r.error);if(!e.isDir(be(r.path)))throw Xe(n,"Not a directory")}function Xe(e,t){return Object.assign(new Error(`${e}: ${t}`),{path:e,fsError:t})}function d0(e,t,n,r){let o=0,i=s=>{let u=t.bytes,a=n?u.length:o,l=Math.max(u.length,a+s.length),f=u.buffer;f.byteLength<l&&(f=new ArrayBuffer(Math.max(l,f.byteLength*2)),new Uint8Array(f).set(u));let c=new Uint8Array(f,0,l);c.set(s,a),t.bytes=c,o=a+s.length};return{path:e,identity:t,get position(){return n?t.bytes.length:o},write(s){s!==""&&(r(),i(B(s)))},writeBytes(s){s.length!==0&&(r(),i(s))}}}var tl=["cwd","home","user","inherit"];function nl(e,t){let n=In(t,"mount","/"),r=In(t,"home",n),o=In(t,"cwd",n);if(t.writable!==void 0&&t.writable!==!1&&t.writable!=="/tmp/")throw new TypeError("createTerminal: writable must be '/tmp/', false, or undefined");let i=t.writable==="/tmp/";if(i&&(n==="/"||n==="/tmp"||n.startsWith("/tmp/")))throw new Error("createTerminal: mount must not be /, /tmp, or inside /tmp when writable is '/tmp/'");let s=Ra(e,n);return{fs:i?el(s):s,cwd:o,home:r,mount:n,writable:i,locale:Wa(t)}}function rl(e,t){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(`fork: options must be an object (got ${t===null?"null":Array.isArray(t)?"an array":typeof t})`);for(let n of Object.keys(t))if(!tl.includes(n))throw new Error(`fork: unknown option \`${n}\` (known: ${tl.join(", ")}; the sources, the mount, the /tmp/ overlay and the commands come from the parent)`);if(t.inherit!==void 0&&typeof t.inherit!="boolean")throw new TypeError(`fork: inherit must be true or false (got ${t.inherit===null?"null":typeof t.inherit})`);return{cwd:In(t,"cwd",e.cwd,"fork",e.cwd),home:In(t,"home",e.home,"fork",e.cwd),user:t.user??e.user,locale:e.locale,inherit:t.inherit??!0}}function In(e,t,n,r="createTerminal",o="/"){let i=e[t]===void 0?n:e[t];if(typeof i!="string"||i.includes("\0"))throw new TypeError(`${r}: ${t} must be a string without NUL characters`);return Z(o,i)}function xe(e,t=0,n=e.value.length){return{value:e.value.slice(t,n),mask:e.mask===null?null:e.mask.slice(t,n),...e.empty?{empty:e.empty.filter(r=>r>=t&&r<=n).map(r=>r-t)}:{}}}function Tn(e){let t=/^([A-Za-z_][A-Za-z0-9_]*)=/u.exec(e.value);return!t||e.mask!==null&&/[12]/u.test(e.mask.slice(0,t[0].length))||e.empty?.some(n=>n<t[0].length)?null:{name:t[1],end:t[0].length}}var ol=(e,t)=>e.mask===null?"0":e.mask[t];function il(e,t=!1){let n=new Set;if(!e.value.includes("~"))return n;let r=e.value,o=u=>ol(e,u)==="0",i=t?null:Tn(e)?.end??null,s=u=>t===!0||i!==null&&u>=i;for(let u=0;u<r.length;u++){let a=u===0||u===i||s(u)&&r[u-1]===":"&&o(u-1),l=s(u)||t==="parameterAssign";if(!a||r[u]!=="~"||!o(u)||!p0(e,u,l))continue;let f=r[u+1];if(f&&f!=="/"&&f!==":"&&o(u+1))throw new y("feature","tilde prefix","named-user and directory-stack tilde prefixes are not supported");(f===void 0||o(u+1)&&(f==="/"||f===":"&&l))&&n.add(u)}return n}function p0(e,t,n){for(let r=t;r<=e.value.length;r++){if(e.empty?.includes(r))return!1;if(r===e.value.length)return!0;if(ol(e,r)!=="0")return!1;if(e.value[r]==="/"||n&&e.value[r]===":")return!0}return!0}function sl(...e){let t="",n="",r=[];for(let o of e){for(let i of o.empty??[])r.push(t.length+i);t+=o.value,n+=o.mask??"0".repeat(o.value.length)}return{value:t,mask:e.every(o=>o.mask===null)?null:n,...r.length?{empty:r}:{}}}var Qt=64;function at(e,t){let n="";for(let r=t+1;r<e.length;r++){let o=e[r];if(o==="`")return{command:n,raw:e.slice(t,r+1),backtick:!0};if(o!=="\\"){n+=o;continue}let i=e[r+1];if(i==="`")throw new y("feature","\\`","nested backtick command substitution is not supported; use `$( )` instead");if(i==="$"||i==="\\"){n+=i,r++;continue}if(i===`
|
|
9
|
+
`){r++;continue}n+=o}throw new Error("unterminated backtick substitution")}var ul=()=>({value:"",quoted:!1,started:!1}),al=()=>new y("feature","command substitution depth",`command substitution nesting above ${Qt} is not supported`);function vi(e,t,n,r,o){if(r>=Qt)throw al();let i={line:e,i:n+1,depth:r,helpers:o,parens:0,quote:null,word:ul(),command:!0,target:null,heredocs:[]};for(;i.i<e.length;)if(h0(i))return{raw:e.slice(t,i.i+1),command:e.slice(n+1,i.i)};throw i.quote?new Error(`unterminated ${i.quote==="'"?"single":"double"} quote`):new Error("unterminated command substitution")}function bt(e,t,n=!1){e.word.value+=t,e.word.quoted||=n,e.word.started=!0}function Si(e){let t=e.word;if(t.started){if(e.target)e.target.op==="heredoc"&&(e.target.delim=t.value,e.target.quotedDelim=t.quoted),e.target=null;else if(e.command&&!t.quoted){if(t.value==="case")throw new y("feature","case","`case` patterns inside command substitutions are not supported");e.command=["!","{","do","then","else","elif","if","while","until"].includes(t.value)||/^[A-Za-z_][A-Za-z0-9_]*=/u.test(t.value)}else e.command=!1;e.word=ul()}}function h0(e){let{line:t,i:n,quote:r}=e,o=t[n];if(r&&o===r)return e.quote=null,e.word.quoted=!0,e.i++,!1;if(r==="'")return bt(e,o,!0),e.i++,!1;if(o==="\\")return m0(e),!1;if(o==="$")return g0(e),!1;if(o==="`")return w0(e),!1;if(r)return bt(e,o,!0),e.i++,!1;if(o==="'"||o==='"')return e.quote=o,e.word.started=!0,e.i++,!1;if(e.command&&!e.target&&!e.word.started&&t.startsWith("[[",n)&&/[ \t\n()<>;&|]|^$/u.test(t[n+2]??"")){let s=e.helpers.readConditional(t,n,e.helpers,e.depth+e.parens+1);return e.i+=s.raw.length,e.command=!1,!1}if(o==="#"&&!e.word.started){let s=t.indexOf(`
|
|
10
10
|
`,n);return e.i=s===-1?t.length:s,!1}if(o===`
|
|
11
|
-
`)return
|
|
12
|
-
`){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(
|
|
13
|
-
`,"");if(t.startsWith("#")&&t.length>1&&
|
|
14
|
-
`?n+=2:(t--,n++);return n}var
|
|
15
|
-
`;)f+=2;if(e[f]==="'"&&!u){let d=i.decodeAnsiC(e,f+1),p
|
|
16
|
-
`;)a+=2;if(e[a]!==")")throw
|
|
11
|
+
`)return y0(e),!1;if(o===" "||o===" ")return Si(e),e.i++,!1;let i;try{i=e.helpers.readOperator(t,n,!e.word.started)}catch(s){if(!(s instanceof y))throw s;return e.i++,!1}return i?b0(e,i):(bt(e,o),e.i++,!1)}function m0(e){let t=e.line[e.i+1];if(t===`
|
|
12
|
+
`){e.i+=2;return}t!==void 0&&(!e.quote||'$`"\\'.includes(t))?(bt(e,t,!0),e.i+=2):(bt(e,"\\",!!e.quote),e.i++)}function g0(e){let{line:t,i:n}=e,r=e.helpers.skipContinuations(t,n+1);if(!e.quote&&t[r]==="'"){let s=e.helpers.decodeAnsiC(t,r+1);bt(e,s.text,!0),e.i=s.end;return}if(!e.quote&&t[r]==='"'){e.quote='"',e.word.started=!0,e.i=r+1;return}let i=e.helpers.readExpansion(t,n,e.depth+e.parens+1,e.quote==='"')?.raw??"$";bt(e,i,!!e.quote),e.i+=i.length}function w0(e){let t=e.i++;for(;e.i<e.line.length;){let n=e.line[e.i++];if(n==="`"){bt(e,e.line.slice(t,e.i),!!e.quote);return}n==="\\"&&e.i<e.line.length&&e.i++}throw new Error("unterminated backtick substitution")}function b0(e,t){Si(e);let n=t.token;if(n.kind==="paren_close"){if(e.parens===0){if(e.heredocs.length)throw new y("feature","command substitution heredoc","a command substitution heredoc must finish before its closing parenthesis");return!0}e.parens--,e.command=!1}else if(n.kind==="paren_open"){if(e.depth+ ++e.parens>=Qt)throw al();e.command=!0}else n.kind==="redir"?(e.command=!1,n.op==="heredoc"&&e.heredocs.push(n),["dup","close"].includes(n.op)||(e.target=n)):e.command=!0;return e.i=t.end,!1}function y0(e){if(Si(e),e.heredocs.some(t=>t.delim===null))throw new Error("heredoc requires a delimiter");e.heredocs.length&&(e.i=e.helpers.readHeredocBodies(e.line,e.i,e.heredocs),e.heredocs=[]),e.command=!0,e.i++}function Ze(e){return Number.isInteger(e)&&e>=0&&e<=1114111&&(e<55296||e>57343)}var Ue=e=>e>65535?2:1,Le=(e,t)=>Ue(e.codePointAt(t));var x0=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])(?![\s\S])/u,k0=/^(?:[A-Za-z_][A-Za-z0-9_]*|[0-9]+|[?*@#$!-])/u;function Ft(e,t="unsupported or malformed parameter expansion"){return new y("feature","${",`${t}: \${${e}}`)}var Ei=e=>/^[0-9]+$/u.test(e)?e.replace(/^0+(?=[0-9])/u,""):e;function $i(e){let t=e.replaceAll(`\\
|
|
13
|
+
`,"");if(t.startsWith("#")&&t.length>1&&x0.test(t.slice(1)))return{name:Ei(t.slice(1)),operator:"length"};if(/^#[A-Za-z_0-9]/u.test(t))throw Ft(e);let n=k0.exec(t)?.[0];if(!n)throw Ft(e);let r=t.slice(n.length);if(!r)return{name:Ei(n),operator:""};if(n==="#"&&/^[%:=+/]$/u.test(r))throw Ft(e);let o=/^(?::[-+=?]|[-+=?]|##?|%%?|:|\/\/?)/u.exec(r)?.[0];if(!o)throw Ft(e);return{name:Ei(n),operator:o,word:e.slice(v0(e,n.length+o.length))}}function v0(e,t){let n=0;for(;t>0;)e[n]==="\\"&&e[n+1]===`
|
|
14
|
+
`?n+=2:(t--,n++);return n}var yt=(e,t)=>new y("feature",e,t),ll=e=>{if(e>=64)throw yt("expansion depth","shell expansion nesting above 64 levels is not supported")};function fl(e,t,n,r,o,i){ll(r);let s=n+1,u=null;for(let a=s;a<e.length;a++){let l=e[a];if(u==="'"){l==="'"&&(u=null);continue}if(l==="\\"){a++;continue}if(l==='"'){u=u==='"'?null:'"';continue}if(l==="'"&&!u){u="'";continue}if(l==="`")throw yt("`","command substitution (backticks) is not supported");if(l==="$"){let f=a+1;for(;e[f]==="\\"&&e[f+1]===`
|
|
15
|
+
`;)f+=2;if(e[f]==="'"&&!u){let d=i.decodeAnsiC(e,f+1),p=$i(e.slice(s,a)).operator;if(o&&/[-+?=]/u.test(p)&&/[$`"'\\}]/u.test(d.text))throw yt("${","active characters in ANSI-C quoted parameter operands are not supported");a=d.end-1;continue}let c=i.readExpansion(e,a,r+1,o||u==='"');if(c){a+=c.raw.length-1;continue}}if(l==="}"&&!u){let f=$i(e.slice(s,a));return{raw:e.slice(t,a+1),parameter:f}}}throw yt("${","unterminated parameter expansion")}function cl(e,t,n,r,o){ll(r);let i=0;for(let s=n+1;s<e.length;s++){let u=e[s];if(u==="\\"){s++;continue}if(u==="$"){let l=o.readExpansion(e,s,r+1,!0);if(l){s+=l.raw.length-1;continue}}if(u==="`")throw yt("`","command substitution (backticks) is not supported");if(u==='"'||u==="'")throw yt("$((","quotes in arithmetic expressions are not supported");if(u==="("&&i++,u!==")")continue;if(i){i--;continue}let a=s+1;for(;e[a]==="\\"&&e[a+1]===`
|
|
16
|
+
`;)a+=2;if(e[a]!==")")throw yt("$((","arithmetic expansion requires a closing `))`");return{raw:e.slice(t,a+1),arithmetic:e.slice(n+1,s)}}throw yt("$((","unterminated arithmetic expansion")}var S0=/^-[abcdefghknoprstuvwxzGLNORS]$/u,E0=new Set(["=","==","!=","=~","<",">","-eq","-ne","-lt","-le","-gt","-ge","-nt","-ot","-ef"]),$0=new Set(["end","&&","||",")"]),N0=/^[A-Za-z_][A-Za-z0-9_]*$/u;function Fn(e,t,n,r=0){let o={line:e,i:t+2,helpers:n,token:null,depth:0,terms:0,removed:0,expansionDepth:r};try{Ye(o,!0);let i=ml(o);return o.token.kind!=="end"&&xt(`unexpected token \`${o.token.value??o.token.kind}\``),{raw:e.slice(t,o.i+o.removed),expression:i}}catch(i){if(i instanceof y||i.conditional)throw i;xt(i.message)}}function ml(e){let t=dl(e);for(;e.token.kind==="||";)Ye(e,!0),t={kind:"or",left:t,right:dl(e)};return t}function dl(e){let t=Ni(e);for(;e.token.kind==="&&";)Ye(e,!0),t={kind:"and",left:t,right:Ni(e)};return t}function Ni(e){if(++e.terms>128)throw new y("feature","[[ complexity","conditional expressions above 128 terms are not supported");if(++e.depth>64)throw new y("feature","[[ nesting","conditional nesting above 64 levels is not supported");try{let t=e.token;if(t.kind==="("){Ye(e,!0);let o=ml(e);return e.token.kind!==")"&&xt("expected `)`"),Ye(e,!0),o}if(gl(t,"!"))return Ye(e,!0),{kind:"not",expression:Ni(e)};if(t.kind!=="word"&&xt("expected an operand"),Ye(e),!t.quoted&&S0.test(t.value)){let o=pl(e);return Ye(e,!0),{kind:"unary",op:t.value,word:o}}if($0.has(e.token.kind))return{kind:"unary",op:"-n",word:t};let n=e.token;if((n.quoted||!E0.has(n.value))&&xt("conditional binary operator expected"),n.value==="=~")throw new y("feature","[[ =~","regular expression comparisons in [[ are not supported");Ye(e);let r=pl(e);return Ye(e,!0),{kind:"binary",op:n.value,left:t,right:r}}finally{e.depth--}}var gl=(e,t)=>e.kind==="word"&&!e.quoted&&e.value===t,xt=e=>{throw Object.assign(new Error(`[[ ${e}`),{conditional:!0})};function pl(e){return e.token.kind!=="word"&&xt("expected an operand"),e.token}function Ye(e,t=!1){if(e.token=hl(e),t)for(;e.token.kind==="newline";)e.token=hl(e)}function hl(e){for(;e.i<e.line.length;){let t=e.line[e.i];if(t===" "||t===" "){e.i++;continue}if(t==="\\"&&e.line[e.i+1]===`
|
|
17
17
|
`){e.i+=2;continue}if(t==="#"){let o=e.line.indexOf(`
|
|
18
18
|
`,e.i);e.i=o<0?e.line.length:o;continue}if(t===`
|
|
19
|
-
`)return e.i++,{kind:"newline"};let n=e.line.slice(e.i,e.i+2);if(n==="<("||n===">(")throw new
|
|
20
|
-
`){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(_e(t,r,"1"),e.i+=2):(_e(t,"\\",n?"2":"1"),e.i++)}function
|
|
21
|
-
`;)e.line=e.line.slice(0,e.i+1)+e.line.slice(e.i+3),e.removed+=2}function
|
|
22
|
-
`;)t+=2;return t}function
|
|
23
|
-
`,r:"\r",t:" ",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function
|
|
24
|
-
`,r);let l=u===-1?e.length:u;if(a+=e.slice(r,l),r=l+1,o.quotedDelim||u===-1||!
|
|
19
|
+
`)return e.i++,{kind:"newline"};let n=e.line.slice(e.i,e.i+2);if(n==="<("||n===">(")throw new y("feature",n,`process substitution (\`${n}\u2026\`) is not supported`);if(n==="&&"||n==="||")return e.i+=2,{kind:n};if("()<>;&|".includes(t))return e.i++,{kind:t,value:t};let r=A0(e);return gl(r,"]]")?{kind:"end"}:r}xt("missing `]]`")}function A0(e){let t={kind:"word",value:"",mask:"",quoted:!1,empty:[]},n=null,r=0;for(;e.i<e.line.length;){let o=e.line[e.i];if(n&&o===n){t.value.length===r&&t.empty.push(r),t.quoted=!0,n=null,e.i++;continue}if(n==="'"){_e(t,o,"1"),e.i++;continue}if(o==="\\"){O0(e,t,n);continue}if(o==="$"){if(C0(e),!n&&e.line[e.i+1]==='"'){n='"',r=t.value.length,e.i+=2;continue}I0(e,t,n);continue}if(o==="`"){let i=at(e.line,e.i);_e(t,"`",n?"2":"0"),_e(t,i.raw.slice(1),"1"),e.i+=i.raw.length;continue}if(n){_e(t,o,"2"),e.i++;continue}if(o==="'"||o==='"'){n=o,r=t.value.length,e.i++;continue}if(o==="("&&t.mask.at(-1)==="0"&&/[?*+@!]/u.test(t.value.at(-1))&&!t.empty.includes(t.value.length))throw new y("feature","[[ extglob","extended glob patterns in [[ are not supported");if(/[ \t\n()<>;&|]/u.test(o))break;_e(t,o,"0"),e.i++}return n&&xt(`unterminated ${n==="'"?"single":"double"} quote`),!t.quoted&&!/[12]/u.test(t.mask)&&(t.mask=null),t.empty.length===0&&delete t.empty,t}function _e(e,t,n,r=n!=="0"){e.value+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function O0(e,t,n){let r=e.line[e.i+1];if(r===`
|
|
20
|
+
`){e.i+=2;return}r!==void 0&&(!n||'$`"\\'.includes(r))?(_e(t,r,"1"),e.i+=2):(_e(t,"\\",n?"2":"1"),e.i++)}function C0(e){for(;e.line[e.i+1]==="\\"&&e.line[e.i+2]===`
|
|
21
|
+
`;)e.line=e.line.slice(0,e.i+1)+e.line.slice(e.i+3),e.removed+=2}function I0(e,t,n){let r=n?"2":"0";if(!n&&e.line[e.i+1]==="'"){let i=e.helpers.decodeAnsiC(e.line,e.i+2);i.text===""&&t.empty.push(t.value.length),_e(t,i.text,"1"),e.i=i.end;return}let o=e.helpers.readExpansion(e.line,e.i,e.expansionDepth+1,!!n);if(!o){_e(t,"$","1"),e.i++;return}if(o.command!==void 0||o.parameter!==void 0||o.arithmetic!==void 0)_e(t,"$",r),_e(t,o.raw.slice(1),"1",!1);else{let i=e.line[e.i+o.raw.length],s=N0.test(o.name)&&(i==="'"||i==='"')?"${"+o.name+"}":o.raw;_e(t,s,r)}e.i+=o.raw.length}var Lt=/^[A-Za-z_][A-Za-z0-9_]*$/u,T0=/[A-Za-z0-9_]/u,F0=/[?#@*$!0-9-]/u;function ae(e,t){for(;e[t]==="\\"&&e[t+1]===`
|
|
22
|
+
`;)t+=2;return t}function Ai(e,t,n=null){let r=s=>s<e.length&&(n===null||n[s]===n[t]);if(!r(t+1))return null;let o=e[t+1];if(F0.test(o))return{name:o,raw:e.slice(t,t+2)};if(!/[A-Za-z_]/u.test(o))return null;let i=t+2;for(;r(i)&&T0.test(e[i]);)i++;return{name:e.slice(t+1,i),raw:e.slice(t,i)}}function ft(e,t,n=0,r=!1,o={}){let i=(a,l,f,c)=>ft(a,l,f,c,o),s=ae(e,t+1),u=e[s];if(u==="("){let a=ae(e,s+1);if(e[a]==="(")return cl(e,t,a,n,{readExpansion:i});let l=vi(e,t,s,n,{readExpansion:i,decodeAnsiC:en,readHeredocBodies:_n,readOperator:Br,readConditional:Fn,skipContinuations:ae});return o.validateSubstitution?.(l.command),l}if(u==="{")return fl(e,t,s,n,r,{readExpansion:i,decodeAnsiC:en});if(u==="[")throw new y("feature","$[","arithmetic expansion (`$[\u2026]`) is not supported");return Ai(e,t)}function yl(e,t,n={}){let r=(s,u,a,l)=>ft(s,u,a,l,n),o=ae(e,t+1),i=vi(e,t,o,0,{readExpansion:r,decodeAnsiC:en,readHeredocBodies:_n,readOperator:Br,readConditional:Fn,skipContinuations:ae});return n.validateSubstitution?.(i.command),i}var wl={a:"\x07",b:"\b",e:"\x1B",E:"\x1B",f:"\f",n:`
|
|
23
|
+
`,r:"\r",t:" ",v:"\v","\\":"\\","'":"'",'"':'"',"?":"?"};function L0(e,t){for(let n=t;n<e.length;n++)if(e[n]==="\\")n++;else if(e[n]==="'")return n;throw new Error("unterminated single quote")}function en(e,t){let n=L0(e,t),r=[],o=s=>{for(let u of A(s))r.push(u)};for(let s=t;s<n;s++){if(e[s]!=="\\"){let l=String.fromCodePoint(e.codePointAt(s));o(l),s+=l.length-1;continue}let u=e[s+1];if(u in wl){o(wl[u]),s++;continue}if(u==="x"&&e[s+2]==="{")throw new y("feature","ANSI-C hexadecimal escape","braced hexadecimal escapes in ANSI-C quotes are not supported");let a=/^(?:[0-7]{1,3}|x[0-9a-fA-F]{1,2}|u[0-9a-fA-F]{1,4}|U[0-9a-fA-F]{1,8})/u.exec(e.slice(s+1,n));if(a){let l=a[0],f=/^[0-7]/u.test(l),c=f?parseInt(l,8):parseInt(l.slice(1),16);if(f||l[0]==="x")r.push(c&255);else{if(!Ze(c))throw new y("feature","ANSI-C Unicode escape","ANSI-C escapes outside Unicode scalar values are not supported");o(String.fromCodePoint(c))}s+=l.length;continue}if(u==="c"&&s+2<n){let l=e.codePointAt(s+2);if(l>127)throw new y("feature","ANSI-C control escape","ANSI-C control escapes require an ASCII character");r.push(l===63?127:l&31),s+=2,l===92&&e[s+1]==="\\"&&s++;continue}o("\\")}let i=r.indexOf(0);return{text:W(Uint8Array.from(i===-1?r:r.slice(0,i))),end:n+1}}function Br(e,t,n){let r=e[t];if(n&&/[0-9]/u.test(r)){let s="",u=t;for(;/[0-9]/u.test(e[u]??"");)s+=e[u],u=ae(e,u+1);return e[u]!==">"&&e[u]!=="<"||e[ae(e,u+1)]==="("?null:bl(e,u,Number(s))}let o=ae(e,t+1),i=e[o];switch(r){case"|":return i==="|"?lt("or",o+1):i==="&"?lt("pipe_err",o+1):lt("pipe",t+1);case"&":if(i==="&")return lt("and",o+1);if(i===">"){let s=ae(e,o+1),u=e[s]===">";return kt(1,u?"bothAppend":"both",(u?s:o)+1)}return lt("amp",t+1);case";":return i===";"?lt("dsemi",o+1):lt("semi",t+1);case"(":return lt("paren_open",t+1);case")":return lt("paren_close",t+1);case"<":case">":return bl(e,t,r==="<"?0:1);default:return null}}var _0={semi:";",dsemi:";;",pipe:"|",pipe_err:"|&",and:"&&",or:"||",amp:"&",paren_open:"(",paren_close:")"},R0={write:">",append:">>",read:"<",heredoc:"<<",herestring:"<<<",both:"&>",bothAppend:"&>>",dup:">&",close:">&-"};function Ln(e){if(e.kind==="word")return e.quoted?`"${e.value}"`:e.value;if(e.kind==="redir"){let t=R0[e.op];if(e.op==="both"||e.op==="bothAppend")return t;let n=e.fd===(e.op==="read"||e.op==="heredoc"||e.op==="herestring"?0:1)?"":String(e.fd);return e.op==="dup"?`${n}${e.fd===0?"<&":">&"}${e.toFd}`:e.op==="close"?`${n}${e.fd===0?"<&-":">&-"}`:n+t}return _0[e.kind]}var lt=(e,t)=>({token:{kind:e},end:t}),kt=(e,t,n,r)=>({token:{kind:"redir",fd:e,op:t,...r},end:n});function bl(e,t,n){let r=e[t],o=ae(e,t+1),i=e[o];if(i==="&")return M0(e,o,n,r==="<"?"<&":`${n===1&&r===">"?"":n}>&`);if(r==="<"){if(i===">")throw new y("feature","<>","read/write file redirects are not supported");if(i==="<"){let s=ae(e,o+1);if(e[s]==="<")return kt(n,"herestring",s+1);let u=e[s]==="-";return kt(n,"heredoc",(u?s:o)+1,{strip:u,delim:null,body:null})}return kt(n,"read",t+1)}return i===">"?kt(n,"append",o+1):kt(n,"write",(i==="|"?o:t)+1)}function M0(e,t,n,r){let o=ae(e,t+1),i=e[o],s=e[ae(e,o+1)],u=s===void 0||/[ \t\n|&>;()<]/u.test(s);if(/[0-9]/u.test(i??"")&&u)return kt(n,"dup",o+1,{toFd:Number(i)});if(i==="-"&&u)return kt(n,"close",o+1);throw new y("feature","redirect target",`redirect \`${r}\` requires a file descriptor number (or \`-\`) followed by a token boundary`)}function _n(e,t,n){let r=t+1;for(let o of n){let i=[],s=!1;for(;r<e.length;){let u,a="";for(;;){u=e.indexOf(`
|
|
24
|
+
`,r);let l=u===-1?e.length:u;if(a+=e.slice(r,l),r=l+1,o.quotedDelim||u===-1||!P0(a))break;a=a.slice(0,-1)}if(u===-1&&a==="")break;if(o.strip&&(a=a.replace(/^\t+/u,"")),a===o.delim){s=!0;break}if(i.push(a),u===-1)break}o.body=i.length===0?"":i.join(`
|
|
25
25
|
`)+`
|
|
26
26
|
`,s||(o.warning=`warning: here-document delimited by end-of-file (wanted \`${o.delim}')
|
|
27
|
-
`)}return r-1}function
|
|
28
|
-
`){if(
|
|
29
|
-
`){e.i+=2;return}t!==void 0&&(!(e.quote||e.fragmentQuoted)||'$`"\\'.includes(t)||e.fragment&&t==="}")?(fe(e,t,"1"),e.i+=2):(fe(e,"\\",e.quote||e.fragmentQuoted?"2":"1"),e.i++)}function $l(e,t){let n=ae(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function Nl(e){$l(e,e.i+1);let{line:t}=e,n=e.quote==='"'||e.fragmentQuoted?"2":"0",r=t[e.i+1];if((n==="0"||e.fragmentQuoted&&!e.quote)&&r==="'"){let u=en(t,e.i+2);if(e.fragmentQuoted&&/[$`"\\]/u.test(u.text))throw new
|
|
30
|
-
`;)e.i++}function G0(e){Rn(e),e.heredocs.length>0&&(e.i=_n(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!B0.has(t.kind)?e.tokens.push({kind:"semi",newline:!0}):(t?.kind==="semi"||t?.kind==="amp")&&(t.lineEnd=!0),e.i++}function jr(e,t,n){let r={aliases:new Set(t),hasCommand:n};return vt(e,r),r.aliases}var Mn=(e,t)=>new Set([...e,...t]);function vt(e,t){let n=null;for(let r of e){let o=r.gate==="and"||r.gate==="or";if(o&&n!==null&&r.gate==="and"!=(n===0))continue;let i=o&&n===null?new Set(t.aliases):null,s=r.stages.length===1?r.stages[0]:null;n=s&&!s.isolate?X0(s,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=Mn(i,t.aliases),n=null)}return n}function X0(e,t){if(e.group)return vt(e.group,t);if(e.conditional)return Z0(e.conditional,t);if(e.loop){if(e.loop.condition&&vt(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let o=new Set(t.aliases);vt(e.loop.body,t),t.aliases=Mn(o,t.aliases)}return null}let n=e.words[0]?.value;if(e.redirs.length===0&&(n==="true"||n==="false"))return+(n==="false");if(!["alias","unalias"].includes(n)||t.hasCommand(n))return null;let r=e.words.slice(1).map(o=>o.value);for(;r[0]?.startsWith("-")&&r[0]!=="-";){let o=r.shift();if(o==="--")break;if(!(n==="alias"?/^-p+$/u:/^-a+$/u).test(o))return null;if(n==="unalias")return t.aliases.clear(),null}for(let o of r)if(n==="unalias")t.aliases.delete(o);else{let i=o.indexOf("="),s=o.slice(0,i);i>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(s)&&t.aliases.add(s)}return null}function Z0(e,t){let n=new Set;for(let r of e.branches){let o=vt(r.condition,t);if(o===0)return vt(r.body,t),t.aliases=Mn(n,t.aliases),null;if(o===null){let i={...t,aliases:new Set(t.aliases)};vt(r.body,i),n=Mn(n,i.aliases)}}return e.otherwise&&vt(e.otherwise,t),t.aliases=Mn(n,t.aliases),null}var Ve=class extends Error{constructor(t){super(t.message),this.finalError=t}},St=e=>new Ve(new Error(e));function ke(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let n=e.read();e.raw=n.tokens,e.done=n.done}return e.raw[t]}function Ol(e,t,n){let r=t.validation??new Map;return{validateSubstitution(o){r.has(o)||(Ii(o,!0,e,{validation:r,syntaxOnly:!0},n),r.set(o,!0))}}}function Ii(e,t,n,r,o){try{return o(Ur(e,Ol(n,r,o)),t,n,r)}catch(i){throw i instanceof Ve?i.finalError:i}}function Y0(e,t,n,r){let o=kl(e,Ol(n,{},r)),i=new Set,s=!1;return()=>{let u={aliases:i,aliasUsed:s,read:o.read,unit:!0},a=r([],t,n,u);return s=u.aliasUsed,i=jr(a,i,n),o.reset(),{steps:a,done:u.done}}}function*Cl(e,t,n,r){let o=Y0(e,t,n,r);for(;;){let i;try{i=o()}catch(s){throw s instanceof Ve?s.finalError:s}if(i.steps.length>0&&(yield i.steps),i.done)return}}var V0=["elif","else","fi"];function Tl(e,t){let n=[],r;do{Ke(e);let i=t(e,"then");Ke(e);let s=t(e,V0);n.push({condition:i,body:s}),r=e.raw[e.i-1].value}while(r==="elif");let o=null;return r==="else"&&(Ke(e),o=t(e,"fi")),{branches:n,otherwise:o}}function Fl(e,t){let{raw:n}=e,r=e.loop;e.loop="for";let o=ke(e);if(o?.kind==="paren_open")throw new b("feature","for ((","arithmetic `for ((\u2026))` loops are not supported; use `for NAME in WORD...`");if(o===void 0||o.kind!=="word")throw new Error("for: expected a variable name");let i=o.value;if(o.quoted||!Lt.test(i))throw new Error(`for: \`${i}\` is not a valid variable name`);e.i++;let s=ke(e);s?.kind==="semi"&&e.i++;let u=ke(e);if(s?.kind==="semi"&&!s.newline&&tn(u,"in"))throw new Error("for: unexpected `in` after `;`");if(!tn(u,"in")){if(tn(u,"do")||u===void 0){let d=new b("feature","for NAME; do",`\`for ${i}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${i} in WORD...\``);throw u===void 0?new Ve(d):d}throw new Error(`for: expected \`in\` after \`${i}\``)}e.i++;let a=[],l=!1;for(let d;(d=ke(e))&&d.kind!=="semi";e.i++){if(d.kind!=="word")throw new Error(`for: unexpected \`${Ln(d)}\` in word list`);tn(d,"do")&&(l=!0),a.push(xe(d))}n[e.i]?.kind==="semi"&&e.i++;let f=ke(e);if(!tn(f,"do"))throw f===void 0?St(l?"for: expected `;` or newline before `do`":"for: missing `do`"):l?new Error("for: expected `;` or newline before `do`"):new Error(`for: expected \`do\`, got \`${Ln(f)}\``);e.i++,Ke(e);let c={name:i,words:a,body:t(e,"done")};return e.loop=r,c}function Ll(e,t,n){let r=e.loop;e.loop=t,Ke(e);let o=n(e,"do");Ke(e);let i={until:t==="until",condition:o,body:n(e,"done")};return e.loop=r,i}function _l(e,t,n){if(t.quoted||!Lt.test(t.value))throw new b("feature","function",`shell functions named \`${t.value}\` are not supported`);e.i+=2,Ke(e);let r=ke(e);if(!tn(r,"{"))throw new b("feature","function",`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,Ke(e);let o=n(e,"}");if(!_t(o))throw new b("feature","function",`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:o}}var _t=e=>e.every(t=>t.stages.every(K0));function K0(e){return e.assigns.length>0||e.define?!1:e.test?Wr(e.test)&&e.redirs.every(Il):e.group?_t(e.group):e.conditional?e.conditional.branches.every(t=>_t(t.condition)&&_t(t.body))&&_t(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(nn)&&_t(e.loop.condition??[])&&_t(e.loop.body):e.words.every(nn)&&e.redirs.every(Il)}function Wr(e){return e.kind==="and"||e.kind==="or"?Wr(e.left)&&Wr(e.right):e.kind==="not"?Wr(e.expression):e.kind==="unary"?nn(e.word):nn(e.left)&&nn(e.right)}var Il=e=>e.op==="text"?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||nn(e.word);function nn(e){for(let t=0;t<e.value.length;t++){let n=e.value[t];if((n==="$"||n==="`")&&(e.mask===null||e.mask[t]!=="1"))return!1}return!0}function Ke(e){for(let t;(t=ke(e))?.kind==="semi"&&t.newline;)e.i++}function tn(e,t){return e!==void 0&&e.kind==="word"&&!e.quoted&&e.value===t}var Ul=(e,t=!1,n=()=>!1,r={})=>Ii(e,t,n,r,Wl),jl=(e,t=!1,n=()=>!1)=>Cl(e,t,n,Wl);function Wl(e,t,n,r){let o={raw:e,i:0,done:!r.read,read:r.read,unitOnly:r.unit,emptyStage:!1,writable:t,aliases:r.aliases??new Set,aliasUsed:r.aliasUsed??!1,hasCommand:n,syntaxOnly:r.syntaxOnly};try{let i=ke(o)?Rt(o,null):[];if(o.emptyStage)throw new Error("empty pipeline stage");return r.aliasUsed=o.aliasUsed,r.done=o.done,i}catch(i){if(o.aliasUsed&&!(i instanceof b)){let s=new b("feature","alias expansion","alias expansion is not supported; input using aliases cannot be parsed");throw i instanceof Ve?new Ve(s):s}throw i}}function Fi(e,t,n){t.stages.push(n),!qr(n)&&!Li(n)&&(e.emptyStage=!0)}var Li=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,qr=e=>e.group||e.loop||e.conditional||e.test||e.define,Rl=()=>({words:[],assigns:[],redirs:[]}),Ti=e=>({gate:e,stages:[],negate:!1,bang:!1}),Ml=(e,t)=>e.bang&&e.stages.length===0&&rn(t)&&t.redirs.length===0,rn=e=>!qr(e)&&e.words.length===0&&e.assigns.length===0,J0=new Set(["for","while","until","do","done","if","{","}","!"]),Q0=new Set(["then","else","elif","fi","esac","in"]),Pl=new Map([["case","`case` statements are not supported; gate on exit status with `&&` / `||` instead"],["select","`select` loops are not supported"],["function","shell functions are not supported"],["time","`time` is not supported"],["coproc","`coproc` is not supported"]]),eg=new Set(["alias","declare","typeset","local","readonly","export","eval","let"]),tg=new Set(["pipe","pipe_err","and","or","semi","amp"]),Dl=new Set(["semi","amp"]);function Rt(e,t){let{raw:n}=e,r=[Ti("first")];t===null&&(e.unit=r[0]);let o=0,i=Rl();for(let s;s=ke(e);){if(s.kind==="condition"){if(!rn(i))throw new Error("unexpected `[[`");i.test=s.expression,e.i++;continue}if(s.kind==="paren_close"){if(t!==")")throw new Error("unexpected `)`");return e.i++,Bl(e,r,i,t)}if(s.kind==="paren_open"){ng(e,i);continue}if(tg.has(s.kind)){if(s.kind==="pipe_err"&&(Li(i)||qr(i))&&i.redirs.push({fd:2,op:"dup",toFd:1}),s.kind==="semi"&&Ml(r.at(-1),i)||Fi(e,r.at(-1),i),s.kind==="amp"&&(r.at(-1).background=!0),i=Rl(),s.kind==="and"||s.kind==="or"?r.push(Ti(s.kind)):Dl.has(s.kind)&&r.push(Ti("seq")),t===null&&(s.newline||s.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=jr(r.slice(o,-1),e.aliases,e.hasCommand),o=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(s.kind==="dsemi")throw new Error("syntax error near unexpected token `;;`");if(s.kind==="redir"){if(s.warning&&(e.unit.warnings=(e.unit.warnings??"")+s.warning),i.define)throw new b("feature","function",`\`${i.define.name}()\` with a redirect of its own is not supported`);let a=ug(e);a&&i.redirs.push(a);continue}if(i.group||i.define)throw new Error(`unexpected token after \`${i.isolate?")":"}"}\``);if(i.loop)throw new Error("unexpected token after `done`");if(i.conditional)throw new Error("unexpected token after `fi`");if(i.test)throw new Error("unexpected token after `]]`");if(!s.quoted&&i.words.length===0&&e.aliases.has(s.value)&&(e.aliasUsed=!0),!s.quoted&&rn(i)){if(Array.isArray(t)?t.includes(s.value):s.value===t)return e.i++,Bl(e,r,i,t);if(rg(s,e,r.at(-1),i))continue}let u=i.words.length===0?Tn(s):null;u===null?i.words.push(xe(s)):i.assigns.push({name:u.name,word:xe(s,u.end)}),e.i++}if(t===")")throw St("unmatched `(`");if(t==="}")throw St("unmatched `{`");if(t==="do"||t==="done")throw St(`${e.loop}: missing \`${t}\``);if(t)throw St(`if: missing \`${t==="then"?"then":"fi"}\``);if(!e.emptyStage&&!qr(i)&&!Li(i)&&["and","or","pipe","pipe_err"].includes(n.at(-1)?.kind))throw St("empty pipeline stage");return Dl.has(n.at(-1)?.kind)?r.pop():Ml(r.at(-1),i)||Fi(e,r.at(-1),i),r}function ng(e,t){let{raw:n,i:r}=e,o=ke(e,r+1),i=n[r-1],s=t.words[0],u=t.words.at(-1);if(!(n[r-2]?.kind==="redir"&&!["dup","close"].includes(n[r-2].op))&&(t.words.length===0&&t.assigns.length>0||u&&u.value===i?.value&&(t.words.length===1||s.mask===null&&eg.has(s.value)))&&n[r].wordAdjacent&&i?.kind==="word"&&!i.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(i.value))throw new b("feature","array assignment","shell array assignments are not supported");if(o?.kind==="paren_open"&&o.adjacent&&rn(t))throw new b("feature","((","arithmetic evaluation (`((\u2026))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&o?.kind==="paren_close"){t.define=_l(e,t.words.pop(),Rt);return}if(!rn(t))throw new Error("unexpected `(`");e.i++,t.group=Rt(e,")"),t.isolate=!0}function rg(e,t,n,r){let o=e.value;if(Pl.has(o))throw new b("feature",o,Pl.get(o));if(Q0.has(o))throw new Error(`syntax error near unexpected token \`${o}\``);if(!J0.has(o))return!1;if(t.i++,o==="!"){if(n.stages.length>0||r.redirs.length>0)throw new Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(o==="{")return Ke(t),r.group=Rt(t,"}"),r.isolate=!1,!0;if(o==="}")throw new Error("syntax error near unexpected token `}`");if(o==="done")throw new Error("unexpected `done`");if(o==="do")throw new Error("unexpected `do`");return o==="if"?r.conditional=Tl(t,Rt):r.loop=o==="for"?Fl(t,Rt):Ll(t,o,Rt),!0}var og={")":"empty subshell `()`","}":"empty group `{ }`"},ig=(e,t)=>t==="do"?`${e.loop}: empty condition`:t==="done"?`${e.loop}: empty loop body`:t==="then"?"if: empty condition":"if: empty branch body";function Bl(e,t,n,r){let o=t.at(-1),i=rn(n)&&n.redirs.length===0&&o.stages.length===0;if(i&&t.length===1)throw new Error(og[r]??ig(e,r));if(i&&o.bang)throw new Error("syntax error near unexpected token after `!`");return i&&o.gate==="seq"?t.pop():Fi(e,o,n),t}var sg=new Set(["/dev/null","/dev/stdout","/dev/stderr"]);function ug(e){let t=e.raw[e.i++],n=Ln(t);if(e.syntaxOnly){if(!["dup","close"].includes(t.op)){let u=ke(e,e.i++);if(!u||u.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new b("feature",n,`only file descriptors 0, 1 and 2 are supported (got \`${n}\`)`);if(t.op==="dup"){if(t.fd===0&&t.toFd===0)return null;if(t.fd===0||t.toFd===0)throw new b("feature",n,`duplicating file descriptor 0 (\`${n}\`) is not supported`);return{fd:t.fd,op:"dup",toFd:t.toFd}}if(t.op==="close"){if(t.fd===0)throw new b("feature","0<&-","closing standard input is not supported");return{fd:t.fd,op:"close"}}let r=ke(e,e.i++);if(!r||r.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`);if(t.op==="heredoc"||t.op==="herestring"||t.op==="read"){if(t.fd!==0)throw new b("feature",n,`reading into file descriptor ${t.fd} (\`${n}\`) is not supported`);return t.op==="heredoc"?{fd:0,op:"text",body:t.body??"",expand:!t.quotedDelim}:{fd:0,op:t.op,word:xe(r)}}if(t.fd===0)throw new b("feature",n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let o=t.op==="both"||t.op==="bothAppend",i=t.op==="append"||t.op==="bothAppend",s=xe(r);if(ag(s))return{fd:t.fd,op:"to",word:s,both:o,append:i,label:n};if(!e.writable&&!sg.has(s.value))throw _i(n,s.value,e.writable);return{fd:t.fd,op:"to",target:s.value,both:o,append:i,label:n}}function ag(e){for(let t=0;t<e.value.length;t++){let n=e.value[t],r=e.mask===null?"0":e.mask[t];if((n==="$"||n==="`")&&r!=="1"||r==="0"&&(/[~*?[{]/u.test(n)||(n==="<"||n===">")&&e.value[t+1]==="("))return!0}return!1}function _i(e,t,n){let r=n?"only `/tmp/` is writable":"the filesystem is read-only";return new b("feature",e,`\`${e}\` cannot write to \`${t}\`: ${r}`)}var lg=/^[a-zA-Z0-9][\w.+-]*$/u,Ri=["run","pipe","hidden"],Mi=["stdout","stderr","exitCode"];function zl(e,t){let n={__proto__:null},r=[],o=[];for(let[i,s]of fg(e)){let{run:u,pipe:a,hidden:l}=cg(i,s,t);l&&r.includes(i)||(n[i]=(f,c,d)=>dg(i,u,f,c,d),!l&&(r.push(i),a&&o.push(i)))}return{handlers:n,names:r,pipeNames:o}}function fg(e){if(e==null)return[];if(Array.isArray(e))throw new TypeError("createTerminal: opts.commands must be an object or a Map (got an array)");if(typeof e!="object")throw new TypeError(`createTerminal: opts.commands must be an object or a Map (got ${typeof e})`);if(typeof e.entries=="function")return[...e.entries()];let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new TypeError("createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)");return Object.entries(e)}function cg(e,t,n){if(typeof e!="string")throw new TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!lg.test(e))throw new Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw new Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t=="function"){for(let o of Object.keys(t))if(Ri.includes(o))throw new Error(`createTerminal: ${e}: \`${o}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(t===null||typeof t!="object")throw new TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!="function")throw new TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let o of Object.keys(t))if(!Ri.includes(o))throw new Error(`createTerminal: ${e}: unknown option \`${o}\` (known: ${Ri.join(", ")})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function dg(e,t,n,r,o){o.io?.bufferOutput(),q(o);let i={cwd:o.cwd,fs:o.fs,mount:o.mount,home:o.home,get notes(){return o.notes},command:e,stdinFile:o.stdinFile,stdinOrigin:o.stdinOrigin},s=!0,u=()=>{s=!1},a={name:e,args:r,stdin:n,cwd:i.cwd,fs:pg(i),readInputs:(f=[])=>{if(typeof f=="string")throw new TypeError(`readInputs: expected an array of paths, got a string: ${f}`);return te(e,[...f],n,i)},run:f=>{if(!s)throw new Error("run: the command this belongs to has finished, and its turn with it");return o.runLine(f)}},l=t(a);return typeof l?.then!="function"?(u(),ql(l)):l.then(ql).finally(u)}function pg(e){let t=n=>E(e.cwd,n,e.fs).path;return{resolve:n=>Z(e.cwd,n),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:n=>e.fs.isLink?.(E(e.cwd,n,e.fs,{follow:!1}).path)===!0,readLink:n=>e.fs.readLink?.(E(e.cwd,n,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>Be(e.fs,t(n))?.slice(),listDir:n=>{let{path:r,error:o}=P(e,e.command,n);if(!e.fs.isDir(r))throw new Error(`${n}: ${o??"Not a directory"}`);let{dirs:i,files:s,links:u=[]}=e.fs.listDir(r);return{dirs:[...i],files:[...s],links:[...u]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function ql(e){if(e==null)return F();if(typeof e=="string")return F(e);if(typeof e!="object")throw new TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw new TypeError("invalid result: expected a string or an object, got an array (join the lines first)");let t=Object.keys(e);for(let i of t)if(!Mi.includes(i))throw new TypeError(`invalid result: unknown field \`${i}\` (known: ${Mi.join(", ")})`);if(t.length===0)throw new TypeError(`invalid result: an object with none of ${Mi.join(", ")} \u2014 return a string for plain output`);let{stdout:n="",stderr:r="",exitCode:o=0}=e;if(typeof n!="string")throw new TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!="string")throw new TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(o)||o<0)throw new TypeError(`invalid result: exitCode must be a non-negative integer (got ${o})`);return{stdout:n,stderr:r===""||r.endsWith(`
|
|
27
|
+
`)}return r-1}function P0(e){let t=0;for(;t<e.length&&e[e.length-1-t]==="\\";)t++;return t%2===1}var D0=new Set(["semi","amp","and","or","pipe","pipe_err","paren_open"]),B0=e=>e===" "||e===" ";function Ur(e,t={}){return vl(Oi(e,t),!1).tokens}function kl(e,t={}){let n=Oi(e,t);return{read:()=>vl(n,!0),reset:()=>{n.tokens=[]}}}function vl(e,t){for(;e.i<e.line.length;){let n=e.line[e.i];if(e.quote&&n===e.quote){Sl(e),e.i++;continue}if(e.quote==="'"){fe(e,n,"1"),e.i++;continue}if(n==="\\"){El(e);continue}if(n==="$"){Nl(e);continue}if(n==="`"){Al(e);continue}if(e.quote){fe(e,n,"2"),e.i++;continue}if(n==="'"||n==='"'){Ii(e,n),e.i++;continue}let r=e.cur!==""||e.empty.length>0;if(!r&&e.line.startsWith("[[",e.i)&&/[ \t\n()<>;&|]|^$/u.test(e.line[e.i+2]??"")&&W0(e.tokens)){let i=Fn(e.line,e.i,{readExpansion:e.readExpansion,decodeAnsiC:en});xl(e,{kind:"condition",expression:i.expression}),e.i+=i.raw.length;continue}if(n==="#"&&!r){z0(e);continue}if(n===`
|
|
28
|
+
`){if(H0(e),t)return{tokens:e.tokens,done:e.i>=e.line.length};continue}if(B0(n)){Rn(e),e.i++;continue}if(n==="("&&e.mask.at(-1)==="0"&&/[?*+@!]/u.test(e.cur.at(-1))&&!e.empty.includes(e.cur.length))throw new y("feature","extglob","extended glob patterns are not supported");if((n==="<"||n===">")&&e.line[ae(e.line,e.i+1)]==="("){q0(e);continue}let o=Br(e.line,e.i,!r);if(o?.token.kind==="paren_open"&&(o.token.wordAdjacent=r),o){Rn(e),xl(e,o.token),e.i=o.end;continue}fe(e,n,"0"),e.i++}if(e.quote)throw new Error(`unterminated ${e.quote==="'"?"single":"double"} quote`);return Rn(e),e.heredocs.length>0&&_n(e.line,e.line.length,e.heredocs),{tokens:e.tokens,done:!0}}function Oi(e,t={}){return{line:e,i:0,tokens:[],cur:"",mask:"",empty:[],quoted:!1,quoteStart:0,quote:null,heredocs:[],lastParenAt:-2,readExpansion:(n,r,o=0,i=!1)=>ft(n,r,o,i,t),readProcess:(n,r)=>yl(n,r,t)}}function Ci(e,t=!1){let n={...Oi(e),fragment:!0,fragmentQuoted:t};for(;n.i<n.line.length;){let r=n.line[n.i];if(n.quote&&r===n.quote){Sl(n),n.i++;continue}if(n.quote==="'"){fe(n,r,"1"),n.i++;continue}if(r==="\\"){El(n);continue}if(r==="$"){Nl(n);continue}if(r==="`"){Al(n);continue}if(n.quote){fe(n,r,"2"),n.i++;continue}if(r==='"'||r==="'"&&!t){Ii(n,r),n.i++;continue}if(!t&&(r==="<"||r===">")&&n.line[ae(n.line,n.i+1)]==="(")throw new y("feature",`${r}(`,"process substitution in parameter operands is not supported");fe(n,r,t?"2":"0"),n.i++}if(n.quote)throw new y("feature","${","unterminated quote in parameter operand");return Rn(n),n.tokens[0]??{value:"",mask:t?"":null}}var U0=new Set(["semi","and","or","pipe","pipe_err","amp","paren_open"]),j0=new Set(["!","{","if","then","else","elif","while","until","do"]);function W0(e){let t=!0,n=null,r=!1;for(let o of e){let i=U0.has(o.kind)||o.kind==="paren_close"&&n?.kind==="paren_open";if(n=o,i){t=!0,r=!1;continue}if(o.kind==="redir"){t=!1,r=!["dup","close"].includes(o.op);continue}if(r){r=!1;continue}(!t||o.kind!=="word"||o.quoted||!j0.has(o.value))&&(t=!1)}return t&&!r}function Ii(e,t){e.quoteStart=e.cur.length,e.quote=t}function Sl(e){e.cur.length===e.quoteStart&&e.empty.push(e.cur.length),e.quote=null}function fe(e,t,n,r=n!=="0"){e.cur+=t,e.mask+=n.repeat(t.length),e.quoted||=r}function Rn(e){if(e.cur!==""||e.empty.length>0){let t=e.empty.length>0||e.quoted,n={kind:"word",value:e.cur,mask:/[12]/u.test(e.mask)||t?e.mask:null,quoted:t,...e.empty.length?{empty:e.empty}:{}};e.tokens.push(n);let r=e.heredocs.find(o=>o.delim===null);r&&(r.delim=n.value,r.quotedDelim=t)}e.cur="",e.mask="",e.empty=[],e.quoted=!1}function xl(e,t){t.kind==="paren_open"&&(t.adjacent=ae(e.line,e.lastParenAt+1)===e.i,e.lastParenAt=e.i),t.kind==="redir"&&t.op==="heredoc"&&e.heredocs.push(t),e.tokens.push(t)}function El(e){let t=e.line[e.i+1];if(t===`
|
|
29
|
+
`){e.i+=2;return}t!==void 0&&(!(e.quote||e.fragmentQuoted)||'$`"\\'.includes(t)||e.fragment&&t==="}")?(fe(e,t,"1"),e.i+=2):(fe(e,"\\",e.quote||e.fragmentQuoted?"2":"1"),e.i++)}function $l(e,t){let n=ae(e.line,t);n!==t&&(e.line=e.line.slice(0,t)+e.line.slice(n))}function Nl(e){$l(e,e.i+1);let{line:t}=e,n=e.quote==='"'||e.fragmentQuoted?"2":"0",r=t[e.i+1];if((n==="0"||e.fragmentQuoted&&!e.quote)&&r==="'"){let u=en(t,e.i+2);if(e.fragmentQuoted&&/[$`"\\]/u.test(u.text))throw new y("feature","${","active characters in ANSI-C quoted parameter operands are not supported");u.text===""&&e.empty.push(e.cur.length),fe(e,u.text,"1"),e.i=u.end;return}if((n==="0"||e.fragmentQuoted&&!e.quote)&&r==='"'){Ii(e,'"'),e.i+=2;return}let o=e.readExpansion(t,e.i,0,n==="2");if(!o){fe(e,"$","1"),e.i++;return}if(o.command!==void 0||o.parameter!==void 0||o.arithmetic!==void 0){fe(e,"$",n),fe(e,o.raw.slice(1),"1",!1),e.i+=o.raw.length;return}let i=t[e.i+o.raw.length],s=Lt.test(o.name)&&(i==='"'||i==="'")?"${"+o.name+"}":o.raw;fe(e,s,n),e.i+=o.raw.length}function q0(e){$l(e,e.i+1);let{raw:t}=e.readProcess(e.line,e.i);fe(e,e.line[e.i],"0"),fe(e,t.slice(1),"1",!1),e.i+=t.length}function Al(e){let t=e.quote==='"'||e.fragmentQuoted?"2":"0",{raw:n}=at(e.line,e.i);fe(e,"`",t),fe(e,n.slice(1),"1",!1),e.i+=n.length}function z0(e){for(;e.i<e.line.length&&e.line[e.i]!==`
|
|
30
|
+
`;)e.i++}function H0(e){Rn(e),e.heredocs.length>0&&(e.i=_n(e.line,e.i,e.heredocs),e.heredocs=[]);let t=e.tokens.at(-1);t&&!D0.has(t.kind)?e.tokens.push({kind:"semi",newline:!0}):(t?.kind==="semi"||t?.kind==="amp")&&(t.lineEnd=!0),e.i++}function jr(e,t,n){let r={aliases:new Set(t),hasCommand:n};return vt(e,r),r.aliases}var Mn=(e,t)=>new Set([...e,...t]);function vt(e,t){let n=null;for(let r of e){let o=r.gate==="and"||r.gate==="or";if(o&&n!==null&&r.gate==="and"!=(n===0))continue;let i=o&&n===null?new Set(t.aliases):null,s=r.stages.length===1?r.stages[0]:null;n=s&&!s.isolate?G0(s,t):null,r.negate&&n!==null&&(n=+(n===0)),i&&(t.aliases=Mn(i,t.aliases),n=null)}return n}function G0(e,t){if(e.group)return vt(e.group,t);if(e.conditional)return X0(e.conditional,t);if(e.loop){if(e.loop.condition&&vt(e.loop.condition,t),e.loop.words===void 0||e.loop.words.length>0){let o=new Set(t.aliases);vt(e.loop.body,t),t.aliases=Mn(o,t.aliases)}return null}let n=e.words[0]?.value;if(e.redirs.length===0&&(n==="true"||n==="false"))return+(n==="false");if(!["alias","unalias"].includes(n)||t.hasCommand(n))return null;let r=e.words.slice(1).map(o=>o.value);for(;r[0]?.startsWith("-")&&r[0]!=="-";){let o=r.shift();if(o==="--")break;if(!(n==="alias"?/^-p+$/u:/^-a+$/u).test(o))return null;if(n==="unalias")return t.aliases.clear(),null}for(let o of r)if(n==="unalias")t.aliases.delete(o);else{let i=o.indexOf("="),s=o.slice(0,i);i>0&&!/[ \t\n/$`=;'"\\|&()<>]/u.test(s)&&t.aliases.add(s)}return null}function X0(e,t){let n=new Set;for(let r of e.branches){let o=vt(r.condition,t);if(o===0)return vt(r.body,t),t.aliases=Mn(n,t.aliases),null;if(o===null){let i={...t,aliases:new Set(t.aliases)};vt(r.body,i),n=Mn(n,i.aliases)}}return e.otherwise&&vt(e.otherwise,t),t.aliases=Mn(n,t.aliases),null}var Ve=class extends Error{constructor(t){super(t.message),this.finalError=t}},St=e=>new Ve(new Error(e));function ke(e,t=e.i){for(;t>=e.raw.length&&!e.done;){let n=e.read();e.raw=n.tokens,e.done=n.done}return e.raw[t]}function Ol(e,t,n){let r=t.validation??new Map;return{validateSubstitution(o){r.has(o)||(Ti(o,!0,e,{validation:r,syntaxOnly:!0},n),r.set(o,!0))}}}function Ti(e,t,n,r,o){try{return o(Ur(e,Ol(n,r,o)),t,n,r)}catch(i){throw i instanceof Ve?i.finalError:i}}function Z0(e,t,n,r){let o=kl(e,Ol(n,{},r)),i=new Set,s=!1;return()=>{let u={aliases:i,aliasUsed:s,read:o.read,unit:!0},a=r([],t,n,u);return s=u.aliasUsed,i=jr(a,i,n),o.reset(),{steps:a,done:u.done}}}function*Cl(e,t,n,r){let o=Z0(e,t,n,r);for(;;){let i;try{i=o()}catch(s){throw s instanceof Ve?s.finalError:s}if(i.steps.length>0&&(yield i.steps),i.done)return}}var Y0=["elif","else","fi"];function Tl(e,t){let n=[],r;do{Ke(e);let i=t(e,"then");Ke(e);let s=t(e,Y0);n.push({condition:i,body:s}),r=e.raw[e.i-1].value}while(r==="elif");let o=null;return r==="else"&&(Ke(e),o=t(e,"fi")),{branches:n,otherwise:o}}function Fl(e,t){let{raw:n}=e,r=e.loop;e.loop="for";let o=ke(e);if(o?.kind==="paren_open")throw new y("feature","for ((","arithmetic `for ((\u2026))` loops are not supported; use `for NAME in WORD...`");if(o===void 0||o.kind!=="word")throw new Error("for: expected a variable name");let i=o.value;if(o.quoted||!Lt.test(i))throw new Error(`for: \`${i}\` is not a valid variable name`);e.i++;let s=ke(e);s?.kind==="semi"&&e.i++;let u=ke(e);if(s?.kind==="semi"&&!s.newline&&tn(u,"in"))throw new Error("for: unexpected `in` after `;`");if(!tn(u,"in")){if(tn(u,"do")||u===void 0){let d=new y("feature","for NAME; do",`\`for ${i}; do \u2026\` iterates the positional parameters, which this shell does not have; write \`for ${i} in WORD...\``);throw u===void 0?new Ve(d):d}throw new Error(`for: expected \`in\` after \`${i}\``)}e.i++;let a=[],l=!1;for(let d;(d=ke(e))&&d.kind!=="semi";e.i++){if(d.kind!=="word")throw new Error(`for: unexpected \`${Ln(d)}\` in word list`);tn(d,"do")&&(l=!0),a.push(xe(d))}n[e.i]?.kind==="semi"&&e.i++;let f=ke(e);if(!tn(f,"do"))throw f===void 0?St(l?"for: expected `;` or newline before `do`":"for: missing `do`"):l?new Error("for: expected `;` or newline before `do`"):new Error(`for: expected \`do\`, got \`${Ln(f)}\``);e.i++,Ke(e);let c={name:i,words:a,body:t(e,"done")};return e.loop=r,c}function Ll(e,t,n){let r=e.loop;e.loop=t,Ke(e);let o=n(e,"do");Ke(e);let i={until:t==="until",condition:o,body:n(e,"done")};return e.loop=r,i}function _l(e,t,n){if(t.quoted||!Lt.test(t.value))throw new y("feature","function",`shell functions named \`${t.value}\` are not supported`);e.i+=2,Ke(e);let r=ke(e);if(!tn(r,"{"))throw new y("feature","function",`\`${t.value}()\` needs a \`{ \u2026 }\` body`);e.i++,Ke(e);let o=n(e,"}");if(!_t(o))throw new y("feature","function",`\`${t.value}()\` is supported only while its body reads and writes no variable`);return{name:t.value,body:o}}var _t=e=>e.every(t=>t.stages.every(V0));function V0(e){return e.assigns.length>0||e.define?!1:e.test?Wr(e.test)&&e.redirs.every(Il):e.group?_t(e.group):e.conditional?e.conditional.branches.every(t=>_t(t.condition)&&_t(t.body))&&_t(e.conditional.otherwise??[]):e.loop?(e.loop.words??[]).every(nn)&&_t(e.loop.condition??[])&&_t(e.loop.body):e.words.every(nn)&&e.redirs.every(Il)}function Wr(e){return e.kind==="and"||e.kind==="or"?Wr(e.left)&&Wr(e.right):e.kind==="not"?Wr(e.expression):e.kind==="unary"?nn(e.word):nn(e.left)&&nn(e.right)}var Il=e=>e.op==="text"?!e.expand||!/[$`]/u.test(e.body):e.word===void 0||nn(e.word);function nn(e){for(let t=0;t<e.value.length;t++){let n=e.value[t];if((n==="$"||n==="`")&&(e.mask===null||e.mask[t]!=="1"))return!1}return!0}function Ke(e){for(let t;(t=ke(e))?.kind==="semi"&&t.newline;)e.i++}function tn(e,t){return e!==void 0&&e.kind==="word"&&!e.quoted&&e.value===t}var Ul=(e,t=!1,n=()=>!1,r={})=>Ti(e,t,n,r,Wl),jl=(e,t=!1,n=()=>!1)=>Cl(e,t,n,Wl);function Wl(e,t,n,r){let o={raw:e,i:0,done:!r.read,read:r.read,unitOnly:r.unit,emptyStage:!1,writable:t,aliases:r.aliases??new Set,aliasUsed:r.aliasUsed??!1,hasCommand:n,syntaxOnly:r.syntaxOnly};try{let i=ke(o)?Rt(o,null):[];if(o.emptyStage)throw new Error("empty pipeline stage");return r.aliasUsed=o.aliasUsed,r.done=o.done,i}catch(i){if(o.aliasUsed&&!(i instanceof y)){let s=new y("feature","alias expansion","alias expansion is not supported; input using aliases cannot be parsed");throw i instanceof Ve?new Ve(s):s}throw i}}function Li(e,t,n){t.stages.push(n),!qr(n)&&!_i(n)&&(e.emptyStage=!0)}var _i=e=>e.words.length>0||e.assigns.length>0||e.redirs.length>0,qr=e=>e.group||e.loop||e.conditional||e.test||e.define,Rl=()=>({words:[],assigns:[],redirs:[]}),Fi=e=>({gate:e,stages:[],negate:!1,bang:!1}),Ml=(e,t)=>e.bang&&e.stages.length===0&&rn(t)&&t.redirs.length===0,rn=e=>!qr(e)&&e.words.length===0&&e.assigns.length===0,K0=new Set(["for","while","until","do","done","if","{","}","!"]),J0=new Set(["then","else","elif","fi","esac","in"]),Pl=new Map([["case","`case` statements are not supported; gate on exit status with `&&` / `||` instead"],["select","`select` loops are not supported"],["function","shell functions are not supported"],["time","`time` is not supported"],["coproc","`coproc` is not supported"]]),Q0=new Set(["alias","declare","typeset","local","readonly","export","eval","let"]),eg=new Set(["pipe","pipe_err","and","or","semi","amp"]),Dl=new Set(["semi","amp"]);function Rt(e,t){let{raw:n}=e,r=[Fi("first")];t===null&&(e.unit=r[0]);let o=0,i=Rl();for(let s;s=ke(e);){if(s.kind==="condition"){if(!rn(i))throw new Error("unexpected `[[`");i.test=s.expression,e.i++;continue}if(s.kind==="paren_close"){if(t!==")")throw new Error("unexpected `)`");return e.i++,Bl(e,r,i,t)}if(s.kind==="paren_open"){tg(e,i);continue}if(eg.has(s.kind)){if(s.kind==="pipe_err"&&(_i(i)||qr(i))&&i.redirs.push({fd:2,op:"dup",toFd:1}),s.kind==="semi"&&Ml(r.at(-1),i)||Li(e,r.at(-1),i),s.kind==="amp"&&(r.at(-1).background=!0),i=Rl(),s.kind==="and"||s.kind==="or"?r.push(Fi(s.kind)):Dl.has(s.kind)&&r.push(Fi("seq")),t===null&&(s.newline||s.lineEnd)){if(e.unitOnly)return e.i++,r.pop(),r;e.aliases=jr(r.slice(o,-1),e.aliases,e.hasCommand),o=r.length-1,e.unit=r.at(-1)}e.i++;continue}if(s.kind==="dsemi")throw new Error("syntax error near unexpected token `;;`");if(s.kind==="redir"){if(s.warning&&(e.unit.warnings=(e.unit.warnings??"")+s.warning),i.define)throw new y("feature","function",`\`${i.define.name}()\` with a redirect of its own is not supported`);let a=sg(e);a&&i.redirs.push(a);continue}if(i.group||i.define)throw new Error(`unexpected token after \`${i.isolate?")":"}"}\``);if(i.loop)throw new Error("unexpected token after `done`");if(i.conditional)throw new Error("unexpected token after `fi`");if(i.test)throw new Error("unexpected token after `]]`");if(!s.quoted&&i.words.length===0&&e.aliases.has(s.value)&&(e.aliasUsed=!0),!s.quoted&&rn(i)){if(Array.isArray(t)?t.includes(s.value):s.value===t)return e.i++,Bl(e,r,i,t);if(ng(s,e,r.at(-1),i))continue}let u=i.words.length===0?Tn(s):null;u===null?i.words.push(xe(s)):i.assigns.push({name:u.name,word:xe(s,u.end)}),e.i++}if(t===")")throw St("unmatched `(`");if(t==="}")throw St("unmatched `{`");if(t==="do"||t==="done")throw St(`${e.loop}: missing \`${t}\``);if(t)throw St(`if: missing \`${t==="then"?"then":"fi"}\``);if(!e.emptyStage&&!qr(i)&&!_i(i)&&["and","or","pipe","pipe_err"].includes(n.at(-1)?.kind))throw St("empty pipeline stage");return Dl.has(n.at(-1)?.kind)?r.pop():Ml(r.at(-1),i)||Li(e,r.at(-1),i),r}function tg(e,t){let{raw:n,i:r}=e,o=ke(e,r+1),i=n[r-1],s=t.words[0],u=t.words.at(-1);if(!(n[r-2]?.kind==="redir"&&!["dup","close"].includes(n[r-2].op))&&(t.words.length===0&&t.assigns.length>0||u&&u.value===i?.value&&(t.words.length===1||s.mask===null&&Q0.has(s.value)))&&n[r].wordAdjacent&&i?.kind==="word"&&!i.quoted&&/^[A-Za-z_][A-Za-z0-9_]*\+?=$/u.test(i.value))throw new y("feature","array assignment","shell array assignments are not supported");if(o?.kind==="paren_open"&&o.adjacent&&rn(t))throw new y("feature","((","arithmetic evaluation (`((\u2026))`) is not supported");if(t.words.length===1&&t.assigns.length===0&&t.redirs.length===0&&o?.kind==="paren_close"){t.define=_l(e,t.words.pop(),Rt);return}if(!rn(t))throw new Error("unexpected `(`");e.i++,t.group=Rt(e,")"),t.isolate=!0}function ng(e,t,n,r){let o=e.value;if(Pl.has(o))throw new y("feature",o,Pl.get(o));if(J0.has(o))throw new Error(`syntax error near unexpected token \`${o}\``);if(!K0.has(o))return!1;if(t.i++,o==="!"){if(n.stages.length>0||r.redirs.length>0)throw new Error("syntax error near unexpected token `!`");return n.negate=!n.negate,n.bang=!0,!0}if(o==="{")return Ke(t),r.group=Rt(t,"}"),r.isolate=!1,!0;if(o==="}")throw new Error("syntax error near unexpected token `}`");if(o==="done")throw new Error("unexpected `done`");if(o==="do")throw new Error("unexpected `do`");return o==="if"?r.conditional=Tl(t,Rt):r.loop=o==="for"?Fl(t,Rt):Ll(t,o,Rt),!0}var rg={")":"empty subshell `()`","}":"empty group `{ }`"},og=(e,t)=>t==="do"?`${e.loop}: empty condition`:t==="done"?`${e.loop}: empty loop body`:t==="then"?"if: empty condition":"if: empty branch body";function Bl(e,t,n,r){let o=t.at(-1),i=rn(n)&&n.redirs.length===0&&o.stages.length===0;if(i&&t.length===1)throw new Error(rg[r]??og(e,r));if(i&&o.bang)throw new Error("syntax error near unexpected token after `!`");return i&&o.gate==="seq"?t.pop():Li(e,o,n),t}var ig=new Set(["/dev/null","/dev/stdout","/dev/stderr"]);function sg(e){let t=e.raw[e.i++],n=Ln(t);if(e.syntaxOnly){if(!["dup","close"].includes(t.op)){let u=ke(e,e.i++);if(!u||u.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`)}return t}if(t.fd>2)throw new y("feature",n,`only file descriptors 0, 1 and 2 are supported (got \`${n}\`)`);if(t.op==="dup"){if(t.fd===0&&t.toFd===0)return null;if(t.fd===0||t.toFd===0)throw new y("feature",n,`duplicating file descriptor 0 (\`${n}\`) is not supported`);return{fd:t.fd,op:"dup",toFd:t.toFd}}if(t.op==="close"){if(t.fd===0)throw new y("feature","0<&-","closing standard input is not supported");return{fd:t.fd,op:"close"}}let r=ke(e,e.i++);if(!r||r.kind!=="word")throw new Error(`redirect \`${n}\` requires a target`);if(t.op==="heredoc"||t.op==="herestring"||t.op==="read"){if(t.fd!==0)throw new y("feature",n,`reading into file descriptor ${t.fd} (\`${n}\`) is not supported`);return t.op==="heredoc"?{fd:0,op:"text",body:t.body??"",expand:!t.quotedDelim}:{fd:0,op:t.op,word:xe(r)}}if(t.fd===0)throw new y("feature",n,`writing to file descriptor 0 (\`${n}\`) is not supported`);let o=t.op==="both"||t.op==="bothAppend",i=t.op==="append"||t.op==="bothAppend",s=xe(r);if(ug(s))return{fd:t.fd,op:"to",word:s,both:o,append:i,label:n};if(!e.writable&&!ig.has(s.value))throw Ri(n,s.value,e.writable);return{fd:t.fd,op:"to",target:s.value,both:o,append:i,label:n}}function ug(e){for(let t=0;t<e.value.length;t++){let n=e.value[t],r=e.mask===null?"0":e.mask[t];if((n==="$"||n==="`")&&r!=="1"||r==="0"&&(/[~*?[{]/u.test(n)||(n==="<"||n===">")&&e.value[t+1]==="("))return!0}return!1}function Ri(e,t,n){let r=n?"only `/tmp/` is writable":"the filesystem is read-only";return new y("feature",e,`\`${e}\` cannot write to \`${t}\`: ${r}`)}var ag=/^[a-zA-Z0-9][\w.+-]*$/u,Mi=["run","pipe","hidden"],Pi=["stdout","stderr","exitCode"];function zl(e,t){let n={__proto__:null},r=[],o=[];for(let[i,s]of lg(e)){let{run:u,pipe:a,hidden:l}=fg(i,s,t);l&&r.includes(i)||(n[i]=(f,c,d)=>cg(i,u,f,c,d),!l&&(r.push(i),a&&o.push(i)))}return{handlers:n,names:r,pipeNames:o}}function lg(e){if(e==null)return[];if(Array.isArray(e))throw new TypeError("createTerminal: opts.commands must be an object or a Map (got an array)");if(typeof e!="object")throw new TypeError(`createTerminal: opts.commands must be an object or a Map (got ${typeof e})`);if(typeof e.entries=="function")return[...e.entries()];let t=Object.getPrototypeOf(e);if(t!==Object.prototype&&t!==null)throw new TypeError("createTerminal: opts.commands must be a plain object or a Map (own enumerable properties only)");return Object.entries(e)}function fg(e,t,n){if(typeof e!="string")throw new TypeError(`createTerminal: command names must be strings (got ${typeof e})`);if(!ag.test(e))throw new Error(`createTerminal: invalid command name: ${JSON.stringify(e)}`);if(n(e))throw new Error(`createTerminal: ${e}: cannot redefine a built-in command`);if(typeof t=="function"){for(let o of Object.keys(t))if(Mi.includes(o))throw new Error(`createTerminal: ${e}: \`${o}\` belongs on a { run } descriptor, not on the handler function`);return{run:t,pipe:!1,hidden:!1}}if(t===null||typeof t!="object")throw new TypeError(`createTerminal: ${e}: expected a function or a { run } object`);let r=t.run;if(typeof r!="function")throw new TypeError(`createTerminal: ${e}: \`run\` must be a function`);for(let o of Object.keys(t))if(!Mi.includes(o))throw new Error(`createTerminal: ${e}: unknown option \`${o}\` (known: ${Mi.join(", ")})`);return{run:r,pipe:!!t.pipe,hidden:!!t.hidden}}function cg(e,t,n,r,o){o.io?.bufferOutput(),q(o);let i={cwd:o.cwd,fs:o.fs,mount:o.mount,home:o.home,get notes(){return o.notes},command:e,stdinFile:o.stdinFile,stdinOrigin:o.stdinOrigin},s=!0,u=()=>{s=!1},a={name:e,args:r,stdin:n,cwd:i.cwd,fs:dg(i),readInputs:(f=[])=>{if(typeof f=="string")throw new TypeError(`readInputs: expected an array of paths, got a string: ${f}`);return te(e,[...f],n,i)},run:f=>{if(!s)throw new Error("run: the command this belongs to has finished, and its turn with it");return o.runLine(f)}},l=t(a);return typeof l?.then!="function"?(u(),ql(l)):l.then(ql).finally(u)}function dg(e){let t=n=>E(e.cwd,n,e.fs).path;return{resolve:n=>Z(e.cwd,n),isFile:n=>e.fs.isFile(t(n)),isDir:n=>e.fs.isDir(t(n)),isLink:n=>e.fs.isLink?.(E(e.cwd,n,e.fs,{follow:!1}).path)===!0,readLink:n=>e.fs.readLink?.(E(e.cwd,n,e.fs,{follow:!1}).path),readFile:n=>e.fs.readFile(t(n)),isBytes:n=>e.fs.isBytes?.(t(n))===!0,readBytes:n=>Be(e.fs,t(n))?.slice(),listDir:n=>{let{path:r,error:o}=P(e,e.command,n);if(!e.fs.isDir(r))throw new Error(`${n}: ${o??"Not a directory"}`);let{dirs:i,files:s,links:u=[]}=e.fs.listDir(r);return{dirs:[...i],files:[...s],links:[...u]}},walkFiles:n=>[...e.fs.walkFiles(t(n))]}}function ql(e){if(e==null)return F();if(typeof e=="string")return F(e);if(typeof e!="object")throw new TypeError(`invalid result: expected a string or an object (got ${typeof e})`);if(Array.isArray(e))throw new TypeError("invalid result: expected a string or an object, got an array (join the lines first)");let t=Object.keys(e);for(let i of t)if(!Pi.includes(i))throw new TypeError(`invalid result: unknown field \`${i}\` (known: ${Pi.join(", ")})`);if(t.length===0)throw new TypeError(`invalid result: an object with none of ${Pi.join(", ")} \u2014 return a string for plain output`);let{stdout:n="",stderr:r="",exitCode:o=0}=e;if(typeof n!="string")throw new TypeError(`invalid result: stdout must be a string (got ${typeof n})`);if(typeof r!="string")throw new TypeError(`invalid result: stderr must be a string (got ${typeof r})`);if(!Number.isInteger(o)||o<0)throw new TypeError(`invalid result: exitCode must be a non-negative integer (got ${o})`);return{stdout:n,stderr:r===""||r.endsWith(`
|
|
31
31
|
`)?r:r+`
|
|
32
|
-
`,exitCode:o}}function N(e,t={}){let n=Pn(t.short),r=Pn(t.long),o=Pn(t.valueShort),i=Pn(t.valueLong),s=Pn(t.repeatable),u=new Set,a=new Map,l=[],f=[],c=0;function d(p,h,m=!1){let g=(m?"--":"-")+p,w=(m?i:o).has(p)||s.has(p)&&(!m||p.length>1);if(w){let
|
|
33
|
-
`;async function
|
|
34
|
-
`,e.status=1,!1}var Xr="gzip",
|
|
35
|
-
`),
|
|
36
|
-
`,e.status=e.status===1?1:n,!1}var
|
|
32
|
+
`,exitCode:o}}function N(e,t={}){let n=Pn(t.short),r=Pn(t.long),o=Pn(t.valueShort),i=Pn(t.valueLong),s=Pn(t.repeatable),u=new Set,a=new Map,l=[],f=[],c=0;function d(p,h,m=!1){let g=(m?"--":"-")+p,w=(m?i:o).has(p)||s.has(p)&&(!m||p.length>1);if(w){let b=h??e[++c];if(h===null&&c>=e.length)throw new Error(g+" requires an argument");if(s.has(p)){let k=a.get(p);k?k.push(b):a.set(p,[b])}else a.set(p,b);f.push({name:p,value:b})}else{if(!(m?r:n).has(p))throw new y("option",g,"unknown option: "+g);if(m&&h!==null)throw new Error("option "+g+" doesn't allow an argument");u.add(p),f.push({name:p})}return w}for(;c<e.length;c++){let p=e[c];if(p==="--"){l.push(...e.slice(c+1));break}if(p.startsWith("--")&&p.length>2){let h=p.indexOf("=");d(h===-1?p.slice(2):p.slice(2,h),h===-1?null:p.slice(h+1),!0);continue}if(p.startsWith("-")&&p.length>1&&!(t.numericOperands&&pg(p,n,o,s))){for(let h=1;h<p.length&&!d(p[h],h+1<p.length?p.slice(h+1):null);h++);continue}if(t.stopAtFirstPositional){l.push(...e.slice(c));break}l.push(p)}return{flags:u,values:a,positional:l,order:f}}function pg(e,t,n,r){if(!/^-\d/u.test(e))return!1;let o=e[1];return!t.has(o)&&!n.has(o)&&!r.has(o)}function Pn(e){return e instanceof Set?e:new Set(e??[])}function hg(e){try{return typeof DecompressionStream=="function"&&!!new DecompressionStream(e)}catch{return!1}}function mg(e){try{return typeof CompressionStream=="function"&&!!new CompressionStream(e)}catch{return!1}}var zr=e=>hg(e)&&mg(e);async function Hl(e,t){let{readable:n,writable:r}=e,o=r.getWriter(),i=(async()=>{try{await o.write(t),await o.close()}catch{}})(),s=n.getReader(),u=[],a=null;try{for(;;){let{done:c,value:d}=await s.read();if(c)break;u.push(d)}}catch(c){a=c?.cause?.message??c?.message??"corrupt input"}await i;let l=new Uint8Array(u.reduce((c,d)=>c+d.length,0)),f=0;for(let c of u)l.set(c,f),f+=c.length;return{bytes:l,error:a}}var Hr=(e,t)=>Hl(new DecompressionStream(t),e),Dn=async(e,t)=>(await Hl(new CompressionStream(t),e)).bytes;var Di="brotli",Gr=".br",Xl=zr(Di)?{brotli:wg}:{},Zl="con",Yl=Object.freeze(["0","1","2","3","4","5","6","7","8","9"]),gg=`Usage: brotli [OPTION]... [FILE]...
|
|
33
|
+
`;async function wg(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:[...Yl,"d","c","k","j","f","Z"],long:["decompress","stdout","keep","rm","force","best"],valueShort:["q"],valueLong:["quality"]}),s=bg(r,o);if(s!==void 0)return v("option","brotli",s,`brotli: ${s}: choosing a compression level is not supported`,1);let u={decompressing:r.has("d")||r.has("decompress"),stdout:r.has("c")||r.has("stdout"),remove:r.has("j")||r.has("rm"),force:r.has("f")||r.has("force")};if(u.stdout&&i.length>1)return{stdout:gg,stderr:"",exitCode:1};let a={ctx:n,events:[],stderr:"",status:0,gap:null};for(let f of i.length===0?["-"]:i)if(!await yg(f,e,u,a))break;if(a.gap)return a.gap;let l=[...a.events,...a.stderr?[{fd:2,text:a.stderr}]:[]];return{stdout:"",stderr:a.stderr,exitCode:a.status,events:l}}function bg(e,t){let n=[...Yl,"Z"].find(r=>e.has(r));return n!==void 0?"-"+n:e.has("best")?"--best":t.has("q")?"-q":t.has("quality")?"--quality":void 0}function yg(e,t,n,r){let{ctx:o}=r;if(e==="-"){let u=o.stdinBytes,a=o.stdinLeft;return q(o,"",!0),Gl(u??B(a),Zl,null,n,r)}let i=null;if(!n.stdout)if(!n.decompressing)i=e+Gr;else{if(e.length<=Gr.length)return Mt(r,`empty output file name for [${e}] input file`);if(e.endsWith(Gr))i=e.slice(0,-Gr.length);else return Mt(r,`input file [${e}] suffix mismatch`)}let s=P(o,"brotli",e);return s.error?Mt(r,`failed to open input file [${e}]: ${s.error}`):i!==null&&!n.force&&P(o,"brotli",i).error===null?Mt(r,`failed to open output file [${i}]: File exists`):o.fs.isDir(s.path)?Mt(r,`failed to read input [${e}]: Is a directory`):Gl(Be(o.fs,s.path),e,i,n,r)}async function Gl(e,t,n,r,o){let{ctx:i}=o,s=r.decompressing?await Hr(e,Di):{bytes:await Dn(e,Di),error:null};if(s.error)return Mt(o,`corrupt input [${t}]`);if(n===null)o.events.push({fd:1,bytes:s.bytes});else if(!xg(n,s.bytes,o))return!1;return r.remove&&t!==Zl&&i.fs.removeWritable(i.cwd,t),!0}function xg(e,t,n){let{ctx:r}=n,o;try{o=r.writable&&r.fs.openWritable?.(r.cwd,e)}catch(i){return Mt(n,`failed to open output file [${e}]: ${i.message}`)}return o?(o.writeBytes(t),!0):(n.gap??=v("feature","brotli","read-only target",`brotli: ${e}: file system is read-only`,1),!1)}function Mt(e,t){return e.stderr+=`${t}
|
|
34
|
+
`,e.status=1,!1}var Xr="gzip",kg=(e,t,n)=>Ui(e,["-d",...t],n),Vl=(e,t,n)=>Ui(e,["-d","-c",...t],n),Ql=zr(Xr)?{gzip:Ui,gunzip:kg,zcat:Vl,gzcat:Vl}:{},Kl=Object.freeze([31,139]),vg=e=>e!==void 0&&e.length>=2&&e[0]===Kl[0]&&e[1]===Kl[1],Sg={__proto__:null,"unexpected end of file":"unexpected end of file","incorrect data check":"invalid compressed data--crc error"},Eg=e=>Sg[e]??"invalid compressed data--format violated",ef=Object.freeze({__proto__:null,".gz":"",".tgz":".tar",".taz":".tar","-gz":"",".z":"","-z":"",_z:""}),$g=".gz",Jl=Object.freeze(["1","2","3","4","5","6","7","8","9"]);async function Ui(e,t,n){let{flags:r,positional:o}=N(t,{short:[...Jl,"d","c","k"],long:["decompress","uncompress","stdout","to-stdout","keep"]}),i=Jl.find(l=>r.has(l));if(i!==void 0)return v("option","gzip",`-${i}`,`gzip: -${i}: choosing a compression level is not supported`,1);let s={decompressing:["d","decompress","uncompress"].some(l=>r.has(l)),stdout:["c","stdout","to-stdout"].some(l=>r.has(l)),keep:r.has("k")||r.has("keep")},u={ctx:n,events:[],stderr:"",status:0,gap:null};if(o.length===0)await Ng(e,s,u);else for(let l of o)await Ag(l,s,u);if(u.gap)return u.gap;let a=[...u.events,...u.stderr?[{fd:2,text:u.stderr}]:[]];return{stdout:"",stderr:u.stderr,exitCode:u.status,events:a}}async function Ng(e,t,n){let r=n.ctx.stdinBytes;return q(n.ctx,"",!0),t.decompressing&&r!==null?tf("stdin",r,{...t,stdout:!0},n):t.decompressing?Bi(n,e===""?"stdin: unexpected end of file":"stdin: not in gzip format"):ji(await Dn(r??B(e),Xr),n)}function Ag(e,t,n){let{ctx:r}=n,o=P(r,"gzip",e);return o.error?Pt(n,`${e}: ${o.error}`,1):r.fs.isDir(o.path)?Pt(n,`${e} is a directory -- ignored`,2):t.decompressing?Fg(e,o.path,t,n):Og(e,o.path,t,n)}async function Og(e,t,n,r){let{ctx:o}=r,i=nf(e);if(!n.stdout&&i!==void 0)return _g(r,`${e} already has ${i} suffix -- unchanged`);let s=Tg(await Dn(Be(o.fs,t),Xr),e.slice(e.lastIndexOf("/")+1),Cg(o));return n.stdout?ji(s,r):rf(e+$g,s,e,n,r)}var Cg=e=>Math.floor(e.createdAt/1e3),Bn=10,Ig=8;function Tg(e,t,n){let r=B(t);if(e.length<Bn||e[3]!==0||r.includes(0))return e;let o=new Uint8Array(e.length+r.length+1);o.set(e.subarray(0,Bn)),o[3]=Ig;for(let i=0;i<4;i++)o[4+i]=n>>>8*i&255;return o.set(r,Bn),o.set(e.subarray(Bn),Bn+r.length+1),o}function Fg(e,t,n,r){let{ctx:o}=r,i=o.fs.isBytes?.(t)===!0?Be(o.fs,t):void 0;return tf(e,i,n,r,t)}async function tf(e,t,n,r,o=null){let{ctx:i}=r;if(!vg(t))return Bi(r,`${e}: ${Lg(t,o,i)?"unexpected end of file":"not in gzip format"}`);let s=await Hr(t,Xr),u=nf(e);(n.stdout?ji(s.bytes,r):u===void 0?Pt(r,`${e}: unknown suffix -- ignored`,2):rf(e.slice(0,-u.length)+ef[u],s.bytes,e,n,r))&&s.error&&Bi(r,`${e}: ${Eg(s.error)}`)}var nf=e=>Object.keys(ef).find(t=>e.length>t.length&&e.endsWith(t));function Lg(e,t,n){if(e!==void 0)return e.length<2;let r=n.fs.readFile(t);return r.length<2&&A(r).length<2}var ji=(e,t)=>(t.events.push({fd:1,bytes:e}),!0);function rf(e,t,n,r,o){let{ctx:i}=o;if(P(i,"gzip",e).error===null)return Pt(o,`${e} already exists; not overwritten`,2);let s;try{s=i.writable&&i.fs.openWritable?.(i.cwd,e)}catch(u){return Pt(o,`${e}: ${u.message}`,1)}return s?(s.writeBytes(t),r.keep||i.fs.removeWritable(i.cwd,n),!0):(o.gap??=v("feature","gzip","read-only target",`gzip: ${e}: file system is read-only`,1),!1)}var Bi=(e,t)=>Pt(e,t,1,`
|
|
35
|
+
`),_g=(e,t)=>Pt(e,t,e.status);function Pt(e,t,n,r=""){return e.stderr+=`${r}gzip: ${t}
|
|
36
|
+
`,e.status=e.status===1?1:n,!1}var Rg=Object.freeze({__proto__:null,1:"SHA-1",256:"SHA-256",384:"SHA-384",512:"SHA-512"}),Mg=Object.freeze(["1","224","256","384","512","512224","512256"]),Pg=()=>{try{return typeof crypto?.subtle?.digest=="function"}catch{return!1}};async function Dg(e,t){let n=new Uint8Array(await crypto.subtle.digest(e,t));return Array.from(n,r=>r.toString(16).padStart(2,"0")).join("")}function Bg(e,t,n){let r=e==="shasum"?n.get("a")??"1":String(t);if(e==="shasum"&&!Mg.includes(r))return{error:x(`${e}: Unrecognized algorithm
|
|
37
37
|
Type shasum -h for help
|
|
38
|
-
`,1)};let o=
|
|
38
|
+
`,1)};let o=Rg[r];return o===void 0?{error:v("feature",e,`SHA-${r}`,`${e}: this runtime's crypto does not digest SHA-${r}`,1)}:{algorithm:o}}function Un(e,t){return async(n,r,o)=>{let{flags:i,order:s,positional:u,values:a}=N(r,{short:e==="shasum"?["b","t","c"]:["b","t","c","z"],long:e==="shasum"?["binary","text","check","tag"]:["binary","text","check","tag","zero"],valueShort:e==="shasum"?["a"]:[]});if(i.has("c")||i.has("check"))return v("feature",e,"-c",`${e}: reading a list of digests back is not supported`,1);let{algorithm:l,error:f}=Bg(e,t,a);if(f)return f;let{mode:c,error:d}=qg(e,i,s);if(d)return d;let p=te(e,u,n,o,{read:"bytes"}),h=await Promise.all(p.inputs.map(g=>Dg(l,g.bytes))),m=zg(l,i,c);return ne(p.inputs.map((g,w)=>m(h[w],g.name??"-")).join(""),p)}}var Ug=new Set(["b","binary"]),jg=new Set(["t","text"]);function Wg(e,t){let n=!1,r=null,o=!1;for(let{name:i}of t)Ug.has(i)?(n=!0,r="binary"):jg.has(i)?(o=!0,r="text"):i==="tag"&&(r="binary");return e==="shasum"?{binary:n,text:o&&!n,ambiguous:n&&o}:{binary:r==="binary",text:r==="text",ambiguous:!1}}function qg(e,t,n){let r=Wg(e,n),o=e==="shasum"?`Type ${e} -h for help
|
|
39
39
|
`:`Try '${e} --help' for more information.
|
|
40
40
|
`;return r.ambiguous?{error:x(`${e}: Ambiguous file mode
|
|
41
41
|
${o}`,1)}:t.has("tag")&&r.text?{error:x(`${e}: --tag does not support --text mode
|
|
42
|
-
${o}`,1)}:{mode:r}}function
|
|
43
|
-
`;if(t.has("tag")){let o=e.replace("-","");return(i,s)=>`${o} (${s}) = ${i}${r}`}return(o,i)=>`${o}${n.binary?" *":" "}${i}${r}`}var of=
|
|
42
|
+
${o}`,1)}:{mode:r}}function zg(e,t,n){let r=t.has("z")||t.has("zero")?"\0":`
|
|
43
|
+
`;if(t.has("tag")){let o=e.replace("-","");return(i,s)=>`${o} (${s}) = ${i}${r}`}return(o,i)=>`${o}${n.binary?" *":" "}${i}${r}`}var of=Pg()?{sha1sum:Un("sha1sum",1),sha256sum:Un("sha256sum",256),sha384sum:Un("sha384sum",384),sha512sum:Un("sha512sum",512),shasum:Un("shasum",1)}:{};var sf={...Ql,...Xl,...of};var Hg=new Uint8Array;function Zr(e,t,n,r,o){let i=uf(e,o.skip,o.skipFlag,0),s=uf(e,o.len,o.lenFlag,Number.POSITIVE_INFINITY);if(i.error||s.error)return{error:i.error??s.error};let u=s.value,a=i.value,l=0,f=n,c=r.stdinBytes,d=[],p={stderr:"",failed:!1};for(let g of t.length?t:[null]){let w=te(e,g===null?[]:[g],f,r,{read:"loose-bytes",noRead:u===0&&a===0}),b=w.entries[0]?.kind==="dir";if(p.stderr+=w.stderr,p.failed||=w.failed&&!(e==="hexdump"&&b),a&&b)return{error:v("feature",e,"skip across unreadable input",`${e}: skipping across a directory operand is not supported`)};if(b&&e==="xxd")return{error:x(p.stderr,2)};if(!w.inputs.length&&!b)continue;let k=w.inputs[0],S=k&&(k.shared||k.name===null);if(e==="hexdump"&&a&&S&&!r.stdinFile)return q(r,f,!0,c),{error:x("hexdump: standard input: Illegal seek")};let I=S&&r.stdinFile&&o.skip!==void 0&&(e==="xxd"||e==="hexdump"&&i.value>0),M=I?A(r.stdinOrigin):k?.bytes??Hg,C=Math.min(a,M.length);a-=C,l+=C;let H=Math.min(u,M.length-C);if(d.push(M.subarray(C,C+H)),u-=H,S){let Y=M.subarray(C+H),D=c!==null&&!I&&Y.length>0?Y:null;f=D===null?W(Y):me(Y)??"",q(r,f,!0,D)}if(I&&a&&(l=i.value,a=0),u===0&&a===0)break}if(a&&o.skipPastEofErrors)return{error:x(p.stderr+`${e}: cannot skip past end of combined input`)};let h=new Uint8Array(d.reduce((g,w)=>g+w.length,0)),m=0;for(let g of d)h.set(g,m),m+=g.length;return{bytes:h,start:l,r:p}}function uf(e,t,n,r){if(t===void 0)return{value:r};if(e==="xxd"&&!/^(?:0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.test(t))return{error:v("feature",e,`${n} ${t}`,`xxd: this offset/count spelling is not supported: ${t}`)};if(e==="hexdump")return/^[ \t\n\r\v\f]*[+\d-]/u.test(t)?!/^\d+$/u.test(t)||/^0\d/u.test(t)?{error:v("feature",e,`${n} ${t}`,`hexdump: this offset/count spelling is not supported: ${t}`)}:BigInt(t)>BigInt(Number.MAX_SAFE_INTEGER)?{error:v("feature",e,"large byte count","hexdump: counts beyond exact integer precision are not supported")}:{value:Number(t)}:{error:x(`${e}: ${n}: invalid count: ${t}`)};let o=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)(b|[kKMGTPEZYRQ](?:i?B)?)?$/u.exec(t);if(!o)return{error:x(`${e}: ${n}: invalid count: ${t}`)};let i=/^0\d/u.test(o[1])?"0o"+o[1].slice(1):o[1];return ki(BigInt(i),o[2],`${e}: ${n}`,t)}var Yr=16,Gg=47,Xg=39;function ff(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["C","v"],valueShort:["n","s"]});if(i.includes("-"))return v("feature","hexdump","hyphen input operand","hexdump: a hyphen input operand is not supported; omit operands to read stdin");let s=Zr("hexdump",i,e,n,{skip:o.get("s"),len:o.get("n"),skipFlag:"-s",lenFlag:"-n"});return s.error?s.error:ne(qi(s.bytes,s.start,r.has("v"),r.has("C")?Yg:Zg),s.r)}function cf(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["v"],valueShort:["j","N"]});if(!r.size&&!o.size&&(i.length===1&&/^\+\d/u.test(i[0])||i.length===2&&/^\+?\d/u.test(i[1])))return v("feature","od","legacy offset operand","od: legacy offset operands are not supported; use -j OFFSET");let s=Zr("od",i,e,n,{skip:o.get("j"),len:o.get("N"),skipFlag:"-j",lenFlag:"-N",skipPastEofErrors:!0});return s.error?s.error:ne(qi(s.bytes,s.start,r.has("v"),Vg),s.r)}function df(e,t,n){let{values:r,positional:o}=N(t,{valueShort:["s","l"]});if(o.length>2)return x("xxd: too many operands");if(o.length===2&&o[1]!=="-")return v("feature","xxd","output file","xxd: output files are not supported (filesystem is read-only)");let i=Zr("xxd",o.slice(0,1),e,n,{skip:r.get("s"),len:r.get("l"),skipFlag:"-s",lenFlag:"-l"});return i.error?i.error:ne(qi(i.bytes,i.start,!1,Kg),i.r)}function qi(e,t,n,r){let o=[],i=null,s=!1;for(let a=0;a<e.length;a+=Yr){let l=e.subarray(a,a+Yr);r.compress&&!n&&i!==null&&l.length===Yr&&ew(l,i)?s||(o.push("*"),s=!0):(o.push(r.row(t+a,l)),s=!1),i=l}let u=t+e.length;return(r.trailer==="always"||r.trailer==="nonzero"&&u>0)&&o.push(r.addr(u)),ge(o)}var Zg={compress:!0,trailer:"nonzero",addr:af,row:(e,t)=>(af(e)+" "+pf(t).map(tw).join(" ")).padEnd(Gg)},Yg={compress:!0,trailer:"nonzero",addr:zi,row:Jg},Vg={compress:!0,trailer:"always",addr:lf,row:(e,t)=>lf(e)+" "+pf(t).map(nw).join(" ")},Kg={compress:!1,trailer:"never",row:(e,t)=>`${zi(e)}: ${Qg(t).join(" ").padEnd(Xg)} ${hf(t)}`};function af(e){return e.toString(16).padStart(7,"0")}function zi(e){return e.toString(16).padStart(8,"0")}function lf(e){return e.toString(8).padStart(7,"0")}function Jg(e,t){let n=[];for(let i=0;i<Yr;i++)n.push(i<t.length?Wi(t[i]):" ");let r=n.slice(0,8).join(" "),o=n.slice(8).join(" ");return`${zi(e)} ${r} ${o} |${hf(t)}|`}function pf(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(n+1<e.length?e[n]|e[n+1]<<8:e[n]);return t}function Qg(e){let t=[];for(let n=0;n<e.length;n+=2)t.push(Wi(e[n])+(n+1<e.length?Wi(e[n+1]):""));return t}function hf(e){let t="";for(let n of e)t+=n>=32&&n<=126?String.fromCodePoint(n):".";return t}function ew(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}var Wi=e=>e.toString(16).padStart(2,"0"),tw=e=>e.toString(16).padStart(4,"0"),nw=e=>e.toString(8).padStart(6,"0");var rw=76;function Vr(e,{encode:t,decode:n}){return(r,o,i)=>{let{flags:s,positional:u,order:a}=N(o,{short:["d","i"],long:["decode","ignore-garbage"],valueShort:["w"],valueLong:["wrap"]}),l=rw;for(let{name:p,value:h}of a){if(p!=="w"&&p!=="wrap")continue;if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(h)||BigInt(h)<0n)return x(`${e}: invalid wrap size: ${h}`);let m=BigInt(h);l=m>ue?0:Number(m)}if(u.length>1)return x(`${e}: extra operand: ${u[1]}`);let f=te(e,u,r,i,{read:"as-held"});if(f.failed)return x(f.stderr);let{content:c,bytes:d}=f.inputs[0];return s.has("d")||s.has("decode")?iw(e,n(c??ai(d),s.has("i")||s.has("ignore-garbage"))):ow(t(d??B(c)),l)}}function ow(e,t){if(!t||e==="")return F(e);let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return F(n.join(`
|
|
44
44
|
`)+`
|
|
45
|
-
`)}function
|
|
46
|
-
`;if(r!==void 0&&n)return F(r);let i=r===void 0?{fd:1,bytes:t}:{fd:1,text:r};return{stdout:r??"",stderr:o,exitCode:n?0:1,events:[...t.length?[i]:[],...o?[{fd:2,text:o}]:[]]}}var mf=[{},{},{}],gf=[[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],[..."0123456789ABCDEFGHIJKLMNOPQRSTUV"],[..."0123456789ABCDEFGHJKMNPQRSTVWXYZ"]],Dt="Invalid character in base32 input",
|
|
47
|
-
`)return!0;if(n!=="\\")continue;let r=e[t+1];if(r==="n"||r==="x"&&/^x\{?0*a\}?/iu.test(e.slice(t+1)))return!0;t++}return!1}function Of(e,t){if(!t)for(let n of e){for(let[r,o]of Ew)if(r.test(n))throw Wn(o,`${o} is not supported; ripgrep's regex engine rejects it too`);if($w(n))throw Wn("newline in a pattern","a newline in a pattern is not supported; ripgrep rejects one outside multiline mode")}}var $=class extends Error{constructor(t,n=null,r=null){super(t),this.line=n,this.gap=r}},Cf=new Set(["BEGIN","END","BEGINFILE","ENDFILE","function","func","if","else","while","for","do","break","continue","next","nextfile","exit","return","delete","in","getline","print","printf","switch","case","default"]),Zi={__proto__:null,length:[0,1],substr:[2,3],index:[2,2],split:[2,3],sub:[2,3],gsub:[2,3],gensub:[3,4],match:[2,3],sprintf:[1,1/0],sin:[1,1],cos:[1,1],atan2:[2,2],exp:[1,1],log:[1,1],sqrt:[1,1],int:[1,1],rand:[0,0],srand:[0,1],tolower:[1,1],toupper:[1,1],close:[1,2],fflush:[0,1],systime:[0,0],strtonum:[1,1],and:[2,1/0],or:[2,1/0],xor:[2,1/0],lshift:[2,2],rshift:[2,2],compl:[1,1],typeof:[1,1],isarray:[1,1]},Jr=new Map([["system","system() is not supported: this terminal runs no processes"],["strftime","strftime() is not supported (gawk extension)"],["mktime","mktime() is not supported (gawk extension)"],["asort","asort() is not supported (gawk extension)"],["asorti","asorti() is not supported (gawk extension)"],["patsplit","patsplit() is not supported (gawk extension)"]]),If=new Set([...Object.keys(Zi),...Jr.keys()]),qn=5e6,Yi=100,Ce=1e6,Qr="this terminal runs no processes";function eo(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;default:return t**n}}var Tf={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},Nw='^$.[]|()*+?{}\\/"',Vi=1e3,Ff=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),Lf=e=>e!==void 0&&e>="0"&&e<="7",Ki=class{constructor(t,n,r,o){this.src=t,this.i=0,this.warn=n,this.tables=r,this.ignoreCase=o,this.groups=0}fail(t){throw new $(`invalid regex /${this.src}/: ${t}`)}peek(){return this.src[this.i]}literal(){let t=this.src.codePointAt(this.i);return this.i+=Ue(t),this.charNode(t)}charNode(t){let n=this.ignoreCase?this.tables.fold(t):[t];return n.length===1?{type:"char",code:t}:{type:"set",negate:!1,items:n.map(r=>[r,r])}}parse(){return this.alternation(0)}alternation(t){let n=[this.concatenation(t)];for(;this.peek()==="|";)this.i++,n.push(this.concatenation(t));return n.length===1?n[0]:{type:"alt",nodes:n}}concatenation(t){let n=[];for(;!this.endsConcatenation(t);)n.push(this.quantified(this.atom(n.length===0,t)));return n.length===1?n[0]:{type:"cat",nodes:n}}endsConcatenation(t){let n=this.peek();return n===void 0||n==="|"||n===")"&&t>0}quantified(t){let n=t;for(;;){let r=this.peek();if(r==="*"){this.i++,n={type:"rep",node:n,min:0,max:null};continue}if(r==="+"){this.i++,n={type:"rep",node:n,min:1,max:null};continue}if(r==="?"){this.i++,n={type:"rep",node:n,min:0,max:1};continue}if(r==="{"){let o=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!o&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail("invalid content of {}"),!o||o[1]===""&&o[2]===void 0)return n;let i=o[1]===""?0:Number(o[1]),s=o[2]===void 0?i:o[3]===""?null:Number(o[3]);if(s!==null&&s<i&&this.fail(`invalid interval {${i},${s}}`),i>Vi||s!==null&&s>Vi)throw new $(`interval count above ${Vi} is not supported`,null,"regex interval limit");this.i+=o[0].length,n={type:"rep",node:n,min:i,max:s};continue}return n}}atom(t,n){let r=this.peek();if(r==="("){this.i++;let o=++this.groups,i=this.alternation(n+1);return this.peek()!==")"&&this.fail("missing `)`"),this.i++,{type:"group",index:o,node:i}}return r==="["?this.bracket():r==="\\"?this.escape():(this.i++,r==="."?{type:"any"}:r==="^"||r==="$"?{type:"assert",kind:r}:((r==="*"||r==="+"||r==="?")&&!t&&this.fail(`unexpected \`${r}\``),this.i--,this.literal()))}escape(){this.i++;let t=this.peek();return t===void 0&&this.fail("trailing backslash"),this.i++,t==="y"?{type:"assert",kind:"y"}:t==="<"||t===">"||t==="B"?{type:"assert",kind:t}:t==="`"?{type:"assert",kind:"^"}:t==="'"?{type:"assert",kind:"$"}:t==="s"||t==="S"?{type:"set",negate:t==="S",items:this.tables.ranges("space")}:t==="w"||t==="W"?{type:"set",negate:t==="W",items:this.tables.ranges("word")}:(t==="b"&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(t,!0)))}escapedCode(t,n){if(t in Tf)return Tf[t];if(Lf(t)){let o=t;for(;o.length<3&&Lf(this.peek());)o+=this.src[this.i++];return _f(o,8)}if(t==="x"&&Ff(this.peek())){let o="";for(;o.length<2&&Ff(this.peek());)o+=this.src[this.i++];return _f(o,16)}let r=this.src.codePointAt(this.i-1);return!Nw.includes(t)&&n&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(r)}' is not a known regexp operator`),this.i+=Ue(r)-1,r}bracket(){this.i++;let t=!1;this.peek()==="^"&&(t=!0,this.i++);let n=[],r=!0;for(;;){this.i>=this.src.length&&this.fail("unterminated bracket expression");let o=this.peek();if(o==="]"&&!r){this.i++;break}if(r=!1,o==="["&&this.src[this.i+1]===":"){let s=this.src.indexOf(":]",this.i+2);if(s!==-1){let u=this.src.slice(this.i+2,s),a=this.tables.ranges(this.ignoreCase?Pr(u):u);a===void 0&&this.fail(`invalid character class \`[:${u}:]\``),n.push(...a),this.i=s+2;continue}}let i=this.bracketChar();if(this.peek()==="-"&&this.src[this.i+1]!=="]"&&this.src[this.i+1]!==void 0){this.i++;let s=this.bracketChar(),u=this.ignoreCase?this.tables.foldRange(i,s):s<i?null:[[i,s]];u===null&&this.fail("invalid range end"),n.push(...u)}else this.ignoreCase?n.push(...this.tables.fold(i).map(s=>[s,s])):n.push([i,i])}return{type:"set",negate:t,items:n}}bracketChar(){let t=this.peek();if(t==="["&&(this.src[this.i+1]==="."||this.src[this.i+1]==="=")){let r=this.src.indexOf(this.src[this.i+1]+"]",this.i+2);if(r!==-1&&r>this.i+2){Array.from(this.src.slice(this.i+2,r)).length!==1&&this.fail("invalid collation character");let o=this.src.codePointAt(this.i+2);return this.i=r+2,o}}if(t==="\\"){this.i++,this.peek()===void 0&&this.fail("trailing backslash");let r=this.src[this.i++];return this.escapedCode(r,!1)}let n=this.src.codePointAt(this.i);return this.i+=Ue(n),n}};function no(e,t=null,n=re(ee),r=!1){let o=new Ki(e,t,n,r);return{ast:o.parse(),groups:o.groups}}function _f(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new $("non-ASCII regex byte escapes are not supported",null,"regex byte escapes");return n}var Aw=e=>`\\u{${e.toString(16)}}`,to=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):Aw(e);function Ow(e,t){if(e==="^"||e==="$")return e;let n=t.assertions();return e==="y"?n.boundary:e==="B"?n.inside:n[e]}function Ji(e,t=re(ee)){let n=r=>Ji(r,t);switch(e.type){case"char":return to(e.code);case"any":return".";case"set":return`[${e.negate?"^":""}${e.items.map(([r,o])=>r===o?to(r):`${to(r)}-${to(o)}`).join("")}]`;case"assert":return Ow(e.kind,t);case"group":return`(${n(e.node)})`;case"cat":return e.nodes.map(n).join("");case"alt":return`(?:${e.nodes.map(n).join("|")})`;case"rep":{let r=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${r}*`:e.min===1?`${r}+`:`${r}{${e.min},}`:e.min===0&&e.max===1?`${r}?`:`${r}{${e.min},${e.max}}`}default:throw new $(`internal: unknown regex node ${e.type}`)}}var Cw=5e4;function Iw(e,t){let n=r=>{for(let o=0;o<e.length;o++)if(r>=e[o][0]&&r<=e[o][1])return!0;return!1};return t?r=>!n(r):n}function Rf(e,t=re(ee)){let n=[],r=l=>{if(n.length>=Cw)throw new $("regex too large",null,"regex state limit");return n.push(l),n.length-1};function o(l,f){switch(l.type){case"char":return r({op:"char",codes:[l.code],next:f});case"any":return r({op:"any",next:f});case"set":return r({op:"set",test:Iw(l.items,l.negate),next:f});case"assert":return r({op:"assert",kind:l.kind,next:f});case"group":return o(l.node,f);case"cat":{let c=f;for(let d=l.nodes.length-1;d>=0;d--)c=o(l.nodes[d],c);return c}case"alt":{let c=l.nodes.map(p=>o(p,f)),d=c.at(-1);for(let p=c.length-2;p>=0;p--)d=r({op:"split",x:c[p],y:d});return d}case"rep":return i(l,f);default:throw new $(`internal: unknown regex node ${l.type}`)}}function i(l,f){let c=f;if(l.max===null){let d=r({op:"split",x:-1,y:f});n[d].x=o(l.node,d),c=d}else for(let d=l.max-l.min;d>0;d--)c=r({op:"split",x:o(l.node,c),y:f});for(let d=0;d<l.min;d++)c=o(l.node,c);return c}let s=o(e,r({op:"match"})),u="",a=s;for(;n[a].op==="char"&&n[a].codes.length===1&&n[a].codes[0]<128;)u+=String.fromCodePoint(n[a].codes[0]),a=n[a].next;return(n[a].op!=="match"||u==="")&&(u=null),{states:n,start:s,literal:u,isWord:l=>t.has("word",l),gen:new Int32Array(n.length).fill(-1),stamp:0}}function Tw(e,t){if(t<=0)return-1;let n=e.codePointAt(t-1);return n>=56320&&n<=57343&&t>=2?e.codePointAt(t-2):n}function Fw(e,t,n,r){if(e==="^")return n===0;if(e==="$")return n===t.length;let o=r(Tw(t,n)),i=n<t.length&&r(t.codePointAt(n));return e==="y"?o!==i:e==="B"?o===i:e==="<"?!o&&i:o&&!i}function Lw(e,t){return e.op==="char"?e.codes.includes(t):e.op==="any"?!0:e.test(t)}function Mf(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let p=t.indexOf(e.literal,n);return p<0?null:{start:p,end:p+e.literal.length}}let{states:r,gen:o}=e,i=t.length,s=[],u=(p,h,m,g,w)=>{for(s.push(h);s.length>0;){let y=s.pop();if(o[y]===w)continue;o[y]=w;let k=r[y];k.op==="split"?s.push(k.y,k.x):k.op==="assert"?Fw(k.kind,t,g,e.isWord)&&s.push(k.next):p.push(y,m)}},a=[],l=[],f=null,c=n,d=++e.stamp;for(;;){f===null&&u(a,e.start,c,c,d);let p=c<i?t.codePointAt(c):-1,h=Ue(p);if(a.length===0){if(f!==null||c>=i)break;c+=h,d=++e.stamp;continue}let m=++e.stamp;for(let g=0;g<a.length;g+=2){let w=a[g],y=a[g+1];if(f!==null&&y>f.start)continue;let k=r[w];if(k.op==="match"){(f===null||y<f.start||y===f.start&&c>f.end)&&(f={start:y,end:c});continue}p!==-1&&Lw(k,p)&&u(l,k.next,y,c+h,m)}if(a.length=0,[a,l]=[l,a],d=m,c>=i)break;c+=h}return f}var ro=new Map,ct=class{constructor(t,n,r,o=re(ee)){let{ast:i,groups:s}=no(t,r,o,n);this.src=t,this.ignoreCase=n,this.tables=o,this.groupCount=s,this.source=Ji(i,o),this.flags="su";try{this.js=new RegExp(this.source,this.flags)}catch(u){throw new $(`cannot compile regex /${t}/: ${u.message}`,null,"regex engine limit")}this.ast=i,this.nfa=null,this.capture=null,this.captureShape=Pf(i)}test(t){return this.checkCase(t),this.js.test(t)}checkCase(t){if(this.ignoreCase&&Tt.test(t+this.src))throw new $("case-insensitive matching over Cyrillic Extended-C letters is not supported",null,"locale-sensitive regex")}search(t,n=0){return this.checkCase(t),this.nfa===null&&(this.nfa=Rf(this.ast,this.tables)),Mf(this.nfa,t,n)}groups(t,n,r){if(this.captureShape.unsafe)throw new $("capture extraction across repeated or alternative groups is not supported",null,"regex capture semantics");let o=this.capture??=new RegExp(this.source,this.flags+"dy");o.lastIndex=n;let i=o.exec(t);if(!i||i.index!==n||n+i[0].length!==r){let s=Array.from(t.slice(r)).length,u=new RegExp(`(?:${this.source})(?=.{${s}}(?![^]))`,this.flags+"dy");u.lastIndex=n,i=u.exec(t)}if(!i)throw new $("capture extraction for this match is not supported",null,"regex capture semantics");return i.indices.map((s,u)=>s===void 0?void 0:{text:i[u],start:s[0],end:s[1]})}};function Pf(e){let n=(e.nodes??(e.node?[e.node]:[])).map(Pf),r=n.reduce((s,u)=>s+u.groups,e.type==="group"?1:0),o=e.type==="assert"||(e.type==="group"||e.type==="cat")&&n.every(s=>s.nullable)||e.type==="alt"&&n.some(s=>s.nullable)||e.type==="rep"&&(e.min===0||n[0].nullable),i=e.type==="rep"&&(e.max===null||e.max>1)&&(r>1||r>0&&n[0].nullable);return{groups:r,nullable:o,unsafe:i||e.type==="alt"&&r>0||n.some(s=>s.unsafe)}}function Re(e,t=!1,n=null,r=re(ee)){let o=(t?"i":"c")+r.name+"\0"+e,i=ro.get(o);if(i)return i;ro.size>=500&&ro.clear();let s=new ct(e,t,n,r);return ro.set(o,s),s}function Qi(e,t,n){for(;;){let r=t.search(e,n);if(!r||r.start!==r.end)return r;if(r.end>=e.length)return null;n=r.end+Le(e,r.end)}}function es(e,t){let n=[],r=0;for(;;){let o=Qi(e,t,r);if(!o)break;n.push(e.slice(r,o.start)),r=o.end}return n.push(e.slice(r)),n}function zn(e,t,n,r){let o=r!=="first",i=e.length,s="",u=0,a=-1,l=0;for(;u<=i;){let f=t.search(e,u);if(!f)break;let c=f.start===f.end;if(c&&f.start===a&&r!=="nth"){if(f.start>=i)break;let p=Le(e,f.start);s+=e.slice(u,f.start+p),u=f.start+p;continue}l++;let d=n(f.start,f.end,l);if(s+=e.slice(u,f.start)+(d===null?e.slice(f.start,f.end):d),a=f.end,c){if(f.end>=i){u=i;break}let p=Le(e,f.end);s+=e.slice(f.end,f.end+p),u=f.end+p}else u=f.end;if(!o)break}return{out:s+e.slice(u),count:l}}function oo(e,t){let n="(){}+?|",r=!1,o=0,i=!1,s="";for(let u=0;u<e.length;u++){let a=e[u];if(i){if(a==="["&&(e[u+1]==="."||e[u+1]==="="))throw new b("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");if(a==="["){let l=Kt(e,u,{classes:t});if(l){s+=l.body,u=l.end-1;continue}}s+=a,a==="]"&&(i=!1,r=!0);continue}if(a==="["){s+=a,i=!0,e[u+1]==="^"&&(s+="^",u++),e[u+1]==="]"&&(s+="\\]",u++);continue}if(a==="\\"){let l=e[++u];if(l===void 0)return{error:"trailing backslash (\\)"};if(n.includes(l)){if((l==="+"||l==="?")&&!r){s+="\\"+l,r=!0;continue}if(l==="("&&o++,l===")"&&o--===0)return{error:"Unmatched ) or \\)"};(l==="("||l==="|")&&(r=!1),(l===")"||l==="}")&&(r=!0),s+=l}else s+="^$\\.*[]/bBsSwW<>`'123456789".includes(l)?"\\"+l:l,r=!"bB<>`'".includes(l);continue}if(a==="*"){s+=r?"*":"\\*",r=!0;continue}if(a==="^"){r=!_w(e,u),s+=r?"\\^":"^";continue}if(a==="$"){r=!(u===e.length-1||e[u+1]==="\\"&&(e[u+2]===")"||e[u+2]==="|")),s+=r?"\\$":"$";continue}s+=n.includes(a)?"\\"+a:a,r=!0}return o>0?{error:"Unmatched ( or \\("}:{source:s}}function _w(e,t){if(t===0)return!0;if(t<2||e[t-2]!=="\\"||e[t-1]!=="("&&e[t-1]!=="|")return!1;let n=0;for(let r=t-3;r>=0&&e[r]==="\\";r--)n++;return n%2===0}function io(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,o=!1,i=0,s=!1,u=[],a=new Set,l=!1;for(let f=0;f<e.length;f++){let c=e[f];if(c==="\\"){let d=e[++f];if(!o&&/[1-9]/u.test(d??"")){let p=Number(d);if(!t.has(p))throw new Error("Invalid back reference");(!a.has(p)||r.has(p))&&(s=!0)}u=[];continue}if(o){c==="]"&&(o=!1);continue}if(c==="["){o=!0,u=[];continue}if(c==="(")n.push({id:++i,entry:new Set(a),branches:[],start:f}),u=[];else if(c==="|"){let d=n.at(-1);d&&d.branches.push(a),a=new Set(d?.entry),u=[]}else if(c===")"){let d=n.pop();if(!d)continue;a=d.branches.reduce((p,h)=>p.intersection(h),a),a.add(d.id),t.add(d.id),u=[...a.difference(d.entry)],l=Rw(e.slice(d.start,f+1))}else if(c==="*"||c==="?"||c==="+"){if(c!=="?"&&l)for(let d of u)r.add(d);if(c!=="+")for(let d of u)a.delete(d)}else if(c==="{"){let d=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(f));if(d){Number(d[1])===0&&(a=a.difference(new Set(u)));let p=d[2]===void 0?Number(d[1]):d[2]===""?1/0:Number(d[2]);l&&p>1&&u.forEach(h=>r.add(h)),f+=d[0].length-1}else u=[]}else u=[]}return s}function Rw(e){try{return new RegExp(`^(?:${e})$`,"su").test("")}catch{return!0}}var Mw="bBsSwW";function Hn(e,t){let n="";for(let r=0;r<e.length;){let o=e[r];if(o==="["){let l=Pw(e,r,t);n+=l.text,r=l.end;continue}let i=o==="\\",s=e.codePointAt(r+(i?1:0)),u=(i?1:0)+Ue(s),a=i&&Mw.includes(e[r+1])?null:t.fold(s);n+=a===null||a.length===1?e.slice(r,r+u):`[${String.fromCodePoint(...a)}]`,r+=u}return n}function Df(e,t){let n="";for(let r of e){let o=t.fold(r.codePointAt(0));n+=o.length===1?RegExp.escape(r):`[${String.fromCodePoint(...o)}]`}return n}function Pw(e,t,n){let r=t+1,o="[";e[r]==="^"&&(o+="^",r++);let i=!0;for(;;){let s=e[r];if(s==="]"&&!i)return{text:o+"]",end:r+1};if(i=!1,s==="["&&":.=".includes(e[r+1])){let l=e[r+1],f=e.indexOf(l+"]",r+2);o+=l===":"?`[:${Pr(e.slice(r+2,f))}:]`:e.slice(r,f+2),r=f+2;continue}let u=e.codePointAt(r),a=r+Ue(u);if(e[a]==="-"&&e[a+1]!==void 0&&e[a+1]!=="]"){let l=e.codePointAt(a+1),f=a+1+Ue(l);o+=Dw(u,l,e.slice(r,f),n),r=f;continue}o+=String.fromCodePoint(...n.fold(u)),r=a}}function Dw(e,t,n,r){let o=r.foldRange(e,t);if(o===null)throw new Error("Invalid range end");return o.length===1&&o[0][0]===e&&o[0][1]===t?n:o.map(([i,s])=>i===s?String.fromCodePoint(i):`${String.fromCodePoint(i)}-${String.fromCodePoint(s)}`).join("")}function Ie(e){throw new b("feature","PCRE "+e,`PCRE ${e} is not supported`)}function Bf(e){let t={captures:0,closed:new Set,names:new Map,stack:[],behind:0,references:!1,risky:!1},n="";for(let r=0;r<e.length;){let o=e[r];if(o==="\\"){let i=Uf(e,r,t,!1);n+=i.source,r=i.end;continue}if(o==="["){let i=jw(e,r,t);n+=i.source,r=i.end;continue}if(o==="("){let i=Bw(e,r,t);n+=i.source,r=i.end;continue}if(o===")"){let i=t.stack.pop();i?.capture&&t.closed.add(i.capture),i?.behind&&t.behind--}if("*+?".includes(o)&&(t.behind&&Ie("variable-length lookbehind"),e[r+1]==="+"&&Ie("possessive repetition"),o!=="+"&&(t.risky=!0)),o==="|"&&(t.risky=!0),o==="{"){let i=Uw(e,r,t);n+=i.source,r=i.end;continue}n+=o==="]"||o==="}"?"\\"+o:o,r++}return t.references&&t.risky&&Ie("conditional backreference"),n}function Bw(e,t,n){let r=!1,o=null,i="(";if(e[t+1]==="*"&&Ie("control verb"),e[t+1]==="?"){let s=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(s||Ie("group"),i=s[0],r=i==="(?<="||i==="(?<!",!s[1]&&i!=="(?:"&&(n.risky=!0),s[1]){if(o=++n.captures,n.names.has(s[1]))throw new Error("duplicate PCRE capture name");n.names.set(s[1],o)}}else o=++n.captures;return r&&n.behind++,n.stack.push({capture:o,behind:r}),{source:i,end:t+i.length}}function Uw(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&Ie("repetition"),{source:"\\{",end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&Ie("variable-length lookbehind"),Number(r[1])>65535||Number(r[2])>65535)throw new Error("PCRE repetition count exceeds 65535");return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]==="+"&&Ie("possessive repetition"),{source:r[0],end:t+r[0].length}}function jw(e,t,n){let r=t+1,o="[";for(e[r]==="^"&&(o+="^",r++),e[r]==="]"&&(o+="\\]",r++);r<e.length&&e[r]!=="]";)if(e[r]==="["&&":.=".includes(e[r+1]??"")&&Ie("character class"),e[r]==="\\"){let i=Uf(e,r,n,!0);o+=i.source,r=i.end}else o+=e[r]==="["?"\\[":e[r],r++;return{source:o+(e[r]==="]"?"]":""),end:r+1}}function Uf(e,t,n,r){let o=e[t+1];if(o===void 0)throw new Error("trailing backslash");if(o==="Q"){let s=e.indexOf("\\E",t+2);return{source:RegExp.escape(e.slice(t+2,s<0?void 0:s)),end:s<0?e.length:s+2}}if(o==="E")return{source:"",end:t+2};if(o==="x"||o==="0"||r&&/[1-7]/u.test(o))return Ww(e,t);if(o==="a"||o==="e")return{source:o==="a"?"\\u0007":"\\u001B",end:t+2};if("AzZ".includes(o)&&!r)return{source:o==="A"?"^":"$",end:t+2};if(/[1-9]/u.test(o)&&!r)return(/\d/u.test(e[t+2]??"")||!n.closed.has(Number(o)))&&Ie("forward or ambiguous backreference"),n.references=!0,{source:"\\"+o,end:t+2};if(o==="k"&&!r){let s=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return(!s||!n.closed.has(n.names.get(s[1])))&&Ie("named backreference"),n.references=!0,{source:s[0],end:t+s[0].length}}if("dDsSwWfnrtbB".includes(o))return{source:"\\"+o,end:t+2};/[A-Za-z0-9]/u.test(o)&&Ie("escape \\"+o);let i=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(i),end:t+1+i.length}}function Ww(e,t){let n=e[t+1]==="x",r=(n?/^\\x(?:\{([\da-fA-F]+)\}|([\da-fA-F]{1,2}))/u:/^\\([0-7]{1,3})/u).exec(e.slice(t));if(!r)throw new Error("invalid PCRE character escape");let o=n?16:8,i=parseInt(r[1]??r[2],o);return Ze(i)||Ie("character escape"),{source:`\\u{${i.toString(16)}}`,end:t+r[0].length}}function ns(e,t){let n="",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"){let s=e[++o]??"";n+=r?i+s:qw(s);continue}if(r&&i==="["){if(e[o+1]==="."||e[o+1]==="=")throw new b("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");let s=Kt(e,o,{classes:t});if(s){n+=s.body,o=s.end-1;continue}}if(i==="["&&!r){n+="[",r=!0,e[o+1]==="^"&&(n+="^",o++),e[o+1]==="]"&&(n+="\\]",o++);continue}i==="]"&&(r=!1),n+=i}return n}function qw(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?"\\"+e:RegExp.escape(e)}function zw(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"){if("bBsSwW<>".includes(e[++t]??""))return!0}else if(".[*+?{".includes(e[t]))return!0;return!1}function Gn(e,t=!1,n=re(ee)){let r=n.assertions(),o=t?{b:"\\y"}:{"<":r["<"],">":r[">"],b:r.boundary,B:r.inside,w:r.word,W:r.nonWord,s:r.space,S:r.nonSpace,"`":"^","'":"$"},i="",s=!1;for(let u=0;u<e.length;u++){let a=e[u];if(a==="\\"){let l=e[++u];i+=!s&&Object.hasOwn(o,l)?o[l]:a+l,!t&&!s&&/[1-9]/u.test(l)&&/\d/u.test(e[u+1]??"")&&(i+="(?:)")}else a==="["&&(s=!0),a==="]"&&(s=!1),i+=a}return i}var rs=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,Hw=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function jf(e,t,n){let r=(n?rs:Hw).exec(e.slice(t));if(!r&&!n)throw new Error("invalid repetition count");r&&Ma(Number(r[1]),r[2]===void 0||r[2]===""?void 0:Number(r[2]))}var Wf={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function Gw(e){if(Wf[e])return Wf[e];let t=rs.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===""?1/0:Number(t[2])}}var qf=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function Xw(e,t){let n=Math.max(t.min,1);if(n>t.max)return{min:0,max:0};if(e.min>0&&(t.min===0&&e.min>1||e.max!==1/0&&t.max>n&&(n+1)*e.min>n*e.max+1))return null;let r=qf(t.max,e.max);return r!==1/0&&r>Lr?null:{min:qf(t.min,e.min),max:r}}function ts(e){return e.max===1/0?e.min===0?"*":e.min===1?"+":`{${e.min},}`:e.min===0&&e.max===1?"?":e.min===e.max?`{${e.min}}`:`{${e.min},${e.max}}`}var Zw=e=>!e.startsWith("(")&&!/^\\[1-9]/u.test(e);function Yw(e,t){if(t.length===1)return e+ts(t[0].bounds);let n=t[0].bounds,r=null;for(let o=1;o<t.length;o++){let{bounds:i,text:s}=t[o],u=r===null?Xw(n,i):null;if(u){n=u;continue}if(!(r===null&&n.min===n.max&&Zw(e))&&i.max>1)throw new Error("stacked quantifier needs ambiguous nesting");r=`(?:${r??e+ts(n)})${s}`}return r??e+ts(n)}function Vw(e,t){let n=t+1;for(e[n]==="^"&&n++;n<e.length;n++){if(e[n]==="\\"){n++;continue}if(e[n]==="]")return n}return e.length-1}function Kw(e){let t="",n=-1,r=-1,o=[],i=()=>{o.length>0&&(t=t.slice(0,n)+Yw(t.slice(n,r),o)),o=[]},s=a=>{i(),n=t.length,r=-1,t+=a},u=[];for(let a=0;a<e.length;a++){let l=e[a];if(l==="\\"){s(l+(e[++a]??""));continue}if(l==="["){let c=Vw(e,a);s(e.slice(a,c+1)),a=c;continue}if(l==="("){i(),u.push(t.length),n=-1,t+=l;continue}if(l===")"){i(),t+=l,n=u.pop()??-1,r=-1;continue}if(l==="|"||l==="^"||l==="$"){i(),t+=l,n=-1;continue}let f=l==="{"?rs.exec(e.slice(a)):null;if(l==="*"||l==="+"||l==="?"||f){let c=f?f[0]:l;if(a+=c.length-1,n<0){t+=c;continue}o.length===0&&(r=t.length),o.push({bounds:Gw(c),text:c});continue}s(l)}return i(),t}function os(e,t,n=!1){let r=-1;for(let o=0;o<e.length;o++){let i=o<=r,s=e[o];if(s==="\\"){let u=e[++o];if(u===void 0)throw new Error("trailing backslash");if(i||u&&"dDxXuUpPkKcC".includes(u))throw new b("feature","regex escape","grep: this regex escape is not supported with GNU semantics");!t&&u==="{"&&jf(e,o-1,!1)}else if(s==="["&&!i)r=Pa(e,o,n);else{if(i)continue;if(t&&s==="{")jf(e,o,!0);else if(t&&s==="("&&e[o+1]==="?")throw new b("feature","regex extension","grep: ECMAScript group extensions are not supported in ERE")}}}function Jw(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"&&/[1-9]/u.test(e[++t]??""))return!0;return!1}function zf(e,t,n=ee){let r=re(n),o=[],i=t.has("x"),s=t.has("w")&&!i;if(t.has("P")&&new Set(e).size>1)return{error:x("grep: -P only supports a single pattern",2)};for(let u of e){let a=!t.has("F")&&!t.has("P");a&&os(u,t.has("E"),r.multibyte);let l=a&&Jw(u),f=t.has("i")&&!t.has("P")&&!l,c=t.has("i")&&!f?"isu":"su",d;if(t.has("F"))d=f?Df(u,r):RegExp.escape(u);else if(t.has("P"))d=Bf(u);else if(t.has("E"))d=ns(f?Hn(u,r):u,r);else{let h=oo(f?Hn(u,r):u,r);if(h.error)return{error:x(`grep: ${h.error}`,2)};d=h.source}let p=d;if(a&&io(p))return{error:v("feature","grep","conditional backreference","grep: backreferences with conditional or repeated-empty captures are not supported",2)};s&&(d=`(?<!${r.assertions().word})(?:${d})(?!${r.assertions().word})`),i&&(d=`^(?:${d})$`);try{let h=new RegExp(a?Gn(Kw(d),!1,r):d,c);h.pcre=t.has("P"),h.localeSensitive=h.pcre?t.has("i")||s||zw(p)||/\\[dD]/u.test(p):t.has("i")&&l,h.folded=f,h.extendedC=f&&Tt.test(u),h.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(u);let m=t.has("F")||!Vf.test(u);if(h.binaryLiteral=!i&&!s&&m,m&&u.isWellFormed()&&(f||!t.has("i"))&&(h.literal={pattern:u,tables:r}),t.has("o")&&a&&!i){if(s||/\\[1-9]|\(\?/u.test(d))return{error:v("feature","grep","-o regex extent","grep: only-matching with backreferences, lookarounds or word constraints is not supported",2)};try{h.extent=new ct(Gn(d,!0,r),!1,null,r)}catch{return{error:v("feature","grep","-o regex extent","grep: POSIX match extent for this pattern is not supported",2)}}}o.push(h)}catch(h){if(!t.has("P")&&Qw(p,t))return{error:v("feature","grep","GNU regex syntax","grep: this GNU regular expression cannot be represented by the JavaScript matcher",2)};let m=t.has("F")?`fixed-string /${c}`:t.has("P")?`PCRE subset /${c}`:t.has("E")?`ERE / ECMAScript /${c}`:`BRE /${c}`;return{error:x(`grep: invalid pattern (${m}): ${h.message}`,2)}}}return{res:o}}function Qw(e,t){if(!t.has("E")&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return no(Gn(e,!0)),!0}catch(n){return!!n.gap}}function Hf({pattern:e,tables:t},n){return[...e].map(r=>(n?t.fold(r.codePointAt(0)):[r.codePointAt(0)]).map(i=>B(String.fromCodePoint(i))))}function Gf(e,t){return t.every(n=>n.literal?(n.literalMask??=Hf(n.literal,n.folded),!Zf(e,n.literalMask)):!1)}function Xf(e,t,n,r=ee){let o=re(r);return t.every(i=>(n||!Vf.test(i))&&i.isWellFormed()&&!Zf(e,Hf({pattern:i,tables:o},!1)))}function Zf(e,t){for(let n=0;n+t.length<=e.length;n++)if(Yf(e,n,t,0))return!0;return!1}function Yf(e,t,n,r){return r===n.length?!0:n[r].some(o=>o.every((i,s)=>e[t+s]===i)&&Yf(e,t+o.length,n,r+1))}var Vf=/[\\.^$*+?()[\]{}|]/u;function is(e,t,n,r=!1,o=ee){if(e.length===0)return null;if(e.some(a=>a.content===void 0))return v("feature","grep","binary input","grep: binary input detection and output are not supported",2);if(!r&&e.some(a=>a.content.includes("\0")&&(n||t.some(l=>!l.binaryLiteral||l.test(a.content)))))return v("feature","grep","binary input","grep: binary input detection and output are not supported",2);let i=/[\u0080-\u{10FFFF}]/u;if(o!==ee&&t.some(a=>a.localeSensitive||a.folded)&&(t.some(a=>a.unicodePattern)||e.some(a=>i.test(a.content))))return v("feature","grep","locale",`grep: matching non-ASCII text in the ${o} locale is not supported`,2);if(t.some(a=>a.extendedC)||t.some(a=>a.folded)&&e.some(a=>Tt.test(a.content)))return v("feature","grep","locale-sensitive regex","grep: case-insensitive matching over Cyrillic Extended-C letters is not supported",2);let s=t.filter(a=>a.localeSensitive);if(s.length===0||!(s.some(a=>a.unicodePattern)||e.some(a=>i.test(a.content))))return null;let u=s.some(a=>a.pcre)?"PCRE matching":"case-insensitive matching with backreferences";return v("feature","grep","non-ASCII regex semantics",`grep: ${u} on non-ASCII input is not supported`,2)}var ss=/[*?[]/u,us=/\P{ASCII}/u,ey=/[.+*?^${}()|[\]\\/]/u;function Me(e,t={}){try{return ty(e,t)}catch(n){throw n instanceof b?n:new b("feature","glob pattern",`unsupported glob pattern: ${n.message}`)}}function ty(e,t){let n="^",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"&&o+1<e.length){let s=e[o+1];n+=Kf(s,t.ignoreCase),o++}else if(i==="*"){for(;e[o+1]==="*";)o++;n+=".*"}else if(i==="?")n+=".";else if(i==="["){let s=Jf(e,o,t);if(s?.voided)return/^(?!)$/u;s?(n+=s.source,o=s.end,r||=s.nonAsciiRange):n+="\\["}else n+=Kf(i,t.ignoreCase)}return ry(new RegExp(n+"(?![\\s\\S])","us"),e,t,r)}function Kf(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:ey.test(e)?"\\"+e:e}function ny(e,t,n){let r=new RegExp(`[${e}]`,"ui"),o=new RegExp(`[${t}]`,"u"),i="";for(let s=0;s<128;s++){let u=String.fromCodePoint(s);(r.test(u)||o.test(u))&&(i+="\\x"+s.toString(16).padStart(2,"0"))}return`[${n?"^":""}${i}]`}function ry(e,t,n,r){let o=/[?[]/u.test(t),i=us.test(t);return{test(s){if(r||n.ignoreCase&&i||(o||n.ignoreCase)&&us.test(s))throw new b("feature","non-ASCII glob matching","locale-dependent glob matching of non-ASCII names is not supported");return e.test(s)}}}function Jf(e,t,n){let{ignoreCase:r}=n,o=t+1,i=!1;(e[o]==="!"||e[o]==="^")&&(i=!0,o++);let s="",u="",a=!1,l=!1,f=!1,c=!1,d="",p=0,h="",m=0;for(e[o]==="]"&&(s+="\\]",o++,a=!0,d="]");o<e.length&&e[o]!=="]";o++){let g=e[o];if(g==="["&&(e[o+1]==="."||e[o+1]==="="))throw new b("feature","glob collating or equivalence class","glob collating symbols and equivalence classes are not supported");if(g==="["&&e[o+1]===":"){let w=n.bash?oy(e,o):Kt(e,o,{unknown:"empty"});if(w){if(!n.bash&&w.body==="")throw new b("feature","glob character class","unknown POSIX classes in command filename patterns are not supported");l&&(c=!0),r?u+=w.body:s+=w.body,o=w.end-1,a=!1,l=!1;continue}if(n.bash)continue}if(g==="-"&&a)m=p,h=d,s+="-",l=!0,a=!1;else{let w=g==="\\"&&o+1<e.length?e[++o]:g;p=s.length,d=w,l&&us.test(h+w)&&(f=!0),l&&w.codePointAt(0)<h.codePointAt(0)?s=s.slice(0,m):s+=/[\]\\^[-]/u.test(w)?`\\${w}`:w,a=!l,l=!1}}return o>=e.length?null:c?{voided:!0,end:o}:{source:r?ny(s,u,i):`[${i?"^":""}${s}]`,end:o,nonAsciiRange:f}}function oy(e,t){let n=e.indexOf(":]",t+2);if(n===-1)return null;let r=e.slice(t+2,n).replace(/\\([\s\S]|$)/gu,"$1");return{body:r==="ascii"?"\\x00-\\x7F":It[r]??"",end:n+2}}function Qf(e,t){return Me(t).test(e)}function ec(e){let{value:t,mask:n}=e;if(n===null)return ss.test(t);for(let r=0;r<t.length;r++)if(n[r]==="0"&&ss.test(t[r]))return!0;return!1}function Xn(e){let t=n=>!e.mask||e.mask[n]==="0";for(let n=0;n<e.value.length;n++){let r=e.value[n];if(t(n)){if(r==="\\")n++;else if(r==="[")n=iy(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]==="("&&t(n+1))return!0}}return!1}function iy(e,t,n){let{value:r}=e,o=t+1;for(/[!^]/u.test(r[o])&&n(o)&&o++,r[o]==="]"&&n(o)&&o++;o<r.length;o++)if(n(o))if(r[o]==="\\")o++;else{if(r[o]==="]")return o;if(r[o]==="["&&/[.:=]/u.test(r[o+1])&&n(o+1)){let i=r.indexOf(r[o+1]+"]",o+2);i!==-1&&(o=i+1)}}return t}var sy=/[*?[\]^!\\:.=-]/u;function on(e){let{value:t,mask:n}=e;if(n===null)return t;let r="";for(let o=0;o<t.length;o++){let i=t[o];r+=n[o]!=="0"&&sy.test(i)?"\\"+i:i}return r}function tc(e,t){let n=on(e),r=n.match(/[^/]+|\/+/gu)??[],o=Jt(),i=new Set,s=[{path:"",marks:null}],u;try{for(let l=0;l<r.length;l++){let f=r[l];if(f.startsWith("/")||!ss.test(f)){s=s.map(c=>({...c,path:c.path+ay(f)}));continue}s=ly(s,f,l===r.length-1,t,i)}let a=s.filter(l=>E(t.cwd,l.path,t.fs,{follow:!1}).path!==null);for(let l of a)for(let f of l.marks??[])o.add(f);return u=a.filter(l=>l.marks===null).map(l=>l.path).sort(j),u}finally{if(u===void 0)for(let a of i)o.add(a);o.emit(t.notes,"glob","",` while expanding ${JSON.stringify(n)}`),u?.length===0&&r.some(uy)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function uy(e){for(let t=0;t<e.length;t++)if(e[t]==="\\")t++;else{if(e[t]==="*"||e[t]==="?")return!0;if(e[t]==="[")try{if(Jf(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var ay=e=>e.replace(/\\(.)/gu,"$1");function ly(e,t,n,r,o){let i=Me(t,{bash:!0}),s=t.startsWith(".")||t.startsWith("\\."),u=[];for(let a of e){let l=E(r.cwd,a.path||".",r.fs).path;if(!r.fs.isDir(l))continue;let{dirs:f,files:c,links:d}=r.fs.listDir(l),p=n?d:d.filter(h=>r.fs.isDir(E(l,h,r.fs).path));for(let h of n?[...f,...c,...p]:[...f,...p]){let m=!s&&h.startsWith(".");if(!m&&a.marks===null)i.test(h)&&u.push({path:a.path+h,marks:null});else if(fy(i,h)){if(!m){u.push({path:a.path+h,marks:a.marks});continue}let g=Z(l,h);o.add(g),u.push({path:a.path+h,marks:[...a.marks??[],g]})}}}return u}function fy(e,t){try{return e.test(t)}catch{return!0}}var ls=(e,t)=>e.some(n=>n.test(t)),fs=()=>({stdout:"",stderr:"",exitCode:1});function cs(e,t,n,r){let o=0;if(r===1/0){for(let s of he(e))ls(t,s)!==n&&o++;return o}let i=0;for(;i<e.length&&o<r;){let s=e.indexOf(`
|
|
48
|
-
`,i);s<0&&(s=e.length),
|
|
45
|
+
`)}function iw(e,{bytes:t,valid:n}){let r=me(t),o=n?"":`${e}: invalid input
|
|
46
|
+
`;if(r!==void 0&&n)return F(r);let i=r===void 0?{fd:1,bytes:t}:{fd:1,text:r};return{stdout:r??"",stderr:o,exitCode:n?0:1,events:[...t.length?[i]:[],...o?[{fd:2,text:o}]:[]]}}var mf=[{},{},{}],gf=[[..."ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],[..."0123456789ABCDEFGHIJKLMNOPQRSTUV"],[..."0123456789ABCDEFGHJKMNPQRSTVWXYZ"]],Dt="Invalid character in base32 input",Hi="Invalid base32 padding",sw="Invalid base32 length",Kr="Invalid last chunk",uw=Ot;function wf(e,t,n){Zt(e);let r=Math.floor(e.length/5),o=r*5,i="",s=0,u=gf[t],a=mf[t];if(!a.pairs)if(a.pairs=[],Oe){a.codepairs=new Uint16Array(1024);let p=a.codepairs,h=new Uint8Array(p.buffer,p.byteOffset,p.byteLength);for(let m=0;m<32;m++){let g=u[m].charCodeAt(0);for(let w=0;w<32;w++)h[m<<6|w<<1]=h[w<<6|(m<<1)+1]=g}}else{let p=a.pairs;for(let h=0;h<32;h++)for(let m=0;m<32;m++)p.push(`${u[h]}${u[m]}`)}let{pairs:l,codepairs:f}=a;if(Oe){let p=new Uint16Array(r*4);for(let h=0;s<o;s+=5){let m=e[s],g=e[s+1],w=e[s+2],b=e[s+3],k=e[s+4],S=m<<2|g>>6,I=(g&63)<<4|w>>4,M=(w&15)<<6|b>>2,C=(b&3)<<8|k;p[h]=f[S],p[h+1]=f[I],p[h+2]=f[M],p[h+3]=f[C],h+=4}i=Cr(p)}else if(uw)for(;s<o;s+=5){let p=e[s],h=e[s+1],m=e[s+2],g=e[s+3],w=e[s+4],b=p<<2|h>>6,k=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,I=(g&3)<<8|w;i+=`${l[b]}${l[k]}${l[S]}${l[I]}`}else for(;s<o;s+=5){let p=e[s],h=e[s+1],m=e[s+2],g=e[s+3],w=e[s+4],b=p<<2|h>>6,k=(h&63)<<4|m>>4,S=(m&15)<<6|g>>2,I=(g&3)<<8|w;i+=l[b],i+=l[k],i+=l[S],i+=l[I]}let c=0,d=3;for(;s<e.length;s++){let p=e[s];i+=u[c|p>>d],d>=5&&(d-=5,i+=u[p>>d&31]),c=p<<5-d&31,d+=3}return d!==3&&(i+=u[c]),n&&(i+=["","======","====","===","="][e.length-o]),i}var aw=Ae?128:65536;function bf(e,t){let n=e.length;for(;e[n-1]==="=";)n--;let r=e.length-n,o=n%8,i=n-o;if(![0,2,4,5,7].includes(o))throw new SyntaxError(sw);if(r>7||r!==0&&e.length%8!==0)throw new SyntaxError(Hi);let s=gf[t],u=mf[t];if(!u.fromMap){u.fromMap=new Int8Array(aw).fill(-1);let g=u.fromMap;s.forEach((w,b)=>{g[w.charCodeAt(0)]=g[w.toLowerCase().charCodeAt(0)]=b}),t===2&&(g[73]=g[76]=g[105]=g[108]=g[49],g[79]=g[111]=g[48])}let a=u.fromMap,l=new Uint8Array(Math.floor(n*5/8)),f=0,c=0;if(Ae){let g=Ir(e,Dt);for(;c<i;c+=8){let w=g[c],b=g[c+1],k=g[c+2],S=g[c+3],I=g[c+4],M=g[c+5],C=g[c+6],H=g[c+7],Y=a[w]<<15|a[b]<<10|a[k]<<5|a[S],D=a[I]<<15|a[M]<<10|a[C]<<5|a[H];if(Y<0||D<0)throw new SyntaxError(Dt);l[f]=Y>>12,l[f+1]=Y>>4&255,l[f+2]=Y<<4&255|D>>16,l[f+3]=D>>8&255,l[f+4]=D&255,f+=5}}else for(;c<i;c+=8){let g=e.charCodeAt(c),w=e.charCodeAt(c+1),b=e.charCodeAt(c+2),k=e.charCodeAt(c+3),S=e.charCodeAt(c+4),I=e.charCodeAt(c+5),M=e.charCodeAt(c+6),C=e.charCodeAt(c+7),H=a[g]<<15|a[w]<<10|a[b]<<5|a[k],Y=a[S]<<15|a[I]<<10|a[M]<<5|a[C];if(H<0||Y<0)throw new SyntaxError(Dt);l[f]=H>>12,l[f+1]=H>>4&255,l[f+2]=H<<4&255|Y>>16,l[f+3]=Y>>8&255,l[f+4]=Y&255,f+=5}if(o<2)return l;let d=a[e.charCodeAt(c++)]<<5|a[e.charCodeAt(c++)];if(d<0)throw new SyntaxError(Dt);if(l[f++]=d>>2,o<4){if(d&3)throw new SyntaxError(Kr);return l}let p=a[e.charCodeAt(c++)]<<5|a[e.charCodeAt(c++)];if(p<0)throw new SyntaxError(Dt);if(l[f++]=d<<6&255|p>>4,o<5){if(p&15)throw new SyntaxError(Kr);return l}let h=a[e.charCodeAt(c++)];if(h<0)throw new SyntaxError(Dt);if(l[f++]=p<<4&255|h>>1,o<7){if(h&1)throw new SyntaxError(Kr);return l}let m=a[e.charCodeAt(c++)]<<5|a[e.charCodeAt(c++)];if(m<0)throw new SyntaxError(Dt);if(l[f++]=h<<7&255|m>>3,m&7)throw new SyntaxError(Kr);return l}function yf(e,t,n,r,o){if(typeof e!="string")throw new TypeError(Yt);if(o!==null&&Or(o),n===!0){if(e.length%8!==0)throw new SyntaxError(Hi)}else if(n===!1){if(e.endsWith("="))throw new SyntaxError("Did not expect padding in base32 input")}else if(n!=="both")throw new TypeError("Invalid padding option");return et(bf(e,t),r)}var Gi=e=>(t,n)=>{if(!n)return yf(t,e,"both","uint8",null);let{format:r="uint8",padding:o="both",...i}=n;return yf(t,e,o,r,i)},xf=Gi(0),PA=Gi(1),DA=Gi(2),kf=(e,{padding:t=!1}={})=>wf(e,0,t);var fw="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",jn=8,cw=Object.freeze([2,4,5,7,8]),vf=Vr("base32",{encode:e=>kf(e,{padding:!0}),decode:pw}),dw=/[a-z]/u;function pw(e,t=!1){let n=e.replace(t?/[^A-Z2-7=]/gu:/\n/gu,"");try{let r=xf(n,{padding:!0});if(!dw.test(n))return{bytes:r,valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r}return hw(n)}function hw(e){let t=new Uint8Array(Math.ceil(e.length/jn)*5),n=0,r=0,o=!0;for(;r<e.length;){if(e.length-r<jn){o=!1;break}let i=e.slice(r,r+jn),s=/^[A-Z2-7]*/u.exec(i)[0];if(n+=mw(i,s,t.subarray(n)),!cw.includes(s.length)||i.slice(s.length)!=="=".repeat(jn-s.length)){o=!1;break}r+=jn}return{bytes:t.subarray(0,n),valid:o}}function mw(e,t,n){let r=0,o=0,i=0;for(let s of t)o=o<<5|fw.indexOf(s),r+=5,!(r<8)&&(r-=8,n[i++]=o>>r&255);return i}var Xi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Sf=Vr("base64",{encode:hi,decode:gw});function gw(e,t=!1){let n=e.replace(t?/[^A-Za-z0-9+/=]/gu:/\n/gu,"");try{return{bytes:Nn(n,{padding:!0}),valid:!0}}catch(r){if(!(r instanceof SyntaxError))throw r;return ww(n)}}function ww(e){let t=new Uint8Array(Math.ceil(e.length/4)*3),n=/[A-Za-z0-9+/]*/uy,r=0,o=0,i=!0;for(;o<e.length;){n.lastIndex=o;let s=n.exec(e)[0].length,u=s-s%4;if(u){let p=Nn(e.slice(o,o+u));t.set(p,r),r+=p.length,o+=u}if(o===e.length)break;let a=s%4;if(a<2){i=!1;break}let l=Xi.indexOf(e[o]),f=Xi.indexOf(e[o+1]),c=a===3?Xi.indexOf(e[o+2]):0;t[r++]=l<<2|f>>4,a===3&&(t[r++]=f<<4|c>>2);let d=4-a;if(o+=a,e.slice(o,o+d)!=="=".repeat(d)){i=!1;break}o+=d}return{bytes:t.subarray(0,r),valid:i}}var bw=["n","N","i","s","w","F","v","l","c","q","u","a","H","I"],yw=["line-number","no-line-number","ignore-case","case-sensitive","word-regexp","fixed-strings","invert-match","files-with-matches","files-without-match","count","quiet","hidden","no-ignore","no-heading","with-filename","no-filename","text","unrestricted"],$f={short:bw,long:yw,valueShort:["A","B","C"],valueLong:["after-context","before-context","context"],repeatable:["e","regexp"]},xw=new Map(Object.entries({"line-number":"n","no-line-number":"N","ignore-case":"i","case-sensitive":"s","word-regexp":"w","fixed-strings":"F","invert-match":"v","files-with-matches":"l","files-without-match":"L",count:"c",quiet:"q",text:"a",unrestricted:"u","with-filename":"H","no-filename":"I",regexp:"e","after-context":"A","before-context":"B",context:"C"})),kw=new Set(["no-heading","no-ignore"]),Wn=(e,t)=>new y("feature",e,`rg: ${t}`);function Nf(e){let t={patterns:[],context:[],mode:null,showName:null,ignoreCase:!1,lineNumbers:!1,word:!1,literal:!1,invert:!1,quiet:!1,text:!1,hidden:!1,unrestricted:0};for(let{name:o,value:i}of e.order)kw.has(o)||vw(t,xw.get(o)??o,i,Zi(o));let n=o=>t.context.findLast(([i])=>i===o)?.[1],r=o=>t.context.findLast(([i])=>i===o)?.[2]??"-"+o;if(t.after=Ef(n("A")??n("C"),n("A")===void 0?r("C"):r("A")),t.before=Ef(n("B")??n("C"),n("B")===void 0?r("C"):r("B")),t.unrestricted>=2&&(t.hidden=!0),t.unrestricted>=3)throw Wn("-uuu","searching binary files is not supported");return t}function vw(e,t,n,r){switch(t){case"i":e.ignoreCase=!0;return;case"s":e.ignoreCase=!1;return;case"n":e.lineNumbers=!0;return;case"N":e.lineNumbers=!1;return;case"l":case"L":case"c":e.mode=t;return;case"H":e.showName="H";return;case"I":e.showName="h";return;case"w":e.word=!0;return;case"F":e.literal=!0;return;case"v":e.invert=!0;return;case"q":e.quiet=!0;return;case"a":e.text=!0;return;case"e":e.patterns.push(n);return;case"hidden":e.hidden=!0;return;case"u":e.unrestricted++;return;case"A":case"B":case"C":e.context.push([t,n,r]);return;default:throw Wn(Zi(t),`${Zi(t)} is not supported`)}}function Ef(e,t){if(e===void 0)return 0;if(!/^\d+$/u.test(e))throw Wn(`${t} value`,`error parsing flag ${t}: value is not a valid number`);return Number(e)}var Zi=e=>(e.length===1?"-":"--")+e;function Af(e,t){return t?e.flatMap(n=>["-e",n]):["-e",e.length===1?e[0]:e.map(n=>`(?:${n})`).join("|")]}var Sw=[[/\\[1-9]/u,"backreference"],[/\(\?<?[=!]/u,"look-around"],[/\\[QE]/u,String.raw`\Q…\E literal span`]];function Ew(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`
|
|
47
|
+
`)return!0;if(n!=="\\")continue;let r=e[t+1];if(r==="n"||r==="x"&&/^x\{?0*a\}?/iu.test(e.slice(t+1)))return!0;t++}return!1}function Of(e,t){if(!t)for(let n of e){for(let[r,o]of Sw)if(r.test(n))throw Wn(o,`${o} is not supported; ripgrep's regex engine rejects it too`);if(Ew(n))throw Wn("newline in a pattern","a newline in a pattern is not supported; ripgrep rejects one outside multiline mode")}}var $=class extends Error{constructor(t,n=null,r=null){super(t),this.line=n,this.gap=r}},Cf=new Set(["BEGIN","END","BEGINFILE","ENDFILE","function","func","if","else","while","for","do","break","continue","next","nextfile","exit","return","delete","in","getline","print","printf","switch","case","default"]),Yi={__proto__:null,length:[0,1],substr:[2,3],index:[2,2],split:[2,3],sub:[2,3],gsub:[2,3],gensub:[3,4],match:[2,3],sprintf:[1,1/0],sin:[1,1],cos:[1,1],atan2:[2,2],exp:[1,1],log:[1,1],sqrt:[1,1],int:[1,1],rand:[0,0],srand:[0,1],tolower:[1,1],toupper:[1,1],close:[1,2],fflush:[0,1],systime:[0,0],strtonum:[1,1],and:[2,1/0],or:[2,1/0],xor:[2,1/0],lshift:[2,2],rshift:[2,2],compl:[1,1],typeof:[1,1],isarray:[1,1]},Jr=new Map([["system","system() is not supported: this terminal runs no processes"],["strftime","strftime() is not supported (gawk extension)"],["mktime","mktime() is not supported (gawk extension)"],["asort","asort() is not supported (gawk extension)"],["asorti","asorti() is not supported (gawk extension)"],["patsplit","patsplit() is not supported (gawk extension)"]]),If=new Set([...Object.keys(Yi),...Jr.keys()]),qn=5e6,Vi=100,Ce=1e6,Qr="this terminal runs no processes";function eo(e,t,n){switch(e){case"+":return t+n;case"-":return t-n;case"*":return t*n;case"/":return t/n;case"%":return t%n;default:return t**n}}var Tf={__proto__:null,n:10,t:9,r:13,f:12,v:11,a:7,b:8},$w='^$.[]|()*+?{}\\/"',Ki=1e3,Ff=e=>e!==void 0&&/[0-9a-fA-F]/u.test(e),Lf=e=>e!==void 0&&e>="0"&&e<="7",Ji=class{constructor(t,n,r,o){this.src=t,this.i=0,this.warn=n,this.tables=r,this.ignoreCase=o,this.groups=0}fail(t){throw new $(`invalid regex /${this.src}/: ${t}`)}peek(){return this.src[this.i]}literal(){let t=this.src.codePointAt(this.i);return this.i+=Ue(t),this.charNode(t)}charNode(t){let n=this.ignoreCase?this.tables.fold(t):[t];return n.length===1?{type:"char",code:t}:{type:"set",negate:!1,items:n.map(r=>[r,r])}}parse(){return this.alternation(0)}alternation(t){let n=[this.concatenation(t)];for(;this.peek()==="|";)this.i++,n.push(this.concatenation(t));return n.length===1?n[0]:{type:"alt",nodes:n}}concatenation(t){let n=[];for(;!this.endsConcatenation(t);)n.push(this.quantified(this.atom(n.length===0,t)));return n.length===1?n[0]:{type:"cat",nodes:n}}endsConcatenation(t){let n=this.peek();return n===void 0||n==="|"||n===")"&&t>0}quantified(t){let n=t;for(;;){let r=this.peek();if(r==="*"){this.i++,n={type:"rep",node:n,min:0,max:null};continue}if(r==="+"){this.i++,n={type:"rep",node:n,min:1,max:null};continue}if(r==="?"){this.i++,n={type:"rep",node:n,min:0,max:1};continue}if(r==="{"){let o=/^\{(\d*)(?:(,)(\d*))?\}/u.exec(this.src.slice(this.i));if(!o&&/^\{[\d,]*\}/u.test(this.src.slice(this.i))&&this.fail("invalid content of {}"),!o||o[1]===""&&o[2]===void 0)return n;let i=o[1]===""?0:Number(o[1]),s=o[2]===void 0?i:o[3]===""?null:Number(o[3]);if(s!==null&&s<i&&this.fail(`invalid interval {${i},${s}}`),i>Ki||s!==null&&s>Ki)throw new $(`interval count above ${Ki} is not supported`,null,"regex interval limit");this.i+=o[0].length,n={type:"rep",node:n,min:i,max:s};continue}return n}}atom(t,n){let r=this.peek();if(r==="("){this.i++;let o=++this.groups,i=this.alternation(n+1);return this.peek()!==")"&&this.fail("missing `)`"),this.i++,{type:"group",index:o,node:i}}return r==="["?this.bracket():r==="\\"?this.escape():(this.i++,r==="."?{type:"any"}:r==="^"||r==="$"?{type:"assert",kind:r}:((r==="*"||r==="+"||r==="?")&&!t&&this.fail(`unexpected \`${r}\``),this.i--,this.literal()))}escape(){this.i++;let t=this.peek();return t===void 0&&this.fail("trailing backslash"),this.i++,t==="y"?{type:"assert",kind:"y"}:t==="<"||t===">"||t==="B"?{type:"assert",kind:t}:t==="`"?{type:"assert",kind:"^"}:t==="'"?{type:"assert",kind:"$"}:t==="s"||t==="S"?{type:"set",negate:t==="S",items:this.tables.ranges("space")}:t==="w"||t==="W"?{type:"set",negate:t==="W",items:this.tables.ranges("word")}:(t==="b"&&this.warn?.("regexp escape sequence `\\b' is a backspace here, as in gawk; `\\y' is the word boundary"),this.charNode(this.escapedCode(t,!0)))}escapedCode(t,n){if(t in Tf)return Tf[t];if(Lf(t)){let o=t;for(;o.length<3&&Lf(this.peek());)o+=this.src[this.i++];return _f(o,8)}if(t==="x"&&Ff(this.peek())){let o="";for(;o.length<2&&Ff(this.peek());)o+=this.src[this.i++];return _f(o,16)}let r=this.src.codePointAt(this.i-1);return!$w.includes(t)&&n&&this.warn?.(`regexp escape sequence \`\\${String.fromCodePoint(r)}' is not a known regexp operator`),this.i+=Ue(r)-1,r}bracket(){this.i++;let t=!1;this.peek()==="^"&&(t=!0,this.i++);let n=[],r=!0;for(;;){this.i>=this.src.length&&this.fail("unterminated bracket expression");let o=this.peek();if(o==="]"&&!r){this.i++;break}if(r=!1,o==="["&&this.src[this.i+1]===":"){let s=this.src.indexOf(":]",this.i+2);if(s!==-1){let u=this.src.slice(this.i+2,s),a=this.tables.ranges(this.ignoreCase?Pr(u):u);a===void 0&&this.fail(`invalid character class \`[:${u}:]\``),n.push(...a),this.i=s+2;continue}}let i=this.bracketChar();if(this.peek()==="-"&&this.src[this.i+1]!=="]"&&this.src[this.i+1]!==void 0){this.i++;let s=this.bracketChar(),u=this.ignoreCase?this.tables.foldRange(i,s):s<i?null:[[i,s]];u===null&&this.fail("invalid range end"),n.push(...u)}else this.ignoreCase?n.push(...this.tables.fold(i).map(s=>[s,s])):n.push([i,i])}return{type:"set",negate:t,items:n}}bracketChar(){let t=this.peek();if(t==="["&&(this.src[this.i+1]==="."||this.src[this.i+1]==="=")){let r=this.src.indexOf(this.src[this.i+1]+"]",this.i+2);if(r!==-1&&r>this.i+2){Array.from(this.src.slice(this.i+2,r)).length!==1&&this.fail("invalid collation character");let o=this.src.codePointAt(this.i+2);return this.i=r+2,o}}if(t==="\\"){this.i++,this.peek()===void 0&&this.fail("trailing backslash");let r=this.src[this.i++];return this.escapedCode(r,!1)}let n=this.src.codePointAt(this.i);return this.i+=Ue(n),n}};function no(e,t=null,n=re(ee),r=!1){let o=new Ji(e,t,n,r);return{ast:o.parse(),groups:o.groups}}function _f(e,t){let n=Number.parseInt(e,t);if(n>=128)throw new $("non-ASCII regex byte escapes are not supported",null,"regex byte escapes");return n}var Nw=e=>`\\u{${e.toString(16)}}`,to=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122?String.fromCodePoint(e):Nw(e);function Aw(e,t){if(e==="^"||e==="$")return e;let n=t.assertions();return e==="y"?n.boundary:e==="B"?n.inside:n[e]}function Qi(e,t=re(ee)){let n=r=>Qi(r,t);switch(e.type){case"char":return to(e.code);case"any":return".";case"set":return`[${e.negate?"^":""}${e.items.map(([r,o])=>r===o?to(r):`${to(r)}-${to(o)}`).join("")}]`;case"assert":return Aw(e.kind,t);case"group":return`(${n(e.node)})`;case"cat":return e.nodes.map(n).join("");case"alt":return`(?:${e.nodes.map(n).join("|")})`;case"rep":{let r=`(?:${n(e.node)})`;return e.max===null?e.min===0?`${r}*`:e.min===1?`${r}+`:`${r}{${e.min},}`:e.min===0&&e.max===1?`${r}?`:`${r}{${e.min},${e.max}}`}default:throw new $(`internal: unknown regex node ${e.type}`)}}var Ow=5e4;function Cw(e,t){let n=r=>{for(let o=0;o<e.length;o++)if(r>=e[o][0]&&r<=e[o][1])return!0;return!1};return t?r=>!n(r):n}function Rf(e,t=re(ee)){let n=[],r=l=>{if(n.length>=Ow)throw new $("regex too large",null,"regex state limit");return n.push(l),n.length-1};function o(l,f){switch(l.type){case"char":return r({op:"char",codes:[l.code],next:f});case"any":return r({op:"any",next:f});case"set":return r({op:"set",test:Cw(l.items,l.negate),next:f});case"assert":return r({op:"assert",kind:l.kind,next:f});case"group":return o(l.node,f);case"cat":{let c=f;for(let d=l.nodes.length-1;d>=0;d--)c=o(l.nodes[d],c);return c}case"alt":{let c=l.nodes.map(p=>o(p,f)),d=c.at(-1);for(let p=c.length-2;p>=0;p--)d=r({op:"split",x:c[p],y:d});return d}case"rep":return i(l,f);default:throw new $(`internal: unknown regex node ${l.type}`)}}function i(l,f){let c=f;if(l.max===null){let d=r({op:"split",x:-1,y:f});n[d].x=o(l.node,d),c=d}else for(let d=l.max-l.min;d>0;d--)c=r({op:"split",x:o(l.node,c),y:f});for(let d=0;d<l.min;d++)c=o(l.node,c);return c}let s=o(e,r({op:"match"})),u="",a=s;for(;n[a].op==="char"&&n[a].codes.length===1&&n[a].codes[0]<128;)u+=String.fromCodePoint(n[a].codes[0]),a=n[a].next;return(n[a].op!=="match"||u==="")&&(u=null),{states:n,start:s,literal:u,isWord:l=>t.has("word",l),gen:new Int32Array(n.length).fill(-1),stamp:0}}function Iw(e,t){if(t<=0)return-1;let n=e.codePointAt(t-1);return n>=56320&&n<=57343&&t>=2?e.codePointAt(t-2):n}function Tw(e,t,n,r){if(e==="^")return n===0;if(e==="$")return n===t.length;let o=r(Iw(t,n)),i=n<t.length&&r(t.codePointAt(n));return e==="y"?o!==i:e==="B"?o===i:e==="<"?!o&&i:o&&!i}function Fw(e,t){return e.op==="char"?e.codes.includes(t):e.op==="any"?!0:e.test(t)}function Mf(e,t,n){if(e.literal!==null&&Number.isInteger(n)&&n>=0&&n<=t.length&&!Object.is(n,-0)){let p=t.indexOf(e.literal,n);return p<0?null:{start:p,end:p+e.literal.length}}let{states:r,gen:o}=e,i=t.length,s=[],u=(p,h,m,g,w)=>{for(s.push(h);s.length>0;){let b=s.pop();if(o[b]===w)continue;o[b]=w;let k=r[b];k.op==="split"?s.push(k.y,k.x):k.op==="assert"?Tw(k.kind,t,g,e.isWord)&&s.push(k.next):p.push(b,m)}},a=[],l=[],f=null,c=n,d=++e.stamp;for(;;){f===null&&u(a,e.start,c,c,d);let p=c<i?t.codePointAt(c):-1,h=Ue(p);if(a.length===0){if(f!==null||c>=i)break;c+=h,d=++e.stamp;continue}let m=++e.stamp;for(let g=0;g<a.length;g+=2){let w=a[g],b=a[g+1];if(f!==null&&b>f.start)continue;let k=r[w];if(k.op==="match"){(f===null||b<f.start||b===f.start&&c>f.end)&&(f={start:b,end:c});continue}p!==-1&&Fw(k,p)&&u(l,k.next,b,c+h,m)}if(a.length=0,[a,l]=[l,a],d=m,c>=i)break;c+=h}return f}var ro=new Map,ct=class{constructor(t,n,r,o=re(ee)){let{ast:i,groups:s}=no(t,r,o,n);this.src=t,this.ignoreCase=n,this.tables=o,this.groupCount=s,this.source=Qi(i,o),this.flags="su";try{this.js=new RegExp(this.source,this.flags)}catch(u){throw new $(`cannot compile regex /${t}/: ${u.message}`,null,"regex engine limit")}this.ast=i,this.nfa=null,this.capture=null,this.captureShape=Pf(i)}test(t){return this.checkCase(t),this.js.test(t)}checkCase(t){if(this.ignoreCase&&Tt.test(t+this.src))throw new $("case-insensitive matching over Cyrillic Extended-C letters is not supported",null,"locale-sensitive regex")}search(t,n=0){return this.checkCase(t),this.nfa===null&&(this.nfa=Rf(this.ast,this.tables)),Mf(this.nfa,t,n)}groups(t,n,r){if(this.captureShape.unsafe)throw new $("capture extraction across repeated or alternative groups is not supported",null,"regex capture semantics");let o=this.capture??=new RegExp(this.source,this.flags+"dy");o.lastIndex=n;let i=o.exec(t);if(!i||i.index!==n||n+i[0].length!==r){let s=Array.from(t.slice(r)).length,u=new RegExp(`(?:${this.source})(?=.{${s}}(?![^]))`,this.flags+"dy");u.lastIndex=n,i=u.exec(t)}if(!i)throw new $("capture extraction for this match is not supported",null,"regex capture semantics");return i.indices.map((s,u)=>s===void 0?void 0:{text:i[u],start:s[0],end:s[1]})}};function Pf(e){let n=(e.nodes??(e.node?[e.node]:[])).map(Pf),r=n.reduce((s,u)=>s+u.groups,e.type==="group"?1:0),o=e.type==="assert"||(e.type==="group"||e.type==="cat")&&n.every(s=>s.nullable)||e.type==="alt"&&n.some(s=>s.nullable)||e.type==="rep"&&(e.min===0||n[0].nullable),i=e.type==="rep"&&(e.max===null||e.max>1)&&(r>1||r>0&&n[0].nullable);return{groups:r,nullable:o,unsafe:i||e.type==="alt"&&r>0||n.some(s=>s.unsafe)}}function Re(e,t=!1,n=null,r=re(ee)){let o=(t?"i":"c")+r.name+"\0"+e,i=ro.get(o);if(i)return i;ro.size>=500&&ro.clear();let s=new ct(e,t,n,r);return ro.set(o,s),s}function es(e,t,n){for(;;){let r=t.search(e,n);if(!r||r.start!==r.end)return r;if(r.end>=e.length)return null;n=r.end+Le(e,r.end)}}function ts(e,t){let n=[],r=0;for(;;){let o=es(e,t,r);if(!o)break;n.push(e.slice(r,o.start)),r=o.end}return n.push(e.slice(r)),n}function zn(e,t,n,r){let o=r!=="first",i=e.length,s="",u=0,a=-1,l=0;for(;u<=i;){let f=t.search(e,u);if(!f)break;let c=f.start===f.end;if(c&&f.start===a&&r!=="nth"){if(f.start>=i)break;let p=Le(e,f.start);s+=e.slice(u,f.start+p),u=f.start+p;continue}l++;let d=n(f.start,f.end,l);if(s+=e.slice(u,f.start)+(d===null?e.slice(f.start,f.end):d),a=f.end,c){if(f.end>=i){u=i;break}let p=Le(e,f.end);s+=e.slice(f.end,f.end+p),u=f.end+p}else u=f.end;if(!o)break}return{out:s+e.slice(u),count:l}}function oo(e,t){let n="(){}+?|",r=!1,o=0,i=!1,s="";for(let u=0;u<e.length;u++){let a=e[u];if(i){if(a==="["&&(e[u+1]==="."||e[u+1]==="="))throw new y("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");if(a==="["){let l=Kt(e,u,{classes:t});if(l){s+=l.body,u=l.end-1;continue}}s+=a,a==="]"&&(i=!1,r=!0);continue}if(a==="["){s+=a,i=!0,e[u+1]==="^"&&(s+="^",u++),e[u+1]==="]"&&(s+="\\]",u++);continue}if(a==="\\"){let l=e[++u];if(l===void 0)return{error:"trailing backslash (\\)"};if(n.includes(l)){if((l==="+"||l==="?")&&!r){s+="\\"+l,r=!0;continue}if(l==="("&&o++,l===")"&&o--===0)return{error:"Unmatched ) or \\)"};(l==="("||l==="|")&&(r=!1),(l===")"||l==="}")&&(r=!0),s+=l}else s+="^$\\.*[]/bBsSwW<>`'123456789".includes(l)?"\\"+l:l,r=!"bB<>`'".includes(l);continue}if(a==="*"){s+=r?"*":"\\*",r=!0;continue}if(a==="^"){r=!Lw(e,u),s+=r?"\\^":"^";continue}if(a==="$"){r=!(u===e.length-1||e[u+1]==="\\"&&(e[u+2]===")"||e[u+2]==="|")),s+=r?"\\$":"$";continue}s+=n.includes(a)?"\\"+a:a,r=!0}return o>0?{error:"Unmatched ( or \\("}:{source:s}}function Lw(e,t){if(t===0)return!0;if(t<2||e[t-2]!=="\\"||e[t-1]!=="("&&e[t-1]!=="|")return!1;let n=0;for(let r=t-3;r>=0&&e[r]==="\\";r--)n++;return n%2===0}function io(e){if(!/\\[1-9]/u.test(e))return!1;let t=new Set,n=[],r=new Set,o=!1,i=0,s=!1,u=[],a=new Set,l=!1;for(let f=0;f<e.length;f++){let c=e[f];if(c==="\\"){let d=e[++f];if(!o&&/[1-9]/u.test(d??"")){let p=Number(d);if(!t.has(p))throw new Error("Invalid back reference");(!a.has(p)||r.has(p))&&(s=!0)}u=[];continue}if(o){c==="]"&&(o=!1);continue}if(c==="["){o=!0,u=[];continue}if(c==="(")n.push({id:++i,entry:new Set(a),branches:[],start:f}),u=[];else if(c==="|"){let d=n.at(-1);d&&d.branches.push(a),a=new Set(d?.entry),u=[]}else if(c===")"){let d=n.pop();if(!d)continue;a=d.branches.reduce((p,h)=>p.intersection(h),a),a.add(d.id),t.add(d.id),u=[...a.difference(d.entry)],l=_w(e.slice(d.start,f+1))}else if(c==="*"||c==="?"||c==="+"){if(c!=="?"&&l)for(let d of u)r.add(d);if(c!=="+")for(let d of u)a.delete(d)}else if(c==="{"){let d=/^\{(\d*)(?:,(\d*))?\}/u.exec(e.slice(f));if(d){Number(d[1])===0&&(a=a.difference(new Set(u)));let p=d[2]===void 0?Number(d[1]):d[2]===""?1/0:Number(d[2]);l&&p>1&&u.forEach(h=>r.add(h)),f+=d[0].length-1}else u=[]}else u=[]}return s}function _w(e){try{return new RegExp(`^(?:${e})$`,"su").test("")}catch{return!0}}var Rw="bBsSwW";function Hn(e,t){let n="";for(let r=0;r<e.length;){let o=e[r];if(o==="["){let l=Mw(e,r,t);n+=l.text,r=l.end;continue}let i=o==="\\",s=e.codePointAt(r+(i?1:0)),u=(i?1:0)+Ue(s),a=i&&Rw.includes(e[r+1])?null:t.fold(s);n+=a===null||a.length===1?e.slice(r,r+u):`[${String.fromCodePoint(...a)}]`,r+=u}return n}function Df(e,t){let n="";for(let r of e){let o=t.fold(r.codePointAt(0));n+=o.length===1?RegExp.escape(r):`[${String.fromCodePoint(...o)}]`}return n}function Mw(e,t,n){let r=t+1,o="[";e[r]==="^"&&(o+="^",r++);let i=!0;for(;;){let s=e[r];if(s==="]"&&!i)return{text:o+"]",end:r+1};if(i=!1,s==="["&&":.=".includes(e[r+1])){let l=e[r+1],f=e.indexOf(l+"]",r+2);o+=l===":"?`[:${Pr(e.slice(r+2,f))}:]`:e.slice(r,f+2),r=f+2;continue}let u=e.codePointAt(r),a=r+Ue(u);if(e[a]==="-"&&e[a+1]!==void 0&&e[a+1]!=="]"){let l=e.codePointAt(a+1),f=a+1+Ue(l);o+=Pw(u,l,e.slice(r,f),n),r=f;continue}o+=String.fromCodePoint(...n.fold(u)),r=a}}function Pw(e,t,n,r){let o=r.foldRange(e,t);if(o===null)throw new Error("Invalid range end");return o.length===1&&o[0][0]===e&&o[0][1]===t?n:o.map(([i,s])=>i===s?String.fromCodePoint(i):`${String.fromCodePoint(i)}-${String.fromCodePoint(s)}`).join("")}function Ie(e){throw new y("feature","PCRE "+e,`PCRE ${e} is not supported`)}function Bf(e){let t={captures:0,closed:new Set,names:new Map,stack:[],behind:0,references:!1,risky:!1},n="";for(let r=0;r<e.length;){let o=e[r];if(o==="\\"){let i=Uf(e,r,t,!1);n+=i.source,r=i.end;continue}if(o==="["){let i=Uw(e,r,t);n+=i.source,r=i.end;continue}if(o==="("){let i=Dw(e,r,t);n+=i.source,r=i.end;continue}if(o===")"){let i=t.stack.pop();i?.capture&&t.closed.add(i.capture),i?.behind&&t.behind--}if("*+?".includes(o)&&(t.behind&&Ie("variable-length lookbehind"),e[r+1]==="+"&&Ie("possessive repetition"),o!=="+"&&(t.risky=!0)),o==="|"&&(t.risky=!0),o==="{"){let i=Bw(e,r,t);n+=i.source,r=i.end;continue}n+=o==="]"||o==="}"?"\\"+o:o,r++}return t.references&&t.risky&&Ie("conditional backreference"),n}function Dw(e,t,n){let r=!1,o=null,i="(";if(e[t+1]==="*"&&Ie("control verb"),e[t+1]==="?"){let s=/^\(\?(?:[:=!]|<[=!]|<([A-Za-z_]\w*)>)/u.exec(e.slice(t));if(s||Ie("group"),i=s[0],r=i==="(?<="||i==="(?<!",!s[1]&&i!=="(?:"&&(n.risky=!0),s[1]){if(o=++n.captures,n.names.has(s[1]))throw new Error("duplicate PCRE capture name");n.names.set(s[1],o)}}else o=++n.captures;return r&&n.behind++,n.stack.push({capture:o,behind:r}),{source:i,end:t+i.length}}function Bw(e,t,n){let r=/^\{(\d+)(?:,(\d*))?\}/u.exec(e.slice(t));if(!r)return/^\{[\d, \t]*\}/u.test(e.slice(t))&&Ie("repetition"),{source:"\\{",end:t+1};if(n.behind&&r[2]!==void 0&&r[1]!==r[2]&&Ie("variable-length lookbehind"),Number(r[1])>65535||Number(r[2])>65535)throw new Error("PCRE repetition count exceeds 65535");return Number(r[1])===0&&(n.risky=!0),e[t+r[0].length]==="+"&&Ie("possessive repetition"),{source:r[0],end:t+r[0].length}}function Uw(e,t,n){let r=t+1,o="[";for(e[r]==="^"&&(o+="^",r++),e[r]==="]"&&(o+="\\]",r++);r<e.length&&e[r]!=="]";)if(e[r]==="["&&":.=".includes(e[r+1]??"")&&Ie("character class"),e[r]==="\\"){let i=Uf(e,r,n,!0);o+=i.source,r=i.end}else o+=e[r]==="["?"\\[":e[r],r++;return{source:o+(e[r]==="]"?"]":""),end:r+1}}function Uf(e,t,n,r){let o=e[t+1];if(o===void 0)throw new Error("trailing backslash");if(o==="Q"){let s=e.indexOf("\\E",t+2);return{source:RegExp.escape(e.slice(t+2,s<0?void 0:s)),end:s<0?e.length:s+2}}if(o==="E")return{source:"",end:t+2};if(o==="x"||o==="0"||r&&/[1-7]/u.test(o))return jw(e,t);if(o==="a"||o==="e")return{source:o==="a"?"\\u0007":"\\u001B",end:t+2};if("AzZ".includes(o)&&!r)return{source:o==="A"?"^":"$",end:t+2};if(/[1-9]/u.test(o)&&!r)return(/\d/u.test(e[t+2]??"")||!n.closed.has(Number(o)))&&Ie("forward or ambiguous backreference"),n.references=!0,{source:"\\"+o,end:t+2};if(o==="k"&&!r){let s=/^\\k<([A-Za-z_]\w*)>/u.exec(e.slice(t));return(!s||!n.closed.has(n.names.get(s[1])))&&Ie("named backreference"),n.references=!0,{source:s[0],end:t+s[0].length}}if("dDsSwWfnrtbB".includes(o))return{source:"\\"+o,end:t+2};/[A-Za-z0-9]/u.test(o)&&Ie("escape \\"+o);let i=String.fromCodePoint(e.codePointAt(t+1));return{source:RegExp.escape(i),end:t+1+i.length}}function jw(e,t){let n=e[t+1]==="x",r=(n?/^\\x(?:\{([\da-fA-F]+)\}|([\da-fA-F]{1,2}))/u:/^\\([0-7]{1,3})/u).exec(e.slice(t));if(!r)throw new Error("invalid PCRE character escape");let o=n?16:8,i=parseInt(r[1]??r[2],o);return Ze(i)||Ie("character escape"),{source:`\\u{${i.toString(16)}}`,end:t+r[0].length}}function rs(e,t){let n="",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"){let s=e[++o]??"";n+=r?i+s:Ww(s);continue}if(r&&i==="["){if(e[o+1]==="."||e[o+1]==="=")throw new y("feature","regex collating or equivalence class","grep: collating and equivalence classes are not supported");let s=Kt(e,o,{classes:t});if(s){n+=s.body,o=s.end-1;continue}}if(i==="["&&!r){n+="[",r=!0,e[o+1]==="^"&&(n+="^",o++),e[o+1]==="]"&&(n+="\\]",o++);continue}i==="]"&&(r=!1),n+=i}return n}function Ww(e){return"^$\\.*+?()[]{}|/bBsSwW<>`'123456789".includes(e)?"\\"+e:RegExp.escape(e)}function qw(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"){if("bBsSwW<>".includes(e[++t]??""))return!0}else if(".[*+?{".includes(e[t]))return!0;return!1}function Gn(e,t=!1,n=re(ee)){let r=n.assertions(),o=t?{b:"\\y"}:{"<":r["<"],">":r[">"],b:r.boundary,B:r.inside,w:r.word,W:r.nonWord,s:r.space,S:r.nonSpace,"`":"^","'":"$"},i="",s=!1;for(let u=0;u<e.length;u++){let a=e[u];if(a==="\\"){let l=e[++u];i+=!s&&Object.hasOwn(o,l)?o[l]:a+l,!t&&!s&&/[1-9]/u.test(l)&&/\d/u.test(e[u+1]??"")&&(i+="(?:)")}else a==="["&&(s=!0),a==="]"&&(s=!1),i+=a}return i}var os=/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u,zw=/^\\\{(?=\d|,)(\d*)(?:,(\d*))?\\\}/u;function jf(e,t,n){let r=(n?os:zw).exec(e.slice(t));if(!r&&!n)throw new Error("invalid repetition count");r&&Ma(Number(r[1]),r[2]===void 0||r[2]===""?void 0:Number(r[2]))}var Wf={__proto__:null,"*":{min:0,max:1/0},"+":{min:1,max:1/0},"?":{min:0,max:1}};function Hw(e){if(Wf[e])return Wf[e];let t=os.exec(e),n=Number(t[1]);return{min:n,max:t[2]===void 0?n:t[2]===""?1/0:Number(t[2])}}var qf=(e,t)=>e===0||t===0?0:e===1/0||t===1/0?1/0:e*t;function Gw(e,t){let n=Math.max(t.min,1);if(n>t.max)return{min:0,max:0};if(e.min>0&&(t.min===0&&e.min>1||e.max!==1/0&&t.max>n&&(n+1)*e.min>n*e.max+1))return null;let r=qf(t.max,e.max);return r!==1/0&&r>Lr?null:{min:qf(t.min,e.min),max:r}}function ns(e){return e.max===1/0?e.min===0?"*":e.min===1?"+":`{${e.min},}`:e.min===0&&e.max===1?"?":e.min===e.max?`{${e.min}}`:`{${e.min},${e.max}}`}var Xw=e=>!e.startsWith("(")&&!/^\\[1-9]/u.test(e);function Zw(e,t){if(t.length===1)return e+ns(t[0].bounds);let n=t[0].bounds,r=null;for(let o=1;o<t.length;o++){let{bounds:i,text:s}=t[o],u=r===null?Gw(n,i):null;if(u){n=u;continue}if(!(r===null&&n.min===n.max&&Xw(e))&&i.max>1)throw new Error("stacked quantifier needs ambiguous nesting");r=`(?:${r??e+ns(n)})${s}`}return r??e+ns(n)}function Yw(e,t){let n=t+1;for(e[n]==="^"&&n++;n<e.length;n++){if(e[n]==="\\"){n++;continue}if(e[n]==="]")return n}return e.length-1}function Vw(e){let t="",n=-1,r=-1,o=[],i=()=>{o.length>0&&(t=t.slice(0,n)+Zw(t.slice(n,r),o)),o=[]},s=a=>{i(),n=t.length,r=-1,t+=a},u=[];for(let a=0;a<e.length;a++){let l=e[a];if(l==="\\"){s(l+(e[++a]??""));continue}if(l==="["){let c=Yw(e,a);s(e.slice(a,c+1)),a=c;continue}if(l==="("){i(),u.push(t.length),n=-1,t+=l;continue}if(l===")"){i(),t+=l,n=u.pop()??-1,r=-1;continue}if(l==="|"||l==="^"||l==="$"){i(),t+=l,n=-1;continue}let f=l==="{"?os.exec(e.slice(a)):null;if(l==="*"||l==="+"||l==="?"||f){let c=f?f[0]:l;if(a+=c.length-1,n<0){t+=c;continue}o.length===0&&(r=t.length),o.push({bounds:Hw(c),text:c});continue}s(l)}return i(),t}function is(e,t,n=!1){let r=-1;for(let o=0;o<e.length;o++){let i=o<=r,s=e[o];if(s==="\\"){let u=e[++o];if(u===void 0)throw new Error("trailing backslash");if(i||u&&"dDxXuUpPkKcC".includes(u))throw new y("feature","regex escape","grep: this regex escape is not supported with GNU semantics");!t&&u==="{"&&jf(e,o-1,!1)}else if(s==="["&&!i)r=Pa(e,o,n);else{if(i)continue;if(t&&s==="{")jf(e,o,!0);else if(t&&s==="("&&e[o+1]==="?")throw new y("feature","regex extension","grep: ECMAScript group extensions are not supported in ERE")}}}function Kw(e){for(let t=0;t<e.length;t++)if(e[t]==="\\"&&/[1-9]/u.test(e[++t]??""))return!0;return!1}function zf(e,t,n=ee){let r=re(n),o=[],i=t.has("x"),s=t.has("w")&&!i;if(t.has("P")&&new Set(e).size>1)return{error:x("grep: -P only supports a single pattern",2)};for(let u of e){let a=!t.has("F")&&!t.has("P");a&&is(u,t.has("E"),r.multibyte);let l=a&&Kw(u),f=t.has("i")&&!t.has("P")&&!l,c=t.has("i")&&!f?"isu":"su",d;if(t.has("F"))d=f?Df(u,r):RegExp.escape(u);else if(t.has("P"))d=Bf(u);else if(t.has("E"))d=rs(f?Hn(u,r):u,r);else{let h=oo(f?Hn(u,r):u,r);if(h.error)return{error:x(`grep: ${h.error}`,2)};d=h.source}let p=d;if(a&&io(p))return{error:v("feature","grep","conditional backreference","grep: backreferences with conditional or repeated-empty captures are not supported",2)};s&&(d=`(?<!${r.assertions().word})(?:${d})(?!${r.assertions().word})`),i&&(d=`^(?:${d})$`);try{let h=new RegExp(a?Gn(Vw(d),!1,r):d,c);h.pcre=t.has("P"),h.localeSensitive=h.pcre?t.has("i")||s||qw(p)||/\\[dD]/u.test(p):t.has("i")&&l,h.folded=f,h.extendedC=f&&Tt.test(u),h.unicodePattern=/[\u0080-\u{10FFFF}]/u.test(u);let m=t.has("F")||!Vf.test(u);if(h.binaryLiteral=!i&&!s&&m,m&&u.isWellFormed()&&(f||!t.has("i"))&&(h.literal={pattern:u,tables:r}),t.has("o")&&a&&!i){if(s||/\\[1-9]|\(\?/u.test(d))return{error:v("feature","grep","-o regex extent","grep: only-matching with backreferences, lookarounds or word constraints is not supported",2)};try{h.extent=new ct(Gn(d,!0,r),!1,null,r)}catch{return{error:v("feature","grep","-o regex extent","grep: POSIX match extent for this pattern is not supported",2)}}}o.push(h)}catch(h){if(!t.has("P")&&Jw(p,t))return{error:v("feature","grep","GNU regex syntax","grep: this GNU regular expression cannot be represented by the JavaScript matcher",2)};let m=t.has("F")?`fixed-string /${c}`:t.has("P")?`PCRE subset /${c}`:t.has("E")?`ERE / ECMAScript /${c}`:`BRE /${c}`;return{error:x(`grep: invalid pattern (${m}): ${h.message}`,2)}}}return{res:o}}function Jw(e,t){if(!t.has("E")&&/(?<!\\)\{(?!\d*(?:,\d*)?\})/u.test(e))return!1;try{return no(Gn(e,!0)),!0}catch(n){return!!n.gap}}function Hf({pattern:e,tables:t},n){return[...e].map(r=>(n?t.fold(r.codePointAt(0)):[r.codePointAt(0)]).map(i=>B(String.fromCodePoint(i))))}function Gf(e,t){return t.every(n=>n.literal?(n.literalMask??=Hf(n.literal,n.folded),!Zf(e,n.literalMask)):!1)}function Xf(e,t,n,r=ee){let o=re(r);return t.every(i=>(n||!Vf.test(i))&&i.isWellFormed()&&!Zf(e,Hf({pattern:i,tables:o},!1)))}function Zf(e,t){for(let n=0;n+t.length<=e.length;n++)if(Yf(e,n,t,0))return!0;return!1}function Yf(e,t,n,r){return r===n.length?!0:n[r].some(o=>o.every((i,s)=>e[t+s]===i)&&Yf(e,t+o.length,n,r+1))}var Vf=/[\\.^$*+?()[\]{}|]/u;function ss(e,t,n,r=!1,o=ee){if(e.length===0)return null;if(e.some(a=>a.content===void 0))return v("feature","grep","binary input","grep: binary input detection and output are not supported",2);if(!r&&e.some(a=>a.content.includes("\0")&&(n||t.some(l=>!l.binaryLiteral||l.test(a.content)))))return v("feature","grep","binary input","grep: binary input detection and output are not supported",2);let i=/[\u0080-\u{10FFFF}]/u;if(o!==ee&&t.some(a=>a.localeSensitive||a.folded)&&(t.some(a=>a.unicodePattern)||e.some(a=>i.test(a.content))))return v("feature","grep","locale",`grep: matching non-ASCII text in the ${o} locale is not supported`,2);if(t.some(a=>a.extendedC)||t.some(a=>a.folded)&&e.some(a=>Tt.test(a.content)))return v("feature","grep","locale-sensitive regex","grep: case-insensitive matching over Cyrillic Extended-C letters is not supported",2);let s=t.filter(a=>a.localeSensitive);if(s.length===0||!(s.some(a=>a.unicodePattern)||e.some(a=>i.test(a.content))))return null;let u=s.some(a=>a.pcre)?"PCRE matching":"case-insensitive matching with backreferences";return v("feature","grep","non-ASCII regex semantics",`grep: ${u} on non-ASCII input is not supported`,2)}var us=/[*?[]/u,as=/\P{ASCII}/u,Qw=/[.+*?^${}()|[\]\\/]/u;function Me(e,t={}){try{return eb(e,t)}catch(n){throw n instanceof y?n:new y("feature","glob pattern",`unsupported glob pattern: ${n.message}`)}}function eb(e,t){let n="^",r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(i==="\\"&&o+1<e.length){let s=e[o+1];n+=Kf(s,t.ignoreCase),o++}else if(i==="*"){for(;e[o+1]==="*";)o++;n+=".*"}else if(i==="?")n+=".";else if(i==="["){let s=Jf(e,o,t);if(s?.voided)return/^(?!)$/u;s?(n+=s.source,o=s.end,r||=s.nonAsciiRange):n+="\\["}else n+=Kf(i,t.ignoreCase)}return nb(new RegExp(n+"(?![\\s\\S])","us"),e,t,r)}function Kf(e,t){return t&&/[a-zA-Z]/u.test(e)?`[${e.toLowerCase()}${e.toUpperCase()}]`:Qw.test(e)?"\\"+e:e}function tb(e,t,n){let r=new RegExp(`[${e}]`,"ui"),o=new RegExp(`[${t}]`,"u"),i="";for(let s=0;s<128;s++){let u=String.fromCodePoint(s);(r.test(u)||o.test(u))&&(i+="\\x"+s.toString(16).padStart(2,"0"))}return`[${n?"^":""}${i}]`}function nb(e,t,n,r){let o=/[?[]/u.test(t),i=as.test(t);return{test(s){if(r||n.ignoreCase&&i||(o||n.ignoreCase)&&as.test(s))throw new y("feature","non-ASCII glob matching","locale-dependent glob matching of non-ASCII names is not supported");return e.test(s)}}}function Jf(e,t,n){let{ignoreCase:r}=n,o=t+1,i=!1;(e[o]==="!"||e[o]==="^")&&(i=!0,o++);let s="",u="",a=!1,l=!1,f=!1,c=!1,d="",p=0,h="",m=0;for(e[o]==="]"&&(s+="\\]",o++,a=!0,d="]");o<e.length&&e[o]!=="]";o++){let g=e[o];if(g==="["&&(e[o+1]==="."||e[o+1]==="="))throw new y("feature","glob collating or equivalence class","glob collating symbols and equivalence classes are not supported");if(g==="["&&e[o+1]===":"){let w=n.bash?rb(e,o):Kt(e,o,{unknown:"empty"});if(w){if(!n.bash&&w.body==="")throw new y("feature","glob character class","unknown POSIX classes in command filename patterns are not supported");l&&(c=!0),r?u+=w.body:s+=w.body,o=w.end-1,a=!1,l=!1;continue}if(n.bash)continue}if(g==="-"&&a)m=p,h=d,s+="-",l=!0,a=!1;else{let w=g==="\\"&&o+1<e.length?e[++o]:g;p=s.length,d=w,l&&as.test(h+w)&&(f=!0),l&&w.codePointAt(0)<h.codePointAt(0)?s=s.slice(0,m):s+=/[\]\\^[-]/u.test(w)?`\\${w}`:w,a=!l,l=!1}}return o>=e.length?null:c?{voided:!0,end:o}:{source:r?tb(s,u,i):`[${i?"^":""}${s}]`,end:o,nonAsciiRange:f}}function rb(e,t){let n=e.indexOf(":]",t+2);if(n===-1)return null;let r=e.slice(t+2,n).replace(/\\([\s\S]|$)/gu,"$1");return{body:r==="ascii"?"\\x00-\\x7F":It[r]??"",end:n+2}}function Qf(e,t){return Me(t).test(e)}function ec(e){let{value:t,mask:n}=e;if(n===null)return us.test(t);for(let r=0;r<t.length;r++)if(n[r]==="0"&&us.test(t[r]))return!0;return!1}function Xn(e){let t=n=>!e.mask||e.mask[n]==="0";for(let n=0;n<e.value.length;n++){let r=e.value[n];if(t(n)){if(r==="\\")n++;else if(r==="[")n=ob(e,n,t);else if(/[?*+@!]/u.test(r)&&e.value[n+1]==="("&&t(n+1))return!0}}return!1}function ob(e,t,n){let{value:r}=e,o=t+1;for(/[!^]/u.test(r[o])&&n(o)&&o++,r[o]==="]"&&n(o)&&o++;o<r.length;o++)if(n(o))if(r[o]==="\\")o++;else{if(r[o]==="]")return o;if(r[o]==="["&&/[.:=]/u.test(r[o+1])&&n(o+1)){let i=r.indexOf(r[o+1]+"]",o+2);i!==-1&&(o=i+1)}}return t}var ib=/[*?[\]^!\\:.=-]/u;function on(e){let{value:t,mask:n}=e;if(n===null)return t;let r="";for(let o=0;o<t.length;o++){let i=t[o];r+=n[o]!=="0"&&ib.test(i)?"\\"+i:i}return r}function tc(e,t){let n=on(e),r=n.match(/[^/]+|\/+/gu)??[],o=Jt(),i=new Set,s=[{path:"",marks:null}],u;try{for(let l=0;l<r.length;l++){let f=r[l];if(f.startsWith("/")||!us.test(f)){s=s.map(c=>({...c,path:c.path+ub(f)}));continue}s=ab(s,f,l===r.length-1,t,i)}let a=s.filter(l=>E(t.cwd,l.path,t.fs,{follow:!1}).path!==null);for(let l of a)for(let f of l.marks??[])o.add(f);return u=a.filter(l=>l.marks===null).map(l=>l.path).sort(j),u}finally{if(u===void 0)for(let a of i)o.add(a);o.emit(t.notes,"glob","",` while expanding ${JSON.stringify(n)}`),u?.length===0&&r.some(sb)&&t.notes.add(`glob: no paths matched ${JSON.stringify(n)}; the pattern was left literal.`)}}function sb(e){for(let t=0;t<e.length;t++)if(e[t]==="\\")t++;else{if(e[t]==="*"||e[t]==="?")return!0;if(e[t]==="[")try{if(Jf(e,t,{bash:!0}))return!0}catch{return!0}}return!1}var ub=e=>e.replace(/\\(.)/gu,"$1");function ab(e,t,n,r,o){let i=Me(t,{bash:!0}),s=t.startsWith(".")||t.startsWith("\\."),u=[];for(let a of e){let l=E(r.cwd,a.path||".",r.fs).path;if(!r.fs.isDir(l))continue;let{dirs:f,files:c,links:d}=r.fs.listDir(l),p=n?d:d.filter(h=>r.fs.isDir(E(l,h,r.fs).path));for(let h of n?[...f,...c,...p]:[...f,...p]){let m=!s&&h.startsWith(".");if(!m&&a.marks===null)i.test(h)&&u.push({path:a.path+h,marks:null});else if(lb(i,h)){if(!m){u.push({path:a.path+h,marks:a.marks});continue}let g=Z(l,h);o.add(g),u.push({path:a.path+h,marks:[...a.marks??[],g]})}}}return u}function lb(e,t){try{return e.test(t)}catch{return!0}}var fs=(e,t)=>e.some(n=>n.test(t)),cs=()=>({stdout:"",stderr:"",exitCode:1});function ds(e,t,n,r){let o=0;if(r===1/0){for(let s of he(e))fs(t,s)!==n&&o++;return o}let i=0;for(;i<e.length&&o<r;){let s=e.indexOf(`
|
|
48
|
+
`,i);s<0&&(s=e.length),fs(t,e.slice(i,s))!==n&&o++,i=s+1}return o}function rc(e,t,n){let r=[],o=!1;for(let{name:i,content:s,recursive:u}of e){let a={...n,showName:n.showName??u,separate:o&&n.hasContext};fb(he(s),t,i,a,r)&&(o=!0)}return o?F(ge(r)):cs()}function fb(e,t,n,r,o){let{invert:i,after:s,before:u,max:a,hasContext:l}=r,f=-1,c=0,d=0;for(let p=0;p<e.length&&!(c===a&&d===0);p++){let h=fs(t,e[p])!==i,m=a!==void 0&&c>=a;if(h&&!m){c++,c===1&&r.separate&&o.push("--");let g=Math.max(0,p-u);l&&f>=0&&g>f+1&&o.push("--");for(let w=Math.max(g,f+1);w<p;w++)ls(e[w],n,w+1,t,r,!1,o);ls(e[p],n,p+1,t,r,!0,o),f=p,d=s;continue}d>0&&(ls(e[p],n,p+1,t,r,!1,o),f=p,d--)}return c>0}function ls(e,t,n,r,o,i,s){if(!o.only){s.push(nc(e,t,n,i,o));return}if(i===o.invert)return;let u=0;for(;u<e.length;){let a=null;for(let l of r){let f;if(l.extent)f=l.extent.search(e,u);else{let c=l.scan??=new RegExp(l.source,l.flags+"g");c.lastIndex=u;let d=c.exec(e);if(d&&d[0]===""&&l.pcre)throw new y("feature","PCRE empty match extent","only-matching with empty PCRE matches is not supported");f=d?{start:d.index,end:d.index+d[0].length}:null}f&&(!a||f.start<a.start||f.start===a.start&&f.end>a.end)&&(a=f)}if(!a)break;if(a.end===a.start){u=a.end+Le(e,a.end);continue}s.push(nc(e.slice(a.start,a.end),t,n,i,o)),u=a.end}}function nc(e,t,n,r,o){let i=r?":":"-";return(o.showName?(t??"(standard input)")+i:"")+(o.showLine?n+i:"")+e}function oc(e,t,{mode:n,invert:r,showName:o,max:i=1/0}){let s=[],u=!1,a=n==="c"?i:Math.min(1,i);for(let{name:l,content:f,recursive:c}of e){let d=ds(f,t,r,a);d>0&&(u=!0);let p=l??"(standard input)";n==="c"?s.push(o??c?p+":"+d:String(d)):d>0==(n==="l")&&s.push(p)}return{stdout:ge(s),stderr:"",exitCode:u?0:1}}function ic(e,t,n){let r=e.order.filter(s=>["e","f","file"].includes(s.name)),o=e.positional;if(r.length===0)return o.length?{patterns:o[0].split(`
|
|
49
49
|
`),rest:o.slice(1),stdin:t}:null;let i=new Set;for(let{name:s,value:u}of r){if(s==="e"){for(let f of u.split(`
|
|
50
|
-
`))i.add(f);continue}let a=st("grep",[u],n,t);if(a.failed)return{error:x(a.stderr,2)};let l=a.inputs[0];for(let f of he(l.content))i.add(f);l.shared&&(t="")}return{patterns:[...i],rest:o,stdin:t}}var sc="[-i] [-a|-I] [-s] [-v] [-n] [-r|-R] [-w] [-x] [-o] [-E|-F|-G|-P] [-l] [-L] [-c] [-q] [-m N] [-h] [-H] [-A N] [-B N] [-C N] [--include=GLOB] [--exclude=GLOB] [--exclude-dir=GLOB]",
|
|
51
|
-
or: grep ${sc} [-e PATTERN] [-f FILE] ... [PATH...]`,
|
|
52
|
-
`,u=!0;continue}if(
|
|
53
|
-
`}:{input:{name:t,...
|
|
50
|
+
`))i.add(f);continue}let a=st("grep",[u],n,t);if(a.failed)return{error:x(a.stderr,2)};let l=a.inputs[0];for(let f of he(l.content))i.add(f);l.shared&&(t="")}return{patterns:[...i],rest:o,stdin:t}}var sc="[-i] [-a|-I] [-s] [-v] [-n] [-r|-R] [-w] [-x] [-o] [-E|-F|-G|-P] [-l] [-L] [-c] [-q] [-m N] [-h] [-H] [-A N] [-B N] [-C N] [--include=GLOB] [--exclude=GLOB] [--exclude-dir=GLOB]",cb=`grep ${sc} PATTERN [PATH...]
|
|
51
|
+
or: grep ${sc} [-e PATTERN] [-f FILE] ... [PATH...]`,db=["i","v","n","r","R","l","L","c","w","x","h","H","o","E","F","G","P","q","I","a","s"],pb=["A","B","C","m"],fc={short:db,long:["text","no-messages"],valueShort:pb,repeatable:["e","f","file","include","exclude","exclude-dir"]};function cc(e){try{return N(e,fc).flags.has("q")}catch{return!1}}function so(e,t,n){let r;try{r=N(t,fc)}catch(m){return K(m,"grep",`grep: ${m.message}`,2)}let{flags:o,values:i}=r,s=ic(r,e,n);if(!s)return pe(cb,2);if(s.error)return s.error;let{patterns:u,rest:a}=s;e=s.stdin;let l=bb(o);if(l)return l;let f;try{f=zf(u,o,n.locale)}catch(m){return K(m,"grep",`grep: ${m.message}`,2)}if(f.error)return f.error;let c=yb(i);if(c.error)return c.error;if(c.max===0&&(!o.has("L")||o.has("q")))return cs();if(c.max!==0&&n.stdinFile&&(o.has("q")||o.has("l")||o.has("L")||i.has("m"))&&(a.length===0||a.includes("-")))return v("feature","grep","partial stdin reads","grep: early termination on shared file input is not supported",2);let d=o.has("r")||o.has("R"),p=vb(r,n),h=r.order.findLast(m=>["a","I","text"].includes(m.name))?.name;p.ignoreBinary=h==="I"&&c.max!==0,p.forceText=h==="a"||h==="text",p.silent=o.has("s")||o.has("no-messages"),p.follow=o.has("R");try{return hb(e,a,n,d,p,f,o,c)}finally{wb(p,n.notes)}}function hb(e,t,n,r,o,i,s,u){if(s.has("q"))return mb(e,t,n,r,o,i.res,s.has("v"));let a=pc(r,e,t,n,o);u.max===0&&q(n,e);let l=a.inputs;o.name.length>0&&(l=l.filter(g=>hc(g,o))),u.max!==0&&(l=l.map(g=>dc(g,o,i.res,s.has("v"))));let f=u.max===0?null:ss(l,i.res,s.has("v"),o.forceText,n.locale);if(f)return f;let c=xb(s,t.length),d=s.has("v"),p={showName:c,invert:d,showLine:s.has("n"),only:s.has("o"),...u},h=["l","L","c"].find(g=>s.has(g)),m;try{m=h?oc(l,i.res,{...p,mode:h}):rc(l,i.res,p)}catch(g){return g instanceof $&&g.gap?v("feature","grep",g.gap,`grep: ${g.message}`,2):K(g,"grep",`grep: ${g.message}`,2)}return a.failed?{stdout:m.stdout,stderr:a.stderr+m.stderr,exitCode:2}:m}function mb(e,t,n,r,o,i,s){let u="",a=!1;for(let l of t.length?t.map(f=>[f]):[[]]){let f=pc(r,e,l,n,o);u+=f.stderr,a||=f.failed,(l.includes("-")||l.includes("/dev/stdin")&&!n.stdinFile)&&(e="");for(let c of f.inputs){if(!hc(c,o))continue;let d=dc(c,o,i,s),p=ss([d],i,s,o.forceText,n.locale);if(p)return p.stderr=u+p.stderr,p;if(ds(d.content,i,s,1)>0)return{stdout:"",stderr:u,exitCode:0}}}return{stdout:"",stderr:u,exitCode:a?2:1}}function dc(e,t,n,r){if(e.content===void 0){if(!r&&Gf(e.bytes,n))return{...e,content:""};if(!t.ignoreBinary)return e;if(!gb(e.bytes,uc))throw new y("feature","late binary detection","grep: binary detection after the initial input buffer is not supported");return ac(e,t)}if(!e.content.includes("\0")||t.forceText)return e;if(!t.ignoreBinary)return/^[\0\n]+$/u.test(e.content)&&n.some(o=>o.test(""))===r?{...e,content:""}:e;if(A(e.content.slice(0,e.content.indexOf("\0"))).length>=uc)throw new y("feature","late binary detection","grep: binary detection after the initial input buffer is not supported");return ac(e,t)}var uc=96*1024;function ac(e,t){let n=e.name===null||e.name==="/dev/stdin"?t.stdinPath:Z(t.cwd,e.name);return n?t.binary.add(n):t.binaryStdin=!0,{...e,content:""}}function gb(e,t){if(e.length<=t)return!0;for(let n=t;n<=t+3&&n<=e.length;n++)if(me(e.subarray(0,n))!==void 0)return!1;return!0}function wb(e,t){let n="Binary input is treated as text with -a.";gt(t,{command:"grep",action:"skipped",noun:["binary file","binary files"],paths:e.binary,explanation:n}),e.binaryStdin&&t.add("grep: skipped binary standard input. "+n),gt(t,{command:"grep",action:"excluded",noun:["entry","entries"],paths:e.excluded,context:" by --include/--exclude/--exclude-dir rules"})}function bb(e){if(e.has("h")&&e.has("H"))return v("option","grep","-h -H","grep: combining -h and -H is not supported");let t=["l","L","c"].filter(r=>e.has(r));if(t.length>1)return v("option","grep","combined output modes",`grep: ${t.map(r=>`-${r}`).join(" / ")} are mutually exclusive`);let n=["E","F","G","P"].filter(r=>e.has(r));return n.length>1?x(`grep: ${n.map(r=>`-${r}`).join(" / ")} are mutually exclusive`,2):null}function yb(e){let t={A:0,B:0,m:void 0};for(let n of["C","A","B","m"]){if(!e.has(n))continue;let r=ye(e.get(n),"grep: -"+n);if(r.error)return n==="m"&&(r.error.exitCode=2),r;n==="C"?t.A=t.B=r.value:t[n]=r.value}return{after:t.A,before:t.B,max:t.m,hasContext:["A","B","C"].some(n=>e.has(n))}}function xb(e,t){return e.has("h")?!1:e.has("H")||t>1?!0:void 0}function pc(e,t,n,r,o){if(!e){let a=te("grep",n,t,r,{read:"maybe-text"});return{...a,stderr:o.silent?"":a.stderr,inputs:a.inputs.map(l=>l.name==="-"?{...l,name:null}:l)}}let i=[],s="",u=!1;for(let a of n.length?n:["."]){if(a==="-"||a==="/dev/stdin"||a==="/dev/null"){let d=st("grep",[a],r,t);i.push(...d.inputs.map(p=>({...p,name:a==="-"?null:a}))),(a==="-"||a==="/dev/stdin")&&(t="");continue}let{path:l,error:f}=P(r,"grep",a);if(r.fs.isFile(l)){i.push({name:a,...ps(r,l)});continue}if(f){s+=`grep: ${a}: ${f}
|
|
52
|
+
`,u=!0;continue}if(Sb(a,o.dir)){o.excluded.add(l);continue}let c=d=>d===l||o.dir.length===0||!hs(o.dir,nt(d))?!0:(o.excluded.add(d),!1);for(let d of Fe(r.fs,l,1/0,c)){if(d.kind==="link"){if(!o.follow)continue;let h=kb(d.path,lc(n.length?a:"",l,d.path),r,o);h?.input&&i.push(h.input),h?.error&&(s+=h.error,u=!0);continue}if(d.kind!=="file")continue;let p=d.path;i.push({name:lc(n.length?a:"",l,p),...ps(r,p),recursive:!0})}}return{inputs:i,stderr:o.silent?"":s,failed:u}}function kb(e,t,n,r){let o=E(n.cwd,e,n.fs),i=n.fs.isDir(o.path);if(!(i?r.dir.length===0||!hs(r.dir,nt(e)):mc(nt(e),r.name)))return r.excluded.add(e),null;if(i)throw new y("option","-R",`following a symbolic link to a directory is not supported: ${t}`);return o.error?{error:`grep: ${t}: ${o.error}
|
|
53
|
+
`}:{input:{name:t,...ps(n,o.path),recursive:!0}}}function ps(e,t){let{text:n,bytes:r}=wt(e.fs,t);return n===void 0?{content:void 0,bytes:r}:{content:n}}function vb(e,t){let n=e.order.filter(o=>o.name==="include"||o.name==="exclude").map(o=>({include:o.name==="include",re:Me(o.value)})),r=(e.values.get("exclude-dir")??[]).map(o=>Me(o));return{name:n,dir:r,binary:new Set,excluded:new Set,cwd:t.cwd,stdinPath:t.stdinHandle?.path}}function hs(e,t){return e.some(n=>n.test(t))}function hc(e,t){return e.name===null||mc(nt(e.name),t.name)?!0:(t.excluded.add(Z(t.cwd,e.name)),!1)}function mc(e,t){if(t.length===0)return!0;let n=null;for(let r of t)r.re.test(e)&&(n=r);return n?n.include:!t[0].include}function Sb(e,t){return t.length===0||e.endsWith("/")?!1:hs(t,e.slice(e.lastIndexOf("/")+1))}function lc(e,t,n){let r=He(t,n);return e===""?r:e.endsWith("/")?e+r:e+"/"+r}var Zn=(e,t)=>v("feature","rg",e,`rg: ${t}`,2);function gc(e,t,n){let r=O(e)??e.note;return r?v(r.kind,"rg",r.detail,t,2):v(n,"rg",e.detail??t.replace(/^rg: /u,""),t,2)}function bc(e,t,n){let r,o;try{o=N(t,$f),r=Nf(o)}catch(d){return gc(d,d.message.startsWith("rg: ")?d.message:`rg: ${d.message}`,"option")}let i=[...o.positional];if(!r.patterns.length){if(!i.length)return Zn("usage","a pattern is required");r.patterns.push(i.shift())}try{Of(r.patterns,r.literal)}catch(d){return gc(d,d.message,"feature")}let u=!i.length&&!!n.stdinPiped?{roots:[],recursive:!1,stdin:!0}:Nb(i,n,r.hidden);if(u.error)return u.error;if(!o.flags.has("no-ignore")&&!r.unrestricted&&u.recursive){let d=Ab(u.roots,n);if(d)return Zn("ignore rules",`${JSON.stringify(d)} would change which files are searched, and its rules are not implemented`)}let a=Eb(i,u,r,n),l=r.text?null:Ob(i,n);if(l)return Zn("named binary file",`${JSON.stringify(l)} is binary, and reporting a binary match is not supported`);let f=$b(a,r,n);return f?Zn(f.detail,f.message):(u.stdin||i.length?1:a.length)===0?{stdout:"",exitCode:2,stderr:`rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
|
|
54
54
|
Running with --debug will show why files are being skipped.
|
|
55
|
-
`}:
|
|
56
|
-
`).some(i=>i.trim()!==""&&!i.trimStart().startsWith("#"))}function
|
|
55
|
+
`}:Cb(e,r,i,u,n)}function Eb(e,t,n,r){let o=e.map(i=>E(r.cwd,i,r.fs).path).filter(Boolean).map(i=>({path:i,named:!0}));for(let i of t.roots)for(let s of Fe(r.fs,i)){if(s.kind!=="file")continue;let u=He(i==="/"?"/":i,s.path).split("/");(n.hidden||u.every(a=>!a.startsWith(".")))&&o.push({path:s.path,named:!1})}return o}function $b(e,t,n){for(let{path:r,named:o}of e){if(n.fs.isDir(r))continue;let{text:i,bytes:s}=wt(n.fs,r);if(i!==void 0&&!i.startsWith("\uFEFF")||(s===void 0?i.includes("\0"):s.includes(0))&&!o&&!t.text)continue;let a=JSON.stringify(He(n.cwd==="/"?"/":n.cwd,r)||r);if(i===void 0){if(!t.invert&&!t.ignoreCase&&Xf(s,t.patterns,t.literal,n.locale))continue;return{detail:"unreadable bytes",message:`${a} holds bytes that are not text, and searching them is not supported`}}if(i.startsWith("\uFEFF"))return{detail:"byte-order mark",message:`${a} begins with a byte-order mark, which ripgrep strips before matching`}}return null}function Nb(e,t,n){let r=[],o=!1;for(let s of e){let u=E(t.cwd,s,t.fs);u.path!==null&&t.fs.isDir(u.path)&&r.push(u.path),s.split("/").some(a=>a.startsWith(".")&&a!=="."&&a!=="..")&&(o=!0)}e.length||r.push(t.cwd);let i=r.length>0;return!n&&i&&o&&e.length?{error:Zn("named hidden path","a hidden path named beside a directory is searched by ripgrep but skipped while walking, and both cannot apply at once")}:{roots:r,recursive:i}}function Ab(e,t){let n=l=>He(t.cwd==="/"?"/":t.cwd,l)||l,r=(l,f=!0)=>{for(let c of e){for(let d of Fe(t.fs,c))if(nt(d.path)===l&&ms(d.path,f,t))return d.path;for(let d=c;d!=="/";d=be(d)){let p=E(be(d),l,t.fs);if(p.path!==null&&ms(p.path,f,t))return p.path}}return null},o=r(".ignore")??r(".rgignore");if(o)return n(o);let i=r(".git",!1);if(!i)return null;let s=E(i,"info/exclude",t.fs).path,u=s!==null&&ms(s,!0,t)?s:null,a=r(".gitignore")??u;return a?n(a):null}function ms(e,t,n){if(!t||n.fs.isDir(e))return!0;let r=E("/",e,n.fs).path,{text:o}=wt(n.fs,r??e);return(o??" ").split(`
|
|
56
|
+
`).some(i=>i.trim()!==""&&!i.trimStart().startsWith("#"))}function Ob(e,t){for(let n of e){let r=E(t.cwd,n,t.fs);if(r.path===null||t.fs.isDir(r.path))continue;let{text:o,bytes:i}=wt(t.fs,r.path);if(i===void 0?o?.includes("\0"):i.includes(0))return n}return null}function Cb(e,t,n,r,o){let i=t.literal?["-F"]:["-P"];t.ignoreCase&&i.push("-i"),t.lineNumbers&&i.push("-n"),t.word&&i.push("-w"),t.invert&&i.push("-v"),t.quiet&&i.push("-q"),t.mode&&i.push("-"+t.mode),t.showName&&i.push("-"+t.showName),i.push(t.text?"-a":"-I"),t.after&&i.push("-A",String(t.after)),t.before&&i.push("-B",String(t.before)),r.recursive&&i.push("-r"),r.recursive&&!t.hidden&&i.push("--exclude=.*","--exclude-dir=.[!.]*","--exclude-dir=..?*"),i.push(...Af(t.patterns,t.literal)),r.stdin||i.push("--",...n.length?n:["."]);let s=new Set(o.notes),u=so(e,i,o);return _b(o.notes,s,r),Lb(Ib(u,t),n,t.patterns)}function Ib(e,t){if(t.mode!=="c")return e;let n=e.stdout.split(`
|
|
57
57
|
`).filter(r=>r!==""&&r!=="0"&&!r.endsWith(":0"));return{...e,stdout:n.length?n.join(`
|
|
58
58
|
`)+`
|
|
59
|
-
`:""}}var wc=new Map([["No such file or directory",2],["Not a directory",20],["Is a directory",21]]),
|
|
60
|
-
`;i&&o.push({fd:2,text:i});let s={...t,stdout:"",stderr:t.stderr+i,exitCode:r||t.exitCode,events:o,unordered:!1},u=O(t);return u?ie(s,u.kind,u.command,u.detail,u.message):s}var
|
|
61
|
-
`,"n"],["\r","r"],[" ","t"],["\v","v"]]);function X(e,t){let n=le(t),r=n?Array.from(B(e),s=>String.fromCodePoint(s)):[...e];if(!n&&r.some(s=>s.codePointAt(0)>127&&/[\p{C}\p{Zl}\p{Zp}]/u.test(s)))throw new
|
|
62
|
-
`,"n"],["\r","r"],[" ","t"],["\v","v"],['"','"'],["\\","\\"]]);function ys(e,t){let n=le(t),r="",o=!1;for(let i of e){let s=i.codePointAt(0),u=
|
|
63
|
-
`,!0)}}return p.result.exitCode=p.failed?1:0,p.result}function
|
|
64
|
-
`,!0);if(u.error)return a(`cannot stat ${i}: ${u.error}`);if(o.fs.isDir(u.path))return n.recursive?
|
|
65
|
-
`,!1,!0);n.sources.add(u.path)}let l=E(o.cwd,t,o.fs);if(l.error&&l.error!=="No such file or directory")return a(`cannot stat ${s}: ${l.error}`);if(n.noClobber&&l.path!==null)return;if(Oc(u.path,l.path,o.fs))return a(`${i} and ${s} are the same file`);if(o.fs.isDir(l.path))return a(`cannot overwrite directory ${s} with non-directory ${i}`);let f=se(o.fs,o.cwd,t);if(r===null&&n.copied.has(f))return a(`will not overwrite just-created ${s} with ${i}`);let c=tt(o.cwd,t,o.fs,l);if(Nc(i,s,n),Ec(o,t,l))return a(`not writing through dangling symlink ${s}`);if(c)return R(o,"cp",t,c),a(`cannot create regular file ${s}: ${c}`);try{if(!o.fs.copyWritable?.(o.cwd,u.path,t))return a(`${n.force&&l.path!==null?"cannot remove":"cannot create regular file"} ${s}: Read-only file system`)}catch(d){if(O(d))throw d;R(o,"cp",d?.path,d?.fsError);let p=V(d);return a(`cannot create regular file ${s}: ${p.startsWith(t+": ")?p.slice(t.length+2):p}`)}r===null&&n.copied.add(f)}function
|
|
66
|
-
`,!0),f=E(s.cwd,n,s.fs,{follow:!1});if(f.error&&f.error!=="No such file or directory")return l(`cannot stat ${a}: ${f.error}`);let c=n.replace(/\/+$/u,"")||n;if(se(s.fs,s.cwd,c,!0)===t)return l(`${u} and ${a} are the same file`);if(f.path!==null&&!s.fs.isDir(f.path))return l(`cannot overwrite non-directory ${a} with directory ${u}`);let d=se(s.fs,s.cwd,c,!1);if(f.path===null){let
|
|
67
|
-
`,!1,!0);r.sources.add(t)}i&&
|
|
59
|
+
`:""}}var wc=new Map([["No such file or directory",2],["Not a directory",20],["Is a directory",21]]),Tb=e=>e.replaceAll(/^(rg: .*: )([A-Z][a-z].*)$/gmu,(t,n,r)=>wc.has(r)?`${n}${r} (os error ${wc.get(r)})`:t),Fb=/^rg: (?:invalid pattern[^\n]*|trailing backslash)$/mu;function Lb(e,t,n){let r=s=>t.length?s:s.replaceAll(/^\.\//gmu,""),o={...e,stdout:r(e.stdout),stderr:Tb(r(e.stderr).replaceAll(/^grep: /gmu,"rg: "))},i=O(e);return i?.detail==="non-ASCII regex semantics"?v("feature","rg","non-ASCII matching","rg: Unicode-aware matching on non-ASCII input is not supported",2):i?v(i.kind,"rg",i.detail,o.stderr.trimEnd()||i.message,e.exitCode):Fb.test(o.stderr)?v("feature","rg","regex parse error",`rg: regex parse error in ${JSON.stringify(n.join(" "))}; the reason ripgrep gives is not reproduced here`,2):o}function _b(e,t,n){let r=[];for(let o of e)!t.has(o)&&o.startsWith("grep: excluded ")&&r.push(o);for(let o of r)e.delete(o),n.recursive&&e.add(o.replace(/^grep: excluded (\d+) (entry|entries) by --include\/--exclude\/--exclude-dir rules/u,"rg: skipped $1 hidden $2").replace(/\.$/u,". Hidden entries are searched with --hidden."))}var yc=e=>e.text??W(e.bytes),ws=(e,t)=>{e.bytes===void 0?t.write(e.text):t.writeBytes(e.bytes)},sn=e=>e.events??[...e.stdout?[{fd:1,text:e.stdout}]:[],...e.stderr?[{fd:2,text:e.stderr}]:[]],gs=e=>e.unordered??(!e.events&&e.stdout!==""&&e.stderr!==""),U=(e="")=>({stdout:"",stderr:e,exitCode:0,ignored:!1,events:e?[{fd:2,text:e}]:[],unordered:!1});function _(e,t){e.stdout+=t.stdout,e.stderr+=t.stderr,e.exitCode=t.exitCode,e.ignored=t.ignored??!1,e.events.push(...sn(t)),e.unordered||=gs(t)}function uo(e,t){t&&_(e.expansionOutput,un(U(t),{fds:e.expansionFds},e))}function un(e,t,n){let r=o=>Rb(e,t,n,o);return n.io?n.io.output(e,t,r):r(ws)}function Rb(e,t,n,r){let o=e,i=t.fds[1],s=t.fds[2];(i===s&&i!=="null"&&i!=="closed"||(i?.identity&&s?.identity?i.identity===s.identity:i?.path&&i.path===s?.path))&&gs(o)&&(o=v("feature",null,"combined output ordering","error: merging this command\u2019s stdout and stderr in order is not supported"),n.unsupported.add(O(o)));let a=[],l="",f="";for(let c of sn(o)){let d=t.fds[c.fd];if(typeof d=="object"){r(c,d);continue}if(t.deferred?.[c.fd]&&c.bytes!==void 0){a.push(c);continue}if(d!=="out"&&d!=="err"){c.fd===2&&Xa(n,yc(c));continue}let p=yc(c);a.push({fd:d==="out"?1:2,text:p}),d==="out"?f+=p:l+=p}return{...o,stdout:f,stderr:l,events:a,unordered:gs(o)&&f!==""&&l!==""}}var Mb=new Map([["ls",2],["grep",2],["egrep",2],["fgrep",2],["sort",2],["xxd",3],["sed",4],["diff",2],["patch",2],["xargs",123],["hexdump",0],["tree",0]]),Pb=e=>e.stdout!==""||sn(e).some(t=>t.fd===1&&(t.bytes?.length??0)>0);function bs(e,t,n){return n.closed.out&&Pb(t)?Db(e,t,n):t}function Db(e,t,n){let r=Mb.get(n.registry.resolveCommand(e))??1,o=sn(t).filter(a=>a.fd!==1),i=r===0?"":`${e}: write error: Bad file descriptor
|
|
60
|
+
`;i&&o.push({fd:2,text:i});let s={...t,stdout:"",stderr:t.stderr+i,exitCode:r||t.exitCode,events:o,unordered:!1},u=O(t);return u?ie(s,u.kind,u.command,u.detail,u.message):s}var Bb=new Map([["\0","0"],["\x07","a"],["\b","b"],["\f","f"],[`
|
|
61
|
+
`,"n"],["\r","r"],[" ","t"],["\v","v"]]);function X(e,t){let n=le(t),r=n?Array.from(B(e),s=>String.fromCodePoint(s)):[...e];if(!n&&r.some(s=>s.codePointAt(0)>127&&/[\p{C}\p{Zl}\p{Zp}]/u.test(s)))throw new y("feature","filename quoting","quoting nonprinting Unicode filenames is not supported");if(e.includes("'")&&r.every(s=>/[-a-zA-Z0-9 %+,./:_\]']/u.test(s)||!n&&s.codePointAt(0)>127))return'"'+e+'"';let o=!1,i="'";for(let s of r){let u=s.codePointAt(0),a=Bb.get(s)??(u<32||u===127||n&&u>127?u.toString(8).padStart(3,"0"):null);a!==null?(o||(i+="'$'"),o=!0,i+="\\"+a):s==="'"?(i+="'\\''",o=!1):(o&&(i+="''"),o=!1,i+=s)}return i+"'"}var Ub=/^[#%+,\-./0-9@A-Z\]_a-z{}~]+$/u;function oe(e,t){return Ub.test(e)&&!"#~".includes(e[0])?e:X(e,t)}var jb=new Map([["\x07","a"],["\b","b"],["\f","f"],[`
|
|
62
|
+
`,"n"],["\r","r"],[" ","t"],["\v","v"],['"','"'],["\\","\\"]]);function ys(e,t){let n=le(t),r="",o=!1;for(let i of e){let s=i.codePointAt(0),u=jb.get(i);if(u!==void 0)r+="\\"+u,o=!0;else if(i===" ")r+=i,o=!0;else if(s<32||s===127||s>127&&(n||/[\p{C}\p{Zl}\p{Zp}]/u.test(i))){for(let a of A(i))r+="\\"+a.toString(8).padStart(3,"0");o=!0}else r+=i}return o?`"${r}"`:e}var Wb=new Set(["/dev/null","/dev/stdin","/dev/stdout","/dev/stderr"]);function kc(e,t,n){let r=N(t,{short:["f","n","v","T","r","R"],long:["force","no-clobber","verbose","no-target-directory","recursive"],valueShort:["t"],valueLong:["target-directory"]}),o=qb(r,n);if(o.error)return x("cp: "+o.error);let{sources:i,target:s,directory:u}=o,{flags:a}=r,l=a.has("v")||a.has("verbose"),f=a.has("r")||a.has("R")||a.has("recursive"),c=i.map(h=>[h,u?s.replace(/\/+$/u,"")+"/"+Gb(h):s]),d=a.has("n")||a.has("no-clobber"),p={ctx:n,result:U(),failed:!1,sources:new Set,copied:new Set,noClobber:d,force:a.has("f")||a.has("force"),verbose:l,recursive:f,outputOverlap:l&&Yb(c,n,{recursive:f,noClobber:d})};for(let[h,m]of c){n.io.setReads([]);try{$c(h,m,p)}catch(g){R(n,"cp",g?.path,g?.fsError);let w=O(g),b="cp: "+V(g);if(w)return n.unsupported.add({...w,command:w.command??"cp",message:b}),_(p.result,x(b)),p.result;Bt(p,b+`
|
|
63
|
+
`,!0)}}return p.result.exitCode=p.failed?1:0,p.result}function qb({positional:e,flags:t,order:n},r){let o=n.filter(({name:f})=>f==="t"||f==="target-directory");if(o.length>1)return{error:"multiple target directories specified"};let i=o[0]?.value,s=t.has("T")||t.has("no-target-directory");if(e.length===0)return{error:"missing file operand"};if(i===void 0&&e.length===1)return{error:"missing destination file operand after "+X(e[0],r)};if(i!==void 0&&s)return{error:"cannot combine --target-directory (-t) and --no-target-directory (-T)"};if(s&&e.length>2)return{error:"extra operand "+X(e[2],r)};let u=i??e.at(-1),a=E(r.cwd,u,r.fs),l=!s&&r.fs.isDir(a.path);return!l&&(i!==void 0||e.length>2)?(R(r,"cp",u,a.error),{error:`${i===void 0?"target":"target directory"} ${X(u,r)}: ${a.error??"Not a directory"}`}):{target:u,directory:l,sources:i===void 0?e.slice(0,-1):e}}function zb(e,t,n){let{ctx:r}=n,o=E(r.cwd,e,r.fs,{follow:!1}).path;if(o===null)return;let i=e.replace(/\/+$/u,""),s=t.replace(/\/+$/u,"");for(let u of Fe(r.fs,o)){if(u.kind!=="link")continue;let a=u.path===o?null:He(o,u.path);if(!vc(a===null?t:`${s}/${a}`,n)&&!(a!==null&&Hb(s,a,n)))throw Sc(a===null?e:`${i}/${a}`)}}var vc=(e,t)=>t.noClobber&&E(t.ctx.cwd,e,t.ctx.fs,{follow:!1}).path!==null;function Hb(e,t,n){let{ctx:r}=n,o=t.split("/");for(let i=1;i<o.length;i++){let s=E(r.cwd,`${e}/${o.slice(0,i).join("/")}`,r.fs,{follow:!1});if(s.path!==null&&!r.fs.isDir(s.path))return!0}return!1}var Sc=e=>new y("feature","symbolic link",`copying a symbolic link is not supported: ${e} (a recursive copy keeps the link, which cp does not make here)`),Ec=(e,t,n)=>n.path===null&&e.fs.isLink?.(E(e.cwd,t,e.fs,{follow:!1}).path)===!0,Gb=e=>{let t=e.replace(/\/+$/u,"").split("/").at(-1);return t===".."?".":t};function $c(e,t,n,r=null){let{ctx:o}=n;if(xc(e,o.cwd)||xc(t,o.cwd))throw new y("feature","special file","copying special files is not supported");let i=X(e,o),s=X(t,o);if(n.recursive&&o.fs.isLink?.(E(o.cwd,e,o.fs,{follow:!1}).path)){if(!vc(t,n))throw Sc(e);return}let u=P(o,"cp",e),a=d=>Bt(n,"cp: "+d+`
|
|
64
|
+
`,!0);if(u.error)return a(`cannot stat ${i}: ${u.error}`);if(o.fs.isDir(u.path))return n.recursive?Xb(e,u.path,t,n,r??{source:i,target:s},r===null):a(`-r not specified; omitting directory ${i}`);if(r===null){if(n.sources.has(u.path))return Bt(n,`cp: warning: source file ${i} specified more than once
|
|
65
|
+
`,!1,!0);n.sources.add(u.path)}let l=E(o.cwd,t,o.fs);if(l.error&&l.error!=="No such file or directory")return a(`cannot stat ${s}: ${l.error}`);if(n.noClobber&&l.path!==null)return;if(Oc(u.path,l.path,o.fs))return a(`${i} and ${s} are the same file`);if(o.fs.isDir(l.path))return a(`cannot overwrite directory ${s} with non-directory ${i}`);let f=se(o.fs,o.cwd,t);if(r===null&&n.copied.has(f))return a(`will not overwrite just-created ${s} with ${i}`);let c=tt(o.cwd,t,o.fs,l);if(Nc(i,s,n),Ec(o,t,l))return a(`not writing through dangling symlink ${s}`);if(c)return R(o,"cp",t,c),a(`cannot create regular file ${s}: ${c}`);try{if(!o.fs.copyWritable?.(o.cwd,u.path,t))return a(`${n.force&&l.path!==null?"cannot remove":"cannot create regular file"} ${s}: Read-only file system`)}catch(d){if(O(d))throw d;R(o,"cp",d?.path,d?.fsError);let p=V(d);return a(`cannot create regular file ${s}: ${p.startsWith(t+": ")?p.slice(t.length+2):p}`)}r===null&&n.copied.add(f)}function Xb(e,t,n,r,o,i){let{ctx:s}=r,u=X(e,s),a=X(n,s),l=b=>Bt(r,"cp: "+b+`
|
|
66
|
+
`,!0),f=E(s.cwd,n,s.fs,{follow:!1});if(f.error&&f.error!=="No such file or directory")return l(`cannot stat ${a}: ${f.error}`);let c=n.replace(/\/+$/u,"")||n;if(se(s.fs,s.cwd,c,!0)===t)return l(`${u} and ${a} are the same file`);if(f.path!==null&&!s.fs.isDir(f.path))return l(`cannot overwrite non-directory ${a} with directory ${u}`);let d=se(s.fs,s.cwd,c,!1);if(f.path===null){let b=tt(s.cwd,c,s.fs);if(b)return R(s,"cp",c,b),l(`cannot create directory ${a}: ${b}`);if(!s.writable||!ut(d))return l(`cannot create directory ${a}: Read-only file system`)}if(d.startsWith(t==="/"?"/":t+"/"))return l(`cannot copy a directory, ${o.source}, into itself, ${o.target}`);if(i){if(r.sources.has(t))return Bt(r,`cp: warning: source directory ${u} specified more than once
|
|
67
|
+
`,!1,!0);r.sources.add(t)}i&&zb(e,n,r);let{dirs:p,files:h,links:m}=s.fs.listDir(t);if(f.path===null&&!Zb(e,n,c,d,r))return;let g=e.replace(/\/+$/u,""),w=n.replace(/\/+$/u,"");for(let b of[...p,...h,...m].sort(j))s.io.setReads([]),$c(`${g}/${b}`,`${w}/${b}`,r,o)}function Zb(e,t,n,r,o){let{ctx:i}=o,s=X(t,i),u=l=>(Bt(o,"cp: cannot create directory "+s+": "+l+`
|
|
68
68
|
`,!0),!1),a=i.writable&&ut(r);a&&Ac(o);try{if(!a||!i.fs.makeWritableDir?.(i.cwd,n))return u("Read-only file system")}catch(l){if(O(l))throw l;R(i,"cp",l?.path,l?.fsError);let f=V(l);return u(f.startsWith(n+": ")?f.slice(n.length+2):f)}return Nc(X(e,i),s,o),!0}function Nc(e,t,n){n.verbose&&(Ac(n),Bt(n,`${e} -> ${t}
|
|
69
|
-
`))}function Ac(e){if(e.outputOverlap)throw new
|
|
70
|
-
`);if(r.path==="/tmp")o="Device or resource busy";else if(!n.writable||!ut(r.path))o="Read-only file system";else return Tc(e,r.path,t,
|
|
71
|
-
`);n.verbose&&
|
|
72
|
-
`,1)}function
|
|
69
|
+
`))}function Ac(e){if(e.outputOverlap)throw new y("feature","copy output buffering","buffered verbose output sharing a copied file is not supported")}function Oc(e,t,n){if(e===t)return!0;let r=n.fileIdentity?.(e);return r!==void 0&&r===n.fileIdentity(t)}function Yb(e,t,{recursive:n,noClobber:r}){let o=t.outputFds[1];if(typeof o!="object")return!1;let i={ctx:t,recursive:n,noClobber:r,holds:s=>o.identity===void 0?o.path===s:o.identity===t.fs.fileIdentity?.(s),made:new Set,sources:new Set,copied:new Set};return e.some(([s,u])=>Vb(s,u,i))}function Vb(e,t,n){let{ctx:r}=n,o=E(r.cwd,e,r.fs),i=o.path??Z(r.cwd,e),s=o.error==="No such file or directory"&&(n.made.has(i)||Qb(i,n));if(o.error&&!s)return!1;let u=se(r.fs,r.cwd,t);return(o.error===null?r.fs.isDir(o.path):!n.made.has(i))?!n.recursive||!ty(i,t,r)||n.sources.has(i)?!1:(n.sources.add(i),Kb(i,u,n)):n.sources.has(i)||(n.sources.add(i),n.copied.has(u)||!ey(i,u,t,r,n.noClobber))?!1:(n.copied.add(u),n.made.add(u),n.holds(i)||n.holds(u))}function Kb(e,t,n){let{ctx:r}=n,o=e==="/"?0:e.length;for(let i of Jb(e,n)){let s=t+i.slice(o);if(!Cc(i,s,E(r.cwd,s,r.fs),r,n.noClobber)&&(n.made.add(s),n.holds(i)||n.holds(s)))return!0}return!1}function Jb(e,t){let n=e==="/"?"/":e+"/",r=t.ctx.fs.isDir(e)?[...t.ctx.fs.walkFiles(e)]:[];return new Set([...r,...[...t.made].filter(o=>o.startsWith(n))])}var Qb=(e,t)=>[...t.made].some(n=>n.startsWith(e+"/"));function Cc(e,t,n,r,o){return n.error&&n.error!=="No such file or directory"||o&&n.path!==null||Oc(e,n.path,r.fs)||r.fs.isDir(n.path)?!0:!r.writable||!ut(t)}function ey(e,t,n,r,o){let i=E(r.cwd,n,r.fs);return!Cc(e,t,i,r,o)&&!Ec(r,n,i)&&!tt(r.cwd,n,r.fs,i)}function ty(e,t,n){let r=E(n.cwd,t,n.fs,{follow:!1});if(r.error&&r.error!=="No such file or directory")return!1;let o=t.replace(/\/+$/u,"")||t;if(r.path!==null&&!n.fs.isDir(r.path)||r.path===null&&tt(n.cwd,o,n.fs))return!1;let i=se(n.fs,n.cwd,o,!1);return se(n.fs,n.cwd,o,!0)===e||i.startsWith(e==="/"?"/":e+"/")?!1:!!n.writable&&ut(i)}function xc(e,t){let n=e.startsWith("/")?e:t+"/"+e;return Wb.has(n.replace(/\/\.(?=\/)/gu,"").replace(/\/+/gu,"/"))}function Bt(e,t,n=!1,r=!1){let o=n||r?U(t):{...U(),stdout:t,events:[{fd:1,text:t}]};_(e.result,e.ctx.flushOutput(o)),e.failed||=n}function Ic(e,t,n){let{flags:r,positional:o}=N(t,{short:["f","v","r","R"],long:["force","verbose","recursive"]}),i=r.has("f")||r.has("force"),s=r.has("v")||r.has("verbose"),u=r.has("r")||r.has("R")||r.has("recursive");if(o.length===0)return i?F(""):x("rm: missing operand");let a={ctx:n,force:i,verbose:s,recursive:u,events:[],stdout:"",stderr:""};try{for(let l of o)ny(l,a)}catch(l){R(n,"rm",l?.path,l?.fsError);let f=K(l,"rm","rm: "+V(l));return f.events=[...a.events,{fd:2,text:f.stderr}],f.stdout=a.stdout,f.stderr=a.stderr+f.stderr,f}return{stdout:a.stdout,stderr:a.stderr,events:a.events,exitCode:a.stderr?1:0}}function ny(e,t){let{ctx:n}=t,r=E(n.cwd,e,n.fs,{follow:!1}),o=r.error;if(!(t.force&&(o==="No such file or directory"||o==="Not a directory"))){if(R(n,"rm",e,o),o===null&&n.fs.isDir(r.path))if(!t.recursive)o="Is a directory";else{if([".",".."].includes(e.replace(/\/+$/u,"").split("/").at(-1)))return ks(t,`rm: refusing to remove '.' or '..' directory: skipping ${X(e,n)}
|
|
70
|
+
`);if(r.path==="/tmp")o="Device or resource busy";else if(!n.writable||!ut(r.path))o="Read-only file system";else return Tc(e,r.path,t,ry(n,e)?"Not a directory":null)}xs(e,r.path,t,!1,o)}}function ry(e,t){let n=t.replace(/\/+$/u,"");return n===t||n===""?!1:e.fs.isLink?.(E(e.cwd,n,e.fs,{follow:!1}).path)===!0}function Tc(e,t,n,r=null){let{ctx:o}=n,{dirs:i,files:s,links:u=[]}=o.fs.listDir(t),a=e.replace(/\/+$/u,"");for(let l of[...i,...s,...u].sort(j)){let f=Te(t,l);o.fs.isDir(f)?Tc(`${a}/${l}`,f,n):xs(`${a}/${l}`,f,n,!1,null)}xs(e,t,n,!0,r)}function xs(e,t,n,r,o){let{ctx:i}=n,s=n.verbose||o!==null||!i.writable||!t?.startsWith("/tmp/")?X(e,i):"",u=()=>r?i.fs.removeWritableDir?.(i.cwd,e):i.fs.removeWritable?.(i.cwd,e);try{o===null&&!u()&&(o="Read-only file system")}catch(a){if(O(a))throw a;R(i,"rm",a?.path,a?.fsError);let l=V(a);o=a?.fsError??(l.startsWith(e+": ")?l.slice(e.length+2):l)}if(o)return ks(n,`rm: cannot remove ${s}: ${o}
|
|
71
|
+
`);n.verbose&&ks(n,`removed ${r?"directory ":""}${s}
|
|
72
|
+
`,1)}function ks(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function Lc(e,t,n){let{flags:r,positional:o}=N(t,{short:["p","v"],long:["parents","verbose"]});if(o.length===0)return x("mkdir: missing operand");let i={ctx:n,events:[],stdout:"",stderr:"",parents:r.has("p")||r.has("parents"),verbose:r.has("v")||r.has("verbose")};try{for(let s of o)i.parents?oy(s,i):vs(s,i,!0)}catch(s){R(n,"mkdir",s?.path,s?.fsError);let u=K(s,"mkdir","mkdir: "+V(s));return u.events=[...i.events,{fd:2,text:u.stderr}],u.stdout=i.stdout,u.stderr=i.stderr+u.stderr,u}return{stdout:i.stdout,stderr:i.stderr,events:i.events,exitCode:i.stderr?1:0}}function oy(e,t){let n=e.split("/"),r=[];for(let o=0;o<n.length;o++)n[o]!==""&&r.push(n.slice(0,o+1).join("/"));if(r.length===0){e===""&&vs(e,t,!0);return}r[r.length-1]=e;for(let[o,i]of r.entries())if(!vs(i,t,o===r.length-1))return}function vs(e,t,n){let{ctx:r}=t,o=X(e,r),i=l=>(Fc(t,`mkdir: cannot create directory ${o}: ${l}
|
|
73
73
|
`),!1),s=e.replace(/\/+$/u,"")||e,u=E(r.cwd,s,r.fs);if(u.error===null)return t.parents?r.fs.isDir(u.path)?!0:i(n?"File exists":"Not a directory"):i("File exists");if(E(r.cwd,s,r.fs,{follow:!1}).error===null)return i(!t.parents||n||u.error!=="Not a directory"?"File exists":"Not a directory");let a=tt(r.cwd,s,r.fs,u);if(a)return R(r,"mkdir",s,a),i(a);try{if(!r.fs.makeWritableDir?.(r.cwd,s))return i("Read-only file system")}catch(l){if(O(l))throw l;R(r,"mkdir",l?.path,l?.fsError);let f=V(l);return i(f.startsWith(s+": ")?f.slice(s.length+2):f)}return t.verbose&&Fc(t,`mkdir: created directory ${o}
|
|
74
|
-
`,1),!0}function Fc(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function _c(e,t,n){let{flags:r,positional:o}=N(t,{short:["c"],long:["no-create"]});if(o.length===0)return x("touch: missing file operand");let i=r.has("c")||r.has("no-create"),s={ctx:n,stderr:"",failed:!1,gap:null};for(let a of o)
|
|
74
|
+
`,1),!0}function Fc(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}function _c(e,t,n){let{flags:r,positional:o}=N(t,{short:["c"],long:["no-create"]});if(o.length===0)return x("touch: missing file operand");let i=r.has("c")||r.has("no-create"),s={ctx:n,stderr:"",failed:!1,gap:null};for(let a of o)iy(a,i,s);let u={stdout:"",stderr:s.stderr,exitCode:s.failed?1:0};return s.gap?ie(u,"feature","touch","times",s.gap):u}function iy(e,t,n){let{ctx:r}=n,o=X(e,r),i=E(r.cwd,e,r.fs);if(i.error===null)return sy(e,o,i.path,n);let s=t||e.endsWith("/");if(t&&i.error==="No such file or directory")return;if(R(r,"touch",e,i.error),s)return Yn(n,`setting times of ${o}: ${i.error}`);let u=tt(r.cwd,e,r.fs,i);if(u)return Yn(n,`cannot touch ${o}: ${u}`);try{r.fs.openWritable?.(r.cwd,e,!0)||Yn(n,`cannot touch ${o}: Read-only file system`)}catch(a){if(O(a))throw a;R(r,"touch",a?.path,a?.fsError);let l=V(a);Yn(n,`cannot touch ${o}: ${l.startsWith(e+": ")?l.slice(e.length+2):l}`)}}function sy(e,t,n,r){let{ctx:o}=r;if(!o.writable||!ut(n))return Yn(r,`setting times of ${t}: Read-only file system`);let i=`touch: setting the times of ${t} is not supported (every entry here carries the one time this filesystem keeps)`;r.gap??=i,r.stderr+=i+`
|
|
75
75
|
`,r.failed=!0}function Yn(e,t){e.stderr+=`touch: ${t}
|
|
76
|
-
`,e.failed=!0}function Vn(e,t,n,r){if(t===""||t.includes("\0"))return{error:"No such file or directory"};if(r==="none")return
|
|
77
|
-
`,d=U(),p=!1;for(let h of i){let m=Vn(n,h,a,u);if(m.error)R(n,"realpath",h,m.error),f||_(d,x(`realpath: ${oe(h,n)}: ${m.error}`)),p=!0;else{let g=l.target&&(!l.base||Dc(l.base,m.path))?
|
|
78
|
-
`);if(u==="")return a(` -> ${X(u,i)}: No such file or directory`);if(o)return a(": No such file or directory");if(n.force){let f=E(i.cwd,t,i.fs,{follow:!1});if(f.error===null){if(i.fs.isDir(f.path))return
|
|
79
|
-
`);try{if(!i.fs.removeWritable?.(i.cwd,t))return a(": Read-only file system")}catch(c){if(O(c))throw c;return a(`: ${Uc(c,t)}`)}}}let l=
|
|
80
|
-
`,1)}function
|
|
76
|
+
`,e.failed=!0}function Vn(e,t,n,r){if(t===""||t.includes("\0"))return{error:"No such file or directory"};if(r==="none")return uy(e,t,n);let o=t;if(r==="logical"){let s=n==="m"?{path:Z(e.cwd,t)}:Pc(e,t);if(s.error)return s;o=s.path+(t.endsWith("/")?"/":"")}let i=ze(e.cwd,o,e.fs,{lenient:n==="m"});return n==="m"?{path:i.rest.length?Z(i.path,i.rest.join("/")):i.path}:i.error==="No such file or directory"&&i.rest.length===0&&n!=="e"?{path:i.path}:i.error?{error:i.error}:t.endsWith("/")&&!e.fs.isDir(i.path)?{error:"Not a directory"}:{path:i.path}}function uy(e,t,n){if(n==="m")return{path:Z(e.cwd,t)};let r=Pc(e,t);if(r.error||n!=="e")return r;let o=E("/",r.path,e.fs);return o.error?{error:o.error}:r}function Pc(e,t){let n=(t.startsWith("/")?t:e.cwd+"/"+t).split("/").filter(Boolean),r="/";for(let o=0;o<n.length;o++){let i=n[o];if(i==="..")r=be(r);else if(i!=="."){r=Te(r,i);let s=o+1;for(;n[s]===".";)s++;let u=n[s]===".."||s===n.length&&(o<n.length-1||t.endsWith("/"));if(u||o===n.length-1){let a=E("/",r+(u?"/":""),e.fs);if(a.error&&!(a.error==="No such file or directory"&&o===n.length-1))return a}}}return{path:r}}function Ss(e,t){let n=e.split("/").filter(Boolean),r=t.split("/").filter(Boolean),o=0;for(;o<n.length&&o<r.length&&n[o]===r[o];)o++;return[...n.slice(o).map(()=>".."),...r.slice(o)].join("/")||"."}var Dc=(e,t)=>e==="/"||t===e||t.startsWith(e+"/"),Rc={e:"e","canonicalize-existing":"e",m:"m","canonicalize-missing":"m"},Mc={P:"physical",physical:"physical",L:"logical",logical:"logical",s:"none",strip:"none","no-symlinks":"none"};function ay(e,t,n,r){let o=t.get("relative-base"),i=t.get("relative-to")??o,s={};for(let[u,a]of[["target",i],["base",o]]){if(a===void 0)continue;let l=Vn(e,a,n,r),f=l.error??(n==="e"&&!e.fs.isDir(l.path)?"Not a directory":null);if(f)return R(e,"realpath",a,f),{error:x(`realpath: ${oe(a,e)}: ${f}`)};s[u]=l.path}return s.base&&!Dc(s.base,s.target)&&delete s.target,s}function Bc(e,t,n){let{flags:r,values:o,positional:i,order:s}=N(t,{short:["e","m","L","P","s","q","z"],long:["canonicalize-existing","canonicalize-missing","logical","physical","strip","no-symlinks","quiet","zero"],valueLong:["relative-to","relative-base"]});if(!i.length)return x("realpath: missing operand");let u="physical",a="E";for(let{name:h}of s)Object.hasOwn(Rc,h)&&(a=Rc[h]),Object.hasOwn(Mc,h)&&(u=Mc[h]);let l=ay(n,o,a,u);if(l.error)return l.error;let f=r.has("q")||r.has("quiet"),c=r.has("z")||r.has("zero")?"\0":`
|
|
77
|
+
`,d=U(),p=!1;for(let h of i){let m=Vn(n,h,a,u);if(m.error)R(n,"realpath",h,m.error),f||_(d,x(`realpath: ${oe(h,n)}: ${m.error}`)),p=!0;else{let g=l.target&&(!l.base||Dc(l.base,m.path))?Ss(l.target,m.path):m.path;_(d,F(g+c))}}return d.exitCode=p?1:0,d}var ao={symbolic:"s",force:"f","no-dereference":"n","no-target-directory":"T",verbose:"v",relative:"r",logical:"L",physical:"P"};function jc(e,t,n){let r=N(t,{short:Object.values(ao),long:Object.keys(ao),valueShort:["t"],valueLong:["target-directory"]}),o=l=>r.flags.has(l)||r.flags.has(Object.keys(ao).find(f=>ao[f]===l)),i={force:o("f"),noDereference:o("n"),noTargetDirectory:o("T"),verbose:o("v"),relative:o("r")},s=r.order.findLast(({name:l})=>l==="t"||l==="target-directory")?.value??null,u=r.positional;if(s!==null&&i.noTargetDirectory)return x("ln: cannot combine --target-directory and --no-target-directory");if(i.relative&&!o("s"))return x("ln: cannot do --relative without --symbolic");if(u.length===0)return x("ln: missing file operand");if(!o("s"))return v("feature","ln","hard link",`ln: hard links are not supported: ${X(u[0],n)} (ln -s makes a symbolic one)`);let a={ctx:n,events:[],stdout:"",stderr:""};try{let l=ly(u,s,i,n);if(l.error)return l.error;for(let[f,c,d]of l)fy(f,c,i,a,d)}catch(l){R(n,"ln",l?.path,l?.fsError);let f=K(l,"ln","ln: "+V(l));return f.events=[...a.events,{fd:2,text:f.stderr}],f.stdout=a.stdout,f.stderr=a.stderr+f.stderr,f}return{stdout:a.stdout,stderr:a.stderr,events:a.events,exitCode:a.stderr?1:0}}function ly(e,t,n,r){let o=a=>X(a,r);if(t!==null){let a=E(r.cwd,t,r.fs);return a.error?(R(r,"ln",t,a.error),{error:x(`ln: failed to access ${o(t)}: ${a.error}`)}):r.fs.isDir(a.path)?e.map(l=>Es(t,l)):{error:x(`ln: target ${o(t)} is not a directory`)}}if(e.length===1)return n.noTargetDirectory?{error:x(`ln: missing destination file operand after ${o(e[0])}`)}:[Es(".",e[0])];if(e.length===2){let a=E(r.cwd,e[1],r.fs,{follow:!n.noDereference});if(n.noTargetDirectory||a.error!==null||!r.fs.isDir(a.path))return[[e[0],e[1]]]}if(n.noTargetDirectory)return{error:x(`ln: extra operand ${o(e[2])}`)};let i=e.at(-1),s=E(r.cwd,i,r.fs),u=s.error??(r.fs.isDir(s.path)?null:"Not a directory");return u?(R(r,"ln",i,u),{error:x(`ln: target ${o(i)}: ${u}`)}):e.slice(0,-1).map(a=>Es(i,a))}function Es(e,t){let n=t.replace(/\/+$/u,"").split("/").at(-1);return[t,e+(e.endsWith("/")?"":"/")+n,n===""]}function fy(e,t,n,r,o=!1){let{ctx:i}=r,s=X(t,i),u=n.relative?dy(i,e,t):e,a=f=>$s(r,`ln: failed to create symbolic link ${s}${f}
|
|
78
|
+
`);if(u==="")return a(` -> ${X(u,i)}: No such file or directory`);if(o)return a(": No such file or directory");if(n.force){let f=E(i.cwd,t,i.fs,{follow:!1});if(f.error===null){if(i.fs.isDir(f.path))return $s(r,`ln: ${oe(t,i)}: cannot overwrite directory
|
|
79
|
+
`);try{if(!i.fs.removeWritable?.(i.cwd,t))return a(": Read-only file system")}catch(c){if(O(c))throw c;return a(`: ${Uc(c,t)}`)}}}let l=cy(i,t);if(l)return R(i,"ln",t,l),a(`: ${l}`);try{if(!i.fs.makeWritableLink?.(i.cwd,t,u))return a(": Read-only file system")}catch(f){if(O(f))throw f;return R(i,"ln",f?.path,f?.fsError),a(`: ${Uc(f,t)}`)}n.verbose&&$s(r,`${s} -> ${X(u,i)}
|
|
80
|
+
`,1)}function cy(e,t){if(t===""||t.includes("\0"))return"No such file or directory";let n=t.replace(/\/+$/u,"");if(n==="")return"File exists";let r=E(e.cwd,n,e.fs,{follow:!1});if(r.error===null)return"File exists";if(r.error!=="No such file or directory"||t!==n)return r.error;let o=ze(e.cwd,n,e.fs);return o.rest.length>0?o.error:null}function dy(e,t,n){let r=Vn(e,be(n),"m","physical"),o=Vn(e,t,"m","physical");return r.error||o.error?t:Ss(r.path,o.path)}function Uc(e,t){let n=V(e);return e?.fsError??(n.startsWith(t+": ")?n.slice(t.length+2):n)}function $s(e,t,n=2){n===1?e.stdout+=t:e.stderr+=t,e.events.push({fd:n,text:t})}var Wc={cp:kc,rm:Ic,mkdir:Lc,touch:_c,ln:jc};function py(e,t,n){let{positional:r}=N(t),o=te("tac",r,e,n),i=[];for(let{content:s}of o.inputs)i.push(...Ge(s).toReversed());return ne(i.join(""),o)}var qc=1e6;function hy(e,t){let{flags:n,values:r,positional:o}=N(t,{short:["w"],valueShort:["s"],numericOperands:!0});if(o.length===0||o.length>3)return pe("seq [-w] [-s SEP] LAST | seq FIRST LAST | seq FIRST INCR LAST");let i=[];for(let p of o){if(!/^[+-]?\d+$/u.test(p))return Number.isFinite(Number(p))&&p.trim()!==""||/^[+-]?inf(?:inity)?$/iu.test(p)?v("feature","seq","non-integer operands","seq: non-integer operands are not supported"):x(`seq: invalid integer: ${p}`);i.push(BigInt(p))}let s=i.length===1?1n:i[0],u=i.length===3?i[1]:1n,a=i.at(-1);if(u===0n)return x("seq: increment must be non-zero");let f=(u>0?s<=a:s>=a)?(a>s?a-s:s-a)/(u>0n?u:-u)+1n:0;if(f>qc)return v("feature","seq","sequence limit",`seq: range too large: ${f} elements exceeds limit of ${qc}`);let c=n.has("w")?Math.max(...[o[0],o.at(-1)].map(p=>p.replace(/^\+/u,"").length)):0,d=[];for(let p=0,h=s;p<f;p++,h+=u)d.push(my(String(h),c));return F(d.length===0?"":d.join(r.get("s")??`
|
|
81
81
|
`)+`
|
|
82
|
-
`)}function
|
|
83
|
-
`,exitCode:1};l.push(`${String(u).padStart(Hc)}${Gc}${c}`),u++}else l.push(
|
|
84
|
-
`?d===""?[]:[d]:he(d)){if(s&&!p.includes(l)){r.has("s")||c.push(p);continue}c.push(s?
|
|
85
|
-
`?he(e):e.split(t);return Xc(r,n).join(t)}function
|
|
86
|
-
`:o==="t"?" ":o==="\\"?"\\":o==="0"?"\0":o};for(;n<e.length;){let o=r();if(e[n]==="-"&&n+1<e.length){n++;let i=r();if(i===null)return{error:x("tr: trailing backslash in set")};let s=o.codePointAt(0),u=i.codePointAt(0);if(u<s)return{error:x(`tr: range-endpoints of '${o}-${i}' are in reverse collating sequence order`)};for(let a=s;a<=u;a++)t.push(String.fromCodePoint(a))}else t.push(o)}return{chars:t}}function
|
|
87
|
-
`)}function
|
|
88
|
-
`)}var
|
|
89
|
-
`,t:" ","%":"%"};return t.replace(/%./gu,p=>{let h=d[p[1]];return typeof h=="function"?h():h??p})}function
|
|
82
|
+
`)}function my(e,t){if(e.length>=t)return e;let n=e.startsWith("-"),r=n?e.slice(1):e;return(n?"-":"")+r.padStart(t-(n?1:0),"0")}var Hc=6,Gc=" ",gy=" ".repeat(Hc+Gc.length);function wy(e,t,n){let{values:r,positional:o,order:i}=N(t,{valueShort:["b","v"],valueLong:["starting-line-number"]}),s=r.get("b")??"t";if(!["a","t","n"].includes(s)){let f=`nl: -b: only \`a\`, \`t\` and \`n\` are supported (got \`${s}\`)`;return s.startsWith("p")?v("option","nl","-b p",f):x(f)}let u=1n;for(let{name:f,value:c}of i)if(!(f!=="v"&&f!=="starting-line-number")){if(!/^[ \t\n\r\f\v]*[+-]?\d+$/u.test(c))return x(`nl: invalid starting line number: ${c}`);if(u=BigInt(c),u<ot||u>ue)return x(`nl: invalid starting line number: ${c}`)}let a=te("nl",o,e,n);if(a.inputs.some(({content:f})=>/(?:^|\n)(?:\\:){1,3}(?:\n|$)/u.test(f)))return v("feature","nl","logical pages","nl: logical page delimiters are not supported");let l=[];for(let{content:f}of a.inputs)for(let c of he(f))if(s==="a"||s==="t"&&c!==""){if(u>ue)return{stdout:ge(l),stderr:a.stderr+`nl: line number overflow
|
|
83
|
+
`,exitCode:1};l.push(`${String(u).padStart(Hc)}${Gc}${c}`),u++}else l.push(gy+c);return ne(ge(l),a)}function by(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["s"],valueShort:["d","f","c"]}),s=o.has("f"),u=o.has("c");if(s===u)return pe("cut -f LIST [-d DELIM] [-s] [file...] | cut -c LIST [file...]");if(u&&o.has("d"))return x("cut: -d is only valid with -f");if(u&&r.has("s"))return x("cut: -s is only valid with -f");let a=vy(s?o.get("f"):o.get("c"),s?"field":"position");if(a.error)return a.error;let l=o.get("d")===""?"\0":o.get("d")??" ";if(s&&A(l).length!==1)return x("cut: -d delimiter must be a single byte");let f=te("cut",i,e,n),c=[];for(let{content:d}of f.inputs)for(let p of s&&l===`
|
|
84
|
+
`?d===""?[]:[d]:he(d)){if(s&&!p.includes(l)){r.has("s")||c.push(p);continue}c.push(s?Sy(p,l,a.ranges):yy(p,a.ranges))}return ne(ge(c),f)}function yy(e,t){let n=A(e);return W(Uint8Array.from(Xc(n,t)))}var xy={field:{zero:"fields are numbered from 1",range:"invalid field range",value:e=>`invalid field value '${e}'`,large:e=>`field number '${e}' is too large`},position:{zero:"byte/character positions are numbered from 1",range:"invalid byte or character range",value:e=>`invalid byte/character position '${e}'`,large:e=>`byte/character offset '${e}' is too large`}},ky=/^(\d*)(-?)(\d*)/u;function vy(e,t){let n=xy[t],r=s=>({error:x(`cut: ${s}`)}),o=[];for(let s of e.split(/[, \t]/u)){if(s==="")return r(n.zero);let[u,a,l,f]=ky.exec(s),c=s.slice(u.length);if(c!=="")return r(c.startsWith("-")?n.range:n.value(c));for(let h of[a,f])if(h!==""&&BigInt(h)>it)return r(n.large(h));if(a===""&&f===""&&l==="")return r(n.value(s));let d=a===""?1:Number(a),p=l===""?d:f===""?1/0:Number(f);if(d<1)return r(n.zero);if(p<d)return r("invalid decreasing range");o.push([d,p])}o.sort((s,u)=>s[0]-u[0]);let i=[];for(let s of o){let u=i.at(-1);u&&s[0]<=u[1]+1?u[1]=Math.max(u[1],s[1]):i.push(s)}return{ranges:i}}function Xc(e,t){return t.flatMap(([n,r])=>Array.from(e.slice(n-1,r)))}function Sy(e,t,n){let r=t===`
|
|
85
|
+
`?he(e):e.split(t);return Xc(r,n).join(t)}function Ey(e,t,n){let{flags:r,positional:o}=N(t,{short:["c","d","s"]}),i=r.has("d"),s=r.has("s"),u=r.has("c");if(i&&s)return v("option","tr","-d -s","tr: -d combined with -s is not supported");if(s&&!i&&o.length===2)return v("feature","tr","translate and squeeze","tr: combined translation and squeezing is not supported");let a=i||s?1:2;if(o.length!==a)return pe("tr [-c] SET1 SET2 | tr [-c] -d SET | tr [-c] -s SET");if(/\P{ASCII}/u.test(e+o.join("")))return v("feature","tr","non-ASCII bytes","tr: translation of non-ASCII bytes is not supported");if(o.some(g=>/\[[:.=]|\[[^\]]*\*/u.test(g)))return v("feature","tr","set expressions","tr: character classes, equivalence classes and repetition expressions are not supported");if(o.some(g=>/\\[0-7]{2}|\\[1-7abfrv]/u.test(g)))return v("feature","tr","set escapes","tr: these set escape sequences are not supported");if(o.some(g=>/(?:^|[^\\])(?:\\\\)*\\$/u.test(g)))return v("feature","tr","trailing backslash","tr: an unescaped trailing backslash in a set is not supported");let l=zc(o[0]);if(l.error)return l.error;let f=new Set(l.chars),c=g=>u!==f.has(g);if(i)return q(n),F([...e].filter(g=>!c(g)).join(""));if(s)return q(n),F($y(e,c));let d=zc(o[1]);if(d.error)return d.error;if(d.chars.length===0)return x("tr: when not truncating set1, string2 must be non-empty");q(n);let p=u?Array.from({length:256},(g,w)=>String.fromCodePoint(w)).filter(g=>!f.has(g)):l.chars,h=new Map,m=d.chars.at(-1);for(let g=0;g<p.length;g++)h.set(p[g],d.chars[g]??m);return F([...e].map(g=>h.get(g)??g).join(""))}function zc(e){let t=[],n=0,r=()=>{if(e[n]!=="\\")return e[n++];if(n+1>=e.length)return null;let o=e[n+1];return n+=2,o==="n"?`
|
|
86
|
+
`:o==="t"?" ":o==="\\"?"\\":o==="0"?"\0":o};for(;n<e.length;){let o=r();if(e[n]==="-"&&n+1<e.length){n++;let i=r();if(i===null)return{error:x("tr: trailing backslash in set")};let s=o.codePointAt(0),u=i.codePointAt(0);if(u<s)return{error:x(`tr: range-endpoints of '${o}-${i}' are in reverse collating sequence order`)};for(let a=s;a<=u;a++)t.push(String.fromCodePoint(a))}else t.push(o)}return{chars:t}}function $y(e,t){let n="",r=null;for(let o of e)t(o)&&o===r||(n+=o,r=o);return n}function Ny(e,t,n){let{positional:r}=N(t);if(r.length===0)return pe("which COMMAND...");let o=[],i=0;for(let s of r)n.hasCommand(s)?o.push(`/usr/bin/${s}`):(o.push(`${s} not found`),i=1);return{stdout:ge(o),stderr:"",exitCode:i}}function Ay(e,t,n){let{positional:r}=N(t);return r.length>0?x(`whoami: extra operand: ${r[0]}`):F((n.user??"user")+`
|
|
87
|
+
`)}function Oy(e,t,n){let{flags:r,positional:o}=N(t,{short:["u"]});if(o.length>1)return x(`date: at most one +FORMAT argument is supported (got: ${o[1]})`);let i="%a %b %e %T %Z %Y";if(o.length===1){if(!o[0].startsWith("+"))return pe("date [-u] [+FORMAT]");i=o[0].slice(1)}return(i.match(/%./gu)??[]).some(s=>/%[-_0^#0-9:EOcCDgGhIjklNpPrRuUVwWxXy+]/u.test(s))?v("feature","date","format","date: this format directive or modifier is not supported"):F(Ns(new Date,i,r.has("u")||n.vars.has("TZ"))+`
|
|
88
|
+
`)}var Cy=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Iy=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ty=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Fy=["January","February","March","April","May","June","July","August","September","October","November","December"];function Ns(e,t,n){let r="get"+(n?"UTC":""),[o,i,s,u,a,l,f]=["FullYear","Month","Date","Hours","Minutes","Seconds","Day"].map(p=>e[r+p]()),c=(p,h="0")=>String(p).padStart(2,h),d={__proto__:null,Y:String(o),m:c(i+1),d:c(s),e:c(s," "),H:c(u),M:c(a),S:c(l),T:[u,a,l].map(p=>c(p)).join(":"),F:[o,c(i+1),c(s)].join("-"),q:String(Math.floor(i/3)+1),s:String(Math.floor(e.getTime()/1e3)),a:Cy[f],A:Iy[f],b:Ty[i],B:Fy[i],Z:()=>Ly(e,n),z:()=>_y(e,n),n:`
|
|
89
|
+
`,t:" ","%":"%"};return t.replace(/%./gu,p=>{let h=d[p[1]];return typeof h=="function"?h():h??p})}function Ly(e,t){if(t)return"UTC";try{return new Intl.DateTimeFormat("en-US",{timeZoneName:"short"}).formatToParts(e).find(o=>o.type==="timeZoneName")?.value??"Local"}catch{return"Local"}}function _y(e,t){if(t)return"+0000";let n=-e.getTimezoneOffset(),r=n>=0?"+":"-",o=Math.abs(n);return`${r}${String(Math.floor(o/60)).padStart(2,"0")}${String(o%60).padStart(2,"0")}`}var Zc={rg:bc,cut:by,tac:py,tr:Ey,seq:hy,nl:wy,which:Ny,hexdump:ff,base64:Sf,...Wc},Yc={whoami:Ay,date:Oy,od:cf,xxd:df,base32:vf,...sf};var As=new Map(Object.entries({all:"a","apparent-size":"A",bytes:"b",total:"c",null:"0","count-links":"l",summarize:"s","separate-dirs":"S","human-readable":"h","max-depth":"d","block-size":"B",dereference:"L","dereference-args":"D","no-dereference":"P"})),Vc={P:"none",D:"args",H:"args",L:"all"};function Jc(e,t){let n=N(e,{short:["0","a","A","b","c","h","H","k","l","m","s","S","L","D","P"],long:[...As.keys()].filter(i=>!["d","B"].includes(As.get(i))).concat(["inodes","si"]),valueShort:["d","B"],valueLong:["max-depth","block-size"]}),r={operands:n.positional.length?n.positional:["."],depth:1/0,flags:new Set,links:"none",scale:null,stderr:""};for(let{name:i,value:s}of n.order){let u=As.get(i)??i;r.flags.add(u),Object.hasOwn(Vc,u)&&(r.links=Vc[u]),u==="d"&&(r.depth=Ry(s)),u==="B"&&(r.scale=Kc(s)),u==="b"&&(r.flags.add("A"),r.scale={unit:1n}),(u==="k"||u==="m")&&(r.scale={unit:u==="k"?1024n:1024n**2n}),(u==="h"||u==="si")&&(r.scale={base:u==="h"?1024n:1000n,unit:1n})}let{flags:o}=r;if(o.has("a")&&o.has("s"))throw new Error("cannot both summarize and show all entries");if(o.has("s")&&o.has("d")){if(r.depth!==0)throw new Error(`summarizing conflicts with --max-depth=${r.depth}`);r.stderr+=`du: warning: summarizing is the same as using --max-depth=0
|
|
90
90
|
`}if(o.has("s")&&(r.depth=0),o.has("inodes")&&o.has("A")&&(r.stderr+=`du: warning: options --apparent-size and -b are ineffective with --inodes
|
|
91
|
-
`),!r.scale){let i=t.vars.get("DU_BLOCK_SIZE")??t.vars.get("BLOCK_SIZE")??t.vars.get("BLOCKSIZE");try{r.scale=i===void 0?{unit:t.vars.has("POSIXLY_CORRECT")?512n:1024n}:Kc(i)}catch(s){throw s instanceof
|
|
91
|
+
`),!r.scale){let i=t.vars.get("DU_BLOCK_SIZE")??t.vars.get("BLOCK_SIZE")??t.vars.get("BLOCKSIZE");try{r.scale=i===void 0?{unit:t.vars.has("POSIXLY_CORRECT")?512n:1024n}:Kc(i)}catch(s){throw s instanceof y?s:new y("feature","invalid block size environment","invalid block size environment settings are not supported")}}return o.has("inodes")&&(r.scale={...r.scale,unit:1n,suffix:r.scale.suffix?.endsWith("B")?"B":""}),r.scale.base&&Cs(t,r.scale.base),r}function Cs(e,t=1024n){let n=e.vars.get("LC_ALL")||e.vars.get("LC_NUMERIC")||e.locale;if(!/^(?:C|POSIX|C\.UTF-?8)$/iu.test(n))throw new y("feature","numeric locale","human-readable sizes in this numeric locale are not supported");return{base:t,unit:1n}}function Ry(e){let t=/^[ \t\n\r\v\f]*([+-]?)(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)$/u.exec(e);if(!t)throw new Error(`invalid maximum depth: ${e}`);let n=Qc(t[2]);if(n>ue||t[1]==="-"&&n!==0n)throw new Error(`invalid maximum depth: ${e}`);return Number(n)}function Qc(e){return BigInt(/^0[0-7]+$/u.test(e)?"0o"+e:e)}function Kc(e){let t=e&&["human-readable","si"].find(a=>a.startsWith(e));if(t)return{base:t==="si"?1000n:1024n,unit:1n};if(e.startsWith("'"))throw new y("feature","grouped block sizes","grouped block sizes are not supported");let n=/^[ \t\n\r\v\f]*\+?(0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)?([kKmMgGtTPEZYRQ](?:i?B|D)?)?$/u.exec(e);if(!n||!n[1]&&e!==n[2])throw new Error(`invalid block size: ${e}`);let r=n[2]??"",o=r?"KMGTPEZYRQ".indexOf(r[0].toUpperCase())+1:0,i=/[BD]$/u.test(r)&&!r.endsWith("iB")?1000n:1024n,s=(n[1]?Qc(n[1]):1n)*i**BigInt(o);if(s===0n||s>it)throw new Error(`invalid block size: ${e}`);let u=n[1]||!r?"":(o===1&&r.endsWith("B")&&i===1000n?"k":r[0].toUpperCase())+(r.endsWith("B")?i===1000n?"B":"iB":"");return{unit:s,suffix:u}}var Kn=4096,My=60,lo=(e,t)=>t==="dir"?Kn:t==="link"&&e<My?0:Math.ceil(e/Kn)*Kn,Os=(e,t)=>(e+t-1n)/t;function Jn(e,{base:t,unit:n,suffix:r=""}){if(!t)return String(Os(e,n))+r;let o=1n,i=0;for(;e>=o*t;)o*=t,i++;if(!i)return String(e);let s=Os(e*10n,o),u;return s<100n?u=`${s/10n}.${s%10n}`:(s=Os(e,o),s===t?(i++,u="1.0"):u=String(s)),u+(i===1&&t===1000n?"k":"KMGTPEZYRQ"[i-1])}var Py=31556952*1e3/2;function ed(e,t){for(let f of["LS_BLOCK_SIZE","BLOCK_SIZE","BLOCKSIZE"])if(e.vars.has(f))throw new y("feature","block size environment",`${f} is not supported in a long listing`);let n=t?Cs(e):null,r=e.user??"user",o=e.createdAt,i=Date.now(),s=o<=i&&i-o<Py,u=Ns(new Date(o),s?"%b %e %H:%M":"%b %e %Y",e.vars.has("TZ")),a=f=>n?Jn(BigInt(f),n):String(f),l=f=>Math.max(0,...f.map(c=>c.length));return{lines(f,c){let d=f.map(({name:g,abs:w,kind:b,target:k})=>{let S=b==="dir",I=S?Kn:e.fs.fileSize(w)??B(e.fs.readFile(w)).length,M=S?"drwx------":b==="link"?"lrwxrwxrwx":"-rw-------",C=lo(I,b)/512;return{name:b==="link"?`${g} -> ${k}`:g,mode:M,units:C,links:String(S?2+e.fs.listDir(w).dirs.length:1),size:a(I)}}),p=l(d.map(g=>g.links)),h=l(d.map(g=>g.size)),m=d.map(g=>`${g.mode} ${g.links.padStart(p)} ${r} ${r} ${g.size.padStart(h)} ${u} ${g.name}`);if(c){let g=d.reduce((w,b)=>w+b.units,0);m.unshift("total "+(n?Jn(BigInt(g)*512n,n):String(g/2)))}return m}}}function td(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["a","d","F"],long:["noreport"],valueShort:["L"]});if(i.length>1)return v("feature","tree","multiple roots","tree: multiple roots are not supported");let s=o.has("L")?ye(o.get("L"),"tree: -L",o.get("L"),{max:2147483647}):{value:Number.POSITIVE_INFINITY};if(s.error)return s.error;if(!s.value)return x("tree: -L must be greater than zero");let u=i[0]??".",{path:a,error:l}=P(n,"tree",u),f=!l&&n.fs.isDir(a),c=E(n.cwd,u,n.fs,{follow:!1}),d=!!l&&!!c.error,p={dirs:f&&fo(n.fs,a,r).length?1:0,files:!d&&!f?1:0},h=[u+Dy(n,r,c,f)+(f?"":" [error opening dir]")];if(f){let m=new Set,g=Jt();try{let w=By(n.fs,a,h,r,s.value,p,m,g);if(w)return w}finally{gt(n.notes,{command:"tree",action:"depth limit omitted contents of",noun:["directory","directories"],paths:m}),g.emit(n.notes,"tree","Hidden entries are included with -a.")}}if(!r.has("noreport")){let m=`${p.dirs} ${p.dirs===1?"directory":"directories"}`,g=`${p.files} ${p.files===1?"file":"files"}`;h.push("",r.has("d")?m:`${m}, ${g}`)}return{stdout:h.join(`
|
|
92
92
|
`)+`
|
|
93
|
-
`,stderr:"",exitCode:d?2:0}}function
|
|
94
|
-
`))),l.exitCode=1;continue}let h=new Set;for(let m of Fe(n.fs,d,s,g=>!h.has(g))){let g=
|
|
95
|
-
`:"\0"),stderr:"",exitCode:0})),!0):e.mode==="batch"?(e.collected.push(t.path),!0):ud(e.cmd,e.args.map(o=>o.replaceAll("{}",t.path)),n,r)}async function ud(e,t,n,r){let o=await n.dispatch(e,t,"");return
|
|
96
|
-
`,set:!0}:e==="PWD"?{value:t.cwd,set:!0}:e==="HOME"?{value:t.home,set:!0}:e==="USER"||e==="LOGNAME"?{value:t.user,set:!0}:e==="LANG"?{value:t.locale,set:!0}:null}function
|
|
97
|
-
`),e.unsupported.add({kind:"feature",command:null,detail:t,message:n})}var hd=16e6,er=e=>new
|
|
98
|
-
`;)i+=2;let s=Ed(o,"/",r.readExpansion,o[i]==="/"?i+1:0),u=await r.expand(o.slice(0,s),{pattern:!0}),a=await r.expand(s<o.length?o.slice(s+1):"",{replacement:!0});return{value:gd(t.value,u,a,e.operator==="//")}}async function
|
|
99
|
-
`;)f+=2;if(!i&&e[f]==="'"){i="ansi",u=f;continue}}if(!i){if(t===":"){if(a==="(")o++;else if(a===")")o--;else if(o===0&&a==="?")s++;else if(o===0&&a===":"&&s){s--;continue}if(o!==0)continue}if(a===t)return u}}return e.length}var
|
|
93
|
+
`,stderr:"",exitCode:d?2:0}}function Dy(e,t,n,r){return t.has("F")?!n.error&&e.fs.isLink?.(n.path)===!0?"@":r&&!t.has("d")?"/":"":""}function By(e,t,n,r,o,i,s,u){let a=[{dir:t,prefix:"",items:fo(e,t,r,u),i:0,depth:0}];for(;a.length;){let l=a.at(-1);if(l.i>=l.items.length){a.pop();continue}let{n:f,isDir:c,target:d}=l.items[l.i++];if([...f+(d??"")].some(w=>w.codePointAt(0)<32||w.codePointAt(0)===127||w==="\\"))return v("feature","tree","filename escaping","tree: listing names requiring escaping is not supported");let p=l.i===l.items.length,h=c&&r.has("F")&&!r.has("d")?"/":"";if(n.push(l.prefix+(p?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+f+(d===void 0?h:" -> "+d+h)),i[c?"dirs":"files"]++,!c||d!==void 0)continue;let m=Te(l.dir,f);if(l.depth+1>=o){fo(e,m,r).length&&s.add(m);continue}let g=fo(e,m,r,u);a.push({dir:m,prefix:l.prefix+(p?" ":"\u2502\xA0\xA0 "),items:g,i:0,depth:l.depth+1})}}function fo(e,t,n,r=null){let{dirs:o,files:i,links:s}=e.listDir(t),u=s.map(l=>{let f=E(t,l,e);return{n:l,isDir:!f.error&&e.isDir(f.path),target:e.readLink(Te(t,l))}}),a=n.has("d")?u.filter(({isDir:l})=>l):[...i.map(l=>({n:l,isDir:!1})),...u];return r&&!n.has("a")&&r.collect(t,[...o,...a.map(({n:l})=>l)]),[...o.map(l=>({n:l,isDir:!0})),...a].filter(({n:l})=>n.has("a")||!l.startsWith(".")).sort((l,f)=>j(l.n,f.n))}var Uy=new Set(["name","iname","type","path","ipath","mindepth","maxdepth"]),Qn=(e,t)=>e==="-"+t||e==="--"+t;function rd(e){let t={tokens:e,i:0,depth:{minDepth:0,maxDepth:Number.POSITIVE_INFINITY},hasAction:!1,batches:[],error:null},n=[];for(e[0]==="--"&&t.i++;t.i<e.length&&!/^(?:-.+|!|\()$/u.test(e[t.i]);)n.push(e[t.i++]);let r=od(t,0);if(t.error)return{error:t.error};if(!t.hasAction)for(let o of r)o.push({kind:"print"});return{starts:n.length?n:["."],...t.depth,groups:r,batches:t.batches}}function od(e,t){let n=[[]],r=!1;if(t>128)return e.error=v("feature","find","expression depth","find: expression nesting above 128 is not supported"),n;for(;e.i<e.tokens.length&&!e.error;){let o=e.tokens[e.i];if(o===")"){t||(e.error=x("find: unexpected closing parenthesis"));break}if(o==="-a"||Qn(o,"and")||o==="-o"||Qn(o,"or")){if(r||n.at(-1).length===0){e.error=x(`find: ${o} with no left-hand expression`);break}(o==="-o"||Qn(o,"or"))&&n.push([]),e.i++,r=o;continue}let i=jy(e,t);i&&n.at(-1).push(i),r=!1}return!e.error&&r&&(e.error=x(`find: ${r} with no right-hand expression`)),!e.error&&t&&n.at(-1).length===0&&(e.error=x("find: expected an expression")),!e.error&&t&&(e.tokens[e.i]===")"?e.i++:e.error=x("find: missing closing parenthesis")),n}function jy(e,t){let n=e.i,r=!1;for(;e.tokens[e.i]==="!"||e.tokens[e.i]==="-not";)r=!r,e.i++;let o=e.tokens[e.i++];if(o==="(")return{kind:"group",groups:od(e,t+1),negate:r};if(o===void 0||o===")"||o==="-a"||o==="-o"||Qn(o,"and")||Qn(o,"or"))return e.error=x(`find: -not or operator ${o??""} must be followed by a primary`),null;let i=o.startsWith("--")?o.slice(2):o.startsWith("-")?o.slice(1):null;if(["print","print0","prune","empty"].includes(i))return(i==="print"||i==="print0")&&(e.hasAction=!0),{kind:i,negate:r};if(i==="exec"){let s=Hy(e.tokens,e.i-1,r);return s.error?(e.error=s.error,null):(e.i=s.nextI+1,e.hasAction=!0,s.pred.mode==="batch"&&e.batches.push(s.pred),s.pred)}if(Uy.has(i)){if(e.i===e.tokens.length)return e.error=x(`find: ${o} requires a value`),null;let s=Wy(i,e.tokens[e.i++],r,e.depth);return s.error?(e.error=s.error,null):s}return o===","?(e.error=v("feature","find","comma operator","find: comma expressions are not supported"),null):e.i-1>n&&!o.startsWith("-")?(e.error=x(`find: -not must be followed by a primary, got: ${o}`),null):(e.error=o==="--"||!o.startsWith("-")?x(`find: paths must precede expression: ${o}`):v("option","find",o,`find: unknown option: ${o}`),null)}function Wy(e,t,n,r){if(e==="type"){let o=zy(t);return o.error?o:{kind:e,negate:n,types:o.types}}if(e==="mindepth"||e==="maxdepth"){let o=ye(t,`find: -${e}`,t,{max:2147483647,digitsOnly:!0});return o.error?o:(r[e==="mindepth"?"minDepth":"maxDepth"]=o.value,{kind:"true",negate:n})}return{kind:e,negate:n,re:Me(t,{ignoreCase:e==="iname"||e==="ipath"})}}var nd="fdl",qy="bcps";function zy(e){let t=e.split(","),n=t.find((i,s)=>t.indexOf(i)!==s);if(n!==void 0)return{error:x(`find: Duplicate file type '${n}' in the argument list to -type.`)};if(t.every(i=>i.length===1&&nd.includes(i)))return{types:t};let r=`find: -type/--type expects 'f', 'd' or 'l', got: ${e}`;return{error:t.every(i=>i.length===1&&(nd+qy).includes(i))?v("option","find",`-type ${e}`,r):x(r)}}function Hy(e,t,n){let r=t+1;for(;r<e.length&&e[r]!==";"&&!(e[r]==="+"&&e[r-1]==="{}");)r++;if(r>=e.length)return{error:x("find: -exec: missing terminator (`;` or `{} +`); quote or escape `;`")};if(r===t+1)return{error:x("find: -exec: requires a command")};let o=e.slice(t+1,r),i=e[r]===";"?"each":"batch";if(i==="batch"){if(o.slice(0,-1).some(u=>u.includes("{}")))return{error:x("find: -exec ... +: only one instance of `{}` is supported")};if(n)return{error:v("feature","find","-not -exec ... +","find: `-not -exec ... +` is not supported (the `+` form has no meaningful negation)")}}let s={kind:"exec",mode:i,cmd:o[0],args:o.slice(1),negate:n};return i==="batch"&&(s.collected=[]),{pred:s,nextI:r}}var Gy={file:"f",dir:"d",link:"l"};async function id(e,t,n){let r=rd(t);if(r.error)return r.error;if(e!==""&&t.some(c=>c==="-exec"||c==="--exec"))return v("feature","find","-exec stdin","find: passing shared standard input to -exec is not supported");let{starts:o,minDepth:i,maxDepth:s,groups:u,batches:a}=r,l=U(),f=new Set;try{for(let c of o){let{path:d,error:p}=P(n,"find",c,{follow:!1});if(p){Is(l,n.flushOutput(U(`find: '${c}': ${p}
|
|
94
|
+
`))),l.exitCode=1;continue}let h=new Set;for(let m of Fe(n.fs,d,s,g=>!h.has(g))){let g=Zy(c,d,m.path);if(m.depth>=i&&await sd(u,{kind:m.kind,path:g,abs:m.path,prune:h},n,l),m.kind!=="dir"||m.depth!==s||h.has(m.path))continue;let{dirs:w,files:b,links:k}=n.fs.listDir(m.path);(w.length||b.length||k.length)&&f.add(g)}}for(let c of a){if(c.collected.length===0)continue;let d=c.args.slice(0,-1).concat(c.collected);await ud(c.cmd,d,n,l)||(l.exitCode=1)}}finally{gt(n.notes,{command:"find",action:"depth limit omitted contents of",noun:["directory","directories"],paths:f})}return l}async function sd(e,t,n,r){for(let o of e){let i=!0;for(let s of o)if(await Xy(s,t,n,r)===!!s.negate){i=!1;break}if(i)return!0}return!1}function Xy(e,t,n,r){if(e.kind==="group")return sd(e.groups,t,n,r);if(e.kind==="true")return!0;if(e.kind==="type")return e.types.includes(Gy[t.kind]);if(e.kind==="name"||e.kind==="iname")return e.re.test(t.path.replace(/\/+$/u,"").split("/").at(-1)||"/");if(e.kind==="prune")return t.kind==="dir"&&t.prune.add(t.abs),!0;if(e.kind==="empty"){if(t.kind==="link")return!1;if(t.kind==="file")return n.fs.isEmptyFile(t.abs);let{dirs:o,files:i,links:s}=n.fs.listDir(t.abs);return o.length+i.length+s.length===0}return e.kind==="path"||e.kind==="ipath"?e.re.test(t.path):e.kind==="print"||e.kind==="print0"?(Is(r,n.flushOutput({stdout:t.path+(e.kind==="print"?`
|
|
95
|
+
`:"\0"),stderr:"",exitCode:0})),!0):e.mode==="batch"?(e.collected.push(t.path),!0):ud(e.cmd,e.args.map(o=>o.replaceAll("{}",t.path)),n,r)}async function ud(e,t,n,r){let o=await n.dispatch(e,t,"");return Is(r,o),o.exitCode===0}function Is(e,t){let n=e.exitCode;_(e,t),e.exitCode=n}function Zy(e,t,n){if(n===t)return e;let r=He(t,n);return e.endsWith("/")?e+r:e+"/"+r}var Fs=1e5,Yy=/^([+-]?\d+)\.\.([+-]?\d+)(?:\.\.([+-]?\d+))?$/u,Vy=/^([A-Za-z])\.\.([A-Za-z])(?:\.\.([+-]?\d+))?$/u,ad=2n**63n-1n,ld=-(2n**63n),Ts=e=>{let t=BigInt(e);return t>ad||t<ld?null:t},fd=(e,t)=>e.mask===null?"0":e.mask[t];function Ls(e,t=Fs){if(!e.value.includes("{"))return[e];let n=Ky(e);for(let r=0;r<e.value.length;r++){if(e.value[r]!=="{"||fd(e,r)!=="0")continue;let o=n.get(r);if(!o)continue;let{end:i,commas:s}=o,u=s.length?[]:Qy(xe(e,r+1,i));if(s.length){let c=r+1;for(let d of[...s,i])u.push(xe(e,c,d)),c=d+1}if(u===null)continue;let a=xe(e,0,r),l=xe(e,i+1),f=[];for(let c of u)if(f.push(...Ls(sl(a,c,l),t)),f.length>t)throw new y("feature","brace expansion limit",`brace expansion \`${e.value}\` would produce more than ${t} words`);return f}return[e]}function Ky(e){let t=[],n=new Map;for(let r=0;r<e.value.length;r++){if(fd(e,r)!=="0")continue;let o=e.value[r];if(o==="{")t.push({start:r,commas:[]});else if(o==="}"&&t.length){let{start:i,commas:s}=t.pop();n.set(i,{end:r,commas:s})}else o===","&&t.length&&t.at(-1).commas.push(r)}return n}function Jy(e){if(e.mask!==null&&/[12]/u.test(e.mask))return null;let t=Yy.exec(e.value),n=t??Vy.exec(e.value);if(!n)return null;let[r,o]=t?[Ts(t[1]),Ts(t[2])]:[BigInt(n[1].codePointAt(0)),BigInt(n[2].codePointAt(0))],i=n[3]===void 0?1n:Ts(n[3]);if(r===null||o===null||i===null||i===ld)return null;let s=o>=r?o-r:r-o;return s>ad?null:{num:t,range:n,from:r,to:o,step:(i<0n?-i:i)||1n,span:s}}function Qy(e){let t=Jy(e);if(t===null)return null;let{num:n,from:r,to:o,step:i,span:s}=t,u=s/i+1n;if(u>Fs)throw new y("feature","brace expansion limit",`brace expansion \`{${e.value}}\` would produce ${u} words (limit ${Fs})`);let a=n?ex(n[1],n[2]):0,l=[],f=o>=r?1n:-1n;for(let c=0n;c<u;c++){let d=r+f*c*i,p=n?tx(d,a):String.fromCodePoint(Number(d));l.push({value:p,mask:null})}return l}function ex(e,t){let n=r=>/^-?0\d/u.test(r);return n(e)||n(t)?Math.max(e.length,t.length):0}function tx(e,t){let n=String(e<0n?-e:e),r=e<0n?"-":"";return r+n.padStart(t-r.length,"0")}var _s=new Set(["CDPATH","GLOBIGNORE","GLOBSORT","BASH_COMPAT","POSIXLY_CORRECT","PATH","RANDOM","SRANDOM","SECONDS","EPOCHSECONDS","EPOCHREALTIME","BASHOPTS","SHELLOPTS","OPTIND"]),Je=class extends Map{constructor(t){super(t),this.unsetNames=new Set(t?.unsetNames)}set(t,n){if(this.expansionTargets?.has(t))throw new y("feature","temporary assignment side effects","modifying a temporary assignment target while expanding assignment values is not supported");if(_s.has(t)||t==="TZ"&&!["UTC","UTC0",""].includes(n))throw new y("feature",t,`shell variable ${t} is not supported with this value`);return(t==="LANG"||t.startsWith("LC_"))&&qa(t,n),this.bound?.add(t),this.unsetNames?.delete(t),super.set(t,n)}delete(t){return this.unsetNames.add(t),super.delete(t)}};var cd=new Set(["$","!","0","-","_"]),nx=new Set(["PPID","UID","EUID","BASHPID","BASH_SUBSHELL","BASH_VERSION","BASH_VERSINFO","BASH_REMATCH","DIRSTACK","PIPESTATUS","FUNCNAME","LINENO","REPLY","BASH","BASH_COMMAND","BASH_ARGV0","BASH_ARGC","BASH_ARGV","BASH_SOURCE","BASH_LINENO","BASH_ALIASES","BASH_CMDS","GROUPS","HOSTTYPE","OSTYPE","MACHTYPE","HOSTNAME","SHLVL","SHELL","TERM","PS4","OPTERR","HISTCMD","BASH_EXECUTION_STRING","BASH_LOADABLES_PATH","COMP_WORDBREAKS"]);function Et(e,t){if(cd.has(e))throw Rs(e);let n=Ms(e,t);if(n)return n;if(dd(e))throw Rs(e);return{value:"",set:!1}}var dd=e=>_s.has(e)||nx.has(e),Rs=e=>new y("feature",`$${e}`,`shell parameter ${e} is not supported`),pd=(e,t)=>Ms(e,t)?.value??"";function Ms(e,t){return e==="?"?{value:String(t.lastExit),set:!0}:e==="#"?{value:"0",set:!0}:e==="@"?{value:"",set:!1,omit:!0}:e==="*"?{value:"",set:!1}:/^[1-9][0-9]*$/u.test(e)?{value:"",set:!1}:t.vars.has(e)?{value:t.vars.get(e),set:!0}:t.vars.unsetNames.has(e)?{value:"",set:!1}:e==="IFS"?{value:`
|
|
96
|
+
`,set:!0}:e==="PWD"?{value:t.cwd,set:!0}:e==="HOME"?{value:t.home,set:!0}:e==="USER"||e==="LOGNAME"?{value:t.user,set:!0}:e==="LANG"?{value:t.locale,set:!0}:null}function Ps(e,t){if(cd.has(e))throw new y("feature",`$${e}`,`shell parameter ${e} is not supported (this terminal runs no process)`);let n=Ms(e,t);if(n)return n;if(dd(e))throw Rs(e);return rx(t,`$${e}`,`warning: $${e} is unset (this shell has no environment variables; only \`for\` bindings and \`NAME=value\` assignments)`),{value:""}}function rx(e,t,n){uo(e,n+`
|
|
97
|
+
`),e.unsupported.add({kind:"feature",command:null,detail:t,message:n})}var hd=16e6,er=e=>new y("feature","${",e);function md(e,t,n){if(Xn(t))throw er("extended glob patterns in parameter expansion are not supported");let r=on({value:t.value,mask:t.mask??null}),o=n[0]==="#",i=wd(r);if(i!==null)return o?e.startsWith(i)?e.slice(i.length):e:e.endsWith(i)?e.slice(0,e.length-i.length):e;let s=Me(r,{bash:!0}),u=n.length===2,a=o===u,l=a?e.length:0,f=0;for(;l>=0&&l<=e.length;){let c=o?e.slice(0,l):e.slice(l);if(f+=c.length+r.length,f>hd)throw er("parameter pattern removal exceeds the matching work limit");if(s.test(c))return o?e.slice(l):e.slice(0,l);l=co(e,l,a)}return e}function gd(e,t,n,r){let o="";if(!r&&/^[#%]/u.test(t.value)&&(!t.mask||t.mask[0]==="0")&&(o=t.value[0],t={value:t.value.slice(1),mask:t.mask?.slice(1)??null}),Xn(t))throw er("extended glob patterns in parameter expansion are not supported");let i=on({value:t.value,mask:t.mask??null}),s={work:0},u=sx(n,s);if(!i)return o==="#"?u("")+e:o==="%"?e+u(""):e;if((/\\+$/u.exec(i)?.[0].length??0)%2)throw er("unescaped trailing backslashes in replacement patterns are not supported");let a=wd(i),l=a===null?ix(e,i,o,s):ox(e,a,o),f=[],c=0;do{let d=l(c);if(!d)break;let[p,h]=d,m=u(e.slice(p,h));if(Ds(s,p-c),f.push(e.slice(c,p),m),c=h,!r)break;if(p===h){let g=co(e,c,!1);f.push(e.slice(c,g)),c=g}}while(c<e.length);return f.push(e.slice(c)),f.join("")}function ox(e,t,n){return r=>{let o=n==="%"?e.length-t.length:e.indexOf(t,r);return o<r||n==="#"&&o!==0||e.slice(o,o+t.length)!==t?null:[o,o+t.length]}}function ix(e,t,n,r){let o=Me(t,{bash:!0});return i=>{for(let s=i;s<=e.length;s=co(e,s,!1)){for(let u=e.length;u>=s;u=co(e,u,!0)){if(Ds(r,u-s+t.length),o.test(e.slice(s,u)))return[s,u];if(n==="%")break}if(n==="#")break}return null}}function Ds(e,t){if(e.work+=t,e.work>hd)throw er("parameter replacement exceeds the matching work limit")}function sx(e,t){let n="";for(let r=0;r<e.value.length;r++){let o=e.value[r];e.mask?.[r]!==void 0&&e.mask[r]!=="0"&&(o==="&"||o==="\\")&&(n+="\\"),n+=o}return r=>{let o=[];for(let i=0;i<n.length;i++){let s=n[i],u=s==="\\"&&/[&\\]/u.test(n[i+1]??"")?n[++i]:s==="&"?r:s;Ds(t,u.length),o.push(u)}return o.join("")}}function co(e,t,n){let r=t+(n?-1:1);return r>0&&r<e.length&&/[\uDC00-\uDFFF]/u.test(e[r])&&/[\uD800-\uDBFF]/u.test(e[r-1])?r+(n?-1:1):r}function wd(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r==="\\"&&n+1<e.length)t+=e[++n];else{if(/[*?[]/u.test(r))return null;t+=r}}return t}var je=e=>BigInt.asIntN(64,e),J=(e,t)=>new y("feature","arithmetic "+e,"arithmetic expansion: "+t);function bd(e){let t=10n,n=!1,r=0n,o=0;if(e[0]==="0"&&(o=1,t=8n,n=!0,(e[1]==="x"||e[1]==="X")&&(t=16n,o=2)),o===2&&e.length===2)throw J("number","hexadecimal constant has no digits");for(;o<e.length;o++){let i=e[o];if(i==="#"){if(n||r<2n||r>64n||o===e.length-1)throw J("number","invalid arithmetic base or integer constant");t=r,r=0n,n=!0;continue}let s=i.codePointAt(0),u=s>=48&&s<=57?s-48:s>=97&&s<=122?s-87:s>=65&&s<=90?s-(t<=36n?55:29):i==="@"?62:i==="_"?63:-1;if(u<0||BigInt(u)>=t)throw J("number","value too great for base in "+e.slice(0,40));r=je(r*t+BigInt(u))}return r}function ux(e,t){if(t<0n)throw J("exponent","exponent less than zero");let n=1n;for(let r=t,o=e;r!==0n;r>>=1n,o=je(o*o))r&1n&&(n=je(n*o));return n}function Bs(e,t,n,r){switch(e){case"+":return je(t+n);case"-":return je(t-n);case"*":return je(t*n);case"/":case"%":{if(n===0n&&r)throw J("division","division by zero");let o=n===0n?1n:n;return je(e==="/"?t/o:t%o)}case"**":return ux(t,n);case"<<":case">>":{if(n<0n||n>63n)throw J("shift count","shift counts outside 0..63 are not supported");return je(e==="<<"?t<<n:t>>n)}case"&":return t&n;case"^":return t^n;case"|":return t|n;case"<":return BigInt(t<n);case"<=":return BigInt(t<=n);case">":return BigInt(t>n);case">=":return BigInt(t>=n);case"==":return BigInt(t===n);case"!=":return BigInt(t!==n);default:throw J("operator","unsupported operator "+e)}}var ax=new Set(["=","+=","-=","*=","/=","%=","<<=",">>=","&=","^=","|="]),lx=[["||"],["&&"],["|"],["^"],["&"],["==","!="],["<","<=",">",">="],["<<",">>"],["+","-"],["*","/","%"],["**"]],fx=new Map(lx.flatMap((e,t)=>e.map(n=>[n,t+3]))),cx=/^(?:<<=|>>=|\+\+|--|\*\*|&&|\|\||<<|>>|[+\-*/%&^|=!<>]=|[+\-*/%&^|=!~<>?:,()])/u;function dx(e){let t=[];for(let n=0;n<e.length;){if(t.length>=1e4)throw J("limit","expression token limit exceeded");let r=e.slice(n),o=/^[ \t\n]+/u.exec(r);if(o){n+=o[0].length;continue}let i=/^[0-9][A-Za-z0-9#@_]*/u.exec(r),s=/^[A-Za-z_][A-Za-z0-9_]*/u.exec(r),u=cx.exec(r);if(i)t.push({type:"number",value:bd(i[0]),raw:i[0]});else if(s)t.push({type:"name",value:s[0],raw:s[0]});else if(u)t.push({type:"operator",value:u[0],raw:u[0]});else throw J(r[0]==="["||r[0]==="]"?"arrays":"syntax","unsupported expression token "+JSON.stringify(r[0]));n+=t.at(-1).raw.length}return t.push({type:"end",value:""}),t}function yd(e){let t=new Us(dx(e));if(t.token.type==="end")return{type:"number",value:0n};let n=t.expression();if(t.token.type!=="end")throw J("syntax","unexpected token "+t.token.value);return n}var Us=class{constructor(t){this.tokens=t,this.at=0,this.depth=0}get token(){return this.tokens[this.at]}next(){return this.tokens[this.at++]}accept(t){return this.token.value===t?this.next():null}expect(t){if(!this.accept(t))throw J("syntax","expected "+t)}expression(t=0){if(++this.depth>128)throw J("limit","expression nesting limit exceeded");let n=this.prefix();for(;;){let r=this.token.value;if(r==="?"&&t<=2){this.next();let u=this.expression();this.expect(":"),n={type:"condition",test:n,consequent:u,alternate:this.expression(2)};continue}let o=ax.has(r),i=r===","?0:o?1:fx.get(r);if(i===void 0||i<t)break;if(this.next(),o&&n.type!=="name")throw J("assignment","attempted assignment to non-variable");let s=this.expression(i+(o||r==="**"?0:1));n={type:o?"assignment":"binary",op:r,left:n,right:s}}return this.depth--,n}prefix(){let t=this.next();if(["+","-","!","~"].includes(t.value))return{type:"unary",op:t.value,value:this.expression(14)};if(t.value==="++"||t.value==="--"){let n=this.next();if(n.type!=="name")throw J("increment","increment requires a scalar variable");return{type:"increment",op:t.value,name:n.value,post:!1}}if(t.value==="("){let n=this.expression();return this.expect(")"),{type:"group",value:n}}if(t.type!=="number"&&t.type!=="name")throw J("syntax","operand expected");return t.type==="name"&&(this.token.value==="++"||this.token.value==="--")?{type:"increment",op:this.next().value,name:t.value,post:!0}:t}};function Ut(e,t,n=0){return kd(e,{ctx:t,steps:1e4,characters:2e5},n,!0)}function kd(e,t,n,r){if(typeof e!="string")throw J("value","expression must be a string");if(t.characters-=e.length,e.length>1e5||t.characters<0)throw J("limit","expression size limit exceeded");if(n>128)throw J("limit","variable recursion limit exceeded");return vd(yd(e),t,n+1,r)}function js(e,t,n,r){if(!r)return 0n;let o;try{o=Et(e,t.ctx)}catch(i){throw J("variable",V(i))}return o.set&&o.value!==""?kd(o.value,t,n+1,!0):0n}function xd(e,t,n,r){if(r)try{Et(e,n.ctx),n.ctx.vars.set(e,t.toString())}catch(o){throw J("assignment",V(o))}return t}function vd(e,t,n,r){if(--t.steps<0||n>128)throw J("limit","expression evaluation limit exceeded");let o=(i,s=r)=>vd(i,t,n+1,s);switch(e.type){case"number":return e.value;case"name":return js(e.value,t,n,r);case"group":return o(e.value);case"unary":{let i=o(e.value);return e.op==="+"?i:e.op==="-"?je(-i):e.op==="!"?BigInt(i===0n):~i}case"increment":{let i=js(e.name,t,n,r),s=xd(e.name,je(i+(e.op==="++"?1n:-1n)),t,r);return e.post?i:s}case"assignment":{let i=e.left.value,s=e.op==="="?0n:js(i,t,n,r),u=o(e.right);return xd(i,e.op==="="?u:Bs(e.op.slice(0,-1),s,u,r),t,r)}case"condition":{let i=o(e.test)!==0n,s=o(e.consequent,r&&i),u=o(e.alternate,r&&!i);return i?s:u}case"binary":{let i=o(e.left),s=r&&(e.op==="&&"?i!==0n:e.op==="||"?i===0n:!0),u=o(e.right,s);return e.op===","?u:e.op==="&&"?BigInt(i!==0n&&u!==0n):e.op==="||"?BigInt(i!==0n||u!==0n):Bs(e.op,i,u,r)}default:throw J("syntax","unsupported expression")}}var po=e=>new y("feature","${",e);async function Sd(e,t,n,r){if(e.name==="@"||e.name==="*")throw po("substring and replacement of positional parameter lists are not supported");if(!t.set)return t;if(e.operator===":")try{return{value:await px(t.value,e.word,n,r)}}catch(l){throw l.halt=!0,l}let o=e.word,i=0;for(;o[i]==="\\"&&o[i+1]===`
|
|
98
|
+
`;)i+=2;let s=Ed(o,"/",r.readExpansion,o[i]==="/"?i+1:0),u=await r.expand(o.slice(0,s),{pattern:!0}),a=await r.expand(s<o.length?o.slice(s+1):"",{replacement:!0});return{value:gd(t.value,u,a,e.operator==="//")}}async function px(e,t,n,r){if(/\P{ASCII}/u.test(e))throw po("locale-dependent slicing of non-ASCII parameters is not supported");let o=Ed(t,":",r.readExpansion),i=async l=>Ut((await r.expand(l,{arithmetic:!0})).value,n),s=await i(t.slice(0,o)),u=BigInt(e.length);if(s<0n&&(s+=u),s<0n||s>u)return"";let a=u;if(o<t.length){let l=await i(t.slice(o+1));if(a=l<0n?u+l:s+l,a>ue)throw po("substring length overflows the shell integer range");if(a<s){let f=new Error(`${t.slice(o+1)}: substring expression < 0`);throw f.exitCode=1,f.halt=!0,f}}return e.slice(Number(s),Number(a>u?u:a))}function Ed(e,t,n,r=0){let o=0,i=null,s=0;for(let u=r;u<e.length;u++){let a=e[u];if(i==="'"){a==="'"&&(i=null);continue}if(i==="ansi"){a==="\\"?u++:a==="'"&&(i=null);continue}if(a==="\\"){u++;continue}if(t===":"&&(a==="'"||a==='"'))throw po("quoted substring arithmetic is not supported");if(a==='"'){i=i==='"'?null:'"';continue}if(a==="'"&&!i){i=a;continue}if(a==="$"){let l=n(e,u,0,t===":"||i==='"');if(l){u+=l.raw.length-1;continue}let f=u+1;for(;e[f]==="\\"&&e[f+1]===`
|
|
99
|
+
`;)f+=2;if(!i&&e[f]==="'"){i="ansi",u=f;continue}}if(!i){if(t===":"){if(a==="(")o++;else if(a===")")o--;else if(o===0&&a==="?")s++;else if(o===0&&a===":"&&s){s--;continue}if(o!==0)continue}if(a===t)return u}}return e.length}var hx=/^[A-Za-z_][A-Za-z0-9_]*$/u;async function $d(e,t,n){let{lookup:r,expand:o}=n,{name:i,operator:s,word:u=""}=e,a=r(i,{quiet:s!==""});if(!s)return a;if(s==="length")return mx(i,a.value);if(s===":"||s.startsWith("/"))return Sd(e,a,t,n);if(s[0]==="#"||s[0]==="%")return!a.value||!u?a:{value:md(a.value,await o(u,{pattern:!0}),s)};let l=!a.set||s.startsWith(":")&&a.value==="",f=s[s.length-1];if(f==="+")return l?{value:"",...a.omit?{omit:!0}:{}}:o(u,{});if(!l)return a;if(f==="?")throw await gx(i,u,s.startsWith(":"),o,t);if(f!=="=")return o(u,{});if(!hx.test(i)){let d=new Error(`$${i}: cannot assign in this way`);throw d.exitCode=1,d.halt=!0,d}let c=await o(u,{assignment:!0});return t.vars.set(i,c.value),{value:t.vars.get(i)}}function mx(e,t){if(e==="*"||e==="@")return{value:"0"};if(/\P{ASCII}/u.test(t))throw Ft("#"+e,"locale-dependent length of non-ASCII parameters is not supported");return{value:String(t.length)}}async function gx(e,t,n,r,o){let i=t?wx(await r(t,{error:!0}),o):n?"parameter null or not set":"parameter not set",s=new Error(`${e}: ${i}`);return s.exitCode=1,s.halt=!0,s}function wx(e,t){let n=t.vars.get("IFS")??`
|
|
100
100
|
`;if(n==="")return e.value;if(n!==`
|
|
101
|
-
`)throw Ft("?","custom IFS separators in parameter errors are not supported");let r=new Set(e.empty),o=[],i=!1,s="",u=()=>{(s||i)&&o.push(s),s="",i=!1};for(let a=0;a<=e.value.length&&(r.has(a)&&(i=!0),a!==e.value.length);a++){let l=e.value[a],f=!e.mask||e.mask[a]==="0";f&&/[ \t\n]/u.test(l)?u():(s+=l,i||=!f)}return u(),o.join(" ")}function $t(e,t){return ce(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new Je(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function ce(e,t,n){let r=Object.fromEntries(Object.keys(t).map(o=>[o,e[o]]));Object.assign(e,t);try{return await n()}finally{Object.assign(e,r)}}async function tr(e,t){let n=[],r=e[0],o=r?.value==="export"&&!/[12]/u.test(r.mask??"")&&!r.empty?.length;for(let i of e)for(let s of
|
|
101
|
+
`)throw Ft("?","custom IFS separators in parameter errors are not supported");let r=new Set(e.empty),o=[],i=!1,s="",u=()=>{(s||i)&&o.push(s),s="",i=!1};for(let a=0;a<=e.value.length&&(r.has(a)&&(i=!0),a!==e.value.length);a++){let l=e.value[a],f=!e.mask||e.mask[a]==="0";f&&/[ \t\n]/u.test(l)?u():(s+=l,i||=!f)}return u(),o.join(" ")}function $t(e,t){return ce(e,{cwd:e.cwd,lastExit:e.lastExit,vars:new Je(e.vars),functions:new Map(e.functions),loopDepth:0,errexit:e.errexit,errexitOff:e.errexitOff},t)}async function ce(e,t,n){let r=Object.fromEntries(Object.keys(t).map(o=>[o,e[o]]));Object.assign(e,t);try{return await n()}finally{Object.assign(e,r)}}async function tr(e,t){let n=[],r=e[0],o=r?.value==="export"&&!/[12]/u.test(r.mask??"")&&!r.empty?.length;for(let i of e)for(let s of Ls(i)){let u=o&&s===i&&Tn(i);if(u){let a=await yx(s,u.end,t);n.push({value:a,mask:"1".repeat(a.length),q:!0})}else n.push(...await Ad(ho(s,t,s===i?!1:"word"),t,!0))}return{argv:bx(n,t)}}function bx(e,t){let n=[];for(let r of e){if(ec(r)){let o=tc(r,t);if(o.length>0){n.push(...o);continue}}(r.value!==""||r.q)&&n.push(r.value)}return n}async function Ws(e,t){let{argv:n}=await tr([e],t);return n.length===1?{value:n[0]}:{error:`${e.value}: ambiguous redirect`}}async function yx(e,t,n){let r=xe(e,t);return e.value.slice(0,t)+await jt(r,n,!0)}async function jt(e,t,n=!1){return(await Ad(ho(e,t,n),t,!1,n))[0].value}var ln=e=>e.vars.get("HOME")??e.home,Nd=(e,t)=>e.mask===null?"0":e.mask[t];function ho(e,t,n=!1){let r=il(e,n);if(r.size===0)return e;let o=e.value,i=ln(t),s="",u="",a=[];for(let l=0;l<o.length;l++){if(e.empty?.includes(l)&&a.push(s.length),r.has(l)){let f=i==="/"&&o[l+1]==="/"?"":i;s+=f,u+="1".repeat(f.length);continue}s+=o[l],u+=Nd(e,l)}return e.empty?.includes(o.length)&&a.push(s.length),{value:s,mask:/[12]/u.test(u)?u:null,...a.length?{empty:a}:{}}}function qs(e,t){return ce(t,{strictExpansion:!0},()=>zs(ho(e,t),t))}async function Ad(e,t,n,r=!1){let o=await zs(e,t,r);return n?vx(o,t):[o]}async function zs(e,t,n=!1){let r={value:"",mask:"",empty:[],split:!1},o=(i,s)=>{r.value+=i,r.mask+=s};e.value===""&&e.mask!==null&&r.empty.push(0);for(let i=0;i<=e.value.length&&(e.empty?.includes(i)&&r.empty.push(r.value.length),i!==e.value.length);i++){let s=Nd(e,i),u=e.value[i];if(s==="0"&&(u==="<"||u===">")&&e.value[i+1]==="(")throw new y("feature",`${u}(`,`process substitution (\`${u}(\u2026)\`) is not supported`);let a=s!=="1"&&(u==="$"||u==="`"),l=e.value[i+1]==="("||e.value[i+1]==="{",f=a?xx(e,i,u,s,l):null;if(!f){o(e.value[i],s);continue}i+=f.raw.length-1;let c=await kx(f,t,s==="2",n);if(c.literal){o(f.raw,s.repeat(f.raw.length));continue}if(!c.omit)if(s==="2")c.value===""&&r.empty.push(r.value.length),o(c.value,"2".repeat(c.value.length));else{r.split=!0;for(let d of c.empty??[])r.empty.push(r.value.length+d);c.q&&!c.value&&!c.empty?.length&&r.empty.push(r.value.length),o(c.value,c.mask??"0".repeat(c.value.length))}}return r.q=r.empty.length>0||/[12]/u.test(r.mask),r}function xx(e,t,n,r,o){return n==="`"?at(e.value,t):o?ft(e.value,t,0,r==="2"):Ai(e.value,t,e.mask)}async function kx(e,t,n,r){if(e.command!==void 0)return{value:await t.substitute(e.command,e.backtick)};if(e.arithmetic!==void 0)try{let o=await ce(t,{strictExpansion:!0},()=>jt(Ci(e.arithmetic,!0),t));return{value:String(Ut(o,t))}}catch(o){throw o.halt=!0,o}return e.parameter!==void 0?e.parameter.operator===""&&!t.strictExpansion&&!/^[0-9]{2,}$/u.test(e.parameter.name)?Ps(e.parameter.name,t):$d(e.parameter,t,{lookup:o=>Et(o,t),readExpansion:ft,expand:(o,i={})=>{let s=i.pattern||i.error||i.replacement||i.arithmetic,u=Ci(o,i.arithmetic||!s&&n),a=!s&&(i.assignment||r),l=i.assignment?"parameterAssign":a?!0:"parameter";return ce(t,{strictExpansion:!0},()=>zs(i.arithmetic?u:ho(u,t,l),t,a))}}):t.strictExpansion?Et(e.name,t):Ps(e.name,t)}function vx(e,t){if(!e.split)return e.value!==""||e.q?[e]:[];let n=t.vars.get("IFS")??`
|
|
102
102
|
`;if(n!==""&&n!==`
|
|
103
|
-
`)throw new
|
|
104
|
-
`}`;_(n.result,n.ctx.flushOutput({...U(),stdout:r,events:[{fd:1,text:r}]}))}var
|
|
103
|
+
`)throw new y("feature","IFS","custom IFS separators are not supported");let r=[],o={value:"",mask:"",q:!1},i=()=>{(o.value!==""||o.q)&&r.push(o),o={value:"",mask:"",q:!1}},s=new Set(e.empty);for(let u=0;u<=e.value.length&&(s.has(u)&&(o.q=!0),u!==e.value.length);u++){let a=e.value[u],l=e.mask[u];if(n!==""&&l==="0"&&/[ \t\n]/u.test(a)){i();continue}o.value+=a,o.mask+=l,o.q||=l!=="0"}return i(),r}function Od(e,t,n){let r=Jc(t,n),o={ctx:n,options:r,seen:new Set,result:U(),total:0n,failed:!1};r.stderr&&_(o.result,n.flushOutput(U(r.stderr)));for(let i of r.operands){let s=i.length>2?i.replace(/\/+$/u,"/"):i,u=P(n,"du",s,{follow:r.links!=="none"});if(u.error){_(o.result,n.flushOutput(x(`du: cannot access ${X(s,n)}: ${u.error}`))),o.failed=!0;continue}try{Sx(u.path,s,o)}catch(a){let l=O(a),f="du: "+V(a);if(l&&n.unsupported.add({...l,command:l.command??"du",message:f}),_(o.result,n.flushOutput(x(f))),o.failed=!0,l)return o.result}}return r.flags.has("c")&&Hs(o.total,"total",o),o.result.exitCode=o.failed?1:0,o.result}function Sx(e,t,n){let{ctx:r,options:o}=n;if(!o.flags.has("inodes")&&r.fs.isDir(e)&&Object.values(r.outputFds??{}).some(s=>typeof s=="object"&&s.path?.startsWith(e==="/"?"/":e+"/")))throw new y("feature","recursive metadata output overlap","output within a measured directory is not supported");let i=[{path:e,name:t,depth:0}];for(;i.length;){let s=i.pop();if(s.total!==void 0){s.depth<=o.depth&&Hs(s.total,s.name,n),s.parent&&!o.flags.has("S")&&(s.parent.total+=s.total);continue}let u=r.fs.isDir(s.path);if(u&&r.fs.isFile(s.path))throw new y("feature","ambiguous file type",`path is both a file and a directory: ${s.name}`);if(!u&&o.links==="all"&&r.fs.isLink?.(s.path))throw new y("option","dereference",`following symbolic links is not supported: ${s.name}`);let a=u?s.path:r.fs.fileIdentity?.(s.path)??s.path;if(!o.flags.has("l")&&n.seen.has(a))continue;n.seen.add(a);let l=u?"dir":r.fs.isLink?.(s.path)?"link":"file",f=u?0:r.fs.fileSize(s.path),c=o.flags.has("inodes")?1n:o.flags.has("A")?BigInt(f):BigInt(lo(f,l));if(n.total+=c,u){s.total=c,i.push(s);let d=r.fs.listDir(s.path),p=[...new Set([...d.dirs,...d.files,...d.links])].sort(j),h=s.name.endsWith("/")?s.name:s.name+"/";for(let m=p.length-1;m>=0;m--)i.push({path:Te(s.path,p[m]),name:h+p[m],depth:s.depth+1,parent:s})}else s.parent&&(s.parent.total+=c),(s.depth===0||o.flags.has("a")&&s.depth<=o.depth)&&Hs(c,s.name,n)}}function Hs(e,t,n){let r=`${Jn(e,n.options.scale)} ${t}${n.options.flags.has("0")?"\0":`
|
|
104
|
+
`}`;_(n.result,n.ctx.flushOutput({...U(),stdout:r,events:[{fd:1,text:r}]}))}var Ex=/^%([-+ 0#']*)(\d+|\*)?'?(?:\.(\d+|\*)?)?[hlL]?(.)?/su,$x="diouxXeEfFgGcs";function go(e){let t=[],n="";for(let r=0;r<e.length;r++){if(e[r]!=="%"){n+=e[r];continue}if(e[r+1]==="%"){n+="%",r++;continue}if(/^%[^a-zA-Z%]*\$/u.test(e.slice(r)))throw new $("positional printf arguments are not supported",null,"positional format arguments");let o=Ex.exec(e.slice(r)),i=o[4];if(i==="a"||i==="A")throw new $("hexadecimal floating-point formats are not supported",null,"hexadecimal float format");if(i==="%"){n+="%",r+=o[0].length-1;continue}if(i===void 0||!$x.includes(i)){n+=o[0],r+=o[0].length-1;continue}n!==""&&(t.push(n),n="");let s=o[1];t.push({minus:s.includes("-"),plus:s.includes("+"),space:s.includes(" "),zero:s.includes("0"),alt:s.includes("#"),width:o[2]===void 0?null:o[2]==="*"?"*":Number(o[2]),precision:o[3]===void 0?o[0].includes(".")?0:null:o[3]==="*"?"*":Number(o[3]),conv:i}),r+=o[0].length-1}return n!==""&&t.push(n),t}function Nt(e,t,n,r){let o=n.width??0;if(o>Ce)throw new $("format width exceeds the output limit",null,"format size limit");let i=o-e.length-[...t].length;return i<=0?e+t:n.minus?e+t+" ".repeat(i):n.zero&&r?e+"0".repeat(i)+t:" ".repeat(i)+e+t}var Td=e=>e.plus?"+":e.space?" ":"",Fd=e=>e==="X"||e==="E"||e==="G"||e==="F";function Wt(e,t){if(t.precision>Ce)throw new $("format precision exceeds the output limit",null,"format size limit");let{conv:n}=t;if(!Number.isFinite(e)){if(Number.isNaN(e))throw new $("formatting signed NaN is not supported",null,"signed NaN");let r=e<0?"-inf":"+inf";return Fd(n)?r.toUpperCase():r}return"ouxX".includes(n)&&(e>=2**64||e<-(2**63))?Cd(e,{...t,conv:"g"}):"diouxX".includes(n)?Nx(e,t):Cd(e,t)}function Nx(e,t){let{conv:n}=t,r=n==="d"||n==="i",o=r?Math.trunc(e)===0:e===0,i=BigInt(Math.trunc(e)),s=!1;i<0n&&(r?(s=!0,i=-i):i=BigInt.asUintN(64,i));let u=n==="o"?8:n==="x"||n==="X"?16:10,a=i.toString(u);n==="X"&&(a=a.toUpperCase()),t.precision!==null&&(t.precision===0&&o?a=t.alt&&!r?"0":"":a=a.padStart(t.precision,"0"));let l=s?"-":r&&a!==""?Td(t):"";return t.alt&&!o&&(n==="o"&&(a="0"+a),(n==="x"||n==="X")&&(l+=n==="x"?"0x":"0X")),Nt(l,a,t,t.precision===null)}var mo=100;function Cd(e,t){let{conv:n}=t;if(t.precision>mo)throw new $(`floating-point precision above ${mo} is not supported`,null,"float precision limit");let r=t.precision??6,o=e<0||Object.is(e,-0),i=Math.abs(e),s;return n==="e"||n==="E"?s=_d(i,r):n==="f"||n==="F"?s=Rd(i,r):s=Ax(i,r,t.alt),t.alt&&r===0&&n!=="g"&&n!=="G"&&(s=n==="e"||n==="E"?s.replace("e",".e"):s+"."),Fd(n)&&(s=s.toUpperCase()),Nt(o?"-":Td(t),s,t,!0)}function Ld(e,t,n,r){let o=t.slice(r);if(!/^50*$/u.test(o))return e;let i=t.slice(0,n),s=i.at(-1);return Number(s)%2===0?i:e}function _d(e,t){let n=e.toExponential(mo),r=n.indexOf("."),o=n.indexOf("e"),[i,s]=e.toExponential(t).split("e"),u=Ld(i,n.slice(0,o),t===0?r:r+1+t,r+1+t),a=Number(u===i?s:n.slice(o+1));return`${u}e${a<0?"-":"+"}${String(Math.abs(a)).padStart(2,"0")}`}function Rd(e,t){if(e>=1e21)return BigInt(e).toString()+(t>0?"."+"0".repeat(t):"");let n=e.toFixed(mo),r=n.indexOf(".");return Ld(e.toFixed(t),n,t===0?r:r+1+t,r+1+t)}function Ax(e,t,n){let r=t===0?1:t;if(e===0)return n?"0."+"0".repeat(r-1):"0";let o=_d(e,r-1),i=o.indexOf("e"),s=Number(o.slice(i+1));if(s<-4||s>=r)return n?o.includes(".")?o:o.slice(0,i)+"."+o.slice(i):Id(o.slice(0,i))+o.slice(i);let u=Rd(e,r-1-s);return n?u.includes(".")?u:u+".":Id(u)}var Id=e=>e.includes(".")?e.replace(/\.?0+$/u,""):e;var Ox=/^[+-]?(?:0[bB][01]+|0[xX][\da-fA-F]+|0[0-7]*|[1-9]\d*)/u,Cx=/^[+-]?(?:0[xX](?:[\da-fA-F]+(?:\.[\da-fA-F]*)?|\.[\da-fA-F]+)(?:[pP][+-]?\d+)?|(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?|inf(?:inity)?|nan(?:\([\w]*\))?)/iu;function Dd(e,t){if(e?.[0]!=="'"&&e?.[0]!=='"')return null;let n=e.slice(1);if(n==="")return null;let r=A(n),o=t.byteLocale?1:A(String.fromCodePoint(n.codePointAt(0))).length;return r.length>o&&(t.stderr+=`printf: warning: ${W(r.slice(o))}: character(s) following character constant have been ignored
|
|
105
105
|
`),t.byteLocale?r[0]:n.codePointAt(0)}function Bd(e,t,n){if(e===void 0||e==="")return"0";let r=e.replace(/^[ \t\n\r\f\v]+/u,""),o=t.exec(r)?.[0]??"";return(o.length!==r.length||o==="")&&(n.stderr+=`printf: ${Ud(e,n)}: ${o?"value not completely converted":"expected a numeric value"}
|
|
106
|
-
`,n.failed=!0),o||"0"}var Md={"\x07":"\\a","\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r","\\":"\\\\","'":"\\'"},Pd=e=>"\\"+e.toString(8).padStart(3,"0");function Ud(e,t){let n="";for(let r of e){if(Md[r]!==void 0){n+=Md[r];continue}let o=r.codePointAt(0);if(o<32||o===127){n+=Pd(o);continue}n+=o>127&&t.byteLocale?A(r).map(Pd).join(""):r}return`'${n}'`}function wo(e,t,n){let r=Dd(e,n);if(r!==null)return BigInt(r);let o=Bd(e,
|
|
107
|
-
`,n.failed=!0,t?it:i?ot:ue):t?BigInt.asUintN(64,a):a}function
|
|
108
|
-
`,n),o=r<0?e.length:r+1;t.push(e.slice(n,o)),n=o}return t}var cn=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: ?(.*?))?\n?$/u,qt=/^\*{15,}(?: (.*?))?\n?$/u,xo=/^\*{3} (\d+)(?:,(\d+))? \*{4}\n?$/u,nr=/^--- (\d+)(?:,(\d+))? ----\n?$/u,dn=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n?$/u;var Pe=class extends Error{constructor(t,n){super(n===void 0?t:`${t} at line ${n+1}`),this.name="PatchError",this.line=n}},
|
|
106
|
+
`,n.failed=!0),o||"0"}var Md={"\x07":"\\a","\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r","\\":"\\\\","'":"\\'"},Pd=e=>"\\"+e.toString(8).padStart(3,"0");function Ud(e,t){let n="";for(let r of e){if(Md[r]!==void 0){n+=Md[r];continue}let o=r.codePointAt(0);if(o<32||o===127){n+=Pd(o);continue}n+=o>127&&t.byteLocale?A(r).map(Pd).join(""):r}return`'${n}'`}function wo(e,t,n){let r=Dd(e,n);if(r!==null)return BigInt(r);let o=Bd(e,Ox,n),i=o[0]==="-",s=o.replace(/^[+-]/u,""),u=BigInt(/^0[0-7]+$/u.test(s)?"0o"+s:s),a=i?-u:u;return(t?u>it:a<ot||a>ue)?(n.stderr+=`printf: ${Ud(e,n)}: Numerical result out of range
|
|
107
|
+
`,n.failed=!0,t?it:i?ot:ue):t?BigInt.asUintN(64,a):a}function bo(e,t){let{conv:n}=t,r=n==="d"||n==="i",o=e<0n,i=n==="o"?8:n==="x"||n==="X"?16:10,s=(o?-e:e).toString(i);n==="X"&&(s=s.toUpperCase()),e===0n&&t.precision===0&&(s=""),s=s.padStart(t.precision??0,"0");let u=o?"-":r?t.plus?"+":t.space?" ":"":"";return t.alt&&(n==="o"&&!s.startsWith("0")&&(s="0"+s),e!==0n&&(n==="x"||n==="X")&&(u=n==="x"?"0x":"0X")),Nt(u,s,t,t.precision===null)}function jd(e,t,n){let r=Dd(e,n),o=r===null?Bd(e,Cx,n):String(r),i=o.replace(/^[+-]/u,"");if(/^(?:inf|nan)/iu.test(i)){let a=o.startsWith("-")?"-":t.plus?"+":t.space?" ":"",l=/^nan/iu.test(i)?"nan":"inf";return t.conv===t.conv.toUpperCase()&&(l=l.toUpperCase()),Nt(a,l,t,!1)}let s=_x(i),u=o.startsWith("-")?-s.value:s.value;if(t.precision>100||"gG".includes(t.conv)&&t.precision>96)throw new y("feature","float precision limit","floating-point precision exceeds the supported limit");try{let a=Wt(u,t);if(!s.exact){let[l,f]=Ix(s.value);for(let c of[l,f])if(Wt(o.startsWith("-")?-c:c,t)!==a)throw new y("feature","floating-point precision","floating-point formatting at this precision is not supported")}return a}catch(a){throw a.gap?new y("feature",a.gap,a.message):a}}var fn=new DataView(new ArrayBuffer(8));function Wd(e){return fn.setFloat64(0,e),fn.getBigUint64(0)}function Ix(e){let t=Wd(e);fn.setBigUint64(0,t-1n);let n=fn.getFloat64(0);return fn.setBigUint64(0,t+1n),[n,fn.getFloat64(0)]}function Tx(e){let t=Wd(e),n=Number(t>>52n);return{coefficient:t&(1n<<52n)-1n|(n?1n<<52n:0n),exponent:n?n-1075:-1074}}function Gs(e,t){let n=e.replace(/^0+|0+$/gu,"");return{digits:n||"0",exponent:n?t+e.length-e.replace(/0+$/u,"").length:0}}function Fx({coefficient:e,exponent:t}){return t<0?Gs((e*5n**BigInt(-t)).toString(),t):Gs((e<<BigInt(t)).toString(),0)}function Lx(e,t){let n=e.exponent-t.exponent;return n>=0?e.coefficient<<BigInt(n)===t.coefficient:e.coefficient===t.coefficient<<BigInt(-n)}function _x(e){let t=/^0x/iu.test(e),n,r;if(t)n=Rx(e),r=Mx(n);else{let[u,a="0"]=e.split(/[eE]/u),[l,f=""]=u.split(".");n=Gs(l+f,Number(a)-f.length),r=Number(e)}if(!Number.isFinite(r))throw new y("feature","floating-point range","floating-point values outside the JavaScript number range are not supported");if(r===0){if(t?n.coefficient!==0n:n.digits!=="0")throw new y("feature","floating-point range","floating-point underflow is not supported");return{value:r,exact:!0}}let o=Tx(r),i=Fx(o),s=t?Lx(n,o):n.digits===i.digits&&n.exponent===i.exponent;return{value:r,exact:s&&i.exponent>=-100&&i.digits.length<=101}}function Rx(e){let[t,n="0"]=e.slice(2).split(/[pP]/u),[r,o=""]=t.split("."),i=(r+o).replace(/^0+/u,"")||"0";if(i.length>4096)throw new y("feature","floating-point input limit","hexadecimal floating-point significands above 4096 digits are not supported");return{coefficient:BigInt("0x"+i),exponent:Number(n)-4*o.length}}function Mx({coefficient:e,exponent:t}){if(e===0n)return 0;let n=e.toString(2).length,r=t+n-1;if(r>1023)return 1/0;if(r<-1075)return 0;let o=Math.max(0,n-53,-1074-t),i=e>>BigInt(o);if(o>0){let s=e-(i<<BigInt(o)),u=1n<<BigInt(o-1);(s>u||s===u&&i%2n!==0n)&&i++}return Number(i)*2**(t+o)}var qd={a:7,b:8,e:27,f:12,n:10,r:13,t:9,v:11,'"':34,"\\":92};function Hd(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]==="%"){if(e[r+1]==="%"||r+1===e.length){n.push([37]),r+=2;continue}let o=/^%([-+ #0']*)(\d+)?(?:\.(\d*))?([\s\S])?/u.exec(e.slice(r)),[,i,s,u,a]=o;if(!a||a==="%")throw new Error(`invalid directive: ${o[0]}`);if(!"nsF".includes(a))throw new y("feature","%"+a,`format %${a} is not supported`);if(i.includes("'"))throw new y("feature","grouped format","digit grouping in stat formats is not supported");let l={field:a,conv:"u",width:Number(s??0),precision:u===void 0?null:Number(u||0),minus:i.includes("-"),zero:i.includes("0"),plus:i.includes("+"),space:i.includes(" "),alt:i.includes("#")};if(l.width>Ce||l.precision>Ce)throw new y("feature","format size limit","format width or precision exceeds the output limit");n.push(l),r+=o[0].length}else if(e[r]==="\\"&&t){let o=e[r+1],i=/^(?:[0-7]{1,3}|x[\da-fA-F]{1,2})/u.exec(e.slice(r+1))?.[0];if(i){let s=i[0]==="x"?16:8;n.push([parseInt(s===16?i.slice(1):i,s)&255]),r+=i.length+1}else if(Object.hasOwn(qd,o))n.push([qd[o]]),r+=2;else throw new y("feature","format escape",`format escape ${JSON.stringify(e.slice(r,r+2))} is not supported`)}else{let o=r+1;for(;o<e.length&&e[o]!=="%"&&!(t&&e[o]==="\\");)o++;n.push(B(e.slice(r,o))),r=o}return t||n.push([10]),n}function Gd(e,t,n,r){let o=r.isDir(n);if(o&&r.isFile(n))throw new y("feature","ambiguous file type",`path is both a file and a directory: ${t}`);let i=!o&&r.isLink?.(n)===!0,s,u=e.map(f=>{if(!f.field)return f;if(f.field==="n")return zd(t,f);if(f.field==="s"&&o)throw new y("feature","directory byte size",`directory byte sizes are not available: ${t}`);return s??=o?0:r.fileSize(n),f.field==="F"?zd(o?"directory":i?"symbolic link":s===0?"regular empty file":"regular file",f):B(bo(BigInt(s),f))}),a=new Uint8Array(u.reduce((f,c)=>f+c.length,0)),l=0;for(let f of u)a.set(f,l),l+=f.length;return W(a)}function zd(e,t){let n=B(e);t.precision!==null&&(n=n.subarray(0,t.precision));let r=Math.max(0,t.width-n.length);if(!r)return n;let o=new Uint8Array(n.length+r).fill(32);return o.set(n,t.minus?0:r),o}function Xd(e,t,n){let{order:r,positional:o}=N(t,{short:["L","t"],long:["dereference","terse"],valueShort:["c"],valueLong:["format","printf","cached"]});if(!o.length)return x("stat: missing operand");let i=r.some(({name:f})=>f==="L"||f==="dereference"),s;for(let f of r)if(f.name==="cached"){if(!f.value||!["always","never","default"].some(c=>c.startsWith(f.value)))return x(`stat: invalid cache mode: ${f.value}`)}else["c","format","printf"].includes(f.name)&&(s=f);if(!s)return v("feature","stat","default metadata","stat: default output requires filesystem metadata that is not available");let u=Hd(s.value,s.name==="printf");if(u.some(f=>f.field==="s"||f.field==="F")&&Dx(o,n,i))return v("feature","stat","metadata output overlap","stat: buffered output sharing a measured file is not supported");let a=U(),l=!1;for(let f of o){let c=Px(u,f,n,i);_(a,c),l||=c.exitCode!==0}return a.exitCode=l?1:0,a}function Px(e,t,n,r){if(t==="-"){let i=v("feature","stat","standard input metadata","stat: standard input metadata is not supported");return n.unsupported.add({kind:"feature",command:"stat",detail:"standard input metadata",message:i.stderr.trimEnd()}),i}let o=P(n,"stat",t,{follow:r});if(o.error)return x(`stat: cannot statx ${X(t,n)}: ${o.error}`);try{return F(Gd(e,t,o.path,n.fs))}catch(i){let s=K(i,"stat","stat: "+V(i)),u=O(s);return u&&n.unsupported.add(u),s}}function Dx(e,t,n){let r=Object.values(t.outputFds).filter(o=>typeof o=="object");return r.length?e.some(o=>{let i=E(t.cwd,o,t.fs,{follow:n});return!i.error&&r.some(s=>s.path===i.path||s.identity!==void 0&&s.identity===t.fs.fileIdentity?.(i.path))}):!1}var Bx=/[ \t\n\v\f\r]/gu,Ux=/[ \t\n\v\f\r]+/gu,Zd=/[ \t\n\v\f\r]+$/u,Yd=e=>e.replace(/[A-Z]/gu,t=>t.toLowerCase());function yo({ignoreCase:e=!1,whitespace:t="none"}={}){let n=null;return t==="all"?n=r=>r.replace(Bx,""):t==="change"?n=r=>r.replace(Zd,"").replace(Ux," "):t==="trailing"&&(n=r=>r.replace(Zd,"")),e?n?r=>Yd(n(r)):Yd:n}function At(e){let t=[];for(let n=0;n<e.length;){let r=e.indexOf(`
|
|
108
|
+
`,n),o=r<0?e.length:r+1;t.push(e.slice(n,o)),n=o}return t}var cn=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: ?(.*?))?\n?$/u,qt=/^\*{15,}(?: (.*?))?\n?$/u,xo=/^\*{3} (\d+)(?:,(\d+))? \*{4}\n?$/u,nr=/^--- (\d+)(?:,(\d+))? ----\n?$/u,dn=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n?$/u;var Pe=class extends Error{constructor(t,n){super(n===void 0?t:`${t} at line ${n+1}`),this.name="PatchError",this.line=n}},ko=(e,t)=>t===0?Number(e):Number(e)-1,Xs=e=>e!==void 0&&e.startsWith("\\"),Zs=e=>e.replace(/\n$/u,"");function Ys(e){let t=At(e),n=[],r={old:null,new:null},o=!1;for(let i=0;i<t.length;){let s=t[i],u=Vd(s,o);if(o=s.startsWith("***************")?!1:s.startsWith("*** "),u){r=u.names??{...r,[u.slot]:u.name},i++;continue}let a=cn.test(s)?"unified":qt.test(s)?"context":dn.test(s)?"normal":null;if(a===null){i++;continue}let l=[],f=Gx[a];for(let c=f(t,i);c!==null&&(l.push(c.hunk),i=c.next,!(i>=t.length||Vd(t[i],!1)));c=f(t,i));n.push({old:r.old,new:r.new,format:a,hunks:l,blocks:jx(l)}),r={old:null,new:null}}return n}function Vd(e,t){let n=/^diff --git (\S+) (\S+)\n?$/u.exec(e);if(n)return{names:{old:n[1],new:n[2]}};if(xo.test(e)||nr.test(e))return null;let r=/^(\*\*\* |--- |\+\+\+ )(.*?)(?:\t.*)?\n?$/u.exec(e);return r?r[1]==="--- "?{slot:t?"new":"old",name:r[2]}:{slot:r[1]==="*** "?"old":"new",name:r[2]}:null}function jx(e){let t=[];for(let n of e){let r=n.oldStart,o=n.newStart,i=null,s=()=>{i&&(t.push(i),r=i.a1,o=i.b1,i=null)};for(let{tag:u,text:a}of n.lines){if(u===" "){s(),r++,o++;continue}u==="-"&&i?.insert.length&&s(),i??={a0:r,a1:r,b0:o,b1:o,remove:[],insert:[]},u==="-"?(i.a1++,i.remove.push(a)):(i.b1++,i.insert.push(a))}s()}return t}function Wx(e,t){let n=cn.exec(e[t]??"");if(!n)return null;let r=n[2]===void 0?1:Number(n[2]),o=n[4]===void 0?1:Number(n[4]),i={oldStart:ko(n[1],r),newStart:ko(n[3],o),label:n[5]||null,lines:[]},s=0,u=t+1,a=0;for(;a<r||s<o;u++){let l=e[u];if(l===void 0)throw new Pe("the patch ends inside a hunk",u);let f=l===`
|
|
109
109
|
`?" ":l[0];if(f!==" "&&f!=="-"&&f!=="+")throw new Pe(`a hunk line begins with ${JSON.stringify(f)}`,u);let c=l===`
|
|
110
|
-
`?l:l.slice(1);if(
|
|
111
|
-
`)throw new Pe("'---' expected",c);c++}return d(l,">","+"),{hunk:f,next:c}}function
|
|
110
|
+
`?l:l.slice(1);if(Xs(e[u+1])&&(c=Zs(c),u++),f!=="+"&&a++,f!=="-"&&s++,a>r||s>o)throw new Pe("a hunk has more lines than its header says",u);i.lines.push({tag:f,text:c})}return{hunk:i,next:u}}function qx(e,t){let n=dn.exec(e[t]??"");if(!n)return null;let[,r,o,i,s,u]=n,a=i==="a"?0:Number(o??r)-Number(r)+1,l=i==="d"?0:Number(u??s)-Number(s)+1;if(a<0||l<0)throw new Pe("a change command counts backwards",t);let f={oldStart:i==="a"?Number(r):Number(r)-1,newStart:i==="d"?Number(s):Number(s)-1,label:null,lines:[]},c=t+1,d=(p,h,m)=>{for(let g=0;g<p;g++,c++){let w=e[c];if(w===void 0)throw new Pe("the patch ends inside a hunk",c);if(w[0]!==h)throw new Pe(`${JSON.stringify(h)} expected`,c);let b=w.slice(2);Xs(e[c+1])&&(b=Zs(b),c++),f.lines.push({tag:m,text:b})}};if(d(a,"<","-"),i==="c"){if(e[c]!==`---
|
|
111
|
+
`)throw new Pe("'---' expected",c);c++}return d(l,">","+"),{hunk:f,next:c}}function zx(e,t){let n=qt.exec(e[t]??"");if(!n)return null;let r=xo.exec(e[t+1]??"");if(!r)throw new Pe("'*** ' range expected",t+1);let o=t+2,i=Kd(e,o,nr,"-");o=i.next;let s=nr.exec(e[o]??"");if(!s)throw new Pe("'--- ' range expected",o);let u=Kd(e,o+1,null,"+"),a=i.lines.length===0?u.lines.filter(d=>d.tag===" "):i.lines,l=u.lines.length===0?i.lines.filter(d=>d.tag===" "):u.lines,f=ko(r[1],a.length),c=ko(s[1],l.length);return{hunk:{oldStart:f,newStart:c,label:n[1]||null,lines:Hx(a,l)},next:u.next}}function Kd(e,t,n,r){let o=[],i=t;for(;i<e.length;i++){let s=e[i];if(n&&n.test(s)||qt.test(s)||xo.test(s)||!n&&nr.test(s))break;if(Xs(s)){o[o.length-1].text=Zs(o.at(-1).text);continue}let u=s===`
|
|
112
112
|
`?" ":s[0];if(u!==" "&&u!=="!"&&u!=="-"&&u!=="+")break;o.push({tag:u===" "?" ":r,text:s===`
|
|
113
|
-
`?s:s.slice(2)})}return{lines:o,next:i}}function
|
|
113
|
+
`?s:s.slice(2)})}return{lines:o,next:i}}function Hx(e,t){let n=[],r=0,o=0;for(;r<e.length||o<t.length;){if(e[r]?.tag===" "&&t[o]?.tag===" "){n.push(e[r]),r++,o++;continue}for(;r<e.length&&e[r].tag!==" ";)n.push(e[r]),r++;for(;o<t.length&&t[o].tag!==" ";)n.push(t[o]),o++;e[r]?.tag===" "&&t[o]===void 0?(n.push(e[r]),r++):t[o]?.tag===" "&&e[r]===void 0&&(n.push(t[o]),o++)}return n}var Gx={unified:Wx,context:zx,normal:qx};var We=class extends Error{constructor(t){super(`the rendered diff does not say what the change set says (${t})`),this.name="FormatError"}};function np(e,t,n,r){if(n.length===0){if(r!=="")throw new We("there was nothing to print, and something was printed");return}let o;try{o=Ys(r)}catch(s){throw new We(`it does not read back (${s.message})`)}if(o.length!==1)throw new We(`${o.length} files read back, not one`);let i=o[0].blocks;if(i.length!==n.length)throw new We(`${i.length} blocks read back, not ${n.length}`);for(let[s,u]of i.entries()){let a=n[s];if(u.a0!==a.a0||u.a1!==a.a1||u.b0!==a.b0||u.b1!==a.b1)throw new We(`block ${s+1} reads back somewhere else`)}for(let s of o[0].hunks){let u=s.oldStart,a=s.newStart;for(let{tag:l,text:f}of s.lines){let c=l==="+"?t[a]:e[u];if(f!==c)throw new We(`a ${l==="+"?"added":l==="-"?"removed":"kept"} line is not the line it stands for`);l!=="+"&&u++,l!=="-"&&a++}}}function Xx(e,t,n,r){let o=[],i=0;for(;i<e.length;){let s=i;for(;s+1<e.length&&e[s+1].a0-e[s].a1<=2*t;)s++;let u=e[i],a=e[s];o.push({blocks:e.slice(i,s+1),a0:Math.max(0,u.a0-t),a1:Math.min(n,a.a1+t),b0:Math.max(0,u.b0-t),b1:Math.min(r,a.b1+t)}),i=s+1}return o}var rp=e=>(t,n,r,{context:o,label:i=null})=>{let s="";for(let u of Xx(r,o,t.length,n.length))s+=e(t,n,u,i?i(u.a0):null);return np(t,n,r,s),s},Zx=`
|
|
114
114
|
\
|
|
115
115
|
`,dt=(e,t)=>e+t+(t.endsWith(`
|
|
116
|
-
`)?"":Zx);function
|
|
116
|
+
`)?"":Zx);function Jd(e,t){return t>e+1?`${e+1},${t}`:`${t>e?e+1:e}`}function op(e,t,n){let r="";for(let{a0:o,a1:i,b0:s,b1:u}of n){let a=o===i?"a":s===u?"d":"c";r+=Jd(o,i)+a+Jd(s,u)+`
|
|
117
117
|
`;for(let l=o;l<i;l++)r+=dt("< ",e[l]);a==="c"&&(r+=`---
|
|
118
|
-
`);for(let l=s;l<u;l++)r+=dt("> ",t[l])}return
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
`,
|
|
122
|
-
`,
|
|
123
|
-
`;function o2(e,t,n){if(e===t)return"";let r=
|
|
118
|
+
`);for(let l=s;l<u;l++)r+=dt("> ",t[l])}return np(e,t,n,r),r}function Qd(e,t){return t<=e?`${e},0`:t===e+1?`${e+1}`:`${e+1},${t-e}`}var ip=rp((e,t,n,r)=>{let o=`@@ -${Qd(n.a0,n.a1)} +${Qd(n.b0,n.b1)} @@${r===null?"":" "+r}
|
|
119
|
+
`,i=n.a0,s=n.b0;for(let{a0:u,a1:a,b1:l}of n.blocks){for(;i<u;i++,s++)o+=dt(" ",e[i]);for(;i<a;i++)o+=dt("-",e[i]);for(;s<l;s++)o+=dt("+",t[s])}for(;i<n.a1;i++,s++)o+=dt(" ",e[i]);return o});function ep(e,t){return t<=e?`${e}`:t===e+1?`${e+1}`:`${e+1},${t}`}var sp=rp((e,t,n,r)=>{let o=`***************${r===null?"":" "+r}
|
|
120
|
+
`;return o+=`*** ${ep(n.a0,n.a1)} ****
|
|
121
|
+
`,n.blocks.some(i=>i.a0<i.a1)&&(o+=tp(e,n.a0,n.a1,n.blocks,"a")),o+=`--- ${ep(n.b0,n.b1)} ----
|
|
122
|
+
`,n.blocks.some(i=>i.b0<i.b1)&&(o+=tp(t,n.b0,n.b1,n.blocks,"b")),o});function tp(e,t,n,r,o){let i=o+"1",s=o+"0",u=o==="a"?"b":"a",a="",l=t;for(let f of r){for(;l<f[s];l++)a+=dt(" ",e[l]);let c=f[u+"0"]<f[u+"1"]?"! ":o==="a"?"- ":"+ ";for(;l<f[i];l++)a+=dt(c,e[l])}for(;l<n;l++)a+=dt(" ",e[l]);return a}function Yx(e){let t=[];for(let n=0;;){let r=n;for(;n<e.length&&e[n];)n++;if(t.push(n>r),n===e.length)return t;n++}}function Vs(e,t,n){let r=t.length,o=Yx(n),i=0,s=0,u=0,a=()=>{if(i===r||e[u]!==e[i])return!1;for(t[u++]=0,t[i++]=1,s++;i<r&&t[i];)i++;return!0},l=()=>{if(u===0||e[u-1]!==e[i-1])return!1;for(t[--u]=1,t[--i]=0,s--;u>0&&t[u-1];)u--;return!0};for(let f=0;f<r;f++){if(!t[f]){s++;continue}for(u=f,i=f;i<r&&t[i];i++);let c=-1;for(let d=-1;d!==i-u;){for(d=i-u;l(););for(c=o[s]?i:-1;a();)o[s]&&(c=i)}if(c!==-1)for(let d=i-c;d>0;d--)l();f=i-1}}function Vx(e){let t=1;for(let n=e;n!==0;n>>=2)t<<=1;return Math.max(256,t)}function up(e,t,{ignoreCase:n=!1,whitespace:r="none",minimal:o=!1,slide:i=!0}={}){let s=yo({ignoreCase:n,whitespace:r});if(s===null&&Ks(e,t,null))return[];let{A:u,B:a}=Kx(e,t,s),l=new Uint8Array(u.length),f=new Uint8Array(a.length);Jx(u,a,l,f,o),i&&(Vs(u,l,f),Vs(a,f,l));let c=t2(l,f);return n2(e,t,c,s),c}function Ks(e,t,n=null){if(e.length!==t.length)return!1;let r=n?(o,i)=>n(o)===n(i):(o,i)=>o===i;for(let o=0;o<e.length;o++)if(!r(e[o],t[o]))return!1;return!0}function Kx(e,t,n){let r=new Map,o=s=>{let u=n?n(s):s,a=r.get(u);return a===void 0&&(a=r.size,r.set(u,a)),a};return{A:Int32Array.from(e,o),B:Int32Array.from(t,o)}}function Jx(e,t,n,r,o){let i=e.length+t.length+3,s={A:e,B:t,fd:new Int32Array(i),bd:new Int32Array(i),base:t.length+1,limit:Vx(e.length+t.length)},u=[{xoff:0,xlim:e.length,yoff:0,ylim:t.length,minimal:o}],a={xmid:0,ymid:0,loMinimal:!1,hiMinimal:!1};for(;u.length;){let{xoff:l,xlim:f,yoff:c,ylim:d,minimal:p}=u.pop();for(;l<f&&c<d&&e[l]===t[c];)l++,c++;for(;l<f&&c<d&&e[f-1]===t[d-1];)f--,d--;if(l===f){for(;c<d;c++)r[c]=1;continue}if(c===d){for(;l<f;l++)n[l]=1;continue}Qx(s,l,f,c,d,p,a),u.push({xoff:a.xmid,xlim:f,yoff:a.ymid,ylim:d,minimal:a.hiMinimal}),u.push({xoff:l,xlim:a.xmid,yoff:c,ylim:a.ymid,minimal:a.loMinimal})}}function Qx(e,t,n,r,o,i,s){let{A:u,B:a,fd:l,bd:f,base:c,limit:d}=e,p=n-r,h=t-o,m=n-o,g=t-r,w=m,b=m,k=g,S=g,I=(g-m&1)!==0;l[c+g]=t,f[c+m]=n;for(let M=1;;M++){S>h?l[c+--S-1]=-1:++S,k<p?l[c+ ++k+1]=-1:--k;for(let C=k;C>=S;C-=2){let H=l[c+C+1],Y=l[c+C-1],D=Y<H?H:Y+1,de=D-C;for(;D<n&&de<o&&u[D]===a[de];)D++,de++;if(l[c+C]=D,I&&b<=C&&C<=w&&f[c+C]<=D){s.xmid=D,s.ymid=de,s.loMinimal=s.hiMinimal=!0;return}}b>h?f[c+--b-1]=2147483647:++b,w<p?f[c+ ++w+1]=2147483647:--w;for(let C=w;C>=b;C-=2){let H=f[c+C+1],Y=f[c+C-1],D=Y<H?Y:H-1,de=D-C;for(;t<D&&r<de&&u[D-1]===a[de-1];)D--,de--;if(f[c+C]=D,!I&&S<=C&&C<=k&&D<=l[c+C]){s.xmid=D,s.ymid=de,s.loMinimal=s.hiMinimal=!0;return}}if(!(i||M<d)){e2(e,{xoff:t,xlim:n,yoff:r,ylim:o,fmin:S,fmax:k,bmin:b,bmax:w},s);return}}}function e2(e,t,n){let{fd:r,bd:o,base:i}=e,{xoff:s,xlim:u,yoff:a,ylim:l,fmin:f,fmax:c,bmin:d,bmax:p}=t,h=0,m=-1;for(let b=c;b>=f;b-=2){let k=Math.min(r[i+b],u),S=k-b;l<S&&(k=l+b,S=l),m<k+S&&(m=k+S,h=k)}let g=0,w=2147483647;for(let b=p;b>=d;b-=2){let k=Math.max(s,o[i+b]),S=k-b;S<a&&(k=a+b,S=a),k+S<w&&(w=k+S,g=k)}u+l-w<m-(s+a)?(n.xmid=h,n.ymid=m-h,n.loMinimal=!0,n.hiMinimal=!1):(n.xmid=g,n.ymid=w-g,n.loMinimal=!1,n.hiMinimal=!0)}function t2(e,t){let n=[],r=t.length,o=e.length,i=0,s=0;for(;i<o||s<r;){if(i<o&&s<r&&!e[i]&&!t[s]){i++,s++;continue}let u=i,a=s;for(;i<o&&e[i];)i++;for(;s<r&&t[s];)s++;if(u===i&&a===s)throw new ve("a kept line has no counterpart");n.push({a0:u,a1:i,b0:a,b1:s})}return n}function n2(e,t,n,r=null){let o=r?(u,a)=>r(u)===r(a):(u,a)=>u===a,i=0,s=0;for(let{a0:u,a1:a,b0:l,b1:f}of n){if(u<i||l<s||a<u||f<l||a>e.length||f>t.length)throw new ve("a block is out of order or out of range");if(u===a&&l===f)throw new ve("a block changes nothing");if(u-i!==l-s)throw new ve("the kept lines before a block differ in count");for(;i<u;i++,s++)if(!o(e[i],t[s]))throw new ve(`kept line ${i+1} does not match`);i=a,s=f}if(e.length-i!==t.length-s)throw new ve("the kept lines after the last block differ in count");for(;i<e.length;i++,s++)if(!o(e[i],t[s]))throw new ve(`kept line ${i+1} does not match`)}var ve=class extends Error{constructor(t){super(`the computed change set does not reconstruct the second file (${t})`),this.name="DiffError"}};var r2={unified:ip,context:sp,normal:op},ap=`Files differ
|
|
123
|
+
`;function o2(e,t,n){if(e===t)return"";let r=yo(n);return r===null?ap:Ks(At(e),At(t),r)?"":ap}function rr(e,t,{format:n="unified",context:r=3,label:o=null,...i}={}){if(n==="brief")return o2(e,t,i);let s=At(e),u=At(t),{slide:a=n!=="normal"&&r>0,...l}=i,f=up(s,u,{...l,slide:a});return f.length===0?"":r2[n](s,u,f,{context:r,label:o})}var i2=[" 1970-01-01 00:00:00.000000000 +0000"," Thu Jan 1 00:00:00 1970"];function lp(e,t,n,r,o){let{ctx:i,opts:s}=e,u=s2(s,t);if(u==="")return"";let a=c=>s.labels[c]??ys(n[c],i)+(r[c]?i2[s.style==="context"?1:0]:""),l=c=>s.labels[c]??ys(n[c],i),f=o?`diff${s.switches} ${l(0)} ${l(1)}
|
|
124
124
|
`:"";return s.style==="unified"?`${f}--- ${a(0)}
|
|
125
125
|
+++ ${a(1)}
|
|
126
126
|
${u}`:s.style==="context"?`${f}*** ${a(0)}
|
|
127
127
|
--- ${a(1)}
|
|
128
|
-
${u}`:f+u}function s2(e,t){let n=e.showFunction?Ge(t[0]):null;return rr(t[0],t[1],{format:e.style??"normal",context:e.context,label:n?r=>a2(n,r):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace})}var u2=/^[A-Za-z$_]/u;function a2(e,t){for(let n=t-1;n>=0;n--){if(!u2.test(e[n]))continue;let r=A(e[n].replace(/\n$/u,"")),o=Math.min(40,r.length);for(;o>0&&l2(r[o-1]);)o--;return f2(r.subarray(0,o))}return null}var l2=e=>e===32||e>=9&&e<=13;function f2(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return W(e.subarray(0,t))}catch{}return""}var c2=["q","s","r","N","a","i","w","b","Z","p","d","u","c","e","n","y","t","T","l","E","B","P","v","H"],d2=["brief","report-identical-files","recursive","new-file","text","ignore-case","ignore-all-space","ignore-space-change","ignore-trailing-space","strip-trailing-cr","show-c-function","minimal","normal","unified","context","ed","rcs","side-by-side","expand-tabs","initial-tab","paginate","ignore-tab-expansion","ignore-blank-lines","unidirectional-new-file","version","help","suppress-common-lines","speed-large-files","ignore-file-name-case","no-ignore-file-name-case","no-dereference","left-column"],
|
|
129
|
-
diff: Try 'diff --help' for more information.`,2);function m2(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--"){t.push(...e.slice(n));break}if(r==="--unified"||r==="--context")t.push("-"+(r==="--unified"?"u":"c"));else if(r.startsWith("--unified=")||r.startsWith("--context="))t.push(r.startsWith("--u")?"-U":"-C",r.slice(10));else{if(r.startsWith("--color"))return{refused:"colored output",label:r};t.push(r)}}return{tokens:t}}function
|
|
130
|
-
`,1)}}function x2(e,[t,n],r,o){
|
|
131
|
-
`):ir(e,t,n,!0,o)}function k2(e,[t,n],[r,o]){let{opts:i}=e,s=[r,o].indexOf("gone");if(s!==-1&&
|
|
132
|
-
`,2,!0)}if(
|
|
133
|
-
`);else if(r===o||s!==-1)ir(e,t,n,!0,[!0,!0]);else{let u=(a,l)=>i.labels[a]??l;Se(e,`File ${u(0,t)} is a ${
|
|
134
|
-
`,1)}}var
|
|
135
|
-
`,2,!0)}else{let d=
|
|
136
|
-
`,2,!0):ir(s,p[0],p[1],!1)}}else ir(s,u,a,!1);return s.out.exitCode=s.status,s.out}function
|
|
128
|
+
${u}`:f+u}function s2(e,t){let n=e.showFunction?Ge(t[0]):null;return rr(t[0],t[1],{format:e.style??"normal",context:e.context,label:n?r=>a2(n,r):null,minimal:e.minimal,ignoreCase:e.ignoreCase,whitespace:e.whitespace})}var u2=/^[A-Za-z$_]/u;function a2(e,t){for(let n=t-1;n>=0;n--){if(!u2.test(e[n]))continue;let r=A(e[n].replace(/\n$/u,"")),o=Math.min(40,r.length);for(;o>0&&l2(r[o-1]);)o--;return f2(r.subarray(0,o))}return null}var l2=e=>e===32||e>=9&&e<=13;function f2(e){for(let t=e.length;t>Math.max(0,e.length-4);t--)try{return W(e.subarray(0,t))}catch{}return""}var c2=["q","s","r","N","a","i","w","b","Z","p","d","u","c","e","n","y","t","T","l","E","B","P","v","H"],d2=["brief","report-identical-files","recursive","new-file","text","ignore-case","ignore-all-space","ignore-space-change","ignore-trailing-space","strip-trailing-cr","show-c-function","minimal","normal","unified","context","ed","rcs","side-by-side","expand-tabs","initial-tab","paginate","ignore-tab-expansion","ignore-blank-lines","unidirectional-new-file","version","help","suppress-common-lines","speed-large-files","ignore-file-name-case","no-ignore-file-name-case","no-dereference","left-column"],fp=["U","C","x","X","S","F","W","I","D"],cp=["show-function-line","exclude-from","starting-file","from-file","to-file","ifdef","width","tabsize","horizon-lines","ignore-matching-lines","line-format","old-line-format","new-line-format","unchanged-line-format","old-group-format","new-group-format","unchanged-group-format","changed-group-format","color","palette"],p2=["L","label","x","exclude"],h2=new Map([["e","ed script output"],["ed","ed script output"],["n","RCS output"],["rcs","RCS output"],["y","side-by-side output"],["side-by-side","side-by-side output"],["W","side-by-side output"],["width","side-by-side output"],["suppress-common-lines","side-by-side output"],["left-column","side-by-side output"],["t","tab expansion"],["expand-tabs","tab expansion"],["T","initial tabs"],["initial-tab","initial tabs"],["tabsize","tab expansion"],["E","tab expansion"],["ignore-tab-expansion","tab expansion"],["B","ignoring blank lines"],["ignore-blank-lines","ignoring blank lines"],["I","ignoring matching lines"],["ignore-matching-lines","ignoring matching lines"],["D","merged #ifdef output"],["ifdef","merged #ifdef output"],["l","pagination"],["paginate","pagination"],["F","a custom function regex"],["show-function-line","a custom function regex"],["X","reading exclusions from a file"],["exclude-from","reading exclusions from a file"],["S","a starting file"],["starting-file","a starting file"],["from-file","comparing one file to many"],["to-file","comparing one file to many"],["P","one-sided new files"],["unidirectional-new-file","one-sided new files"],["v","a version banner"],["version","a version banner"],["help","a help text"],["H","large-file heuristics"],["speed-large-files","large-file heuristics"],["horizon-lines","the horizon setting"],["ignore-file-name-case","case-insensitive names"],["no-ignore-file-name-case","case-insensitive names"],["no-dereference","symbolic links"],["color","colored output"],["palette","colored output"],["line-format","custom line formats"],["old-line-format","custom line formats"],["new-line-format","custom line formats"],["unchanged-line-format","custom line formats"],["old-group-format","custom group formats"],["new-group-format","custom group formats"],["unchanged-group-format","custom group formats"],["changed-group-format","custom group formats"]]),or=e=>x(`diff: ${e}
|
|
129
|
+
diff: Try 'diff --help' for more information.`,2);function m2(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--"){t.push(...e.slice(n));break}if(r==="--unified"||r==="--context")t.push("-"+(r==="--unified"?"u":"c"));else if(r.startsWith("--unified=")||r.startsWith("--context="))t.push(r.startsWith("--u")?"-U":"-C",r.slice(10));else{if(r.startsWith("--color"))return{refused:"colored output",label:r};t.push(r)}}return{tokens:t}}function dp(e){let t=m2(e);if(t.refused)return{refused:v("option","diff",t.label.replace(/=.*/u,""),`diff: ${t.label}: ${t.refused} is not supported`,2)};let n;try{n=N(t.tokens,{short:c2,long:d2,valueShort:fp,valueLong:cp,repeatable:p2})}catch(o){let i=O(o);return i?{refused:v(i.kind,"diff",i.detail,`diff: ${o.message}`,2)}:{error:or(o.message)}}let r={style:null,context:-1,labels:[],excludes:[],whitespace:"none",switches:b2(e)};for(let{name:o,value:i}of n.order){let s=h2.get(o),u=(o.length===1?"-":"--")+o;if(s)return{refused:v("option","diff",u,`diff: ${u}: ${s} is not supported`,2)};let a=g2(r,o,i);if(a)return{error:a}}return r.showFunction&&r.style===null&&(r.style="context"),r.context<0&&(r.context=3),n.positional.length<2?{error:or(`missing operand after '${n.positional[0]??"diff"}'`)}:n.positional.length>2?{error:or(`extra operand '${n.positional[2]}'`)}:{opts:r,operands:n.positional}}function g2(e,t,n){let r=o=>e.style!==null&&e.style!==o?or("conflicting output style options"):(e.style=o,null);switch(t){case"u":case"c":{let o=r(t==="u"?"unified":"context");return e.context<3&&(e.context=3),o}case"U":case"C":{let o=w2(n);if(o===null)return or(`invalid context length '${n}'`);let i=r(t==="U"?"unified":"context");return e.context<o&&(e.context=o),i}case"normal":return r("normal");case"q":case"brief":return e.brief=!0,null;case"s":case"report-identical-files":return e.identical=!0,null;case"r":case"recursive":return e.recursive=!0,null;case"N":case"new-file":return e.newFile=!0,null;case"a":case"text":return e.text=!0,null;case"i":case"ignore-case":return e.ignoreCase=!0,null;case"w":case"ignore-all-space":return e.whitespace="all",null;case"b":case"ignore-space-change":return e.whitespace!=="all"&&(e.whitespace="change"),null;case"Z":case"ignore-trailing-space":return e.whitespace==="none"&&(e.whitespace="trailing"),null;case"strip-trailing-cr":return e.stripCr=!0,null;case"p":case"show-c-function":return e.showFunction=!0,null;case"d":case"minimal":return e.minimal=!0,null;case"L":case"label":return e.labels.length===2?x("diff: too many file label options",2):(e.labels.push(n),null);case"x":case"exclude":return e.excludes.push(n),null;default:return null}}function w2(e){if(e==="")return 0;let t=ye(e,"diff");return t.error?null:t.value}function b2(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="--")break;!r.startsWith("-")||r==="-"||(t.push(r),y2(r)&&n+1<e.length&&t.push(e[++n]))}return t.map(n=>" "+oe(n,{vars:new Map})).join("")}function y2(e){if(e.startsWith("--"))return!e.includes("=")&&(cp.includes(e.slice(2))||e==="--label"||e==="--exclude");for(let t=1;t<e.length;t++){let n=e[t];if(fp.includes(n)||n==="L")return t+1===e.length}return!1}function Eo(e,t,n){let{ctx:r,opts:o}=e,i=v2(mp(e,t),mp(e,n));for(let[s,u,a]of i){let l=So(t,s),f=So(n,s),c=u?hp(r,l):null,d=a?hp(r,f):null;if(u&&a){k2(e,[l,f],[c,d]);continue}o.newFile?x2(e,[l,f],c??d,[u,a]):Se(e,`Only in ${u?t:n}: ${s}
|
|
130
|
+
`,1)}}function x2(e,[t,n],r,o){vo(r)?e.opts.recursive?gp(e,[t,n],o.map(i=>i?r:null)):Se(e,`Common subdirectories: ${t} and ${n}
|
|
131
|
+
`):ir(e,t,n,!0,o)}function k2(e,[t,n],[r,o]){let{opts:i}=e,s=[r,o].indexOf("gone");if(s!==-1&&vo([r,o][1-s])){let u=[t,n][s];return Se(e,`diff: ${u}: ${E(e.ctx.cwd,u,e.ctx.fs).error}
|
|
132
|
+
`,2,!0)}if(vo(r)&&vo(o))i.recursive?gp(e,[t,n],[r,o]):Se(e,`Common subdirectories: ${t} and ${n}
|
|
133
|
+
`);else if(r===o||s!==-1)ir(e,t,n,!0,[!0,!0]);else{let u=(a,l)=>i.labels[a]??l;Se(e,`File ${u(0,t)} is a ${pp[r]} while file ${u(1,n)} is a ${pp[o]}
|
|
134
|
+
`,1)}}var pp={dir:"directory",link:"directory",file:"regular file"},vo=e=>e==="dir"||e==="link";function hp(e,t){let n=E(e.cwd,t,e.fs);return n.error?"gone":e.fs.isDir(n.path)?e.fs.isLink?.(E(e.cwd,t,e.fs,{follow:!1}).path)?"link":"dir":"file"}function gp(e,[t,n],[r,o]){for(let[i,s]of[[r,t],[o,n]])if(i==="link")throw new y("feature","symbolic link to a directory",`comparing what a symbolic link to a directory holds is not supported: ${s}`);Eo(e,t,n)}function mp(e,t){let{ctx:n,opts:r}=e,o=E(n.cwd,t,n.fs);if(o.error||!n.fs.isDir(o.path))return[];let{dirs:i,files:s,links:u}=n.fs.listDir(o.path),a=[...i,...s,...u].sort(j);return r.excludes.length?a.filter(l=>!r.excludes.some(f=>Qf(l,f))):a}function v2(e,t){let n=[],r=0,o=0;for(;r<e.length||o<t.length;){let i=r===e.length?1:o===t.length?-1:j(e[r],t[o]);i===0?(n.push([e[r++],!0,!0]),o++):i<0?n.push([e[r++],!0,!1]):n.push([t[o++],!1,!0])}return n}function xp(e,t,n){let r=dp(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:o,operands:i}=r,s={ctx:n,opts:o,stdin:e,out:U(),status:0},[u,a]=i,l=i.map(f=>wp(s,f));if(l[0]==="dir"&&l[1]==="dir"&&S2(s,u,a))return s.out;if(l[0]==="dir"&&l[1]==="dir")Eo(s,u,a);else if(l[0]==="dir"||l[1]==="dir"){let f=l[0]==="dir"?0:1,c=i[1-f];if(c==="-")return x("diff: cannot compare '-' to a directory",2);if(l[1-f]==="missing"){let d=E(s.ctx.cwd,c,s.ctx.fs).error;o.newFile&&d==="No such file or directory"?Eo(s,u,a):Se(s,`diff: ${c}: ${d}
|
|
135
|
+
`,2,!0)}else{let d=So(i[f],nt(c)),p=f===0?[d,c]:[c,d];wp(s,d)==="missing"?Se(s,`diff: ${d}: No such file or directory
|
|
136
|
+
`,2,!0):ir(s,p[0],p[1],!1)}}else ir(s,u,a,!1);return s.out.exitCode=s.status,s.out}function So(e,t){let n=e.replace(/\/+$/u,"");return(n===""?"/":n+"/")+t}function S2(e,t,n){return E(e.ctx.cwd,t,e.ctx.fs).path===E(e.ctx.cwd,n,e.ctx.fs).path}function wp(e,t){if(t==="-")return"stdin";let n=E(e.ctx.cwd,t,e.ctx.fs);return n.error?"missing":e.ctx.fs.isDir(n.path)?"dir":"file"}function Se(e,t,n=0,r=!1){_(e.out,r?U(t):{...U(),stdout:t,events:[{fd:1,text:t}]}),e.status=Math.max(e.status,n)}function ir(e,t,n,r,o=null){let{opts:i}=e,s=[t,n].map(p=>N2(e,p)),u=s.map(p=>p.content===null),a=i.newFile&&!(u[0]&&u[1]),l=!1;for(let p=0;p<2;p++)!u[p]||(o?!o[p]:a)||(Se(e,`diff: ${[t,n][p]}: ${s[p].error??"No such file or directory"}
|
|
137
137
|
`,2,!0),l=!0);if(l)return;if(s[0].identity!==void 0&&s[0].identity===s[1].identity&&!u[0])return sr(e,t,n);let f=p=>i.labels[p]??[t,n][p];if(!i.text&&s.some($2))return bp(s)?sr(e,t,n):Se(e,`${i.brief?"Files":"Binary files"} ${f(0)} and ${f(1)} differ
|
|
138
138
|
`,1);if(s.some(p=>p.content===void 0)){if(bp(s))return sr(e,t,n);if(i.brief&&!i.ignoreCase&&!i.stripCr&&i.whitespace==="none")return Se(e,`Files ${f(0)} and ${f(1)} differ
|
|
139
139
|
`,1)}for(let[p,h]of s.entries())h.content===void 0&&rt(h.bytes,JSON.stringify(f(p)));let c=s.map(p=>p.content??"");if(i.stripCr&&(c=c.map(E2)),i.brief)return rr(c[0],c[1],{format:"brief",ignoreCase:i.ignoreCase,whitespace:i.whitespace})===""?sr(e,t,n):Se(e,`Files ${f(0)} and ${f(1)} differ
|
|
140
|
-
`,1);let d;try{d=
|
|
140
|
+
`,1);let d;try{d=lp(e,c,[t,n],u,r)}catch(p){if(!(p instanceof ve)&&!(p instanceof We))throw p;let h=`diff: ${t} ${n}: ${p.message}`,m=p instanceof ve?"change set verification":"diff rendering verification";_(e.out,v("feature","diff",m,h,2)),e.status=2;return}if(d==="")return sr(e,t,n);Se(e,d,1)}function sr(e,t,n){e.opts.identical&&Se(e,`Files ${t} and ${n} are identical
|
|
141
141
|
`)}var E2=e=>e.replace(/\r\n/gu,`
|
|
142
|
-
`),$2=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes("\0")===!0,bp=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:On(e.bytes??
|
|
142
|
+
`),$2=e=>e.content===void 0?e.bytes.includes(0):e.content?.includes("\0")===!0,bp=([e,t])=>e.content!==void 0&&t.content!==void 0?e.content===t.content:On(e.bytes??yp,t.bytes??yp),yp=new Uint8Array;function N2(e,t){let{ctx:n}=e;if(t==="-")return q(n),{content:e.stdin,identity:n.stdinHandle?.identity??Symbol("stdin")};let r=P(n,"diff",t);if(r.error||n.fs.isDir(r.path))return{content:null,bytes:null,identity:void 0,error:r.error};let{text:o,bytes:i}=wt(n.fs,r.path);return{content:o,bytes:i,identity:n.fs.fileIdentity?.(r.path)??r.path}}var pn=(e,t,n)=>{throw new Q(`malformed patch at line ${Math.min(t,e.lines.length-1)+1}: ${n??""}`)};function ur(e,t){return!!e.lines[t+1]?.startsWith("\\")}function Sp(e){let{lines:t}=e,n=e.pos,r=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@(?: (.*))?\n$/u.exec(t[n]??"");if(!r)return null;let o=n,i=Number(r[3]),s=Number(r[1]),u=r[2]===void 0?1:Number(r[2]),a=r[4]===void 0?1:Number(r[4]);u===0&&s++,a===0&&i++;let l=[],f=[],c=0,d=n,p=-1;for(n++;f.length<u||l.length<a;n+=1){let h=t[n]!==void 0;if(!h&&a-l.length>3)throw new Q("unexpected end of file in patch");let m=h?t[n]:`
|
|
143
143
|
`;h&&(d=n);let g=m[0],w=m;g===" "||g===`
|
|
144
|
-
`?g=" ":w=m.slice(1),g!=="-"&&g!=="+"&&g!==" "&&pn(e,n,m);let
|
|
145
|
-
`?o=" ":(r=r.slice(1),(r[0]===" "||r[0]===" ")&&(r=r.slice(1)));let i=n&&ur(e,t);return{mark:o,text:i?r.replace(/\n$/u,""):r,skip:i}}function A2({oldRange:e,oldSide:t,newRange:n,newSide:r,fn:o,line:i}){let s=r,u=t;if(t.length===0&&e.count&&(u=r.filter(p=>p.mark===" ")),r.length===0&&n.count&&(s=t.filter(p=>p.mark===" ")),u.length!==e.count||s.length!==n.count)throw new Q(`replacement text or line numbers mangled in hunk at line ${i+1}`);let a=u.map(p=>({tag:p.mark===" "?" ":"-",text:p.text})),l=s.map(p=>({tag:p.mark===" "?" ":"+",text:p.text})),f=p=>{let h=0;for(let m of p){if(m.tag!==" ")break;h++}return h},c=Math.min(f(a),f(l)),d=Math.min(f(a.toReversed()),f(l.toReversed()));if(a.every(p=>p.tag===" ")&&l.every(p=>p.tag===" "))throw new Q(`replacement text or line numbers mangled in hunk at line ${i+1}`);return{oldStart:e.first,oldLines:a,newStart:n.first,newLines:l,prefix:c,suffix:d,fn:o,marks:{old:u.map(p=>p.mark),new:s.map(p=>p.mark)},line:i}}function
|
|
144
|
+
`?g=" ":w=m.slice(1),g!=="-"&&g!=="+"&&g!==" "&&pn(e,n,m);let b=!1;g!=="+"&&(f.length>=u&&pn(e,n,m),b=h&&f.length+1===u&&ur(e,n),b&&(w=w.replace(/\n$/u,"")),f.push({tag:g,text:w}),g===" "&&c++),g!=="-"&&(l.length>=a&&pn(e,n,m),!b&&h&&l.length+1===a&&ur(e,n)&&(b=!0,w=w.replace(/\n$/u,"")),l.push({tag:g,text:w})),g!==" "&&(p===-1&&(p=c),c=0),b&&n++}return p===-1&&pn(e,d,t[d]),e.pos=n,{oldStart:s,oldLines:f,newStart:i,newLines:l,prefix:p,suffix:c,fn:r[5]===void 0?null:" "+r[5],marks:null,line:o}}function Js(e){let{lines:t}=e,n=e.pos;if(!t[n]?.startsWith("********"))return null;let r=n,o=/^\*+( .*)?\n$/u.exec(t[n])?.[1]??null,i=/^\*\*\* (\d+)(?:,(\d+))?/u.exec(t[++n]??"");if(!i)throw new Q(`unexpected '***' at line ${n+1}: ${t[n]??""}`);let s=kp(i),u=[],a=c=>/^--- (\d+)(?:,(\d+))? ----/u.exec(t[c]??"")??/^--- (\d+)(?:,(\d+))?/u.exec(t[c]??"");for(n++;!a(n);n++){if(t[n]===void 0||u.length>=s.count)throw new Q(`no '---' found in patch at line ${r+1}`);u.push(vp(e,n,u.length+1===s.count)),u.at(-1).skip&&n++}let l=kp(a(n)),f=[];for(n++;f.length<l.count;n++){let c=t[n];if(c===void 0||!/^[ !+\-\t\n]/u.test(c)||c.startsWith("***"))break;f.push(vp(e,n,f.length+1===l.count)),f.at(-1).skip&&n++}return f.length!==0&&f.length<l.count&&pn(e,n,t[n]),e.pos=n,A2({oldRange:s,oldSide:u,newRange:l,newSide:f,fn:o,line:r})}function kp(e){let t=Number(e[1]),n=e[2]===void 0?t:Number(e[2]);return t===0&&e[2]===void 0?{first:1,count:0}:{first:t,count:n-t+1}}function vp(e,t,n){let r=e.lines[t],o=r[0];o===" "||o===`
|
|
145
|
+
`?o=" ":(r=r.slice(1),(r[0]===" "||r[0]===" ")&&(r=r.slice(1)));let i=n&&ur(e,t);return{mark:o,text:i?r.replace(/\n$/u,""):r,skip:i}}function A2({oldRange:e,oldSide:t,newRange:n,newSide:r,fn:o,line:i}){let s=r,u=t;if(t.length===0&&e.count&&(u=r.filter(p=>p.mark===" ")),r.length===0&&n.count&&(s=t.filter(p=>p.mark===" ")),u.length!==e.count||s.length!==n.count)throw new Q(`replacement text or line numbers mangled in hunk at line ${i+1}`);let a=u.map(p=>({tag:p.mark===" "?" ":"-",text:p.text})),l=s.map(p=>({tag:p.mark===" "?" ":"+",text:p.text})),f=p=>{let h=0;for(let m of p){if(m.tag!==" ")break;h++}return h},c=Math.min(f(a),f(l)),d=Math.min(f(a.toReversed()),f(l.toReversed()));if(a.every(p=>p.tag===" ")&&l.every(p=>p.tag===" "))throw new Q(`replacement text or line numbers mangled in hunk at line ${i+1}`);return{oldStart:e.first,oldLines:a,newStart:n.first,newLines:l,prefix:c,suffix:d,fn:o,marks:{old:u.map(p=>p.mark),new:s.map(p=>p.mark)},line:i}}function Ep(e){let{lines:t}=e,n=e.pos,r=/^(\d+)(?:,(\d+))?([acd])(\d+)(?:,(\d+))?[ \t]*\r?\n$/u.exec(t[n]??"");if(!r)return null;let o=n,i=Number(r[1]),s=r[3]==="a"?0:r[2]===void 0?1:Number(r[2])-i+1;r[3]==="a"&&i++;let u=Number(r[4]),a=r[5]===void 0?u:Number(r[5]);r[3]==="d"&&u++;let l=a-u+1;(s<0||l<0)&&pn(e,n,t[n]);let f=[],c=[];n++;for(let d=0;d<s;d++,n++){if(t[n]===void 0)throw new Q(`unexpected end of file in patch at line ${n}`);if(!/^<[ \t]/u.test(t[n]))throw new Q(`'<' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===s&&ur(e,n);c.push({tag:"-",text:p?t[n].slice(2).replace(/\n$/u,""):t[n].slice(2)}),p&&n++}if(r[3]==="c"){if(t[n]===void 0)throw new Q(`unexpected end of file in patch at line ${n}`);if(!t[n].startsWith("-"))throw new Q(`'---' expected at line ${n+1} of patch`);n++}for(let d=0;d<l;d++,n++){if(t[n]===void 0)throw new Q(`unexpected end of file in patch at line ${n}`);if(!/^>[ \t]/u.test(t[n]))throw new Q(`'>' followed by space or tab expected at line ${n+1} of patch`);let p=d+1===l&&ur(e,n);f.push({tag:"+",text:p?t[n].slice(2).replace(/\n$/u,""):t[n].slice(2)}),p&&n++}return e.pos=n,{oldStart:i,oldLines:c,newStart:u,newLines:f,prefix:0,suffix:0,fn:null,marks:null,line:o}}function $o(e){let t=(r,o,i)=>r.map(s=>({tag:s.tag===o?i:s.tag,text:s.text})),n=(r,o,i)=>r.map(s=>s===o?i:s);return{...e,oldStart:e.newStart,newStart:e.oldStart,oldLines:t(e.newLines,"+","-"),newLines:t(e.oldLines,"-","+"),marks:e.marks&&{old:n(e.marks.new,"+","-"),new:n(e.marks.old,"-","+")}}}var Q=class extends Error{constructor(t){super(t),this.name="PatchFatal"}},hn=(e,t)=>{throw new y("feature",e,t)};function Cp(e){let t=Ge(e);return t.length&&!t.at(-1).endsWith(`
|
|
146
146
|
`)&&(t[t.length-1]+=`
|
|
147
|
-
`),{lines:t,pos:0,base:0,empty:e===""}}var O2=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u
|
|
147
|
+
`),{lines:t,pos:0,base:0,empty:e===""}}var O2=/^\d+(?:,\d+)?[acd]\d+(?:,\d+)?[ \t]*\r?\n$/u,$p=/^(?:\d+(?:,\d+)?)?(?:[acdi]|s\/\.\/\/)[ \t]*\n$/u,Np=/^[0-9a-fA-F]+/u;function Ip(e,{needHeader:t,strip:n,format:r}){let{lines:o}=e,i={names:{old:null,new:null,index:null},stamps:{old:-1,new:-1},timestrs:{old:null,new:null},says:[0,0],git:!1,rename:[!1,!1],copy:[!1,!1],extended:!1},s=t&&r!=="normal"&&r!=="ed",u=!1,a=-1,l=!1,f=!1;for(let c=e.pos;;c++){if(c>=o.length)return u&&hn("ed script","ed scripts are not supported"),i.extended?{...i,type:"unified",start:c,hunkLine:c,empty:!0}:null;let d=o[c],p=d.replace(/^[ \tX]+/u,""),h=/^\d/u.test(p)&&O2.test(p);!s&&a<0&&($p.test(p)||h)&&(a=c,u=$p.test(p));let m=C2(d,i,n,f);if(m==="binary"&&hn("git binary patch","git binary diffs are not supported"),m==="prereq"&&hn("Prereq","Prereq: lines are not supported"),m==="git"&&i.extended)return{...i,type:"unified",start:c,hunkLine:c,empty:!0};m&&(s=!1);let g=d.startsWith("********");if(/^[ \t]+(?:@@ -\d|\*{8})/u.test(d)&&hn("indented patch","indented patches are not supported"),!s){if(d.endsWith(`\r
|
|
148
148
|
`)&&(d.startsWith("@@ -")||f)&&hn("CRLF patch","patches with CRLF line endings are not supported"),(r===null||r==="ed")&&a>=0&&d===`.
|
|
149
|
-
`&&hn("ed script","ed scripts are not supported"),(r===null||r==="unified")&&d.startsWith("@@ -"))return T2(i,c,d);if((r===null||r==="context")&&f&&d.startsWith("*** "))return F2(e,i,c,d);if((r===null||r==="normal")&&l&&(d.startsWith("< ")||d.startsWith("> ")))return{...i,type:"normal",start:c-1,hunkLine:c-1}}f=g,l=h}}function C2(e,t,n,r){if(!r&&e.startsWith("*** ")||e.startsWith("+++ "))return Qs(t,"old",e.slice(4),n);if(e.startsWith("Index:"))return t.names.index=
|
|
150
|
-
`,l+1)!==-1))break}o=r.slice(0,a),i=r.slice(a)}if(o==="/dev/null")return{stamp:0};let s=
|
|
151
|
-
`,r:"\r",t:" ",v:"\v","\\":"\\",'"':'"'};function
|
|
149
|
+
`&&hn("ed script","ed scripts are not supported"),(r===null||r==="unified")&&d.startsWith("@@ -"))return T2(i,c,d);if((r===null||r==="context")&&f&&d.startsWith("*** "))return F2(e,i,c,d);if((r===null||r==="normal")&&l&&(d.startsWith("< ")||d.startsWith("> ")))return{...i,type:"normal",start:c-1,hunkLine:c-1}}f=g,l=h}}function C2(e,t,n,r){if(!r&&e.startsWith("*** ")||e.startsWith("+++ "))return Qs(t,"old",e.slice(4),n);if(e.startsWith("Index:"))return t.names.index=Fp(e.slice(6),n,!1).name,"index";if(e.startsWith("Prereq:"))return"prereq";if(e.startsWith("diff --git ")){let i=Ap(e.slice(11),n),s=i.name===null?null:Ap(i.rest,n);return t.names.old=s&&s.rest.trim()===""?i.name:null,t.names.new=t.names.old===null?null:s.name,t.git=!0,t.stamps.old=t.stamps.new=-1,"git"}if(t.git){let i=I2(e,t);if(i)return i}let o=e;for(;o.startsWith("- ");)o=o.slice(2);return o.startsWith("--- ")?Qs(t,"new",o.slice(4),n):null}function I2(e,t){if(e.startsWith("index ")){let n=Np.exec(e.slice(6)),r=n?e.slice(6+n[0].length):"",o=r.startsWith("..")?Np.exec(r.slice(2)):null;return o?(t.says[0]=/^0+$/u.test(n[0])?2:0,t.says[1]=/^0+$/u.test(o[0])?2:0,t.extended=!0,"index"):null}return e.startsWith("old mode ")||e.startsWith("new mode ")?(t.extended=!0,"mode"):e.startsWith("deleted file mode ")?(t.says[1]=2,t.extended=!0,"mode"):e.startsWith("new file mode ")?(t.says[0]=2,t.extended=!0,"mode"):e.startsWith("rename from ")?(t.rename[0]=!0,t.extended=!0,"rename"):e.startsWith("rename to ")?(t.rename[1]=!0,t.extended=!0,"rename"):e.startsWith("copy from ")?(t.copy[0]=!0,t.extended=!0,"copy"):e.startsWith("copy to ")?(t.copy[1]=!0,t.extended=!0,"copy"):e.startsWith("GIT binary patch")?"binary":null}function Qs(e,t,n,r){let o=Fp(n,r,!0);return o.stamp!==void 0&&(e.stamps[t]=o.stamp),o.name!==void 0&&(e.names[t]=o.name,e.timestrs[t]=o.timestr),"name"}function T2(e,t,n){let r={names:{...e.names,old:e.names.new,new:e.names.old},stamps:{old:e.stamps.new,new:e.stamps.old},timestrs:{old:e.timestrs.new,new:e.timestrs.old}},o=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))?/u.exec(n),i=[...e.says];return o&&o[1]==="0"&&(i[0]=1+(r.stamps.old===0?1:0)),o&&o[3]==="0"&&(i[1]=1+(r.stamps.new===0?1:0)),{...e,...r,says:i,type:"unified",start:t,hunkLine:t}}function F2(e,t,n,r){let o=[...t.says];/^\*\*\* 0(?!\d)/u.test(r)&&(o[0]=1+(t.stamps.old===0?1:0));let i={...e,pos:n-1};try{let s=Js(i);s&&s.newLines.length===0&&s.newStart===1&&(o[1]=1+(t.stamps.new===0?1:0))}catch{}return{...t,says:o,type:"context",start:n-1,hunkLine:n-1}}function Tp(e,t){return t==="unified"?Sp(e):t==="context"?Js(e):Ep(e)}function Fp(e,t,n){let r=e.replace(/^[ \t\n\v\f\r]+/u,""),o,i;if(r.startsWith('"')){let a=_p(r);if(!a)return{};o=a.value,i=a.rest}else{let a=0;for(;a<r.length;a++){if(!/[ \t\n\v\f\r]/u.test(r[a]))continue;let l=a;for(;r[l]!==" "&&/[ \t\n\v\f\r]/u.test(r[l+1]??"");)l++;if(!(r[l]!==" "&&r.indexOf(n?" ":`
|
|
150
|
+
`,l+1)!==-1))break}o=r.slice(0,a),i=r.slice(a)}if(o==="/dev/null")return{stamp:0};let s=Lp(o,t);if(s===null)return{};let u=i.replace(/\r?\n$/u,"");return{name:s,timestr:u,stamp:n&&u!==""?L2(u):-1}}function L2(e){let t=/^\s*(\d{4})-(\d\d)-(\d\d)[ T](\d\d):(\d\d):(\d\d)(?:\.\d+)?\s*(?:([+-])(\d\d):?(\d\d))?/u.exec(e),n;if(t){let[,r,o,i,s,u,a,l,f,c]=t;n=Date.UTC(Number(r),Number(o)-1,Number(i),Number(s),Number(u),Number(a))/1e3,l&&(n-=(l==="-"?-1:1)*(Number(f)*3600+Number(c)*60))}else{let r=/^\s*[A-Z][a-z]{2} ([A-Z][a-z]{2}) +(\d+) (\d\d):(\d\d):(\d\d) (\d{4})/u.exec(e);if(!r)return-1;let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],[,i,s,u,a,l,f]=r;n=Date.UTC(Number(f),o.indexOf(i),Number(s),Number(u),Number(a),Number(l))/1e3}return n>-25*3600&&n<26*3600?0:n}function Lp(e,t){let n=t,r=0;for(let o=0;o<e.length;o++)if(e[o]==="/"){for(;e[o+1]==="/";)o++;(t<0||--n>=0)&&(r=o+1)}return(t<0||n<=0)&&r<e.length?e.slice(r):null}function Ap(e,t){let n=e.replace(/^[ \t\n\v\f\r]+/u,""),r,o;if(n.startsWith('"')){let i=_p(n);if(!i)return{name:null,rest:""};r=i.value,o=i.rest}else{let i=n.search(/[ \t\n\v\f\r]/u);r=i<0?n:n.slice(0,i),o=i<0?"":n.slice(i)}return{name:Lp(r,t),rest:o}}var Op={a:"\x07",b:"\b",f:"\f",n:`
|
|
151
|
+
`,r:"\r",t:" ",v:"\v","\\":"\\",'"':'"'};function _p(e){let t="";for(let n=1;n<e.length;n++){let r=e[n];if(r==='"')return{value:t,rest:e.slice(n+1)};if(r!=="\\"){t+=r;continue}let o=e[++n];if(o===void 0)return null;if(/[0-7]/u.test(o)){let i=/^[0-7]{1,3}/u.exec(e.slice(n))[0];t+=String.fromCodePoint(Number.parseInt(i,8)),n+=i.length-1}else if(o in Op)t+=Op[o];else return null}return null}function Rp(e,t){let n=i=>i.split("/").length-1,r=i=>i.slice(i.lastIndexOf("/")+1).length,o=-1;for(let i=0;i<e.length;i++){let s=e[i];if(s===null||t[i])continue;if(o===-1){o=i;continue}let[u,a]=[n(s),n(e[o])];if(u!==a){u<a&&(o=i);continue}let[l,f]=[r(s),r(e[o])];if(l!==f){l<f&&(o=i);continue}s.length<e[o].length&&(o=i)}return o}function eu(e,t){let{opts:n}=e;return(n.noReverse||!(n.force&&n.silent))&&e.say(t),n.noReverse?(e.say(` Skipping patch.
|
|
152
152
|
`),e.skipRest=!0,!1):n.force?(n.silent||e.say(` Applying it anyway.
|
|
153
153
|
`),!1):n.batch?(e.say(e.reverse?` Ignoring -R.
|
|
154
154
|
`:` Assuming -R.
|
|
@@ -156,23 +156,23 @@ diff: Try 'diff --help' for more information.`,2);function m2(e){let t=[];for(le
|
|
|
156
156
|
`:` Assume -R? [n]
|
|
157
157
|
`),e.say(`Apply anyway? [n]
|
|
158
158
|
`),n.silent||e.say(`Skipping patch.
|
|
159
|
-
`),e.skipRest=!0,!1)}function
|
|
160
|
-
which ${l}!`)&&(e.reverse=!e.reverse)}return u}function
|
|
161
|
-
`),e.skipRest=!0),i===-1){if(n===null)return null;let u=r(n);return(!u.exists||!u.isDir)&&
|
|
159
|
+
`),e.skipRest=!0,!1)}function Mp(e,t,n,r,o){let i=e.reverse?1:0,s=t.says,u=(o?0:1)<s[i^(o?1:0)];if(o&&s[i^(r?1:0)]===1&&s[1-i^(r?1:0)]===2)return!1;if(u){let a=r?"delete":o?"empty out":"create",l=r?"does not exist":o?"is already empty":"already exists";eu(e,`The next patch${e.reverse?", when reversed,":""} would ${a} the file ${e.quote(n)},
|
|
160
|
+
which ${l}!`)&&(e.reverse=!e.reverse)}return u}function Pp(e,t,n,r){let o=[t.names.old,t.names.new,t.names.index];(o[0]!==null||o[1]!==null)&&o[2]!==null&&(o[2]=null);let i=-1;if(n===null){let u=o.map(f=>f===null?null:r(f)),a=u.map(f=>f===null||!f.exists);i=Rp(o,a);let l=o.findIndex(f=>f!==null);if(l!==-1&&(i===-1||!u[i].isDir)){let f=i===-1;Mp(e,t,o[f?l:i],f,f||u[i].size===0)&&f&&(i=l)}i===-1&&t.says[e.reverse?1:0]&&(i=Rp(o,o.map(()=>!1)))}if((t.rename[0]||t.rename[1]||t.copy[0]||t.copy[1])&&n===null&&!((i===0||i===1)&&o[0]!==null&&o[1]!==null)&&(e.say(`Cannot ${t.rename[0]||t.rename[1]?"rename":"copy"} file without two valid file names
|
|
161
|
+
`),e.skipRest=!0),i===-1){if(n===null)return null;let u=r(n);return(!u.exists||!u.isDir)&&Mp(e,t,n,!u.exists,!u.exists||u.size===0),n}return o[i]}function Bp(e){return{input:e,frozen:0,inOffset:0,outOffset:0,out:[]}}var _2=(e,t)=>t<1||t>e.input.length?"":e.input[t-1];function R2(e,t){let n=r=>r.replace(/\n$/u,"").replace(/[ \t]+$/u,"").replace(/[ \t]+/gu," ");return n(e)===n(t)}function No(e,t,n,r,o,i,s){let u=t.oldLines,a=u.length-i;for(let l=n+r+o,f=o;f<a;f++,l++){let c=_2(e,l),d=u[f].text;if(s?!R2(c,d):c!==d)return!1}return!0}function Dp(e,t,n,r){let o=t.oldStart+e.inOffset,i=t.oldLines.length,s=Math.max(t.prefix,t.suffix),u=n+t.prefix-s,a=n+t.suffix-s,l=e.input.length,f=l-(i-a)+1,c=e.frozen+1,d=f-o,p=o-c,h=Math.max(d,p);if(!i)return o;o<=p&&(p=o-1);let m=w=>(e.inOffset+=w,o+w);if(u<0&&t.oldStart<=1){if(a<0&&(i!==l||t.prefix<e.frozen))return 0;let w=1-o;return e.frozen<=t.prefix&&w<=d&&No(e,t,o,w,0,a,r)?m(w):0}else u<0&&(u=0);if(a<0){let w=o-(l-i+1);return w<=p&&No(e,t,o,-w,u,0,r)?m(-w):0}let g=d<0?o-f:p<0?o-c:0;for(let w=g;w<=h;w++){if(w<=d&&No(e,t,o,w,u,a,r))return m(w);if(w<=p&&No(e,t,o,-w,u,a,r))return m(-w)}return 0}function Ao(e,t){if(e.frozen>t)return!1;for(;e.frozen<t;)e.frozen<e.input.length&&e.out.push(e.input[e.frozen]),e.frozen++;return!0}function M2(e,t,n){let r=n-1,o=t.newLines,i=t.oldLines,s=0,u=0,a=()=>{throw new Q(`Out-of-sync patch, lines ${t.line+1+u+1},${t.line+1+i.length+s+1} -- mangled text or line numbers, maybe?`)};for(;u<i.length;)if(i[u].tag==="-"){if(!Ao(e,r+u))return!1;e.frozen++,u++}else{if(s>=o.length)break;if(o[s].tag==="+"){if(!Ao(e,r+u))return!1;e.out.push(o[s++].text)}else o[s].tag===i[u].tag?(u++,s++):a()}for(;s<o.length&&o[s].tag==="+";s++){if(!Ao(e,r+u))return!1;e.out.push(o[s].text)}return e.outOffset+=o.length-i.length,!0}var Up=e=>e.frozen>=e.input.length||Ao(e,e.input.length),jp=e=>e.map((t,n)=>n<e.length-1&&!t.endsWith(`
|
|
162
162
|
`)?t+`
|
|
163
|
-
`:t).join("");function
|
|
163
|
+
`:t).join("");function Wp(e,t,n,r,o){let{opts:i}=e,s={count:0,failed:0,mismatch:!1,applyAnyway:!1};for(let u=n();u;u=n()){s.count++;let a=e.skipRest?{hunk:e.reverse?$o(u):u,where:0,fuzz:0}:P2(e,r,e.reverse?$o(u):u,s),{hunk:l,where:f,fuzz:c}=a,d=(f||l.oldStart)+r.outOffset,p=f===1&&t.says[e.reverse?1:0]===2&&r.input.length>0;if(e.skipRest||p||!f||!M2(r,l,f))e.skipRejectFile||o.add(l,s.failed===0,r.outOffset,e.reverse),s.failed++,!e.skipRest&&!i.silent&&e.say(`Hunk #${s.count} FAILED at ${d}.
|
|
164
164
|
`);else if(!i.silent&&(c||r.inOffset)){let h=r.inOffset?` (offset ${r.inOffset} line${r.inOffset===1?"":"s"})`:"";e.say(`Hunk #${s.count} succeeded at ${d}${c?` with fuzz ${c}`:""}${h}.
|
|
165
|
-
`)}}return s}function P2(e,t,n,r){let{opts:o}=e,i=0,s=n,u=0,a=Math.min(o.fuzz,Math.max(s.prefix,s.suffix));do if(u=
|
|
165
|
+
`)}}return s}function P2(e,t,n,r){let{opts:o}=e,i=0,s=n,u=0,a=Math.min(o.fuzz,Math.max(s.prefix,s.suffix));do if(u=Dp(t,s,i,o.loose),(!u||i||t.inOffset)&&(r.mismatch=!0),r.count===1&&!u&&!(o.force||r.applyAnyway)&&e.reverse===e.reverseFlag){let l=$o(s);u=Dp(t,l,i,o.loose),u&&eu(e,`${e.reverse?"Unreversed":"Reversed (or previously applied)"} patch detected!`)?(e.reverse=!e.reverse,s=l):u&&(r.applyAnyway=!0,i--,u=0)}while(!e.skipRest&&!u&&++i<=a);return{hunk:s,where:u,fuzz:i}}var ar=(e,t)=>e+t;function Hp(e,t){let n="",r=(i,s)=>`${i} ${e.names[s]??"/dev/null"}${e.timestrs[s]??""}
|
|
166
166
|
`,o=e.names.index===null?"":`Index: ${e.names.index}
|
|
167
|
-
`;return{get text(){return n},add(i,s,u,a){let l=a?["new","old"]:["old","new"];t==="unified"?(s&&(n+=o+r("---",l[0])+r("+++",l[1])),n+=D2(i,u)):(s&&(n+=o+r("***",l[0])+r("---",l[1])),n+=B2(i,u,t))}}}var
|
|
168
|
-
`,i=0,s=0;for(;;s++,i++){for(;s<r.length&&r[s].tag==="-";s++)o+=ar("-",r[s].text);for(;i<n.length&&n[i].tag==="+";i++)o+=ar("+",n[i].text);if(s>=r.length)break;o+=ar(" ",r[s].text)}return o}function
|
|
169
|
-
`;return i+=`*** ${
|
|
170
|
-
`,e.oldLines.forEach((s,u)=>{i+=ar(o.old[u]+" ",s.text)}),i+=`--- ${
|
|
171
|
-
`,e.newLines.forEach((s,u)=>{i+=ar(o.new[u]+" ",s.text)}),i}var U2=e=>({old:e.oldLines.map(t=>t.tag),new:e.newLines.map(t=>t.tag)});function j2(e){let t=e.newLines.map(i=>i.tag),n=e.oldLines.map(i=>i.tag),r=0,o=0;for(;o<n.length;)if(n[o]==="-")if(r<t.length&&t[r]==="+"){do n[o++]="!";while(o<n.length&&n[o]==="-");do t[r++]="!";while(r<t.length&&t[r]==="+")}else do o++;while(o<n.length&&n[o]==="-");else if(r<t.length&&t[r]==="+")do r++;while(r<t.length&&t[r]==="+");else o++,r++;return{old:n,new:t}}var W2=["R","N","f","t","s","b","l","E","T","Z","e","u","c","n","v"],q2=["reverse","forward","force","batch","silent","quiet","backup","ignore-whitespace","remove-empty-files","dry-run","verbose","unified","context","normal","ed","binary","no-backup-if-mismatch","backup-if-mismatch","posix","follow-symlinks","help","version","set-time","set-utc"],z2=["p","i","o","d","r","F","z","B","Y","V","g","D","x"],H2=["strip","input","output","directory","reject-file","fuzz","suffix","prefix","basename-prefix","version-control","get","reject-format","quoting-style","read-only","merge","debug"],
|
|
172
|
-
patch: Try 'patch --help' for more information.`,2);function
|
|
167
|
+
`;return{get text(){return n},add(i,s,u,a){let l=a?["new","old"]:["old","new"];t==="unified"?(s&&(n+=o+r("---",l[0])+r("+++",l[1])),n+=D2(i,u)):(s&&(n+=o+r("***",l[0])+r("---",l[1])),n+=B2(i,u,t))}}}var qp=(e,t)=>t===0?`${e-1},0`:t===1?`${e}`:`${e},${t}`;function D2(e,t){let n=e.newLines,r=e.oldLines,o=`@@ -${qp(e.oldStart+t,r.length)} +${qp(e.newStart+t,n.length)} @@${e.fn??""}
|
|
168
|
+
`,i=0,s=0;for(;;s++,i++){for(;s<r.length&&r[s].tag==="-";s++)o+=ar("-",r[s].text);for(;i<n.length&&n[i].tag==="+";i++)o+=ar("+",n[i].text);if(s>=r.length)break;o+=ar(" ",r[s].text)}return o}function zp(e,t){let n=e+t-1;return n<e?"0":n===e?`${e}`:`${e},${n}`}function B2(e,t,n){let r=n!=="normal",o=e.marks??(n==="normal"?U2(e):j2(e)),i=`***************${e.fn??""}
|
|
169
|
+
`;return i+=`*** ${zp(e.oldStart+t,e.oldLines.length)}${r?" ****":""}
|
|
170
|
+
`,e.oldLines.forEach((s,u)=>{i+=ar(o.old[u]+" ",s.text)}),i+=`--- ${zp(e.newStart+t,e.newLines.length)}${r?" ----":" -----"}
|
|
171
|
+
`,e.newLines.forEach((s,u)=>{i+=ar(o.new[u]+" ",s.text)}),i}var U2=e=>({old:e.oldLines.map(t=>t.tag),new:e.newLines.map(t=>t.tag)});function j2(e){let t=e.newLines.map(i=>i.tag),n=e.oldLines.map(i=>i.tag),r=0,o=0;for(;o<n.length;)if(n[o]==="-")if(r<t.length&&t[r]==="+"){do n[o++]="!";while(o<n.length&&n[o]==="-");do t[r++]="!";while(r<t.length&&t[r]==="+")}else do o++;while(o<n.length&&n[o]==="-");else if(r<t.length&&t[r]==="+")do r++;while(r<t.length&&t[r]==="+");else o++,r++;return{old:n,new:t}}var W2=["R","N","f","t","s","b","l","E","T","Z","e","u","c","n","v"],q2=["reverse","forward","force","batch","silent","quiet","backup","ignore-whitespace","remove-empty-files","dry-run","verbose","unified","context","normal","ed","binary","no-backup-if-mismatch","backup-if-mismatch","posix","follow-symlinks","help","version","set-time","set-utc"],z2=["p","i","o","d","r","F","z","B","Y","V","g","D","x"],H2=["strip","input","output","directory","reject-file","fuzz","suffix","prefix","basename-prefix","version-control","get","reject-format","quoting-style","read-only","merge","debug"],Gp=new Map([["T","setting file times"],["Z","setting file times"],["set-time","setting file times"],["set-utc","setting file times"],["e","ed scripts"],["ed","ed scripts"],["v","a version banner"],["version","a version banner"],["help","a help text"],["verbose","verbose output"],["B","backup prefixes"],["prefix","backup prefixes"],["Y","backup prefixes"],["basename-prefix","backup prefixes"],["V","numbered backups"],["version-control","numbered backups"],["g","version control"],["get","version control"],["D","merged #ifdef output"],["x","debugging output"],["debug","debugging output"],["posix","POSIX mode"],["follow-symlinks","symbolic links"],["quoting-style","quoting styles"],["read-only","read-only handling"],["merge","merging"]]),Xp=e=>x(`patch: ${e}
|
|
172
|
+
patch: Try 'patch --help' for more information.`,2);function Yp(e){for(let r of e){if(r==="--")break;let o=r.replace(/=.*/u,"");if(o==="--merge"||o==="--read-only")return{refused:v("option","patch",o,`patch: ${o}: ${Gp.get(o.slice(2))} is not supported`,2)}}let t;try{t=N(e,{short:W2,long:q2,valueShort:z2,valueLong:H2})}catch(r){let o=O(r);return o?{refused:v(o.kind,"patch",o.detail,`patch: ${r.message}`,2)}:{error:Xp(r.message)}}let n={strip:-1,input:null,output:null,directory:null,rejectFile:null,fuzz:2,suffix:".orig",format:null,rejectFormat:null,reverse:!1,noReverse:!1,force:!1,batch:!1,silent:!1,backup:!1,backupIfMismatch:!0,loose:!1,removeEmpty:!1,dryRun:!1};for(let{name:r,value:o}of t.order){let i=(r.length===1?"-":"--")+r,s=Gp.get(r);if(s)return{refused:v("option","patch",i,`patch: ${i}: ${s} is not supported`,2)};let u=G2(n,r,o);if(u)return{error:u}}return t.positional.length>2?{error:Xp(`${t.positional[2]}: extra operand`)}:{opts:n,operands:t.positional}}function Zp(e,t){if(!/^[+-]?\d+$/u.test(e))return{error:x(`patch: **** ${t} ${oe(e,{vars:new Map})} is not a number`,2)};let n=Number(e);return n<0?{error:x(`patch: **** ${t} ${e} is negative`,2)}:{value:Math.min(n,Number.MAX_SAFE_INTEGER)}}function G2(e,t,n){switch(t){case"p":case"strip":{let r=Zp(n,"strip count");return r.error?r.error:(e.strip=r.value,null)}case"F":case"fuzz":{let r=Zp(n,"fuzz factor");return r.error?r.error:(e.fuzz=r.value,null)}case"i":case"input":return e.input=n,null;case"o":case"output":return e.output=n,null;case"d":case"directory":return e.directory=n,null;case"r":case"reject-file":return e.rejectFile=n,null;case"z":case"suffix":return n===""?x("patch: **** backup suffix is empty",2):(e.suffix=n,null);case"R":case"reverse":return e.reverse=!0,null;case"N":case"forward":return e.noReverse=!0,null;case"f":case"force":return e.force=!0,null;case"t":case"batch":return e.batch=!0,null;case"s":case"silent":case"quiet":return e.silent=!0,null;case"b":case"backup":return e.backup=!0,null;case"l":case"ignore-whitespace":return e.loose=!0,null;case"E":case"remove-empty-files":return e.removeEmpty=!0,null;case"dry-run":return e.dryRun=!0,null;case"u":case"unified":return e.format="unified",null;case"c":case"context":return e.format="context",null;case"n":case"normal":return e.format="normal",null;case"no-backup-if-mismatch":return e.backupIfMismatch=!1,null;case"backup-if-mismatch":return e.backupIfMismatch=!0,null;case"reject-format":return n!=="unified"&&n!=="context"?x(`patch: **** unknown reject format ${n}`,2):(e.rejectFormat=n,null);default:return null}}function Kp(e,t,n){let r=Yp(t);if(r.error)return r.error;if(r.refused)return r.refused;let{opts:o,operands:i}=r,s={ctx:n,opts:o,dir:n.cwd,events:[],stdout:"",stderr:"",skipRest:!1,skipRejectFile:!1,reverse:o.reverse,reverseFlag:o.reverse,someFailed:!1,rejectsMade:new Set,output:""},u=o.output==="-"?2:1;s.quote=a=>oe(a,n),s.say=a=>{u===1?s.stdout+=a:s.stderr+=a,s.events.push({fd:u,text:a})};try{if(o.directory!==null){let l=E(n.cwd,o.directory,n.fs);if(l.error||!n.fs.isDir(l.path))throw new Q(`Can't change to directory ${oe(o.directory,n)} : ${l.error??"Not a directory"}`);s.dir=l.path}let a=X2(s,e,o.input??i[1]??null);Z2(s,Cp(a),i[0]??null),o.output!==null&&o.output!=="-"&&Co(s,o.output,s.output,!1)}catch(a){if(!(a instanceof Q)){let f=O(a);if(!f)throw a;let c=`patch: ${a.message}`,d={stdout:s.stdout,stderr:s.stderr+c+`
|
|
173
173
|
`,events:[...s.events,{fd:2,text:c+`
|
|
174
174
|
`}],exitCode:2};return ie(d,f.kind,"patch",f.detail,c)}let l=`patch: **** ${a.message}
|
|
175
|
-
`;return{stdout:s.stdout,stderr:s.stderr+l,events:[...s.events,{fd:2,text:l}],exitCode:2}}return{stdout:s.stdout,stderr:s.stderr,events:s.events,exitCode:s.someFailed?1:0}}function X2(e,t,n){if(n===null)return q(e.ctx),t;if(n==="-")return q(e.ctx),t;let r=P(e.ctx,"patch",n);if(r.error||e.ctx.fs.isDir(r.path))throw new Q(`Can't open patch file ${oe(n,e.ctx)} : ${r.error??"Is a directory"}`);return e.ctx.fs.readFile(r.path)}function Z2(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let o=
|
|
175
|
+
`;return{stdout:s.stdout,stderr:s.stderr+l,events:[...s.events,{fd:2,text:l}],exitCode:2}}return{stdout:s.stdout,stderr:s.stderr,events:s.events,exitCode:s.someFailed?1:0}}function X2(e,t,n){if(n===null)return q(e.ctx),t;if(n==="-")return q(e.ctx),t;let r=P(e.ctx,"patch",n);if(r.error||e.ctx.fs.isDir(r.path))throw new Q(`Can't open patch file ${oe(n,e.ctx)} : ${r.error??"Is a directory"}`);return e.ctx.fs.readFile(r.path)}function Z2(e,t,n){let{opts:r}=e;for(;;){if(t.base!==0&&t.base>=t.lines.length)return;let o=Ip(t,{needHeader:n===null,strip:r.strip,format:r.format});if(o===null){if(t.base===0&&!t.empty)throw new Q("Only garbage was found in the patch input.");return}e.skipRest=!1,e.skipRejectFile=!1,e.reverse=e.reverseFlag;let i=Pp(e,o,n,s=>Io(e,s));i===null&&(i=Y2(e,t,o)),e.skipRest&&(e.someFailed=!0),t.pos=o.start,V2(e,t,o,i),t.base=t.pos}}function Y2(e,t,n){let{opts:r}=e;if(r.silent||(e.say(`can't find file to patch at input line ${n.hunkLine+1}
|
|
176
176
|
`),n.type!=="normal"&&e.say(r.strip===-1?`Perhaps you should have used the -p or --strip option?
|
|
177
177
|
`:`Perhaps you used the wrong -p or --strip option?
|
|
178
178
|
`)),t.base<n.start){e.say(`The text leading up to this was:
|
|
@@ -182,18 +182,18 @@ patch: Try 'patch --help' for more information.`,2);function Vp(e){for(let r of
|
|
|
182
182
|
`):(e.say(`File to patch:
|
|
183
183
|
`),e.say(`Skip this patch? [y]
|
|
184
184
|
`),r.silent||e.say(`Skipping patch.
|
|
185
|
-
`)),e.skipRest=!0,null}function V2(e,t,n,r){let{opts:o}=e,i=n.copy[0]||n.copy[1]||n.rename[0]||n.rename[1],s=null;e.skipRest||(s=o.output??(i?n.names[e.reverse?"old":"new"]:r));let u={exists:!1,isDir:!1,content:""};e.skipRest||(u=
|
|
186
|
-
`),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!o.dryRun&&o.output===null&&(lr(e,s),i&&r!==s&&lr(e,r));let a=
|
|
187
|
-
`)}let l=
|
|
185
|
+
`)),e.skipRest=!0,null}function V2(e,t,n,r){let{opts:o}=e,i=n.copy[0]||n.copy[1]||n.rename[0]||n.rename[1],s=null;e.skipRest||(s=o.output??(i?n.names[e.reverse?"old":"new"]:r));let u={exists:!1,isDir:!1,content:""};e.skipRest||(u=Io(e,r),(u.isDir||u.link)&&(e.say(`File ${oe(r,e.ctx)} is not a regular file -- refusing to patch
|
|
186
|
+
`),e.skipRest=!0,e.someFailed=!0)),!e.skipRest&&!o.dryRun&&o.output===null&&(lr(e,s),i&&r!==s&&lr(e,r));let a=Bp(Ge(u.exists?u.content:""));if(!e.skipRest&&!o.silent){let p=r!==s,h=!p&&(n.rename[0]||n.rename[1]),m=n.copy[0]||n.copy[1]?"copied":n.rename[0]||n.rename[1]?"renamed":"read",g=h?n.names[r===n.names.old?"new":"old"]:r,w=p||h?` (${h?"already ":""}${m} from ${g})`:"";e.say(`${o.dryRun?"checking":"patching"} file ${oe(s,e.ctx)}${w}
|
|
187
|
+
`)}let l=Hp(n,o.rejectFormat??n.type),c=Wp(e,n,()=>n.empty?null:Tp(t,n.type),a,l);!e.skipRest&&!Up(a)&&(e.say(`misordered hunks! output would be garbled
|
|
188
188
|
Skipping patch.
|
|
189
|
-
`),e.skipRest=!0);let d=
|
|
190
|
-
`)),!r.dryRun){if(a.failed<a.count||f)
|
|
189
|
+
`),e.skipRest=!0);let d=jp(a.out);o.output!==null&&!e.skipRest&&(o.output==="-"?(e.stdout+=d,e.events.push({fd:1,text:d})):e.output+=d),!e.skipRest&&o.output===null&&K2(e,n,{inname:r,outname:s,input:u,content:d,result:c,empty:a.out.length===0,renaming:i}),c.failed&&!e.skipRejectFile&&J2(e,s,c,l.text)}function K2(e,t,n){let{opts:r}=e,{inname:o,outname:i,input:s,content:u,result:a,empty:l,renaming:f}=n,c=r.backup||r.backupIfMismatch&&(a.mismatch||a.failed>0),d=t.says[e.reverse?0:1]===2;if(l&&(r.removeEmpty||d)){r.dryRun||Vp(e,i,c);return}if(!l&&d&&(e.someFailed=!0,r.silent||e.say(`Not deleting file ${oe(i,e.ctx)} as content differs from patch
|
|
190
|
+
`)),!r.dryRun){if(a.failed<a.count||f)Co(e,i,u,c),f&&o!==i&&(t.rename[0]||t.rename[1])&&Vp(e,o,!1);else if(c){if(!s.exists)throw new Q(`Can't reopen file ${oe(i,e.ctx)} : No such file or directory`);Co(e,Oo(e,i),s.content,!1)}}}function J2(e,t,n,r){let{opts:o}=e;if(e.someFailed=!0,e.say(`${n.failed} out of ${n.count} hunk${n.count===1?"":"s"} ${e.skipRest?"ignored":"FAILED"}`),t===null||o.rejectFile==="-"){e.say(`
|
|
191
191
|
`);return}let i=o.rejectFile??t+".rej";if(o.dryRun){e.say(`
|
|
192
192
|
`);return}e.say(` -- saving rejects to file ${oe(i,e.ctx)}
|
|
193
|
-
`),lr(e,i);let s=e.rejectsMade.has(Z(e.dir,i));e.rejectsMade.add(Z(e.dir,i));let u=s?
|
|
193
|
+
`),lr(e,i);let s=e.rejectsMade.has(Z(e.dir,i));e.rejectsMade.add(Z(e.dir,i));let u=s?Io(e,i).content:"";Co(e,i,u+r,!1)}var Oo=(e,t)=>t+e.opts.suffix;function Io(e,t){let n=E(e.dir,t,e.ctx.fs,{follow:!1}),r=!n.error&&e.ctx.fs.isLink?.(n.path)===!0,o=E(e.dir,t,e.ctx.fs);if(o.error)return{exists:!1,isDir:!1,link:r,size:0,content:""};if(e.ctx.fs.isDir(o.path))return{exists:!0,isDir:!0,link:r,size:0,content:""};let i=e.ctx.fs.readFile(o.path);return{exists:!0,isDir:!1,link:r,size:i.length,content:i}}function lr(e,t){let n=se(e.ctx.fs,e.dir,t,!1);if(!(e.ctx.writable&&n.startsWith("/tmp/")))throw new y("feature","read-only target",`${t}: file system is read-only`)}function Co(e,t,n,r){let{ctx:o}=e;lr(e,t);let i=E(e.dir,t,o.fs);try{if(!i.error){o.fs.replaceWritable(e.dir,t,n,r?Oo(e,t):void 0);return}r&&o.fs.openWritable(e.dir,Oo(e,t)),o.fs.openWritable(e.dir,t).write(n)}catch(s){throw new Q(`Can't create file ${oe(t,e.ctx)} : ${s?.fsError??s.message}`)}}function Vp(e,t,n){let{ctx:r}=e;lr(e,t);let o=Io(e,t);o.exists&&(n&&r.fs.openWritable(e.dir,Oo(e,t)).write(o.content),r.fs.removeWritable(e.dir,t))}var Jp={du:Od,stat:Xd,realpath:Bc,diff:xp,patch:Kp};function Q2(e,t,n){return N(t),F(n.cwd+`
|
|
194
194
|
`)}function ek(e,t,n){let{positional:r}=N(t);if(r.length>1)return x("cd: too many arguments");if(!r.length&&n.vars.unsetNames.has("HOME"))return x("cd: HOME not set");let o=r[0]??ln(n);if(o==="-"){if(!n.vars.has("OLDPWD"))return x("cd: OLDPWD not set");o=n.vars.get("OLDPWD")}let i=r[0]==="-"?o+`
|
|
195
|
-
`:"";if(o==="")return F(i);let{path:s,error:u}=P(n,"cd",o);return u?x(`cd: ${o}: ${u}`):n.fs.isDir(s)?s!==Z(n.cwd,o)?v("feature","cd","symbolic link cwd",`cd: ${o}: a working directory reached through a symbolic link is not supported (it leads to ${s})`):(n.vars.set("OLDPWD",n.cwd),n.vars.set("PWD",s),n.cwd=s,F(i)):x(`cd: ${o}: Not a directory`)}var tk={dir:"/",link:"@",file:""};function nk(e,t,n){let{flags:r,positional:o}=N(t,{short:["1","l","a","A","R","d","r","F","h"]}),i=r.has("l")?ed(n,r.has("h")):null,s=(o.length?o:["."]).toSorted(j);r.has("r")&&s.reverse();let u=[],a=[],l=[],f=Jt(),c=r.has("a")||r.has("A"),d=
|
|
196
|
-
`)]:[];for(let
|
|
195
|
+
`:"";if(o==="")return F(i);let{path:s,error:u}=P(n,"cd",o);return u?x(`cd: ${o}: ${u}`):n.fs.isDir(s)?s!==Z(n.cwd,o)?v("feature","cd","symbolic link cwd",`cd: ${o}: a working directory reached through a symbolic link is not supported (it leads to ${s})`):(n.vars.set("OLDPWD",n.cwd),n.vars.set("PWD",s),n.cwd=s,F(i)):x(`cd: ${o}: Not a directory`)}var tk={dir:"/",link:"@",file:""};function nk(e,t,n){let{flags:r,positional:o}=N(t,{short:["1","l","a","A","R","d","r","F","h"]}),i=r.has("l")?ed(n,r.has("h")):null,s=(o.length?o:["."]).toSorted(j);r.has("r")&&s.reverse();let u=[],a=[],l=[],f=Jt(),c=r.has("a")||r.has("A"),d=b=>n.fs.isDir(b)?"dir":n.fs.isLink?.(b)?"link":"file",p=b=>r.has("F")?tk[b]:"",h=(b,k,S)=>({raw:b,abs:k,kind:S,name:S==="link"&&i?b:b+(b.endsWith("/")?"":p(S)),target:S==="link"?n.fs.readLink(k)+p(d(E(n.cwd,k,n.fs).path??"")):null}),m=(b,k)=>i?i.lines(b,k):b.map(S=>S.name),g=!(r.has("l")||r.has("F")||r.has("d"));for(let b of s){let{path:k,error:S}=P(n,"ls",b,{follow:!1}),I=S||!g||!n.fs.isLink?.(k)?k:E(n.cwd,b,n.fs).path;S?a.push(`ls: cannot access '${b}': ${S}`):r.has("d")||n.fs.isFile(k)||!n.fs.isDir(I)?l.push(h(b,k,d(k))):u.push({path:b,abs:I})}let w=l.length?[m(l,!1).join(`
|
|
196
|
+
`)]:[];for(let b of u){let k=[b];for(;k.length;){let{path:S,abs:I}=k.pop(),M=n.fs.listDir(I);c||f.collect(I,[...M.dirs,...M.files,...M.links]);let C=(D,de)=>D.filter(Xt=>c||!Xt.startsWith(".")).map(Xt=>h(Xt,Z(I,Xt),de)),H=[...C(M.dirs,"dir"),...C(M.files,"file"),...C(M.links,"link")];r.has("a")&&H.push(h(".",I,"dir"),h("..",Z(I,".."),"dir")),H.sort((D,de)=>j(D.raw,de.raw)),r.has("r")&&H.reverse();let Y=m(H,!0);if((s.length>1||r.has("R"))&&Y.unshift(S+":"),Y.length&&w.push(Y.join(`
|
|
197
197
|
`)),!!r.has("R"))for(let D of H.toReversed())D.raw==="."||D.raw===".."||!n.fs.isDir(D.abs)||k.push({path:S.endsWith("/")?S+D.raw:S+"/"+D.raw,abs:D.abs})}}return f.emit(n.notes,"ls","Hidden entries are included with -a."),{stdout:w.length?w.join(`
|
|
198
198
|
|
|
199
199
|
`)+`
|
|
@@ -202,72 +202,72 @@ Skipping patch.
|
|
|
202
202
|
`:"",exitCode:a.length?2:0}}function rk(e,t){let{positional:n}=N(t);if(n.length===0)return pe("basename PATH [SUFFIX]");if(n.length>2)return x(`basename: extra operand: ${n[2]}`);let r=n[0].replace(/\/+$/u,""),o=r===""?n[0]===""?"":"/":r.slice(r.lastIndexOf("/")+1);return F(ok(o,n[1])+`
|
|
203
203
|
`)}function ok(e,t){return!t||t===e||!e.endsWith(t)?e:e.slice(0,-t.length)}function ik(e,t){let{positional:n}=N(t);return n.length===0?pe("dirname PATH"):F(n.map(r=>{let o=r.replace(/\/+$/u,""),i=o.lastIndexOf("/");return i<0?r.startsWith("/")?"/":".":o.slice(0,i).replace(/\/+$/u,"")||"/"}).join(`
|
|
204
204
|
`)+`
|
|
205
|
-
`)}var
|
|
206
|
-
`;continue}let w=c?a:d?n.stdinOrigin:n.fs.readFile(p);if(o&&w!=="")throw new
|
|
207
|
-
`),f=l?a.slice(0,-1):a,c=(t.has("b")?f!=="":t.has("n"))?`${String(++s).padStart(6)} `:"";return o?f=[...A(f)].map(d=>
|
|
205
|
+
`)}var Qp={pwd:Q2,cd:ek,ls:nk,find:id,tree:td,basename:rk,dirname:ik,...Jp};function r1(e,t,n){let{flags:r,positional:o}=N(t,{short:["n","b","s","v","E","T","A","e","t"]}),i=u=>ak(u,r),s=sk(o,e,n,i,r.size!==0);if(s.bytes===void 0)return ne(i(s.content),s);if(r.size)throw new y("feature","binary file","cat: formatting bytes that spell no text is not supported");return{stdout:"",stderr:s.stderr,exitCode:s.failed?1:0,events:[{fd:1,bytes:s.bytes},...s.stderr?[{fd:2,text:s.stderr}]:[]]}}function e1(e,t,n){let r=te("cat",e,t,n,{read:"maybe-text"});return{parts:r.inputs.map(o=>o.content??o.bytes),stderr:r.stderr,failed:r.failed}}var t1=e=>e.every(t=>typeof t=="string")?{content:e.join("")}:{bytes:vn([...e.map(t=>typeof t=="string"?B(t):t),new Uint8Array])};function sk(e,t,n,r,o){let i=n.outputFds[1];if(!i?.path&&!n.outputFds[2]?.path){let f=e1(e,t,n);return{...t1(f.parts),stderr:f.stderr,failed:f.failed}}let s=[],u="",a=t,l="";for(let f of e.length?e:["-"]){let c=f==="-",d=c||f==="/dev/stdin",p=d?n.stdinHandle?.path:E(n.cwd,f,n.fs).path,h=d?n.stdinHandle?.identity:n.fs.fileIdentity?.(p);if(l&&n1(p,h,n.outputFds[2]))throw new y("feature","cat input modified by diagnostics","cat: reading an input after writing diagnostics to the same file is not supported");if(n1(p,h,i)){if((c?A(n.stdinHandle.content).length-A(a).length:0)<i.position+uk(s,u,r)){l+=`cat: ${f}: input file is output file
|
|
206
|
+
`;continue}let w=c?a:d?n.stdinOrigin:n.fs.readFile(p);if(o&&w!=="")throw new y("feature","cat transforms its input file","cat: transforming an input file through its own output descriptor is not supported")}let m=e1([f],a,n);s.push(...m.parts),u+=m.parts.filter(g=>typeof g=="string").join(""),l+=m.stderr,(c||f==="/dev/stdin"&&!n.stdinFile)&&(a="")}return{...t1(s),stderr:l,failed:l!==""}}var uk=(e,t,n)=>e.every(r=>typeof r=="string")?A(n(t)).length:e.reduce((r,o)=>r+(typeof o=="string"?A(o).length:o.length),0);function n1(e,t,n){return!e||!n?.path?!1:t!==void 0&&n.identity!==void 0?t===n.identity:e===n.path}function ak(e,t){if(!t.size)return e;let n=t.has("E")||t.has("A")||t.has("e"),r=t.has("T")||t.has("A")||t.has("t"),o=t.has("v")||t.has("A")||t.has("e")||t.has("t"),i=t.has("s")?lk(e):e,s=0;return Ge(i).map(a=>{let l=a.endsWith(`
|
|
207
|
+
`),f=l?a.slice(0,-1):a,c=(t.has("b")?f!=="":t.has("n"))?`${String(++s).padStart(6)} `:"";return o?f=[...A(f)].map(d=>o1(d,r)).join(""):(r&&(f=f.replaceAll(" ","^I")),n&&l&&f.endsWith("\r")&&(f=f.slice(0,-1)+"^M")),c+f+(l?n?`$
|
|
208
208
|
`:`
|
|
209
|
-
`:"")}).join("")}function
|
|
210
|
-
`)}var
|
|
209
|
+
`:"")}).join("")}function o1(e,t){return e===9?t?"^I":" ":e>=128?"M-"+o1(e-128,!0):e<32?"^"+String.fromCodePoint(e+64):e===127?"^?":String.fromCodePoint(e)}function lk(e){return e.replace(/(^|\n)\n+/gu,`$1
|
|
210
|
+
`)}var To="sed: supported commands are p, P, n, N, d, D, a, i, c, g, G, h, H, x, w, q, =, y, :, b, t, T, { }, and s/regexp/replacement/[NgiIpw]",tu=1e6,Fo=16*1024*1024,i1=64*1024*1024;function Ee(e="script"){throw new y("feature",e,To)}function Lo(e){return e.gap?v("feature","sed",e.gap,`sed: ${e.message}`):e instanceof RangeError?v("feature","sed","regex runtime limit",`sed: ${e.message}`):K(e,"sed",`sed: ${e.message.replace(/^sed: /u,"")}`,e.exitCode)}function s1(e){let t=[],n=null;for(let r=0;r<e.length;r++){let o=e[r];if(o==="--"){t.push(...e.slice(r));break}if(o==="--in-place"||o.startsWith("--in-place=")){n=o==="--in-place"?"":o.slice(11);continue}if(o.startsWith("--")||!o.startsWith("-")){t.push(o),(o==="--expression"||o==="--file")&&r+1<e.length&&t.push(e[++r]);continue}let i=o;for(let s=1;s<o.length;s++){let u=o[s];if(u==="i"){n=o.slice(s+1),i=o.slice(0,s);break}if(u==="e"||u==="f"){t.push(o),s+1===o.length&&r+1<e.length&&t.push(e[++r]),i="";break}if(!"nErsz".includes(u))break}i&&(i!=="-"||o==="-")&&t.push(i)}return{tokens:t,inPlace:n}}function u1(e,t,n,r,o){if(e.files.length===0)return x("sed: no input files",4);let i=U(),s=new Set([...t,"s"]),u=!1;for(let a of e.files){let l=fk(a,n);if(l.error){if(_(i,n.flushOutput(l.error)),l.error.exitCode!==2)return _o(i,l.error);u=!0;continue}let f=o({...e,files:[l.path]},s),{content:c,...d}=f;if(_(i,d),f.failed||O(f))return _o(i,f);let p=ck(a,r),h;try{h=n.fs.replaceWritable(n.cwd,a,c,p)}catch(m){R(n,"sed",m?.path,m?.fsError);let g=K(m,"sed",`sed: ${m.message}`,4);return _(i,g),_o(i,g)}if(!h){let m=nu(p??a);return _(i,m),_o(i,m)}if(f.quit)break}return u&&(i.exitCode=2),i}function fk(e,t){if(e==="/dev/null"||e==="/dev/stdin"&&!t.stdinFile||e==="/dev/stdout"&&!t.outputFds[1]?.path||e==="/dev/stderr"&&!t.outputFds[2]?.path)return{error:x(`sed: couldn't edit ${e}: not a regular file`,4)};if(e==="/dev/stdin"||e==="/dev/stdout"||e==="/dev/stderr")return{error:nu(e)};let n=P(t,"sed",e);if(n.error)return{error:x(xi("sed",e,n.error).trimEnd(),2)};if(t.fs.isDir(n.path))return{error:x(`sed: couldn't edit ${e}: not a regular file`,4)};let r=E(t.cwd,e,t.fs,{follow:!1}).path;return!t.writable||!r.startsWith("/tmp/")?{error:nu(e)}:n}function ck(e,t){if(!(t===""||t==="*"))return t.includes("*")?t.replaceAll("*",()=>e):e+t}function nu(e){return v("feature","sed","-i",`sed: ${e}: file system is read-only`)}function _o(e,t){let n=O(t);return n?ie(e,n.kind,n.command,n.detail,n.message):e}function ru(e,t){let n=!1;return(r,o)=>{e((n?t:"")+r+(o??"")),n=o===""}}function a1(e,t){let n=new Map,r=0,o,i,s,u=()=>e.io.setReads([o,i?.identity]);function a(f,c){if(c==="")return;l(c),u();let d=e.outputFds[f];if(d?.path){d.write(c);return}if(d==="closed"){let p=new Error("write error: Bad file descriptor");throw p.exitCode=4,p}s[f===1?"stdout":"stderr"]+=c,s.events.push({fd:f,text:c})}function l(f){if(r+=f.length,r>i1)throw new y("feature","output limit","sed: output limit exceeded")}return{start(f){return s=U(),i=f,o=void 0,u(),s},record(f){o=f?.identity,u()},finish(){o=void 0,i=null,u()},stream:a,account:l,openWrite(f){if(n.has(f))return n.get(f);let c;if(f==="/dev/null")c=()=>{};else if(f==="/dev/stdout"||f==="/dev/stderr")c=p=>a(f==="/dev/stdout"?1:2,p);else{let p;try{p=e.writable&&e.fs.openWritable(e.cwd,f)}catch(h){throw R(e,"sed",h?.path,h?.fsError),h.exitCode=4,h}if(!p)throw new y("feature","output file",`sed: ${f}: Read-only file system`);c=h=>{l(h),u(),p.write(h)}}let d=ru(c,t);return n.set(f,d),d}}}function fr(e,t){let n=t.stdinHandle;if(!n)return e;let r=t.io.bufferReads(()=>t.fs.readIdentity(n.identity));if(r===n.content)return e;if(e!==n.content)throw new y("feature","modified redirected input","sed: reading an input file changed after partial consumption is not supported");return t.stdinHandle={...n,content:r},t.stdinOrigin=t.stdinLeft=r,r}function l1(e,t,n,r,o,i){let s=e.length?e:["-"],u={stderr:"",failed:!1},a=0,l=0,f=t,c=null;function d(){for(;c===null||c.pos===c.content.length;){if(a===s.length)return!1;c=null;let h=s[a++];h==="-"?f=fr(f,n):h==="/dev/stdin"&&n.stdinHandle&&(n.stdinOrigin=n.io.bufferReads(()=>n.fs.readIdentity(n.stdinHandle.identity)));let m=st("sed",[h],n,f);if(u.stderr+=m.stderr,u.failed||=m.failed,c=m.inputs.length?{...m.inputs[0],identity:dk(h,n),pos:0,first:!0}:null,m.stderr&&i&&i(m.stderr),m.entries.some(g=>g.kind==="dir"))return u.directory=!0,a=s.length,!1;c?.shared&&q(n,f),o&&(l=0)}return!0}function p(){if(!d())return null;let h=c.pos,m=c.content.indexOf(r,h),g=m<0?"":r,w=c.content.slice(h,m<0?c.content.length:m);c.pos=m<0?c.content.length:m+r.length,c.shared&&(f=c.content.slice(c.pos),q(n,f));let b=c.first;c.first=!1;let k;return{text:w,terminator:g,line:++l,reset:b,identity:c.identity,last:()=>k??=c.pos<c.content.length?!1:o||!d()}}return{next:p,status:u,get identity(){return c?.identity}}}function dk(e,t){return e==="-"||e==="/dev/stdin"?t.stdinHandle?.identity:t.fs.fileIdentity?.(E(t.cwd,e,t.fs).path??Z(t.cwd,e))}var Ro={n:`
|
|
211
211
|
`,t:" ",r:"\r",a:"\x07",f:"\f",v:"\v"};function cr(e,t="substitute command"){let n=e.script[e.i++];if(n===void 0||n===`
|
|
212
|
-
`)throw new Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw new Error("delimiter character is not a single-byte character");return n}function
|
|
212
|
+
`)throw new Error(`unterminated ${t}`);if(n.codePointAt(0)>127)throw new Error("delimiter character is not a single-byte character");return n}function Mo(e,t,n,r="substitute command"){let o="",i=!1;for(;e.i<e.script.length;){let s=e.script[e.i++];if(s===`
|
|
213
213
|
`)throw new Error(`unterminated ${r}`);if(s===t&&!i)return o;if(s==="\\"){let u=e.script[e.i++];if(u===void 0||u===`
|
|
214
214
|
`&&i)throw new Error(`unterminated ${r}`);if(u===`
|
|
215
215
|
`){o+=u;continue}o+=!i&&u===t&&(n||u!=="&")?u:s+u;continue}if(n&&s==="["&&!i){i=!0,o+=s,e.script[e.i]==="^"&&(o+=e.script[e.i++]),e.script[e.i]==="]"&&(o+=e.script[e.i++]);continue}if(n&&i&&s==="["&&/[:.=]/u.test(e.script[e.i]??"")){let u=e.script.indexOf(e.script[e.i]+"]",e.i+1);if(u<0)throw new Error("unterminated character class");if(e.script.slice(e.i,u).includes(`
|
|
216
|
-
`))throw new Error(`unterminated ${r}`);o+=s+e.script.slice(e.i,u+2),e.i=u+2;continue}n&&s==="]"&&(i=!1),o+=s}throw new Error(`unterminated ${r}`)}function
|
|
217
|
-
`)break;if(/\d/u.test(n)){if(t.nth!==null)throw new Error("multiple number options to substitute command");let r=/^\d*/u.exec(e.script.slice(e.i))[0];if(e.i+=r.length,t.nth=Number(n+r),t.nth===0)throw new Error("number option to substitute command may not be zero");Number.isSafeInteger(t.nth)||Ee("substitution occurrence limit")}else if(n==="g"||n==="p"){let r=n==="g"?"global":"print";if(t[r])throw new Error("multiple substitution flags");t[r]=!0}else if(n==="w"){Object.assign(t,ou(e));break}else if(n==="i"||n==="I")t.ignoreCase=!0;else if(n==="m"||n==="M")t.multiline=n;else if(n==="e")
|
|
216
|
+
`))throw new Error(`unterminated ${r}`);o+=s+e.script.slice(e.i,u+2),e.i=u+2;continue}n&&s==="]"&&(i=!1),o+=s}throw new Error(`unterminated ${r}`)}function f1(e){let t=cr(e),n=Mo(e,t,!0),r=Mo(e,t,!1),o=mk(r),i=pk(e);if(n===""&&(i.ignoreCase||i.multiline))throw new Error("cannot specify modifiers on empty regexp");i.multiline&&c1(i.multiline);let s=iu(n,e.extended,!1,i.ignoreCase,e.locale);for(let u of o)if(typeof u=="number"&&u>s.re?.groupCount)throw new Error(`invalid reference \\${u} in replacement`);return{...s,parts:o,...i}}function pk(e){let t={global:!1,print:!1,nth:null};for(;e.i<e.script.length;){let n=e.script[e.i];if(/[;\n#}]/u.test(n))break;if(e.i++,!/[ \t]/u.test(n)){if(n==="\r"&&e.script[e.i]===`
|
|
217
|
+
`)break;if(/\d/u.test(n)){if(t.nth!==null)throw new Error("multiple number options to substitute command");let r=/^\d*/u.exec(e.script.slice(e.i))[0];if(e.i+=r.length,t.nth=Number(n+r),t.nth===0)throw new Error("number option to substitute command may not be zero");Number.isSafeInteger(t.nth)||Ee("substitution occurrence limit")}else if(n==="g"||n==="p"){let r=n==="g"?"global":"print";if(t[r])throw new Error("multiple substitution flags");t[r]=!0}else if(n==="w"){Object.assign(t,ou(e));break}else if(n==="i"||n==="I")t.ignoreCase=!0;else if(n==="m"||n==="M")t.multiline=n;else if(n==="e")c1(n);else throw new Error(`unknown option to substitute command: '${n}'`)}}return t}function c1(e){let t=e==="e"?"command evaluation":"multiline regex matching";throw new y("feature",`substitution flag ${e}`,`sed: substitution flag '${e}' (${t}) is not supported`)}function ou(e){let t=/^[ \t]*([^\n]*)/u.exec(e.script.slice(e.i));e.i+=t[0].length;let n=t[1].split("\0",1)[0];if(n==="")throw new Error("missing filename in r/R/w/W commands");return e.openWrite?{writer:e.openWrite(n)}:{writeName:n}}function iu(e,t,n=!1,r=!1,o=ee){if(!e){if(r)throw new Error("cannot specify modifiers on empty regexp");return{re:null}}let i=re(o);is(e,t,i.multibyte);let s=e.replace(/\\(.)/gu,(f,c)=>(c==="o"&&Ee("regex escape"),Object.hasOwn(Ro,c)?Ro[c]:f)),u=r?Hn(s,i):s,a=t?{source:rs(u,i)}:oo(u,i);if(a.error)throw new Error(a.error);hk(a.source,t),io(a.source);for(let[,f]of a.source.matchAll(/\\(.)/gu))/[1-9]/u.test(f)&&Ee("regex backreferences");return{re:new ct(Gn(a.source,!0,i),!1,null,i),noSub:n,locale:o,ignoreCase:r,pattern:s}}function hk(e,t){let n=!1,r=0,o=!1,i=!1;for(let s=0;s<e.length;s++){let u=e[s];if(u==="\\"){let a=e[++s];n||(o=!"bB<>`'".includes(a),i=!1);continue}if(n){u==="]"&&(n=!1,o=!0,i=!1);continue}if(u==="["){n=!0;continue}if(u==="("){r++,o=!1,i=!1;continue}if(u===")"){if(--r<0)throw new Error("unmatched )")}else if(u==="|"||u==="^"||u==="$"){o=!1,i=!1;continue}else if("*+?{".includes(u)){let a=u==="{"?/^\{(?=\d|,)(\d*)(?:,(\d*))?\}/u.exec(e.slice(s)):null;if(u==="{"&&a===null)throw new Error("invalid repetition count");if(!o||!t&&i&&(u==="*"||u==="{"))throw new Error("Invalid preceding regular expression");a&&(s+=a[0].length-1),i=!0;continue}o=!0,i=!1}if(r>0)throw new Error("unmatched (")}function mk(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="&"){t.push(0);continue}if(r!=="\\"){t.push(r);continue}let o=e[++n];/[0-9]/u.test(o)?t.push(Number(o)):o==="\\"||o==="&"?t.push(o):Object.hasOwn(Ro,o)?t.push(Ro[o]):Ee("replacement escape")}return t}function su(e,t){if(/[\u0080-\u{10FFFF}]/u.test(e+t.re.src)){if(t.locale!==ee)throw new y("feature","locale",`matching non-ASCII text in the ${t.locale} locale is not supported`);t.ignoreCase&&Tt.test(e+t.pattern)&&Ee("case folding of Cyrillic Extended-C letters")}}function uu(e,t,n=null){let r=e.re===null?t.last:e;if(!r)throw new Error("no previous regular expression");if(t.last=r,n!==null&&r.noSub){if(n>r.re.groupCount)throw new Error(`invalid reference \\${n} in replacement`);r.noSub=!1}return r}function au(e,t,n){let r=t.parts.reduce((l,f)=>typeof f=="number"?Math.max(l,f):l,0),o=uu(t,n,r);su(e,o);let i=t.parts.some(l=>typeof l=="number"&&l>0&&l<=o.re.groupCount),s=0,u=t.nth&&!t.global?{search:(l,f)=>s?null:o.re.search(l,f)}:o.re;return{out:zn(e,u,(l,f,c)=>{if(t.nth&&c<t.nth)return null;s++;let d=i?o.re.groups(e,l,f):null;return t.parts.map(p=>typeof p=="string"?p:p===0?e.slice(l,f):d?.[p]?.text??"").join("")},t.global||t.nth?"global":"first").out,count:s}}var d1={a:7,f:12,n:10,r:13,t:9,v:11,"\n":10},p1={d:10,o:8,x:16};function m1(e,t){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;if(e.i===e.script.length)throw new Error("expected \\ after 'a', 'c' or 'i'");if(t.text=null,e.textState.pending={command:t,raw:""},e.script[e.i]==="\\"){let n=e.script[++e.i];if(n===void 0)return;e.i++,n!==`
|
|
218
218
|
`&&(e.textState.pending.raw=n)}fu(e)}function fu(e){let t=e.textState.pending;if(!t)return;let n=t.raw;for(;e.i<e.script.length&&e.script[e.i]!==`
|
|
219
219
|
`;){let r=e.script[e.i++];if(r==="\\"){if(e.i===e.script.length){t.raw=n+`
|
|
220
220
|
`;return}n+=r+e.script[e.i++]}else n+=r}t.command.text=gk(n+`
|
|
221
|
-
`),e.textState.pending=null}function cu(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function gk(e){return W(lu(e))}function lu(e){let t=A(e),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(o!==92||r+1===t.length){n.push(o);continue}let i=String.fromCodePoint(t[++r]);if(Object.hasOwn(
|
|
221
|
+
`),e.textState.pending=null}function cu(e){e?.pending&&(e.pending.command.text=e.pending.raw||null,e.pending=null)}function gk(e){return W(lu(e))}function lu(e){let t=A(e),n=[];for(let r=0;r<t.length;r++){let o=t[r];if(o!==92||r+1===t.length){n.push(o);continue}let i=String.fromCodePoint(t[++r]);if(Object.hasOwn(d1,i)){n.push(d1[i]);continue}if(Object.hasOwn(p1,i)){let s=p1[i],u=s===16?2:3,a=0,l=0;for(;a<u&&r+1<t.length;){let f=t[r+1],c=f>=48&&f<=57?f-48:(f|32)>=97&&(f|32)<=102?(f|32)-87:-1;if(c<0||c>=s)break;l=l*s+c,a++,r++}n.push(a?l&255:i.codePointAt(0))}else if(i==="c"){if(++r===t.length)continue;let s=t[r];if(s===92&&t[++r]!==92)throw new Error("recursive escaping after \\c not allowed");n.push((s>=97&&s<=122?s-32:s)^64)}else n.push(i.codePointAt(0))}return Uint8Array.from(n)}function g1(e){let t=cr(e,"'y' command"),n=lu(h1(e,t)),r=lu(h1(e,t)),o=e.byteLocale?n:[...W(n)],i=e.byteLocale?r:[...W(r)];if(o.length!==i.length)throw new Error("'y' command strings have different lengths");let s=e.byteLocale?Uint8Array.from({length:256},(u,a)=>a):new Map;for(let u=0;u<o.length;u++)e.byteLocale?s[o[u]]=i[u]:s.has(o[u])||s.set(o[u],i[u]);return{translation:s,byteLocale:e.byteLocale}}function h1(e,t){let n="";for(;e.i<e.script.length;){let r=e.script[e.i++];if(r===`
|
|
222
222
|
`)break;if(r===t)return n;if(r!=="\\"){n+=r;continue}let o=e.script[e.i++];if(o===void 0)break;n+=o===t||o===`
|
|
223
|
-
`?o:r+o}throw new Error("unterminated 'y' command")}function
|
|
224
|
-
`,u=
|
|
225
|
-
`;continue}u!==-1?n.vars.set(l,(a?pd(l,n):"")+s.slice(u+1)):n.vars.has(l)&&n.vars.set(l,n.vars.get(l))}return{stdout:"",stderr:i,exitCode:i?1:0}}function Tk(e,t,n){let r=t[0]==="-v"?1:0,o=t[r]==="--";o&&r++;let i=t.slice(r);for(let s of i){if(!o&&s.startsWith("-"))return v("option","unset",s,`unset: option \`${s}\` is not supported`);if(s.includes("["))return v("feature","unset","array subscript","unset: array subscripts are not supported");if(s==="LANG")return v("feature","unset","LANG",`unset: LANG: ${Rr}`);n.vars.delete(s)}return F()}function Fk(e,t,n){let r=null;for(let o=0;o<t.length;o++){let i=t[o];if(i==="-e"||i==="+e")r=i==="-e";else if((i==="-o"||i==="+o")&&t[o+1]==="errexit")r=i==="-o",o++;else return
|
|
226
|
-
`:i)}function Lk(e){let t={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92},n=[],r=i=>{for(let s of A(i))n.push(s)},o=i=>({text:W(Uint8Array.from(n)),stop:i});for(let i=0;i<e.length;i++){if(e[i]!=="\\"||i+1>=e.length){let l=e.indexOf("\\",i+1),f=l<0?e.length:l;r(e.slice(i,f)),i=f-1;continue}let s=e[++i];if(s==="c")return o(!0);if(s in t){n.push(t[s]);continue}if(s==="0"){let l="";for(;l.length<3&&/[0-7]/u.test(e[i+1]??"");)l+=e[++i];n.push(l===""?0:parseInt(l,8)&255);continue}let u=s==="x"?2:s==="u"?4:s==="U"?8:0;if(u>0&&/[0-9a-fA-F]/u.test(e[i+1]??"")){let l="";for(;l.length<u&&/[0-9a-fA-F]/u.test(e[i+1]??"");)l+=e[++i];let f=parseInt(l,16);if(s==="x")n.push(f);else{if(!Ze(f))throw new
|
|
227
|
-
`,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let u=parseInt(e.slice(t+2,i),16);if(o==="x")return{bytes:[u],end:i};if(!Ze(u))throw new
|
|
228
|
-
`))return e;let n=le(t);if(!n&&/[\u0080-\u009F\u2028\u2029]/u.test(e))throw new
|
|
223
|
+
`?o:r+o}throw new Error("unterminated 'y' command")}function w1(e,t){if(t.byteLocale)return W(A(e).map(r=>t.translation[r]));let n="";for(let r of e)n+=t.translation.get(r)??r;return n}function du(e,t=!1,n=ee,r=null){let o={script:e,i:0,extended:t,locale:n,byteLocale:Mr(n),textState:r??{},openWrite:r?.openWrite},i=[];for(fu(o);o.i<e.length;){if(/[;\n\r\f\v \t]/u.test(e[o.i])){o.i++;continue}e[o.i]==="#"&&Ee("comments");let s=b1(o),u=null;if(s&&e[o.i]===","&&(o.i++,u=b1(o,!0),u===null))throw new Error("missing second address");e[o.i]==="~"&&Ee("step address");let a=s?.type==="line"&&s.value===0;if(a&&u?.type!=="regex")throw new Error("line numbers must be >= 1");let l=!1;if(e[o.i]==="!"){for(l=!0,o.i++;/[ \t]/u.test(e[o.i]??"");)o.i++;if(e[o.i]==="!")throw new Error("multiple '!'s")}let f=e[o.i++],c={kind:f,start:s,end:u,active:a,negated:l};if(f&&"pPnNdD=gGhHx".includes(f))i.push(c);else if(f==="w"){i.push({...c,...ou(o)});continue}else if(f===":"||f==="b"||f==="t"||f==="T"){i.push({...c,label:wk(o,c)});continue}else if(f==="s")i.push({...c,...f1(o)});else if(f==="a"||f==="i"||f==="c")m1(o,c),i.push(c);else if(f==="y")i.push({...c,...g1(o)});else if(f==="q"){if(u!==null)throw new Error("command only uses one address");let d=/^[ \t]*(\d*)/u.exec(e.slice(o.i));o.i+=d[0].length;let p=BigInt.asIntN(32,BigInt(d[1]||"0"));i.push({...c,exitCode:p===-1n?0:Number(BigInt.asUintN(8,p))})}else if(f==="{"){o.textState.blockDepth=(o.textState.blockDepth??0)+1,i.push(c);continue}else if(f==="}"){if(!o.textState.blockDepth)throw new Error("unexpected '}'");if(s!==null)throw new Error("'}' doesn't want any addresses");o.textState.blockDepth--,i.push(c)}else{if(f===void 0)throw new Error("missing command");if("QlLFzrRWev".includes(f))Ee();else throw new Error(`unknown command: '${f}'`)}for(;/[ \t]/u.test(e[o.i]??"");)o.i++;if(e[o.i]==="#"&&Ee("comments"),o.i<e.length&&!/[;\n}]/u.test(e[o.i]))throw new Error("extra characters after command")}return r===null&&cu(o.textState),i}function pu(e,t){let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.kind==="{"&&n.push(o),o.kind==="}"){if(n.length===0)throw new Error("unexpected '}'");n.pop().jump=r}}if(n.length)throw new Error("unmatched '{'");return cu(t),bk(e),e}function wk(e,t){if(t.kind===":"&&t.start!==null)throw new Error("':' doesn't want any addresses");let n=/^[ \t]*([^ \t\n;}#]*)/u.exec(e.script.slice(e.i));e.i+=n[0].length;let r=n[1].split("\0",1)[0];if(t.kind===":"&&r==="")throw new Error("':' lacks a label");return r}function bk(e){let t=new Map;for(let n=0;n<e.length;n++)e[n].kind===":"&&t.set(e[n].label,n);for(let n=e.length-1;n>=0;n--){let r=e[n];if(!["b","t","T"].includes(r.kind))continue;let o=r.label===""?e.length:t.get(r.label);if(o===void 0)throw Object.assign(new Error(`can't find label for jump to \`${r.label}'`),{exitCode:4});r.jump=o}}function b1(e,t=!1){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;e.script[e.i]==="~"&&Ee("step address");let n=/^(\d+|\+[ \t]*\d+)/u.exec(e.script.slice(e.i)),r=null;if(n){let o=n[0][0]==="+";if(o&&!t)throw new Error("relative address requires a range");let i=Number(n[0].replace(/[ \t]/gu,""));Number.isSafeInteger(i)||Ee("address limit"),e.i+=n[0].length,r={type:o?"offset":"line",value:i}}else if(e.script[e.i]==="$")e.i++,r={type:"last"};else if(e.script[e.i]==="/"||e.script[e.i]==="\\"){e.script[e.i]==="\\"&&e.i++;let o=cr(e,"address regex"),i=Mo(e,o,!0,"address regex"),s=!1;for(;;){for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;let u=e.script[e.i];if(u!=="I"&&u!=="M")break;if(i==="")throw new Error("cannot specify modifiers on empty regexp");u==="M"&&Ee("address regex flags"),s=!0,e.i++}r={type:"regex",...iu(i,e.extended,!0,s,e.locale)}}for(;/[ \t]/u.test(e.script[e.i]??"");)e.i++;return r}function y1(e,t,n,r,o){let{start:i,end:s}=e;if(i===null)return!0;if(s===null)return Po(i,t,n,r,o);if(!e.active){if(i.type==="line"){if(e.closed||n<i.value)return!1}else if(!Po(i,t,n,r,o))return!1;if(e.active=!0,s.type==="regex")return!0;if(s.type==="offset"&&(e.until=n+s.value),s.type==="line")return e.active=n<s.value,e.closed=!e.active,n<=s.value||Po(i,t,n,r,o)}return s.type==="line"?(e.active=n<s.value,e.closed=!e.active,n<=s.value):((s.type==="offset"?n>=e.until:Po(s,t,n,r,o))&&(e.active=!1,e.closed=!0),!0)}function Po(e,t,n,r,o){if(e.type==="line")return n===e.value;if(e.type==="last")return typeof r=="function"?r():r;let i=uu(e,o);return su(t,i),i.re.search(t)!==null}function hu(e,t,n,r=!1){let{output:o,delimiter:i}=e,s=t.has("n")||t.has("quiet")||t.has("silent"),u=t.has("s")||t.has("separate"),a=l1(e.files,e.stdin,n,i,u,p=>o.stream(2,p)),l=o.start(a),f=[],c=ru(r?p=>{o.account(p),f.push(p)}:p=>o.stream(1,p),i),d={delimiter:i,quiet:s,separate:u,hold:e.hold,regexState:e.regexState,budget:e.budget,emit:c,input:a,output:o};try{let p=yk(e.commands,d);l.quit=p!==null,l.exitCode=a.status.failed?a.status.directory?4:2:p??0,l.failed=a.status.failed}catch(p){let h=Lo(p);_(l,h);let m=O(h);m&&ie(l,m.kind,m.command,m.detail,m.message),l.failed=!0}finally{o.finish()}return r&&(l.content=f.join("")),l}function yk(e,t){let n=!0;for(let r=t.input.next();r;r=t.input.next()){if(n||t.separate&&r.reset){t.hold.text="";for(let s of e)s.active=s.start?.type==="line"&&s.start.value===0,s.closed=!1;n=!1}t.output.record(r);let o={...r,...t,append:[],exitCode:null,replaced:!1},i=xk(e,o);if(!t.quiet&&!i&&t.emit(o.text,o.terminator),o.exitCode!==null&&t.emit(""),x1(o),o.exitCode!==null)return o.exitCode;t.output.record(null)}return null}function xk(e,t){for(let n=0;n<e.length;n++){if(++t.budget.steps>tu)throw new y("feature","execution limit",`sed: execution limit reached after ${tu} commands (infinite loop?)`);let r=e[n];if(r.kind==="}"||r.kind===":")continue;if(y1(r,t.text,t.line,t.last,t.regexState)===!!r.negated){r.kind==="{"&&(n=r.jump);continue}let i=r.kind;if(i!=="{"){if(i==="b"||i==="t"||i==="T"){let s=i==="b"||(i==="t"?t.replaced:!t.replaced);i!=="b"&&(t.replaced=!1),s&&(n=r.jump-1);continue}if(i==="q"){t.exitCode=r.exitCode;break}if(i==="d")return!0;if(i==="D"){let s=t.text.indexOf(t.delimiter);if(s<0)return!0;t.text=t.text.slice(s+t.delimiter.length),n=-1;continue}if(i==="n"||i==="N"){if(!Sk(t,i==="N"))return!0;continue}if(i==="c")return!r.active&&r.text!==null&&t.emit(r.text.slice(0,-1),t.delimiter),!0;if(kk(r,t),t.text.length>Fo)throw new y("feature","pattern space limit","sed: pattern space limit exceeded")}}return!1}function kk(e,t){let{kind:n}=e;if(n==="a"){t.append.push(e.text);return}if(n==="i")e.text!==null&&t.emit(e.text.slice(0,-1),t.delimiter);else if(n==="p")t.emit(t.text,t.terminator);else if(n==="P"){let r=t.text.indexOf(t.delimiter);t.emit(r<0?t.text:t.text.slice(0,r),r<0?t.terminator:t.delimiter)}else if(n==="=")t.emit(String(t.line),t.delimiter);else if(n==="w")e.writer(t.text,t.terminator);else if("gGhHx".includes(n))vk(n,t);else if(n==="y")t.text=w1(t.text,e);else{let r=au(t.text,e,t.regexState);if(t.text=r.out,!r.count)return;t.replaced=!0,e.print&&t.emit(t.text,t.terminator),e.writer&&e.writer(t.text,t.terminator)}}function vk(e,t){let n=t.hold;if(e==="x"){let{text:r,terminator:o}=t;Object.assign(t,n),Object.assign(n,{text:r,terminator:o})}else{let r=e==="h"||e==="H"?t:n,o=r===n?t:n;o.text=e==="G"||e==="H"?o.text+t.delimiter+r.text:r.text,o.terminator=r.terminator}if(n.text.length>Fo)throw new y("feature","hold space limit","sed: hold space limit exceeded")}function Sk(e,t){if(!t&&!e.quiet&&e.emit(e.text,e.terminator),e.last())return t&&!e.quiet&&e.emit(e.text,e.terminator),!1;x1(e);let n=e.input.next();if(!n)return t&&!e.quiet&&e.emit(e.text,e.delimiter),!1;let r=t?e.text+e.delimiter+n.text:n.text;if(r.length>Fo)throw new y("feature","pattern space limit","sed: pattern space limit exceeded");return Object.assign(e,n,{text:r,replaced:!1}),e.output.record(n),!0}function x1(e){if(e.append.length!==0){e.emit("");for(let t of e.append)e.emit(t??"");e.append.length=0}}function k1(e,t,n){try{let{tokens:r,inPlace:o}=s1(t),i=N(r,{short:["n","E","r","s","z"],long:["regexp-extended","quiet","silent","separate","null-data","zero-terminated"],repeatable:["e","expression","f","file"]}),s=i.flags.has("z")||i.flags.has("null-data")||i.flags.has("zero-terminated")?"\0":`
|
|
224
|
+
`,u=a1(n,s),a=Ek(i,e,n,u.openWrite);return a===null?x(To):a.error?a.error:(Object.assign(a,{output:u,delimiter:s,hold:{text:"",terminator:s},regexState:{last:null},budget:{steps:0}}),a.stdin=fr(a.stdin,n),o===null?hu(a,i.flags,n):u1(a,i.flags,n,o,(l,f)=>hu(l,f,n,!0)))}catch(r){return Lo(r)}}function Ek({order:e,positional:t},n,r,o){let i=[],s={openWrite:o},u=!1,a=!1;for(let{name:l,value:f}of e){if((l==="E"||l==="r"||l==="regexp-extended")&&(u=!0),!["e","expression","f","file"].includes(l))continue;a=!0;let c=f;if(l==="f"||l==="file"){n=fr(n,r);let d=n,p=r.io.bufferReads(()=>st("sed",[f],r,d));if(p.failed)return{error:x(p.stderr,4)};c=p.inputs[0].content,p.inputs[0].shared&&(n="")}for(let d of du(c,u,r.locale,s))i.push(d)}return a?{commands:pu(i,s),files:t,stdin:n}:t.length===0?null:{commands:pu(du(t[0],u,r.locale,s),s),files:t.slice(1),stdin:n}}var $k=new Set(["-b","-c","-g","-k","-p","-r","-s","-t","-u","-v","-w","-x","-G","-N","-O","-R","-S","-o"]),Nk=new Set(["-nt","-ot","-ef","<",">"]),pr={__proto__:null,"-eq":(e,t)=>e===t,"-ne":(e,t)=>e!==t,"-lt":(e,t)=>e<t,"-le":(e,t)=>e<=t,"-gt":(e,t)=>e>t,"-ge":(e,t)=>e>=t},Ak=String(ue).length,Ok=new Set(["/dev/stdin","/dev/stdout","/dev/stderr"]);function E1(e,t,n){return N1("test",t,n)}function $1(e,t,n){return t.at(-1)!=="]"?x("[: missing `]'",2):N1("[",t.slice(0,-1),n)}function N1(e,t,n){try{return{...F(),exitCode:mu(t,n)?0:1}}catch(r){return K(r,e,`${e}: ${r.message}`,2)}}function mu(e,t){let[n,r,o]=e;if(e.length===0)return!1;if(e.length===1)return n!=="";if(e.length===2){if(n==="!")return r==="";if(n==="-n")return r!=="";if(n==="-z")return r==="";if(["-a","-e","-f","-d","-h","-L"].includes(n))return gu(n,r,t);throw $k.has(n)&&dr(n),new Error(`${n}: unary operator expected`)}if(e.length===3){if(r==="="||r==="==")return n===o;if(r==="!=")return n!==o;if(Object.hasOwn(pr,r))return pr[r](v1(n),v1(o));Nk.has(r)&&dr(r),(r==="-a"||r==="-o")&&dr("compound expressions")}if(e.length<=4){if(n==="!")return!mu(e.slice(1),t);if(n==="("&&e.at(-1)===")")return mu(e.slice(1,-1),t)}throw e.some(i=>["-a","-o","!","(",")"].includes(i))&&dr("compound expressions"),new Error(e.length>3?"too many arguments":`${r}: binary operator expected`)}function v1(e){let t=/^[ \t\n\r\f\v]*([+-]?)(\d+)[ \t]*$/u.exec(e);if(t&&t[0].length===e.length){let n=t[2].replace(/^0+/u,"")||"0";if(n.length<=Ak){let r=BigInt(t[1]+n);if(r>=ot&&r<=ue)return r}}throw new Error(`${e}: integer expression expected`)}function gu(e,t,n){let r={isDir:u=>u==="/dev"||u==="/dev/fd"||n.fs.isDir(u),isFile:u=>u==="/dev/null"||S1(u)||n.fs.isFile(u),isLink:u=>n.fs.isLink?.(u)===!0,readLink:u=>n.fs.readLink?.(u)},o=e==="-h"||e==="-L",{path:i,error:s}=E(n.cwd,t,r,{follow:!o});return s?!1:(S1(i)&&dr("stream device metadata"),o?r.isLink(i):e==="-e"||e==="-a"?!0:e==="-d"?r.isDir(i):i!=="/dev/null"&&n.fs.isFile(i))}function S1(e){return Ok.has(e)||/^\/dev\/fd\/\d+$/u.test(e)}function dr(e){throw new y("feature",e,`${e} is not supported`)}function C1(e){let t=e.replace(/^[ \t\n\r\v\f]+|[ \t\n\r\v\f]+$/gu,""),n=/^[+-]?\d+$/u.test(t)?BigInt(t):null,r=n!==null&&n>=ot&&n<=ue?n:null;return{arg:t,n:r}}var mn=e=>({...e,halt:!0});function Ck(e,t,n){let r=t[0]==="--"?t.slice(1):t;if(r.length===0)return mn({...F(),exitCode:n.lastExit});let{arg:o,n:i}=C1(r[0]);return i===null?mn(x(`exit: ${o}: numeric argument required`,2)):r.length>1?mn(x("exit: too many arguments")):mn({...F(),exitCode:Number((i%256n+256n)%256n)})}function A1(e){return(t,n,r)=>{let o=n[0]==="--"?n.slice(1):n;if(o.length>1)return mn(x(`${e}: too many arguments`));let{arg:i,n:s}=C1(o[0]??"1");return s===null?mn(x(`${e}: ${i}: numeric argument required`,128)):s<=0?{...x(`${e}: ${i}: loop count out of range`),control:r.loopDepth?{type:"break",levels:r.loopDepth}:void 0}:r.loopDepth===0?x(`${e}: only meaningful in a \`for\`, \`while\` or \`until\` loop`,0):{...F(),control:{type:e,levels:Number(s>BigInt(r.loopDepth)?BigInt(r.loopDepth):s)}}}}function Ik(e,t,n){let r=t[0]==="--",o=r?t.slice(1):t;if(o.length===0||!r&&o[0]==="-p")return v("option","export","-p","export: listing the environment is not supported (there is none)");let i="";for(let s of o){let u=s.indexOf("="),a=u>0&&s[u-1]==="+",l=u===-1?s:s.slice(0,a?u-1:u);if(!r&&s.startsWith("-"))return v("option","export",s,`export: option \`${s}\` is not supported`);if(!Lt.test(l)){i+=`export: \`${l}': not a valid identifier
|
|
225
|
+
`;continue}u!==-1?n.vars.set(l,(a?pd(l,n):"")+s.slice(u+1)):n.vars.has(l)&&n.vars.set(l,n.vars.get(l))}return{stdout:"",stderr:i,exitCode:i?1:0}}function Tk(e,t,n){let r=t[0]==="-v"?1:0,o=t[r]==="--";o&&r++;let i=t.slice(r);for(let s of i){if(!o&&s.startsWith("-"))return v("option","unset",s,`unset: option \`${s}\` is not supported`);if(s.includes("["))return v("feature","unset","array subscript","unset: array subscripts are not supported");if(s==="LANG")return v("feature","unset","LANG",`unset: LANG: ${Rr}`);n.vars.delete(s)}return F()}function Fk(e,t,n){let r=null;for(let o=0;o<t.length;o++){let i=t[o];if(i==="-e"||i==="+e")r=i==="-e";else if((i==="-o"||i==="+o")&&t[o+1]==="errexit")r=i==="-o",o++;else return O1()}return r===null?O1():(n.errexit=r,F())}var O1=()=>v("feature","set","set","set: `set` is supported only as `set -e` or `set +e`",127),wu={exit:Ck,break:A1("break"),continue:A1("continue"),export:Ik,set:Fk,unset:Tk},I1=new Map([["return"," (there are no shell functions)"],["source"," (nothing can be sourced into this shell)"],[".","","`.` (source)"],"eval","exec",["read"," (there is no interactive input)"],["shift"," (there are no positional parameters)"],"shopt",["local"," (there are no shell functions)"],["declare","; use `NAME=value`"],["typeset","; use `NAME=value`"],["readonly","; use `NAME=value`"],["let"," (no arithmetic)"],["type","; use `which`"],["command","; run the command directly"],"builtin","hash","alias","unalias","trap",["wait"," (nothing runs in the background)"],["kill"," (there are no processes)"],["jobs"," (there are no processes)"],["bg"," (there are no processes)"],["fg"," (there are no processes)"],["disown"," (there are no processes)"],"suspend","times","ulimit","umask",["pushd","; use `cd`"],["popd","; use `cd -`"],"dirs","history","help","logout","getopts","mapfile","readarray","caller","enable","compgen","complete","bind","fc"].map(e=>{let[t,n="",r="`"+t+"`"]=Array.isArray(e)?e:[e];return[t,r+" is not supported"+n]}));function T1(e,t){let n=0,r=!0,o=!1;for(;n<t.length&&/^-[neE]+$/u.test(t[n]);n++)for(let s of t[n].slice(1))s==="n"?r=!1:o=s==="e";let i=t.slice(n).join(" ");if(o){let s=Lk(i);i=s.text,s.stop&&(r=!1)}return F(r?i+`
|
|
226
|
+
`:i)}function Lk(e){let t={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92},n=[],r=i=>{for(let s of A(i))n.push(s)},o=i=>({text:W(Uint8Array.from(n)),stop:i});for(let i=0;i<e.length;i++){if(e[i]!=="\\"||i+1>=e.length){let l=e.indexOf("\\",i+1),f=l<0?e.length:l;r(e.slice(i,f)),i=f-1;continue}let s=e[++i];if(s==="c")return o(!0);if(s in t){n.push(t[s]);continue}if(s==="0"){let l="";for(;l.length<3&&/[0-7]/u.test(e[i+1]??"");)l+=e[++i];n.push(l===""?0:parseInt(l,8)&255);continue}let u=s==="x"?2:s==="u"?4:s==="U"?8:0;if(u>0&&/[0-9a-fA-F]/u.test(e[i+1]??"")){let l="";for(;l.length<u&&/[0-9a-fA-F]/u.test(e[i+1]??"");)l+=e[++i];let f=parseInt(l,16);if(s==="x")n.push(f);else{if(!Ze(f))throw new y("feature","echo Unicode escape","echo: escapes outside Unicode scalar values are not supported");r(String.fromCodePoint(f))}continue}let a=i+Le(e,i);r("\\"+e.slice(i,a)),i=a-1}return o(!1)}var F1={a:7,b:8,e:27,E:27,f:12,n:10,r:13,t:9,v:11,"\\":92};function bu(e,t,n,r){let o=e[t+1],i=t+2;if(o===void 0)return{bytes:[92],end:t+1};if(n&&o==="c")return{bytes:[],end:i,stop:!0};if(Object.hasOwn(F1,o))return{bytes:[F1[o]],end:i};if(!n&&`'"?`.includes(o))return{bytes:[o.codePointAt(0)],end:i};if(/[0-7]/u.test(o)){let u=n&&o==="0"?4:3;for(;i<t+1+u&&/[0-7]/u.test(e[i]??"");)i++;return{bytes:[parseInt(e.slice(t+1,i),8)&255],end:i}}let s=o==="x"?2:o==="u"?4:o==="U"?8:0;if(s){for(;i<t+2+s&&/[\da-fA-F]/u.test(e[i]??"");)i++;if(i===t+2||o!=="x"&&i!==t+2+s)return r.stderr+=`printf: missing hexadecimal number in escape
|
|
227
|
+
`,r.failed=!0,r.stop=!0,{bytes:[],end:e.length,stop:!0};let u=parseInt(e.slice(t+2,i),16);if(o==="x")return{bytes:[u],end:i};if(!Ze(u))throw new y("feature","Unicode escape","escapes outside Unicode scalar values are not supported");if(r.byteLocale&&u>127)throw new y("feature","Unicode escape in C locale","non-ASCII Unicode escapes in the C locale are not supported");return{bytes:A(String.fromCodePoint(u)),end:i}}return i=t+1+Le(e,t+1),{bytes:A(e.slice(t,i)),end:i}}function L1(e,t){let n=[];for(let r=0;r<e.length;)if(e[r]==="\\"){let o=bu(e,r,!0,t);for(let i of o.bytes)n.push(i);if(r=o.end,o.stop){t.stop=!0;break}}else{let o=e.indexOf("\\",r),i=o<0?e.length:o;for(let s of A(e.slice(r,i)))n.push(s);r=i}return Uint8Array.from(n)}var Rk=/^%([-+ #0']*)(\d+|\*)?(?:\.(-?\d+|\*)?)?([hlLjzt]*)(.)?/su,Mk=8e6;function _1(e,t,n){let r=t[0]==="--"?t.slice(1):t;if(r.length===0)return pe("printf format [arguments]");if(t[0]!=="--"&&/^-./su.test(t[0])){let s=t[0].startsWith("-v")?"-v":t[0];return v("option","printf",s,`printf: option ${s} is not supported`,2)}let o={args:r.slice(1),index:0,chunks:[],size:0,stderr:"",failed:!1,stop:!1,byteLocale:le(n)},i;try{if(r.some(s=>s.includes("\0")))throw new y("feature","NUL in argument","NUL bytes in command arguments are not supported");do{let s=o.index;if(Dk(r[0],o),o.index===s)break}while(!o.stop&&o.index<o.args.length);i=F()}catch(s){i=K(s,"printf",`printf: ${s.message}`)}try{i.stdout=Pk(o)}catch(s){let u=O(i);u&&n.unsupported.add(u,"printf");let a=K(s,"printf",`printf: ${s.message}`);a.stderr=i.stderr+a.stderr,i=a}return i.stderr=o.stderr+i.stderr,o.failed&&i.exitCode===0&&(i.exitCode=1),i}function zt(e,t){if(e.size+t.length>Mk)throw new y("feature","format size limit","formatted output exceeds the output limit");t.length&&e.chunks.push(t),e.size+=t.length}function Pk(e){let t=new Uint8Array(e.size),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return W(t)}var yu=e=>e.args[e.index++];function Dk(e,t){for(let n=0;n<e.length&&!t.stop;)if(e[n]==="\\"){let r=bu(e,n,!1,t);zt(t,r.bytes),n=r.end}else if(e[n]==="%"){if(e[n+1]==="%"){zt(t,[37]),n+=2;continue}let r=Bk(e.slice(n),t);n+=r.length;let o=yu(t);if("sbc".includes(r.conv))Uk(o??"",r,t);else{let i="diouxX".includes(r.conv)?bo(wo(o,"ouxX".includes(r.conv),t),r):jd(o,r,t);zt(t,A(i))}}else{let r=n+1;for(;r<e.length&&e[r]!=="%"&&e[r]!=="\\";)r++;zt(t,A(e.slice(n,r))),n=r}}function Bk(e,t){if(/^%[-+ #0'\d.*]*\$/u.test(e))throw new y("feature","positional format arguments","positional format arguments are not supported");let n=Rk.exec(e),[,r,o,i,s,u]=n;if(u===void 0)throw new Error("missing format character");if(!"sbcdiouxXeEfFgG".includes(u))throw"aAqQnCS(p%I".includes(u)?new y("feature","%"+u,`format %${u} is not supported`):new Error(`invalid format character: ${u}`);if(s&&"sbc".includes(u))throw new y("feature","format length modifier","length modifiers on string and character formats are not supported");let a={conv:u,length:n[0].length,minus:r.includes("-"),plus:r.includes("+"),space:r.includes(" "),zero:r.includes("0"),alt:r.includes("#"),width:Number(o==="*"?wo(yu(t),!1,t):o??0),precision:i==="*"?Number(wo(yu(t),!1,t)):i===void 0?n[0].includes(".")?0:null:Number(i)};if(o==="*"&&Math.abs(a.width)>2147483647||i==="*"&&(a.precision<-2147483648||a.precision>2147483647))throw new y("feature","format size limit","star width or precision outside the signed 32-bit range is not supported");if(a.width<0&&(a.minus=!0,a.width=-a.width),a.precision<0&&(a.precision=null),a.width>Ce||a.precision>Ce)throw new y("feature","format size limit","format width or precision exceeds the output limit");return a}function Uk(e,t,n){let r=t.conv==="b"?L1(e,n):A(e);t.conv==="c"?r=r.length?r.subarray(0,1):new Uint8Array(1):t.precision!==null&&(r=r.subarray(0,t.precision));let o=Math.max(0,t.width-r.length),i=o?new Uint8Array(o).fill(32):[];t.minus||zt(n,i),zt(n,r),t.minus&&zt(n,i)}function jk(e,t){if(!e.includes(`
|
|
228
|
+
`))return e;let n=le(t);if(!n&&/[\u0080-\u009F\u2028\u2029]/u.test(e))throw new y("feature","filename quoting","wc: locale-sensitive filename quoting is not supported");let r=n?Array.from(A(e),u=>String.fromCodePoint(u)):[...e],o={7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r"},i=!1,s="'";for(let u of r){let a=u.codePointAt(0);a<32||a===127||n&&a>127?(i||(s+="'$'"),s+=o[a]??"\\"+a.toString(8).padStart(3,"0"),i=!0):(u==="'"?s+="'\\''":s+=(i?"''":"")+u,i=!1)}return s+"'"}function R1(e,t,n,r,o){let i=[];for(let s of["l","w","m","c"])n[s]&&i.push(String(e[s]).padStart(r));return i.join(" ")+(t?" "+jk(t,o):"")}var Wk=["**=","**","++","--","+=","-=","*=","/=","%=","^=","==","!=","<=",">=","&&","||","!~",">>","|&","+","-","*","/","%","^","!",">","<","|","?",":","~","$","=","(",")","{","}","[","]",";",","],qk=new Set(["number","string","name","builtin"]),zk=new Set([")","]","++","--"]),Hk=/^(?:0[xX][0-9a-fA-F]+|\d+\.?\d*(?:[eE][+-]?\d+)?|\.\d+(?:[eE][+-]?\d+)?)/u,Gk=e=>e!==void 0&&/[A-Za-z_]/u.test(e),Xk=e=>e!==void 0&&/[A-Za-z0-9_]/u.test(e),M1=e=>e!==void 0&&e>="0"&&e<="9";function B1(e,t=null){let n=[],r=1,o=0,i=(u,a)=>n.push({type:u,value:a,line:r}),s=()=>{let u=n.at(-1);return u?qk.has(u.type)?!1:!(u.type==="punct"&&zk.has(u.value)):!0};for(;o<e.length;){let u=e[o];if(u===`
|
|
229
229
|
`){n.at(-1)?.type!=="newline"&&i("newline",`
|
|
230
230
|
`),r++,o++;continue}if(u===" "||u===" "||u==="\r"){o++;continue}if(u==="\\"&&(e[o+1]===`
|
|
231
231
|
`||e[o+1]==="\r"&&e[o+2]===`
|
|
232
232
|
`)){o+=e[o+1]===`
|
|
233
233
|
`?2:3,r++;continue}if(u==="#"){for(;o<e.length&&e[o]!==`
|
|
234
|
-
`;)o++;continue}if(u==='"'){let f=
|
|
235
|
-
`,t:" ",r:"\r",a:"\x07",b:"\b",f:"\f",v:"\v",'"':'"',"\\":"\\"};function Yk(e,t,n){let r=e[t+1];if(r===void 0)return{text:"\\",end:t+1};if(r in
|
|
234
|
+
`;)o++;continue}if(u==='"'){let f=U1(e,o+1,t,r);i("string",f.value),o=f.end;continue}if(u==="/"&&s()){let f=Vk(e,o+1,r);i("regex",f.value),o=f.end;continue}if(M1(u)||u==="."&&M1(e[o+1])){let f=Zk(e,o);i("number",f.value),o=f.end;continue}if(Gk(u)){let f=o+1;for(;Xk(e[f]);)f++;let c=e.slice(o,f);if(e.slice(f,f+2)==="::")throw new $("namespaces are not supported",r,"namespaces");o=f,Cf.has(c)?i("keyword",c==="func"?"function":c):If.has(c)?i("builtin",c):i(e[f]==="("?"funcname":"name",c);continue}let a=o,l=Wk.find(f=>e.startsWith(f,a));if(u==="@")throw new $("typed regexes, indirect calls and source directives are not supported",r,"@ extensions");if(!l)throw new $(`unexpected character \`${u}\``,r);i("punct",l),o+=l.length}return i("eof",""),n}function Zk(e,t){let n=Hk.exec(e.slice(t))[0],r=n;return/^0[xX]/u.test(n)?r=String(Number.parseInt(n.slice(2),16)):/^0[0-7]+$/u.test(n)&&(r=String(Number.parseInt(n,8))),{value:r,end:t+n.length}}var P1={__proto__:null,n:`
|
|
235
|
+
`,t:" ",r:"\r",a:"\x07",b:"\b",f:"\f",v:"\v",'"':'"',"\\":"\\"};function Yk(e,t,n){let r=e[t+1];if(r===void 0)return{text:"\\",end:t+1};if(r in P1)return{text:P1[r],end:t+2};if(r>="0"&&r<="7"){let o=t+1;for(;o<t+4&&e[o]>="0"&&e[o]<="7";)o++;return{byte:Number.parseInt(e.slice(t+1,o),8)&255,end:o}}if(r==="x"&&/[0-9a-fA-F]/u.test(e[t+2]??"")){let o=t+2;for(;o<t+4&&/[0-9a-fA-F]/u.test(e[o]??"");)o++;return{byte:Number.parseInt(e.slice(t+2,o),16),end:o}}if(r.codePointAt(0)>127)throw new $("non-ASCII characters after an escape are not supported",null,"non-ASCII string escape");return n?.(`escape sequence \`\\${r}' treated as plain \`${r}'`),{text:r,end:t+2}}function U1(e,t,n,r=null){let o=[],i=t;for(;i<e.length;){let s=e[i];if(r!==null){if(s==='"')return{value:W(Uint8Array.from(o)),end:i+1};if(s===`
|
|
236
236
|
`)break;if(s==="\\"&&e[i+1]===`
|
|
237
|
-
`){i+=2;continue}}if(s==="\\"){let u=Yk(e,i,n);
|
|
238
|
-
`)break;if(i==="\\"){r+=2;continue}if(o){if(i==="["&&e[r+1]===":"){let s=e.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}i==="]"&&(o=!1),r++;continue}if(i==="["){o=!0,r++,e[r]==="^"&&r++,e[r]==="]"&&r++;continue}if(i==="/")return{value:e.slice(t,r),end:r+1};r++}throw new $("unterminated regexp",n)}function hr(e,t=null){return j1(e,0,t).value}function B1(e,t){if(t.byte===void 0)for(let n of A(t.text))e.push(n);else e.push(t.byte)}var Kk=new Set(["=","+=","-=","*=","/=","%=","^=","**="]),W1=new Set(["<","<=","==","!=",">",">="]),gr=e=>e.type==="var"||e.type==="index"||e.type==="field";function q1(e){let t=e.tok;return H1(e)||t.type==="regex"||t.type==="keyword"&&t.value==="getline"||t.type==="punct"&&["!","-","+"].includes(t.value)}function gn(e,t){let n=[$e(e,t)];for(;e.accept(",");)e.skipNewlines(),n.push($e(e,t));return n}function $e(e,t){let n=Jk(e,t),r=e.tok;if(r.type==="punct"&&Kk.has(r.value)){gr(n)||e.fail(`cannot assign to ${n.type==="regex"?"a regex":"a non-variable"} (left side of \`${r.value}\`)`),e.next();let o=$e(e,t);return{type:"assign",op:r.value==="**="?"^=":r.value,target:n,value:o}}return n}function Jk(e,t){let n=xu(e,t);if(!e.accept("?"))return n;e.skipNewlines();let r=$e(e,t);return e.skipNewlines(),e.expect(":"),e.skipNewlines(),{type:"cond",test:n,consequent:r,alternate:$e(e,t)}}var Qk=[["or",["||"]],["and",["&&"]],["in",["in"]],["match",["~","!~"]],["compare",[...W1]],["concat",[]],["binary",["+","-"]],["binary",["*","/","%"]]],ev=new Map(Qk.flatMap(([e,t],n)=>t.map(r=>[r,{type:e,precedence:n}]))),tv={type:"concat",precedence:5};function xu(e,t,n=0){let r=Po(e,t),o=1/0;for(;;){let i=e.tok;n<=4&&o>4&&!t.noGt&&(e.is("|")||e.is("|&"))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${Qr}`,'"cmd" | getline');let s=H1(e)?tv:i.type==="punct"||i.type==="keyword"&&i.value==="in"?ev.get(i.value):void 0;if(!s||s.precedence<n||s.precedence>o||t.noGt&&e.is(">"))return r;let{type:u,precedence:a}=s,l=u==="concat"?null:e.next().value;if(o=a,(u==="or"||u==="and")&&e.skipNewlines(),u==="in"){r={type:u,keys:[r],array:z1(e)};continue}let f=xu(e,t,a+1);(l==="/"||l==="%")&&mr(f)===0&&mr(r)!==null&&e.fail(l==="/"?"division by zero attempted":"division by zero attempted in `%`"),u==="compare"&&nv(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),u==="binary"||u==="compare"?r={type:u,op:l,left:r,right:f}:u==="match"?r={type:u,negate:l==="!~",left:r,right:f}:r={type:u,left:r,right:f}}}function z1(e){return e.tok.type!=="name"&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var nv=(e,t)=>e.tok.type==="punct"&&W1.has(e.tok.value)&&!(t.noGt&&e.tok.value===">");function H1(e){let t=e.tok;return t.type==="number"||t.type==="string"||t.type==="name"||t.type==="funcname"||t.type==="builtin"?!0:t.type==="punct"&&["$","(","++","--"].includes(t.value)}function G1(e,t){return xu(e,t,5)}function mr(e){if(e.type==="num")return e.value;if(e.type==="neg"||e.type==="plus"){let r=mr(e.expr);return r===null?null:e.type==="neg"?-r:r}if(e.type!=="binary")return null;let t=mr(e.left),n=mr(e.right);return t===null||n===null?null:eo(e.op,t,n)}var rv={__proto__:null,"!":"not","-":"neg","+":"plus"};function Po(e,t,n=!1){if(n&&(e.is("$")||e.is("++")||e.is("--")))return Do(e,t);let r=e.tok.type==="punct"&&rv[e.tok.value];return r?(e.next(),{type:r,expr:Po(e,t,n)}):n?Z1(e,t):ov(e,t)}function ov(e,t){let n=X1(e,t);return!e.is("^")&&!e.is("**")?n:(e.next(),{type:"binary",op:"^",left:n,right:Po(e,t)})}function X1(e,t){let n=Do(e,t);for(;(e.is("++")||e.is("--"))&&gr(n);)n={type:"postinc",op:e.next().value,target:n};return n}function Do(e,t){if(e.accept("$"))return{type:"field",index:Po(e,t,!0)};if(e.is("++")||e.is("--")){let n=e.next().value,r=Do(e,t);return gr(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:"preinc",op:n,target:r}}return Z1(e,t)}function Z1(e,t){let n=e.tok;switch(n.type){case"number":return e.next(),{type:"num",value:Number(n.value)};case"string":return e.next(),{type:"str",value:n.value};case"regex":return e.next(),{type:"regex",source:n.value,re:iv(e,n.value)};case"name":return sv(e);case"funcname":return uv(e);case"builtin":return lv(e);case"keyword":return n.value==="getline"?fv(e,t):e.unexpected();case"punct":return n.value==="("?av(e):e.unexpected();default:return e.unexpected()}}function iv(e,t){try{return Re(t,!1,n=>e.warn(n))}catch(n){return e.fail(n.message,n.gap??null)}}function ku(e){if(!e.accept("["))return null;let t=gn(e,{});return e.expect("]"),e.is("[")&&e.fail("arrays of arrays are not supported","arrays of arrays"),t}function sv(e){let t=e.next().value,n=ku(e);return n!==null?{type:"index",name:t,subs:n}:(e.is("(")&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:"var",name:t})}function uv(e){return{type:"call",name:e.next().value,args:Y1(e)}}function Y1(e){e.expect("(");let t=e.is(")")?[]:gn(e,{});return e.expect(")"),t}function av(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=gn(e,{});if(e.expect(")"),n.length===1){for(;t-- >0;)e.expect(")");return n[0]}return e.isKw("in")||e.fail("a parenthesized list must be followed by `in ARRAY`"),e.next(),{type:"in",keys:n,array:z1(e)}}function lv(e){let t=e.next().value;if(Jr.has(t)&&e.fail(Jr.get(t),`${t}()`),!e.is("(")){if(t==="length")return{type:"builtin",name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=Y1(e),[r,o]=Zi[t];return(n.length<r||n.length>o)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?"":"s"}; it takes ${r===o?r:`${r} to ${o===1/0?"any number":o}`}`),(t==="sub"||t==="gsub")&&n[2]&&!gr(n[2])&&e.fail(`${t}(): substitution into a temporary value is not supported`,"substitution into temporary value"),t==="split"&&n[1].type!=="var"&&e.fail("split(): second argument must be an array name"),t==="match"&&n[2]&&n[2].type!=="var"&&e.fail("match(): third argument must be an array name"),{type:"builtin",name:t,args:n}}function fv(e,t){e.next();let n=null;(e.tok.type==="name"||e.is("$"))&&(n=Do(e,t),gr(n)||e.fail("getline: target must be a variable, field or array element"));let r=null;return e.accept("<")&&(r=X1(e,t)),{type:"getline",target:n,file:r}}var cv=new Set(["/dev/stdout","/dev/stderr","/dev/null"]),vu=class{constructor(t,n){this.toks=t,this.i=0,this.warnings=n,this.funcs=new Set,this.parens=new Map;let r=[];for(let o=0;o+1<t.length;o++){let i=t[o],s=t[o+1];i.type==="punct"&&(i.value==="("?r.push(o):i.value===")"&&r.length>0&&this.parens.set(r.pop(),o)),i.type==="keyword"&&i.value==="function"&&(s.type==="name"||s.type==="funcname")&&this.funcs.add(s.value)}this.loopDepth=0,this.switchDepth=0,this.context="main"}get tok(){return this.toks[this.i]}peek(t){return this.toks[Math.min(this.i+t,this.toks.length-1)]}is(t,n="punct"){return this.tok.type===n&&this.tok.value===t}isKw(t){return this.is(t,"keyword")}next(){return this.toks[this.i++]}accept(t,n="punct"){return this.is(t,n)?this.next():null}expect(t,n="punct"){return this.is(t,n)||this.fail(`expected \`${t}\` but found ${Ht(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type==="newline";)this.i++}skipTerminators(){for(;this.tok.type==="newline"||this.is(";");)this.i++}fail(t,n=null){throw new $(t,this.tok.line,n)}warn(t){this.warnings.push(t)}unexpected(){this.fail(`unexpected ${Ht(this.tok)}`)}};function Ht(e){return e.type==="eof"?"end of program":e.type==="newline"?"newline":e.type==="string"?`string "${e.value}"`:e.type==="regex"?`regex /${e.value}/`:`\`${e.value}\``}var V1={__proto__:null,BEGIN:"begin",END:"end",BEGINFILE:"beginFile",ENDFILE:"endFile"};function Q1(e){let t=[],n=new vu(U1(e,o=>t.push(o)),t),r={begin:[],end:[],beginFile:[],endFile:[],rules:[],functions:new Map,warnings:t};for(n.skipNewlines();n.tok.type!=="eof";)n.is(";")&&n.fail("each rule must have a pattern or an action part"),dv(n,r),n.accept(";"),n.skipNewlines();return r}function dv(e,t){if(e.isKw("function")){pv(e,t);return}if(e.tok.type==="keyword"&&e.tok.value in V1){let i=e.next().value;e.is("{")||e.fail(`${i} requires an action: ${i} { ... }`),t[V1[i]].push(...wr(e,i.toLowerCase()));return}if(e.is("{")){t.rules.push({pattern:null,action:wr(e,"main")});return}let n=$e(e,{}),r=n;e.accept(",")&&(e.skipNewlines(),r={type:"range",from:n,to:$e(e,{})});let o=e.is("{")?wr(e,"main"):null;o===null&&!(e.tok.type==="newline"||e.tok.type==="eof"||e.is(";"))&&e.unexpected(),t.rules.push({pattern:r,action:o})}function pv(e,t){e.next();let n=e.tok;n.type==="builtin"&&e.fail(`cannot redefine builtin function \`${n.value}\``),n.type!=="name"&&n.type!=="funcname"&&e.fail(`expected a function name but found ${Ht(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect("(");let o=[];for(;!e.is(")");){let i=e.tok;if(i.type!=="name"&&e.fail(`expected a parameter name but found ${Ht(i)}`),(i.value===r||o.includes(i.value))&&e.fail(`duplicate parameter \`${i.value}\` in function \`${r}\``),o.push(e.next().value),!e.accept(","))break;e.skipNewlines()}e.expect(")"),e.skipNewlines(),t.functions.set(r,{params:o,body:wr(e,"function")})}function wr(e,t=e.context){let n=e.context;e.context=t,e.expect("{");let r=[];for(e.skipTerminators();!e.is("}");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),r.push(Su(e)),e.skipTerminators();return e.next(),e.context=n,r}function yr(e){if(e.is(";")||e.tok.type==="newline"){e.next();return}e.is("}")||e.tok.type==="eof"||e.unexpected()}var hv={__proto__:null,if:mv,while:gv,do:wv,for:yv,switch:bv,break:e=>wn(e,"break"),continue:e=>wn(e,"continue"),next:e=>wn(e,"next"),nextfile:e=>wn(e,"nextfile"),exit:e=>wn(e,"exit"),return:e=>wn(e,"return"),delete:kv,print:e=>J1(e,"print"),printf:e=>J1(e,"printf")};function Su(e){if(e.is("{"))return{type:"block",body:wr(e)};if(e.is(";"))return e.next(),{type:"empty"};let t=e.tok.type==="keyword"?hv[e.tok.value]:void 0;if(t)return t(e);let n=$e(e,{});return yr(e),{type:"expr",expr:n}}function yn(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=Su(e);return t&&e.loopDepth--,n}function Bo(e){e.next(),e.expect("(");let t=$e(e,{});return e.expect(")"),t}function mv(e){let t=Bo(e),n=yn(e,!1),r=e.i;return e.skipNewlines(),e.isKw("else")?(e.next(),{type:"if",test:t,consequent:n,alternate:yn(e,!1)}):(e.i=r,{type:"if",test:t,consequent:n,alternate:null})}function gv(e){return{type:"while",test:Bo(e),body:yn(e,!0)}}function wv(e){e.next();let t=yn(e,!0);e.skipTerminators(),e.isKw("while")||e.fail("`do` body must be followed by `while (...)`");let n=Bo(e);return yr(e),{type:"do",body:t,test:n}}function yv(e){if(e.next(),e.expect("("),e.tok.type==="name"&&e.peek(1).type==="keyword"&&e.peek(1).value==="in"&&e.peek(2).type==="name"&&e.peek(3).value===")"){let o=e.next().value;e.next();let i=e.next().value;return e.next(),{type:"forin",name:o,array:i,body:yn(e,!0)}}let t=e.is(";")?null:$e(e,{});e.expect(";"),e.skipNewlines();let n=e.is(";")?null:$e(e,{});e.expect(";"),e.skipNewlines();let r=e.is(")")?null:$e(e,{});return e.expect(")"),{type:"for",init:t,test:n,step:r,body:yn(e,!0)}}function bv(e){let t=Bo(e);e.skipNewlines(),e.expect("{");let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is("}");e.skipTerminators()){let o=null;e.accept("case","keyword")?o=xv(e):e.accept("default","keyword")||e.fail(`expected \`case\` or \`default\` in switch body but found ${Ht(e.tok)}`);let i=o===null?"default":o.type==="regex"?`/${o.source}/`:String(o.value);r.has(i)&&e.fail(`duplicate case values in switch body: ${i}`),r.add(i),e.expect(":");let s=[];for(e.skipTerminators();!e.is("}")&&!e.isKw("case")&&!e.isKw("default");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),s.push(Su(e)),e.skipTerminators();n.push({test:o,body:s})}return e.switchDepth--,e.next(),{type:"switch",expr:t,cases:n}}function xv(e){let t=e.accept("-")?-1:(e.accept("+"),1),n=e.tok;return n.type==="number"?(e.next(),{type:"num",value:t*Number(n.value)}):t===1&&n.type==="string"?(e.next(),{type:"str",value:n.value}):t===1&&n.type==="regex"?(e.next(),{type:"regex",source:n.value,re:Re(n.value,!1,r=>e.warn(r))}):e.fail(`case value must be a number, string or regex constant, found ${Ht(n)}`)}function wn(e,t){t==="break"&&e.loopDepth===0&&e.switchDepth===0&&e.fail("`break` is not allowed outside a loop or switch"),t==="continue"&&e.loopDepth===0&&e.fail("`continue` is not allowed outside a loop"),t==="next"&&e.context!=="main"&&e.context!=="function"&&e.fail(`\`next\` cannot be used in a ${e.context.toUpperCase()} action`),t==="nextfile"&&(e.context==="begin"||e.context==="end"||e.context==="endfile")&&e.fail(`\`nextfile\` cannot be used in a ${e.context.toUpperCase()} action`),t==="return"&&e.context!=="function"&&e.fail("`return` is only allowed inside a function"),e.next();let n={type:t};return(t==="exit"||t==="return")&&(n.value=q1(e)?$e(e,{}):null),yr(e),n}function kv(e){e.next(),e.tok.type!=="name"&&e.fail(`\`delete\` needs an array name but found ${Ht(e.tok)}`);let t=e.next().value,n=ku(e);return yr(e),{type:"delete",name:t,subs:n}}var K1=e=>e.is(";")||e.is("}")||e.is(">")||e.is(">>")||e.is("|")||e.is("|&")||e.tok.type==="newline"||e.tok.type==="eof";function J1(e,t){e.next();let n=null;if(e.is("(")){let o=e.i;e.next();let i=e.is(")")?[]:gn(e,{});e.accept(")")&&K1(e)?n=i:e.i=o}n===null&&(n=K1(e)?[]:gn(e,{noGt:!0})),t==="printf"&&n.length===0&&e.fail("printf needs a format string");let r=null;return(e.is("|")||e.is("|&"))&&e.fail(`output pipes (\`${t} ... | "cmd"\`) are not supported: ${Qr}`,`${t} | "cmd"`),(e.accept(">")||e.accept(">>"))&&(r=G1(e,{noGt:!0}),r.type==="str"&&!cv.has(r.value)&&e.fail(Eu(r.value),`${t} > FILE`)),yr(e),{type:t,args:n,dest:r}}function Eu(e){return`cannot redirect output to \`${e}\`: the filesystem is read-only (only /dev/stdout, /dev/stderr and /dev/null). To print a comparison, parenthesize it: print (a > b)`}var G=class{constructor(t){this.s=t,this.number=void 0,this.numeric=void 0}},br="[ \\t\\n\\r\\f\\v]*",nh="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",vv=new RegExp(`^${br}${nh}${br}$`,"u"),Sv=new RegExp(`^${br}(${nh})`,"u"),rh=new RegExp(`^${br}([+-])(inf|nan)${br}$`,"iu"),$u=e=>vv.test(e)||rh.test(e);function eh(e){let t=Sv.exec(e);if(t)return Number(t[1]);let n=rh.exec(e);return n?n[2].toLowerCase()==="nan"?Number.NaN:n[1]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:0}var Nu=()=>new $("attempt to use an array in a scalar context");function z(e){if(typeof e=="number")return e;if(e===void 0)return 0;if(e instanceof G)return e.number??=eh(e.s);if(typeof e=="string")return eh(e);throw Nu()}var Uo=new Map;function oh(e,t){if(Number.isNaN(e))throw new $("formatting signed NaN is not supported",null,"signed NaN");if(!Number.isFinite(e))return e<0?"-inf":"+inf";if(Number.isInteger(e))return Math.abs(e)<2**53?String(e):BigInt(e).toString();let n=Uo.get(t);if(n===void 0){Uo.size>64&&Uo.clear(),n=go(t);let r=n.filter(o=>typeof o!="string");if(r.length>1||r.some(o=>!"diouxXeEfFgG".includes(o.conv)||o.width==="*"||o.precision==="*"))throw new $("this numeric conversion format is not supported",null,"numeric conversion format");Uo.set(t,n)}return n.map(r=>typeof r=="string"?r:Wt(e,r)).join("")}var ih=e=>typeof e=="string"?e:e instanceof G?e.s:"%.6g",Ev=e=>ih(e.globals.get("CONVFMT")),$v=e=>ih(e.globals.get("OFMT"));function L(e,t){if(typeof e=="string")return pt(t,e);if(e instanceof G)return pt(t,e.s);if(typeof e=="number")return oh(e,Ev(t));if(e===void 0)return"";throw Nu()}function pt(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new $("non-ASCII AWK text in a byte locale is not supported",null,"byte locale text");return t}function Gt(e,t=!1){return[...e].map(n=>{let r=t?n.toUpperCase():n.toLowerCase();if([...r].length!==1)throw new $("Unicode case expansion is not supported",null,"Unicode case mapping");return r}).join("")}function sh(e,t){return typeof e=="number"?oh(e,$v(t)):L(e,t)}var Au=e=>e.numeric??=$u(e.s),th=e=>typeof e=="number"||e===void 0||e instanceof G&&Au(e),qe=e=>Ne(e.globals.get("IGNORECASE"));function jo(e,t,n){if(th(e)&&th(t)){let i=z(e),s=z(t);return i<s?-1:i>s?1:i===s?0:Number.NaN}let r=L(e,n),o=L(t,n);return qe(n)&&(r=Gt(r),o=Gt(o)),j(r,o)}function Ne(e){if(typeof e=="number")return e!==0&&!Number.isNaN(e);if(typeof e=="string")return e!=="";if(e instanceof G)return Au(e)?z(e)!==0:e.s!=="";if(e===void 0)return!1;throw Nu()}var Ou=(e,t)=>Number.isSafeInteger(e)?String(e):L(e,t);function Cu(e){return e instanceof Map?"array":e===void 0?"untyped":typeof e=="number"?"number":e instanceof G&&Au(e)?"strnum":"string"}function uh(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t==="")return Nv(e);let o,i;if(t.length===1){let u=r.indexOf(t,e.pos);i=u===-1?r.length:u,o=u===-1?r.length:u+1}else{let u=Qi(r,Re(t,n),e.pos);i=u?.start??r.length,o=u?.end??r.length}let s=r.slice(e.pos,i);return e.pos=o,{rec:s,rt:r.slice(i,o)}}function Nv(e){let{text:t}=e,n=e.pos;for(;t[n]===`
|
|
239
|
-
`;)n++;if(n>=t.length)return e.pos=n,null;let r=/\n\n+/gu;r.lastIndex=n;let o=r.exec(t);if(!o){e.pos=t.length;let i=t.slice(n).replace(/\n+$/u,"");return{rec:i,rt:t.slice(n+i.length)}}return e.pos=o.index+o[0].length,{rec:t.slice(n,o.index),rt:o[0]}}function Fu(e,t,n,r){if(e==="")return[];if(t instanceof ct)return
|
|
237
|
+
`){i+=2;continue}}if(s==="\\"){let u=Yk(e,i,n);D1(o,u),i=u.end}else{let u=String.fromCodePoint(e.codePointAt(i));D1(o,{text:u}),i+=u.length}}if(r!==null)throw new $("unterminated string",r);return{value:W(Uint8Array.from(o)),end:i}}function Vk(e,t,n){let r=t,o=!1;for(;r<e.length;){let i=e[r];if(i===`
|
|
238
|
+
`)break;if(i==="\\"){r+=2;continue}if(o){if(i==="["&&e[r+1]===":"){let s=e.indexOf(":]",r+2);if(s!==-1){r=s+2;continue}}i==="]"&&(o=!1),r++;continue}if(i==="["){o=!0,r++,e[r]==="^"&&r++,e[r]==="]"&&r++;continue}if(i==="/")return{value:e.slice(t,r),end:r+1};r++}throw new $("unterminated regexp",n)}function hr(e,t=null){return U1(e,0,t).value}function D1(e,t){if(t.byte===void 0)for(let n of A(t.text))e.push(n);else e.push(t.byte)}var Kk=new Set(["=","+=","-=","*=","/=","%=","^=","**="]),j1=new Set(["<","<=","==","!=",">",">="]),gr=e=>e.type==="var"||e.type==="index"||e.type==="field";function W1(e){let t=e.tok;return z1(e)||t.type==="regex"||t.type==="keyword"&&t.value==="getline"||t.type==="punct"&&["!","-","+"].includes(t.value)}function gn(e,t){let n=[$e(e,t)];for(;e.accept(",");)e.skipNewlines(),n.push($e(e,t));return n}function $e(e,t){let n=Jk(e,t),r=e.tok;if(r.type==="punct"&&Kk.has(r.value)){gr(n)||e.fail(`cannot assign to ${n.type==="regex"?"a regex":"a non-variable"} (left side of \`${r.value}\`)`),e.next();let o=$e(e,t);return{type:"assign",op:r.value==="**="?"^=":r.value,target:n,value:o}}return n}function Jk(e,t){let n=xu(e,t);if(!e.accept("?"))return n;e.skipNewlines();let r=$e(e,t);return e.skipNewlines(),e.expect(":"),e.skipNewlines(),{type:"cond",test:n,consequent:r,alternate:$e(e,t)}}var Qk=[["or",["||"]],["and",["&&"]],["in",["in"]],["match",["~","!~"]],["compare",[...j1]],["concat",[]],["binary",["+","-"]],["binary",["*","/","%"]]],ev=new Map(Qk.flatMap(([e,t],n)=>t.map(r=>[r,{type:e,precedence:n}]))),tv={type:"concat",precedence:5};function xu(e,t,n=0){let r=Do(e,t),o=1/0;for(;;){let i=e.tok;n<=4&&o>4&&!t.noGt&&(e.is("|")||e.is("|&"))&&e.fail(`command pipelines (\`"cmd" | getline\`) are not supported: ${Qr}`,'"cmd" | getline');let s=z1(e)?tv:i.type==="punct"||i.type==="keyword"&&i.value==="in"?ev.get(i.value):void 0;if(!s||s.precedence<n||s.precedence>o||t.noGt&&e.is(">"))return r;let{type:u,precedence:a}=s,l=u==="concat"?null:e.next().value;if(o=a,(u==="or"||u==="and")&&e.skipNewlines(),u==="in"){r={type:u,keys:[r],array:q1(e)};continue}let f=xu(e,t,a+1);(l==="/"||l==="%")&&mr(f)===0&&mr(r)!==null&&e.fail(l==="/"?"division by zero attempted":"division by zero attempted in `%`"),u==="compare"&&nv(e,t)&&e.fail(`comparison operators do not chain (\`a ${l} b ${e.tok.value} c\`); parenthesize the first comparison`),u==="binary"||u==="compare"?r={type:u,op:l,left:r,right:f}:u==="match"?r={type:u,negate:l==="!~",left:r,right:f}:r={type:u,left:r,right:f}}}function q1(e){return e.tok.type!=="name"&&e.fail(`expected an array name after \`in\` but found \`${e.tok.value}\``),e.next().value}var nv=(e,t)=>e.tok.type==="punct"&&j1.has(e.tok.value)&&!(t.noGt&&e.tok.value===">");function z1(e){let t=e.tok;return t.type==="number"||t.type==="string"||t.type==="name"||t.type==="funcname"||t.type==="builtin"?!0:t.type==="punct"&&["$","(","++","--"].includes(t.value)}function H1(e,t){return xu(e,t,5)}function mr(e){if(e.type==="num")return e.value;if(e.type==="neg"||e.type==="plus"){let r=mr(e.expr);return r===null?null:e.type==="neg"?-r:r}if(e.type!=="binary")return null;let t=mr(e.left),n=mr(e.right);return t===null||n===null?null:eo(e.op,t,n)}var rv={__proto__:null,"!":"not","-":"neg","+":"plus"};function Do(e,t,n=!1){if(n&&(e.is("$")||e.is("++")||e.is("--")))return Bo(e,t);let r=e.tok.type==="punct"&&rv[e.tok.value];return r?(e.next(),{type:r,expr:Do(e,t,n)}):n?X1(e,t):ov(e,t)}function ov(e,t){let n=G1(e,t);return!e.is("^")&&!e.is("**")?n:(e.next(),{type:"binary",op:"^",left:n,right:Do(e,t)})}function G1(e,t){let n=Bo(e,t);for(;(e.is("++")||e.is("--"))&&gr(n);)n={type:"postinc",op:e.next().value,target:n};return n}function Bo(e,t){if(e.accept("$"))return{type:"field",index:Do(e,t,!0)};if(e.is("++")||e.is("--")){let n=e.next().value,r=Bo(e,t);return gr(r)||e.fail(`\`${n}\` needs a variable, field or array element`),{type:"preinc",op:n,target:r}}return X1(e,t)}function X1(e,t){let n=e.tok;switch(n.type){case"number":return e.next(),{type:"num",value:Number(n.value)};case"string":return e.next(),{type:"str",value:n.value};case"regex":return e.next(),{type:"regex",source:n.value,re:iv(e,n.value)};case"name":return sv(e);case"funcname":return uv(e);case"builtin":return lv(e);case"keyword":return n.value==="getline"?fv(e,t):e.unexpected();case"punct":return n.value==="("?av(e):e.unexpected();default:return e.unexpected()}}function iv(e,t){try{return Re(t,!1,n=>e.warn(n))}catch(n){return e.fail(n.message,n.gap??null)}}function ku(e){if(!e.accept("["))return null;let t=gn(e,{});return e.expect("]"),e.is("[")&&e.fail("arrays of arrays are not supported","arrays of arrays"),t}function sv(e){let t=e.next().value,n=ku(e);return n!==null?{type:"index",name:t,subs:n}:(e.is("(")&&e.funcs.has(t)&&e.fail(`function \`${t}\` called with space between name and \`(\``),{type:"var",name:t})}function uv(e){return{type:"call",name:e.next().value,args:Z1(e)}}function Z1(e){e.expect("(");let t=e.is(")")?[]:gn(e,{});return e.expect(")"),t}function av(e){let t=0;for(;e.parens.get(e.i+1)===e.parens.get(e.i)-1;)e.next(),t++;e.next();let n=gn(e,{});if(e.expect(")"),n.length===1){for(;t-- >0;)e.expect(")");return n[0]}return e.isKw("in")||e.fail("a parenthesized list must be followed by `in ARRAY`"),e.next(),{type:"in",keys:n,array:q1(e)}}function lv(e){let t=e.next().value;if(Jr.has(t)&&e.fail(Jr.get(t),`${t}()`),!e.is("(")){if(t==="length")return{type:"builtin",name:t,args:[]};e.fail(`\`${t}\` needs parentheses: ${t}(...)`)}let n=Z1(e),[r,o]=Yi[t];return(n.length<r||n.length>o)&&e.fail(`${t}() called with ${n.length} argument${n.length===1?"":"s"}; it takes ${r===o?r:`${r} to ${o===1/0?"any number":o}`}`),(t==="sub"||t==="gsub")&&n[2]&&!gr(n[2])&&e.fail(`${t}(): substitution into a temporary value is not supported`,"substitution into temporary value"),t==="split"&&n[1].type!=="var"&&e.fail("split(): second argument must be an array name"),t==="match"&&n[2]&&n[2].type!=="var"&&e.fail("match(): third argument must be an array name"),{type:"builtin",name:t,args:n}}function fv(e,t){e.next();let n=null;(e.tok.type==="name"||e.is("$"))&&(n=Bo(e,t),gr(n)||e.fail("getline: target must be a variable, field or array element"));let r=null;return e.accept("<")&&(r=G1(e,t)),{type:"getline",target:n,file:r}}var cv=new Set(["/dev/stdout","/dev/stderr","/dev/null"]),vu=class{constructor(t,n){this.toks=t,this.i=0,this.warnings=n,this.funcs=new Set,this.parens=new Map;let r=[];for(let o=0;o+1<t.length;o++){let i=t[o],s=t[o+1];i.type==="punct"&&(i.value==="("?r.push(o):i.value===")"&&r.length>0&&this.parens.set(r.pop(),o)),i.type==="keyword"&&i.value==="function"&&(s.type==="name"||s.type==="funcname")&&this.funcs.add(s.value)}this.loopDepth=0,this.switchDepth=0,this.context="main"}get tok(){return this.toks[this.i]}peek(t){return this.toks[Math.min(this.i+t,this.toks.length-1)]}is(t,n="punct"){return this.tok.type===n&&this.tok.value===t}isKw(t){return this.is(t,"keyword")}next(){return this.toks[this.i++]}accept(t,n="punct"){return this.is(t,n)?this.next():null}expect(t,n="punct"){return this.is(t,n)||this.fail(`expected \`${t}\` but found ${Ht(this.tok)}`),this.next()}skipNewlines(){for(;this.tok.type==="newline";)this.i++}skipTerminators(){for(;this.tok.type==="newline"||this.is(";");)this.i++}fail(t,n=null){throw new $(t,this.tok.line,n)}warn(t){this.warnings.push(t)}unexpected(){this.fail(`unexpected ${Ht(this.tok)}`)}};function Ht(e){return e.type==="eof"?"end of program":e.type==="newline"?"newline":e.type==="string"?`string "${e.value}"`:e.type==="regex"?`regex /${e.value}/`:`\`${e.value}\``}var Y1={__proto__:null,BEGIN:"begin",END:"end",BEGINFILE:"beginFile",ENDFILE:"endFile"};function J1(e){let t=[],n=new vu(B1(e,o=>t.push(o)),t),r={begin:[],end:[],beginFile:[],endFile:[],rules:[],functions:new Map,warnings:t};for(n.skipNewlines();n.tok.type!=="eof";)n.is(";")&&n.fail("each rule must have a pattern or an action part"),dv(n,r),n.accept(";"),n.skipNewlines();return r}function dv(e,t){if(e.isKw("function")){pv(e,t);return}if(e.tok.type==="keyword"&&e.tok.value in Y1){let i=e.next().value;e.is("{")||e.fail(`${i} requires an action: ${i} { ... }`),t[Y1[i]].push(...wr(e,i.toLowerCase()));return}if(e.is("{")){t.rules.push({pattern:null,action:wr(e,"main")});return}let n=$e(e,{}),r=n;e.accept(",")&&(e.skipNewlines(),r={type:"range",from:n,to:$e(e,{})});let o=e.is("{")?wr(e,"main"):null;o===null&&!(e.tok.type==="newline"||e.tok.type==="eof"||e.is(";"))&&e.unexpected(),t.rules.push({pattern:r,action:o})}function pv(e,t){e.next();let n=e.tok;n.type==="builtin"&&e.fail(`cannot redefine builtin function \`${n.value}\``),n.type!=="name"&&n.type!=="funcname"&&e.fail(`expected a function name but found ${Ht(n)}`),e.next();let r=n.value;t.functions.has(r)&&e.fail(`function \`${r}\` is defined twice`),e.expect("(");let o=[];for(;!e.is(")");){let i=e.tok;if(i.type!=="name"&&e.fail(`expected a parameter name but found ${Ht(i)}`),(i.value===r||o.includes(i.value))&&e.fail(`duplicate parameter \`${i.value}\` in function \`${r}\``),o.push(e.next().value),!e.accept(","))break;e.skipNewlines()}e.expect(")"),e.skipNewlines(),t.functions.set(r,{params:o,body:wr(e,"function")})}function wr(e,t=e.context){let n=e.context;e.context=t,e.expect("{");let r=[];for(e.skipTerminators();!e.is("}");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),r.push(Su(e)),e.skipTerminators();return e.next(),e.context=n,r}function br(e){if(e.is(";")||e.tok.type==="newline"){e.next();return}e.is("}")||e.tok.type==="eof"||e.unexpected()}var hv={__proto__:null,if:mv,while:gv,do:wv,for:bv,switch:yv,break:e=>wn(e,"break"),continue:e=>wn(e,"continue"),next:e=>wn(e,"next"),nextfile:e=>wn(e,"nextfile"),exit:e=>wn(e,"exit"),return:e=>wn(e,"return"),delete:kv,print:e=>K1(e,"print"),printf:e=>K1(e,"printf")};function Su(e){if(e.is("{"))return{type:"block",body:wr(e)};if(e.is(";"))return e.next(),{type:"empty"};let t=e.tok.type==="keyword"?hv[e.tok.value]:void 0;if(t)return t(e);let n=$e(e,{});return br(e),{type:"expr",expr:n}}function bn(e,t){e.skipNewlines(),t&&e.loopDepth++;let n=Su(e);return t&&e.loopDepth--,n}function Uo(e){e.next(),e.expect("(");let t=$e(e,{});return e.expect(")"),t}function mv(e){let t=Uo(e),n=bn(e,!1),r=e.i;return e.skipNewlines(),e.isKw("else")?(e.next(),{type:"if",test:t,consequent:n,alternate:bn(e,!1)}):(e.i=r,{type:"if",test:t,consequent:n,alternate:null})}function gv(e){return{type:"while",test:Uo(e),body:bn(e,!0)}}function wv(e){e.next();let t=bn(e,!0);e.skipTerminators(),e.isKw("while")||e.fail("`do` body must be followed by `while (...)`");let n=Uo(e);return br(e),{type:"do",body:t,test:n}}function bv(e){if(e.next(),e.expect("("),e.tok.type==="name"&&e.peek(1).type==="keyword"&&e.peek(1).value==="in"&&e.peek(2).type==="name"&&e.peek(3).value===")"){let o=e.next().value;e.next();let i=e.next().value;return e.next(),{type:"forin",name:o,array:i,body:bn(e,!0)}}let t=e.is(";")?null:$e(e,{});e.expect(";"),e.skipNewlines();let n=e.is(";")?null:$e(e,{});e.expect(";"),e.skipNewlines();let r=e.is(")")?null:$e(e,{});return e.expect(")"),{type:"for",init:t,test:n,step:r,body:bn(e,!0)}}function yv(e){let t=Uo(e);e.skipNewlines(),e.expect("{");let n=[],r=new Set;for(e.switchDepth++,e.skipTerminators();!e.is("}");e.skipTerminators()){let o=null;e.accept("case","keyword")?o=xv(e):e.accept("default","keyword")||e.fail(`expected \`case\` or \`default\` in switch body but found ${Ht(e.tok)}`);let i=o===null?"default":o.type==="regex"?`/${o.source}/`:String(o.value);r.has(i)&&e.fail(`duplicate case values in switch body: ${i}`),r.add(i),e.expect(":");let s=[];for(e.skipTerminators();!e.is("}")&&!e.isKw("case")&&!e.isKw("default");)e.tok.type==="eof"&&e.fail("missing `}` at end of program"),s.push(Su(e)),e.skipTerminators();n.push({test:o,body:s})}return e.switchDepth--,e.next(),{type:"switch",expr:t,cases:n}}function xv(e){let t=e.accept("-")?-1:(e.accept("+"),1),n=e.tok;return n.type==="number"?(e.next(),{type:"num",value:t*Number(n.value)}):t===1&&n.type==="string"?(e.next(),{type:"str",value:n.value}):t===1&&n.type==="regex"?(e.next(),{type:"regex",source:n.value,re:Re(n.value,!1,r=>e.warn(r))}):e.fail(`case value must be a number, string or regex constant, found ${Ht(n)}`)}function wn(e,t){t==="break"&&e.loopDepth===0&&e.switchDepth===0&&e.fail("`break` is not allowed outside a loop or switch"),t==="continue"&&e.loopDepth===0&&e.fail("`continue` is not allowed outside a loop"),t==="next"&&e.context!=="main"&&e.context!=="function"&&e.fail(`\`next\` cannot be used in a ${e.context.toUpperCase()} action`),t==="nextfile"&&(e.context==="begin"||e.context==="end"||e.context==="endfile")&&e.fail(`\`nextfile\` cannot be used in a ${e.context.toUpperCase()} action`),t==="return"&&e.context!=="function"&&e.fail("`return` is only allowed inside a function"),e.next();let n={type:t};return(t==="exit"||t==="return")&&(n.value=W1(e)?$e(e,{}):null),br(e),n}function kv(e){e.next(),e.tok.type!=="name"&&e.fail(`\`delete\` needs an array name but found ${Ht(e.tok)}`);let t=e.next().value,n=ku(e);return br(e),{type:"delete",name:t,subs:n}}var V1=e=>e.is(";")||e.is("}")||e.is(">")||e.is(">>")||e.is("|")||e.is("|&")||e.tok.type==="newline"||e.tok.type==="eof";function K1(e,t){e.next();let n=null;if(e.is("(")){let o=e.i;e.next();let i=e.is(")")?[]:gn(e,{});e.accept(")")&&V1(e)?n=i:e.i=o}n===null&&(n=V1(e)?[]:gn(e,{noGt:!0})),t==="printf"&&n.length===0&&e.fail("printf needs a format string");let r=null;return(e.is("|")||e.is("|&"))&&e.fail(`output pipes (\`${t} ... | "cmd"\`) are not supported: ${Qr}`,`${t} | "cmd"`),(e.accept(">")||e.accept(">>"))&&(r=H1(e,{noGt:!0}),r.type==="str"&&!cv.has(r.value)&&e.fail(Eu(r.value),`${t} > FILE`)),br(e),{type:t,args:n,dest:r}}function Eu(e){return`cannot redirect output to \`${e}\`: the filesystem is read-only (only /dev/stdout, /dev/stderr and /dev/null). To print a comparison, parenthesize it: print (a > b)`}var G=class{constructor(t){this.s=t,this.number=void 0,this.numeric=void 0}},yr="[ \\t\\n\\r\\f\\v]*",th="[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?",vv=new RegExp(`^${yr}${th}${yr}$`,"u"),Sv=new RegExp(`^${yr}(${th})`,"u"),nh=new RegExp(`^${yr}([+-])(inf|nan)${yr}$`,"iu"),$u=e=>vv.test(e)||nh.test(e);function Q1(e){let t=Sv.exec(e);if(t)return Number(t[1]);let n=nh.exec(e);return n?n[2].toLowerCase()==="nan"?Number.NaN:n[1]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY:0}var Nu=()=>new $("attempt to use an array in a scalar context");function z(e){if(typeof e=="number")return e;if(e===void 0)return 0;if(e instanceof G)return e.number??=Q1(e.s);if(typeof e=="string")return Q1(e);throw Nu()}var jo=new Map;function rh(e,t){if(Number.isNaN(e))throw new $("formatting signed NaN is not supported",null,"signed NaN");if(!Number.isFinite(e))return e<0?"-inf":"+inf";if(Number.isInteger(e))return Math.abs(e)<2**53?String(e):BigInt(e).toString();let n=jo.get(t);if(n===void 0){jo.size>64&&jo.clear(),n=go(t);let r=n.filter(o=>typeof o!="string");if(r.length>1||r.some(o=>!"diouxXeEfFgG".includes(o.conv)||o.width==="*"||o.precision==="*"))throw new $("this numeric conversion format is not supported",null,"numeric conversion format");jo.set(t,n)}return n.map(r=>typeof r=="string"?r:Wt(e,r)).join("")}var oh=e=>typeof e=="string"?e:e instanceof G?e.s:"%.6g",Ev=e=>oh(e.globals.get("CONVFMT")),$v=e=>oh(e.globals.get("OFMT"));function L(e,t){if(typeof e=="string")return pt(t,e);if(e instanceof G)return pt(t,e.s);if(typeof e=="number")return rh(e,Ev(t));if(e===void 0)return"";throw Nu()}function pt(e,t){if(e.byteLocale&&/[\u0080-\u{10FFFF}]/u.test(t))throw new $("non-ASCII AWK text in a byte locale is not supported",null,"byte locale text");return t}function Gt(e,t=!1){return[...e].map(n=>{let r=t?n.toUpperCase():n.toLowerCase();if([...r].length!==1)throw new $("Unicode case expansion is not supported",null,"Unicode case mapping");return r}).join("")}function ih(e,t){return typeof e=="number"?rh(e,$v(t)):L(e,t)}var Au=e=>e.numeric??=$u(e.s),eh=e=>typeof e=="number"||e===void 0||e instanceof G&&Au(e),qe=e=>Ne(e.globals.get("IGNORECASE"));function Wo(e,t,n){if(eh(e)&&eh(t)){let i=z(e),s=z(t);return i<s?-1:i>s?1:i===s?0:Number.NaN}let r=L(e,n),o=L(t,n);return qe(n)&&(r=Gt(r),o=Gt(o)),j(r,o)}function Ne(e){if(typeof e=="number")return e!==0&&!Number.isNaN(e);if(typeof e=="string")return e!=="";if(e instanceof G)return Au(e)?z(e)!==0:e.s!=="";if(e===void 0)return!1;throw Nu()}var Ou=(e,t)=>Number.isSafeInteger(e)?String(e):L(e,t);function Cu(e){return e instanceof Map?"array":e===void 0?"untyped":typeof e=="number"?"number":e instanceof G&&Au(e)?"strnum":"string"}function sh(e,t,n){let{text:r}=e;if(e.pos>=r.length)return null;if(t==="")return Nv(e);let o,i;if(t.length===1){let u=r.indexOf(t,e.pos);i=u===-1?r.length:u,o=u===-1?r.length:u+1}else{let u=es(r,Re(t,n),e.pos);i=u?.start??r.length,o=u?.end??r.length}let s=r.slice(e.pos,i);return e.pos=o,{rec:s,rt:r.slice(i,o)}}function Nv(e){let{text:t}=e,n=e.pos;for(;t[n]===`
|
|
239
|
+
`;)n++;if(n>=t.length)return e.pos=n,null;let r=/\n\n+/gu;r.lastIndex=n;let o=r.exec(t);if(!o){e.pos=t.length;let i=t.slice(n).replace(/\n+$/u,"");return{rec:i,rt:t.slice(n+i.length)}}return e.pos=o.index+o[0].length,{rec:t.slice(n,o.index),rt:o[0]}}function Fu(e,t,n,r){if(e==="")return[];if(t instanceof ct)return ts(e,t);if(t===" "){let i=e.replace(/^[ \t\n]+|[ \t\n]+$/gu,"");return i===""?[]:i.split(/[ \t\n]+/u)}if(t==="")return[...e];if(t.length===1&&(!n||t===`
|
|
240
240
|
`))return e.split(t);if(n&&t==="^")throw new $('paragraph splitting with FS="^" is not supported',null,"paragraph FS caret");let o=t.length===1?`[${"^$.[]|()*+?{}\\".includes(t)?"\\"+t:t}
|
|
241
|
-
]`:t;return es(e,Re(o,r))}function ah(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let o=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),i=o?.[1]===void 0?0:Number(o[1]),s=o?.[2]==="*"?4294967295:Number(o?.[2]);if(!o||o[1]!==void 0&&i===0||i>4294967295||!(s>0&&s<=4294967295)||o[2]==="*"&&r!==t.length-1)throw new $(`invalid FIELDWIDTHS value \`${e}'`);return{skip:i,width:s}})}function Av(e,t){let n=[...e],r=[],o=0;for(let{skip:i,width:s}of t){if(o>=n.length)break;o+=i,r.push(n.slice(o,o+s).join("")),o+=s}return r}function Ov(e,t){let n=[],r=0;for(;r<e.length;){let o=t.search(e.slice(r));if(n.length>0&&o?.end===0&&(r+=Le(e,r),o=t.search(e.slice(r))),!o)break;n.push(e.slice(r+o.start,r+o.end)),r+=o.end}return n}function lh(e,t){let n=qe(e);return e.fieldMode==="FIELDWIDTHS"?Av(t,e.widths):e.fieldMode==="FPAT"?Ov(t,Re(L(e.globals.get("FPAT"),e),n,e.warn)):Fu(t,L(e.globals.get("FS"),e),L(e.globals.get("RS"),e)==="",n)}var Cv=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,Tu=e=>e!==void 0&&e.type==="exit",Wo=class{constructor(t,n){this.ctx=t,this.stdin=n,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(t){for(;this.exitSignal===void 0;){if(this.src){let n=uh(this.src,L(t.globals.get("RS"),t),qe(t));if(n!==null)return t.globals.set("NR",z(t.globals.get("NR"))+1),t.globals.set("FNR",z(t.globals.get("FNR"))+1),t.globals.set("RT",n.rt),n.rec;this.closeFile(t);continue}if(!this.open(t))return null}return null}open(t){for(;this.idx<Math.trunc(z(t.globals.get("ARGC")));){if(++t.steps>qn)throw new $("input operand scan exceeded execution limit",null,"execution limit");let n=L(t.globals.get("ARGV").get(String(this.idx++)),t);if(n==="")continue;t.globals.set("ARGIND",this.idx-1);let r=Cv.exec(n);if(r){t.assign(r[1],new G(hr(r[2],t.warn)));continue}this.sawFile=!0;let{text:o,error:i}=this.readOperand(n);if(i==="Is a directory"){this.failFile(t,n,i),this.exitSignal===void 0&&t.warn(`command line argument \`${n}' is a directory: skipped`);continue}if(i){let s=this.failFile(t,n,i);if(s!==void 0&&s.type==="nextfile")continue;if(this.exitSignal!==void 0)return!1;throw new $(`${n}: ${i}`)}if(this.use(t,n,o))return!0}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(t,"-",this.takeStdin()))}readOperand(t){if(t==="/dev/null")return{text:""};if(t==="-"||t==="/dev/stdin")return{text:t==="/dev/stdin"&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:n,error:r}=P(this.ctx,"awk",t);return this.ctx.fs.isDir(n)?{error:"Is a directory"}:r?{error:r}:{text:this.ctx.fs.readFile(n)}}takeStdin(){let t=this.stdin;return this.stdin="",q(this.ctx),t}use(t,n,r){this.src={text:r,pos:0},t.globals.set("FILENAME",n),t.globals.set("FNR",0),t.globals.set("ERRNO","");let o=t.fileRule("begin");return Tu(o)?(this.exitSignal=o,this.src=null,!1):o!==void 0&&o.type==="nextfile"?(this.closeFile(t),!1):(pt(t,r),!0)}failFile(t,n,r){if(t.globals.set("ERRNO",r),!t.hasFileRules)return;t.globals.set("FILENAME",n),t.globals.set("FNR",0);let o=t.fileRule("begin");return Tu(o)&&(this.exitSignal=o),o}closeFile(t){this.src=null;let n=t.fileRule("end");Tu(n)&&(this.exitSignal=n)}readNamed(t,n){let r=this.readers.get(n);if(!r){let{text:i,error:s}=this.readOperand(n);if(s)return t.globals.set("ERRNO",s),{status:-1};r={text:pt(t,i),pos:0},this.readers.set(n,r)}let o=uh(r,L(t.globals.get("RS"),t),qe(t));return o===null?{status:0}:(t.globals.set("RT",o.rt),{status:1,record:o.rec})}close(t,n){return this.readers.delete(n)?0:(t.globals.set("ERRNO","close of redirection that was never opened"),-1)}};var Iv=(e,t)=>({isRef:!0,scope:e,name:t}),xr=e=>typeof e=="object"&&e!==null&&e.isRef===!0,kr=class extends Error{constructor(t){super(t.type),this.signal=t}},dh=e=>new $(`attempt to use array \`${e}\` in a scalar context`);function qo(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function Tv(e){let t=e;for(;xr(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function bn(e,t){let n=qo(e,t).get(t);return xr(n)?Tv(n):n}var Fv=new Set(["FS","FIELDWIDTHS","FPAT"]);function zo(e,t,n){let r=qo(e,t);if(r.get(t)instanceof Map)throw dh(t);if(r===e.globals){if(t==="NF"){_v(e,n);return}if(t==="FIELDWIDTHS"&&(e.widths=ah(L(n,e))),(t==="FPAT"||(t==="FS"||t==="RS")&&L(n,e).length>1)&&Re(L(n,e),qe(e),e.warn,e.tables),Fv.has(t)){e.fieldMode=t;let o=e.globals.get("PROCINFO");o instanceof Map&&o.set("FS",t)}}r.set(t,n)}function ht(e,t){let n=qo(e,t),r=t,o=n,i=o.get(r);if(i instanceof Map)return i;let s=xr(i);for(;xr(i);)o=i.scope,r=i.name,i=o.get(r);if(!(i instanceof Map)){if(i!==void 0)throw new $(`attempt to use scalar \`${r}\` as an array`);i=new Map,o.set(r,i)}return s&&n.set(t,i),i}function Ho(e,t,n=new G(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...lh(e,t).map(r=>new G(r))],e.nf=e.fields.length-1,e.globals.set("NF",e.nf)}function ph(e){let t=L(e.globals.get("OFS"),e);e.record=e.fields.slice(1).map(n=>L(n,e)).join(t),e.recordValue=e.record}function hh(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function Lv(e,t,n){if(t===0){let r=L(n,e);Ho(e,r,typeof n=="number"?r:n);return}for(;e.nf<t;)e.fields[++e.nf]="";e.fields[t]=n,e.globals.set("NF",e.nf),ph(e)}function _v(e,t){let n=Math.trunc(z(t));if(n<0)throw new $(`NF set to negative value ${n}`);for(;e.nf<n;)e.fields[++e.nf]="";e.fields.length=n+1,e.nf=n,e.globals.set("NF",n),ph(e)}function mh(e,t){let n=z(T(e,t));if(!(n>=0))throw new $(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function vr(e,t){if(t.length===1)return Ou(T(e,t[0]),e);let n=L(e.globals.get("SUBSEP"),e);return t.map(r=>Ou(T(e,r),e)).join(n)}function Lu(e,t){return t.type==="var"?t:t.type==="index"?{type:"index",arr:ht(e,t.name),key:vr(e,t.subs)}:{type:"field",i:mh(e,t.index)}}function gh(e,t){return t.type==="var"?wh(bn(e,t.name),t.name):t.type==="index"?t.arr.get(t.key):hh(e,t.i)}function _u(e,t,n){t.type==="var"?zo(e,t.name,n):t.type==="index"?t.arr.set(t.key,n):Lv(e,t.i,n)}function Ru(e,t,n){_u(e,Lu(e,t),n)}function fh(e,t,n){if(n===0&&(e==="/"||e==="%"))throw new $(e==="/"?"division by zero attempted":"division by zero attempted in `%`");return eo(e,t,n)}var Rv={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function mt(e,t){let n=qe(e);return t.type==="regex"?n?Re(t.source,!0,null,e.tables):t.re:Re(L(T(e,t),e),n,e.warn,e.tables)}function wh(e,t){if(e instanceof Map)throw dh(t);return e}function ch(e,t,n){let r=Lu(e,t.target),o=z(gh(e,r)),i=t.op==="++"?o+1:o-1;return _u(e,r,i),n?o:i}function T(e,t){switch(t.type){case"num":case"str":return t.value;case"regex":return mt(e,t).test(e.record)?1:0;case"var":return wh(bn(e,t.name),t.name);case"index":{let n=ht(e,t.name),r=vr(e,t.subs),o=n.get(r);return o===void 0&&n.set(r,void 0),o}case"field":return hh(e,mh(e,t.index));case"assign":{let n=Lu(e,t.target),r=T(e,t.value);if(r instanceof Map)throw new $("attempt to use an array in a scalar context");return t.op!=="="&&(r=fh(t.op[0],z(gh(e,n)),z(r))),_u(e,n,r),r}case"cond":return T(e,Ne(T(e,t.test))?t.consequent:t.alternate);case"or":return Ne(T(e,t.left))||Ne(T(e,t.right))?1:0;case"and":return Ne(T(e,t.left))&&Ne(T(e,t.right))?1:0;case"not":return Ne(T(e,t.expr))?0:1;case"neg":return-z(T(e,t.expr));case"plus":return z(T(e,t.expr));case"binary":return fh(t.op,z(T(e,t.left)),z(T(e,t.right)));case"concat":return L(T(e,t.left),e)+L(T(e,t.right),e);case"compare":return Rv[t.op](jo(T(e,t.left),T(e,t.right),e))?1:0;case"match":{let n=L(T(e,t.left),e);return mt(e,t.right).test(n)===t.negate?0:1}case"in":return ht(e,t.array).has(vr(e,t.keys))?1:0;case"preinc":return ch(e,t,!1);case"postinc":return ch(e,t,!0);case"call":return Mv(e,t);case"builtin":return e.callBuiltin(e,t);case"getline":return Dv(e,t);default:throw new $(`unknown expression: ${t.type}`)}}function Mv(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new $(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new $(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=Yi)throw new $(`function call nesting deeper than ${Yi} levels (runaway recursion?)`,null,"call depth limit");let r=e.frame,o=new Map;for(let i=0;i<n.params.length;i++)o.set(n.params[i],i<t.args.length?Pv(e,t.args[i]):void 0);e.frame=o,e.callDepth++;try{let i=e.execStmts(e,n.body);if(i===void 0||i.type==="return")return i?.value;throw new kr(i)}finally{e.frame=r,e.callDepth--}}function Pv(e,t){if(t.type!=="var")return T(e,t);let n=qo(e,t.name),r=n.get(t.name);return r instanceof Map||xr(r)?r:r===void 0?Iv(n,t.name):r}function Dv(e,t){let n;if(t.file===null){if(n=e.input.next(e),n===null)return 0}else{let r=e.input.readNamed(e,L(T(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?Ho(e,n):Ru(e,t.target,new G(n)),1}var Qe=(e,t)=>z(T(e,t)),Mu=2**32;function bh(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var xh=()=>({seed:1,state:bh(1)});function Bv(e){e.rng.state=(e.rng.state+1831565813)%Mu;let t=e.rng.state;t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61);let n=t^t>>>14;return(n<0?n+Mu:n)/Mu}function Uv(e,t){let n=e.rng.seed,r=t.length>0?Qe(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=bh(r),n}function jv(e,t){let n=Qe(e,t[0]);return n<0&&e.warn(`log: received negative argument ${L(n,e)}`),Math.log(n)}function Wv(e,t){let n=Qe(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${L(n,e)}`),Math.sqrt(n)}function qv(e,t){let n=Qe(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${L(n,e)} is out of range`),r}function zv(e,t){let n=T(e,t[0]);if(typeof n=="number")return n;let r=n instanceof G?n.s:L(n,e),o=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(o)return o[1]===""?0:Number.parseInt(o[1],16);let i=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return i?Number.parseInt(i[0],8):z(new G(r))}function Sr(e,t,n,r){let o=Qe(e,n);if(o<0)throw new $(`${t}: argument ${r} negative value ${L(o,e)} is not allowed`);if(!Number.isFinite(o))throw new $(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(o)))}function Du(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function Pu(e,t){return(n,r)=>{if(r.length<2)throw new $(`${e}: called with less than two arguments`);let o=Sr(n,e,r[0],1);for(let i=1;i<r.length;i++)o=t(o,Sr(n,e,r[i],i+1));return Du(o)}}function yh(e,t){return(n,r)=>{let o=Sr(n,e,r[0],1),i=Sr(n,e,r[1],2)%64n;return Du(BigInt.asUintN(64,t?o<<i:o>>i))}}var kh={__proto__:null,sin:(e,t)=>Math.sin(Qe(e,t[0])),cos:(e,t)=>Math.cos(Qe(e,t[0])),atan2:(e,t)=>Math.atan2(Qe(e,t[0]),Qe(e,t[1])),exp:qv,log:jv,sqrt:Wv,int:(e,t)=>Math.trunc(Qe(e,t[0])),rand:Bv,srand:Uv,systime:()=>Math.floor(Date.now()/1e3),strtonum:zv,and:Pu("and",(e,t)=>e&t),or:Pu("or",(e,t)=>e|t),xor:Pu("xor",(e,t)=>e^t),lshift:yh("lshift",!0),rshift:yh("rshift",!1),compl:(e,t)=>Du(BigInt.asUintN(64,~Sr(e,"compl",t[0],1)))};var Go=new Map;function Hv(e){let t=Go.get(e);return t||(Go.size>=256&&Go.clear(),t=go(e),Go.set(e,t)),t}function Xo(e,t,n){let r=0,o=()=>{if(r>=n.length)throw new $("printf: not enough arguments to satisfy format string");return n[r++]},i="";for(let s of Hv(t)){if(typeof s=="string"){i+=s;continue}let u={...s};if(s.width==="*"){let a=Math.trunc(z(o()));a<0?(u.minus=!0,u.width=-a):u.width=a}if(s.precision==="*"){let a=Math.trunc(z(o()));u.precision=a<0?null:a}if(u.width>Ce||u.precision>Ce)throw new $(`printf: field width or precision above ${Ce} is not supported`,null,"format size limit");i+=Gv(e,u,o())}return i}function Gv(e,t,n){if(t.conv==="s"){let r=L(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join("")),Nt("",r,t,!1)}return t.conv==="c"?Nt("",pt(e,Xv(n)),t,!1):Wt(z(n),t)}function Xv(e){if(typeof e=="number"||e instanceof G&&$u(e.s)){let r=Math.trunc(z(e));if(!Ze(r))throw new $("printf: character code outside Unicode scalar values is not supported",null,"character code");return String.fromCodePoint(r)}let n=e instanceof G?e.s:e??"";return n===""?"\0":String.fromCodePoint(n.codePointAt(0))}var we=(e,t)=>L(T(e,t),e),vh=(e,t)=>z(T(e,t)),Zv={type:"field",index:{type:"num",value:0}};function Yv(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"){if(e[r+1]==="\\"&&e[r+2]==="\\"&&(e[r+3]==="&"||e[r+3]==="\\")){n+="\\"+e[r+3],r+=3;continue}if(e[r+1]==="\\"&&e[r+2]==="&"){n+="\\"+t,r+=2;continue}if(e[r+1]==="&"){n+="&",r++;continue}}n+=o==="&"?t:o}return n}function Sh(e,t,n){let r=mt(e,t[0]),o=we(e,t[1]),i=t[2]??Zv,s=we(e,i),{out:u,count:a}=zn(s,r,(l,f)=>Yv(o,s.slice(l,f)),n?"global":"first");return a>0&&Ru(e,i,u),a}function Vv(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"&&r+1===e.length)throw new $("gensub with a trailing replacement backslash is not supported",null,"gensub trailing backslash");if(o==="\\"&&r+1<e.length){let i=e[++r];i>="0"&&i<="9"?n+=t[Number(i)]?.text??"":n+=i;continue}n+=o==="&"?t[0].text:o}return n}function Kv(e,t){let n=mt(e,t[0]),r=we(e,t[1]),o=T(e,t[2]),i=L(o,e),s=i.startsWith("g")||i.startsWith("G"),u=0;s||(u=Math.trunc(z(o)),u<1&&(e.warn(`gensub: third argument \`${i}' treated as 1`),u=1));let a=t[3]?we(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return zn(a,n,(f,c,d)=>!s&&d!==u?null:Vv(r,l?n.groups(a,f,c):[{text:a.slice(f,c)}]),s?"global":"nth").out}function Jv(e,t){let n=we(e,t[0]),r=mt(e,t[1]),o=r.search(n,0),i=o?Array.from(n.slice(0,o.start)).length+1:0;if(e.globals.set("RSTART",i),e.globals.set("RLENGTH",o?Array.from(n.slice(o.start,o.end)).length:-1),t[2]){let s=ht(e,t[2].name);if(s.clear(),o){let u=L(e.globals.get("SUBSEP"),e);r.groups(n,o.start,o.end).forEach((a,l)=>{a!==void 0&&(s.set(String(l),new G(a.text)),s.set(`${l}${u}start`,Array.from(n.slice(0,a.start)).length+1),s.set(`${l}${u}length`,[...a.text].length))})}}return i}function Qv(e,t){let n=we(e,t[0]),r=ht(e,t[1].name),o;t[2]===void 0?o=L(e.globals.get("FS"),e):t[2].type==="regex"?o=mt(e,t[2]):o=we(e,t[2]);let i=Fu(n,o,!1,qe(e));return r.clear(),i.forEach((s,u)=>r.set(String(u+1),new G(s))),i.length}function eS(e,t){let n=[...we(e,t[0])],r=Math.trunc(vh(e,t[1])),o=Number.isNaN(r)?1:Math.max(r,1),i=n.length+1;if(t[2]){let s=Math.trunc(vh(e,t[2]));if(!(s>=1))return"";i=Math.min(i,o+s)}return i>o?n.slice(o-1,i-1).join(""):""}function tS(e,t){if(t.length===0)return[...e.record].length;if(t[0].type==="var"){let n=bn(e,t[0].name);return n instanceof Map?n.size:[...L(n,e)].length}return[...we(e,t[0])].length}function nS(e,t){let n=we(e,t[0]),r=we(e,t[1]);qe(e)&&(n=Gt(n),r=Gt(r));let o=n.indexOf(r);return o<0?0:Array.from(n.slice(0,o)).length+1}function rS(e,t){let n=we(e,t[0]);return n==="/dev/stdout"||n==="/dev/stderr"||n==="/dev/null"?0:e.input.close(e,n)}var oS=(e,t)=>t[0].type==="var"?Cu(bn(e,t[0].name)):Cu(T(e,t[0])),iS={__proto__:null,...kh,length:tS,substr:eS,index:nS,split:Qv,sub:(e,t)=>Sh(e,t,!1),gsub:(e,t)=>Sh(e,t,!0),gensub:Kv,match:Jv,sprintf:(e,t)=>Xo(e,we(e,t[0]),t.slice(1).map(n=>T(e,n))),tolower:(e,t)=>Gt(we(e,t[0])),toupper:(e,t)=>Gt(we(e,t[0]),!0),close:rS,fflush:()=>0,typeof:oS,isarray:(e,t)=>t[0].type==="var"&&bn(e,t[0].name)instanceof Map?1:0};function Eh(e,t){let n=iS[t.name];if(!n)throw new $(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var Yo={type:"break"},Uu={type:"continue"},sS={type:"next"},uS={type:"nextfile"},aS={type:"exit"};function $h(e,t,n,r){let o=new Map([["0","awk"]]);r.forEach((u,a)=>o.set(String(a+1),new G(u)));let i=new Map([["FS"," "],["OFS"," "],["ORS",`
|
|
241
|
+
]`:t;return ts(e,Re(o,r))}function uh(e){let t=e.split(/[ \t]+/u).filter(Boolean);return t.map((n,r)=>{let o=/^(?:(\+?\d+):)?(\+?\d+|\*)$/u.exec(n),i=o?.[1]===void 0?0:Number(o[1]),s=o?.[2]==="*"?4294967295:Number(o?.[2]);if(!o||o[1]!==void 0&&i===0||i>4294967295||!(s>0&&s<=4294967295)||o[2]==="*"&&r!==t.length-1)throw new $(`invalid FIELDWIDTHS value \`${e}'`);return{skip:i,width:s}})}function Av(e,t){let n=[...e],r=[],o=0;for(let{skip:i,width:s}of t){if(o>=n.length)break;o+=i,r.push(n.slice(o,o+s).join("")),o+=s}return r}function Ov(e,t){let n=[],r=0;for(;r<e.length;){let o=t.search(e.slice(r));if(n.length>0&&o?.end===0&&(r+=Le(e,r),o=t.search(e.slice(r))),!o)break;n.push(e.slice(r+o.start,r+o.end)),r+=o.end}return n}function ah(e,t){let n=qe(e);return e.fieldMode==="FIELDWIDTHS"?Av(t,e.widths):e.fieldMode==="FPAT"?Ov(t,Re(L(e.globals.get("FPAT"),e),n,e.warn)):Fu(t,L(e.globals.get("FS"),e),L(e.globals.get("RS"),e)==="",n)}var Cv=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u,Tu=e=>e!==void 0&&e.type==="exit",qo=class{constructor(t,n){this.ctx=t,this.stdin=n,this.idx=1,this.src=null,this.sawFile=!1,this.exitSignal=void 0,this.readers=new Map}next(t){for(;this.exitSignal===void 0;){if(this.src){let n=sh(this.src,L(t.globals.get("RS"),t),qe(t));if(n!==null)return t.globals.set("NR",z(t.globals.get("NR"))+1),t.globals.set("FNR",z(t.globals.get("FNR"))+1),t.globals.set("RT",n.rt),n.rec;this.closeFile(t);continue}if(!this.open(t))return null}return null}open(t){for(;this.idx<Math.trunc(z(t.globals.get("ARGC")));){if(++t.steps>qn)throw new $("input operand scan exceeded execution limit",null,"execution limit");let n=L(t.globals.get("ARGV").get(String(this.idx++)),t);if(n==="")continue;t.globals.set("ARGIND",this.idx-1);let r=Cv.exec(n);if(r){t.assign(r[1],new G(hr(r[2],t.warn)));continue}this.sawFile=!0;let{text:o,error:i}=this.readOperand(n);if(i==="Is a directory"){this.failFile(t,n,i),this.exitSignal===void 0&&t.warn(`command line argument \`${n}' is a directory: skipped`);continue}if(i){let s=this.failFile(t,n,i);if(s!==void 0&&s.type==="nextfile")continue;if(this.exitSignal!==void 0)return!1;throw new $(`${n}: ${i}`)}if(this.use(t,n,o))return!0}return this.sawFile||this.exitSignal!==void 0?!1:(this.sawFile=!0,this.use(t,"-",this.takeStdin()))}readOperand(t){if(t==="/dev/null")return{text:""};if(t==="-"||t==="/dev/stdin")return{text:t==="/dev/stdin"&&this.ctx.stdinFile?this.ctx.stdinOrigin:this.takeStdin()};let{path:n,error:r}=P(this.ctx,"awk",t);return this.ctx.fs.isDir(n)?{error:"Is a directory"}:r?{error:r}:{text:this.ctx.fs.readFile(n)}}takeStdin(){let t=this.stdin;return this.stdin="",q(this.ctx),t}use(t,n,r){this.src={text:r,pos:0},t.globals.set("FILENAME",n),t.globals.set("FNR",0),t.globals.set("ERRNO","");let o=t.fileRule("begin");return Tu(o)?(this.exitSignal=o,this.src=null,!1):o!==void 0&&o.type==="nextfile"?(this.closeFile(t),!1):(pt(t,r),!0)}failFile(t,n,r){if(t.globals.set("ERRNO",r),!t.hasFileRules)return;t.globals.set("FILENAME",n),t.globals.set("FNR",0);let o=t.fileRule("begin");return Tu(o)&&(this.exitSignal=o),o}closeFile(t){this.src=null;let n=t.fileRule("end");Tu(n)&&(this.exitSignal=n)}readNamed(t,n){let r=this.readers.get(n);if(!r){let{text:i,error:s}=this.readOperand(n);if(s)return t.globals.set("ERRNO",s),{status:-1};r={text:pt(t,i),pos:0},this.readers.set(n,r)}let o=sh(r,L(t.globals.get("RS"),t),qe(t));return o===null?{status:0}:(t.globals.set("RT",o.rt),{status:1,record:o.rec})}close(t,n){return this.readers.delete(n)?0:(t.globals.set("ERRNO","close of redirection that was never opened"),-1)}};var Iv=(e,t)=>({isRef:!0,scope:e,name:t}),xr=e=>typeof e=="object"&&e!==null&&e.isRef===!0,kr=class extends Error{constructor(t){super(t.type),this.signal=t}},ch=e=>new $(`attempt to use array \`${e}\` in a scalar context`);function zo(e,t){let n=e.frame;return n!==void 0&&n.has(t)?n:e.globals}function Tv(e){let t=e;for(;xr(t);)t=t.scope.get(t.name);return t instanceof Map?t:void 0}function yn(e,t){let n=zo(e,t).get(t);return xr(n)?Tv(n):n}var Fv=new Set(["FS","FIELDWIDTHS","FPAT"]);function Ho(e,t,n){let r=zo(e,t);if(r.get(t)instanceof Map)throw ch(t);if(r===e.globals){if(t==="NF"){_v(e,n);return}if(t==="FIELDWIDTHS"&&(e.widths=uh(L(n,e))),(t==="FPAT"||(t==="FS"||t==="RS")&&L(n,e).length>1)&&Re(L(n,e),qe(e),e.warn,e.tables),Fv.has(t)){e.fieldMode=t;let o=e.globals.get("PROCINFO");o instanceof Map&&o.set("FS",t)}}r.set(t,n)}function ht(e,t){let n=zo(e,t),r=t,o=n,i=o.get(r);if(i instanceof Map)return i;let s=xr(i);for(;xr(i);)o=i.scope,r=i.name,i=o.get(r);if(!(i instanceof Map)){if(i!==void 0)throw new $(`attempt to use scalar \`${r}\` as an array`);i=new Map,o.set(r,i)}return s&&n.set(t,i),i}function Go(e,t,n=new G(t)){e.record=t,e.recordValue=n,e.fields=[void 0,...ah(e,t).map(r=>new G(r))],e.nf=e.fields.length-1,e.globals.set("NF",e.nf)}function dh(e){let t=L(e.globals.get("OFS"),e);e.record=e.fields.slice(1).map(n=>L(n,e)).join(t),e.recordValue=e.record}function ph(e,t){return t===0?e.recordValue:t<=e.nf?e.fields[t]:void 0}function Lv(e,t,n){if(t===0){let r=L(n,e);Go(e,r,typeof n=="number"?r:n);return}for(;e.nf<t;)e.fields[++e.nf]="";e.fields[t]=n,e.globals.set("NF",e.nf),dh(e)}function _v(e,t){let n=Math.trunc(z(t));if(n<0)throw new $(`NF set to negative value ${n}`);for(;e.nf<n;)e.fields[++e.nf]="";e.fields.length=n+1,e.nf=n,e.globals.set("NF",n),dh(e)}function hh(e,t){let n=z(T(e,t));if(!(n>=0))throw new $(`attempt to access field ${Number.isNaN(n)?n:Math.trunc(n)}`);return Math.trunc(n)}function vr(e,t){if(t.length===1)return Ou(T(e,t[0]),e);let n=L(e.globals.get("SUBSEP"),e);return t.map(r=>Ou(T(e,r),e)).join(n)}function Lu(e,t){return t.type==="var"?t:t.type==="index"?{type:"index",arr:ht(e,t.name),key:vr(e,t.subs)}:{type:"field",i:hh(e,t.index)}}function mh(e,t){return t.type==="var"?gh(yn(e,t.name),t.name):t.type==="index"?t.arr.get(t.key):ph(e,t.i)}function _u(e,t,n){t.type==="var"?Ho(e,t.name,n):t.type==="index"?t.arr.set(t.key,n):Lv(e,t.i,n)}function Ru(e,t,n){_u(e,Lu(e,t),n)}function lh(e,t,n){if(n===0&&(e==="/"||e==="%"))throw new $(e==="/"?"division by zero attempted":"division by zero attempted in `%`");return eo(e,t,n)}var Rv={__proto__:null,"<":e=>e<0,"<=":e=>e<=0,"==":e=>e===0,"!=":e=>e!==0,">":e=>e>0,">=":e=>e>=0};function mt(e,t){let n=qe(e);return t.type==="regex"?n?Re(t.source,!0,null,e.tables):t.re:Re(L(T(e,t),e),n,e.warn,e.tables)}function gh(e,t){if(e instanceof Map)throw ch(t);return e}function fh(e,t,n){let r=Lu(e,t.target),o=z(mh(e,r)),i=t.op==="++"?o+1:o-1;return _u(e,r,i),n?o:i}function T(e,t){switch(t.type){case"num":case"str":return t.value;case"regex":return mt(e,t).test(e.record)?1:0;case"var":return gh(yn(e,t.name),t.name);case"index":{let n=ht(e,t.name),r=vr(e,t.subs),o=n.get(r);return o===void 0&&n.set(r,void 0),o}case"field":return ph(e,hh(e,t.index));case"assign":{let n=Lu(e,t.target),r=T(e,t.value);if(r instanceof Map)throw new $("attempt to use an array in a scalar context");return t.op!=="="&&(r=lh(t.op[0],z(mh(e,n)),z(r))),_u(e,n,r),r}case"cond":return T(e,Ne(T(e,t.test))?t.consequent:t.alternate);case"or":return Ne(T(e,t.left))||Ne(T(e,t.right))?1:0;case"and":return Ne(T(e,t.left))&&Ne(T(e,t.right))?1:0;case"not":return Ne(T(e,t.expr))?0:1;case"neg":return-z(T(e,t.expr));case"plus":return z(T(e,t.expr));case"binary":return lh(t.op,z(T(e,t.left)),z(T(e,t.right)));case"concat":return L(T(e,t.left),e)+L(T(e,t.right),e);case"compare":return Rv[t.op](Wo(T(e,t.left),T(e,t.right),e))?1:0;case"match":{let n=L(T(e,t.left),e);return mt(e,t.right).test(n)===t.negate?0:1}case"in":return ht(e,t.array).has(vr(e,t.keys))?1:0;case"preinc":return fh(e,t,!1);case"postinc":return fh(e,t,!0);case"call":return Mv(e,t);case"builtin":return e.callBuiltin(e,t);case"getline":return Dv(e,t);default:throw new $(`unknown expression: ${t.type}`)}}function Mv(e,t){let n=e.program.functions.get(t.name);if(n===void 0)throw new $(`function \`${t.name}\` not defined`);if(t.args.length>n.params.length)throw new $(`function \`${t.name}\` called with ${t.args.length} arguments, but it accepts only ${n.params.length}`);if(e.callDepth>=Vi)throw new $(`function call nesting deeper than ${Vi} levels (runaway recursion?)`,null,"call depth limit");let r=e.frame,o=new Map;for(let i=0;i<n.params.length;i++)o.set(n.params[i],i<t.args.length?Pv(e,t.args[i]):void 0);e.frame=o,e.callDepth++;try{let i=e.execStmts(e,n.body);if(i===void 0||i.type==="return")return i?.value;throw new kr(i)}finally{e.frame=r,e.callDepth--}}function Pv(e,t){if(t.type!=="var")return T(e,t);let n=zo(e,t.name),r=n.get(t.name);return r instanceof Map||xr(r)?r:r===void 0?Iv(n,t.name):r}function Dv(e,t){let n;if(t.file===null){if(n=e.input.next(e),n===null)return 0}else{let r=e.input.readNamed(e,L(T(e,t.file),e));if(r.status!==1)return r.status;n=r.record}return t.target===null?Go(e,n):Ru(e,t.target,new G(n)),1}var Qe=(e,t)=>z(T(e,t)),Mu=2**32;function bh(e){return Number(BigInt.asUintN(32,BigInt(Math.trunc(e))))}var yh=()=>({seed:1,state:bh(1)});function Bv(e){e.rng.state=(e.rng.state+1831565813)%Mu;let t=e.rng.state;t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61);let n=t^t>>>14;return(n<0?n+Mu:n)/Mu}function Uv(e,t){let n=e.rng.seed,r=t.length>0?Qe(e,t[0]):Math.floor(Date.now()/1e3);return e.rng.seed=r,e.rng.state=bh(r),n}function jv(e,t){let n=Qe(e,t[0]);return n<0&&e.warn(`log: received negative argument ${L(n,e)}`),Math.log(n)}function Wv(e,t){let n=Qe(e,t[0]);return n<0&&e.warn(`sqrt: called with negative argument ${L(n,e)}`),Math.sqrt(n)}function qv(e,t){let n=Qe(e,t[0]),r=Math.exp(n);return Number.isFinite(n)&&!Number.isFinite(r)&&e.warn(`exp: argument ${L(n,e)} is out of range`),r}function zv(e,t){let n=T(e,t[0]);if(typeof n=="number")return n;let r=n instanceof G?n.s:L(n,e),o=/^0[xX]([0-9a-fA-F]*)/u.exec(r);if(o)return o[1]===""?0:Number.parseInt(o[1],16);let i=/^0[0-7]+(?![.\deE0-9])/u.exec(r);return i?Number.parseInt(i[0],8):z(new G(r))}function Sr(e,t,n,r){let o=Qe(e,n);if(o<0)throw new $(`${t}: argument ${r} negative value ${L(o,e)} is not allowed`);if(!Number.isFinite(o))throw new $(`${t}: argument ${r} is not a finite number`);return BigInt.asUintN(64,BigInt(Math.trunc(o)))}function Du(e){let t=e;for(;t>0n&&BigInt(Number(t))!==t;)t&=(1n<<BigInt(t.toString(2).length-1))-1n;return Number(t)}function Pu(e,t){return(n,r)=>{if(r.length<2)throw new $(`${e}: called with less than two arguments`);let o=Sr(n,e,r[0],1);for(let i=1;i<r.length;i++)o=t(o,Sr(n,e,r[i],i+1));return Du(o)}}function wh(e,t){return(n,r)=>{let o=Sr(n,e,r[0],1),i=Sr(n,e,r[1],2)%64n;return Du(BigInt.asUintN(64,t?o<<i:o>>i))}}var xh={__proto__:null,sin:(e,t)=>Math.sin(Qe(e,t[0])),cos:(e,t)=>Math.cos(Qe(e,t[0])),atan2:(e,t)=>Math.atan2(Qe(e,t[0]),Qe(e,t[1])),exp:qv,log:jv,sqrt:Wv,int:(e,t)=>Math.trunc(Qe(e,t[0])),rand:Bv,srand:Uv,systime:()=>Math.floor(Date.now()/1e3),strtonum:zv,and:Pu("and",(e,t)=>e&t),or:Pu("or",(e,t)=>e|t),xor:Pu("xor",(e,t)=>e^t),lshift:wh("lshift",!0),rshift:wh("rshift",!1),compl:(e,t)=>Du(BigInt.asUintN(64,~Sr(e,"compl",t[0],1)))};var Xo=new Map;function Hv(e){let t=Xo.get(e);return t||(Xo.size>=256&&Xo.clear(),t=go(e),Xo.set(e,t)),t}function Zo(e,t,n){let r=0,o=()=>{if(r>=n.length)throw new $("printf: not enough arguments to satisfy format string");return n[r++]},i="";for(let s of Hv(t)){if(typeof s=="string"){i+=s;continue}let u={...s};if(s.width==="*"){let a=Math.trunc(z(o()));a<0?(u.minus=!0,u.width=-a):u.width=a}if(s.precision==="*"){let a=Math.trunc(z(o()));u.precision=a<0?null:a}if(u.width>Ce||u.precision>Ce)throw new $(`printf: field width or precision above ${Ce} is not supported`,null,"format size limit");i+=Gv(e,u,o())}return i}function Gv(e,t,n){if(t.conv==="s"){let r=L(n,e);return t.precision!==null&&(r=[...r].slice(0,t.precision).join("")),Nt("",r,t,!1)}return t.conv==="c"?Nt("",pt(e,Xv(n)),t,!1):Wt(z(n),t)}function Xv(e){if(typeof e=="number"||e instanceof G&&$u(e.s)){let r=Math.trunc(z(e));if(!Ze(r))throw new $("printf: character code outside Unicode scalar values is not supported",null,"character code");return String.fromCodePoint(r)}let n=e instanceof G?e.s:e??"";return n===""?"\0":String.fromCodePoint(n.codePointAt(0))}var we=(e,t)=>L(T(e,t),e),kh=(e,t)=>z(T(e,t)),Zv={type:"field",index:{type:"num",value:0}};function Yv(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"){if(e[r+1]==="\\"&&e[r+2]==="\\"&&(e[r+3]==="&"||e[r+3]==="\\")){n+="\\"+e[r+3],r+=3;continue}if(e[r+1]==="\\"&&e[r+2]==="&"){n+="\\"+t,r+=2;continue}if(e[r+1]==="&"){n+="&",r++;continue}}n+=o==="&"?t:o}return n}function vh(e,t,n){let r=mt(e,t[0]),o=we(e,t[1]),i=t[2]??Zv,s=we(e,i),{out:u,count:a}=zn(s,r,(l,f)=>Yv(o,s.slice(l,f)),n?"global":"first");return a>0&&Ru(e,i,u),a}function Vv(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="\\"&&r+1===e.length)throw new $("gensub with a trailing replacement backslash is not supported",null,"gensub trailing backslash");if(o==="\\"&&r+1<e.length){let i=e[++r];i>="0"&&i<="9"?n+=t[Number(i)]?.text??"":n+=i;continue}n+=o==="&"?t[0].text:o}return n}function Kv(e,t){let n=mt(e,t[0]),r=we(e,t[1]),o=T(e,t[2]),i=L(o,e),s=i.startsWith("g")||i.startsWith("G"),u=0;s||(u=Math.trunc(z(o)),u<1&&(e.warn(`gensub: third argument \`${i}' treated as 1`),u=1));let a=t[3]?we(e,t[3]):e.record,l=/(?:^|[^\\])(?:\\\\)*\\[1-9]/u.test(r);return zn(a,n,(f,c,d)=>!s&&d!==u?null:Vv(r,l?n.groups(a,f,c):[{text:a.slice(f,c)}]),s?"global":"nth").out}function Jv(e,t){let n=we(e,t[0]),r=mt(e,t[1]),o=r.search(n,0),i=o?Array.from(n.slice(0,o.start)).length+1:0;if(e.globals.set("RSTART",i),e.globals.set("RLENGTH",o?Array.from(n.slice(o.start,o.end)).length:-1),t[2]){let s=ht(e,t[2].name);if(s.clear(),o){let u=L(e.globals.get("SUBSEP"),e);r.groups(n,o.start,o.end).forEach((a,l)=>{a!==void 0&&(s.set(String(l),new G(a.text)),s.set(`${l}${u}start`,Array.from(n.slice(0,a.start)).length+1),s.set(`${l}${u}length`,[...a.text].length))})}}return i}function Qv(e,t){let n=we(e,t[0]),r=ht(e,t[1].name),o;t[2]===void 0?o=L(e.globals.get("FS"),e):t[2].type==="regex"?o=mt(e,t[2]):o=we(e,t[2]);let i=Fu(n,o,!1,qe(e));return r.clear(),i.forEach((s,u)=>r.set(String(u+1),new G(s))),i.length}function eS(e,t){let n=[...we(e,t[0])],r=Math.trunc(kh(e,t[1])),o=Number.isNaN(r)?1:Math.max(r,1),i=n.length+1;if(t[2]){let s=Math.trunc(kh(e,t[2]));if(!(s>=1))return"";i=Math.min(i,o+s)}return i>o?n.slice(o-1,i-1).join(""):""}function tS(e,t){if(t.length===0)return[...e.record].length;if(t[0].type==="var"){let n=yn(e,t[0].name);return n instanceof Map?n.size:[...L(n,e)].length}return[...we(e,t[0])].length}function nS(e,t){let n=we(e,t[0]),r=we(e,t[1]);qe(e)&&(n=Gt(n),r=Gt(r));let o=n.indexOf(r);return o<0?0:Array.from(n.slice(0,o)).length+1}function rS(e,t){let n=we(e,t[0]);return n==="/dev/stdout"||n==="/dev/stderr"||n==="/dev/null"?0:e.input.close(e,n)}var oS=(e,t)=>t[0].type==="var"?Cu(yn(e,t[0].name)):Cu(T(e,t[0])),iS={__proto__:null,...xh,length:tS,substr:eS,index:nS,split:Qv,sub:(e,t)=>vh(e,t,!1),gsub:(e,t)=>vh(e,t,!0),gensub:Kv,match:Jv,sprintf:(e,t)=>Zo(e,we(e,t[0]),t.slice(1).map(n=>T(e,n))),tolower:(e,t)=>Gt(we(e,t[0])),toupper:(e,t)=>Gt(we(e,t[0]),!0),close:rS,fflush:()=>0,typeof:oS,isarray:(e,t)=>t[0].type==="var"&&yn(e,t[0].name)instanceof Map?1:0};function Sh(e,t){let n=iS[t.name];if(!n)throw new $(`function \`${t.name}\` is not supported`,null,`${t.name}()`);return n(e,t.args)}var Vo={type:"break"},Uu={type:"continue"},sS={type:"next"},uS={type:"nextfile"},aS={type:"exit"};function Eh(e,t,n,r){let o=new Map([["0","awk"]]);r.forEach((u,a)=>o.set(String(a+1),new G(u)));let i=new Map([["FS"," "],["OFS"," "],["ORS",`
|
|
242
242
|
`],["RS",`
|
|
243
|
-
`],["RT",""],["NR",0],["NF",0],["FNR",0],["FILENAME",""],["SUBSEP",""],["CONVFMT","%.6g"],["OFMT","%.6g"],["RSTART",0],["RLENGTH",-1],["ERRNO",""],["IGNORECASE",0],["FIELDWIDTHS",""],["FPAT","[^[:space:]]+"],["ENVIRON",new
|
|
244
|
-
`),fileRule:u=>lS(s,u)};return s}var
|
|
245
|
-
`),a=2,c instanceof RangeError&&(l={detail:"runtime limit",message:`awk: ${c.message}`}),c.gap&&(l={detail:c.gap,message:`awk: ${c.message}`}),d&&(l={detail:d.detail,message:`awk: ${c.message}`})}let f={stdout:u.out.join(""),stderr:u.errOut.join(""),exitCode:a};return l===null?f:ie(f,"feature","awk",l.detail,l.message)}var kS=/^-[Fvf]\S*\s/su;function vS(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="-F"||r==="-v"||r==="-f"){t.push(r),n+1<e.length&&t.push(e[++n]);continue}if(kS.test(r)){t.push(r.slice(0,2),r.slice(2));continue}if(!r.startsWith("-")||r==="-"||r==="--"){t.push(...e.slice(n));break}t.push(r)}return t}function SS(e,t,n){if(e.length===0)return t.length===0?{error:pe(
|
|
246
|
-
`),operands:t}}function
|
|
247
|
-
`,d=f.inputs.flatMap(({content:g})=>he(g,c)),p=l.specs.length?l.specs:[{start:1,...a}],h=_S(d,p,u,r.has("u"),a.r),m=ge(h,c);return s.length===0?ne(m,f):ES(s[0],m,n,f)}function ES(e,t,n,r){if(e==="/dev/null")return ne("",r);if(e==="/dev/stdout")return ne(t,r);n.io?.setReads([]);let o;try{o=n.writable&&n.fs.openWritable(n.cwd,e),o&&o.write(t)}catch(i){return R(n,"sort",i?.path,i?.fsError),K(i,"sort",`sort: open failed: ${i.message}`,2)}return o?ne("",r):v("feature","sort","-o",`sort: open failed: ${e}: Read-only file system`,2)}var $S="nrfb",NS="bdfghiMnRrV",AS=/^[ \t]*\+?(\d+)/u,OS=(e,t)=>x(`sort: ${e}: invalid count at start of '${t}'`,2),
|
|
248
|
-
`,exitCode:124};if(
|
|
249
|
-
`)throw
|
|
250
|
-
`?(r&&t.push(o),o="",r=!1):(o+=s,r=!0)}if(n)throw
|
|
243
|
+
`],["RT",""],["NR",0],["NF",0],["FNR",0],["FILENAME",""],["SUBSEP",""],["CONVFMT","%.6g"],["OFMT","%.6g"],["RSTART",0],["RLENGTH",-1],["ERRNO",""],["IGNORECASE",0],["FIELDWIDTHS",""],["FPAT","[^[:space:]]+"],["ENVIRON",new Yo("ENVIRON")],["PROCINFO",new Yo("PROCINFO",[["FS","FS"]])],["ARGC",r.length+1],["ARGV",o],["ARGIND",0]]),s={program:e,globals:i,frame:void 0,callDepth:0,record:"",recordValue:new G(""),fields:[void 0],nf:0,fieldMode:"FS",out:[],errOut:[],steps:0,exitCode:0,ranges:[],rng:yh(),input:new qo(t,n),byteLocale:le(t),tables:re(t.locale),hasFileRules:e.beginFile.length>0,callBuiltin:Sh,execStmts:Ko,assign:(u,a)=>Ho(s,u,a),warn:u=>s.errOut.push(`awk: warning: ${u}
|
|
244
|
+
`),fileRule:u=>lS(s,u)};return s}var Yo=class extends Map{constructor(t,n=[]){super(n),this.systemName=t}check(t){if(!this.systemName||this.systemName==="PROCINFO"&&t==="FS")return;let n=this.systemName==="ENVIRON"?"ENVIRON":`PROCINFO[${t??"*"}]`;throw new $(`${n} is not supported without the corresponding environment or process metadata`,null,n)}get(t){return this.check(t),super.get(t)}has(t){return this.check(t),super.has(t)}set(t,n){return this.check(t),super.set(t,n)}delete(t){return this.check(t),super.delete(t)}clear(){return this.check(),super.clear()}get size(){return this.check(),super.size}keys(){return this.check(),super.keys()}values(){return this.check(),super.values()}entries(){return this.check(),super.entries()}[Symbol.iterator](){return this.check(),super[Symbol.iterator]()}};function $h(e){let{program:t}=e,n=Bu(e,t.begin,"BEGIN"),r=t.rules.length>0||t.end.length>0||t.beginFile.length>0||t.endFile.length>0;return!Nh(n)&&r&&fS(e),Bu(e,t.end,"END"),e.exitCode}var Nh=e=>e!==void 0&&e.type==="exit";function Bu(e,t,n){let r=Ah(e,t);if(r!==void 0&&(r.type==="next"||r.type==="nextfile"&&(n==="BEGIN"||n==="END")))throw new $(`\`${r.type}' cannot be called from a ${n} rule`);return r}function lS(e,t){let n=t==="begin"?e.program.beginFile:e.program.endFile;return n.length===0?void 0:Bu(e,n,t==="begin"?"BEGINFILE":"ENDFILE")}function fS(e){for(;;){let t=e.input.next(e);if(t===null)return e.input.exitSignal;Go(e,t);let n=cS(e);if(Nh(n))return n;n!==void 0&&n.type==="nextfile"&&e.input.closeFile(e)}}function cS(e){let{rules:t}=e.program;for(let n=0;n<t.length;n++){let r=t[n];if(!dS(e,r,n))continue;if(r.action===null){ju(e,null,e.record+L(e.globals.get("ORS"),e));continue}let o=Ah(e,r.action);if(o!==void 0)return o}}function Ah(e,t){try{return Ko(e,t)}catch(n){if(!(n instanceof kr))throw n;return n.signal}}function dS(e,t,n){let{pattern:r}=t;if(r===null)return!0;if(r.type!=="range")return Ne(T(e,r));if(!e.ranges[n]){if(!Ne(T(e,r.from)))return!1;e.ranges[n]=!0}return Ne(T(e,r.to))&&(e.ranges[n]=!1),!0}function Ko(e,t){for(let n of t){let r=Er(e,n);if(r!==void 0)return r}}function Er(e,t){if(++e.steps>qn)throw new $(`execution stopped after ${qn} statements (infinite loop?)`,null,"execution limit");switch(t.type){case"block":return Ko(e,t.body);case"empty":return;case"expr":T(e,t.expr);return;case"print":return gS(e,t);case"printf":return wS(e,t);case"if":return Ne(T(e,t.test))?Er(e,t.consequent):t.alternate===null?void 0:Er(e,t.alternate);case"while":case"do":case"for":return pS(e,t);case"forin":return hS(e,t);case"switch":return mS(e,t);case"break":return Vo;case"continue":return Uu;case"next":return sS;case"nextfile":return uS;case"exit":return bS(e,t);case"return":return{type:"return",value:t.value===null?void 0:T(e,t.value)};case"delete":{let n=ht(e,t.name);t.subs===null?n.clear():n.delete(vr(e,t.subs));return}default:throw new $(`unknown statement: ${t.type}`)}}function pS(e,t){t.init&&T(e,t.init);let n=!0;for(;t.type==="do"&&n||t.test===null||Ne(T(e,t.test));){n=!1;let r=Er(e,t.body);if(r===Vo)return;if(r!==void 0&&r!==Uu)return r;t.step&&T(e,t.step)}}function hS(e,t){let n=ht(e,t.array);for(let r of Array.from(n.keys())){Ho(e,t.name,new G(r));let o=Er(e,t.body);if(o===Vo)return;if(o!==void 0&&o!==Uu)return o}}function mS(e,t){let n=T(e,t.expr),r=i=>i.test.type==="regex"?mt(e,i.test).test(L(n,e)):Wo(n,i.test.value,e)===0,o=t.cases.findIndex(i=>i.test!==null&&r(i));if(o===-1&&(o=t.cases.findIndex(i=>i.test===null)),o!==-1)for(let i=o;i<t.cases.length;i++){let s=Ko(e,t.cases[i].body);if(s===Vo)return;if(s!==void 0)return s}}function ju(e,t,n){if(t===null){e.out.push(n);return}let r=L(T(e,t),e);if(r==="/dev/stdout")e.out.push(n);else if(r==="/dev/stderr")e.errOut.push(n);else if(r!=="/dev/null")throw new $(Eu(r),null,"output redirection")}function gS(e,t){let n=L(e.globals.get("ORS"),e),r;if(t.args.length===0)r=e.record;else{let o=L(e.globals.get("OFS"),e);r=t.args.map(i=>ih(T(e,i),e)).join(o)}ju(e,t.dest,r+n)}function wS(e,t){let n=t.args.map(r=>T(e,r));ju(e,t.dest,Zo(e,L(n[0],e),n.slice(1)))}function bS(e,t){if(t.value!==null){let n=Math.trunc(z(T(e,t.value)));e.exitCode=(n%256+256)%256}return aS}var yS="awk [-F fs] [-v var=value] 'program' [file ...] | awk [-F fs] [-v var=value] -f progfile [file ...]",xS=/^([A-Za-z_][A-Za-z0-9_]*)=([^]*)$/u;function Oh(e,t,n){let{values:r,positional:o}=N(vS(t),{valueShort:["F"],repeatable:["v","f"],stopAtFirstPositional:!0}),i=SS(r.get("f")??[],o,n);if(i.error)return i.error;let s;try{pt({byteLocale:le(n)},i.text),s=J1(i.text)}catch(c){if(c instanceof RangeError)return v("feature","awk","parser depth limit",`awk: program too deeply nested (${c.message})`);if(O(c))return K(c,"awk",`awk: ${c.message}`);if(!(c instanceof $))throw c;let d=c.line===null?`awk: ${c.message}`:`awk: syntax error at line ${c.line}: ${c.message}`;return c.gap===null?x(d):v("feature","awk",c.gap,d)}let u=Eh(s,n,e,i.operands);for(let c of s.warnings)u.warn(c);let a,l=null;try{r.has("F")&&u.assign("FS",hr(r.get("F"),u.warn));for(let c of r.get("v")??[]){let d=xS.exec(c);if(!d)return x(`awk: -v: expected var=value but got \`${c}\``);u.assign(d[1],new G(hr(d[2],u.warn)))}a=$h(u)}catch(c){let d=O(c);if(!(c instanceof $)&&!(c instanceof RangeError)&&!d)throw c;u.errOut.push(`awk: ${c.message}
|
|
245
|
+
`),a=2,c instanceof RangeError&&(l={detail:"runtime limit",message:`awk: ${c.message}`}),c.gap&&(l={detail:c.gap,message:`awk: ${c.message}`}),d&&(l={detail:d.detail,message:`awk: ${c.message}`})}let f={stdout:u.out.join(""),stderr:u.errOut.join(""),exitCode:a};return l===null?f:ie(f,"feature","awk",l.detail,l.message)}var kS=/^-[Fvf]\S*\s/su;function vS(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r==="-F"||r==="-v"||r==="-f"){t.push(r),n+1<e.length&&t.push(e[++n]);continue}if(kS.test(r)){t.push(r.slice(0,2),r.slice(2));continue}if(!r.startsWith("-")||r==="-"||r==="--"){t.push(...e.slice(n));break}t.push(r)}return t}function SS(e,t,n){if(e.length===0)return t.length===0?{error:pe(yS,2)}:{text:t[0],operands:t.slice(1)};let r=[];for(let o of e){let{path:i,error:s}=P(n,"awk",o);if(s||!n.fs.isFile(i))return{error:x(`awk: cannot open program file \`${o}\`: ${s??"Is a directory"}`,2)};r.push(n.fs.readFile(i))}return{text:r.join(`
|
|
246
|
+
`),operands:t}}function Ih(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["n","r","u","f","b","z"],valueShort:["t","o"],valueLong:["output"],repeatable:["k","o","output"]}),s=[...o.get("o")??[],...o.get("output")??[]];if(s.length>1)return x("sort: multiple output files specified",2);let u=o.get("t");if(u!==void 0&&A(u).length!==1)return x(`sort: multi-character tab '${u}'`,2);let a={n:r.has("n"),f:r.has("f"),b:r.has("b"),r:r.has("r")},l=IS(o.get("k")??[],a);if(l.error)return l.error;let f=te("sort",i,e,n,{stopOnError:!0});if(f.failed)return{stdout:"",stderr:f.stderr,exitCode:2};let c=r.has("z")?"\0":`
|
|
247
|
+
`,d=f.inputs.flatMap(({content:g})=>he(g,c)),p=l.specs.length?l.specs:[{start:1,...a}],h=_S(d,p,u,r.has("u"),a.r),m=ge(h,c);return s.length===0?ne(m,f):ES(s[0],m,n,f)}function ES(e,t,n,r){if(e==="/dev/null")return ne("",r);if(e==="/dev/stdout")return ne(t,r);n.io?.setReads([]);let o;try{o=n.writable&&n.fs.openWritable(n.cwd,e),o&&o.write(t)}catch(i){return R(n,"sort",i?.path,i?.fsError),K(i,"sort",`sort: open failed: ${i.message}`,2)}return o?ne("",r):v("feature","sort","-o",`sort: open failed: ${e}: Read-only file system`,2)}var $S="nrfb",NS="bdfghiMnRrV",AS=/^[ \t]*\+?(\d+)/u,OS=(e,t)=>x(`sort: ${e}: invalid count at start of '${t}'`,2),Jo=(e,t)=>x(`sort: ${e}: invalid field specification '${t}'`,2);function CS(e){let t=0,n=null,r=u=>{let a=AS.exec(e.slice(t));return a===null?(n=OS(u,e.slice(t)),null):(t+=a[0].length,Number(a[1]))},o=u=>{let a=r(u);if(a===null)return null;let l=null;if(e[t]==="."&&(t++,l=r("invalid number after '.'"),l===null))return null;let f=t;for(;t<e.length&&/[a-zA-Z]/u.test(e[t]);)t++;return{field:a,offset:l,mods:e.slice(f,t)}},i=o("invalid number at field start");if(i===null)return{error:n};let s=null;return e[t]===","&&(t++,s=o("invalid number after ','"),s===null)?{error:n}:i.field===0||s?.field===0?{error:Jo("field number is zero",e)}:i.offset===0?{error:Jo("character offset is zero",e)}:t!==e.length?{error:Jo("stray character in field spec",e)}:{from:i,to:s}}function IS(e,t){let n=[];for(let r of e){let o=CS(r);if(o.error)return{error:o.error};let{from:i,to:s}=o,u=i.mods+(s?.mods??"");for(let l of u)if(!$S.includes(l))return NS.includes(l)?{error:v("option","sort",`-k${r}`,`sort: unknown key option \`${l}\` in ${r}`,2)}:{error:Jo("stray character in field spec",r)};if(i.offset!==null||(s?.offset??0)!==0)return{error:v("option","sort",`-k${r}`,`sort: invalid key specification: ${r} (character offsets are not supported)`,2)};let a=u.length>0;n.push({start:i.field,end:s?.field,n:a?u.includes("n"):t.n,r:a?u.includes("r"):t.r,f:a?u.includes("f"):t.f,b:a?i.mods.includes("b"):t.b})}return{specs:n}}function TS(e,t){let n=[];if(t!==void 0){let o=0;for(;;){let i=e.indexOf(t,o);if(i===-1){n.push([o,e.length]);break}n.push([o,i]),o=i+t.length}return n}let r=0;do{let o=r;for(;r<e.length&&/[ \t]/u.test(e[r]);)r++;for(;r<e.length&&!/[ \t]/u.test(e[r]);)r++;n.push([o,r])}while(r<e.length);return n}function FS(e,t,n){if(t.start>n.length)return"";let r=n[t.start-1][0],o=t.end===void 0||t.end>n.length?e.length:n[t.end-1][1];if(t.b)for(;r<o&&/[ \t]/u.test(e[r]);)r++;return e.slice(r,Math.max(r,o))}var LS=e=>e.replace(/[a-z]/gu,t=>t.toUpperCase());function _S(e,t,n,r,o){let i=t.every(l=>l.start===1&&l.end===void 0);if(i&&t.length===1&&!t[0].n&&!t[0].f&&!t[0].b)return e.sort(e.some(l=>/[\u{10000}-\u{10FFFF}]/u.test(l))?j:void 0),t[0].r&&e.reverse(),r?e.filter((l,f)=>f===0||l!==e[f-1]):e;let s=e.map(l=>{let f=i?[[0,l.length]]:TS(l,n);return{line:l,keys:t.map(c=>{let d=FS(l,c,f);return c.n?RS(d):c.f?LS(d):d})}}),u=(l,f)=>{for(let c=0;c<t.length;c++){let d=t[c],p=d.n?MS(l.keys[c],f.keys[c]):j(l.keys[c],f.keys[c]);if(p!==0)return d.r?-p:p}return r?0:(o?-1:1)*j(l.line,f.line)};s.sort(u);let a=[];for(let l=0;l<s.length;l++)r&&l>0&&u(s[l-1],s[l])===0||a.push(s[l].line);return a}function RS(e){let t=/^[ \t]*(-?)(?:(\d+)(?:\.(\d*))?|\.(\d+))/u.exec(e),n=(t?.[2]??"").replace(/^0+/u,"")||"0",r=(t?.[3]??t?.[4]??"").replace(/0+$/u,"");return{integer:n,fraction:r,negative:t?.[1]==="-"&&(n!=="0"||r!=="")}}var Ch=(e,t)=>e<t?-1:e>t?1:0;function MS(e,t){if(e.negative!==t.negative)return e.negative?-1:1;let n=e.integer.length-t.integer.length||Ch(e.integer,t.integer)||Ch(e.fraction,t.fraction);return e.negative?-n:n}async function Fh(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["r","0"],valueShort:["n","I"],stopAtFirstPositional:!0}),[s="echo",...u]=i,a=o.get("I"),l=o.has("n")?ye(o.get("n"),"xargs: -n"):{value:void 0};if(l.error)return l.error;if(l.value===0)return x("xargs: -n: must be at least 1");if(a==="")return x("xargs: -I: replacement string must not be empty");if(a!==void 0&&l.value!==void 0)return v("option","xargs","-I -n","xargs: combining replacement and chunk limits is not supported");if(q(n),!r.has("0")&&e.includes("\0"))return v("feature","xargs","NUL input","xargs: NUL input requires -0");let f;if(r.has("0"))f=he(e,"\0");else if(a===void 0)f=PS(e);else{if(/["'\\]/u.test(e))return v("feature","xargs","-I input quoting","xargs: quoted or escaped replacement lines are not supported");f=he(e).map(m=>m.replace(/^[ \t\r\f\v]+/u,"")).filter(Boolean)}if(f.length===0&&(r.has("r")||a!==void 0))return F();let c=a===void 0?l.value??Math.max(1,f.length):1,d=0,p="",h="";for(let m=0;m<Math.max(1,f.length);m+=c){let g=f[m],w=a===void 0?[...u,...f.slice(m,m+c)]:u.map(k=>k.replaceAll(a,g)),b=await n.dispatch(s,w,"");if(h+=b.stdout,p+=b.stderr,b.exitCode===255)return{stdout:h,stderr:p+"xargs: "+s+`: exited with status 255; aborting
|
|
248
|
+
`,exitCode:124};if(b.exitCode===127&&!n.hasCommand(n.registry.resolveCommand(s)))return{stdout:h,stderr:p,exitCode:127};b.exitCode!==0&&(d=123)}return{stdout:h,stderr:p,exitCode:d}}var Th=e=>new Error(`unmatched ${e==="'"?"single":"double"} quote; by default quotes are special to xargs unless you use the -0 option`);function PS(e){let t=[],n=null,r=!1,o="";for(let i=0;i<e.length;i++){let s=e[i];if(!(!r&&/[ \t\n\r\f\v]/u.test(s)))if(n)if(s===n)n=null;else{if(s===`
|
|
249
|
+
`)throw Th(n);o+=s}else if(s==='"'||s==="'")n=s,r=!0;else if(s==="\\"){if(i+1>=e.length)break;o+=e[++i],r=!0}else s===" "||s===" "||s===`
|
|
250
|
+
`?(r&&t.push(o),o="",r=!1):(o+=s,r=!0)}if(n)throw Th(n);return r&&t.push(o),t}function Lh(e,t,n,r){let{values:o,positional:i,order:s}=N(BS(n),{short:["q","v"],valueShort:["c","n"]}),u=s.findLast(w=>w.name==="n"||w.name==="c")?.name??"n",a=Qa(o.get(u)??"10",e+": -"+u);if(a.error)return a.error;let l=s.findLast(w=>w.name==="q"||w.name==="v"),f=l?l.name==="v":null,c=e==="head",d=a.sign==="+";if(c&&a.value===0&&a.sign!=="-")return _h(e,t,i,r,()=>"",{unit:u,banner:f,leftover:w=>w,readOptions:{noRead:!0}});if(!c&&a.value===0&&!d){if(!r.stdinFile&&(!i.length||i.includes("-")||i.includes("/dev/stdin"))){let w=Dh(e,t,"",u,"standard input");w&&r.notes.add(w)}return F()}let p=w=>c?[0,a.sign==="-"?Math.max(0,w-a.value):a.value]:[d?Math.min(w,Math.max(0,a.value-1)):Math.max(0,w-a.value),w],h=w=>{if(u==="c")return Ph(w,p);let b=c?a.sign==="-":!d,k=c||b?a.value:Math.max(0,a.value-1),S=Mh(w,k,b);return c?w.slice(0,S):w.slice(S)},m=c?DS(a,u,r):void 0;return _h(e,t,i,r,h,{unit:u,banner:f,leftover:m,readOptions:!c&&d?{stopOnDir:!0}:void 0})}function DS(e,t,n){return e.sign==="-"||t==="n"&&!n.stdinFile?()=>"":t==="c"?r=>Ph(r,o=>[Math.min(e.value,o),o]):r=>r.slice(Mh(r,e.value))}function Mh(e,t,n=!1){if(n){if(t===0)return e.length;let o=e.length-Number(e.endsWith(`
|
|
251
251
|
`));for(let i=0;i<t;i++)if(o<=0||(o=e.lastIndexOf(`
|
|
252
252
|
`,o-1),o<0))return 0;return o+1}let r=0;for(let o=0;o<t&&r<e.length;o++){let i=e.indexOf(`
|
|
253
|
-
`,r);r=i===-1?e.length:i+1}return r}function BS(e){return/^-\d+$/u.test(e[0]??"")?["-n",e[0].slice(1),...e.slice(1)]:e}function
|
|
253
|
+
`,r);r=i===-1?e.length:i+1}return r}function BS(e){return/^-\d+$/u.test(e[0]??"")?["-n",e[0].slice(1),...e.slice(1)]:e}function Ph(e,t){let n=A(e),[r,o]=t(n.length);return r===0&&o>=n.length?e:W(n.subarray(r,o))}function _h(e,t,n,r,o,{unit:i,banner:s,leftover:u=()=>"",readOptions:a}){let l=te(e,n,t,r,a),f=s??n.length>1,c=l.entries.filter(m=>m.kind!=="missing"),d=[],p=[],h=null;for(let m=0;m<c.length;m++){let{name:g,kind:w,shared:b}=c[m],{content:k}=c[m];(b||g===null)&&(h!==null&&(k=h),h=u(k),q(r,h));let S=w==="dir"?"":o(k);if(w==="file"&&S!==k){let M=Dh(e,k,S,i,Dr(g,r));M&&p.push(M)}let I=g===null||g==="-"?"standard input":g;d.push(f?`${m>0?`
|
|
254
254
|
`:""}==> ${I} <==
|
|
255
255
|
${S}`:S)}for(let m of p)r.notes.add(m);return ne(d.join(""),l)}function US(e){let t=+(e.length>0&&!e.endsWith(`
|
|
256
256
|
`));for(let n=e.indexOf(`
|
|
257
257
|
`);n!==-1;n=e.indexOf(`
|
|
258
|
-
`,n+1))t++;return t}function
|
|
259
|
-
`:10;for(let r=e.indexOf(n);r>=0;r=e.indexOf(n,r+1))t++;return t}function XS(e){if(typeof e=="string")return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of Ar(e))n>=0&&t++;return t}var ZS=new Set([9,10,11,12,13,32]),YS=new Set([160,8199,8239,8288]),Wu=1,qu=0,zu=2,VS=Uint8Array.from({length:128},(e,t)=>ZS.has(t)?Wu:t>32&&t<127?zu:qu),KS=(e,t)=>t.has("print",e)?t.has("space",e)||YS.has(e)?Wu:zu:qu;function JS(e,t){let n=re(t.locale),r=0,o=!1;for(let i of QS(e,t)){let s=i<0?qu:i<128?VS[i]:KS(i,n);s===Wu?(o&&r++,o=!1):s===zu&&(o=!0)}return o?r+1:r}function*QS(e,t){if(typeof e!="string"){yield*le(t)?e:Ar(e);return}if(le(t)){yield*A(e);return}for(let n=0;n<e.length;){let r=e.codePointAt(n);yield r>=55296&&r<=57343?65533:r,n+=r>65535?2:1}}function eE(e,t){let n=0;for(let r=0;r<t&&n<e.length;r++){for(;n<e.length&&/[ \t]/u.test(e[n]);)n++;for(;n<e.length&&!/[ \t]/u.test(e[n]);)n++}return e.slice(n)}function tE(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["c","d","u","i","D"],valueShort:["f","s","w"]});if(i.length>2)return x(`uniq: extra operand: ${i[2]}`);if(i.length===2&&i[1]!=="-")return v("feature","uniq","output file","uniq: output files are not supported (filesystem is read-only)");let s=
|
|
258
|
+
`,n+1))t++;return t}function Dh(e,t,n,r,o){let i=r==="c"?l=>A(l).length:US,s=i(n),u=i(t);if(s>=u)return null;let a=(r==="c"?"byte":"line")+(u===1?"":"s");return`${e}: selected ${s} of ${u} ${a} from ${o}.`}function jS(e,t,n){let{flags:r,positional:o}=N(t,{short:["l","w","c","m"]}),i=qS(r),s=te("wc",o,e,n,{read:"as-held"}),u=o.length>1||Object.values(i).filter(Boolean).length>1,a=[],l={l:0,w:0,m:0,c:0};for(let{name:c,content:d,bytes:p,kind:h,shared:m}of s.entries.filter(g=>g.kind!=="missing")){let g=zS(p??d,n,i,u);a.push({counts:g,name:c,kind:h,shared:m}),l.l+=g.l,l.w+=g.w,l.m+=g.m,l.c+=g.c}let f=u?WS(a,n.stdinFile):1;return o.length>1&&a.push({counts:l,name:"total"}),ne(ge(a.map(c=>R1(c.counts,c.name,i,f,n))),s)}function WS(e,t){let n=0,r=1;for(let{name:o,kind:i,shared:s,counts:u}of e)i==="dir"||(o===null||s)&&!t?r=7:n+=u.c;return Math.max(r,String(n).length)}function qS(e){return e.size===0?{l:!0,w:!0,m:!1,c:!0}:{l:e.has("l"),w:e.has("w"),m:e.has("m"),c:e.has("c")}}function zS(e,t,n,r){let o=le(t),i=n.c||r||n.m&&o?HS(e):0;return{l:n.l?GS(e):0,w:n.w?JS(e,t):0,m:n.m?o?i:XS(e):0,c:i}}var HS=e=>typeof e=="string"?A(e).length:e.length;function GS(e){let t=0,n=typeof e=="string"?`
|
|
259
|
+
`:10;for(let r=e.indexOf(n);r>=0;r=e.indexOf(n,r+1))t++;return t}function XS(e){if(typeof e=="string")return e.length-(e.match(/[\u{10000}-\u{10FFFF}]/gu)??[]).length;let t=0;for(let n of Ar(e))n>=0&&t++;return t}var ZS=new Set([9,10,11,12,13,32]),YS=new Set([160,8199,8239,8288]),Wu=1,qu=0,zu=2,VS=Uint8Array.from({length:128},(e,t)=>ZS.has(t)?Wu:t>32&&t<127?zu:qu),KS=(e,t)=>t.has("print",e)?t.has("space",e)||YS.has(e)?Wu:zu:qu;function JS(e,t){let n=re(t.locale),r=0,o=!1;for(let i of QS(e,t)){let s=i<0?qu:i<128?VS[i]:KS(i,n);s===Wu?(o&&r++,o=!1):s===zu&&(o=!0)}return o?r+1:r}function*QS(e,t){if(typeof e!="string"){yield*le(t)?e:Ar(e);return}if(le(t)){yield*A(e);return}for(let n=0;n<e.length;){let r=e.codePointAt(n);yield r>=55296&&r<=57343?65533:r,n+=r>65535?2:1}}function eE(e,t){let n=0;for(let r=0;r<t&&n<e.length;r++){for(;n<e.length&&/[ \t]/u.test(e[n]);)n++;for(;n<e.length&&!/[ \t]/u.test(e[n]);)n++}return e.slice(n)}function tE(e,t,n){let{flags:r,values:o,positional:i}=N(t,{short:["c","d","u","i","D"],valueShort:["f","s","w"]});if(i.length>2)return x(`uniq: extra operand: ${i[2]}`);if(i.length===2&&i[1]!=="-")return v("feature","uniq","output file","uniq: output files are not supported (filesystem is read-only)");let s=ye(o.get("f")??"0","uniq: -f");if(s.error)return s.error;let u=ye(o.get("s")??"0","uniq: -s");if(u.error)return u.error;let a=o.has("w")?ye(o.get("w"),"uniq: -w"):{value:void 0};if(a.error)return a.error;let l=r.has("D"),f=r.has("c");if(l&&f)return x("uniq: printing all duplicated lines and repeat counts is meaningless");let c=Ja("uniq",i.slice(0,1),e,n),d=r.has("d"),p=r.has("u"),h=r.has("i"),m=S=>{let I=s.value>0?eE(S,s.value):S;if(u.value===0&&a.value===void 0){let C=I.toWellFormed();return h?C.replace(/[A-Z]/gu,H=>H.toLowerCase()):C}let M=A(I).subarray(u.value,a.value===void 0?void 0:u.value+a.value);return(h?M.map(C=>C>=65&&C<=90?C+32:C):M).join(",")},g=he(c.content),w=[],b=0,k=g.length?m(g[0]):null;for(let S=1;S<=g.length;S++){let I=S===g.length?null:m(g[S]);if(S<g.length&&I===k)continue;let M=S-b,C=M>=2;(l?C:!(d&&p)&&(d?C:!p||!C))&&(l?w.push(...g.slice(b+(p?1:0),S)):w.push(f?String(M).padStart(7)+" "+g[b]:g[b])),b=S,k=I}return ne(ge(w),c)}function Rh(){return F()}function nE(){return{stdout:"",stderr:"",exitCode:1}}var Hu={grep:so,head:(e,t,n)=>Lh("head",e,t,n),tail:(e,t,n)=>Lh("tail",e,t,n),wc:jS,sort:Ih,uniq:tE,echo:T1,printf:_1,xargs:Fh,awk:Oh},Bh={true:Rh,false:nE,":":Rh};var qh={test:E1,cat:r1,...Hu,...Qp,...Zc},Uh=(e,t)=>(n,r,o)=>{let i=Hu.grep(n,[t,...r],o),s=O(i);return s?ie(i,s.kind,e,s.detail,s.message):i},Gu={__proto__:null,sed:k1,egrep:Uh("egrep","-E"),fgrep:Uh("fgrep","-F"),"[":$1,...Yc,...Bh,...wu,...qh},zh=new Set(["cd",":",...Object.keys(wu)]),rE=e=>!!Gu[e],oE=new Set(["basename","cp","dirname","ln","mkdir","patch","rm","touch"]),Hh=Object.fromEntries(Object.entries(qh).filter(([e])=>!oE.has(e))),iE=["ls","cd","cat","grep","rg","find","head","tail","wc","tree","du","stat","realpath","sort","uniq","cut","tr","awk","nl","tac","hexdump","base64","xargs","echo","printf","test","diff","pwd","seq","which"],jh=Object.keys(Gu).filter(e=>!zh.has(e)&&!Object.hasOwn(Hh,e)).sort(),sE=new Set(["base32","brotli","egrep","fgrep","gunzip","gzcat","gzip","od","sed","sha1sum","sha256sum","sha384sum","sha512sum","shasum","xxd","zcat"]),Wh=aE(),uE=["grep","head","tail","wc","sort","uniq","cut","xargs","awk","tr","nl","tac","hexdump","cat","base64","diff","patch"];function aE(){let e=new Set(Object.keys(Hh)),t=[];for(let n of iE)e.delete(n)&&t.push(n);return t.push(...[...e].sort()),t}var Gh=Object.freeze(["/usr/local/bin/","/usr/bin/","/bin/","/sbin/"]);function Xh(e,t){for(let n of Gh)if(e.startsWith(n)){let r=e.slice(n.length);if(t(r))return r}return e}var lE=new Set(["test","[","true","false"]),fE=new Set(["grep","egrep","fgrep"]);function cE(e,t){let n=Xh(e[0],t);return lE.has(n)?"status":fE.has(n)?cc(e.slice(1))?"status":"search":"work"}function Xu(e){let t=zl(e,rE),n=Object.freeze({__proto__:null,...Gu,...t.handlers}),r=i=>!!n[i],o=Object.freeze([...Wh,...jh,...t.names]);return Object.freeze({commands:n,names:o,pipeNames:Object.freeze([...uE,...jh.filter(i=>sE.has(i)),...t.pipeNames]),binPrefixes:Gh,has:r,shellOnly:i=>zh.has(i),resolveCommand:i=>Xh(i,r),chainRole:i=>cE(i,r),known:[...Wh,...t.names].join(", ")})}var Zh=Xu();function Yh(e,t){let n=I1.get(e);return n!==void 0?v("feature",e,e,`${e}: ${n}`,127):v("command",e,e,`${e}: command not found. Available: ${t.known}`,127)}function Kh(e,t,n){let r=mE(e);if(!r)return[];let{start:o,pipe:i,quote:s,words:u}=r;for(;dE.has(u[0]);)u.shift();if(pE.has(u[0]))return[];if(u[0]==="for"&&u.length<=2)return[];let a=e.slice(o),l=Vh(a,s);if(!l)return[];let f=u.length===0,c=f?"":n.resolveCommand(Vh(u[0],null)?.value??""),d=f?hE(l.value,i,n,t.functions):i?[]:wE(l,t,c==="cd"),p=e.slice(0,o),h=i&&a===""&&p.endsWith("|")?" ":"";return d.map(m=>p+h+a+gE(m.slice(l.value.length),s))}var dE=new Set(["!","{","do","then","else","elif","if","while","until"]),pE=new Set(["done","fi","}","esac"]);function hE(e,t,n,r){let o=t?n.pipeNames:n.names;for(let s of n.binPrefixes)if(e.startsWith(s))return o.filter(u=>u.startsWith(e.slice(s.length))).map(u=>s+u);if(e.startsWith("/")||e.startsWith("./"))return[];let i=[...r.keys()].filter(s=>!o.includes(s));return[...o,...i].filter(s=>s.startsWith(e))}function mE(e){let t=0,n=!1,r=null,o=!1,i=-1,s=[];for(let u=0;u<e.length;u++){let a=e[u];if(r==="'"){a===r&&(r=null);continue}if(a==="\\"&&(!r||'$`"\\\n'.includes(e[u+1]))){if(u+1===e.length)return null;e[++u]!==`
|
|
260
260
|
`&&(o=!0);continue}if(a==="`"||a==="$"&&e[u+1]==="(")return null;if(r){a===r&&(r=null);continue}if(a==="'"||a==='"'){r=a,o=!0;continue}if(a==="#"&&!o){let c=e.indexOf(`
|
|
261
261
|
`,u);if(c===-1)return null;u=c-1;continue}if(a===" "||a===" "){o&&s.push(e.slice(t,u)),t=u+1,o=!1;continue}let l=a==="|"&&e[u+1]==="|",f=a==="&"&&e[u+1]==="&";if(a==="|"||f||a===";"||a===`
|
|
262
|
-
`||a==="("||a===")"&&i===u-1){(l||f)&&u++,a==="("&&(i=u),t=u+1,n=a==="|"&&!l,s.length=0,o=!1;continue}o=!0}return{start:t,pipe:n,quote:r,words:s}}function
|
|
262
|
+
`||a==="("||a===")"&&i===u-1){(l||f)&&u++,a==="("&&(i=u),t=u+1,n=a==="|"&&!l,s.length=0,o=!1;continue}o=!0}return{start:t,pipe:n,quote:r,words:s}}function Vh(e,t){if(e==="")return{value:"",mask:null};try{let n=Ur(e+(t??""));if(n.length!==1||n[0].kind!=="word")return null;let r=n[0];for(let o=0;o<r.value.length;o++){let i=r.mask?.[o]??"0";if(i!=="1"&&r.value[o]==="$"||i==="0"&&"*?[{".includes(r.value[o]))return null}return r}catch{return null}}function gE(e,t){return t==="'"?e.replaceAll("'","'\\''")+"'":t==='"'?e.replace(/[\\$`"]/gu,"\\$&")+'"':e.replace(/[\s\\'"`$&|;()<>*?[\]{}!#~]/gu,n=>n===`
|
|
263
263
|
`?`'
|
|
264
|
-
'`:"\\"+n)}function wE(e,t,n=!1){let r=e.value,o=r.startsWith("~")&&(e.mask?.[0]??"0")==="0"&&!e.empty?.some(h=>h<=1)&&(r.length===1||(e.mask?.[1]??"0")==="0");if(o&&r==="~")return t.fs.isDir(E(t.cwd,ln(t),t.fs).path)?["~/"]:[];if(o&&!r.startsWith("~/"))return[];let i=r.lastIndexOf("/"),s=r.slice(0,i+1),u=r.slice(i+1),a=o?ln(t)+s.slice(1):s||".",l=E(t.cwd,a,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:f,files:c,links:d}=t.fs.listDir(l),p=f.map(h=>h+"/");for(let h of d)t.fs.isDir(E(l,h,t.fs).path)?p.push(h+"/"):n||p.push(h);return n||p.push(...c),p.filter(h=>h.startsWith(u)&&(u.startsWith(".")||!h.startsWith("."))).filter(h=>s!==""||u===""||!h.startsWith("-")).map(h=>s===""&&h.startsWith("-")?"./"+h:s+h)}async function
|
|
264
|
+
'`:"\\"+n)}function wE(e,t,n=!1){let r=e.value,o=r.startsWith("~")&&(e.mask?.[0]??"0")==="0"&&!e.empty?.some(h=>h<=1)&&(r.length===1||(e.mask?.[1]??"0")==="0");if(o&&r==="~")return t.fs.isDir(E(t.cwd,ln(t),t.fs).path)?["~/"]:[];if(o&&!r.startsWith("~/"))return[];let i=r.lastIndexOf("/"),s=r.slice(0,i+1),u=r.slice(i+1),a=o?ln(t)+s.slice(1):s||".",l=E(t.cwd,a,t.fs).path;if(!t.fs.isDir(l))return[];let{dirs:f,files:c,links:d}=t.fs.listDir(l),p=f.map(h=>h+"/");for(let h of d)t.fs.isDir(E(l,h,t.fs).path)?p.push(h+"/"):n||p.push(h);return n||p.push(...c),p.filter(h=>h.startsWith(u)&&(u.startsWith(".")||!h.startsWith("."))).filter(h=>s!==""||u===""||!h.startsWith("-")).map(h=>s===""&&h.startsWith("-")?"./"+h:s+h)}async function Jh(e,t,n,r=!1){let o=(t.substitutionDepth??0)+1;if(o>Qt)throw new y("feature","command substitution nesting limit",`command substitution nesting beyond ${Qt} levels is not supported`);let i=t.expansionFds[2],u=await ce(t,{substitutionDepth:o,outputFds:{1:"out",2:typeof i=="object"||i==="closed"?i:"err"},errexitOff:!0,closed:{out:!1,err:i==="closed"}},()=>$t(t,()=>{let c;try{c=Ul(e,t.writable,t.registry.has)}catch(p){let h=O(p);if(!h){if(r)return x(`error: command substitution: ${p.message}`,2);throw new y("feature","command substitution syntax",`runtime command substitution syntax errors are not supported: ${p.message}`)}return t.unsupported.add(h),x(`error: ${p.message}`,1)}let d=c.length===1&&!c[0].negate&&c[0].stages.length===1?c[0].stages[0]:null;return d&&!d.group&&!d.loop&&!d.conditional&&!d.test&&d.words.length===0&&d.assigns.length===0&&d.redirs.length===1&&d.redirs[0].op==="read"&&d.words.push({value:"cat",mask:null}),n(c,t,{text:t.stdinLeft,bytes:t.stdinBytes})}));t.lastExit=t.substitutionExit=u.exitCode;let a=u.stdout,l=u.stderr;if(a.includes("\0")){let c=a.length;a=a.replaceAll("\0","");let d=c-a.length;t.notes.add(`command substitution: discarded ${d} NUL ${d===1?"byte":"bytes"}.`),l+=`warning: command substitution: ignored null byte in input
|
|
265
265
|
`}uo(t,l);let f=a.length;for(;f>0&&a[f-1]===`
|
|
266
|
-
`;)f--;return a.slice(0,f)}async function
|
|
267
|
-
`,u=!1,f=!1,m=!0;else{let k=await w(()=>
|
|
268
|
-
`,r.exitCode=t.lastExit}return UE(r,t,n)})}var UE=(e,t,n)=>({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,cwd:t.cwd,unsupported:Object.freeze(n.entries),notes:Object.freeze([...t.notes,...yi(t.discarded,e.stderr,t.notes)])});var jE={unified:[[/^--- /u,"bold"],[/^\+\+\+ /u,"bold"],[cn,"cyan"],[/^\+/u,"green"],[/^-/u,"red"],[/^\\ /u,"gray"]],context:[[qt,"cyan"],[/^\*{3} \d/u,"cyan"],[/^--- \d/u,"cyan"],[/^\*{3} /u,"bold"],[/^--- /u,"bold"],[/^! /u,"yellow"],[/^\+ /u,"green"],[/^- /u,"red"]],normal:[[dn,"cyan"],[/^< /u,"red"],[/^> /u,"green"],[/^---$/u,"gray"]]};function WE(e){return e.some(t=>qt.test(t))?"context":e.some(t=>cn.test(t))?"unified":e.some(t=>dn.test(t))?"normal":null}function
|
|
269
|
-
`),n=jE[WE(t)];return n===void 0?null:t.map(r=>n.find(([o])=>o.test(r))?.[1]??null)}var qE={bold:"head",cyan:"hunk",green:"add",red:"del",yellow:"chg",gray:"meta"};function
|
|
270
|
-
`).map((n,r)=>({text:n,kind:t[r]===null?"":qE[t[r]]??""}))}function
|
|
271
|
-
`;var Qu="/sources",HE={mount:Qu,home:"/",writable:"/tmp/"};function GE(e){let n=["ls","find /",`grep -r ${XE(e)} .`];if(!e||e.size===0)return n;let r=null;for(let[o,i]of e){if(typeof i!="string")continue;let s=ZE(o);(r===null||s.length<r.length)&&(r=s)}return r&&n.push(`cat ${r} | head -n 20`),n}var Ju=["TODO","FIXME","XXX","HACK","NOTE","BUG","export","import","require","//"];function XE(e){if(!e||e.size===0)return Ju[0];for(let t of Ju)for(let n of e.values())if(typeof n=="string"&&n.includes(t))return t;return Ju[0]}function ZE(e){return e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e}var ea=class e extends na{static properties={sources:{attribute:!1},_lines:{state:!0},_input:{state:!0},_cwd:{state:!0},_ghost:{state:!0},_notes:{state:!0},_running:{state:!0}};static styles=ra(
|
|
272
|
-
`}];return}finally{this._running=!1}this._cwd=i.cwd;let s=[...this._lines,{kind:"prompt",cwd:o,text:n}];i.stdout&&s.push({kind:"stdout",text:i.stdout,diff:
|
|
266
|
+
`;)f--;return a.slice(0,f)}async function Qh(e,t){return{stdout:"",stderr:"",exitCode:await xn(e,t)?0:1}}var Zu=async(e,t)=>(await qs(e,t)).value;async function xn(e,t){let{kind:n}=e;if(n==="not")return!await xn(e.expression,t);if(n==="and")return await xn(e.left,t)&&await xn(e.right,t);if(n==="or")return await xn(e.left,t)||await xn(e.right,t);let{op:r}=e;if(n==="unary"){let u=await Zu(e.word,t);if(r==="-n")return u!=="";if(r==="-z")return u==="";if(["-a","-e","-f","-d"].includes(r))return gu(r,u,t);if(r==="-v")return bE(u,t);$r(r)}["<",">","-nt","-ot","-ef"].includes(r)&&$r(r);let o=await Zu(e.left,t);if(Object.hasOwn(pr,r)){let u=await Zu(e.right,t);return pr[r](Ut(o,t),Ut(u,t))}let i=await qs(e.right,t);Xn(i)&&$r("extglob");let s=Me(on(i),{bash:!0}).test(o);return r==="!="?!s:s}function bE(e,t){return e.includes("[")&&$r("-v array subscript"),/^[ \t\n\r\f\v]*[+-]?0+[ \t]*$/u.test(e)&&$r("-v positional parameter"),/^[A-Za-z_][A-Za-z0-9_]*$/u.test(e)?Et(e,t).set:!1}function $r(e){throw new y("feature",`[[ ${e}`,`${e} in [[ is not supported`)}function tm(e,t,n,r){return e.define?(t.functions.set(e.define.name,e.define.body),U()):e.test?Qh(e.test,t):e.group?SE(e,t,n,r):e.loop?e.loop.words?kE(e.loop,t,r):yE(e.loop,t,r):vE(e.conditional,t,n,r)}var nm=1e4,em={kind:"feature",command:null,detail:"loop limit",message:`a loop running more than ${nm} times is not supported`};async function yE(e,t,n){let r=U(),o={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let i=0;;i++){if(i===nm){t.unsupported.add(em),_(r,x(`error: ${em.message}`,1));break}let s=r.ignored,u=r.exitCode,a=await n(e.condition,t,o,!0);if(_(r,a),r.exitCode=u,r.ignored=s,a.halt||a.control)return{...r,halt:a.halt,control:a.control,blame:a.blame};if(a.exitCode===0==!!e.until)break;let l=await n(e.body,t,o);if(_(r,l),r.blame=l.blame,l.halt)return{...r,halt:!0};if(l.control?.levels>1)return{...r,control:{...l.control,levels:l.control.levels-1}};if(l.control?.type==="break")break}}finally{t.loopDepth--}return r}var xE={value:"for",mask:null};async function kE(e,t,n){let r=await tr([xE,...e.words],t),o=U(),i={text:t.stdinLeft,bytes:t.stdinBytes};t.loopDepth++;try{for(let s of r.argv.slice(1)){t.vars.set(e.name,s);let u=await n(e.body,t,i);if(_(o,u),o.blame=u.blame,u.halt)return{...o,halt:!0};if(u.control?.levels>1)return{...o,control:{...u.control,levels:u.control.levels-1}};if(u.control?.type==="break")break}}finally{t.loopDepth--}return o}async function vE(e,t,n,r){let o=U(),i={text:n,bytes:t.stdinBytes};for(let u of e.branches){let a=await r(u.condition,t,i,!0);if(_(o,a),a.halt||a.control)return{...o,halt:a.halt,control:a.control,blame:a.blame};if(a.exitCode!==0)continue;let l=await r(u.body,t,i);return _(o,l),{...o,halt:l.halt,control:l.control,blame:l.blame}}if(!e.otherwise)return o.exitCode=0,o.ignored=!1,o;let s=await r(e.otherwise,t,i);return _(o,s),{...o,halt:s.halt,control:s.control,blame:s.blame}}async function SE(e,t,n,r){let o={text:n,bytes:t.stdinBytes};return e.isolate?{...await $t(t,()=>r(e.group,t,o)),halt:!1,control:void 0,ignored:!1}:r(e.group,t,o)}var EE=new Set(["sort","cat"]),$E=new Set(["wc","tac"]);function Yu(e){let t=null,n=null,r=i=>{t&&!t.bufferReads&&t.reads.push(i)},o=i=>{if(i!==void 0)for(let s=t;s;s=s.parent){if(!s.reads.includes(i)||s===t&&n?.scope===s&&(n.unsupported||s.buffered||n.fd===1&&(EE.has(s.name)||$E.has(s.name)&&!s.reads.slice(1).includes(i))))continue;if(s.failure)throw s.failure;let u=s===t&&n?.fd===2,a=u?"input modified by diagnostics":"streaming self-output",l=u?"reading input while diagnostics write to the same file is not supported":"writing to an actively read input file is not supported";throw s.failure=ie(new y("feature",a,l),"feature",s.name,a,l),s.failure}};return e.observeIo?.({read:r,write:o}),{read:r,bufferOutput(){t&&(t.buffered=!0)},bufferReads(i){if(!t)return i();let s=t,u=s.bufferReads;s.bufferReads=!0;try{return i()}finally{s.bufferReads=u}},setReads(i){t&&(t.reads=i)},async run(i,s){let u=t;t={name:i,reads:[],parent:u};try{return await s()}finally{t=u}},output(i,s,u){let a=n;n={scope:t,fd:null,unsupported:!!O(i)};try{for(let l of sn(i))l.text!==""&&(n.fd=l.fd,o(s.fds[l.fd]?.identity));return u((l,f)=>{n.fd=l.fd,ws(l,f)})}finally{n=a}}}}function Ku(e,t){let n={1:t.outputFds[1]?.path?t.outputFds[1]:"out",2:t.outputFds[2]?.path?t.outputFds[2]:"err"},r={1:rm(t.outputFds[1]),2:rm(t.outputFds[2])};return un(e,{fds:n,deferred:r},t)}var rm=e=>e!=="out"&&e!=="err"&&!e?.path;async function Nr(e,t,n,r=!1){if(e.some(u=>u.background))throw new y("feature","&","background processes (`&`) are not supported");let o=U(),i=null,s=null;for(let[u,a]of e.entries()){if(a.warnings&&_(o,un({...U(a.warnings),exitCode:o.exitCode,ignored:o.ignored},{fds:t.outputFds},t)),a.gate==="and"&&o.exitCode!==0){(s??=Ya()).skip(r?null:i,o.exitCode);continue}if(a.gate==="or"&&o.exitCode===0)continue;s?.flush(t.notes);let l=r||a.negate||NE(e,u),f=await(l?ce(t,{errexitOff:!0},()=>om(a.stages,t,n)):om(a.stages,t,n));if(_(o,f),a.negate&&!f.halt&&(o.exitCode=f.exitCode===0?1:0),l&&(o.ignored=!0),i=a.negate?null:f.blame,t.lastExit=o.exitCode,f.halt||f.control){Object.assign(o,{halt:f.halt,control:f.control});break}if(o.exitCode!==0&&!o.ignored&&t.errexit&&!t.errexitOff){o.halt=!0;break}}return s?.flush(t.notes),t.stdinLeft=n.text,t.stdinBytes=n.bytes??null,Object.assign(o,{blame:i})}var NE=(e,t)=>["and","or"].includes(e[t+1]?.gate);async function om(e,t,n){let r=U(),o=n.text,i=n.bytes??null;for(let s=0;s<e.length;s++){let u=e[s],a=s===0,l=s<e.length-1?AE():null,f={...t.outputFds};l&&(f[1]=l);let c=i,d=o,p=()=>OE(u,t,{stdin:d,stdinBytes:c,stdinFile:a&&t.stdinFile,fds:f,stdinPiped:a?t.stdinPiped:!0}),h=e.length>1?{...await $t(t,p),ignored:!1}:await p();a&&(n.text=h.inputLeft,n.bytes=h.bytesLeft??null),_(r,h);let m=l?.carried()??{text:""};i=m.bytes??null,o=m.text??me(m.bytes)??"",r.blame=h.blame,e.length===1&&(r.halt=h.halt,r.control=h.control)}return r}function AE(){let e="",t=null;return{write(n){t===null?e+=n:n!==""&&t.push(B(n))},writeBytes(n){t===null&&(t=e===""?[]:[B(e)],e=""),t.push(n)},carried:()=>t===null?{text:e}:{bytes:vn([...t,new Uint8Array])}}}function OE(e,t,{stdin:n,stdinBytes:r,stdinFile:o,fds:i,stdinPiped:s}){let u={fds:i,stdin:n,stdinBytes:r,stdinFile:o,stdinPiped:s,stdinOrigin:o?t.stdinOrigin:null,stdinHandle:o?t.stdinHandle:null};return ce(t,{substitutionExit:null,expansionOutput:U(),expansionFds:i},()=>Vu(u,t,async()=>{let a=!e.group&&!e.loop&&!e.conditional&&!e.test&&!e.define,l,f;try{a&&(l=await tr(e.words,t),l.argv.length===0?await _E(e.assigns,t):l.temps=await RE(e.assigns,t))}catch(w){f=Qo(t,w)}if(f)return _(t.expansionOutput,im(f,u,t)),{...t.expansionOutput,inputLeft:t.stdinLeft,bytesLeft:t.stdinBytes,halt:f.halt};let c=await CE(e,t,t.stdinLeft,o,i);t.expansionFds=c.fds;let d=!1,p=null,h=await Vu(c,t,()=>IE(t,async()=>{if(c.error)return c.error;if(!a){let S=await tm(e,t,c.stdin,Nr);return d=!0,p=S.blame??null,S}let w=l.argv.length>0?l.argv[0]:null,b=w===null?void 0:t.functions.get(w);if(b){if(d=!0,t.calling.has(w)){let S=v("feature",w,"function recursion",`${w}: a function calling itself is not supported`);return t.unsupported.add(O(S)),S}t.calling.add(w);try{return await ce(t,{loopDepth:0},async()=>({...await sm(l.temps,t,()=>Nr(b,t,{text:c.stdin,bytes:c.stdinBytes})),ignored:!1}))}finally{t.calling.delete(w)}}let k=await LE(t,l);return l.argv.length&&(p=Za(t.registry.chainRole(l.argv),l.argv[0])),k})),m=c.inherited?t.stdinLeft:c.parentLeft,g=c.inherited?t.stdinBytes:c.parentBytes;return _(t.expansionOutput,d?h:im(h,c,t)),{...t.expansionOutput,inputLeft:m,bytesLeft:g,halt:h.halt,control:h.control,blame:p}}))}function im(e,t,n){try{return un(e,t,n)}catch(r){return un(Qo(n,r),t,n)}}async function CE(e,t,n,r,o){let i={...o},s=n,u=r,a=u?t.stdinOrigin:null,l=u?t.stdinHandle:null,f=!0,c=n,d=!1,p=t.stdinBytes,h=p,m=!1,g=b=>({error:b,fds:i,stdin:s,stdinBytes:m?null:p,stdinFile:u,stdinPiped:d||t.stdinPiped,stdinOrigin:u?a:null,stdinHandle:u?l:null,inherited:f,parentLeft:c,parentBytes:h}),w=async b=>{let k=await ce(t,{expansionFds:i},()=>Vu({fds:i,stdin:s,stdinBytes:p,stdinFile:u,stdinOrigin:a,stdinHandle:l},t,b));return s=t.stdinLeft,p=t.stdinBytes,f&&(c=s,h=p),k};try{for(let b of e.redirs)if(b.op==="dup"){if(i[b.toFd]===void 0||i[b.toFd]==="closed")return g(x(`error: ${b.toFd}: Bad file descriptor`));i[b.fd]=i[b.toFd]}else if(b.op==="close")i[b.fd]="closed";else if(b.op==="to"){let k=b.target===void 0?await w(()=>Ws(b.word,t)):{value:b.target};if(k.error)return g(x(`error: ${k.error}`));let S=k.value==="/dev/null"?"null":k.value==="/dev/stdout"?i[1]:k.value==="/dev/stderr"?i[2]:t.writable?t.fs.openWritable(t.cwd,k.value,b.append):null;if(S===null){let I=Ri(b.label,k.value,t.writable);return t.unsupported.add(O(I)),g(x(`error: ${I.message}`))}if(S==="closed")return g(x(`error: ${k.value}: No such file or directory`));i[b.fd]=S,b.both&&(i[2]=S)}else if(b.op==="text")s=b.expand?await w(()=>jt(TE(b.body),t)):b.body,u=!1,f=!1,m=!0;else if(b.op==="herestring")s=await w(()=>jt(b.word,t))+`
|
|
267
|
+
`,u=!1,f=!1,m=!0;else{let k=await w(()=>Ws(b.word,t)),S=k.error?{error:x(`error: ${k.error}`)}:FE(k.value,t,u?a:s);if(S.error)return g(S.error);s=S.content,m=k.value!=="/dev/stdin",(k.value!=="/dev/stdin"||u)&&(f=!1),k.value!=="/dev/stdin"&&(u=k.value!=="/dev/null",a=u?s:null,l=S.handle,d=u)}if(u&&l){let b=t.io.bufferReads(()=>t.fs.readIdentity(l.identity));if(b!==l.content){if(f||s!==l.content)throw new y("feature","modified redirected input","reading an inherited input file after it changes is not supported");s=a=b,l={...l,content:b}}}}catch(b){return g(Qo(t,b))}return g()}function Qo(e,t){R(e,"shell",t?.path,t?.fsError);let n=O(t);return n&&e.unsupported.add(n),{...x(`error: ${V(t)}`,1),...t?.halt?{halt:!0}:{}}}async function IE(e,t){try{return await t()}catch(n){return Qo(e,n)}}function Vu(e,t,n){let r={outputFds:e.fds,closed:{out:e.fds[1]==="closed",err:e.fds[2]==="closed"},stdinFile:!!e.stdinFile,stdinPiped:e.stdinPiped??t.stdinPiped,stdinOrigin:e.stdinOrigin,stdinHandle:e.stdinHandle};return t.stdinLeft=e.stdin,t.stdinBytes=e.stdinBytes??null,ce(t,r,n)}function TE(e){let t="",n="";for(let r=0;r<e.length;r++){let o=e[r],i=e[r+1];if(o==="\\"&&(i==="$"||i==="\\"||i==="`")){t+=i,n+="1",r++;continue}if(o==="`"){let s=at(e,r);t+=s.raw,n+="2"+"1".repeat(s.raw.length-1),r+=s.raw.length-1;continue}if(o==="$"){let s=ft(e,r,0,!0);if(s?.command!==void 0||s?.parameter!==void 0||s?.arithmetic!==void 0){t+=s.raw,n+="2"+"1".repeat(s.raw.length-1),r+=s.raw.length-1;continue}}t+=o,n+="2"}return{value:t,mask:n}}function FE(e,t,n){if(e==="/dev/null")return{content:""};if(e==="/dev/stdin")return{content:n};let{path:r,error:o}=P(t,"shell",e);if(o)return{error:x(`error: ${e}: ${o}`)};if(t.fs.isFile(r)){let i=t.fs.readFile(r);return{content:i,handle:t.writable&&r.startsWith("/tmp/")?{path:r,content:i,identity:t.fs.fileIdentity(r)}:null}}return{error:x(`error: ${e}: Is a directory`)}}function LE(e,t){let{argv:n}=t;return n.length===0?{stdout:"",stderr:"",exitCode:e.substitutionExit??0}:sm(t.temps,e,()=>e.invoke(n[0],n.slice(1),e.stdinLeft))}async function _E(e,t){for(let n of e)t.vars.set(n.name,await jt(n.word,t,!0))}async function RE(e,t){if(e.length===0)return null;let n=t.vars,r=new Je(n),o=new Set(e.map(i=>i.name));r.bound=new Set;try{await ce(t,{vars:r},async()=>{for(let i of e){r.expansionTargets=o;let s=await jt(i.word,t,!0);r.expansionTargets=null,r.set(i.name,s)}})}finally{r.expansionTargets=null;for(let i of r.bound)o.has(i)||n.set(i,r.get(i))}return{vars:r,names:o}}async function sm(e,t,n){if(!e)return n();let r=t.vars,o=new Je(r),i=e.names;for(let s of i)o.set(s,e.vars.get(s));t.vars=o;try{return o.bound=new Set,await n()}finally{t.vars=r;for(let[s,u]of o)(!i.has(s)||o.bound?.has(s))&&r.set(s,u);for(let s of o.unsetNames)i.has(s)||r.delete(s)}}function am(e,t={}){let{fs:n,cwd:r,home:o,mount:i,writable:s,locale:u}=nl(e,t),a=t.commands===void 0?Zh:Xu(t.commands),l={fs:n,io:Yu(n),mount:i,writable:s,registry:a,createdAt:Date.now(),lock:{turn:Promise.resolve()}};return cm(fm(l,{cwd:r,home:o,user:t.user??"user",locale:u,...lm()}),"createTerminal")}var lm=()=>({vars:new Je,functions:new Map,lastExit:0,errexit:!1}),ME=e=>({vars:new Je(e.vars),functions:new Map(e.functions),lastExit:e.lastExit,errexit:e.errexit});function PE(e,t={}){let{cwd:n,home:r,user:o,locale:i,inherit:s}=rl(e,t),u=s?ME(e):lm();return cm(fm(e,{cwd:n,home:r,user:o,locale:i,...u}),"fork")}function fm({fs:e,io:t,mount:n,writable:r,registry:o,createdAt:i,lock:s},u){let a={fs:e,io:t,mount:n,writable:r,registry:o,createdAt:i,lock:s,...u,calling:new Set,outputFds:{1:"out",2:"err"},loopDepth:0,closed:{out:!1,err:!1},stdinFile:!1,stdinPiped:!1,stdinOrigin:null,stdinHandle:null,stdinLeft:"",stdinBytes:null,unsupported:ti(),notes:new Set};return a.dispatch=(l,f,c)=>ce(a,{stdinLeft:a.stdinLeft,stdinBytes:a.stdinBytes,stdinFile:!1,stdinPiped:!1,stdinOrigin:null,stdinHandle:null},()=>$t(a,()=>um(l,f,c,a,!0))),a.flushOutput=l=>Ku(l,a),a.hasCommand=l=>o.has(l)&&!o.shellOnly(l),a.invoke=(l,f,c)=>um(l,f,c,a),a.substitute=(l,f)=>Jh(l,a,Nr,f),a.runLine=l=>dm(l,a),a}function cm(e,t){if(!e.fs.isDir(e.cwd))throw new Error(`${t}: cwd is not a directory: ${e.cwd}`);return{run:n=>BE(e,n),cwd:()=>e.cwd,complete:n=>Kh(n,e,e.registry),fork:n=>PE(e,n)}}async function um(e,t,n,r,o=!1){let i=r.registry,s=i.resolveCommand(e),u=()=>{if((o||e!==s)&&i.shellOnly(s))return v("command",e,e,`${e}: shell builtin cannot be invoked as an external command`,127);let l=i.commands[s];return l?l(n,t,r):Yh(e,i)},a=l=>Ku(DE(r,bs(e,l,r),s),r);try{return await r.io.run(s,async()=>a(await u()))}catch(l){R(r,e,l?.path,l?.fsError);let f=`${e}: ${V(l)}`,c=O(l);return c&&r.unsupported.add({...c,command:c.command??e,message:f},c.command??s),a(x(f))}}function DE(e,t,n){let r=O(t);return r&&e.unsupported.add(r,n),t}function BE(e,t){let{lock:n}=e,r=n.turn.then(()=>dm(t,e));return n.turn=r.then(()=>null,()=>null),r}function dm(e,t){let n=ti();return ce(t,{unsupported:n,notes:new Set,discarded:new Set,stdinFile:!1,stdinPiped:!1,stdinOrigin:null,stdinHandle:null,stdinBytes:null,closed:{out:!1,err:!1},outputFds:{1:"out",2:"err"}},async()=>{let r={stdout:"",stderr:"",exitCode:0},o={text:""};try{for(let i of jl(e,t.writable,t.registry.has)){let s=await Nr(i,t,o);if(r.stdout+=s.stdout,r.stderr+=s.stderr,r.exitCode=s.exitCode,s.halt||s.control)break}}catch(i){let s=O(i);s&&n.add(s),t.lastExit=i.exitCode??(s?1:2),r.stderr+=`error: ${i.message}
|
|
268
|
+
`,r.exitCode=t.lastExit}return UE(r,t,n)})}var UE=(e,t,n)=>({stdout:e.stdout,stderr:e.stderr,exitCode:e.exitCode,cwd:t.cwd,unsupported:Object.freeze(n.entries),notes:Object.freeze([...t.notes,...yi(t.discarded,e.stderr,t.notes)])});var jE={unified:[[/^--- /u,"bold"],[/^\+\+\+ /u,"bold"],[cn,"cyan"],[/^\+/u,"green"],[/^-/u,"red"],[/^\\ /u,"gray"]],context:[[qt,"cyan"],[/^\*{3} \d/u,"cyan"],[/^--- \d/u,"cyan"],[/^\*{3} /u,"bold"],[/^--- /u,"bold"],[/^! /u,"yellow"],[/^\+ /u,"green"],[/^- /u,"red"]],normal:[[dn,"cyan"],[/^< /u,"red"],[/^> /u,"green"],[/^---$/u,"gray"]]};function WE(e){return e.some(t=>qt.test(t))?"context":e.some(t=>cn.test(t))?"unified":e.some(t=>dn.test(t))?"normal":null}function pm(e){let t=e.split(`
|
|
269
|
+
`),n=jE[WE(t)];return n===void 0?null:t.map(r=>n.find(([o])=>o.test(r))?.[1]??null)}var qE={bold:"head",cyan:"hunk",green:"add",red:"del",yellow:"chg",gray:"meta"};function hm(e){let t=pm(e);return t===null?null:e.split(`
|
|
270
|
+
`).map((n,r)=>({text:n,kind:t[r]===null?"":qE[t[r]]??""}))}function mm({stdout:e,stderr:t,unsupported:n}){return n.filter(r=>!t.includes(r.message)&&!e.includes(r.message)).map(r=>r.message)}var gm=`:host{display:flex;flex-direction:column;position:relative;height:100%;min-height:0;background:var(--bg, #0c0c0c);color:var(--text, #e6edf3);font-family:ui-monospace,SF Mono,Menlo,Consolas,monospace;font-size:13px;line-height:1.45}.output{flex:1 1 auto;overflow-y:auto;overscroll-behavior:none;-webkit-app-region:no-drag;app-region:no-drag;scrollbar-gutter:stable;padding:var(--terminal-output-padding, 12px 14px 6px);cursor:text}.banner{color:var(--muted, #8b949e);margin-bottom:8px;user-select:none}.banner .cmd{color:var(--accent, #58a6ff)}.banner .cmd:hover{text-decoration:underline}.line{white-space:pre-wrap;overflow-wrap:break-word}.cwd{color:var(--accent, #58a6ff)}.sigil{color:var(--muted, #8b949e)}.stdout,.stderr{margin:0 0 4px;font:inherit;white-space:pre-wrap;overflow-wrap:break-word}.stderr{color:var(--critical, #d8413a)}.diff-head{color:var(--text, #e6edf3);font-weight:600}.diff-hunk{color:var(--accent, #58a6ff)}.diff-add{color:var(--green, #3fb950)}.diff-del{color:var(--critical, #d8413a)}.diff-chg{color:var(--yellow, #d29922)}.diff-meta{color:var(--muted, #8b949e)}.form{flex:0 0 auto;display:flex;align-items:center;padding:var(--terminal-form-padding, 8px 14px 10px);border-top:1px solid var(--border, #2c2c2c)}.form:focus-within{border-top-color:var(--accent, #58a6ff)}.form[aria-busy=true] .sigil{opacity:.4}.form[aria-busy=true] .input{caret-color:transparent}.form .cwd{flex:0 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;user-select:none}.form .sigil{flex:0 0 auto;user-select:none;margin:0 1ch}.input-wrap{flex:1 1 auto;min-width:0;position:relative;display:flex;align-items:center}.input{width:100%;background:transparent;border:none;outline:none;color:inherit;font:inherit;padding:0;position:relative}.ghost{position:absolute;inset:0;display:flex;align-items:center;font:inherit;white-space:pre;overflow:hidden;pointer-events:none;user-select:none;color:var(--muted, #8b949e);opacity:.55}.ghost-pad{color:transparent}.notes{position:absolute;top:8px;right:14px;z-index:2;display:flex;flex-direction:column;align-items:flex-end;gap:6px;max-width:min(52%,320px);pointer-events:none}.note{box-sizing:border-box;padding:5px 9px;border:1px solid var(--border, #2c2c2c);border-radius:var(--ui-radius, 5px);background:var(--bg, #0c0c0c);color:var(--muted, #8b949e);font-size:12px;line-height:1.4;text-align:left;overflow-wrap:break-word;animation:note-in .14s ease-out,note-out .4s ease-in var(--dwell-out, 5.6s) forwards}.note-gap{border-color:var(--warning, #d97706);color:var(--text, #e6edf3)}@keyframes note-in{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}@keyframes note-out{to{opacity:0;transform:translateY(-4px)}}@media(prefers-reduced-motion:reduce){.note{animation:none}}
|
|
271
|
+
`;var Qu="/sources",HE={mount:Qu,home:"/",writable:"/tmp/"};function GE(e){let n=["ls","find /",`grep -r ${XE(e)} .`];if(!e||e.size===0)return n;let r=null;for(let[o,i]of e){if(typeof i!="string")continue;let s=ZE(o);(r===null||s.length<r.length)&&(r=s)}return r&&n.push(`cat ${r} | head -n 20`),n}var Ju=["TODO","FIXME","XXX","HACK","NOTE","BUG","export","import","require","//"];function XE(e){if(!e||e.size===0)return Ju[0];for(let t of Ju)for(let n of e.values())if(typeof n=="string"&&n.includes(t))return t;return Ju[0]}function ZE(e){return e.startsWith("./")?e.slice(2):e.startsWith("/")?e.slice(1):e}var ea=class e extends na{static properties={sources:{attribute:!1},_lines:{state:!0},_input:{state:!0},_cwd:{state:!0},_ghost:{state:!0},_notes:{state:!0},_running:{state:!0}};static styles=ra(gm);#n=null;#f=null;#t=[];#e=-1;#i="";#o=null;#s=null;static#h=200;#r=new Map;#m=0;static#g=3;static#w=400;constructor(){super(),this.sources=null,this._lines=[],this._input="",this._cwd=Qu,this._ghost="",this._notes=[],this._running=!1}willUpdate(t){t.has("sources")&&this.sources!==this.#f&&(this.#n=this.sources?am(this.sources,HE):null,this._cwd=this.#n?this.#n.cwd():Qu,this._lines=[{kind:"banner",commands:GE(this.sources)}],this.#t=[],this.#e=-1,this.#i="",this.#o=null,this._input="",this.#l(),this.#f=this.sources),t.has("_input")&&(this.#a(),this.#d())}connectedCallback(){super.connectedCallback(),this.updateComplete.then(()=>this.#c())}disconnectedCallback(){super.disconnectedCallback(),this.#a(),this.#l()}firstUpdated(){this.#u()}updated(t){(t.has("_lines")||t.has("sources"))&&this.#c()}#u(){let t=this.renderRoot.querySelector(".input");t&&t.focus()}#c(){let t=this.renderRoot.querySelector(".output");t&&(t.scrollTop=t.scrollHeight)}#b=async t=>{if(t.preventDefault(),!this.#n||this._running)return;let n=this._input,r=n.trim();if(r==="clear"){this._lines=[],this.#l(),this._input="",r.length>0&&(this.#t=[...this.#t,n]),this.#e=-1;return}let o=this._cwd;r.length>0&&(this.#t=[...this.#t,n]),this.#e=-1,this._input="";let i;this._running=!0;try{i=await this.#n.run(n)}catch(u){this._lines=[...this._lines,{kind:"prompt",cwd:o,text:n},{kind:"stderr",text:`${u?.message??u}
|
|
272
|
+
`}];return}finally{this._running=!1}this._cwd=i.cwd;let s=[...this._lines,{kind:"prompt",cwd:o,text:n}];i.stdout&&s.push({kind:"stdout",text:i.stdout,diff:hm(i.stdout)}),i.stderr&&s.push({kind:"stderr",text:i.stderr}),this._lines=s,this.#v(i)};#y=t=>{if(t.key==="Tab"&&!t.shiftKey){t.preventDefault(),this.#x();return}this.#o=null,t.key==="ArrowUp"?(t.preventDefault(),this.#A()):t.key==="ArrowDown"&&(t.preventDefault(),this.#O()),this.#a(),this.#d()};#x(){if(!this.#n)return;let t=this.#o;if(t&&t.items[t.index]===this._input){t.index=(t.index+1)%t.items.length,this._input=t.items[t.index];return}let n=this.#n.complete(this._input);if(n.length===0){this.#o=null;return}this._input=n[0],this.#o=n.length>1?{items:n,index:0}:null}#a(){this._ghost="",this.#s!==null&&(clearTimeout(this.#s),this.#s=null)}#d(){this.#s=setTimeout(()=>{this.#s=null,this.#k()},e.#h)}#k(){if(!this.#n||this.#o)return;let t=this._input,n=t.slice(-1),r=t===""||n===" "||n==="|",o=/[\w./]/u.test(n);if(!r&&!o)return;let i=this.#n.complete(t);if(i.length===0)return;let s=i[0];!s.startsWith(t)||s===t||o&&i.includes(t)||(this._ghost=s.slice(t.length))}#v(t){let n=t.notes.map(r=>({text:r,kind:"note"}));for(let r of mm(t))n.push({text:`silenced: ${r}`,kind:"gap"});this.#S(n)}#S(t){if(t.length===0)return;let n=[...this._notes];for(let{text:r,kind:o}of t){let i=n.findIndex(s=>s.text===r);i!==-1&&this.#p(n,i),n.push({id:++this.#m,text:r,kind:o,dwell:e.#E(r)})}for(;n.length>e.#g;)this.#p(n,0);for(let r of n)this.#r.has(r.id)||this.#r.set(r.id,setTimeout(()=>this.#N(r.id),r.dwell));this._notes=n}static#E(t){return Math.min(1e4,3200+t.length*55)}#p(t,n){let[r]=t.splice(n,1);this.#$(r.id)}#$(t){let n=this.#r.get(t);n!==void 0&&(clearTimeout(n),this.#r.delete(t))}#N(t){this.#r.delete(t),this._notes=this._notes.filter(n=>n.id!==t)}#l(){for(let t of this.#r.values())clearTimeout(t);this.#r.clear(),this._notes=[]}#A(){this.#t.length!==0&&(this.#e<0?(this.#i=this._input,this.#e=this.#t.length-1):this.#e=Math.max(0,this.#e-1),this._input=this.#t[this.#e])}#O(){if(this.#e<0)return;let t=this.#e+1;t>=this.#t.length?(this.#e=-1,this._input=this.#i,this.#i=""):(this.#e=t,this._input=this.#t[t])}#C=t=>{this._input=t.target.value};#I=t=>{this._input=t,this.#e=-1,this.#i="",this.#u()};#T=()=>{let t=this.renderRoot.getSelection?.()??document.getSelection();t&&!t.isCollapsed||this.#u()};render(){return De`<div class="notes" role="log" aria-atomic="false">${oa(this._notes,t=>t.id,t=>De`<div class="note ${t.kind==="gap"?"note-gap":""}" style="--dwell-out: ${t.dwell-e.#w}ms">${t.text}</div>`)}</div><div class="output" @click="${this.#T}">${this._lines.map(t=>this.#F(t))}</div><form class="form" @submit="${this.#b}" aria-busy="${this._running?"true":"false"}"><span class="cwd">${this._cwd}</span><span class="sigil">$</span><div class="input-wrap">${this._ghost?De`<div class="ghost" aria-hidden="true"><span class="ghost-pad">${this._input}</span>${this._ghost}</div>`:ei} <input class="input" type="text" aria-label="Terminal command" autocomplete="off" autocapitalize="off" autocorrect="off" spellcheck="false" .value="${this._input}" @input="${this.#C}" @keydown="${this.#y}"></div></form>`}#F(t){return t.kind==="banner"?De`<div class="banner">Virtual shell over the bundle source tree. Try ${t.commands.map((n,r)=>De`${r>0?", ":""}\`<span class="cmd" @click="${()=>this.#I(n)}">${n}</span>\``)}. ↑/↓ for history, Tab to complete.</div>`:t.kind==="prompt"?De`<div class="line"><span class="cwd">${t.cwd}</span>${" "}<span class="sigil">$</span>${" "}${t.text}</div>`:t.kind==="stdout"?this.#L(t):t.kind==="stderr"?De`<pre class="stderr">${t.text}</pre>`:ei}#L(t){if(!t.diff)return De`<pre class="stdout">${t.text}</pre>`;let n=t.diff.flatMap((r,o)=>{let i=r.kind?De`<span class="diff-${r.kind}">${r.text}</span>`:r.text;return o===0?[i]:[`
|
|
273
273
|
`,i]});return De`<pre class="stdout">${n}</pre>`}};customElements.define("bundle-terminal",ea);function L_(e,t){let n=document.createElement("bundle-terminal");return n.dataset.integrity=t??"",n.sources=e,n}export{L_ as createTerminalElement};
|