brsh 3.10.6 → 3.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/shell.min.js CHANGED
@@ -18,13 +18,21 @@
18
18
  `))e.length>0&&h.push(e);m=!0,b=!0;break}case`f`:{let e=g.slice(y+1);p=e.length>0?e:_[++v],m=!0,b=!0;break}default:return f||(this.stdErr=`grep: invalid option -- '${g[y]}'`),this.exitCode=2,Promise.resolve()}}else g.push(y);v++}for(;v<_.length;)g.push(_[v++]);if(p!==null){let e=``;if(p===`-`)e=typeof this.stdin==`string`?this.stdin:``;else{let t=this.fs.getFileByPath(p);if(t==null){if(!f){let e=this.fs.exists(p)?`Permission denied`:`No such file or directory`;this.stdErr=`grep: ${p}: ${e}`}return this.exitCode=2,Promise.resolve()}e=t.toString()}for(let t of e.split(`
19
19
  `))t.length>0&&h.push(t)}if(h.length===0&&!m){if(g.length===0)return this.stdErr=`grep: no pattern given`,this.exitCode=2,Promise.resolve();let e=g.shift();for(let t of e.split(`
20
20
  `))t.length>0&&h.push(t);h.length===0&&h.push(e)}let y=e?`gi`:`g`,b=[];for(let e of h){let t=c?e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`):e;u&&(t=`(?:^|\\W)(?:${t})(?:\\W|$)`),d&&(t=`^(?:${t})$`);try{b.push(new RegExp(t,y))}catch(e){return this.stdErr=`grep: invalid regex: ${e.message}`,this.exitCode=2,Promise.resolve()}}let x=[],S=!1,C=typeof this.stdin==`string`?this.stdin:``,w=(e,t=!1)=>{let n=this.fs.getFileByPath(e);if(n==null){if(!f){let t=this.fs.exists(e)?`Permission denied`:`No such file or directory`;this.stdErr=`grep: ${e}: ${t}`}S=!0;return}if(n.constructor===Object){if(!s){f||(this.stdErr=`grep: ${e}: Is a directory`),S=!0;return}if(!t&&this.fs.isSymlink&&this.fs.isSymlink(e))return;for(let t of Object.keys(n))w(e.replace(/\/$/,``)+`/`+t,!1);return}x.push({label:e,content:n.toString()})};if(g.length===0)x.push({label:null,content:C});else for(let e of g)e===`-`?x.push({label:`(standard input)`,content:C}):w(e,!0);let T=s||x.length+ +!!S>1,E=!1,D=e=>{if(b.length===0)return!1;for(let t of b)if(t.lastIndex=0,t.test(e))return!0;return!1},O=e=>{let t=[];for(let n of b){n.lastIndex=0;let r;for(;(r=n.exec(e))!==null;){if(r[0].length===0){n.lastIndex++;continue}if(t.push(r[0]),!n.global)break}}return t};for(let{label:e,content:s}of x){let c=s.split(`
21
- `);c.length>0&&c[c.length-1]===``&&c.pop();let u=0,d=[];for(let e=0;e<c.length;e++){let n=c[e],r,i=[];l&&!t?(i=O(n),r=i.length>0):r=D(n),r!==t&&(u++,d.push({text:n,num:e+1,segments:i}))}if(a){u===0&&(this.stdOut=e||`(standard input)`,E=!0);continue}if(u>0&&(E=!0),!o){if(i){u>0&&(this.stdOut=e||`(standard input)`);continue}if(r){let t=T&&e?`${e}:`:``;this.stdOut=`${t}${u}`;continue}for(let{text:t,num:r,segments:i}of d){let a=T&&e?`${e}:`:``,o=n?`${r}:`:``;if(l)for(let e of i)this.stdOut=`${a}${o}${e}`;else this.stdOut=`${a}${o}${t}`}}}return S&&!(o&&E)?this.exitCode=2:E||(this.exitCode=1),Promise.resolve()}}})),be=t(((e,t)=>{var n=w();t.exports=class extends n{static get name(){return`true`}run(){return Promise.resolve()}}})),xe=t(((e,t)=>{var n=w();t.exports=class extends n{static get name(){return`false`}run(){return this.exitCode=1,Promise.resolve()}}})),Se=t(((e,t)=>{var{Test:n,TestBracket:r}=le();t.exports=[ue(),ge(),_e(),ve(),ye(),be(),xe(),n,r]})),Ce=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`alias`}run(){if(this.arguments.length!==1)return Promise.reject(`alias requires a single argument`);let e=this.arguments[0].split(`=`);return e.length===2?(this.context.setAlias(e[0],e[1]),Promise.resolve()):Promise.reject(`alias requires a key and value delimited by '=' ie: key=value`)}}})),we=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`export`}run(){if(this.arguments.length!==1)return Promise.reject(`export requires a single argument`);let e=this.arguments[0].split(`=`);return e.length!==2&&Promise.reject(`export requires a key and value delimited by '=' ie: key=value`),this.context.setVar(e[0],e[1]),Promise.resolve()}}})),Te=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`cd`}run(){if(this.arguments.length!==1)return Promise.reject(`cd requires a single argument`);let e=this.context.fs.stat(this.arguments[0]);return e?e.isDirectory?(this.context.setCwd(this.arguments[0]),Promise.resolve()):Promise.reject(`${this.arguments[0]}: Not a directory`):Promise.reject(`file or directory not found`)}}})),Ee=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`chmod`}get requiresFilesystem(){return!0}run(){let e=this.arguments;if(e.length<2)return this.stdErr=`chmod: usage: chmod MODE FILE...`,this.exitCode=1,Promise.resolve();let t=e[0],n=e.slice(1);for(let e of n){if(!this.fs.exists(e)){this.stdErr=`chmod: cannot access '${e}': No such file or directory`,this.exitCode=1;continue}let n=this.fs.getMode(e),r=this._parseMode(t,n===null?420:n);if(r===null)return this.stdErr=`chmod: invalid mode: '${t}'`,this.exitCode=1,Promise.resolve();this.fs.setMode(e,r)}return Promise.resolve()}_parseMode(e,t){if(/^0?[0-7]{3,4}$/.test(e))return parseInt(e,8);let n=e.match(/^([ugoa]*)([+\-=])([rwx]+)$/);if(!n)return null;let[,r,i,a]=n,o=!r||r===`a`?[`u`,`g`,`o`]:r.split(``),s={u:256,g:32,o:4},c={u:128,g:16,o:2},l={u:64,g:8,o:1},u=0;for(let e of o)a.includes(`r`)&&(u|=s[e]),a.includes(`w`)&&(u|=c[e]),a.includes(`x`)&&(u|=l[e]);if(i===`+`)return t|u;if(i===`-`)return t&~u;if(i===`=`){let e=0;for(let t of o)e|=s[t]|c[t]|l[t];return t&~e|u}return null}}})),De=t(((e,t)=>{var n=T(),r=D();t.exports=class extends n{static get name(){return`cp`}get requiresFilesystem(){return!0}run(){let e=!1,t=null,n=!1,r=!1,i=null,a=[],o=[...this.arguments],s=0;for(;s<o.length;){let c=o[s];if(c===`--`){s++;break}if(c.startsWith(`-`)&&c.length>1)for(let a of c.slice(1))switch(a){case`r`:case`R`:e=!0,n=!0;break;case`a`:e=!0,n=!0,t=`preserve`,i=`preserve`;break;case`d`:case`P`:t=`preserve`,i=`preserve`;break;case`L`:t=`follow`,i=`follow`;break;case`H`:t=`follow_cl`,r=!0;break;case`f`:break}else a.push(c);s++}for(;s<o.length;)a.push(o[s++]);let c=t===null?n?`preserve`:`follow`:t;if(a.length<2)return this.stdErr=`cp: missing destination file operand${a.length?` after '${a[0]}'`:``}`,this.exitCode=1,Promise.resolve();let l=a[a.length-1],u=a.slice(0,-1),d=this.fs.stat(l),f=d!==null&&d.isDirectory,p=r||c===`follow_cl`?`follow`:c,m=r||c===`follow_cl`?i===null?`preserve`:i:c;for(let t of u){let n=this.fs.isSymlink?this.fs.isSymlink(t):!1,r=this.fs.stat(t);if(r===null){this.stdErr=`cp: cannot stat '${t}': No such file or directory`,this.exitCode=1;continue}if(!(n&&p===`preserve`)&&r.isDirectory&&!e){this.stdErr=`cp: omitting directory '${t}'`,this.exitCode=1;continue}let i=f?l.replace(/\/$/,``)+`/`+t.split(`/`).pop():l,a=this._copy(t,i,p,n,m);a&&(this.stdErr=a,this.exitCode=1)}return Promise.resolve()}_copy(e,t,n,i,a){if(i&&n===`preserve`&&this.fs.readSymlink){let n=this.fs.readSymlink(e);if(n===null)return`cp: cannot read symlink '${e}'`;try{this.fs.createSymlink(n,t)}catch(e){return`cp: cannot create symlink '${t}': ${e.message}`}return null}let o=this.fs.getFileByPath(e);if(o==null)return`cp: cannot stat '${e}': ${this.fs.exists(e)?`Permission denied`:`No such file or directory`}`;if(o.constructor===Object){try{this.fs.setFileByPath(t,{},!0)}catch(e){return`cp: cannot create directory '${t}': ${e.message}`}let n=this.fs.absolutePath(e),i;try{i=r.readdirSync(n)}catch{i=Object.keys(o)}for(let n of i){let r=e.replace(/\/$/,``)+`/`+n,i=t.replace(/\/$/,``)+`/`+n,o=this.fs.isSymlink?this.fs.isSymlink(r):!1,s=this._copy(r,i,a,o,a);s&&(this.stdErr=s,this.exitCode=1)}}else try{this.fs.setFileByPath(t,o,!0)}catch(e){return`cp: cannot create '${t}': ${e.message}`}return null}}})),Oe=t(((e,t)=>{var n=T(),r=(()=>{try{return D()}catch{return null}})();t.exports=class extends n{static get name(){return`ln`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=[],i=[...this.arguments],a=0;for(;a<i.length;){let r=i[a];if(r===`--`){a++;break}if(r.startsWith(`-`)&&r.length>1)for(let n of r.slice(1))switch(n){case`s`:e=!0;break;case`f`:t=!0;break;case`n`:break;case`v`:break}else n.push(r);a++}for(;a<i.length;)n.push(i[a++]);if(n.length<2)return this.stdErr=n.length===0?`ln: missing file operand`:`ln: missing destination file operand after '${n[0]}'`,this.exitCode=1,Promise.resolve();let o=n[n.length-1],s=n.slice(0,-1),c=this.fs.stat(o),l=c!==null&&c.isDirectory;for(let n of s){let i=l?o.replace(/\/$/,``)+`/`+n.split(`/`).pop():o;if(t&&this.fs.exists(i)&&!this.fs.stat(i)?.isDirectory)try{this.fs.deleteFileByPath(i)}catch{}if(e){if(!this.fs.createSymlink){this.stdErr=`ln: cannot create symlink '${i}': Operation not supported`,this.exitCode=1;continue}try{this.fs.createSymlink(n,i)}catch(e){this.stdErr=`ln: cannot create symlink '${i}': ${e.message}`,this.exitCode=1}}else{if(!this.fs.isRealFilesystem||!r){this.stdErr=`ln: cannot create hard link '${i}': Operation not supported`,this.exitCode=1;continue}if(!this.fs.exists(n)){this.stdErr=`ln: failed to create hard link '${i}' => '${n}': No such file or directory`,this.exitCode=1;continue}try{r.linkSync(this.fs.absolutePath(n),this.fs.absolutePath(i))}catch(e){this.stdErr=`ln: failed to create hard link '${i}' => '${n}': ${e.message}`,this.exitCode=1}}}return Promise.resolve()}}})),ke=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`mkdir`}get requiresFilesystem(){return!0}run(){let e=!1,t=[];for(let n of this.arguments)n===`-p`||n===`--parents`?e=!0:t.push(n);if(t.length===0)return this.stdErr=`mkdir: missing operand`,this.exitCode=1,Promise.resolve();for(let n of t){if(this.fs.exists(n)){e||(this.stdErr=`mkdir: cannot create directory '${n}': File exists`,this.exitCode=1);continue}try{this.fs.setFileByPath(n,{},e)}catch(e){this.stdErr=`mkdir: cannot create directory '${n}': ${e.message}`,this.exitCode=1}}return Promise.resolve()}}})),Ae=t(((e,t)=>{var n=T(),r=D();t.exports=class extends n{static get name(){return`mv`}get requiresFilesystem(){return!0}run(){let e=null,t=[],n=[...this.arguments],i=0;for(;i<n.length;){let r=n[i];if(r===`--`){i++;break}if(r.startsWith(`-`)&&r.length>1)for(let t=1;t<r.length;t++)switch(r[t]){case`f`:case`i`:case`n`:break;case`t`:{let a=r.slice(t+1);e=a.length>0?a:n[++i],t=r.length;break}}else t.push(r);i++}for(;i<n.length;)t.push(n[i++]);let a=e===null?t[t.length-1]:e,o=e===null?t.slice(0,-1):t;if(!a||o.length===0)return this.stdErr=`mv: missing destination file operand${o.length?` after '${o[0]}'`:``}`,this.exitCode=1,Promise.resolve();let s=this.fs.stat(a),c=s!==null&&s.isDirectory;for(let e of o){let t=c?a.replace(/\/$/,``)+`/`+e.split(`/`).pop():a;if(this.fs.isRealFilesystem){let n=this.fs.absolutePath(e),i=this.fs.absolutePath(t);try{r.lstatSync(n)}catch{this.stdErr=`mv: cannot stat '${e}': No such file or directory`,this.exitCode=1;continue}try{let e=Y();r.mkdirSync(e.dirname(i),{recursive:!0}),r.renameSync(n,i)}catch(n){this.stdErr=`mv: cannot move '${e}' to '${t}': ${n.message}`,this.exitCode=1}}else{let n=this.fs.getFileByPath(e);if(n==null){let t=this.fs.exists(e)?`Permission denied`:`No such file or directory`;this.stdErr=`mv: cannot stat '${e}': ${t}`,this.exitCode=1;continue}try{this.fs.setFileByPath(t,this._deepCopy(n),!0),this.fs.deleteFileByPath(e)}catch(n){this.stdErr=`mv: cannot move '${e}' to '${t}': ${n.message}`,this.exitCode=1}}}return Promise.resolve()}_deepCopy(e){if(e==null||typeof e==`function`||typeof e!=`object`)return e;let t={};for(let[n,r]of Object.entries(e))t[n]=this._deepCopy(r);return t}}})),je=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`pwd`}run(){let e=this.context.fs.cwd;return this.stdOut=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,Promise.resolve()}}})),Me=t(((e,t)=>{var n=T(),r=D();t.exports=class extends n{static get name(){return`rm`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=[];for(let r of this.arguments)/^-[rRf]+$/.test(r)?((r.includes(`r`)||r.includes(`R`))&&(e=!0),r.includes(`f`)&&(t=!0)):n.push(r);if(n.length===0)return t||(this.stdErr=`rm: missing operand`,this.exitCode=1),Promise.resolve();for(let r of n)try{this._remove(r,e,t)}catch(e){this.stdErr=e.message,this.exitCode=1}return Promise.resolve()}_remove(e,t,n){if(!(this.fs.isSymlink&&this.fs.isSymlink(e))){let i=this.fs.getFileByPath(e);if(i==null){if(!n)throw Error(`rm: cannot remove '${e}': No such file or directory`);return}if(i.constructor===Object){if(!t)throw Error(`rm: cannot remove '${e}': Is a directory`);let a;if(this.fs.isRealFilesystem)try{a=r.readdirSync(this.fs.absolutePath(e))}catch{a=[]}else a=Object.keys(i);for(let r of a){let i=e.replace(/\/$/,``)+`/`+r;this._remove(i,t,n)}}}this.fs.deleteFileByPath(e)}}})),Ne=t(((e,t)=>{var n=T(),r=(()=>{try{return D()}catch{return null}})();t.exports=class extends n{static get name(){return`stat`}get requiresFilesystem(){return!0}run(){let e=[];for(let t of this.arguments){if(t===`--`)break;t.startsWith(`-`)||e.push(t)}if(e.length===0)return this.stdErr=`stat: missing operand`,this.exitCode=1,Promise.resolve();for(let t of e){let e=this.fs.isSymlink?this.fs.isSymlink(t):!1;if(!this.fs.exists(t)&&!e){this.stdErr=`stat: cannot stat '${t}': No such file or directory`,this.exitCode=1;continue}this.stdOut=this._format(t,e)}return Promise.resolve()}_format(e,t){let n=this.fs.absolutePath(e);if(this.fs.isRealFilesystem&&r)try{let e=r.lstatSync(n),t=e.isSymbolicLink()?`l`:e.isDirectory()?`d`:`-`,i=e.isSymbolicLink()?`symbolic link`:e.isDirectory()?`directory`:`regular file`,a=(e.mode&511).toString(8).padStart(4,`0`),o=t+this._rwxBits(e.mode&511);return[` File: ${n}${e.isSymbolicLink()?` -> ${r.readlinkSync(n)}`:``}`,` Size: ${e.size}\t\tBlocks: ${e.blocks}\t\tIO Block: ${e.blksize}\t${i}`,`Device: ${e.dev}\t\tInode: ${e.ino}\t\tLinks: ${e.nlink}`,`Access: (${a}/${o})\tUid: ${e.uid}\tGid: ${e.gid}`,`Access: ${e.atime.toISOString()}`,`Modify: ${e.mtime.toISOString()}`,`Change: ${e.ctime.toISOString()}`].join(`
21
+ `);c.length>0&&c[c.length-1]===``&&c.pop();let u=0,d=[];for(let e=0;e<c.length;e++){let n=c[e],r,i=[];l&&!t?(i=O(n),r=i.length>0):r=D(n),r!==t&&(u++,d.push({text:n,num:e+1,segments:i}))}if(a){u===0&&(this.stdOut=e||`(standard input)`,E=!0);continue}if(u>0&&(E=!0),!o){if(i){u>0&&(this.stdOut=e||`(standard input)`);continue}if(r){let t=T&&e?`${e}:`:``;this.stdOut=`${t}${u}`;continue}for(let{text:t,num:r,segments:i}of d){let a=T&&e?`${e}:`:``,o=n?`${r}:`:``;if(l)for(let e of i)this.stdOut=`${a}${o}${e}`;else this.stdOut=`${a}${o}${t}`}}}return S&&!(o&&E)?this.exitCode=2:E||(this.exitCode=1),Promise.resolve()}}})),be=t(((e,t)=>{function n(e,t,n){if(t===void 0||t===`-`)return typeof e.stdin==`string`?e.stdin:(e.stdErr=`${n}: no input`,e.exitCode=1,null);let r=e.fs.getFileByPath(t);return r==null?(e.stdErr=`${n}: ${t}: ${e.fs.exists(t)?`Permission denied`:`No such file or directory`}`,e.exitCode=1,null):r.constructor===Object?(e.stdErr=`${n}: ${t}: Is a directory`,e.exitCode=1,null):r.toString()}function r(e){return e===``?[]:(e.endsWith(`
22
+ `)?e.slice(0,-1):e).split(`
23
+ `)}t.exports={readInput:n,toLines:r}})),xe=t(((e,t)=>{var n=w(),{readInput:r,toLines:i}=be(),a={alpha:`a-zA-Z`,digit:`0-9`,alnum:`a-zA-Z0-9`,upper:`A-Z`,lower:`a-z`,space:`\\s`,blank:` \\t`,punct:"!-\\/:-@\\[-`{-~",xdigit:`0-9A-Fa-f`};function o(e,t){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(i===`[`){let t=r+1,i=`[`;for(e[t]===`^`&&(i+=`^`,t++),e[t]===`]`&&(i+=`\\]`,t++);t<e.length&&e[t]!==`]`;t++){let n=/^\[:(\w+):\]/.exec(e.slice(t));n&&a[n[1]]?(i+=a[n[1]],t+=n[0].length-1):i+=e[t]===`\\`?`\\\\`:e[t]}if(t>=e.length)throw Error(`unterminated address regex`);n+=`${i}]`,r=t}else if(i===`\\`&&r+1<e.length){let i=e[++r];n+=!t&&`(){}+?|`.includes(i)?i:`\\${i}`}else !t&&`(){}+?|`.includes(i)?n+=`\\${i}`:!t&&i===`*`&&(n===``||n.endsWith(`(`))?n+=`\\*`:n+=i}return n}function s(e,t,n){let r=``;for(;t<e.length;t++)if(e[t]===`\\`&&t+1<e.length)r+=e[t+1]===n?n:`\\${e[t+1]}`,t++;else if(e[t]===n)return[r,t+1];else r+=e[t];throw Error(`unterminated command`)}function c(e){let t=[],n=``;for(let r=0;r<e.length;r++)if(e[r]===`\\`&&r+1<e.length){let i=e[++r];/\d/.test(i)?(n&&t.push(n),n=``,t.push(parseInt(i,10))):n+=i===`n`?`
24
+ `:i===`t`?` `:i}else e[r]===`&`?(n&&t.push(n),n=``,t.push(0)):n+=e[r];return n&&t.push(n),t}t.exports=class extends n{static get name(){return`sed`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=[],a=[],o=this.arguments;for(let r=0;r<o.length;r++){let i=o[r];if(i===`--`){a.push(...o.slice(r+1));break}if(i.length<2||!i.startsWith(`-`)){a.push(i);continue}for(let a=1;a<i.length;a++){let s=i[a];if(s===`n`)e=!0;else if(s===`E`||s===`r`)t=!0;else if(s===`e`){n.push(a+1<i.length?i.slice(a+1):o[++r]);break}else return this._fail(`invalid option -- ${s}`)}}if(n.length<1&&a.length>0&&n.push(a.shift()),n.length<1||n.some(e=>e===void 0))return this._fail(`usage: sed [-nEr] [-e script] script [file ...]`);let s;try{this.lastRe=null,s=this._parse(n.join(`
25
+ `),t)}catch(e){return this._fail(e.message)}let c=(a.length>0?a:[void 0]).map(e=>r(this,e,`sed`)).filter(e=>e!==null).flatMap(i);return this._execute(s,c,e),Promise.resolve()}_fail(e){return this.stdErr=e.startsWith(`usage`)?e:`sed: ${e}`,this.exitCode=1,Promise.resolve()}_regex(e,t,n){if(e===``){if(!this.lastRe)throw Error(`no previous regular expression`);return new RegExp(this.lastRe.source,n)}let r=new RegExp(o(e,t),n);return this.lastRe=r,r}_parse(e,t){let n=[],r=0,i=t=>{for(;r<e.length&&t.includes(e[r]);)r++},a=()=>{if(/\d/.test(e[r]||``)){let t=r;return i(`0123456789`),{type:`line`,n:parseInt(e.slice(t,r),10)}}if(e[r]===`$`)return r++,{type:`last`};if(e[r]===`/`){let[n,i]=s(e,r+1,`/`);return r=i,{type:`re`,re:this._regex(n,t,``)}}};for(i(`
26
+ ;`);r<e.length;i(`
27
+ ;`)){let o={};if(o.a1=a(),o.a1&&e[r]===`,`&&(r++,o.a2=a(),!o.a2))throw Error("unexpected `,'");if(i(` `),e[r]===`!`&&(o.negate=!0,r++,i(` `)),o.name=e[r++],o.name===`s`){let n=e[r++];if(!n||n===`
28
+ `||n===`\\`)throw Error("unterminated `s' command");let[i,a]=s(e,r,n),[l,u]=s(e,a,n);r=u,o.global=!1,o.print=!1,o.nth=1;let d=`g`;for(;r<e.length&&/[gpiI\d]/.test(e[r]);r++){let t=e[r];t===`g`?o.global=!0:t===`p`?o.print=!0:t===`i`||t===`I`?d+=`i`:o.nth=parseInt(t,10)||1}o.re=this._regex(i,t,d),o.replacement=c(l)}else if(o.name===`y`){let t=e[r++],[n,i]=s(e,r,t),[a,c]=s(e,i,t);if(r=c,n.length!==a.length)throw Error("strings for `y' command are different lengths");o.map=Object.fromEntries([...n].map((e,t)=>[e,a[t]]))}else if(!`dpq=`.includes(o.name||`?`))throw Error(`unknown command: \`${o.name||``}'`);if(i(` `),r<e.length&&!`;
29
+ `.includes(e[r]))throw Error(`extra characters after command`);n.push(o)}return n}_matches(e,t,n,r){return e.type===`line`?t===e.n:e.type===`last`?t===r:e.re.test(n)}_selected(e,t,n,r){return e.a1?e.a2?e.active?((e.a2.type===`line`?t>=e.a2.n:this._matches(e.a2,t,n,r))&&delete e.active,!0):this._matches(e.a1,t,n,r)?(e.a2.type===`line`&&e.a2.n<=t||(e.active=!0),!0):!1:this._matches(e.a1,t,n,r):!0}_substitute(e,t){let n=0,r=!1;return{out:t.replace(e.re,(...t)=>{if(n++,n<e.nth||!e.global&&n>e.nth)return t[0];r=!0;let i=t.slice(0,-2);return e.replacement.map(e=>typeof e==`number`?i[e]||``:e).join(``)}),replaced:r}}_execute(e,t,n){for(let r=0;r<t.length;r++){let i=r+1,a=t[r],o=!1,s=!1;for(let n of e)if(this._selected(n,i,a,t.length)!==!!n.negate){if(n.name===`s`){let{out:e,replaced:t}=this._substitute(n,a);a=e,t&&n.print&&(this.stdOut=a)}else if(n.name===`y`)a=[...a].map(e=>n.map[e]??e).join(``);else if(n.name===`p`)this.stdOut=a;else if(n.name===`=`)this.stdOut=String(i);else if(n.name===`d`){o=!0;break}else if(n.name===`q`){s=!0;break}}if(!n&&!o&&(this.stdOut=a),s)return}}}})),Se=t(((e,t)=>{var n=w(),{readInput:r,toLines:i}=be();t.exports=class extends n{static get name(){return`tail`}get requiresFilesystem(){return!0}run(){let e=`10`,t=!1,n=[],a=this.arguments;for(let r=0;r<a.length;r++){let i=a[r];if(i===`-n`||i===`-c`)t=i===`-c`,e=a[++r];else if(/^-[nc]./.test(i))t=i[1]===`c`,e=i.slice(2);else if(/^-\d+$/.test(i)||/^\+\d+$/.test(i))e=i;else if(i===`-f`||i===`-q`)continue;else if(i.startsWith(`-`)&&i.length>1)return this.stdErr=`tail: invalid option -- ${i.slice(1)}`,this.exitCode=1,Promise.resolve();else n.push(i)}if(!/^[+-]?\d+$/.test(e||``))return this.stdErr=`tail: invalid number: ${e}`,this.exitCode=1,Promise.resolve();let o=e.startsWith(`+`),s=Math.abs(parseInt(e,10)),c=n.length>0?n:[void 0];return c.forEach((e,n)=>{let a=r(this,e,`tail`);if(a===null)return;if(c.length>1&&(n>0&&(this.stdOut=``),this.stdOut=`==> ${e===void 0?`standard input`:e} <==`),t){i(o?a.slice(Math.max(s-1,0)):s<1?``:a.slice(-s)).forEach(e=>this.stdOut=e);return}let l=i(a);(o?l.slice(Math.max(s-1,0)):s<1?[]:l.slice(-s)).forEach(e=>this.stdOut=e)}),Promise.resolve()}}})),Ce=t(((e,t)=>{var n=w();t.exports=class extends n{static get name(){return`true`}run(){return Promise.resolve()}}})),we=t(((e,t)=>{var n=w();t.exports=class extends n{static get name(){return`false`}run(){return this.exitCode=1,Promise.resolve()}}})),Te=t(((e,t)=>{var{Test:n,TestBracket:r}=le();t.exports=[ue(),ge(),_e(),ve(),ye(),xe(),Se(),Ce(),we(),n,r]})),Ee=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`alias`}run(){if(this.arguments.length!==1)return Promise.reject(`alias requires a single argument`);let e=this.arguments[0].split(`=`);return e.length===2?(this.context.setAlias(e[0],e[1]),Promise.resolve()):Promise.reject(`alias requires a key and value delimited by '=' ie: key=value`)}}})),De=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`export`}run(){if(this.arguments.length!==1)return Promise.reject(`export requires a single argument`);let e=this.arguments[0].split(`=`);return e.length!==2&&Promise.reject(`export requires a key and value delimited by '=' ie: key=value`),this.context.setVar(e[0],e[1]),Promise.resolve()}}})),Oe=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`cd`}run(){if(this.arguments.length!==1)return Promise.reject(`cd requires a single argument`);let e=this.context.fs.stat(this.arguments[0]);return e?e.isDirectory?(this.context.setCwd(this.arguments[0]),Promise.resolve()):Promise.reject(`${this.arguments[0]}: Not a directory`):Promise.reject(`file or directory not found`)}}})),ke=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`chmod`}get requiresFilesystem(){return!0}run(){let e=this.arguments;if(e.length<2)return this.stdErr=`chmod: usage: chmod MODE FILE...`,this.exitCode=1,Promise.resolve();let t=e[0],n=e.slice(1);for(let e of n){if(!this.fs.exists(e)){this.stdErr=`chmod: cannot access '${e}': No such file or directory`,this.exitCode=1;continue}let n=this.fs.getMode(e),r=this._parseMode(t,n===null?420:n);if(r===null)return this.stdErr=`chmod: invalid mode: '${t}'`,this.exitCode=1,Promise.resolve();this.fs.setMode(e,r)}return Promise.resolve()}_parseMode(e,t){if(/^0?[0-7]{3,4}$/.test(e))return parseInt(e,8);let n=e.match(/^([ugoa]*)([+\-=])([rwx]+)$/);if(!n)return null;let[,r,i,a]=n,o=!r||r===`a`?[`u`,`g`,`o`]:r.split(``),s={u:256,g:32,o:4},c={u:128,g:16,o:2},l={u:64,g:8,o:1},u=0;for(let e of o)a.includes(`r`)&&(u|=s[e]),a.includes(`w`)&&(u|=c[e]),a.includes(`x`)&&(u|=l[e]);if(i===`+`)return t|u;if(i===`-`)return t&~u;if(i===`=`){let e=0;for(let t of o)e|=s[t]|c[t]|l[t];return t&~e|u}return null}}})),Ae=t(((e,t)=>{var n=T(),r=D();t.exports=class extends n{static get name(){return`cp`}get requiresFilesystem(){return!0}run(){let e=!1,t=null,n=!1,r=!1,i=null,a=[],o=[...this.arguments],s=0;for(;s<o.length;){let c=o[s];if(c===`--`){s++;break}if(c.startsWith(`-`)&&c.length>1)for(let a of c.slice(1))switch(a){case`r`:case`R`:e=!0,n=!0;break;case`a`:e=!0,n=!0,t=`preserve`,i=`preserve`;break;case`d`:case`P`:t=`preserve`,i=`preserve`;break;case`L`:t=`follow`,i=`follow`;break;case`H`:t=`follow_cl`,r=!0;break;case`f`:break}else a.push(c);s++}for(;s<o.length;)a.push(o[s++]);let c=t===null?n?`preserve`:`follow`:t;if(a.length<2)return this.stdErr=`cp: missing destination file operand${a.length?` after '${a[0]}'`:``}`,this.exitCode=1,Promise.resolve();let l=a[a.length-1],u=a.slice(0,-1),d=this.fs.stat(l),f=d!==null&&d.isDirectory,p=r||c===`follow_cl`?`follow`:c,m=r||c===`follow_cl`?i===null?`preserve`:i:c;for(let t of u){let n=this.fs.isSymlink?this.fs.isSymlink(t):!1,r=this.fs.stat(t);if(r===null){this.stdErr=`cp: cannot stat '${t}': No such file or directory`,this.exitCode=1;continue}if(!(n&&p===`preserve`)&&r.isDirectory&&!e){this.stdErr=`cp: omitting directory '${t}'`,this.exitCode=1;continue}let i=f?l.replace(/\/$/,``)+`/`+t.split(`/`).pop():l,a=this._copy(t,i,p,n,m);a&&(this.stdErr=a,this.exitCode=1)}return Promise.resolve()}_copy(e,t,n,i,a){if(i&&n===`preserve`&&this.fs.readSymlink){let n=this.fs.readSymlink(e);if(n===null)return`cp: cannot read symlink '${e}'`;try{this.fs.createSymlink(n,t)}catch(e){return`cp: cannot create symlink '${t}': ${e.message}`}return null}let o=this.fs.getFileByPath(e);if(o==null)return`cp: cannot stat '${e}': ${this.fs.exists(e)?`Permission denied`:`No such file or directory`}`;if(o.constructor===Object){try{this.fs.setFileByPath(t,{},!0)}catch(e){return`cp: cannot create directory '${t}': ${e.message}`}let n=this.fs.absolutePath(e),i;try{i=r.readdirSync(n)}catch{i=Object.keys(o)}for(let n of i){let r=e.replace(/\/$/,``)+`/`+n,i=t.replace(/\/$/,``)+`/`+n,o=this.fs.isSymlink?this.fs.isSymlink(r):!1,s=this._copy(r,i,a,o,a);s&&(this.stdErr=s,this.exitCode=1)}}else try{this.fs.setFileByPath(t,o,!0)}catch(e){return`cp: cannot create '${t}': ${e.message}`}return null}}})),je=t(((e,t)=>{var n=T(),r=(()=>{try{return D()}catch{return null}})();t.exports=class extends n{static get name(){return`ln`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=[],i=[...this.arguments],a=0;for(;a<i.length;){let r=i[a];if(r===`--`){a++;break}if(r.startsWith(`-`)&&r.length>1)for(let n of r.slice(1))switch(n){case`s`:e=!0;break;case`f`:t=!0;break;case`n`:break;case`v`:break}else n.push(r);a++}for(;a<i.length;)n.push(i[a++]);if(n.length<2)return this.stdErr=n.length===0?`ln: missing file operand`:`ln: missing destination file operand after '${n[0]}'`,this.exitCode=1,Promise.resolve();let o=n[n.length-1],s=n.slice(0,-1),c=this.fs.stat(o),l=c!==null&&c.isDirectory;for(let n of s){let i=l?o.replace(/\/$/,``)+`/`+n.split(`/`).pop():o;if(t&&this.fs.exists(i)&&!this.fs.stat(i)?.isDirectory)try{this.fs.deleteFileByPath(i)}catch{}if(e){if(!this.fs.createSymlink){this.stdErr=`ln: cannot create symlink '${i}': Operation not supported`,this.exitCode=1;continue}try{this.fs.createSymlink(n,i)}catch(e){this.stdErr=`ln: cannot create symlink '${i}': ${e.message}`,this.exitCode=1}}else{if(!this.fs.isRealFilesystem||!r){this.stdErr=`ln: cannot create hard link '${i}': Operation not supported`,this.exitCode=1;continue}if(!this.fs.exists(n)){this.stdErr=`ln: failed to create hard link '${i}' => '${n}': No such file or directory`,this.exitCode=1;continue}try{r.linkSync(this.fs.absolutePath(n),this.fs.absolutePath(i))}catch(e){this.stdErr=`ln: failed to create hard link '${i}' => '${n}': ${e.message}`,this.exitCode=1}}}return Promise.resolve()}}})),Me=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`mkdir`}get requiresFilesystem(){return!0}run(){let e=!1,t=[];for(let n of this.arguments)n===`-p`||n===`--parents`?e=!0:t.push(n);if(t.length===0)return this.stdErr=`mkdir: missing operand`,this.exitCode=1,Promise.resolve();for(let n of t){if(this.fs.exists(n)){e||(this.stdErr=`mkdir: cannot create directory '${n}': File exists`,this.exitCode=1);continue}try{this.fs.setFileByPath(n,{},e)}catch(e){this.stdErr=`mkdir: cannot create directory '${n}': ${e.message}`,this.exitCode=1}}return Promise.resolve()}}})),Ne=t(((e,t)=>{var n=T(),r=D();t.exports=class extends n{static get name(){return`mv`}get requiresFilesystem(){return!0}run(){let e=null,t=[],n=[...this.arguments],i=0;for(;i<n.length;){let r=n[i];if(r===`--`){i++;break}if(r.startsWith(`-`)&&r.length>1)for(let t=1;t<r.length;t++)switch(r[t]){case`f`:case`i`:case`n`:break;case`t`:{let a=r.slice(t+1);e=a.length>0?a:n[++i],t=r.length;break}}else t.push(r);i++}for(;i<n.length;)t.push(n[i++]);let a=e===null?t[t.length-1]:e,o=e===null?t.slice(0,-1):t;if(!a||o.length===0)return this.stdErr=`mv: missing destination file operand${o.length?` after '${o[0]}'`:``}`,this.exitCode=1,Promise.resolve();let s=this.fs.stat(a),c=s!==null&&s.isDirectory;for(let e of o){let t=c?a.replace(/\/$/,``)+`/`+e.split(`/`).pop():a;if(this.fs.isRealFilesystem){let n=this.fs.absolutePath(e),i=this.fs.absolutePath(t);try{r.lstatSync(n)}catch{this.stdErr=`mv: cannot stat '${e}': No such file or directory`,this.exitCode=1;continue}try{let e=Y();r.mkdirSync(e.dirname(i),{recursive:!0}),r.renameSync(n,i)}catch(n){this.stdErr=`mv: cannot move '${e}' to '${t}': ${n.message}`,this.exitCode=1}}else{let n=this.fs.getFileByPath(e);if(n==null){let t=this.fs.exists(e)?`Permission denied`:`No such file or directory`;this.stdErr=`mv: cannot stat '${e}': ${t}`,this.exitCode=1;continue}try{this.fs.setFileByPath(t,this._deepCopy(n),!0),this.fs.deleteFileByPath(e)}catch(n){this.stdErr=`mv: cannot move '${e}' to '${t}': ${n.message}`,this.exitCode=1}}}return Promise.resolve()}_deepCopy(e){if(e==null||typeof e==`function`||typeof e!=`object`)return e;let t={};for(let[n,r]of Object.entries(e))t[n]=this._deepCopy(r);return t}}})),Pe=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`pwd`}run(){let e=this.context.fs.cwd;return this.stdOut=e.endsWith(`/`)&&e!==`/`?e.slice(0,-1):e,Promise.resolve()}}})),Fe=t(((e,t)=>{var n=T(),r=D();t.exports=class extends n{static get name(){return`rm`}get requiresFilesystem(){return!0}run(){let e=!1,t=!1,n=[];for(let r of this.arguments)/^-[rRf]+$/.test(r)?((r.includes(`r`)||r.includes(`R`))&&(e=!0),r.includes(`f`)&&(t=!0)):n.push(r);if(n.length===0)return t||(this.stdErr=`rm: missing operand`,this.exitCode=1),Promise.resolve();for(let r of n)try{this._remove(r,e,t)}catch(e){this.stdErr=e.message,this.exitCode=1}return Promise.resolve()}_remove(e,t,n){if(!(this.fs.isSymlink&&this.fs.isSymlink(e))){let i=this.fs.getFileByPath(e);if(i==null){if(!n)throw Error(`rm: cannot remove '${e}': No such file or directory`);return}if(i.constructor===Object){if(!t)throw Error(`rm: cannot remove '${e}': Is a directory`);let a;if(this.fs.isRealFilesystem)try{a=r.readdirSync(this.fs.absolutePath(e))}catch{a=[]}else a=Object.keys(i);for(let r of a){let i=e.replace(/\/$/,``)+`/`+r;this._remove(i,t,n)}}}this.fs.deleteFileByPath(e)}}})),Ie=t(((e,t)=>{var n=T(),r=(()=>{try{return D()}catch{return null}})();t.exports=class extends n{static get name(){return`stat`}get requiresFilesystem(){return!0}run(){let e=[];for(let t of this.arguments){if(t===`--`)break;t.startsWith(`-`)||e.push(t)}if(e.length===0)return this.stdErr=`stat: missing operand`,this.exitCode=1,Promise.resolve();for(let t of e){let e=this.fs.isSymlink?this.fs.isSymlink(t):!1;if(!this.fs.exists(t)&&!e){this.stdErr=`stat: cannot stat '${t}': No such file or directory`,this.exitCode=1;continue}this.stdOut=this._format(t,e)}return Promise.resolve()}_format(e,t){let n=this.fs.absolutePath(e);if(this.fs.isRealFilesystem&&r)try{let e=r.lstatSync(n),t=e.isSymbolicLink()?`l`:e.isDirectory()?`d`:`-`,i=e.isSymbolicLink()?`symbolic link`:e.isDirectory()?`directory`:`regular file`,a=(e.mode&511).toString(8).padStart(4,`0`),o=t+this._rwxBits(e.mode&511);return[` File: ${n}${e.isSymbolicLink()?` -> ${r.readlinkSync(n)}`:``}`,` Size: ${e.size}\t\tBlocks: ${e.blocks}\t\tIO Block: ${e.blksize}\t${i}`,`Device: ${e.dev}\t\tInode: ${e.ino}\t\tLinks: ${e.nlink}`,`Access: (${a}/${o})\tUid: ${e.uid}\tGid: ${e.gid}`,`Access: ${e.atime.toISOString()}`,`Modify: ${e.mtime.toISOString()}`,`Change: ${e.ctime.toISOString()}`].join(`
22
30
  `)}catch(t){return`stat: cannot stat '${e}': ${t.message}`}let i=this.fs.stat(e),a=this.fs.getMode(e)??420,o=this.fs.getSize(e),s=t?`l`:i?.isDirectory?`d`:`-`,c=t?`symbolic link`:i?.isDirectory?`directory`:(i?.isCommand,`regular file`),l=a.toString(8).padStart(4,`0`),u=s+this._rwxBits(a);return[` File: ${n}${t&&this.fs.readSymlink?` -> ${this.fs.readSymlink(e)}`:``}`,` Size: ${o}\t\tType: ${c}`,`Access: (${l}/${u})`].join(`
23
- `)}_rwxBits(e){return[e&256?`r`:`-`,e&128?`w`:`-`,e&64?`x`:`-`,e&32?`r`:`-`,e&16?`w`:`-`,e&8?`x`:`-`,e&4?`r`:`-`,e&2?`w`:`-`,e&1?`x`:`-`].join(``)}}})),Pe=t(((e,t)=>{var n=T(),r=(()=>{try{return D()}catch{return null}})();t.exports=class extends n{static get name(){return`touch`}get requiresFilesystem(){return!0}run(){let e=!1,t=[];for(let n of this.arguments){if(n===`--`)break;if(n.startsWith(`-`)&&n.length>1)for(let t of n.slice(1))t===`c`&&(e=!0);else t.push(n)}if(t.length===0)return this.stdErr=`touch: missing file operand`,this.exitCode=1,Promise.resolve();let n=new Date;for(let i of t)if(this.fs.exists(i)){if(r&&this.fs.isRealFilesystem)try{r.utimesSync(this.fs.absolutePath(i),n,n)}catch(e){this.stdErr=`touch: cannot touch '${i}': ${e.message}`,this.exitCode=1}}else{if(e)continue;try{this.fs.setFileByPath(i,``,!0)}catch(e){this.stdErr=`touch: cannot touch '${i}': ${e.message}`,this.exitCode=1}}return Promise.resolve()}}})),Fe=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`which`}run(){if(this.arguments.length!==1)return Promise.reject(`which requires a single argument`);let e=`${this.context.getVar(`PATH`)}/${this.arguments[0]}`,t=this.context.fs.getFileByPath(e);return!t||t.constructor===Object||t.constructor===String&&!t.startsWith(`#!`)&&!this.context.fs.isExecutable(e)?Promise.reject():Promise.resolve(e)}}})),Ie=t(((e,t)=>{var n=E(),r=T();t.exports=class extends r{static get name(){return`source`}constructor(e,t){if(super(e,t),this.arguments.length!==1)return Promise.reject(`source requires a single argument`);let r=this.arguments[0];if(r.startsWith(`./`)||r.startsWith(`/`)){let i=this.context.fs.getFileByPath(r);if(i&&i.constructor===String&&i.startsWith(`#!`))return new n(i,e,t,!0)}}run(){let e=this.arguments[0];if(e.startsWith(`./`)||e.startsWith(`/`)){let t=this.context.fs.getFileByPath(e);if(!t){let t=this.context.fs.exists(e)?`Permission denied`:`No such file or directory`;return Promise.reject(`${e}: ${t}`)}if(t.constructor===Object)return Promise.reject(`${e}: is a directory`);if(t.prototype&&typeof t.prototype.run==`function`&&typeof t.prototype.runCommand==`function`)return Promise.reject(`${e}: command not found`);if(t.constructor===String&&t.startsWith(`#!`))return Promise.reject(`FATAL: should not get here`)}return Promise.reject(`${e}: permission denied`)}}})),Le=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`clear`}run(){return this.arguments.length>0?Promise.reject(`clear does not require arguments`):(this.stdout&&this.stdout.write(`\x1B[2J\x1B[3J\x1B[H`),this.context.clear(),Promise.resolve())}}})),Re=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`exit`}run(){let e=parseInt(this.arguments[0])||0;return this.exitCode=e,this.context.destroy(e),Promise.resolve()}}})),ze=t(((e,t)=>{var n=T(),r=he();t.exports=class extends n{static get name(){return`read`}get requiresFilesystem(){return!1}get captureInput(){return!0}run(){let e;try{e=this.parseArgs()}catch(e){return this.printHelp(e),Promise.reject()}return e.help?(this.printHelp(),Promise.resolve()):(this.nchars=e.nchars,this.names=e.name||[],this.raw=e.raw,new Promise(t=>{let n=setTimeout(()=>{t(),this.exitCode=1},e.timeout?e.timeout*1e3:864e5);this.completionCallback=e=>{clearTimeout(n),t(e)},this.stdErr=e.prompt||``,this.flush()}))}onInput(e){if(this.inputBuffer||=``,!this.raw&&!this.escaped&&e===`\\`){this.escaped=!0;return}this.escaped&&(delete this.escaped,e===`Enter`)||e.length===1&&(this.inputBuffer+=e,this.inputBuffer.length!==this.nchars)||(e===`Enter`||this.inputBuffer.length===this.nchars)&&this._finish()}_finish(){if(this.names.length<1)return this.completionCallback(this.inputBuffer);let e=this.context.vars.IFS;this._split(this.inputBuffer,e===void 0?`
24
- `:e).forEach((e,t)=>this.context.setVar(this.names[t],e)),this.completionCallback()}_split(e,t){let{names:n}=this,r=e=>e.replace(/[\]\\^-]/g,`\\$&`),i=r(t.replace(/[^ \t\n]/g,``)),a=r(t.replace(/[ \t\n]/g,``)),o=e=>i?e.replace(RegExp(`^[${i}]+`),``):e,s=e=>i?e.replace(RegExp(`[${i}]+$`),``):e,c=t===``?null:RegExp(a?`[${i}]*[${a}][${i}]*|[${i}]+`:`[${i}]+`),l=o(e);return n.map((e,t)=>{if(t===n.length-1)return s(l);let r=c&&c.exec(l);if(!r){let e=l;return l=``,e}let i=l.slice(0,r.index);return l=l.slice(r.index+r[0].length),i})}printHelp(e){e&&(this.stdOut=e.message),this.stdOut=`usage: read [-r] [-n nchars] [-p prompt] [-t timeout] [name ...]`}parseArgs(){return r([{name:`prompt`,alias:`p`,type:String},{name:`nchars`,alias:`n`,type:Number},{name:`timeout`,alias:`t`,type:Number},{name:`raw`,alias:`r`,type:Boolean},{name:`help`,alias:`h`,type:Boolean},{defaultOption:!0,multiple:!0,name:`name`,type:String}],{argv:this.arguments})}}})),Be=t(((e,t)=>{var n=T(),r=w();t.exports=class extends n{static get name(){return`jsfunction`}run(){let[e,...t]=this.arguments;if(!e||t.length===0)return this.stdErr=`usage: jsfunction <name> <function-body>`,this.exitCode=1,Promise.resolve();let n=t.join(` `),i;try{if(i=Function(`return (`+n+`)`)(),typeof i!=`function`)throw Error(`expression is not a function`)}catch(e){return this.stdErr=`jsfunction: ${e.message}`,this.exitCode=1,Promise.resolve()}class a extends r{run(){let e;try{e=i(this.arguments)}catch(e){return this.stdErr=e.message||String(e),this.exitCode=1,Promise.resolve()}return e&&typeof e.then==`function`?e.then(e=>{e!=null&&(this.stdOut=String(e))}).catch(e=>{this.stdErr=e.message||String(e),this.exitCode=1}):(e!=null&&(this.stdOut=String(e)),Promise.resolve())}}return Object.defineProperty(a,"name",{value:e,configurable:!0}),this.context.setCommand(a),Promise.resolve()}}})),Ve=t(((e,t)=>{var n=T();function r(e){return e>=1048576?(e/1048576).toFixed(1)+` MB`:e>=1024?(e/1024).toFixed(1)+` KB`:e+` B`}t.exports=class extends n{static get name(){return`curl`}get requiresFilesystem(){return!0}run(){let e=[...this.arguments],t=null,n={},i=null,a=!1,o=!1,s=null,c=null,l=0;for(;l<e.length;){let r=e[l];switch(r){case`-X`:case`--request`:t=e[++l];break;case`-H`:case`--header`:{let t=e[++l]||``,r=t.indexOf(`:`);r>0&&(n[t.slice(0,r).trim()]=t.slice(r+1).trim());break}case`-d`:case`--data`:case`--data-raw`:i=e[++l],t||=`POST`;break;case`-u`:case`--user`:{let t=e[++l]||``;n.Authorization=`Basic `+btoa(t);break}case`-o`:case`--output`:s=e[++l];break;case`-i`:case`--include`:a=!0;break;case`-s`:case`--silent`:o=!0;break;case`-#`:case`--progress-bar`:break;case`-L`:case`--location`:break;default:r.startsWith(`-`)?o||(this.stdErr=`curl: unknown option '${r}'`):c=r}l++}if(!c)return this.stdErr=`curl: no URL specified`,this.exitCode=1,Promise.resolve();if(!/^https?:\/\//i.test(c))return this.stdErr=`curl: unsupported protocol in URL: ${c}`,this.exitCode=1,Promise.resolve();let u={method:t||`GET`,headers:n};return i!==null&&(u.body=i),fetch(c,u).then(async e=>{a&&(this.stdOut=`HTTP/1.1 ${e.status} ${e.statusText}`,e.headers.forEach((e,t)=>{this.stdOut=`${t}: ${e}`}),this.stdOut=``);let t=null,n=Number(e.headers.get(`content-length`)||0);if(e.body&&typeof e.body.getReader==`function`){let i=e.body.getReader(),a=[],c=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;if(a.push(t),c+=t.length,s&&!o){if(n>0){let e=Math.min(100,Math.floor(c/n*100)),t=Math.min(20,Math.round(c/n*20)),i=`=`.repeat(Math.max(0,t-1))+(t>0?`>`:``)+` `.repeat(Math.max(0,20-t));this.stdOut=`\r[${i}] ${e}% (${r(c)} / ${r(n)})`}else this.stdOut=`\rDownloading: ${r(c)}`;this.flush()}}t=new Uint8Array(c);let l=0;for(let e of a)t.set(e,l),l+=e.length;if(s&&!o&&c>0){let e=n||c;this.stdOut=`\r[${`=`.repeat(20)}] 100% (${r(c)} / ${r(e)})`,this.flush()}}else{let n=await e.arrayBuffer();t=new Uint8Array(n)}if(s)try{let n=e.headers.get(`content-type`)||``;if(/^text\/|application\/(json|javascript|xml|x-sh)/i.test(n)){let e=new TextDecoder().decode(t);this.fs.setFileByPath(s,e,!0)}else{let{BinaryFile:e}=J(),r=e?new e(t.buffer,n||`application/octet-stream`):t;this.fs.setFileByPath(s,r,!0)}}catch(e){this.stdErr=`curl: cannot write to '${s}': ${e.message}`,this.exitCode=1}else new TextDecoder().decode(t).split(/\r?\n/).forEach(e=>{this.stdOut=e});e.ok||(this.exitCode=22)}).catch(e=>{if(!o){let t=e&&e.message?e.message:String(e);if(e instanceof TypeError&&/failed to fetch|networkerror|load failed|fetch is aborted/i.test(t)){let e=/^https:\/\//i.test(c),t=typeof location<`u`&&location.protocol===`https:`;!e&&t?this.stdErr=`curl: (35) Mixed content blocked — the page is served over HTTPS but the target URL is HTTP. Browsers block insecure requests from secure pages.`:(this.stdErr=`curl: (6) Network request failed — this is likely a CORS error. The server at ${c} did not include the required 'Access-Control-Allow-Origin' response header. You can only fetch cross-origin resources that explicitly allow it.`,this.stdErr=` Hint: try a public CORS proxy, or ensure the server sends 'Access-Control-Allow-Origin: *'.`)}else this.stdErr=`curl: (6) Could not connect: ${t}`}this.exitCode=6})}}})),He=t(((e,t)=>{var n=T(),r={errexit:`e`,xtrace:`x`,nounset:`u`,noexec:`n`,allexport:`a`};t.exports=class extends n{static get name(){return`set`}run(){let e=this.arguments;if(e.length===0){let e=this.context.vars;return Object.keys(e).sort().forEach(t=>{this.stdOut=`${t}=${e[t]}`}),Promise.resolve()}let t=0;for(;t<e.length;){let n=e[t];if(n===`--`){let n=e.slice(t+1),r=1;for(;this.context.getVar(String(r));)this.context.unsetVar(String(r)),r++;return n.forEach((e,t)=>this.context.setVar(String(t+1),e)),this.context.setVar(`#`,String(n.length)),Promise.resolve()}if((n.startsWith(`-`)||n.startsWith(`+`))&&n.length>1&&n[1]!==`-`){let i=n[0]===`-`,a=n.slice(1);if(a===`o`){t++;let n=e[t];if(n===void 0){Object.entries(r).forEach(([e,t])=>{let n=this.context.getVar(`-`)||``;this.stdOut=`${e.padEnd(15)} ${n.includes(t)?`on`:`off`}`}),t++;continue}let a=r[n];a?this._setFlag(a,i):this.stdErr=`set: ${n}: invalid option name`,t++;continue}for(let e of a)this._setFlag(e,i);t++;continue}t++}return Promise.resolve()}_setFlag(e,t){let n=this.context.getVar(`-`)||``;t?n.includes(e)||this.context.setVar(`-`,n+e):this.context.setVar(`-`,n.split(``).filter(t=>t!==e).join(``))}}})),Ue=t(((e,t)=>{var n=Ie();t.exports=class extends n{static get name(){return`.`}}})),We=t(((e,t)=>{t.exports=[Ce(),we(),Te(),Ee(),De(),Oe(),ke(),Ae(),je(),Me(),Ne(),Pe(),Fe(),Ie(),Le(),Re(),ze(),Be(),Ve(),He(),Ue()]})),Ge=t(((e,t)=>{t.exports=Object})),Ke=t(((e,t)=>{t.exports=Error})),qe=t(((e,t)=>{t.exports=EvalError})),Je=t(((e,t)=>{t.exports=RangeError})),Ye=t(((e,t)=>{t.exports=ReferenceError})),Xe=t(((e,t)=>{t.exports=SyntaxError})),Q=t(((e,t)=>{t.exports=TypeError})),Ze=t(((e,t)=>{t.exports=URIError})),Qe=t(((e,t)=>{t.exports=Math.abs})),$e=t(((e,t)=>{t.exports=Math.floor})),et=t(((e,t)=>{t.exports=Math.max})),tt=t(((e,t)=>{t.exports=Math.min})),nt=t(((e,t)=>{t.exports=Math.pow})),rt=t(((e,t)=>{t.exports=Math.round})),it=t(((e,t)=>{t.exports=Number.isNaN||function(e){return e!==e}})),at=t(((e,t)=>{var n=it();t.exports=function(e){return n(e)||e===0?e:e<0?-1:1}})),ot=t(((e,t)=>{t.exports=Object.getOwnPropertyDescriptor})),st=t(((e,t)=>{var n=ot();if(n)try{n([],`length`)}catch{n=null}t.exports=n})),ct=t(((e,t)=>{var n=Object.defineProperty||!1;if(n)try{n({},`a`,{value:1})}catch{n=!1}t.exports=n})),lt=t(((e,t)=>{t.exports=function(){if(typeof Symbol!=`function`||typeof Object.getOwnPropertySymbols!=`function`)return!1;if(typeof Symbol.iterator==`symbol`)return!0;var e={},t=Symbol(`test`),n=Object(t);if(typeof t==`string`||Object.prototype.toString.call(t)!==`[object Symbol]`||Object.prototype.toString.call(n)!==`[object Symbol]`)return!1;var r=42;for(var i in e[t]=r,e)return!1;if(typeof Object.keys==`function`&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames==`function`&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor==`function`){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==r||o.enumerable!==!0)return!1}return!0}})),ut=t(((e,t)=>{var n=typeof Symbol<`u`&&Symbol,r=lt();t.exports=function(){return typeof n!=`function`||typeof Symbol!=`function`||typeof n(`foo`)!=`symbol`||typeof Symbol(`bar`)!=`symbol`?!1:r()}})),dt=t(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect.getPrototypeOf||null})),ft=t(((e,t)=>{t.exports=Ge().getPrototypeOf||null})),pt=t(((e,t)=>{var n=`Function.prototype.bind called on incompatible `,r=Object.prototype.toString,i=Math.max,a=`[object Function]`,o=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},s=function(e,t){for(var n=[],r=t||0,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},c=function(e,t){for(var n=``,r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};t.exports=function(e){var t=this;if(typeof t!=`function`||r.apply(t)!==a)throw TypeError(n+t);for(var l=s(arguments,1),u,d=function(){if(this instanceof u){var n=t.apply(this,o(l,arguments));return Object(n)===n?n:this}return t.apply(e,o(l,arguments))},f=i(0,t.length-l.length),p=[],m=0;m<f;m++)p[m]=`$`+m;if(u=Function(`binder`,`return function (`+c(p,`,`)+`){ return binder.apply(this,arguments); }`)(d),t.prototype){var h=function(){};h.prototype=t.prototype,u.prototype=new h,h.prototype=null}return u}})),mt=t(((e,t)=>{var n=pt();t.exports=Function.prototype.bind||n})),ht=t(((e,t)=>{t.exports=Function.prototype.call})),gt=t(((e,t)=>{t.exports=Function.prototype.apply})),_t=t(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect&&Reflect.apply})),vt=t(((e,t)=>{var n=mt(),r=gt(),i=ht();t.exports=_t()||n.call(i,r)})),yt=t(((e,t)=>{var n=mt(),r=Q(),i=ht(),a=vt();t.exports=function(e){if(e.length<1||typeof e[0]!=`function`)throw new r(`a function is required`);return a(n,i,e)}})),bt=t(((e,t)=>{var n=yt(),r=st(),i;try{i=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!=`object`||!(`code`in e)||e.code!==`ERR_PROTO_ACCESS`)throw e}var a=!!i&&r&&r(Object.prototype,`__proto__`),o=Object,s=o.getPrototypeOf;t.exports=a&&typeof a.get==`function`?n([a.get]):typeof s==`function`?function(e){return s(e==null?e:o(e))}:!1})),xt=t(((e,t)=>{var n=dt(),r=ft(),i=bt();t.exports=n?function(e){return n(e)}:r?function(e){if(!e||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`getProto: not an object`);return r(e)}:i?function(e){return i(e)}:null})),St=t(((e,t)=>{var n=Function.prototype.call,r=Object.prototype.hasOwnProperty;t.exports=mt().call(n,r)})),$=t(((e,t)=>{var n,r=Ge(),i=Ke(),a=qe(),o=Je(),s=Ye(),c=Xe(),l=Q(),u=Ze(),d=Qe(),f=$e(),p=et(),m=tt(),h=nt(),g=rt(),_=at(),v=Function,y=function(e){try{return v(`"use strict"; return (`+e+`).constructor;`)()}catch{}},b=st(),x=ct(),S=function(){throw new l},C=b?function(){try{return arguments.callee,S}catch{try{return b(arguments,`callee`).get}catch{return S}}}():S,w=ut()(),T=xt(),E=ft(),D=dt(),O=gt(),k=ht(),A={},j=typeof Uint8Array>`u`||!T?n:T(Uint8Array),M={__proto__:null,"%AggregateError%":typeof AggregateError>`u`?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>`u`?n:ArrayBuffer,"%ArrayIteratorPrototype%":w&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":A,"%AsyncGenerator%":A,"%AsyncGeneratorFunction%":A,"%AsyncIteratorPrototype%":A,"%Atomics%":typeof Atomics>`u`?n:Atomics,"%BigInt%":typeof BigInt>`u`?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>`u`?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>`u`?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>`u`?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":a,"%Float16Array%":typeof Float16Array>`u`?n:Float16Array,"%Float32Array%":typeof Float32Array>`u`?n:Float32Array,"%Float64Array%":typeof Float64Array>`u`?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>`u`?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":A,"%Int8Array%":typeof Int8Array>`u`?n:Int8Array,"%Int16Array%":typeof Int16Array>`u`?n:Int16Array,"%Int32Array%":typeof Int32Array>`u`?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":w&&T?T(T([][Symbol.iterator]())):n,"%JSON%":typeof JSON==`object`?JSON:n,"%Map%":typeof Map>`u`?n:Map,"%MapIteratorPrototype%":typeof Map>`u`||!w||!T?n:T(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":r,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>`u`?n:Promise,"%Proxy%":typeof Proxy>`u`?n:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":typeof Reflect>`u`?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>`u`?n:Set,"%SetIteratorPrototype%":typeof Set>`u`||!w||!T?n:T(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>`u`?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":w&&T?T(``[Symbol.iterator]()):n,"%Symbol%":w?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":C,"%TypedArray%":j,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>`u`?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>`u`?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>`u`?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>`u`?n:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap>`u`?n:WeakMap,"%WeakRef%":typeof WeakRef>`u`?n:WeakRef,"%WeakSet%":typeof WeakSet>`u`?n:WeakSet,"%Function.prototype.call%":k,"%Function.prototype.apply%":O,"%Object.defineProperty%":x,"%Object.getPrototypeOf%":E,"%Math.abs%":d,"%Math.floor%":f,"%Math.max%":p,"%Math.min%":m,"%Math.pow%":h,"%Math.round%":g,"%Math.sign%":_,"%Reflect.getPrototypeOf%":D};if(T)try{null.error}catch(e){M[`%Error.prototype%`]=T(T(e))}var N=function e(t){var n;if(t===`%AsyncFunction%`)n=y(`async function () {}`);else if(t===`%GeneratorFunction%`)n=y(`function* () {}`);else if(t===`%AsyncGeneratorFunction%`)n=y(`async function* () {}`);else if(t===`%AsyncGenerator%`){var r=e(`%AsyncGeneratorFunction%`);r&&(n=r.prototype)}else if(t===`%AsyncIteratorPrototype%`){var i=e(`%AsyncGenerator%`);i&&T&&(n=T(i.prototype))}return M[t]=n,n},P={__proto__:null,"%ArrayBufferPrototype%":[`ArrayBuffer`,`prototype`],"%ArrayPrototype%":[`Array`,`prototype`],"%ArrayProto_entries%":[`Array`,`prototype`,`entries`],"%ArrayProto_forEach%":[`Array`,`prototype`,`forEach`],"%ArrayProto_keys%":[`Array`,`prototype`,`keys`],"%ArrayProto_values%":[`Array`,`prototype`,`values`],"%AsyncFunctionPrototype%":[`AsyncFunction`,`prototype`],"%AsyncGenerator%":[`AsyncGeneratorFunction`,`prototype`],"%AsyncGeneratorPrototype%":[`AsyncGeneratorFunction`,`prototype`,`prototype`],"%BooleanPrototype%":[`Boolean`,`prototype`],"%DataViewPrototype%":[`DataView`,`prototype`],"%DatePrototype%":[`Date`,`prototype`],"%ErrorPrototype%":[`Error`,`prototype`],"%EvalErrorPrototype%":[`EvalError`,`prototype`],"%Float32ArrayPrototype%":[`Float32Array`,`prototype`],"%Float64ArrayPrototype%":[`Float64Array`,`prototype`],"%FunctionPrototype%":[`Function`,`prototype`],"%Generator%":[`GeneratorFunction`,`prototype`],"%GeneratorPrototype%":[`GeneratorFunction`,`prototype`,`prototype`],"%Int8ArrayPrototype%":[`Int8Array`,`prototype`],"%Int16ArrayPrototype%":[`Int16Array`,`prototype`],"%Int32ArrayPrototype%":[`Int32Array`,`prototype`],"%JSONParse%":[`JSON`,`parse`],"%JSONStringify%":[`JSON`,`stringify`],"%MapPrototype%":[`Map`,`prototype`],"%NumberPrototype%":[`Number`,`prototype`],"%ObjectPrototype%":[`Object`,`prototype`],"%ObjProto_toString%":[`Object`,`prototype`,`toString`],"%ObjProto_valueOf%":[`Object`,`prototype`,`valueOf`],"%PromisePrototype%":[`Promise`,`prototype`],"%PromiseProto_then%":[`Promise`,`prototype`,`then`],"%Promise_all%":[`Promise`,`all`],"%Promise_reject%":[`Promise`,`reject`],"%Promise_resolve%":[`Promise`,`resolve`],"%RangeErrorPrototype%":[`RangeError`,`prototype`],"%ReferenceErrorPrototype%":[`ReferenceError`,`prototype`],"%RegExpPrototype%":[`RegExp`,`prototype`],"%SetPrototype%":[`Set`,`prototype`],"%SharedArrayBufferPrototype%":[`SharedArrayBuffer`,`prototype`],"%StringPrototype%":[`String`,`prototype`],"%SymbolPrototype%":[`Symbol`,`prototype`],"%SyntaxErrorPrototype%":[`SyntaxError`,`prototype`],"%TypedArrayPrototype%":[`TypedArray`,`prototype`],"%TypeErrorPrototype%":[`TypeError`,`prototype`],"%Uint8ArrayPrototype%":[`Uint8Array`,`prototype`],"%Uint8ClampedArrayPrototype%":[`Uint8ClampedArray`,`prototype`],"%Uint16ArrayPrototype%":[`Uint16Array`,`prototype`],"%Uint32ArrayPrototype%":[`Uint32Array`,`prototype`],"%URIErrorPrototype%":[`URIError`,`prototype`],"%WeakMapPrototype%":[`WeakMap`,`prototype`],"%WeakSetPrototype%":[`WeakSet`,`prototype`]},F=mt(),I=St(),ee=F.call(k,Array.prototype.concat),te=F.call(O,Array.prototype.splice),ne=F.call(k,String.prototype.replace),L=F.call(k,String.prototype.slice),R=F.call(k,RegExp.prototype.exec),z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,B=/\\(\\)?/g,V=function(e){var t=L(e,0,1),n=L(e,-1);if(t===`%`&&n!==`%`)throw new c("invalid intrinsic syntax, expected closing `%`");if(n===`%`&&t!==`%`)throw new c("invalid intrinsic syntax, expected opening `%`");var r=[];return ne(e,z,function(e,t,n,i){r[r.length]=n?ne(i,B,`$1`):t||e}),r},H=function(e,t){var n=e,r;if(I(P,n)&&(r=P[n],n=`%`+r[0]+`%`),I(M,n)){var i=M[n];if(i===A&&(i=N(n)),i===void 0&&!t)throw new l(`intrinsic `+e+` exists, but is not available. Please file an issue!`);return{alias:r,name:n,value:i}}throw new c(`intrinsic `+e+` does not exist!`)};t.exports=function(e,t){if(typeof e!=`string`||e.length===0)throw new l(`intrinsic name must be a non-empty string`);if(arguments.length>1&&typeof t!=`boolean`)throw new l(`"allowMissing" argument must be a boolean`);if(R(/^%?[^%]*%?$/,e)===null)throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=V(e),r=n.length>0?n[0]:``,i=H(`%`+r+`%`,t),a=i.name,o=i.value,s=!1,u=i.alias;u&&(r=u[0],te(n,ee([0,1],u)));for(var d=1,f=!0;d<n.length;d+=1){var p=n[d],m=L(p,0,1),h=L(p,-1);if((m===`"`||m===`'`||m==="`"||h===`"`||h===`'`||h==="`")&&m!==h)throw new c(`property names with quotes must have matching quotes`);if((p===`constructor`||!f)&&(s=!0),r+=`.`+p,a=`%`+r+`%`,I(M,a))o=M[a];else if(o!=null){if(!(p in o)){if(!t)throw new l(`base intrinsic for `+e+` exists, but the property is not available.`);return}if(b&&d+1>=n.length){var g=b(o,p);f=!!g,o=f&&`get`in g&&!(`originalValue`in g.get)?g.get:o[p]}else f=I(o,p),o=o[p];f&&!s&&(M[a]=o)}}return o}})),Ct=t(((e,t)=>{var n=ct(),r=Xe(),i=Q(),a=st();t.exports=function(e,t,o){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`obj` must be an object or a function`");if(typeof t!=`string`&&typeof t!=`symbol`)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=`boolean`&&arguments[3]!==null)throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=`boolean`&&arguments[4]!==null)throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=`boolean`&&arguments[5]!==null)throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=`boolean`)throw new i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,d=!!a&&a(e,t);if(n)n(e,t,{configurable:l===null&&d?d.configurable:!l,enumerable:s===null&&d?d.enumerable:!s,value:o,writable:c===null&&d?d.writable:!c});else if(u||!s&&!c&&!l)e[t]=o;else throw new r(`This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.`)}})),wt=t(((e,t)=>{var n=ct(),r=function(){return!!n};r.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],`length`,{value:1}).length!==1}catch{return!0}},t.exports=r})),Tt=t(((e,t)=>{var n=$(),r=Ct(),i=wt()(),a=st(),o=Q(),s=n(`%Math.floor%`);t.exports=function(e,t){if(typeof e!=`function`)throw new o("`fn` is not a function");if(typeof t!=`number`||t<0||t>4294967295||s(t)!==t)throw new o("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],c=!0,l=!0;if(`length`in e&&a){var u=a(e,`length`);u&&!u.configurable&&(c=!1),u&&!u.writable&&(l=!1)}return(c||l||!n)&&(i?r(e,`length`,t,!0,!0):r(e,`length`,t)),e}})),Et=t(((e,t)=>{var n=mt(),r=gt(),i=vt();t.exports=function(){return i(n,r,arguments)}})),Dt=t(((e,t)=>{var n=Tt(),r=ct(),i=yt(),a=Et();t.exports=function(e){var t=i(arguments),r=1+e.length-(arguments.length-1);return n(t,r>0?r:0,!0)},r?r(t.exports,`apply`,{value:a}):t.exports.apply=a})),Ot=t(((e,t)=>{var n=Object.prototype.toString;t.exports=function(e){var t=n.call(e),r=t===`[object Arguments]`;return r||=t!==`[object Array]`&&typeof e==`object`&&!!e&&typeof e.length==`number`&&e.length>=0&&n.call(e.callee)===`[object Function]`,r}})),kt=t(((e,t)=>{var n;if(!Object.keys){var r=Object.prototype.hasOwnProperty,i=Object.prototype.toString,a=Ot(),o=Object.prototype.propertyIsEnumerable,s=!o.call({toString:null},`toString`),c=o.call(function(){},`prototype`),l=[`toString`,`toLocaleString`,`valueOf`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`constructor`],u=function(e){var t=e.constructor;return t&&t.prototype===e},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},f=function(){if(typeof window>`u`)return!1;for(var e in window)try{if(!d[`$`+e]&&r.call(window,e)&&window[e]!==null&&typeof window[e]==`object`)try{u(window[e])}catch{return!0}}catch{return!0}return!1}(),p=function(e){if(typeof window>`u`||!f)return u(e);try{return u(e)}catch{return!1}};n=function(e){var t=typeof e==`object`&&!!e,n=i.call(e)===`[object Function]`,o=a(e),u=t&&i.call(e)===`[object String]`,d=[];if(!t&&!n&&!o)throw TypeError(`Object.keys called on a non-object`);var f=c&&n;if(u&&e.length>0&&!r.call(e,0))for(var m=0;m<e.length;++m)d.push(String(m));if(o&&e.length>0)for(var h=0;h<e.length;++h)d.push(String(h));else for(var g in e)!(f&&g===`prototype`)&&r.call(e,g)&&d.push(String(g));if(s)for(var _=p(e),v=0;v<l.length;++v)!(_&&l[v]===`constructor`)&&r.call(e,l[v])&&d.push(l[v]);return d}}t.exports=n})),At=t(((e,t)=>{var n=Array.prototype.slice,r=Ot(),i=Object.keys,a=i?function(e){return i(e)}:kt(),o=Object.keys;a.shim=function(){return Object.keys?function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2)||(Object.keys=function(e){return r(e)?o(n.call(e)):o(e)}):Object.keys=a,Object.keys||a},t.exports=a})),jt=t(((e,t)=>{var n=At(),r=typeof Symbol==`function`&&typeof Symbol(`foo`)==`symbol`,i=Object.prototype.toString,a=Array.prototype.concat,o=Ct(),s=function(e){return typeof e==`function`&&i.call(e)===`[object Function]`},c=wt()(),l=function(e,t,n,r){if(t in e){if(r===!0){if(e[t]===n)return}else if(!s(r)||!r())return}c?o(e,t,n,!0):o(e,t,n)},u=function(e,t){var i=arguments.length>2?arguments[2]:{},o=n(t);r&&(o=a.call(o,Object.getOwnPropertySymbols(t)));for(var s=0;s<o.length;s+=1)l(e,o[s],t[o[s]],i[o[s]])};u.supportsDescriptors=!!c,t.exports=u})),Mt=t(((e,t)=>{var n=$(),r=yt(),i=r([n(`%String.prototype.indexOf%`)]);t.exports=function(e,t){var a=n(e,!!t);return typeof a==`function`&&i(e,`.prototype.`)>-1?r([a]):a}})),Nt=t(((e,t)=>{var n=$()(`%Array%`),r=!n.isArray&&Mt()(`Object.prototype.toString`);t.exports=n.isArray||function(e){return r(e)===`[object Array]`}})),Pt=t(((e,t)=>{t.exports=Nt()})),Ft=t(((e,t)=>{var n=$(),r=Mt(),i=Q(),a=Pt(),o=n(`%Reflect.apply%`,!0)||r(`Function.prototype.apply`);t.exports=function(e,t){var n=arguments.length>2?arguments[2]:[];if(!a(n))throw new i("Assertion failed: optional `argumentsList`, if provided, must be a List");return o(e,t,n)}})),It=t(((e,t)=>{t.exports={}})),Lt=t(((e,t)=>{me();var n=typeof Map==`function`&&Map.prototype,r=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,`size`):null,i=n&&r&&typeof r.get==`function`?r.get:null,a=n&&Map.prototype.forEach,o=typeof Set==`function`&&Set.prototype,s=Object.getOwnPropertyDescriptor&&o?Object.getOwnPropertyDescriptor(Set.prototype,`size`):null,c=o&&s&&typeof s.get==`function`?s.get:null,l=o&&Set.prototype.forEach,u=typeof WeakMap==`function`&&WeakMap.prototype?WeakMap.prototype.has:null,d=typeof WeakSet==`function`&&WeakSet.prototype?WeakSet.prototype.has:null,f=typeof WeakRef==`function`&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,m=Object.prototype.toString,h=Function.prototype.toString,g=String.prototype.match,_=String.prototype.slice,v=String.prototype.replace,y=String.prototype.toUpperCase,b=String.prototype.toLowerCase,x=RegExp.prototype.test,S=Array.prototype.concat,C=Array.prototype.join,w=Array.prototype.slice,T=Math.floor,E=typeof BigInt==`function`?BigInt.prototype.valueOf:null,D=Object.getOwnPropertySymbols,O=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?Symbol.prototype.toString:null,k=typeof Symbol==`function`&&typeof Symbol.iterator==`object`,A=typeof Symbol==`function`&&Symbol.toStringTag?Symbol.toStringTag:null,j=Object.prototype.propertyIsEnumerable,M=(typeof Reflect==`function`?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function N(e,t){if(e===1/0||e===-1/0||e!==e||e&&e>-1e3&&e<1e3||x.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof e==`number`){var r=e<0?-T(-e):T(e);if(r!==e){var i=String(r),a=_.call(t,i.length+1);return v.call(i,n,`$&_`)+`.`+v.call(v.call(a,/([0-9]{3})/g,`$&_`),/_$/,``)}}return v.call(t,n,`$&_`)}var P=It(),F=P.custom,I=W(F)?F:null,ee={__proto__:null,double:`"`,single:`'`},te={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};t.exports=function e(t,n,r,o){var s=n||{};if(K(s,`quoteStyle`)&&!K(ee,s.quoteStyle))throw TypeError(`option "quoteStyle" must be "single" or "double"`);if(K(s,`maxStringLength`)&&(typeof s.maxStringLength==`number`?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var u=K(s,`customInspect`)?s.customInspect:!0;if(typeof u!=`boolean`&&u!==`symbol`)throw TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(K(s,`indent`)&&s.indent!==null&&s.indent!==` `&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(K(s,`numericSeparator`)&&typeof s.numericSeparator!=`boolean`)throw TypeError('option "numericSeparator", if provided, must be `true` or `false`');var d=s.numericSeparator;if(t===void 0)return`undefined`;if(t===null)return`null`;if(typeof t==`boolean`)return t?`true`:`false`;if(typeof t==`string`)return fe(t,s);if(typeof t==`number`){if(t===0)return 1/0/t>0?`0`:`-0`;var f=String(t);return d?N(t,f):f}if(typeof t==`bigint`){var m=String(t)+`n`;return d?N(t,m):m}var h=s.depth===void 0?5:s.depth;if(r===void 0&&(r=0),r>=h&&h>0&&typeof t==`object`)return z(t)?`[Array]`:`[Object]`;var g=ve(s,r);if(o===void 0)o=[];else if(Y(o,t)>=0)return`[Circular]`;function y(t,n,i){if(n&&(o=w.call(o),o.push(n)),i){var a={depth:s.depth};return K(s,`quoteStyle`)&&(a.quoteStyle=s.quoteStyle),e(t,a,r+1,o)}return e(t,s,r+1,o)}if(typeof t==`function`&&!V(t)){var x=J(t),T=be(t,y);return`[Function`+(x?`: `+x:` (anonymous)`)+`]`+(T.length>0?` { `+C.call(T,`, `)+` }`:``)}if(W(t)){var D=k?v.call(String(t),/^(Symbol\(.*\))_[^)]*$/,`$1`):O.call(t);return typeof t==`object`&&!k?Z(D):D}if(de(t)){for(var F=`<`+b.call(String(t.nodeName)),te=t.attributes||[],R=0;R<te.length;R++)F+=` `+te[R].name+`=`+ne(L(te[R].value),`double`,s);return F+=`>`,t.childNodes&&t.childNodes.length&&(F+=`...`),F+=`</`+b.call(String(t.nodeName))+`>`,F}if(z(t)){if(t.length===0)return`[]`;var G=be(t,y);return g&&!_e(G)?`[`+ye(G,g)+`]`:`[ `+C.call(G,`, `)+` ]`}if(H(t)){var X=be(t,y);return!(`cause`in Error.prototype)&&`cause`in t&&!j.call(t,`cause`)?`{ [`+String(t)+`] `+C.call(S.call(`[cause]: `+y(t.cause),X),`, `)+` }`:X.length===0?`[`+String(t)+`]`:`{ [`+String(t)+`] `+C.call(X,`, `)+` }`}if(typeof t==`object`&&u){if(I&&typeof t[I]==`function`&&P)return P(t,{depth:h-r});if(u!==`symbol`&&typeof t.inspect==`function`)return t.inspect()}if(oe(t)){var me=[];return a&&a.call(t,function(e,n){me.push(y(n,t,!0)+` => `+y(e,t))}),ge(`Map`,i.call(t),me,g)}if(le(t)){var xe=[];return l&&l.call(t,function(e){xe.push(y(e,t))}),ge(`Set`,c.call(t),xe,g)}if(se(t))return he(`WeakMap`);if(ue(t))return he(`WeakSet`);if(ce(t))return he(`WeakRef`);if(re(t))return Z(y(Number(t)));if(ae(t))return Z(y(E.call(t)));if(ie(t))return Z(p.call(t));if(U(t))return Z(y(String(t)));if(typeof window<`u`&&t===window)return`{ [object Window] }`;if(typeof globalThis<`u`&&t===globalThis||pe!==void 0&&t===pe)return`{ [object globalThis] }`;if(!B(t)&&!V(t)){var Se=be(t,y),Ce=M?M(t)===Object.prototype:t instanceof Object||t.constructor===Object,we=t instanceof Object?``:`null prototype`,Te=!Ce&&A&&Object(t)===t&&A in t?_.call(q(t),8,-1):we?`Object`:``,Ee=(Ce||typeof t.constructor!=`function`?``:t.constructor.name?t.constructor.name+` `:``)+(Te||we?`[`+C.call(S.call([],Te||[],we||[]),`: `)+`] `:``);return Se.length===0?Ee+`{}`:g?Ee+`{`+ye(Se,g)+`}`:Ee+`{ `+C.call(Se,`, `)+` }`}return String(t)};function ne(e,t,n){var r=ee[n.quoteStyle||t];return r+e+r}function L(e){return v.call(String(e),/"/g,`&quot;`)}function R(e){return!A||!(typeof e==`object`&&(A in e||e[A]!==void 0))}function z(e){return q(e)===`[object Array]`&&R(e)}function B(e){return q(e)===`[object Date]`&&R(e)}function V(e){return q(e)===`[object RegExp]`&&R(e)}function H(e){return q(e)===`[object Error]`&&R(e)}function U(e){return q(e)===`[object String]`&&R(e)}function re(e){return q(e)===`[object Number]`&&R(e)}function ie(e){return q(e)===`[object Boolean]`&&R(e)}function W(e){if(k)return e&&typeof e==`object`&&e instanceof Symbol;if(typeof e==`symbol`)return!0;if(!e||typeof e!=`object`||!O)return!1;try{return O.call(e),!0}catch{}return!1}function ae(e){if(!e||typeof e!=`object`||!E)return!1;try{return E.call(e),!0}catch{}return!1}var G=Object.prototype.hasOwnProperty||function(e){return e in this};function K(e,t){return G.call(e,t)}function q(e){return m.call(e)}function J(e){if(e.name)return e.name;var t=g.call(h.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}function Y(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function oe(e){if(!i||!e||typeof e!=`object`)return!1;try{i.call(e);try{c.call(e)}catch{return!0}return e instanceof Map}catch{}return!1}function se(e){if(!u||!e||typeof e!=`object`)return!1;try{u.call(e,u);try{d.call(e,d)}catch{return!0}return e instanceof WeakMap}catch{}return!1}function ce(e){if(!f||!e||typeof e!=`object`)return!1;try{return f.call(e),!0}catch{}return!1}function le(e){if(!c||!e||typeof e!=`object`)return!1;try{c.call(e);try{i.call(e)}catch{return!0}return e instanceof Set}catch{}return!1}function ue(e){if(!d||!e||typeof e!=`object`)return!1;try{d.call(e,d);try{u.call(e,u)}catch{return!0}return e instanceof WeakSet}catch{}return!1}function de(e){return!e||typeof e!=`object`?!1:typeof HTMLElement<`u`&&e instanceof HTMLElement?!0:typeof e.nodeName==`string`&&typeof e.getAttribute==`function`}function fe(e,t){if(e.length>t.maxStringLength){var n=e.length-t.maxStringLength,r=`... `+n+` more character`+(n>1?`s`:``);return fe(_.call(e,0,t.maxStringLength),t)+r}var i=te[t.quoteStyle||`single`];return i.lastIndex=0,ne(v.call(v.call(e,i,`\\$1`),/[\x00-\x1f]/g,X),`single`,t)}function X(e){var t=e.charCodeAt(0),n={8:`b`,9:`t`,10:`n`,12:`f`,13:`r`}[t];return n?`\\`+n:`\\x`+(t<16?`0`:``)+y.call(t.toString(16))}function Z(e){return`Object(`+e+`)`}function he(e){return e+` { ? }`}function ge(e,t,n,r){var i=r?ye(n,r):C.call(n,`, `);return e+` (`+t+`) {`+i+`}`}function _e(e){for(var t=0;t<e.length;t++)if(Y(e[t],`
31
+ `)}_rwxBits(e){return[e&256?`r`:`-`,e&128?`w`:`-`,e&64?`x`:`-`,e&32?`r`:`-`,e&16?`w`:`-`,e&8?`x`:`-`,e&4?`r`:`-`,e&2?`w`:`-`,e&1?`x`:`-`].join(``)}}})),Le=t(((e,t)=>{var n=T(),r=(()=>{try{return D()}catch{return null}})();t.exports=class extends n{static get name(){return`touch`}get requiresFilesystem(){return!0}run(){let e=!1,t=[];for(let n of this.arguments){if(n===`--`)break;if(n.startsWith(`-`)&&n.length>1)for(let t of n.slice(1))t===`c`&&(e=!0);else t.push(n)}if(t.length===0)return this.stdErr=`touch: missing file operand`,this.exitCode=1,Promise.resolve();let n=new Date;for(let i of t)if(this.fs.exists(i)){if(r&&this.fs.isRealFilesystem)try{r.utimesSync(this.fs.absolutePath(i),n,n)}catch(e){this.stdErr=`touch: cannot touch '${i}': ${e.message}`,this.exitCode=1}}else{if(e)continue;try{this.fs.setFileByPath(i,``,!0)}catch(e){this.stdErr=`touch: cannot touch '${i}': ${e.message}`,this.exitCode=1}}return Promise.resolve()}}})),Re=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`which`}run(){if(this.arguments.length!==1)return Promise.reject(`which requires a single argument`);let e=`${this.context.getVar(`PATH`)}/${this.arguments[0]}`,t=this.context.fs.getFileByPath(e);return!t||t.constructor===Object||t.constructor===String&&!t.startsWith(`#!`)&&!this.context.fs.isExecutable(e)?Promise.reject():Promise.resolve(e)}}})),ze=t(((e,t)=>{var n=E(),r=T();t.exports=class extends r{static get name(){return`source`}constructor(e,t){if(super(e,t),this.arguments.length!==1)return Promise.reject(`source requires a single argument`);let r=this.arguments[0];if(r.startsWith(`./`)||r.startsWith(`/`)){let i=this.context.fs.getFileByPath(r);if(i&&i.constructor===String&&i.startsWith(`#!`))return new n(i,e,t,!0)}}run(){let e=this.arguments[0];if(e.startsWith(`./`)||e.startsWith(`/`)){let t=this.context.fs.getFileByPath(e);if(!t){let t=this.context.fs.exists(e)?`Permission denied`:`No such file or directory`;return Promise.reject(`${e}: ${t}`)}if(t.constructor===Object)return Promise.reject(`${e}: is a directory`);if(t.prototype&&typeof t.prototype.run==`function`&&typeof t.prototype.runCommand==`function`)return Promise.reject(`${e}: command not found`);if(t.constructor===String&&t.startsWith(`#!`))return Promise.reject(`FATAL: should not get here`)}return Promise.reject(`${e}: permission denied`)}}})),Be=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`clear`}run(){return this.arguments.length>0?Promise.reject(`clear does not require arguments`):(this.stdout&&this.stdout.write(`\x1B[2J\x1B[3J\x1B[H`),this.context.clear(),Promise.resolve())}}})),Ve=t(((e,t)=>{var n=T();t.exports=class extends n{static get name(){return`exit`}run(){let e=parseInt(this.arguments[0])||0;return this.exitCode=e,this.context.destroy(e),Promise.resolve()}}})),He=t(((e,t)=>{var n=T(),r=he();t.exports=class extends n{static get name(){return`read`}get requiresFilesystem(){return!1}get captureInput(){return!0}run(){let e;try{e=this.parseArgs()}catch(e){return this.printHelp(e),Promise.reject()}return e.help?(this.printHelp(),Promise.resolve()):(this.nchars=e.nchars,this.names=e.name||[],this.raw=e.raw,new Promise(t=>{let n=setTimeout(()=>{t(),this.exitCode=1},e.timeout?e.timeout*1e3:864e5);this.completionCallback=e=>{clearTimeout(n),t(e)},this.stdErr=e.prompt||``,this.flush()}))}onInput(e){if(this.inputBuffer||=``,!this.raw&&!this.escaped&&e===`\\`){this.escaped=!0;return}this.escaped&&(delete this.escaped,e===`Enter`)||e.length===1&&(this.inputBuffer+=e,this.inputBuffer.length!==this.nchars)||(e===`Enter`||this.inputBuffer.length===this.nchars)&&this._finish()}_finish(){if(this.names.length<1)return this.completionCallback(this.inputBuffer);let e=this.context.vars.IFS;this._split(this.inputBuffer,e===void 0?`
32
+ `:e).forEach((e,t)=>this.context.setVar(this.names[t],e)),this.completionCallback()}_split(e,t){let{names:n}=this,r=e=>e.replace(/[\]\\^-]/g,`\\$&`),i=r(t.replace(/[^ \t\n]/g,``)),a=r(t.replace(/[ \t\n]/g,``)),o=e=>i?e.replace(RegExp(`^[${i}]+`),``):e,s=e=>i?e.replace(RegExp(`[${i}]+$`),``):e,c=t===``?null:RegExp(a?`[${i}]*[${a}][${i}]*|[${i}]+`:`[${i}]+`),l=o(e);return n.map((e,t)=>{if(t===n.length-1)return s(l);let r=c&&c.exec(l);if(!r){let e=l;return l=``,e}let i=l.slice(0,r.index);return l=l.slice(r.index+r[0].length),i})}printHelp(e){e&&(this.stdOut=e.message),this.stdOut=`usage: read [-r] [-n nchars] [-p prompt] [-t timeout] [name ...]`}parseArgs(){return r([{name:`prompt`,alias:`p`,type:String},{name:`nchars`,alias:`n`,type:Number},{name:`timeout`,alias:`t`,type:Number},{name:`raw`,alias:`r`,type:Boolean},{name:`help`,alias:`h`,type:Boolean},{defaultOption:!0,multiple:!0,name:`name`,type:String}],{argv:this.arguments})}}})),Ue=t(((e,t)=>{var n=T(),r=w();t.exports=class extends n{static get name(){return`jsfunction`}run(){let[e,...t]=this.arguments;if(!e||t.length===0)return this.stdErr=`usage: jsfunction <name> <function-body>`,this.exitCode=1,Promise.resolve();let n=t.join(` `),i;try{if(i=Function(`return (`+n+`)`)(),typeof i!=`function`)throw Error(`expression is not a function`)}catch(e){return this.stdErr=`jsfunction: ${e.message}`,this.exitCode=1,Promise.resolve()}class a extends r{run(){let e;try{e=i(this.arguments)}catch(e){return this.stdErr=e.message||String(e),this.exitCode=1,Promise.resolve()}return e&&typeof e.then==`function`?e.then(e=>{e!=null&&(this.stdOut=String(e))}).catch(e=>{this.stdErr=e.message||String(e),this.exitCode=1}):(e!=null&&(this.stdOut=String(e)),Promise.resolve())}}return Object.defineProperty(a,"name",{value:e,configurable:!0}),this.context.setCommand(a),Promise.resolve()}}})),We=t(((e,t)=>{var n=T();function r(e){return e>=1048576?(e/1048576).toFixed(1)+` MB`:e>=1024?(e/1024).toFixed(1)+` KB`:e+` B`}t.exports=class extends n{static get name(){return`curl`}get requiresFilesystem(){return!0}run(){let e=[...this.arguments],t=null,n={},i=null,a=!1,o=!1,s=null,c=null,l=0;for(;l<e.length;){let r=e[l];switch(r){case`-X`:case`--request`:t=e[++l];break;case`-H`:case`--header`:{let t=e[++l]||``,r=t.indexOf(`:`);r>0&&(n[t.slice(0,r).trim()]=t.slice(r+1).trim());break}case`-d`:case`--data`:case`--data-raw`:i=e[++l],t||=`POST`;break;case`-u`:case`--user`:{let t=e[++l]||``;n.Authorization=`Basic `+btoa(t);break}case`-o`:case`--output`:s=e[++l];break;case`-i`:case`--include`:a=!0;break;case`-s`:case`--silent`:o=!0;break;case`-#`:case`--progress-bar`:break;case`-L`:case`--location`:break;default:r.startsWith(`-`)?o||(this.stdErr=`curl: unknown option '${r}'`):c=r}l++}if(!c)return this.stdErr=`curl: no URL specified`,this.exitCode=1,Promise.resolve();if(!/^https?:\/\//i.test(c))return this.stdErr=`curl: unsupported protocol in URL: ${c}`,this.exitCode=1,Promise.resolve();let u={method:t||`GET`,headers:n};return i!==null&&(u.body=i),fetch(c,u).then(async e=>{a&&(this.stdOut=`HTTP/1.1 ${e.status} ${e.statusText}`,e.headers.forEach((e,t)=>{this.stdOut=`${t}: ${e}`}),this.stdOut=``);let t=null,n=Number(e.headers.get(`content-length`)||0);if(e.body&&typeof e.body.getReader==`function`){let i=e.body.getReader(),a=[],c=0;for(;;){let{done:e,value:t}=await i.read();if(e)break;if(a.push(t),c+=t.length,s&&!o){if(n>0){let e=Math.min(100,Math.floor(c/n*100)),t=Math.min(20,Math.round(c/n*20)),i=`=`.repeat(Math.max(0,t-1))+(t>0?`>`:``)+` `.repeat(Math.max(0,20-t));this.stdOut=`\r[${i}] ${e}% (${r(c)} / ${r(n)})`}else this.stdOut=`\rDownloading: ${r(c)}`;this.flush()}}t=new Uint8Array(c);let l=0;for(let e of a)t.set(e,l),l+=e.length;if(s&&!o&&c>0){let e=n||c;this.stdOut=`\r[${`=`.repeat(20)}] 100% (${r(c)} / ${r(e)})`,this.flush()}}else{let n=await e.arrayBuffer();t=new Uint8Array(n)}if(s)try{let n=e.headers.get(`content-type`)||``;if(/^text\/|application\/(json|javascript|xml|x-sh)/i.test(n)){let e=new TextDecoder().decode(t);this.fs.setFileByPath(s,e,!0)}else{let{BinaryFile:e}=J(),r=e?new e(t.buffer,n||`application/octet-stream`):t;this.fs.setFileByPath(s,r,!0)}}catch(e){this.stdErr=`curl: cannot write to '${s}': ${e.message}`,this.exitCode=1}else new TextDecoder().decode(t).split(/\r?\n/).forEach(e=>{this.stdOut=e});e.ok||(this.exitCode=22)}).catch(e=>{if(!o){let t=e&&e.message?e.message:String(e);if(e instanceof TypeError&&/failed to fetch|networkerror|load failed|fetch is aborted/i.test(t)){let e=/^https:\/\//i.test(c),t=typeof location<`u`&&location.protocol===`https:`;!e&&t?this.stdErr=`curl: (35) Mixed content blocked — the page is served over HTTPS but the target URL is HTTP. Browsers block insecure requests from secure pages.`:(this.stdErr=`curl: (6) Network request failed — this is likely a CORS error. The server at ${c} did not include the required 'Access-Control-Allow-Origin' response header. You can only fetch cross-origin resources that explicitly allow it.`,this.stdErr=` Hint: try a public CORS proxy, or ensure the server sends 'Access-Control-Allow-Origin: *'.`)}else this.stdErr=`curl: (6) Could not connect: ${t}`}this.exitCode=6})}}})),Ge=t(((e,t)=>{var n=T(),r={errexit:`e`,xtrace:`x`,nounset:`u`,noexec:`n`,allexport:`a`};t.exports=class extends n{static get name(){return`set`}run(){let e=this.arguments;if(e.length===0){let e=this.context.vars;return Object.keys(e).sort().forEach(t=>{this.stdOut=`${t}=${e[t]}`}),Promise.resolve()}let t=0;for(;t<e.length;){let n=e[t];if(n===`--`){let n=e.slice(t+1),r=1;for(;this.context.getVar(String(r));)this.context.unsetVar(String(r)),r++;return n.forEach((e,t)=>this.context.setVar(String(t+1),e)),this.context.setVar(`#`,String(n.length)),Promise.resolve()}if((n.startsWith(`-`)||n.startsWith(`+`))&&n.length>1&&n[1]!==`-`){let i=n[0]===`-`,a=n.slice(1);if(a===`o`){t++;let n=e[t];if(n===void 0){Object.entries(r).forEach(([e,t])=>{let n=this.context.getVar(`-`)||``;this.stdOut=`${e.padEnd(15)} ${n.includes(t)?`on`:`off`}`}),t++;continue}let a=r[n];a?this._setFlag(a,i):this.stdErr=`set: ${n}: invalid option name`,t++;continue}for(let e of a)this._setFlag(e,i);t++;continue}t++}return Promise.resolve()}_setFlag(e,t){let n=this.context.getVar(`-`)||``;t?n.includes(e)||this.context.setVar(`-`,n+e):this.context.setVar(`-`,n.split(``).filter(t=>t!==e).join(``))}}})),Ke=t(((e,t)=>{var n=ze();t.exports=class extends n{static get name(){return`.`}}})),qe=t(((e,t)=>{t.exports=[Ee(),De(),Oe(),ke(),Ae(),je(),Me(),Ne(),Pe(),Fe(),Ie(),Le(),Re(),ze(),Be(),Ve(),He(),Ue(),We(),Ge(),Ke()]})),Je=t(((e,t)=>{t.exports=Object})),Ye=t(((e,t)=>{t.exports=Error})),Xe=t(((e,t)=>{t.exports=EvalError})),Ze=t(((e,t)=>{t.exports=RangeError})),Qe=t(((e,t)=>{t.exports=ReferenceError})),$e=t(((e,t)=>{t.exports=SyntaxError})),Q=t(((e,t)=>{t.exports=TypeError})),et=t(((e,t)=>{t.exports=URIError})),tt=t(((e,t)=>{t.exports=Math.abs})),nt=t(((e,t)=>{t.exports=Math.floor})),rt=t(((e,t)=>{t.exports=Math.max})),it=t(((e,t)=>{t.exports=Math.min})),at=t(((e,t)=>{t.exports=Math.pow})),ot=t(((e,t)=>{t.exports=Math.round})),st=t(((e,t)=>{t.exports=Number.isNaN||function(e){return e!==e}})),ct=t(((e,t)=>{var n=st();t.exports=function(e){return n(e)||e===0?e:e<0?-1:1}})),lt=t(((e,t)=>{t.exports=Object.getOwnPropertyDescriptor})),ut=t(((e,t)=>{var n=lt();if(n)try{n([],`length`)}catch{n=null}t.exports=n})),dt=t(((e,t)=>{var n=Object.defineProperty||!1;if(n)try{n({},`a`,{value:1})}catch{n=!1}t.exports=n})),ft=t(((e,t)=>{t.exports=function(){if(typeof Symbol!=`function`||typeof Object.getOwnPropertySymbols!=`function`)return!1;if(typeof Symbol.iterator==`symbol`)return!0;var e={},t=Symbol(`test`),n=Object(t);if(typeof t==`string`||Object.prototype.toString.call(t)!==`[object Symbol]`||Object.prototype.toString.call(n)!==`[object Symbol]`)return!1;var r=42;for(var i in e[t]=r,e)return!1;if(typeof Object.keys==`function`&&Object.keys(e).length!==0||typeof Object.getOwnPropertyNames==`function`&&Object.getOwnPropertyNames(e).length!==0)return!1;var a=Object.getOwnPropertySymbols(e);if(a.length!==1||a[0]!==t||!Object.prototype.propertyIsEnumerable.call(e,t))return!1;if(typeof Object.getOwnPropertyDescriptor==`function`){var o=Object.getOwnPropertyDescriptor(e,t);if(o.value!==r||o.enumerable!==!0)return!1}return!0}})),pt=t(((e,t)=>{var n=typeof Symbol<`u`&&Symbol,r=ft();t.exports=function(){return typeof n!=`function`||typeof Symbol!=`function`||typeof n(`foo`)!=`symbol`||typeof Symbol(`bar`)!=`symbol`?!1:r()}})),mt=t(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect.getPrototypeOf||null})),ht=t(((e,t)=>{t.exports=Je().getPrototypeOf||null})),gt=t(((e,t)=>{var n=`Function.prototype.bind called on incompatible `,r=Object.prototype.toString,i=Math.max,a=`[object Function]`,o=function(e,t){for(var n=[],r=0;r<e.length;r+=1)n[r]=e[r];for(var i=0;i<t.length;i+=1)n[i+e.length]=t[i];return n},s=function(e,t){for(var n=[],r=t||0,i=0;r<e.length;r+=1,i+=1)n[i]=e[r];return n},c=function(e,t){for(var n=``,r=0;r<e.length;r+=1)n+=e[r],r+1<e.length&&(n+=t);return n};t.exports=function(e){var t=this;if(typeof t!=`function`||r.apply(t)!==a)throw TypeError(n+t);for(var l=s(arguments,1),u,d=function(){if(this instanceof u){var n=t.apply(this,o(l,arguments));return Object(n)===n?n:this}return t.apply(e,o(l,arguments))},f=i(0,t.length-l.length),p=[],m=0;m<f;m++)p[m]=`$`+m;if(u=Function(`binder`,`return function (`+c(p,`,`)+`){ return binder.apply(this,arguments); }`)(d),t.prototype){var h=function(){};h.prototype=t.prototype,u.prototype=new h,h.prototype=null}return u}})),_t=t(((e,t)=>{var n=gt();t.exports=Function.prototype.bind||n})),vt=t(((e,t)=>{t.exports=Function.prototype.call})),yt=t(((e,t)=>{t.exports=Function.prototype.apply})),bt=t(((e,t)=>{t.exports=typeof Reflect<`u`&&Reflect&&Reflect.apply})),xt=t(((e,t)=>{var n=_t(),r=yt(),i=vt();t.exports=bt()||n.call(i,r)})),St=t(((e,t)=>{var n=_t(),r=Q(),i=vt(),a=xt();t.exports=function(e){if(e.length<1||typeof e[0]!=`function`)throw new r(`a function is required`);return a(n,i,e)}})),Ct=t(((e,t)=>{var n=St(),r=ut(),i;try{i=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!=`object`||!(`code`in e)||e.code!==`ERR_PROTO_ACCESS`)throw e}var a=!!i&&r&&r(Object.prototype,`__proto__`),o=Object,s=o.getPrototypeOf;t.exports=a&&typeof a.get==`function`?n([a.get]):typeof s==`function`?function(e){return s(e==null?e:o(e))}:!1})),wt=t(((e,t)=>{var n=mt(),r=ht(),i=Ct();t.exports=n?function(e){return n(e)}:r?function(e){if(!e||typeof e!=`object`&&typeof e!=`function`)throw TypeError(`getProto: not an object`);return r(e)}:i?function(e){return i(e)}:null})),Tt=t(((e,t)=>{var n=Function.prototype.call,r=Object.prototype.hasOwnProperty;t.exports=_t().call(n,r)})),$=t(((e,t)=>{var n,r=Je(),i=Ye(),a=Xe(),o=Ze(),s=Qe(),c=$e(),l=Q(),u=et(),d=tt(),f=nt(),p=rt(),m=it(),h=at(),g=ot(),_=ct(),v=Function,y=function(e){try{return v(`"use strict"; return (`+e+`).constructor;`)()}catch{}},b=ut(),x=dt(),S=function(){throw new l},C=b?function(){try{return arguments.callee,S}catch{try{return b(arguments,`callee`).get}catch{return S}}}():S,w=pt()(),T=wt(),E=ht(),D=mt(),O=yt(),k=vt(),A={},j=typeof Uint8Array>`u`||!T?n:T(Uint8Array),M={__proto__:null,"%AggregateError%":typeof AggregateError>`u`?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>`u`?n:ArrayBuffer,"%ArrayIteratorPrototype%":w&&T?T([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":A,"%AsyncGenerator%":A,"%AsyncGeneratorFunction%":A,"%AsyncIteratorPrototype%":A,"%Atomics%":typeof Atomics>`u`?n:Atomics,"%BigInt%":typeof BigInt>`u`?n:BigInt,"%BigInt64Array%":typeof BigInt64Array>`u`?n:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>`u`?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>`u`?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":a,"%Float16Array%":typeof Float16Array>`u`?n:Float16Array,"%Float32Array%":typeof Float32Array>`u`?n:Float32Array,"%Float64Array%":typeof Float64Array>`u`?n:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>`u`?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":A,"%Int8Array%":typeof Int8Array>`u`?n:Int8Array,"%Int16Array%":typeof Int16Array>`u`?n:Int16Array,"%Int32Array%":typeof Int32Array>`u`?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":w&&T?T(T([][Symbol.iterator]())):n,"%JSON%":typeof JSON==`object`?JSON:n,"%Map%":typeof Map>`u`?n:Map,"%MapIteratorPrototype%":typeof Map>`u`||!w||!T?n:T(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":r,"%Object.getOwnPropertyDescriptor%":b,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>`u`?n:Promise,"%Proxy%":typeof Proxy>`u`?n:Proxy,"%RangeError%":o,"%ReferenceError%":s,"%Reflect%":typeof Reflect>`u`?n:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>`u`?n:Set,"%SetIteratorPrototype%":typeof Set>`u`||!w||!T?n:T(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>`u`?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":w&&T?T(``[Symbol.iterator]()):n,"%Symbol%":w?Symbol:n,"%SyntaxError%":c,"%ThrowTypeError%":C,"%TypedArray%":j,"%TypeError%":l,"%Uint8Array%":typeof Uint8Array>`u`?n:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>`u`?n:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>`u`?n:Uint16Array,"%Uint32Array%":typeof Uint32Array>`u`?n:Uint32Array,"%URIError%":u,"%WeakMap%":typeof WeakMap>`u`?n:WeakMap,"%WeakRef%":typeof WeakRef>`u`?n:WeakRef,"%WeakSet%":typeof WeakSet>`u`?n:WeakSet,"%Function.prototype.call%":k,"%Function.prototype.apply%":O,"%Object.defineProperty%":x,"%Object.getPrototypeOf%":E,"%Math.abs%":d,"%Math.floor%":f,"%Math.max%":p,"%Math.min%":m,"%Math.pow%":h,"%Math.round%":g,"%Math.sign%":_,"%Reflect.getPrototypeOf%":D};if(T)try{null.error}catch(e){M[`%Error.prototype%`]=T(T(e))}var N=function e(t){var n;if(t===`%AsyncFunction%`)n=y(`async function () {}`);else if(t===`%GeneratorFunction%`)n=y(`function* () {}`);else if(t===`%AsyncGeneratorFunction%`)n=y(`async function* () {}`);else if(t===`%AsyncGenerator%`){var r=e(`%AsyncGeneratorFunction%`);r&&(n=r.prototype)}else if(t===`%AsyncIteratorPrototype%`){var i=e(`%AsyncGenerator%`);i&&T&&(n=T(i.prototype))}return M[t]=n,n},P={__proto__:null,"%ArrayBufferPrototype%":[`ArrayBuffer`,`prototype`],"%ArrayPrototype%":[`Array`,`prototype`],"%ArrayProto_entries%":[`Array`,`prototype`,`entries`],"%ArrayProto_forEach%":[`Array`,`prototype`,`forEach`],"%ArrayProto_keys%":[`Array`,`prototype`,`keys`],"%ArrayProto_values%":[`Array`,`prototype`,`values`],"%AsyncFunctionPrototype%":[`AsyncFunction`,`prototype`],"%AsyncGenerator%":[`AsyncGeneratorFunction`,`prototype`],"%AsyncGeneratorPrototype%":[`AsyncGeneratorFunction`,`prototype`,`prototype`],"%BooleanPrototype%":[`Boolean`,`prototype`],"%DataViewPrototype%":[`DataView`,`prototype`],"%DatePrototype%":[`Date`,`prototype`],"%ErrorPrototype%":[`Error`,`prototype`],"%EvalErrorPrototype%":[`EvalError`,`prototype`],"%Float32ArrayPrototype%":[`Float32Array`,`prototype`],"%Float64ArrayPrototype%":[`Float64Array`,`prototype`],"%FunctionPrototype%":[`Function`,`prototype`],"%Generator%":[`GeneratorFunction`,`prototype`],"%GeneratorPrototype%":[`GeneratorFunction`,`prototype`,`prototype`],"%Int8ArrayPrototype%":[`Int8Array`,`prototype`],"%Int16ArrayPrototype%":[`Int16Array`,`prototype`],"%Int32ArrayPrototype%":[`Int32Array`,`prototype`],"%JSONParse%":[`JSON`,`parse`],"%JSONStringify%":[`JSON`,`stringify`],"%MapPrototype%":[`Map`,`prototype`],"%NumberPrototype%":[`Number`,`prototype`],"%ObjectPrototype%":[`Object`,`prototype`],"%ObjProto_toString%":[`Object`,`prototype`,`toString`],"%ObjProto_valueOf%":[`Object`,`prototype`,`valueOf`],"%PromisePrototype%":[`Promise`,`prototype`],"%PromiseProto_then%":[`Promise`,`prototype`,`then`],"%Promise_all%":[`Promise`,`all`],"%Promise_reject%":[`Promise`,`reject`],"%Promise_resolve%":[`Promise`,`resolve`],"%RangeErrorPrototype%":[`RangeError`,`prototype`],"%ReferenceErrorPrototype%":[`ReferenceError`,`prototype`],"%RegExpPrototype%":[`RegExp`,`prototype`],"%SetPrototype%":[`Set`,`prototype`],"%SharedArrayBufferPrototype%":[`SharedArrayBuffer`,`prototype`],"%StringPrototype%":[`String`,`prototype`],"%SymbolPrototype%":[`Symbol`,`prototype`],"%SyntaxErrorPrototype%":[`SyntaxError`,`prototype`],"%TypedArrayPrototype%":[`TypedArray`,`prototype`],"%TypeErrorPrototype%":[`TypeError`,`prototype`],"%Uint8ArrayPrototype%":[`Uint8Array`,`prototype`],"%Uint8ClampedArrayPrototype%":[`Uint8ClampedArray`,`prototype`],"%Uint16ArrayPrototype%":[`Uint16Array`,`prototype`],"%Uint32ArrayPrototype%":[`Uint32Array`,`prototype`],"%URIErrorPrototype%":[`URIError`,`prototype`],"%WeakMapPrototype%":[`WeakMap`,`prototype`],"%WeakSetPrototype%":[`WeakSet`,`prototype`]},F=_t(),I=Tt(),ee=F.call(k,Array.prototype.concat),te=F.call(O,Array.prototype.splice),ne=F.call(k,String.prototype.replace),L=F.call(k,String.prototype.slice),R=F.call(k,RegExp.prototype.exec),z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,B=/\\(\\)?/g,V=function(e){var t=L(e,0,1),n=L(e,-1);if(t===`%`&&n!==`%`)throw new c("invalid intrinsic syntax, expected closing `%`");if(n===`%`&&t!==`%`)throw new c("invalid intrinsic syntax, expected opening `%`");var r=[];return ne(e,z,function(e,t,n,i){r[r.length]=n?ne(i,B,`$1`):t||e}),r},H=function(e,t){var n=e,r;if(I(P,n)&&(r=P[n],n=`%`+r[0]+`%`),I(M,n)){var i=M[n];if(i===A&&(i=N(n)),i===void 0&&!t)throw new l(`intrinsic `+e+` exists, but is not available. Please file an issue!`);return{alias:r,name:n,value:i}}throw new c(`intrinsic `+e+` does not exist!`)};t.exports=function(e,t){if(typeof e!=`string`||e.length===0)throw new l(`intrinsic name must be a non-empty string`);if(arguments.length>1&&typeof t!=`boolean`)throw new l(`"allowMissing" argument must be a boolean`);if(R(/^%?[^%]*%?$/,e)===null)throw new c("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=V(e),r=n.length>0?n[0]:``,i=H(`%`+r+`%`,t),a=i.name,o=i.value,s=!1,u=i.alias;u&&(r=u[0],te(n,ee([0,1],u)));for(var d=1,f=!0;d<n.length;d+=1){var p=n[d],m=L(p,0,1),h=L(p,-1);if((m===`"`||m===`'`||m==="`"||h===`"`||h===`'`||h==="`")&&m!==h)throw new c(`property names with quotes must have matching quotes`);if((p===`constructor`||!f)&&(s=!0),r+=`.`+p,a=`%`+r+`%`,I(M,a))o=M[a];else if(o!=null){if(!(p in o)){if(!t)throw new l(`base intrinsic for `+e+` exists, but the property is not available.`);return}if(b&&d+1>=n.length){var g=b(o,p);f=!!g,o=f&&`get`in g&&!(`originalValue`in g.get)?g.get:o[p]}else f=I(o,p),o=o[p];f&&!s&&(M[a]=o)}}return o}})),Et=t(((e,t)=>{var n=dt(),r=$e(),i=Q(),a=ut();t.exports=function(e,t,o){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`obj` must be an object or a function`");if(typeof t!=`string`&&typeof t!=`symbol`)throw new i("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!=`boolean`&&arguments[3]!==null)throw new i("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!=`boolean`&&arguments[4]!==null)throw new i("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!=`boolean`&&arguments[5]!==null)throw new i("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!=`boolean`)throw new i("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,l=arguments.length>5?arguments[5]:null,u=arguments.length>6?arguments[6]:!1,d=!!a&&a(e,t);if(n)n(e,t,{configurable:l===null&&d?d.configurable:!l,enumerable:s===null&&d?d.enumerable:!s,value:o,writable:c===null&&d?d.writable:!c});else if(u||!s&&!c&&!l)e[t]=o;else throw new r(`This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.`)}})),Dt=t(((e,t)=>{var n=dt(),r=function(){return!!n};r.hasArrayLengthDefineBug=function(){if(!n)return null;try{return n([],`length`,{value:1}).length!==1}catch{return!0}},t.exports=r})),Ot=t(((e,t)=>{var n=$(),r=Et(),i=Dt()(),a=ut(),o=Q(),s=n(`%Math.floor%`);t.exports=function(e,t){if(typeof e!=`function`)throw new o("`fn` is not a function");if(typeof t!=`number`||t<0||t>4294967295||s(t)!==t)throw new o("`length` must be a positive 32-bit integer");var n=arguments.length>2&&!!arguments[2],c=!0,l=!0;if(`length`in e&&a){var u=a(e,`length`);u&&!u.configurable&&(c=!1),u&&!u.writable&&(l=!1)}return(c||l||!n)&&(i?r(e,`length`,t,!0,!0):r(e,`length`,t)),e}})),kt=t(((e,t)=>{var n=_t(),r=yt(),i=xt();t.exports=function(){return i(n,r,arguments)}})),At=t(((e,t)=>{var n=Ot(),r=dt(),i=St(),a=kt();t.exports=function(e){var t=i(arguments),r=1+e.length-(arguments.length-1);return n(t,r>0?r:0,!0)},r?r(t.exports,`apply`,{value:a}):t.exports.apply=a})),jt=t(((e,t)=>{var n=Object.prototype.toString;t.exports=function(e){var t=n.call(e),r=t===`[object Arguments]`;return r||=t!==`[object Array]`&&typeof e==`object`&&!!e&&typeof e.length==`number`&&e.length>=0&&n.call(e.callee)===`[object Function]`,r}})),Mt=t(((e,t)=>{var n;if(!Object.keys){var r=Object.prototype.hasOwnProperty,i=Object.prototype.toString,a=jt(),o=Object.prototype.propertyIsEnumerable,s=!o.call({toString:null},`toString`),c=o.call(function(){},`prototype`),l=[`toString`,`toLocaleString`,`valueOf`,`hasOwnProperty`,`isPrototypeOf`,`propertyIsEnumerable`,`constructor`],u=function(e){var t=e.constructor;return t&&t.prototype===e},d={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},f=function(){if(typeof window>`u`)return!1;for(var e in window)try{if(!d[`$`+e]&&r.call(window,e)&&window[e]!==null&&typeof window[e]==`object`)try{u(window[e])}catch{return!0}}catch{return!0}return!1}(),p=function(e){if(typeof window>`u`||!f)return u(e);try{return u(e)}catch{return!1}};n=function(e){var t=typeof e==`object`&&!!e,n=i.call(e)===`[object Function]`,o=a(e),u=t&&i.call(e)===`[object String]`,d=[];if(!t&&!n&&!o)throw TypeError(`Object.keys called on a non-object`);var f=c&&n;if(u&&e.length>0&&!r.call(e,0))for(var m=0;m<e.length;++m)d.push(String(m));if(o&&e.length>0)for(var h=0;h<e.length;++h)d.push(String(h));else for(var g in e)!(f&&g===`prototype`)&&r.call(e,g)&&d.push(String(g));if(s)for(var _=p(e),v=0;v<l.length;++v)!(_&&l[v]===`constructor`)&&r.call(e,l[v])&&d.push(l[v]);return d}}t.exports=n})),Nt=t(((e,t)=>{var n=Array.prototype.slice,r=jt(),i=Object.keys,a=i?function(e){return i(e)}:Mt(),o=Object.keys;a.shim=function(){return Object.keys?function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2)||(Object.keys=function(e){return r(e)?o(n.call(e)):o(e)}):Object.keys=a,Object.keys||a},t.exports=a})),Pt=t(((e,t)=>{var n=Nt(),r=typeof Symbol==`function`&&typeof Symbol(`foo`)==`symbol`,i=Object.prototype.toString,a=Array.prototype.concat,o=Et(),s=function(e){return typeof e==`function`&&i.call(e)===`[object Function]`},c=Dt()(),l=function(e,t,n,r){if(t in e){if(r===!0){if(e[t]===n)return}else if(!s(r)||!r())return}c?o(e,t,n,!0):o(e,t,n)},u=function(e,t){var i=arguments.length>2?arguments[2]:{},o=n(t);r&&(o=a.call(o,Object.getOwnPropertySymbols(t)));for(var s=0;s<o.length;s+=1)l(e,o[s],t[o[s]],i[o[s]])};u.supportsDescriptors=!!c,t.exports=u})),Ft=t(((e,t)=>{var n=$(),r=St(),i=r([n(`%String.prototype.indexOf%`)]);t.exports=function(e,t){var a=n(e,!!t);return typeof a==`function`&&i(e,`.prototype.`)>-1?r([a]):a}})),It=t(((e,t)=>{var n=$()(`%Array%`),r=!n.isArray&&Ft()(`Object.prototype.toString`);t.exports=n.isArray||function(e){return r(e)===`[object Array]`}})),Lt=t(((e,t)=>{t.exports=It()})),Rt=t(((e,t)=>{var n=$(),r=Ft(),i=Q(),a=Lt(),o=n(`%Reflect.apply%`,!0)||r(`Function.prototype.apply`);t.exports=function(e,t){var n=arguments.length>2?arguments[2]:[];if(!a(n))throw new i("Assertion failed: optional `argumentsList`, if provided, must be a List");return o(e,t,n)}})),zt=t(((e,t)=>{t.exports={}})),Bt=t(((e,t)=>{me();var n=typeof Map==`function`&&Map.prototype,r=Object.getOwnPropertyDescriptor&&n?Object.getOwnPropertyDescriptor(Map.prototype,`size`):null,i=n&&r&&typeof r.get==`function`?r.get:null,a=n&&Map.prototype.forEach,o=typeof Set==`function`&&Set.prototype,s=Object.getOwnPropertyDescriptor&&o?Object.getOwnPropertyDescriptor(Set.prototype,`size`):null,c=o&&s&&typeof s.get==`function`?s.get:null,l=o&&Set.prototype.forEach,u=typeof WeakMap==`function`&&WeakMap.prototype?WeakMap.prototype.has:null,d=typeof WeakSet==`function`&&WeakSet.prototype?WeakSet.prototype.has:null,f=typeof WeakRef==`function`&&WeakRef.prototype?WeakRef.prototype.deref:null,p=Boolean.prototype.valueOf,m=Object.prototype.toString,h=Function.prototype.toString,g=String.prototype.match,_=String.prototype.slice,v=String.prototype.replace,y=String.prototype.toUpperCase,b=String.prototype.toLowerCase,x=RegExp.prototype.test,S=Array.prototype.concat,C=Array.prototype.join,w=Array.prototype.slice,T=Math.floor,E=typeof BigInt==`function`?BigInt.prototype.valueOf:null,D=Object.getOwnPropertySymbols,O=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?Symbol.prototype.toString:null,k=typeof Symbol==`function`&&typeof Symbol.iterator==`object`,A=typeof Symbol==`function`&&Symbol.toStringTag?Symbol.toStringTag:null,j=Object.prototype.propertyIsEnumerable,M=(typeof Reflect==`function`?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function N(e,t){if(e===1/0||e===-1/0||e!==e||e&&e>-1e3&&e<1e3||x.call(/e/,t))return t;var n=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if(typeof e==`number`){var r=e<0?-T(-e):T(e);if(r!==e){var i=String(r),a=_.call(t,i.length+1);return v.call(i,n,`$&_`)+`.`+v.call(v.call(a,/([0-9]{3})/g,`$&_`),/_$/,``)}}return v.call(t,n,`$&_`)}var P=zt(),F=P.custom,I=W(F)?F:null,ee={__proto__:null,double:`"`,single:`'`},te={__proto__:null,double:/(["\\])/g,single:/(['\\])/g};t.exports=function e(t,n,r,o){var s=n||{};if(K(s,`quoteStyle`)&&!K(ee,s.quoteStyle))throw TypeError(`option "quoteStyle" must be "single" or "double"`);if(K(s,`maxStringLength`)&&(typeof s.maxStringLength==`number`?s.maxStringLength<0&&s.maxStringLength!==1/0:s.maxStringLength!==null))throw TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var u=K(s,`customInspect`)?s.customInspect:!0;if(typeof u!=`boolean`&&u!==`symbol`)throw TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(K(s,`indent`)&&s.indent!==null&&s.indent!==` `&&!(parseInt(s.indent,10)===s.indent&&s.indent>0))throw TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(K(s,`numericSeparator`)&&typeof s.numericSeparator!=`boolean`)throw TypeError('option "numericSeparator", if provided, must be `true` or `false`');var d=s.numericSeparator;if(t===void 0)return`undefined`;if(t===null)return`null`;if(typeof t==`boolean`)return t?`true`:`false`;if(typeof t==`string`)return fe(t,s);if(typeof t==`number`){if(t===0)return 1/0/t>0?`0`:`-0`;var f=String(t);return d?N(t,f):f}if(typeof t==`bigint`){var m=String(t)+`n`;return d?N(t,m):m}var h=s.depth===void 0?5:s.depth;if(r===void 0&&(r=0),r>=h&&h>0&&typeof t==`object`)return z(t)?`[Array]`:`[Object]`;var g=ve(s,r);if(o===void 0)o=[];else if(Y(o,t)>=0)return`[Circular]`;function y(t,n,i){if(n&&(o=w.call(o),o.push(n)),i){var a={depth:s.depth};return K(s,`quoteStyle`)&&(a.quoteStyle=s.quoteStyle),e(t,a,r+1,o)}return e(t,s,r+1,o)}if(typeof t==`function`&&!V(t)){var x=J(t),T=be(t,y);return`[Function`+(x?`: `+x:` (anonymous)`)+`]`+(T.length>0?` { `+C.call(T,`, `)+` }`:``)}if(W(t)){var D=k?v.call(String(t),/^(Symbol\(.*\))_[^)]*$/,`$1`):O.call(t);return typeof t==`object`&&!k?Z(D):D}if(de(t)){for(var F=`<`+b.call(String(t.nodeName)),te=t.attributes||[],R=0;R<te.length;R++)F+=` `+te[R].name+`=`+ne(L(te[R].value),`double`,s);return F+=`>`,t.childNodes&&t.childNodes.length&&(F+=`...`),F+=`</`+b.call(String(t.nodeName))+`>`,F}if(z(t)){if(t.length===0)return`[]`;var G=be(t,y);return g&&!_e(G)?`[`+ye(G,g)+`]`:`[ `+C.call(G,`, `)+` ]`}if(H(t)){var X=be(t,y);return!(`cause`in Error.prototype)&&`cause`in t&&!j.call(t,`cause`)?`{ [`+String(t)+`] `+C.call(S.call(`[cause]: `+y(t.cause),X),`, `)+` }`:X.length===0?`[`+String(t)+`]`:`{ [`+String(t)+`] `+C.call(X,`, `)+` }`}if(typeof t==`object`&&u){if(I&&typeof t[I]==`function`&&P)return P(t,{depth:h-r});if(u!==`symbol`&&typeof t.inspect==`function`)return t.inspect()}if(oe(t)){var me=[];return a&&a.call(t,function(e,n){me.push(y(n,t,!0)+` => `+y(e,t))}),ge(`Map`,i.call(t),me,g)}if(le(t)){var xe=[];return l&&l.call(t,function(e){xe.push(y(e,t))}),ge(`Set`,c.call(t),xe,g)}if(se(t))return he(`WeakMap`);if(ue(t))return he(`WeakSet`);if(ce(t))return he(`WeakRef`);if(re(t))return Z(y(Number(t)));if(ae(t))return Z(y(E.call(t)));if(ie(t))return Z(p.call(t));if(U(t))return Z(y(String(t)));if(typeof window<`u`&&t===window)return`{ [object Window] }`;if(typeof globalThis<`u`&&t===globalThis||pe!==void 0&&t===pe)return`{ [object globalThis] }`;if(!B(t)&&!V(t)){var Se=be(t,y),Ce=M?M(t)===Object.prototype:t instanceof Object||t.constructor===Object,we=t instanceof Object?``:`null prototype`,Te=!Ce&&A&&Object(t)===t&&A in t?_.call(q(t),8,-1):we?`Object`:``,Ee=(Ce||typeof t.constructor!=`function`?``:t.constructor.name?t.constructor.name+` `:``)+(Te||we?`[`+C.call(S.call([],Te||[],we||[]),`: `)+`] `:``);return Se.length===0?Ee+`{}`:g?Ee+`{`+ye(Se,g)+`}`:Ee+`{ `+C.call(Se,`, `)+` }`}return String(t)};function ne(e,t,n){var r=ee[n.quoteStyle||t];return r+e+r}function L(e){return v.call(String(e),/"/g,`&quot;`)}function R(e){return!A||!(typeof e==`object`&&(A in e||e[A]!==void 0))}function z(e){return q(e)===`[object Array]`&&R(e)}function B(e){return q(e)===`[object Date]`&&R(e)}function V(e){return q(e)===`[object RegExp]`&&R(e)}function H(e){return q(e)===`[object Error]`&&R(e)}function U(e){return q(e)===`[object String]`&&R(e)}function re(e){return q(e)===`[object Number]`&&R(e)}function ie(e){return q(e)===`[object Boolean]`&&R(e)}function W(e){if(k)return e&&typeof e==`object`&&e instanceof Symbol;if(typeof e==`symbol`)return!0;if(!e||typeof e!=`object`||!O)return!1;try{return O.call(e),!0}catch{}return!1}function ae(e){if(!e||typeof e!=`object`||!E)return!1;try{return E.call(e),!0}catch{}return!1}var G=Object.prototype.hasOwnProperty||function(e){return e in this};function K(e,t){return G.call(e,t)}function q(e){return m.call(e)}function J(e){if(e.name)return e.name;var t=g.call(h.call(e),/^function\s*([\w$]+)/);return t?t[1]:null}function Y(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}function oe(e){if(!i||!e||typeof e!=`object`)return!1;try{i.call(e);try{c.call(e)}catch{return!0}return e instanceof Map}catch{}return!1}function se(e){if(!u||!e||typeof e!=`object`)return!1;try{u.call(e,u);try{d.call(e,d)}catch{return!0}return e instanceof WeakMap}catch{}return!1}function ce(e){if(!f||!e||typeof e!=`object`)return!1;try{return f.call(e),!0}catch{}return!1}function le(e){if(!c||!e||typeof e!=`object`)return!1;try{c.call(e);try{i.call(e)}catch{return!0}return e instanceof Set}catch{}return!1}function ue(e){if(!d||!e||typeof e!=`object`)return!1;try{d.call(e,d);try{u.call(e,u)}catch{return!0}return e instanceof WeakSet}catch{}return!1}function de(e){return!e||typeof e!=`object`?!1:typeof HTMLElement<`u`&&e instanceof HTMLElement?!0:typeof e.nodeName==`string`&&typeof e.getAttribute==`function`}function fe(e,t){if(e.length>t.maxStringLength){var n=e.length-t.maxStringLength,r=`... `+n+` more character`+(n>1?`s`:``);return fe(_.call(e,0,t.maxStringLength),t)+r}var i=te[t.quoteStyle||`single`];return i.lastIndex=0,ne(v.call(v.call(e,i,`\\$1`),/[\x00-\x1f]/g,X),`single`,t)}function X(e){var t=e.charCodeAt(0),n={8:`b`,9:`t`,10:`n`,12:`f`,13:`r`}[t];return n?`\\`+n:`\\x`+(t<16?`0`:``)+y.call(t.toString(16))}function Z(e){return`Object(`+e+`)`}function he(e){return e+` { ? }`}function ge(e,t,n,r){var i=r?ye(n,r):C.call(n,`, `);return e+` (`+t+`) {`+i+`}`}function _e(e){for(var t=0;t<e.length;t++)if(Y(e[t],`
25
33
  `)>=0)return!1;return!0}function ve(e,t){var n;if(e.indent===` `)n=` `;else if(typeof e.indent==`number`&&e.indent>0)n=C.call(Array(e.indent+1),` `);else return null;return{base:n,prev:C.call(Array(t+1),n)}}function ye(e,t){if(e.length===0)return``;var n=`
26
34
  `+t.prev+t.base;return n+C.call(e,`,`+n)+`
27
- `+t.prev}function be(e,t){var n=z(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=K(e,i)?t(e[i],e):``}var a=typeof D==`function`?D(e):[],o;if(k){o={};for(var s=0;s<a.length;s++)o[`$`+a[s]]=a[s]}for(var c in e)K(e,c)&&(n&&String(Number(c))===c&&c<e.length||k&&o[`$`+c]instanceof Symbol||(x.call(/[^\w$]/,c)?r.push(t(c,e)+`: `+t(e[c],e)):r.push(c+`: `+t(e[c],e))));if(typeof D==`function`)for(var l=0;l<a.length;l++)j.call(e,a[l])&&r.push(`[`+t(a[l])+`]: `+t(e[a[l]],e));return r}})),Rt=t(((e,t)=>{t.exports=function(e){return typeof e==`string`||typeof e==`symbol`}})),zt=t(((e,t)=>{t.exports=function(e){return!!e&&(typeof e==`function`||typeof e==`object`)}})),Bt=t(((e,t)=>{var n=Q(),r=Lt(),i=Rt(),a=zt();t.exports=function(e,t){if(!a(e))throw new n(`Assertion failed: Type(O) is not Object`);if(!i(t))throw new n(`Assertion failed: P is not a Property Key, got `+r(t));return e[t]}})),Vt=t(((e,t)=>{var n=Q(),r=Lt(),i=Rt();t.exports=function(e,t){if(!i(t))throw new n(`Assertion failed: P is not a Property Key, got `+r(t));return e[t]}})),Ht=t(((e,t)=>{var n=Function.prototype.toString,r=typeof Reflect==`object`&&Reflect!==null&&Reflect.apply,i,a;if(typeof r==`function`&&typeof Object.defineProperty==`function`)try{i=Object.defineProperty({},"length",{get:function(){throw a}}),a={},r(function(){throw 42},null,i)}catch(e){e!==a&&(r=null)}else r=null;var o=/^\s*class\b/,s=function(e){try{var t=n.call(e);return o.test(t)}catch{return!1}},c=function(e){try{return s(e)?!1:(n.call(e),!0)}catch{return!1}},l=Object.prototype.toString,u=`[object Object]`,d=`[object Function]`,f=`[object GeneratorFunction]`,p=`[object HTMLAllCollection]`,m=`[object HTML document.all class]`,h=`[object HTMLCollection]`,g=typeof Symbol==`function`&&!!Symbol.toStringTag,_=!(0 in[,]),v=function(){return!1};if(typeof document==`object`){var y=document.all;l.call(y)===l.call(document.all)&&(v=function(e){if((_||!e)&&(e===void 0||typeof e==`object`))try{var t=l.call(e);return(t===p||t===m||t===h||t===u)&&e(``)==null}catch{}return!1})}t.exports=r?function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;try{r(e,null,i)}catch(e){if(e!==a)return!1}return!s(e)&&c(e)}:function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;if(g)return c(e);if(s(e))return!1;var t=l.call(e);return t!==d&&t!==f&&!/^\[object HTML/.test(t)?!1:c(e)}})),Ut=t(((e,t)=>{t.exports=Ht()})),Wt=t(((e,t)=>{var n=Q(),r=Vt(),i=Ut(),a=Rt(),o=Lt();t.exports=function(e,t){if(!a(t))throw new n(`Assertion failed: P is not a Property Key`);var s=r(e,t);if(s!=null){if(!i(s))throw new n(o(t)+` is not a function: `+o(s));return s}}})),Gt=t(((e,t)=>{var n=lt();t.exports=function(){return n()&&!!Symbol.toStringTag}})),Kt=t(((e,t)=>{var n=Mt(),r=Gt()(),i=St(),a=st(),o;if(r){var s=n(`RegExp.prototype.exec`),c={},l=function(){throw c},u={toString:l,valueOf:l};typeof Symbol.toPrimitive==`symbol`&&(u[Symbol.toPrimitive]=l),o=function(e){if(!e||typeof e!=`object`)return!1;var t=a(e,`lastIndex`);if(!(t&&i(t,`value`)))return!1;try{s(e,u)}catch(e){return e===c}}}else{var d=n(`Object.prototype.toString`),f=`[object RegExp]`;o=function(e){return!e||typeof e!=`object`&&typeof e!=`function`?!1:d(e)===f}}t.exports=o})),qt=t(((e,t)=>{t.exports=function(e){return!!e}})),Jt=t(((e,t)=>{var n=$()(`%Symbol.match%`,!0),r=Kt(),i=zt(),a=qt();t.exports=function(e){if(!i(e))return!1;if(n){var t=e[n];if(t!==void 0)return a(t)}return r(e)}})),Yt=t(((e,t)=>{var n=$()(`%String%`),r=Q();t.exports=function(e){if(typeof e==`symbol`)throw new r(`Cannot convert a Symbol value to a string`);return n(e)}})),Xt=t(((e,t)=>{var n=Q();t.exports=function(e){if(e==null)throw new n(arguments.length>0&&arguments[1]||`Cannot call method on `+e);return e}})),Zt=t(((e,t)=>{var n=function(){return typeof function(){}.name==`string`},r=Object.getOwnPropertyDescriptor;if(r)try{r([],`length`)}catch{r=null}n.functionsHaveConfigurableNames=function(){if(!n()||!r)return!1;var e=r(function(){},`name`);return!!e&&!!e.configurable};var i=Function.prototype.bind;n.boundFunctionsHaveNames=function(){return n()&&typeof i==`function`&&function(){}.bind().name!==``},t.exports=n})),Qt=t(((e,t)=>{var n=Ct(),r=wt()(),i=Zt().functionsHaveConfigurableNames(),a=Q();t.exports=function(e,t){if(typeof e!=`function`)throw new a("`fn` is not a function");return(!(arguments.length>2&&arguments[2])||i)&&(r?n(e,`name`,t,!0,!0):n(e,`name`,t)),e}})),$t=t(((e,t)=>{var n=Qt(),r=Q(),i=Object;t.exports=n(function(){if(this==null||this!==i(this))throw new r(`RegExp.prototype.flags getter called on non-object`);var e=``;return this.hasIndices&&(e+=`d`),this.global&&(e+=`g`),this.ignoreCase&&(e+=`i`),this.multiline&&(e+=`m`),this.dotAll&&(e+=`s`),this.unicode&&(e+=`u`),this.unicodeSets&&(e+=`v`),this.sticky&&(e+=`y`),e},`get flags`,!0)})),en=t(((e,t)=>{var n=$t(),r=jt().supportsDescriptors,i=Object.getOwnPropertyDescriptor;t.exports=function(){if(r&&/a/gim.flags===`gim`){var e=i(RegExp.prototype,`flags`);if(e&&typeof e.get==`function`&&`dotAll`in RegExp.prototype&&`hasIndices`in RegExp.prototype){var t=``,a={};if(Object.defineProperty(a,"hasIndices",{get:function(){t+=`d`}}),Object.defineProperty(a,"sticky",{get:function(){t+=`y`}}),e.get.call(a),t===`dy`)return e.get}}return n}})),tn=t(((e,t)=>{var n=jt().supportsDescriptors,r=en(),i=st(),a=Object.defineProperty,o=Ke(),s=xt(),c=/a/;t.exports=function(){if(!n||!s)throw new o(`RegExp.prototype.flags requires a true ES5 environment that supports property descriptors`);var e=r(),t=s(c),l=i(t,`flags`);return(!l||l.get!==e)&&a(t,`flags`,{configurable:!0,enumerable:!1,get:e}),e}})),nn=t(((e,t)=>{var n=jt(),r=Dt(),i=$t(),a=en(),o=tn(),s=r(a());n(s,{getPolyfill:a,implementation:i,shim:o}),t.exports=s})),rn=t(((e,t)=>{t.exports=function(e){return typeof e==`number`&&e>=55296&&e<=56319}})),an=t(((e,t)=>{t.exports=function(e){return typeof e==`number`&&e>=56320&&e<=57343}})),on=t(((e,t)=>{var n=$(),r=Q(),i=n(`%String.fromCharCode%`),a=rn(),o=an();t.exports=function(e,t){if(!a(e)||!o(t))throw new r("Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code");return i(e)+i(t)}})),sn=t(((e,t)=>{var n=Q(),r=Mt(),i=rn(),a=an(),o=on(),s=r(`String.prototype.charAt`),c=r(`String.prototype.charCodeAt`);t.exports=function(e,t){if(typeof e!=`string`)throw new n("Assertion failed: `string` must be a String");var r=e.length;if(t<0||t>=r)throw new n("Assertion failed: `position` must be >= 0, and < the length of `string`");var l=c(e,t),u=s(e,t),d=i(l),f=a(l);if(!d&&!f)return{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!1};if(f||t+1===r)return{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!0};var p=c(e,t+1);return a(p)?{"[[CodePoint]]":o(l,p),"[[CodeUnitCount]]":2,"[[IsUnpairedSurrogate]]":!1}:{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!0}}})),cn=t(((e,t)=>{var n=it();t.exports=function(e){return(typeof e==`number`||typeof e==`bigint`)&&!n(e)&&e!==1/0&&e!==-1/0}})),ln=t(((e,t)=>{var n=Qe(),r=$e(),i=it(),a=cn();t.exports=function(e){if(typeof e!=`number`||i(e)||!a(e))return!1;var t=n(e);return r(t)===t}})),un=t(((e,t)=>{t.exports=2**53-1||9007199254740991})),dn=t(((e,t)=>{var n=sn(),r=Q(),i=ln(),a=un();t.exports=function(e,t,o){if(typeof e!=`string`)throw new r("Assertion failed: `S` must be a String");if(!i(t)||t<0||t>a)throw new r("Assertion failed: `length` must be an integer >= 0 and <= 2**53");if(typeof o!=`boolean`)throw new r("Assertion failed: `unicode` must be a Boolean");if(!o)return t+1;var s=e.length;return t+1>=s?t+1:t+n(e,t)[`[[CodeUnitCount]]`]}})),fn=t(((e,t)=>{var n=Q();t.exports=function(e,t){if(typeof t!=`boolean`)throw new n(`Assertion failed: Type(done) is not Boolean`);return{value:e,done:t}}})),pn=t(((e,t)=>{var n=Q(),r=St(),i={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};t.exports=function(e){if(!e||typeof e!=`object`)return!1;for(var t in e)if(r(e,t)&&!i[t])return!1;var a=r(e,`[[Value]]`)||r(e,`[[Writable]]`),o=r(e,`[[Get]]`)||r(e,`[[Set]]`);if(a&&o)throw new n(`Property Descriptors may not be both accessor and data descriptors`);return!0}})),mn=t(((e,t)=>{var n=wt(),r=ct(),i=n.hasArrayLengthDefineBug(),a=i&&Nt(),o=Mt()(`Object.prototype.propertyIsEnumerable`);t.exports=function(e,t,n,s,c,l){if(!r){if(!e(l)||!l[`[[Configurable]]`]||!l[`[[Writable]]`]||c in s&&o(s,c)!==!!l[`[[Enumerable]]`])return!1;var u=l[`[[Value]]`];return s[c]=u,t(s[c],u)}return i&&c===`length`&&`[[Value]]`in l&&a(s)&&s.length!==l[`[[Value]]`]?(s.length=l[`[[Value]]`],s.length===l[`[[Value]]`]):(r(s,c,n(l)),!0)}})),hn=t(((e,t)=>{t.exports=function(e){if(e===void 0)return e;var t={};return`[[Value]]`in e&&(t.value=e[`[[Value]]`]),`[[Writable]]`in e&&(t.writable=!!e[`[[Writable]]`]),`[[Get]]`in e&&(t.get=e[`[[Get]]`]),`[[Set]]`in e&&(t.set=e[`[[Set]]`]),`[[Enumerable]]`in e&&(t.enumerable=!!e[`[[Enumerable]]`]),`[[Configurable]]`in e&&(t.configurable=!!e[`[[Configurable]]`]),t}})),gn=t(((e,t)=>{var n=Q(),r=pn(),i=hn();t.exports=function(e){if(e!==void 0&&!r(e))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return i(e)}})),_n=t(((e,t)=>{var n=Q(),r=St(),i=pn();t.exports=function(e){if(e===void 0)return!1;if(!i(e))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return!(!r(e,`[[Value]]`)&&!r(e,`[[Writable]]`))}})),vn=t(((e,t)=>{var n=it();t.exports=function(e,t){return e===t?e===0?1/e==1/t:!0:n(e)&&n(t)}})),yn=t(((e,t)=>{var n=St(),r=Q(),i=zt(),a=Ut(),o=qt();t.exports=function(e){if(!i(e))throw new r(`ToPropertyDescriptor requires an object`);var t={};if(n(e,`enumerable`)&&(t[`[[Enumerable]]`]=o(e.enumerable)),n(e,`configurable`)&&(t[`[[Configurable]]`]=o(e.configurable)),n(e,`value`)&&(t[`[[Value]]`]=e.value),n(e,`writable`)&&(t[`[[Writable]]`]=o(e.writable)),n(e,`get`)){var s=e.get;if(s!==void 0&&!a(s))throw new r(`getter must be a function`);t[`[[Get]]`]=s}if(n(e,`set`)){var c=e.set;if(c!==void 0&&!a(c))throw new r(`setter must be a function`);t[`[[Set]]`]=c}if((n(t,`[[Get]]`)||n(t,`[[Set]]`))&&(n(t,`[[Value]]`)||n(t,`[[Writable]]`)))throw new r(`Invalid property descriptor. Cannot both specify accessors and a value or writable attribute`);return t}})),bn=t(((e,t)=>{var n=Q(),r=zt(),i=pn(),a=mn(),o=gn(),s=_n(),c=Rt(),l=vn(),u=yn();t.exports=function(e,t,d){if(!r(e))throw new n(`Assertion failed: Type(O) is not Object`);if(!c(t))throw new n(`Assertion failed: P is not a Property Key`);var f=i(d)?d:u(d);if(!i(f))throw new n(`Assertion failed: Desc is not a valid Property Descriptor`);return a(s,l,o,e,t,f)}})),xn=t(((e,t)=>{t.exports=function(e){return e===null||typeof e!=`function`&&typeof e!=`object`}})),Sn=t(((e,t)=>{var n=$(),r=n(`%Object.preventExtensions%`,!0),i=n(`%Object.isExtensible%`,!0),a=xn();t.exports=r?function(e){return!a(e)&&i(e)}:function(e){return!a(e)}})),Cn=t(((e,t)=>{var n=Q(),r=zt(),i=bn(),a=Sn(),o=Rt();t.exports=function(e,t,s,c){if(!r(e))throw new n("Assertion failed: `homeObject` is not an Object");if(!o(t))throw new n("Assertion failed: `key` is not a Property Key or a Private Name");if(typeof s!=`function`)throw new n("Assertion failed: `closure` is not a function");if(typeof c!=`boolean`)throw new n("Assertion failed: `enumerable` is not a Boolean");if(!a(e))throw new n("Assertion failed: `homeObject` is not an ordinary, extensible object, with no non-configurable properties");i(e,t,{"[[Value]]":s,"[[Writable]]":!0,"[[Enumerable]]":c,"[[Configurable]]":!0})}})),wn=t(((e,t)=>{t.exports=function(e,t){for(var n=0;n<e.length;n+=1)t(e[n],n,e)}})),Tn=t(((e,t)=>{var n=Lt(),r=Q(),i=function(e,t,n){for(var r=e,i;(i=r.next)!=null;r=i)if(i.key===t)return r.next=i.next,n||(i.next=e.next,e.next=i),i},a=function(e,t){if(e){var n=i(e,t);return n&&n.value}},o=function(e,t,n){var r=i(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}},s=function(e,t){return e?!!i(e,t):!1},c=function(e,t){if(e)return i(e,t,!0)};t.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new r(`Side channel does not contain `+n(e))},delete:function(t){var n=c(e,t);return n&&e&&!e.next&&(e=void 0),!!n},get:function(t){return a(e,t)},has:function(t){return s(e,t)},set:function(t,n){e||={next:void 0},o(e,t,n)}};return t}})),En=t(((e,t)=>{var n=$(),r=Mt(),i=Lt(),a=Q(),o=n(`%Map%`,!0),s=r(`Map.prototype.get`,!0),c=r(`Map.prototype.set`,!0),l=r(`Map.prototype.has`,!0),u=r(`Map.prototype.delete`,!0),d=r(`Map.prototype.size`,!0);t.exports=!!o&&function(){var e,t={assert:function(e){if(!t.has(e))throw new a(`Side channel does not contain `+i(e))},delete:function(t){if(e){var n=u(e,t);return d(e)===0&&(e=void 0),n}return!1},get:function(t){if(e)return s(e,t)},has:function(t){return e?l(e,t):!1},set:function(t,n){e||=new o,c(e,t,n)}};return t}})),Dn=t(((e,t)=>{var n=$(),r=Mt(),i=Lt(),a=En(),o=Q(),s=n(`%WeakMap%`,!0),c=r(`WeakMap.prototype.get`,!0),l=r(`WeakMap.prototype.set`,!0),u=r(`WeakMap.prototype.has`,!0),d=r(`WeakMap.prototype.delete`,!0);t.exports=s?function(){var e,t,n={assert:function(e){if(!n.has(e))throw new o(`Side channel does not contain `+i(e))},delete:function(n){if(s&&n&&(typeof n==`object`||typeof n==`function`)){if(e)return d(e,n)}else if(a&&t)return t.delete(n);return!1},get:function(n){return s&&n&&(typeof n==`object`||typeof n==`function`)&&e?c(e,n):t&&t.get(n)},has:function(n){return s&&n&&(typeof n==`object`||typeof n==`function`)&&e?u(e,n):!!t&&t.has(n)},set:function(n,r){s&&n&&(typeof n==`object`||typeof n==`function`)?(e||=new s,l(e,n,r)):a&&(t||=a(),t.set(n,r))}};return n}:a})),On=t(((e,t)=>{var n=Q(),r=Lt(),i=Tn(),a=En(),o=Dn()||a||i;t.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new n(`Side channel does not contain `+r(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,n){e||=o(),e.set(t,n)}};return t}})),kn=t(((e,t)=>{var n=St(),r=On()(),i=Q(),a={assert:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");if(r.assert(e),!a.has(e,t))throw new i("`"+t+"` is not present on `O`")},get:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var n=r.get(e);return n&&n[`$`+t]},has:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var a=r.get(e);return!!a&&n(a,`$`+t)},set:function(e,t,n){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var a=r.get(e);a||(a={},r.set(e,a)),a[`$`+t]=n}};Object.freeze&&Object.freeze(a),t.exports=a})),An=t(((e,t)=>{var n={__proto__:null,foo:{}},r={__proto__:n}.foo===n.foo&&!(n instanceof Object);t.exports=function(){return r}})),jn=t(((e,t)=>{var n=$()(`%Object.create%`,!0),r=Q(),i=Xe(),a=zt(),o=Pt(),s=wn(),c=kn(),l=An()();t.exports=function(e){if(e!==null&&!a(e))throw new r("Assertion failed: `proto` must be null or an object");var t=arguments.length<2?[]:arguments[1];if(!o(t))throw new r("Assertion failed: `additionalInternalSlotsList` must be an Array");var u;if(l)u={__proto__:e};else if(n)u=n(e);else{if(e===null)throw new i(`native Object.create support is required to create null objects`);var d=function(){};d.prototype=e,u=new d}return t.length>0&&s(t,function(e){c.set(u,e,void 0)}),u}})),Mn=t(((e,t)=>{var n=Q(),r=zt(),i=Mt()(`RegExp.prototype.exec`),a=Ft(),o=Bt(),s=Ut();t.exports=function(e,t){if(!r(e))throw new n("Assertion failed: `R` must be an Object");if(typeof t!=`string`)throw new n("Assertion failed: `S` must be a String");var c=o(e,`exec`);if(s(c)){var l=a(c,e,[t]);if(l===null||r(l))return l;throw new n('"exec" method must return `null` or an Object')}return i(e,t)}})),Nn=t(((e,t)=>{var n=Q(),r=zt(),i=Rt(),a=vn(),o=function(){try{return delete 0,!0}catch{return!1}}();t.exports=function(e,t,s,c){if(!r(e))throw new n("Assertion failed: `O` must be an Object");if(!i(t))throw new n("Assertion failed: `P` must be a Property Key");if(typeof c!=`boolean`)throw new n("Assertion failed: `Throw` must be a Boolean");if(c){if(e[t]=s,o&&!a(e[t],s))throw new n(`Attempted to assign to readonly property.`);return!0}try{return e[t]=s,o?a(e[t],s):!0}catch{return!1}}})),Pn=t(((e,t)=>{t.exports=function(e){return e===null||typeof e!=`function`&&typeof e!=`object`}})),Fn=t(((e,t)=>{var n=Mt(),r=n(`Date.prototype.getDay`),i=function(e){try{return r(e),!0}catch{return!1}},a=n(`Object.prototype.toString`),o=`[object Date]`,s=Gt()();t.exports=function(e){return typeof e!=`object`||!e?!1:s?i(e):a(e)===o}})),In=t(((e,t)=>{var n=Mt(),r=Kt(),i=n(`RegExp.prototype.exec`),a=Q();t.exports=function(e){if(!r(e))throw new a("`regex` must be a RegExp");return function(t){return i(e,t)!==null}}})),Ln=t(((e,t)=>{var n=Mt(),r=n(`Object.prototype.toString`),i=ut()(),a=In();if(i){var o=n(`Symbol.prototype.toString`),s=a(/^Symbol\(.*\)$/),c=function(e){return typeof e.valueOf()==`symbol`?s(o(e)):!1};t.exports=function(e){if(typeof e==`symbol`)return!0;if(!e||typeof e!=`object`||r(e)!==`[object Symbol]`)return!1;try{return c(e)}catch{return!1}}}else t.exports=function(e){return!1}})),Rn=t(((e,t)=>{var n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`,r=Pn(),i=Ht(),a=Fn(),o=Ln(),s=function(e,t){if(e==null)throw TypeError(`Cannot call method on `+e);if(typeof t!=`string`||t!==`number`&&t!==`string`)throw TypeError(`hint must be "string" or "number"`);var n=t===`string`?[`toString`,`valueOf`]:[`valueOf`,`toString`],a,o,s;for(s=0;s<n.length;++s)if(a=e[n[s]],i(a)&&(o=a.call(e),r(o)))return o;throw TypeError(`No default value`)},c=function(e,t){var n=e[t];if(n!=null){if(!i(n))throw TypeError(n+` returned for property `+String(t)+` of object `+e+` is not a function`);return n}};t.exports=function(e){if(r(e))return e;var t=`default`;arguments.length>1&&(arguments[1]===String?t=`string`:arguments[1]===Number&&(t=`number`));var i;if(n&&(Symbol.toPrimitive?i=c(e,Symbol.toPrimitive):o(e)&&(i=Symbol.prototype.valueOf)),i!==void 0){var l=i.call(e,t);if(r(l))return l;throw TypeError(`unable to convert exotic object to primitive`)}return t===`default`&&(a(e)||o(e))&&(t=`string`),s(e,t===`default`?`number`:t)}})),zn=t(((e,t)=>{var n=Rn();t.exports=function(e){return arguments.length>1?n(e,arguments[1]):n(e)}})),Bn=t(((e,t)=>{var n=Xt(),r=Yt(),i=Mt()(`String.prototype.replace`),a=/^\s$/.test(`᠎`),o=a?/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/:/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/,s=a?/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/:/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/;t.exports=function(){return i(i(r(n(this)),o,``),s,``)}})),Vn=t(((e,t)=>{var n=Bn(),r=`​`,i=`᠎`;t.exports=function(){return String.prototype.trim&&r.trim()===r&&i.trim()===i&&(`_`+i).trim()===`_`+i&&(i+`_`).trim()===i+`_`?String.prototype.trim:n}})),Hn=t(((e,t)=>{var n=wt()(),r=Ct(),i=Vn();t.exports=function(){var e=i();return String.prototype.trim!==e&&(n?r(String.prototype,`trim`,e,!0):r(String.prototype,`trim`,e)),e}})),Un=t(((e,t)=>{var n=Dt(),r=jt(),i=Xt(),a=Bn(),o=Vn(),s=Hn(),c=n(o()),l=function(e){return i(e),c(e)};r(l,{getPolyfill:o,implementation:a,shim:s}),t.exports=l})),Wn=t(((e,t)=>{var n=$(),r=n(`%RegExp%`),i=Q(),a=n(`%parseInt%`),o=Mt(),s=In(),c=o(`String.prototype.slice`),l=s(/^0b[01]+$/i),u=s(/^0o[0-7]+$/i),d=s(/^[-+]0x[0-9a-f]+$/i),f=s(new r(`[`+[`…`,`​`,`￾`].join(``)+`]`,`g`)),p=Un();t.exports=function e(t){if(typeof t!=`string`)throw new i("Assertion failed: `argument` is not a String");if(l(t))return+a(c(t,2),2);if(u(t))return+a(c(t,2),8);if(f(t)||d(t))return NaN;var n=p(t);return n===t?+t:e(n)}})),Gn=t(((e,t)=>{var n=$(),r=Q(),i=n(`%Number%`),a=xn(),o=zn(),s=Wn();t.exports=function(e){var t=a(e)?e:o(e,i);if(typeof t==`symbol`)throw new r(`Cannot convert a Symbol value to a number`);if(typeof t==`bigint`)throw new r(`Conversion from 'BigInt' to 'number' is not allowed.`);return typeof t==`string`?s(t):+t}})),Kn=t(((e,t)=>{var n=$e();t.exports=function(e){return typeof e==`bigint`?e:n(e)}})),qn=t(((e,t)=>{var n=Kn(),r=Q();t.exports=function(e){if(typeof e!=`number`&&typeof e!=`bigint`)throw new r(`argument must be a Number or a BigInt`);var t=e<0?-n(-e):n(e);return t===0?0:t}})),Jn=t(((e,t)=>{var n=Gn(),r=qn(),i=it(),a=cn();t.exports=function(e){var t=n(e);return i(t)||t===0?0:a(t)?r(t):t}})),Yn=t(((e,t)=>{var n=un(),r=Jn();t.exports=function(e){var t=r(e);return t<=0?0:t>n?n:t}})),Xn=t(((e,t)=>{var n=$()(`%Object.defineProperty%`,!0),r=Gt()(),i=St(),a=Q(),o=r?Symbol.toStringTag:null;t.exports=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(r!==void 0&&typeof r!=`boolean`||s!==void 0&&typeof s!=`boolean`)throw new a("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");o&&(r||!i(e,o))&&(n?n(e,o,{configurable:!s,enumerable:!1,value:t,writable:!1}):e[o]=t)}})),Zn=t(((e,t)=>{var n=$(),r=ut()(),i=Q(),a=zt(),o=n(`%IteratorPrototype%`,!0),s=dn(),c=fn(),l=Cn(),u=Bt(),d=jn(),f=Mn(),p=Nn(),m=Yn(),h=Yt(),g=kn(),_=Xn(),v=function(e,t,n,r){if(typeof t!=`string`)throw new i("`S` must be a string");if(typeof n!=`boolean`)throw new i("`global` must be a boolean");if(typeof r!=`boolean`)throw new i("`fullUnicode` must be a boolean");g.set(this,`[[IteratingRegExp]]`,e),g.set(this,`[[IteratedString]]`,t),g.set(this,`[[Global]]`,n),g.set(this,`[[Unicode]]`,r),g.set(this,`[[Done]]`,!1)};o&&(v.prototype=d(o)),l(v.prototype,`next`,function(){var e=this;if(!a(e))throw new i(`receiver must be an object`);if(!(e instanceof v)||!g.has(e,`[[IteratingRegExp]]`)||!g.has(e,`[[IteratedString]]`)||!g.has(e,`[[Global]]`)||!g.has(e,`[[Unicode]]`)||!g.has(e,`[[Done]]`))throw new i(`"this" value must be a RegExpStringIterator instance`);if(g.get(e,`[[Done]]`))return c(void 0,!0);var t=g.get(e,`[[IteratingRegExp]]`),n=g.get(e,`[[IteratedString]]`),r=g.get(e,`[[Global]]`),o=g.get(e,`[[Unicode]]`),l=f(t,n);return l===null?(g.set(e,`[[Done]]`,!0),c(void 0,!0)):r?(h(u(l,`0`))===``&&p(t,`lastIndex`,s(n,m(u(t,`lastIndex`)),o),!0),c(l,!1)):(g.set(e,`[[Done]]`,!0),c(l,!1))},!1),r&&(_(v.prototype,`RegExp String Iterator`),Symbol.iterator&&typeof v.prototype[Symbol.iterator]!=`function`&&l(v.prototype,Symbol.iterator,function(){return this},!1)),t.exports=function(e,t,n,r){return new v(e,t,n,r)}})),Qn=t(((e,t)=>{t.exports=$()})),$n=t(((e,t)=>{var n=Qn()(`%Reflect.construct%`,!0),r=bn();try{r({},``,{"[[Get]]":function(){}})}catch{r=null}if(r&&n){var i={},a={};r(a,`length`,{"[[Get]]":function(){throw i},"[[Enumerable]]":!0}),t.exports=function(e){try{n(e,a)}catch(e){return e===i}}}else t.exports=function(e){return typeof e==`function`&&!!e.prototype}})),er=t(((e,t)=>{var n=$()(`%Symbol.species%`,!0),r=Q(),i=zt(),a=$n();t.exports=function(e,t){if(!i(e))throw new r(`Assertion failed: Type(O) is not Object`);var o=e.constructor;if(o===void 0)return t;if(!i(o))throw new r(`O.constructor is not an Object`);var s=n?o[n]:void 0;if(s==null)return t;if(a(s))return s;throw new r(`no constructor found`)}})),tr=t(((e,t)=>{var n=zt();t.exports=function(e){if(e===null)return`Null`;if(e===void 0)return`Undefined`;if(n(e))return`Object`;if(typeof e==`number`)return`Number`;if(typeof e==`boolean`)return`Boolean`;if(typeof e==`string`)return`String`}})),nr=t(((e,t)=>{var n=tr();t.exports=function(e){return typeof e==`symbol`?`Symbol`:typeof e==`bigint`?`BigInt`:n(e)}})),rr=t(((e,t)=>{var n=Zn(),r=Bt(),i=Nn(),a=er(),o=Yn(),s=Yt(),c=nr(),l=nn(),u=Qt(),d=Mt(),f=$(),p=Q(),m=d(`String.prototype.indexOf`),h=f(`%RegExp%`),g=`flags`in h.prototype,_=function(e,t){var n,i=`flags`in t?r(t,`flags`):s(l(t));return n=g&&typeof i==`string`?new e(t,i):e===h?new e(t.source,i):new e(t,i),{flags:i,matcher:n}};t.exports=u(function(e){var t=this;if(c(t)!==`Object`)throw new p(`"this" value must be an Object`);var l=s(e),u=_(a(t,h),t),d=u.flags,f=u.matcher;return i(f,`lastIndex`,o(r(t,`lastIndex`)),!0),n(f,l,m(d,`g`)>-1,m(d,`u`)>-1)},`[Symbol.matchAll]`,!0)})),ir=t(((e,t)=>{var n=ut()(),r=rr();t.exports=function(){return!n||typeof Symbol.matchAll!=`symbol`||typeof RegExp.prototype[Symbol.matchAll]!=`function`?r:RegExp.prototype[Symbol.matchAll]}})),ar=t(((e,t)=>{var n=Ft(),r=Bt(),i=Wt(),a=Jt(),o=Yt(),s=Xt(),c=Mt(),l=ut()(),u=nn(),d=$(),f=Q(),p=d(`%RegExp%`),m=c(`String.prototype.indexOf`),h=ir(),g=function(e){var t=h();if(l&&typeof Symbol.matchAll==`symbol`){var n=i(e,Symbol.matchAll);return n===p.prototype[Symbol.matchAll]&&n!==t?t:n}if(a(e))return t};t.exports=function(e){var t=s(this);if(e!=null){if(a(e)){var i=`flags`in e?r(e,`flags`):u(e);if(s(i),m(o(i),`g`)<0)throw new f(`matchAll requires a global regular expression`)}var c=g(e);if(c!==void 0)return n(c,e,[t])}var l=o(t),d=new p(e,`g`);return n(g(d),d,[l])}})),or=t(((e,t)=>{var n=ar();t.exports=function(){if(String.prototype.matchAll)try{``.matchAll(RegExp.prototype)}catch{return String.prototype.matchAll}return n}})),sr=t(((e,t)=>{var n=jt(),r=ut()(),i=st(),a=or(),o=ir(),s=Object.defineProperty;t.exports=function(){var e=a();if(n(String.prototype,{matchAll:e},{matchAll:function(){return String.prototype.matchAll!==e}}),r){var t=Symbol.matchAll||(Symbol.for?Symbol.for(`Symbol.matchAll`):Symbol(`Symbol.matchAll`));if(n(Symbol,{matchAll:t},{matchAll:function(){return Symbol.matchAll!==t}}),s&&i){var c=i(Symbol,t);(!c||c.configurable)&&s(Symbol,t,{configurable:!1,enumerable:!1,value:t,writable:!1})}var l=o(),u={};u[t]=l;var d={};d[t]=function(){return RegExp.prototype[t]!==l},n(RegExp.prototype,u,d)}return e}})),cr=t(((e,t)=>{var n=Dt(),r=jt(),i=ar(),a=or(),o=sr(),s=n(i);r(s,{getPolyfill:a,implementation:i,shim:o}),t.exports=s}));return t(((e,t)=>{y();var n=se(),r=T(),i=E(),a=O(),o=ce(),s=w(),c=k(),{TtyStream:l,hasCustomStdinListener:u}=C(),d=`/.brsh_history`,f=Se(),p=We(),m=b(),h=M(),{isAsyncFilesystemSource:g,resolveFilesystemSource:_}=q(),x=/\$(?:\{([\w\d?#@*-]+)\}|([\w\d]+|[?#@*-]))/g,S=m.EventEmitter||m.default||m;String.prototype.regexIndexOf=function(e,t){let n=this.substring(t||0).search(e);return n>=0?n+(t||0):n},cr().shim();var D=class e extends S{constructor(e){super();let{path:t=`/bin`,profile:r,motd:i,command:a,interactive:o=!0,subshell:s=!1,hostname:c=`browser`,filesystem:u={},permissions:d={},cwd:f=`/`,onFsChange:p,useRealFilesystem:m=!1,cols:h,rows:_}=e;if(this.context=new n(Object.assign({},e,{clearFn:this.clear.bind(this),destroyFn:this.destroy.bind(this),onFsChange:typeof p==`function`?p:null})),this._readonlyContext=Object.freeze({getVar:e=>this.context.getVar(e),getAlias:e=>this.context.getAlias(e),getCommand:e=>this.context.getCommand(e)}),this.context.setVar(`PATH`,t),this.context.setVar(`HOST`,c),!s){let e=(o?`i`:``)+(a?`c`:``);e&&this.context.setVar(`-`,e)}this._lastCode=0,this._subshell=s,this._useRealFilesystem=m,this._profile=r,this._motd=i,this._initialCommand=a||null,this._suppressMotd=!!a,this._loadingFs=null,this._queuedWhileLoading=!1;let v=typeof h==`number`&&h>0?Math.floor(h):80,y=typeof _==`number`&&_>0?Math.floor(_):24;if((typeof h==`number`&&h>0||typeof _==`number`&&_>0)&&(this._terminalSize={cols:v,rows:y},this.context.setVar(`COLUMNS`,String(v)),this.context.setVar(`LINES`,String(y))),this.stdinStream=new l({columns:v,rows:y}),this.stdout=new l({columns:v,rows:y,onWrite:e=>this.emit(`data`,e)}),this.stderr=new l({columns:v,rows:y,onWrite:e=>this.emit(`data`,e)}),this._lineBuffer=[],this._cursorPos=0,this._history=[],this._historyPos=null,this._savedInput=null,this._historyLoaded=!1,this._working=!0,this._promptReady=!1,this._inProgressLine=!1,this._fromLineEditor=!1,this._lastPromptRowOffset=0,this._pendingCommands=[],s||this._setupTtyStreams(),m)this.context.setNodeFilesystem(f),this.context.setCwd(f),this._loadDefaultCommands(),this._loadBuiltinCommands(!0),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0));else if(g(u)||u&&typeof u==`object`&&g(u.filesystem))this.context.setFilesystem({},d),this._loadDefaultCommands(),this._loadBuiltinCommands(!1),this._initializing=!s,this._loadingFs=this._initAsyncFilesystem(u,d,f,r),this.ready=this._loadingFs;else{this.context.setFilesystem(u,d),this.context.setCwd(f);let e=this.context.fs.exists(this.context.getVar(`PATH`));this._loadDefaultCommands(),this._loadBuiltinCommands(e),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0))}this.context.fs&&typeof this.context.fs.setTtyDevice==`function`&&this.context.fs.setTtyDevice({write:e=>this.stdout.write(e),read:()=>``})}async _initAsyncFilesystem(t,n,r){let i=this.context.getVar(`PATH`)||`/bin`,a=()=>{try{let e=this.context.fs.getRaw(),t=i.replace(/^\/+|\/+$/g,``).split(`/`).filter(Boolean),n=e;for(let e of t)n&&=n[e];return n&&typeof n==`object`?Object.assign({},n):{}}catch{return{}}},o=a();try{let e=await _(t,n),s=a(),c=[];for(let[e,t]of Object.entries(s))o[e]!==t&&typeof t==`function`&&c.push(t);let l=this.context._onFsChange;this.context._onFsChange=null,this.context.setFilesystem(e.filesystem,e.permissions);let u=this.context.fs.exists(i);this._loadDefaultCommands(),this._loadBuiltinCommands(u);for(let e of c)this.context.setCommand(e);this.context.setCwd(r),this.context._onFsChange=l,l&&this.context.fs&&(this.context.fs._onChange=()=>l(this.context.fs.getRaw(),this.context.fs.getRawPermissions())),this.context.fs&&typeof this.context.fs.setTtyDevice==`function`&&this.context.fs.setTtyDevice({write:e=>this.stdout.write(e),read:()=>``})}catch(e){this.emit(`stdErr`,e.message||String(e))}finally{this._loadingFs=null}return this._subshell?(this._initializing=!1,!this._queuedWhileLoading&&!this.destroyed&&this.emit(`status`,e.STATUS_READY)):await this._init(),this}get path(){return this.context.getVar(`PATH`)}set lastCode(e){this.context.setVar(`?`,String(e)),this._lastCode=e}get lastCode(){return this._lastCode}get stdin(){return this._stdin===void 0?this.stdinStream:this._stdin}set stdin(e){this._stdin=e}write(e){return this.stdinStream.pushData(e),!0}resize(e,t){this.setTerminalSize(e,t)}onInput(e){if(this.runningCommand){let t=this.runningCommand;if((e===`^C`||e===``)&&!(t.isRaw||t.stdinStream&&t.stdinStream.isRaw)){let e=!!(t.interactive||t._inAltScreen);return typeof t.kill==`function`&&t.kill(`SIGINT`),e||this.stdout.write(`^C\r
35
+ `+t.prev}function be(e,t){var n=z(e),r=[];if(n){r.length=e.length;for(var i=0;i<e.length;i++)r[i]=K(e,i)?t(e[i],e):``}var a=typeof D==`function`?D(e):[],o;if(k){o={};for(var s=0;s<a.length;s++)o[`$`+a[s]]=a[s]}for(var c in e)K(e,c)&&(n&&String(Number(c))===c&&c<e.length||k&&o[`$`+c]instanceof Symbol||(x.call(/[^\w$]/,c)?r.push(t(c,e)+`: `+t(e[c],e)):r.push(c+`: `+t(e[c],e))));if(typeof D==`function`)for(var l=0;l<a.length;l++)j.call(e,a[l])&&r.push(`[`+t(a[l])+`]: `+t(e[a[l]],e));return r}})),Vt=t(((e,t)=>{t.exports=function(e){return typeof e==`string`||typeof e==`symbol`}})),Ht=t(((e,t)=>{t.exports=function(e){return!!e&&(typeof e==`function`||typeof e==`object`)}})),Ut=t(((e,t)=>{var n=Q(),r=Bt(),i=Vt(),a=Ht();t.exports=function(e,t){if(!a(e))throw new n(`Assertion failed: Type(O) is not Object`);if(!i(t))throw new n(`Assertion failed: P is not a Property Key, got `+r(t));return e[t]}})),Wt=t(((e,t)=>{var n=Q(),r=Bt(),i=Vt();t.exports=function(e,t){if(!i(t))throw new n(`Assertion failed: P is not a Property Key, got `+r(t));return e[t]}})),Gt=t(((e,t)=>{var n=Function.prototype.toString,r=typeof Reflect==`object`&&Reflect!==null&&Reflect.apply,i,a;if(typeof r==`function`&&typeof Object.defineProperty==`function`)try{i=Object.defineProperty({},"length",{get:function(){throw a}}),a={},r(function(){throw 42},null,i)}catch(e){e!==a&&(r=null)}else r=null;var o=/^\s*class\b/,s=function(e){try{var t=n.call(e);return o.test(t)}catch{return!1}},c=function(e){try{return s(e)?!1:(n.call(e),!0)}catch{return!1}},l=Object.prototype.toString,u=`[object Object]`,d=`[object Function]`,f=`[object GeneratorFunction]`,p=`[object HTMLAllCollection]`,m=`[object HTML document.all class]`,h=`[object HTMLCollection]`,g=typeof Symbol==`function`&&!!Symbol.toStringTag,_=!(0 in[,]),v=function(){return!1};if(typeof document==`object`){var y=document.all;l.call(y)===l.call(document.all)&&(v=function(e){if((_||!e)&&(e===void 0||typeof e==`object`))try{var t=l.call(e);return(t===p||t===m||t===h||t===u)&&e(``)==null}catch{}return!1})}t.exports=r?function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;try{r(e,null,i)}catch(e){if(e!==a)return!1}return!s(e)&&c(e)}:function(e){if(v(e))return!0;if(!e||typeof e!=`function`&&typeof e!=`object`)return!1;if(g)return c(e);if(s(e))return!1;var t=l.call(e);return t!==d&&t!==f&&!/^\[object HTML/.test(t)?!1:c(e)}})),Kt=t(((e,t)=>{t.exports=Gt()})),qt=t(((e,t)=>{var n=Q(),r=Wt(),i=Kt(),a=Vt(),o=Bt();t.exports=function(e,t){if(!a(t))throw new n(`Assertion failed: P is not a Property Key`);var s=r(e,t);if(s!=null){if(!i(s))throw new n(o(t)+` is not a function: `+o(s));return s}}})),Jt=t(((e,t)=>{var n=ft();t.exports=function(){return n()&&!!Symbol.toStringTag}})),Yt=t(((e,t)=>{var n=Ft(),r=Jt()(),i=Tt(),a=ut(),o;if(r){var s=n(`RegExp.prototype.exec`),c={},l=function(){throw c},u={toString:l,valueOf:l};typeof Symbol.toPrimitive==`symbol`&&(u[Symbol.toPrimitive]=l),o=function(e){if(!e||typeof e!=`object`)return!1;var t=a(e,`lastIndex`);if(!(t&&i(t,`value`)))return!1;try{s(e,u)}catch(e){return e===c}}}else{var d=n(`Object.prototype.toString`),f=`[object RegExp]`;o=function(e){return!e||typeof e!=`object`&&typeof e!=`function`?!1:d(e)===f}}t.exports=o})),Xt=t(((e,t)=>{t.exports=function(e){return!!e}})),Zt=t(((e,t)=>{var n=$()(`%Symbol.match%`,!0),r=Yt(),i=Ht(),a=Xt();t.exports=function(e){if(!i(e))return!1;if(n){var t=e[n];if(t!==void 0)return a(t)}return r(e)}})),Qt=t(((e,t)=>{var n=$()(`%String%`),r=Q();t.exports=function(e){if(typeof e==`symbol`)throw new r(`Cannot convert a Symbol value to a string`);return n(e)}})),$t=t(((e,t)=>{var n=Q();t.exports=function(e){if(e==null)throw new n(arguments.length>0&&arguments[1]||`Cannot call method on `+e);return e}})),en=t(((e,t)=>{var n=function(){return typeof function(){}.name==`string`},r=Object.getOwnPropertyDescriptor;if(r)try{r([],`length`)}catch{r=null}n.functionsHaveConfigurableNames=function(){if(!n()||!r)return!1;var e=r(function(){},`name`);return!!e&&!!e.configurable};var i=Function.prototype.bind;n.boundFunctionsHaveNames=function(){return n()&&typeof i==`function`&&function(){}.bind().name!==``},t.exports=n})),tn=t(((e,t)=>{var n=Et(),r=Dt()(),i=en().functionsHaveConfigurableNames(),a=Q();t.exports=function(e,t){if(typeof e!=`function`)throw new a("`fn` is not a function");return(!(arguments.length>2&&arguments[2])||i)&&(r?n(e,`name`,t,!0,!0):n(e,`name`,t)),e}})),nn=t(((e,t)=>{var n=tn(),r=Q(),i=Object;t.exports=n(function(){if(this==null||this!==i(this))throw new r(`RegExp.prototype.flags getter called on non-object`);var e=``;return this.hasIndices&&(e+=`d`),this.global&&(e+=`g`),this.ignoreCase&&(e+=`i`),this.multiline&&(e+=`m`),this.dotAll&&(e+=`s`),this.unicode&&(e+=`u`),this.unicodeSets&&(e+=`v`),this.sticky&&(e+=`y`),e},`get flags`,!0)})),rn=t(((e,t)=>{var n=nn(),r=Pt().supportsDescriptors,i=Object.getOwnPropertyDescriptor;t.exports=function(){if(r&&/a/gim.flags===`gim`){var e=i(RegExp.prototype,`flags`);if(e&&typeof e.get==`function`&&`dotAll`in RegExp.prototype&&`hasIndices`in RegExp.prototype){var t=``,a={};if(Object.defineProperty(a,"hasIndices",{get:function(){t+=`d`}}),Object.defineProperty(a,"sticky",{get:function(){t+=`y`}}),e.get.call(a),t===`dy`)return e.get}}return n}})),an=t(((e,t)=>{var n=Pt().supportsDescriptors,r=rn(),i=ut(),a=Object.defineProperty,o=Ye(),s=wt(),c=/a/;t.exports=function(){if(!n||!s)throw new o(`RegExp.prototype.flags requires a true ES5 environment that supports property descriptors`);var e=r(),t=s(c),l=i(t,`flags`);return(!l||l.get!==e)&&a(t,`flags`,{configurable:!0,enumerable:!1,get:e}),e}})),on=t(((e,t)=>{var n=Pt(),r=At(),i=nn(),a=rn(),o=an(),s=r(a());n(s,{getPolyfill:a,implementation:i,shim:o}),t.exports=s})),sn=t(((e,t)=>{t.exports=function(e){return typeof e==`number`&&e>=55296&&e<=56319}})),cn=t(((e,t)=>{t.exports=function(e){return typeof e==`number`&&e>=56320&&e<=57343}})),ln=t(((e,t)=>{var n=$(),r=Q(),i=n(`%String.fromCharCode%`),a=sn(),o=cn();t.exports=function(e,t){if(!a(e)||!o(t))throw new r("Assertion failed: `lead` must be a leading surrogate char code, and `trail` must be a trailing surrogate char code");return i(e)+i(t)}})),un=t(((e,t)=>{var n=Q(),r=Ft(),i=sn(),a=cn(),o=ln(),s=r(`String.prototype.charAt`),c=r(`String.prototype.charCodeAt`);t.exports=function(e,t){if(typeof e!=`string`)throw new n("Assertion failed: `string` must be a String");var r=e.length;if(t<0||t>=r)throw new n("Assertion failed: `position` must be >= 0, and < the length of `string`");var l=c(e,t),u=s(e,t),d=i(l),f=a(l);if(!d&&!f)return{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!1};if(f||t+1===r)return{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!0};var p=c(e,t+1);return a(p)?{"[[CodePoint]]":o(l,p),"[[CodeUnitCount]]":2,"[[IsUnpairedSurrogate]]":!1}:{"[[CodePoint]]":u,"[[CodeUnitCount]]":1,"[[IsUnpairedSurrogate]]":!0}}})),dn=t(((e,t)=>{var n=st();t.exports=function(e){return(typeof e==`number`||typeof e==`bigint`)&&!n(e)&&e!==1/0&&e!==-1/0}})),fn=t(((e,t)=>{var n=tt(),r=nt(),i=st(),a=dn();t.exports=function(e){if(typeof e!=`number`||i(e)||!a(e))return!1;var t=n(e);return r(t)===t}})),pn=t(((e,t)=>{t.exports=2**53-1||9007199254740991})),mn=t(((e,t)=>{var n=un(),r=Q(),i=fn(),a=pn();t.exports=function(e,t,o){if(typeof e!=`string`)throw new r("Assertion failed: `S` must be a String");if(!i(t)||t<0||t>a)throw new r("Assertion failed: `length` must be an integer >= 0 and <= 2**53");if(typeof o!=`boolean`)throw new r("Assertion failed: `unicode` must be a Boolean");if(!o)return t+1;var s=e.length;return t+1>=s?t+1:t+n(e,t)[`[[CodeUnitCount]]`]}})),hn=t(((e,t)=>{var n=Q();t.exports=function(e,t){if(typeof t!=`boolean`)throw new n(`Assertion failed: Type(done) is not Boolean`);return{value:e,done:t}}})),gn=t(((e,t)=>{var n=Q(),r=Tt(),i={__proto__:null,"[[Configurable]]":!0,"[[Enumerable]]":!0,"[[Get]]":!0,"[[Set]]":!0,"[[Value]]":!0,"[[Writable]]":!0};t.exports=function(e){if(!e||typeof e!=`object`)return!1;for(var t in e)if(r(e,t)&&!i[t])return!1;var a=r(e,`[[Value]]`)||r(e,`[[Writable]]`),o=r(e,`[[Get]]`)||r(e,`[[Set]]`);if(a&&o)throw new n(`Property Descriptors may not be both accessor and data descriptors`);return!0}})),_n=t(((e,t)=>{var n=Dt(),r=dt(),i=n.hasArrayLengthDefineBug(),a=i&&It(),o=Ft()(`Object.prototype.propertyIsEnumerable`);t.exports=function(e,t,n,s,c,l){if(!r){if(!e(l)||!l[`[[Configurable]]`]||!l[`[[Writable]]`]||c in s&&o(s,c)!==!!l[`[[Enumerable]]`])return!1;var u=l[`[[Value]]`];return s[c]=u,t(s[c],u)}return i&&c===`length`&&`[[Value]]`in l&&a(s)&&s.length!==l[`[[Value]]`]?(s.length=l[`[[Value]]`],s.length===l[`[[Value]]`]):(r(s,c,n(l)),!0)}})),vn=t(((e,t)=>{t.exports=function(e){if(e===void 0)return e;var t={};return`[[Value]]`in e&&(t.value=e[`[[Value]]`]),`[[Writable]]`in e&&(t.writable=!!e[`[[Writable]]`]),`[[Get]]`in e&&(t.get=e[`[[Get]]`]),`[[Set]]`in e&&(t.set=e[`[[Set]]`]),`[[Enumerable]]`in e&&(t.enumerable=!!e[`[[Enumerable]]`]),`[[Configurable]]`in e&&(t.configurable=!!e[`[[Configurable]]`]),t}})),yn=t(((e,t)=>{var n=Q(),r=gn(),i=vn();t.exports=function(e){if(e!==void 0&&!r(e))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return i(e)}})),bn=t(((e,t)=>{var n=Q(),r=Tt(),i=gn();t.exports=function(e){if(e===void 0)return!1;if(!i(e))throw new n("Assertion failed: `Desc` must be a Property Descriptor");return!(!r(e,`[[Value]]`)&&!r(e,`[[Writable]]`))}})),xn=t(((e,t)=>{var n=st();t.exports=function(e,t){return e===t?e===0?1/e==1/t:!0:n(e)&&n(t)}})),Sn=t(((e,t)=>{var n=Tt(),r=Q(),i=Ht(),a=Kt(),o=Xt();t.exports=function(e){if(!i(e))throw new r(`ToPropertyDescriptor requires an object`);var t={};if(n(e,`enumerable`)&&(t[`[[Enumerable]]`]=o(e.enumerable)),n(e,`configurable`)&&(t[`[[Configurable]]`]=o(e.configurable)),n(e,`value`)&&(t[`[[Value]]`]=e.value),n(e,`writable`)&&(t[`[[Writable]]`]=o(e.writable)),n(e,`get`)){var s=e.get;if(s!==void 0&&!a(s))throw new r(`getter must be a function`);t[`[[Get]]`]=s}if(n(e,`set`)){var c=e.set;if(c!==void 0&&!a(c))throw new r(`setter must be a function`);t[`[[Set]]`]=c}if((n(t,`[[Get]]`)||n(t,`[[Set]]`))&&(n(t,`[[Value]]`)||n(t,`[[Writable]]`)))throw new r(`Invalid property descriptor. Cannot both specify accessors and a value or writable attribute`);return t}})),Cn=t(((e,t)=>{var n=Q(),r=Ht(),i=gn(),a=_n(),o=yn(),s=bn(),c=Vt(),l=xn(),u=Sn();t.exports=function(e,t,d){if(!r(e))throw new n(`Assertion failed: Type(O) is not Object`);if(!c(t))throw new n(`Assertion failed: P is not a Property Key`);var f=i(d)?d:u(d);if(!i(f))throw new n(`Assertion failed: Desc is not a valid Property Descriptor`);return a(s,l,o,e,t,f)}})),wn=t(((e,t)=>{t.exports=function(e){return e===null||typeof e!=`function`&&typeof e!=`object`}})),Tn=t(((e,t)=>{var n=$(),r=n(`%Object.preventExtensions%`,!0),i=n(`%Object.isExtensible%`,!0),a=wn();t.exports=r?function(e){return!a(e)&&i(e)}:function(e){return!a(e)}})),En=t(((e,t)=>{var n=Q(),r=Ht(),i=Cn(),a=Tn(),o=Vt();t.exports=function(e,t,s,c){if(!r(e))throw new n("Assertion failed: `homeObject` is not an Object");if(!o(t))throw new n("Assertion failed: `key` is not a Property Key or a Private Name");if(typeof s!=`function`)throw new n("Assertion failed: `closure` is not a function");if(typeof c!=`boolean`)throw new n("Assertion failed: `enumerable` is not a Boolean");if(!a(e))throw new n("Assertion failed: `homeObject` is not an ordinary, extensible object, with no non-configurable properties");i(e,t,{"[[Value]]":s,"[[Writable]]":!0,"[[Enumerable]]":c,"[[Configurable]]":!0})}})),Dn=t(((e,t)=>{t.exports=function(e,t){for(var n=0;n<e.length;n+=1)t(e[n],n,e)}})),On=t(((e,t)=>{var n=Bt(),r=Q(),i=function(e,t,n){for(var r=e,i;(i=r.next)!=null;r=i)if(i.key===t)return r.next=i.next,n||(i.next=e.next,e.next=i),i},a=function(e,t){if(e){var n=i(e,t);return n&&n.value}},o=function(e,t,n){var r=i(e,t);r?r.value=n:e.next={key:t,next:e.next,value:n}},s=function(e,t){return e?!!i(e,t):!1},c=function(e,t){if(e)return i(e,t,!0)};t.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new r(`Side channel does not contain `+n(e))},delete:function(t){var n=c(e,t);return n&&e&&!e.next&&(e=void 0),!!n},get:function(t){return a(e,t)},has:function(t){return s(e,t)},set:function(t,n){e||={next:void 0},o(e,t,n)}};return t}})),kn=t(((e,t)=>{var n=$(),r=Ft(),i=Bt(),a=Q(),o=n(`%Map%`,!0),s=r(`Map.prototype.get`,!0),c=r(`Map.prototype.set`,!0),l=r(`Map.prototype.has`,!0),u=r(`Map.prototype.delete`,!0),d=r(`Map.prototype.size`,!0);t.exports=!!o&&function(){var e,t={assert:function(e){if(!t.has(e))throw new a(`Side channel does not contain `+i(e))},delete:function(t){if(e){var n=u(e,t);return d(e)===0&&(e=void 0),n}return!1},get:function(t){if(e)return s(e,t)},has:function(t){return e?l(e,t):!1},set:function(t,n){e||=new o,c(e,t,n)}};return t}})),An=t(((e,t)=>{var n=$(),r=Ft(),i=Bt(),a=kn(),o=Q(),s=n(`%WeakMap%`,!0),c=r(`WeakMap.prototype.get`,!0),l=r(`WeakMap.prototype.set`,!0),u=r(`WeakMap.prototype.has`,!0),d=r(`WeakMap.prototype.delete`,!0);t.exports=s?function(){var e,t,n={assert:function(e){if(!n.has(e))throw new o(`Side channel does not contain `+i(e))},delete:function(n){if(s&&n&&(typeof n==`object`||typeof n==`function`)){if(e)return d(e,n)}else if(a&&t)return t.delete(n);return!1},get:function(n){return s&&n&&(typeof n==`object`||typeof n==`function`)&&e?c(e,n):t&&t.get(n)},has:function(n){return s&&n&&(typeof n==`object`||typeof n==`function`)&&e?u(e,n):!!t&&t.has(n)},set:function(n,r){s&&n&&(typeof n==`object`||typeof n==`function`)?(e||=new s,l(e,n,r)):a&&(t||=a(),t.set(n,r))}};return n}:a})),jn=t(((e,t)=>{var n=Q(),r=Bt(),i=On(),a=kn(),o=An()||a||i;t.exports=function(){var e,t={assert:function(e){if(!t.has(e))throw new n(`Side channel does not contain `+r(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,n){e||=o(),e.set(t,n)}};return t}})),Mn=t(((e,t)=>{var n=Tt(),r=jn()(),i=Q(),a={assert:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");if(r.assert(e),!a.has(e,t))throw new i("`"+t+"` is not present on `O`")},get:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var n=r.get(e);return n&&n[`$`+t]},has:function(e,t){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var a=r.get(e);return!!a&&n(a,`$`+t)},set:function(e,t,n){if(!e||typeof e!=`object`&&typeof e!=`function`)throw new i("`O` is not an object");if(typeof t!=`string`)throw new i("`slot` must be a string");var a=r.get(e);a||(a={},r.set(e,a)),a[`$`+t]=n}};Object.freeze&&Object.freeze(a),t.exports=a})),Nn=t(((e,t)=>{var n={__proto__:null,foo:{}},r={__proto__:n}.foo===n.foo&&!(n instanceof Object);t.exports=function(){return r}})),Pn=t(((e,t)=>{var n=$()(`%Object.create%`,!0),r=Q(),i=$e(),a=Ht(),o=Lt(),s=Dn(),c=Mn(),l=Nn()();t.exports=function(e){if(e!==null&&!a(e))throw new r("Assertion failed: `proto` must be null or an object");var t=arguments.length<2?[]:arguments[1];if(!o(t))throw new r("Assertion failed: `additionalInternalSlotsList` must be an Array");var u;if(l)u={__proto__:e};else if(n)u=n(e);else{if(e===null)throw new i(`native Object.create support is required to create null objects`);var d=function(){};d.prototype=e,u=new d}return t.length>0&&s(t,function(e){c.set(u,e,void 0)}),u}})),Fn=t(((e,t)=>{var n=Q(),r=Ht(),i=Ft()(`RegExp.prototype.exec`),a=Rt(),o=Ut(),s=Kt();t.exports=function(e,t){if(!r(e))throw new n("Assertion failed: `R` must be an Object");if(typeof t!=`string`)throw new n("Assertion failed: `S` must be a String");var c=o(e,`exec`);if(s(c)){var l=a(c,e,[t]);if(l===null||r(l))return l;throw new n('"exec" method must return `null` or an Object')}return i(e,t)}})),In=t(((e,t)=>{var n=Q(),r=Ht(),i=Vt(),a=xn(),o=function(){try{return delete 0,!0}catch{return!1}}();t.exports=function(e,t,s,c){if(!r(e))throw new n("Assertion failed: `O` must be an Object");if(!i(t))throw new n("Assertion failed: `P` must be a Property Key");if(typeof c!=`boolean`)throw new n("Assertion failed: `Throw` must be a Boolean");if(c){if(e[t]=s,o&&!a(e[t],s))throw new n(`Attempted to assign to readonly property.`);return!0}try{return e[t]=s,o?a(e[t],s):!0}catch{return!1}}})),Ln=t(((e,t)=>{t.exports=function(e){return e===null||typeof e!=`function`&&typeof e!=`object`}})),Rn=t(((e,t)=>{var n=Ft(),r=n(`Date.prototype.getDay`),i=function(e){try{return r(e),!0}catch{return!1}},a=n(`Object.prototype.toString`),o=`[object Date]`,s=Jt()();t.exports=function(e){return typeof e!=`object`||!e?!1:s?i(e):a(e)===o}})),zn=t(((e,t)=>{var n=Ft(),r=Yt(),i=n(`RegExp.prototype.exec`),a=Q();t.exports=function(e){if(!r(e))throw new a("`regex` must be a RegExp");return function(t){return i(e,t)!==null}}})),Bn=t(((e,t)=>{var n=Ft(),r=n(`Object.prototype.toString`),i=pt()(),a=zn();if(i){var o=n(`Symbol.prototype.toString`),s=a(/^Symbol\(.*\)$/),c=function(e){return typeof e.valueOf()==`symbol`?s(o(e)):!1};t.exports=function(e){if(typeof e==`symbol`)return!0;if(!e||typeof e!=`object`||r(e)!==`[object Symbol]`)return!1;try{return c(e)}catch{return!1}}}else t.exports=function(e){return!1}})),Vn=t(((e,t)=>{var n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`,r=Ln(),i=Gt(),a=Rn(),o=Bn(),s=function(e,t){if(e==null)throw TypeError(`Cannot call method on `+e);if(typeof t!=`string`||t!==`number`&&t!==`string`)throw TypeError(`hint must be "string" or "number"`);var n=t===`string`?[`toString`,`valueOf`]:[`valueOf`,`toString`],a,o,s;for(s=0;s<n.length;++s)if(a=e[n[s]],i(a)&&(o=a.call(e),r(o)))return o;throw TypeError(`No default value`)},c=function(e,t){var n=e[t];if(n!=null){if(!i(n))throw TypeError(n+` returned for property `+String(t)+` of object `+e+` is not a function`);return n}};t.exports=function(e){if(r(e))return e;var t=`default`;arguments.length>1&&(arguments[1]===String?t=`string`:arguments[1]===Number&&(t=`number`));var i;if(n&&(Symbol.toPrimitive?i=c(e,Symbol.toPrimitive):o(e)&&(i=Symbol.prototype.valueOf)),i!==void 0){var l=i.call(e,t);if(r(l))return l;throw TypeError(`unable to convert exotic object to primitive`)}return t===`default`&&(a(e)||o(e))&&(t=`string`),s(e,t===`default`?`number`:t)}})),Hn=t(((e,t)=>{var n=Vn();t.exports=function(e){return arguments.length>1?n(e,arguments[1]):n(e)}})),Un=t(((e,t)=>{var n=$t(),r=Qt(),i=Ft()(`String.prototype.replace`),a=/^\s$/.test(`᠎`),o=a?/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/:/^[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+/,s=a?/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/:/[\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF]+$/;t.exports=function(){return i(i(r(n(this)),o,``),s,``)}})),Wn=t(((e,t)=>{var n=Un(),r=`​`,i=`᠎`;t.exports=function(){return String.prototype.trim&&r.trim()===r&&i.trim()===i&&(`_`+i).trim()===`_`+i&&(i+`_`).trim()===i+`_`?String.prototype.trim:n}})),Gn=t(((e,t)=>{var n=Dt()(),r=Et(),i=Wn();t.exports=function(){var e=i();return String.prototype.trim!==e&&(n?r(String.prototype,`trim`,e,!0):r(String.prototype,`trim`,e)),e}})),Kn=t(((e,t)=>{var n=At(),r=Pt(),i=$t(),a=Un(),o=Wn(),s=Gn(),c=n(o()),l=function(e){return i(e),c(e)};r(l,{getPolyfill:o,implementation:a,shim:s}),t.exports=l})),qn=t(((e,t)=>{var n=$(),r=n(`%RegExp%`),i=Q(),a=n(`%parseInt%`),o=Ft(),s=zn(),c=o(`String.prototype.slice`),l=s(/^0b[01]+$/i),u=s(/^0o[0-7]+$/i),d=s(/^[-+]0x[0-9a-f]+$/i),f=s(new r(`[`+[`…`,`​`,`￾`].join(``)+`]`,`g`)),p=Kn();t.exports=function e(t){if(typeof t!=`string`)throw new i("Assertion failed: `argument` is not a String");if(l(t))return+a(c(t,2),2);if(u(t))return+a(c(t,2),8);if(f(t)||d(t))return NaN;var n=p(t);return n===t?+t:e(n)}})),Jn=t(((e,t)=>{var n=$(),r=Q(),i=n(`%Number%`),a=wn(),o=Hn(),s=qn();t.exports=function(e){var t=a(e)?e:o(e,i);if(typeof t==`symbol`)throw new r(`Cannot convert a Symbol value to a number`);if(typeof t==`bigint`)throw new r(`Conversion from 'BigInt' to 'number' is not allowed.`);return typeof t==`string`?s(t):+t}})),Yn=t(((e,t)=>{var n=nt();t.exports=function(e){return typeof e==`bigint`?e:n(e)}})),Xn=t(((e,t)=>{var n=Yn(),r=Q();t.exports=function(e){if(typeof e!=`number`&&typeof e!=`bigint`)throw new r(`argument must be a Number or a BigInt`);var t=e<0?-n(-e):n(e);return t===0?0:t}})),Zn=t(((e,t)=>{var n=Jn(),r=Xn(),i=st(),a=dn();t.exports=function(e){var t=n(e);return i(t)||t===0?0:a(t)?r(t):t}})),Qn=t(((e,t)=>{var n=pn(),r=Zn();t.exports=function(e){var t=r(e);return t<=0?0:t>n?n:t}})),$n=t(((e,t)=>{var n=$()(`%Object.defineProperty%`,!0),r=Jt()(),i=Tt(),a=Q(),o=r?Symbol.toStringTag:null;t.exports=function(e,t){var r=arguments.length>2&&!!arguments[2]&&arguments[2].force,s=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(r!==void 0&&typeof r!=`boolean`||s!==void 0&&typeof s!=`boolean`)throw new a("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");o&&(r||!i(e,o))&&(n?n(e,o,{configurable:!s,enumerable:!1,value:t,writable:!1}):e[o]=t)}})),er=t(((e,t)=>{var n=$(),r=pt()(),i=Q(),a=Ht(),o=n(`%IteratorPrototype%`,!0),s=mn(),c=hn(),l=En(),u=Ut(),d=Pn(),f=Fn(),p=In(),m=Qn(),h=Qt(),g=Mn(),_=$n(),v=function(e,t,n,r){if(typeof t!=`string`)throw new i("`S` must be a string");if(typeof n!=`boolean`)throw new i("`global` must be a boolean");if(typeof r!=`boolean`)throw new i("`fullUnicode` must be a boolean");g.set(this,`[[IteratingRegExp]]`,e),g.set(this,`[[IteratedString]]`,t),g.set(this,`[[Global]]`,n),g.set(this,`[[Unicode]]`,r),g.set(this,`[[Done]]`,!1)};o&&(v.prototype=d(o)),l(v.prototype,`next`,function(){var e=this;if(!a(e))throw new i(`receiver must be an object`);if(!(e instanceof v)||!g.has(e,`[[IteratingRegExp]]`)||!g.has(e,`[[IteratedString]]`)||!g.has(e,`[[Global]]`)||!g.has(e,`[[Unicode]]`)||!g.has(e,`[[Done]]`))throw new i(`"this" value must be a RegExpStringIterator instance`);if(g.get(e,`[[Done]]`))return c(void 0,!0);var t=g.get(e,`[[IteratingRegExp]]`),n=g.get(e,`[[IteratedString]]`),r=g.get(e,`[[Global]]`),o=g.get(e,`[[Unicode]]`),l=f(t,n);return l===null?(g.set(e,`[[Done]]`,!0),c(void 0,!0)):r?(h(u(l,`0`))===``&&p(t,`lastIndex`,s(n,m(u(t,`lastIndex`)),o),!0),c(l,!1)):(g.set(e,`[[Done]]`,!0),c(l,!1))},!1),r&&(_(v.prototype,`RegExp String Iterator`),Symbol.iterator&&typeof v.prototype[Symbol.iterator]!=`function`&&l(v.prototype,Symbol.iterator,function(){return this},!1)),t.exports=function(e,t,n,r){return new v(e,t,n,r)}})),tr=t(((e,t)=>{t.exports=$()})),nr=t(((e,t)=>{var n=tr()(`%Reflect.construct%`,!0),r=Cn();try{r({},``,{"[[Get]]":function(){}})}catch{r=null}if(r&&n){var i={},a={};r(a,`length`,{"[[Get]]":function(){throw i},"[[Enumerable]]":!0}),t.exports=function(e){try{n(e,a)}catch(e){return e===i}}}else t.exports=function(e){return typeof e==`function`&&!!e.prototype}})),rr=t(((e,t)=>{var n=$()(`%Symbol.species%`,!0),r=Q(),i=Ht(),a=nr();t.exports=function(e,t){if(!i(e))throw new r(`Assertion failed: Type(O) is not Object`);var o=e.constructor;if(o===void 0)return t;if(!i(o))throw new r(`O.constructor is not an Object`);var s=n?o[n]:void 0;if(s==null)return t;if(a(s))return s;throw new r(`no constructor found`)}})),ir=t(((e,t)=>{var n=Ht();t.exports=function(e){if(e===null)return`Null`;if(e===void 0)return`Undefined`;if(n(e))return`Object`;if(typeof e==`number`)return`Number`;if(typeof e==`boolean`)return`Boolean`;if(typeof e==`string`)return`String`}})),ar=t(((e,t)=>{var n=ir();t.exports=function(e){return typeof e==`symbol`?`Symbol`:typeof e==`bigint`?`BigInt`:n(e)}})),or=t(((e,t)=>{var n=er(),r=Ut(),i=In(),a=rr(),o=Qn(),s=Qt(),c=ar(),l=on(),u=tn(),d=Ft(),f=$(),p=Q(),m=d(`String.prototype.indexOf`),h=f(`%RegExp%`),g=`flags`in h.prototype,_=function(e,t){var n,i=`flags`in t?r(t,`flags`):s(l(t));return n=g&&typeof i==`string`?new e(t,i):e===h?new e(t.source,i):new e(t,i),{flags:i,matcher:n}};t.exports=u(function(e){var t=this;if(c(t)!==`Object`)throw new p(`"this" value must be an Object`);var l=s(e),u=_(a(t,h),t),d=u.flags,f=u.matcher;return i(f,`lastIndex`,o(r(t,`lastIndex`)),!0),n(f,l,m(d,`g`)>-1,m(d,`u`)>-1)},`[Symbol.matchAll]`,!0)})),sr=t(((e,t)=>{var n=pt()(),r=or();t.exports=function(){return!n||typeof Symbol.matchAll!=`symbol`||typeof RegExp.prototype[Symbol.matchAll]!=`function`?r:RegExp.prototype[Symbol.matchAll]}})),cr=t(((e,t)=>{var n=Rt(),r=Ut(),i=qt(),a=Zt(),o=Qt(),s=$t(),c=Ft(),l=pt()(),u=on(),d=$(),f=Q(),p=d(`%RegExp%`),m=c(`String.prototype.indexOf`),h=sr(),g=function(e){var t=h();if(l&&typeof Symbol.matchAll==`symbol`){var n=i(e,Symbol.matchAll);return n===p.prototype[Symbol.matchAll]&&n!==t?t:n}if(a(e))return t};t.exports=function(e){var t=s(this);if(e!=null){if(a(e)){var i=`flags`in e?r(e,`flags`):u(e);if(s(i),m(o(i),`g`)<0)throw new f(`matchAll requires a global regular expression`)}var c=g(e);if(c!==void 0)return n(c,e,[t])}var l=o(t),d=new p(e,`g`);return n(g(d),d,[l])}})),lr=t(((e,t)=>{var n=cr();t.exports=function(){if(String.prototype.matchAll)try{``.matchAll(RegExp.prototype)}catch{return String.prototype.matchAll}return n}})),ur=t(((e,t)=>{var n=Pt(),r=pt()(),i=ut(),a=lr(),o=sr(),s=Object.defineProperty;t.exports=function(){var e=a();if(n(String.prototype,{matchAll:e},{matchAll:function(){return String.prototype.matchAll!==e}}),r){var t=Symbol.matchAll||(Symbol.for?Symbol.for(`Symbol.matchAll`):Symbol(`Symbol.matchAll`));if(n(Symbol,{matchAll:t},{matchAll:function(){return Symbol.matchAll!==t}}),s&&i){var c=i(Symbol,t);(!c||c.configurable)&&s(Symbol,t,{configurable:!1,enumerable:!1,value:t,writable:!1})}var l=o(),u={};u[t]=l;var d={};d[t]=function(){return RegExp.prototype[t]!==l},n(RegExp.prototype,u,d)}return e}})),dr=t(((e,t)=>{var n=At(),r=Pt(),i=cr(),a=lr(),o=ur(),s=n(i);r(s,{getPolyfill:a,implementation:i,shim:o}),t.exports=s}));return t(((e,t)=>{y();var n=se(),r=T(),i=E(),a=O(),o=ce(),s=w(),c=k(),{TtyStream:l,hasCustomStdinListener:u}=C(),d=`/.brsh_history`,f=Te(),p=qe(),m=b(),h=M(),{isAsyncFilesystemSource:g,resolveFilesystemSource:_}=q(),x=m.EventEmitter||m.default||m;String.prototype.regexIndexOf=function(e,t){let n=this.substring(t||0).search(e);return n>=0?n+(t||0):n},dr().shim();var S=`\0`,D=class e extends x{constructor(e){super();let{path:t=`/bin`,profile:r,motd:i,command:a,interactive:o=!0,subshell:s=!1,hostname:c=`browser`,filesystem:u={},permissions:d={},cwd:f=`/`,onFsChange:p,useRealFilesystem:m=!1,cols:h,rows:_}=e;if(this.context=new n(Object.assign({},e,{clearFn:this.clear.bind(this),destroyFn:this.destroy.bind(this),onFsChange:typeof p==`function`?p:null})),this._readonlyContext=Object.freeze({getVar:e=>this.context.getVar(e),getAlias:e=>this.context.getAlias(e),getCommand:e=>this.context.getCommand(e)}),this.context.setVar(`PATH`,t),this.context.setVar(`HOST`,c),!s){let e=(o?`i`:``)+(a?`c`:``);e&&this.context.setVar(`-`,e)}this._lastCode=0,this._subshell=s,this._useRealFilesystem=m,this._profile=r,this._motd=i,this._initialCommand=a||null,this._suppressMotd=!!a,this._loadingFs=null,this._queuedWhileLoading=!1;let v=typeof h==`number`&&h>0?Math.floor(h):80,y=typeof _==`number`&&_>0?Math.floor(_):24;if((typeof h==`number`&&h>0||typeof _==`number`&&_>0)&&(this._terminalSize={cols:v,rows:y},this.context.setVar(`COLUMNS`,String(v)),this.context.setVar(`LINES`,String(y))),this.stdinStream=new l({columns:v,rows:y}),this.stdout=new l({columns:v,rows:y,onWrite:e=>this.emit(`data`,e)}),this.stderr=new l({columns:v,rows:y,onWrite:e=>this.emit(`data`,e)}),this._lineBuffer=[],this._cursorPos=0,this._history=[],this._historyPos=null,this._savedInput=null,this._historyLoaded=!1,this._working=!0,this._promptReady=!1,this._inProgressLine=!1,this._fromLineEditor=!1,this._lastPromptRowOffset=0,this._pendingCommands=[],s||this._setupTtyStreams(),m)this.context.setNodeFilesystem(f),this.context.setCwd(f),this._loadDefaultCommands(),this._loadBuiltinCommands(!0),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0));else if(g(u)||u&&typeof u==`object`&&g(u.filesystem))this.context.setFilesystem({},d),this._loadDefaultCommands(),this._loadBuiltinCommands(!1),this._initializing=!s,this._loadingFs=this._initAsyncFilesystem(u,d,f,r),this.ready=this._loadingFs;else{this.context.setFilesystem(u,d),this.context.setCwd(f);let e=this.context.fs.exists(this.context.getVar(`PATH`));this._loadDefaultCommands(),this._loadBuiltinCommands(e),this.ready=Promise.resolve(this),s?this._initializing=!1:(this._initializing=!0,setTimeout(()=>this._init(),0))}this.context.fs&&typeof this.context.fs.setTtyDevice==`function`&&this.context.fs.setTtyDevice({write:e=>this.stdout.write(e),read:()=>``})}async _initAsyncFilesystem(t,n,r){let i=this.context.getVar(`PATH`)||`/bin`,a=()=>{try{let e=this.context.fs.getRaw(),t=i.replace(/^\/+|\/+$/g,``).split(`/`).filter(Boolean),n=e;for(let e of t)n&&=n[e];return n&&typeof n==`object`?Object.assign({},n):{}}catch{return{}}},o=a();try{let e=await _(t,n),s=a(),c=[];for(let[e,t]of Object.entries(s))o[e]!==t&&typeof t==`function`&&c.push(t);let l=this.context._onFsChange;this.context._onFsChange=null,this.context.setFilesystem(e.filesystem,e.permissions);let u=this.context.fs.exists(i);this._loadDefaultCommands(),this._loadBuiltinCommands(u);for(let e of c)this.context.setCommand(e);this.context.setCwd(r),this.context._onFsChange=l,l&&this.context.fs&&(this.context.fs._onChange=()=>l(this.context.fs.getRaw(),this.context.fs.getRawPermissions())),this.context.fs&&typeof this.context.fs.setTtyDevice==`function`&&this.context.fs.setTtyDevice({write:e=>this.stdout.write(e),read:()=>``})}catch(e){this.emit(`stdErr`,e.message||String(e))}finally{this._loadingFs=null}return this._subshell?(this._initializing=!1,!this._queuedWhileLoading&&!this.destroyed&&this.emit(`status`,e.STATUS_READY)):await this._init(),this}get path(){return this.context.getVar(`PATH`)}set lastCode(e){this.context.setVar(`?`,String(e)),this._lastCode=e}get lastCode(){return this._lastCode}get stdin(){return this._stdin===void 0?this.stdinStream:this._stdin}set stdin(e){this._stdin=e}write(e){return this.stdinStream.pushData(e),!0}resize(e,t){this.setTerminalSize(e,t)}onInput(e){if(this.runningCommand){let t=this.runningCommand;if((e===`^C`||e===``)&&!(t.isRaw||t.stdinStream&&t.stdinStream.isRaw)){let e=!!(t.interactive||t._inAltScreen);return typeof t.kill==`function`&&t.kill(`SIGINT`),e||this.stdout.write(`^C\r
28
36
  `),!0}if(t.onInput&&t.captureInput)return t.onInput(e),!0}}setTerminalSize(e,t){this._terminalSize={cols:e,rows:t},this.context.setVar(`COLUMNS`,String(e)),this.context.setVar(`LINES`,String(t)),this.stdinStream.resize(e,t),this.stdout.resize(e,t),this.stderr.resize(e,t),this.runningCommand&&(this.runningCommand.stdinStream&&this.runningCommand.stdinStream.resize(e,t),this.runningCommand.stdout&&this.runningCommand.stdout.resize(e,t),this.runningCommand.stderr&&this.runningCommand.stderr.resize(e,t)),this.emit(`resize`,{cols:e,rows:t})}get terminalSize(){return this._terminalSize||{cols:80,rows:24}}_loadDefaultCommands(){p.forEach(e=>{this.context.setCommand(e)})}_loadBuiltinCommands(e=!1){f.forEach(e=>{this.context.setCommand(e)}),e||this.context.fs.setMode(this.context.getVar(`PATH`),365)}suppressMotd(){this._suppressMotd=!0;let e=this.context.getVar(`-`);e.includes(`c`)||this.context.setVar(`-`,e+`c`)}async _init(){try{if(!this._suppressMotd&&!this._initialCommand&&await this._runMotd(),await this._loadProfile(this._profile),this._initialCommand){await this.onCommand(this._initialCommand,!1);let e=this.context.getVar(`-`);e.includes(`c`)&&this.context.setVar(`-`,e.replace(/c/g,``))}}finally{this._initializing=!1,!this._queuedWhileLoading&&!this.destroyed&&this.emit(`status`,e.STATUS_READY)}}_hasHushlogin(){if(this.context.fs.exists(`.hushlogin`))return!0;let e=this.context.getVar(`HOME`);return!!(e&&this.context.fs.exists(`${e.replace(/\/$/,``)}/.hushlogin`))}async _runMotd(){if(!(this._motd===!1||this._hasHushlogin())){if(typeof this._motd==`string`){await this._renderMotdPath(this._motd);return}this._useRealFilesystem||(this.context.fs.exists(`/etc/update-motd.d`)&&await this._runMotdDir(`/etc/update-motd.d`),this.context.fs.exists(`/etc/motd`)&&await this._renderMotdPath(`/etc/motd`))}}async _runMotdDir(e){let t=this.context.fs.getFileByPath(e);if(!t||t.constructor!==Object)return;let n=Object.keys(t).sort(),r=e.endsWith(`/`)?e.slice(0,-1):e;for(let e of n){let t=`${r}/${e}`,n=this.context.fs.stat(t);!n||n.isDirectory||this.context.fs.isExecutable(t)&&await this.onCommand(t,!1)}}async _renderMotdPath(e){if(!this.context.fs.exists(e))return;let t=this.context.fs.stat(e);if(!t)return;if(t.isDirectory){await this._runMotdDir(e);return}let n=this.context.fs.getFileByPath(e);if(n==null)return;if(typeof n==`function`){this.context.fs.isExecutable(e)&&await this.onCommand(e,!1);return}if(typeof n==`string`&&n.startsWith(`#!`)){this.context.fs.isExecutable(e)?await this.onCommand(e,!1):await this.onCommand(`source ${e}`,!1);return}let r=n.toString();r.endsWith(`
29
37
  `)&&(r=r.slice(0,-1)),r.split(/\r?\n/).forEach(e=>{this.emit(`stdOut`,e)})}async _loadProfile(e){if(!this._useRealFilesystem&&e!==`/etc/profile`&&this.context.fs.exists(`/etc/profile`)){let e=this.context.fs.getFileByPath(`/etc/profile`);typeof e==`string`&&e.startsWith(`#!`)&&await this.onCommand(`source /etc/profile`,!1)}e&&await this.onCommand(`source ${e}`,!1)}onCommand(t,n=!0){n&&!this._subshell&&this._promptReady&&!this._fromLineEditor&&(this.stdout.write(`\r${this.getPrompt()} ${t}\x1b[K\r\n`),this._lineBuffer=[],this._cursorPos=0),this._fromLineEditor=!1;let r=this._splitInput(t),i=this._groupPipes(r),a=!0;this._loadingFs&&n&&(this._queuedWhileLoading=!0);let o=this._loadingFs?Promise.resolve(this._loadingFs):Promise.resolve(),s=i.reduce((e,{commands:t,op:n})=>e.then(()=>{if(!a){n===`&&`?a=this._lastCode===0:n===`||`?a=this._lastCode!==0:n===`;`&&(a=!0);return}return this._runPipeChain(t).then(()=>{n===`&&`?a=this._lastCode===0:n===`||`?a=this._lastCode!==0:n===`;`&&(a=!0)})}),o);return n?s.then(()=>{this.destroyed||this.emit(`status`,e.STATUS_READY)}).catch(()=>this.emit(`status`,e.STATUS_READY)):s}tabCompletion(e){return this.context.fs.autoComplete(e,this.path)}async _runCommand(t){if(!t||t.length<1)return;this._initializing||this.emit(`status`,e.STATUS_WORKING);let n;try{n=await this._parseCommandLine(t)}catch(e){this.emit(`stdErr`,e.message||String(e)),this.lastCode=1,this.emit(`exitCode`,this.lastCode);return}if(!n.length)return;let a=!1;for(;n.length>0&&!n[0].hasQuote&&n[0].value===`!`;)a=!a,n.shift();if(!n.length){this.lastCode=+!!a,this.emit(`exitCode`,this.lastCode);return}let o={type:`stdout`},s={type:`stderr`},c=[];for(let e=0;e<n.length;e++){let{value:t,hasQuote:r}=n[e];if(r){c.push(t);continue}if(t===`2>&1`){s={...o};continue}if(t===`1>&2`){o={...s};continue}if(t===`2>&-`){s={type:`null`};continue}if(t===`1>&-`||t===`>&-`){o={type:`null`};continue}if(t===`&>>`){if(e+1<n.length){let t=n[++e].value,r=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!0};o=r,s=r}continue}if(t===`&>`||t===`>&`){if(e+1<n.length){let t=n[++e].value,r=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!1};o=r,s=r}continue}if(t.startsWith(`&>>`)&&t.length>3){let e=t.slice(3),n=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!0};o=n,s=n;continue}if((t.startsWith(`&>`)||t.startsWith(`>&`))&&t.length>2){let e=t.slice(2),n=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!1};o=n,s=n;continue}if(t===`2>>`){if(e+1<n.length){let t=n[++e].value;s=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!0}}continue}if(t===`2>`){if(e+1<n.length){let t=n[++e].value;s=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!1}}continue}if(t.startsWith(`2>>`)&&t.length>3){let e=t.slice(3);s=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!0};continue}if(t.startsWith(`2>`)&&t.length>2){let e=t.slice(2);s=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!1};continue}if(t===`1>>`||t===`>>`){if(e+1<n.length){let t=n[++e].value;o=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!0}}continue}if(t===`1>`||t===`>`){if(e+1<n.length){let t=n[++e].value;o=t===`/dev/null`?{type:`null`}:{type:`file`,file:t,append:!1}}continue}if((t.startsWith(`1>>`)||t.startsWith(`>>`))&&t.length>(t.startsWith(`1>>`)?3:2)){let e=t.slice(t.startsWith(`1>>`)?3:2);o=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!0};continue}if((t.startsWith(`1>`)||t.startsWith(`>`))&&t.length>(t.startsWith(`1>`)?2:1)){let e=t.slice(t.startsWith(`1>`)?2:1);o=e===`/dev/null`?{type:`null`}:{type:`file`,file:e,append:!1};continue}c.push(t)}if(!c.length){for(let e of[o,s])if(e.type===`file`&&e.file!==`/dev/null`)try{let t=this.context.fs.absolutePath(e.file),n=this.context.fs._getFileRaw(t);(!e.append||n===void 0)&&this.context.fs.setFileByPath(t,n||``,!0)}catch{this.emit(`stdErr`,`${e.file}: Permission denied`),this.lastCode=+!a,this.emit(`exitCode`,this.lastCode);return}this.lastCode=+!!a,this.emit(`exitCode`,this.lastCode);return}let l=c.shift();if(n=c,n.length===0&&/^[A-Za-z_]\w*=/.test(l)){let e=l.indexOf(`=`);this.context.setVar(l.slice(0,e),l.slice(e+1)),this.lastCode=+!!a,this.emit(`exitCode`,this.lastCode);return}let u=this.context.getAlias(l);if(u)return this.onCommand(u,!1).then(()=>{a&&(this.lastCode=+(this.lastCode===0),this.emit(`exitCode`,this.lastCode))});let d;try{d=this._parseCommand(l.startsWith(`/`)||l.startsWith(`./`)?l:l.toLowerCase())}catch(e){this._handleCommandError(e.message,s,a);return}let f=e=>typeof e==`function`&&typeof e.prototype.run==`function`&&typeof e.prototype.runCommand==`function`,p;if(d.prototype instanceof r||new d instanceof i)p=new d(n,this.context);else if(f(d))p=new d(n,this._readonlyContext);else{this._handleCommandError(`${l}: Command not found`,s,a);return}p.requiresFilesystem&&(p.fs=this.context.fs.sandbox()),this._stdin!==void 0&&(p.stdin=this._stdin);let m=new Map,h=({type:e,string:t})=>{let n=e===`out`?o:s;if(n.type===`stdout`)this.emit(`stdOut`,t);else if(n.type===`stderr`)this.emit(`stdErr`,t);else if(n.type===`file`&&n.file!==`/dev/null`){let e=m.get(n.file);e||(e={append:n.append,lines:[]},m.set(n.file,e)),e.lines.push(t)}};this.runningCommand=p;let g=this.stdout&&this.stdout.columns||this.stdinStream&&this.stdinStream.columns,_=this.stdout&&this.stdout.rows||this.stdinStream&&this.stdinStream.rows;return g&&_&&(p.stdinStream&&(p.stdinStream.columns=g,p.stdinStream.rows=_),p.stdout&&(p.stdout.columns=g,p.stdout.rows=_),p.stderr&&(p.stderr.columns=g,p.stderr.rows=_)),this.runningCommand.on&&(this.runningCommand.on(`flush`,e=>{e.forEach(h)}),this.runningCommand.on(`stdout`,e=>{o.type===`file`?p._streamedStdout||(p.stdOut=String(e??``)):o.type===`stderr`?this.stderr.write(e):o.type===`null`||(this.stdout.write(e),this.emit(`stdOutRaw`,e))}),this.runningCommand.on(`token`,e=>{this.emit(`token`,e)}),this.runningCommand.on(`stderr`,e=>{s.type===`file`?p.stdErr=String(e??``):s.type===`stdout`?o.type===`file`?p.stdOut=String(e??``):o.type===`null`||(this.stdout.write(e),this.emit(`stdOutRaw`,e)):s.type===`null`||this.stderr.write(e)})),p.interactive&&this.emit(`interactive`),p.runCommand().then(e=>{e.getStdOutput().forEach(h);for(let e of[o,s])e.type===`file`&&e.file!==`/dev/null`&&!m.has(e.file)&&m.set(e.file,{append:e.append,lines:[]});for(let[e,{append:t,lines:n}]of m){let r=this.context.fs.absolutePath(e),i=n.join(`
30
38
  `),o=i;if(t){let e=this.context.fs._getFileRaw(r);o=typeof e==`string`&&e.length>0?e+`
@@ -43,8 +51,8 @@
43
51
  `&&n++,n++;continue}if(r===127||r===8){this._cursorPos>0&&(this._lineBuffer.splice(this._cursorPos-1,1),this._cursorPos--,this._redrawPromptLine()),n++;continue}if(r===9){this._handleTab(),n++;continue}if(r===1){this._cursorPos=0,this._redrawPromptLine(),n++;continue}if(r===5){this._cursorPos=this._lineBuffer.length,this._redrawPromptLine(),n++;continue}if(r===21){this._lineBuffer.splice(0,this._cursorPos),this._cursorPos=0,this._redrawPromptLine(),n++;continue}if(r===11){this._lineBuffer.splice(this._cursorPos),this._redrawPromptLine(),n++;continue}if(r===23){let e=this._wordLeft();this._lineBuffer.splice(e,this._cursorPos-e),this._cursorPos=e,this._redrawPromptLine(),n++;continue}if(r===12){this.stdout.write(`\x1B[2J\x1B[H`),this._redrawPromptLine(),n++;continue}if(r===3){this._lineBuffer=[],this._cursorPos=0,this._historyPos=null,this._savedInput=null,this.stdout.write(`^C\r
44
52
  `),this._redrawPromptLine(),n++;continue}r>=32&&(this._lineBuffer.splice(this._cursorPos,0,e),this._cursorPos++,this._redrawPromptLine()),n++}}_handleEscapeSeq(e){e===`A`?this._navigateHistory(-1):e===`B`?this._navigateHistory(1):e===`C`?this._cursorPos<this._lineBuffer.length&&(this._cursorPos++,this._redrawPromptLine()):e===`D`?this._cursorPos>0&&(this._cursorPos--,this._redrawPromptLine()):e===`1;3D`||e===`1;5D`?(this._cursorPos=this._wordLeft(),this._redrawPromptLine()):e===`1;3C`||e===`1;5C`?(this._cursorPos=this._wordRight(),this._redrawPromptLine()):e===`H`||e===`1~`||e===`7~`?(this._cursorPos=0,this._redrawPromptLine()):e===`F`||e===`4~`||e===`8~`?(this._cursorPos=this._lineBuffer.length,this._redrawPromptLine()):e===`3~`&&this._cursorPos<this._lineBuffer.length&&(this._lineBuffer.splice(this._cursorPos,1),this._redrawPromptLine())}_handleTab(){let e=this._lineBuffer.join(``).split(` `),t=e.pop(),n=this.tabCompletion(t);if(!n)return;let{options:r,path:i}=n;r.length===1?(e.push(`${i==null?``:i.concat(`/`)}${r[0]}`),this._lineBuffer=e.join(` `).split(``),this._cursorPos=this._lineBuffer.length,this._redrawPromptLine()):r.length>1&&(this.stdout.write(`\r
45
53
  `+r.join(` `)+`\r
46
- `),this._redrawPromptLine())}_splitInput(e){return this._parseOperators(e)}_parseOperators(e){let t=[],n=``,r=0,i=!1,a=!1;for(;r<e.length;){let o=e[r];if(o===`'`&&!a){i=!i,n+=o,r++;continue}if(o===`"`&&!i){a=!a,n+=o,r++;continue}if(!i&&!a){if(o===`#`&&(n.trim()===``||/\s/.test(e[r-1]))){let t=e.indexOf(`
47
- `,r);if(t===-1)break;r=t;continue}if(o===`&`&&e[r+1]===`&`){t.push({command:n.trim(),op:`&&`}),n=``,r+=2;continue}if(o===`|`&&e[r+1]===`|`){t.push({command:n.trim(),op:`||`}),n=``,r+=2;continue}if(o===`|`){t.push({command:n.trim(),op:`|`}),n=``,r++;continue}if(o===`;`){t.push({command:n.trim(),op:`;`}),n=``,r++;continue}}n+=o,r++}return n.trim()&&t.push({command:n.trim(),op:null}),t}_loadJsCommand(e,t){return this._jsCommandCache||=new Map,o.load(this.context.fs,e,t,this._jsCommandCache)}_findExecutablePath(e){return this.context.fs.exists(e)?e:!e.endsWith(`.wasm`)&&this.context.fs.exists(`${e}.wasm`)?`${e}.wasm`:!e.endsWith(`.js`)&&this.context.fs.exists(`${e}.js`)?`${e}.js`:null}_resolveCommandFromPath(e){let t=this.context.fs.realpath(e);if(!this.context.fs.isExecutable(e)&&!this.context.fs.isExecutable(t))throw Error(`${e}: permission denied`);let n=this.context.fs.getFileByPath(t);return o.isCommandClass(n)?n:typeof n==`string`&&n.startsWith(`#!`)?i.bind(this,n):a.isWasmFile(t,n)?a.bind(null,t):o.isJsFile(t,n)?this._loadJsCommand(t,n):null}_parseCommand(e){if(e.startsWith(`./`)||e.startsWith(`/`)||e.startsWith(`../`)||e.includes(`/`)){let t=this._findExecutablePath(this.context.fs.absolutePath(e));if(!t)throw Error(`${e}: No such file or directory`);let n=this.context.fs.stat(t);if(n&&n.isDirectory)throw Error(`${e}: is a directory`);let r=this._resolveCommandFromPath(t);if(!r)throw Error(`${e}: permission denied`);return r}let t=this.context.getCommand(e)||!e.endsWith(`.wasm`)&&this.context.getCommand(`${e}.wasm`)||!e.endsWith(`.js`)&&this.context.getCommand(`${e}.js`);if(o.isCommandClass(t))return t;if(typeof t==`string`&&t.startsWith(`#!`))return i.bind(this,t);let n=(this.context.getVar(`PATH`)||`/bin`).split(`:`).filter(Boolean);for(let t of n){let n=this._findExecutablePath(`${t}/${e}`);if(n){let e=this._resolveCommandFromPath(n);if(e)return e}}throw Error(`${e}: Command not found`)}async _parseCommandLine(t){let n=e._splitCommand(t),r=n.length>0?n[0].value:``,i=r===`export`||r===`alias`||r===`local`,a=[];for(let e=0;e<n.length;e++){let{value:t,hasQuote:r}=n[e];if(r&&t===`$@`){let e=parseInt(this.context.getVar(`#`)||`0`,10)||0;for(let t=1;t<=e;t++)a.push({value:String(this.context.getVar(String(t))),hasQuote:!0});continue}let o=await this._replaceVariables(t),s=n.length===1&&/^[A-Za-z_]\w*=/.test(t),c=e>0&&i&&/^[A-Za-z_]\w*=/.test(t);if(r||s||c||!t.includes(`$`)){(o.length>0||r)&&a.push({value:o,hasQuote:r});continue}let l=o.trim().split(/\s+/).filter(Boolean);for(let e of l)a.push({value:e,hasQuote:!1})}return a}static _sanitiseCommandPart(e){return e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.substring(1,e.length-1):e}static _sanitiseArray(e){return e.filter(e=>e.length>0)}async _replaceVariables(t){let n=[...t.matchAll(/\$\(\(([^)]+)\)\)/g)];for(let e of n)t=t.replace(e[0],String(this._evalArithmetic(e[1])));let r=[...t.matchAll(/\$\((?!\()([^)]+)\)/g)];for(let e of r){let n=await this._runAndCapture(e[1]);t=t.replace(e[0],n)}let i=t.matchAll(x),a=i.next();for(;!a.done;){let n=a.value[1]||a.value[2],r=this.context.getVar(n);t=t.replace(new RegExp(e._escapeRegExp(a.value[0]),`g`),String(r)),a=i.next()}return t}_evalArithmetic(e){let t=e.replace(/\${?([\w\d]+)}?/g,(e,t)=>String(parseInt(this.context.getVar(t))||0));if(t=t.replace(/\b([A-Za-z_]\w*)\b/g,(e,t)=>String(parseInt(this.context.getVar(t))||0)),!/^[\d\s+\-*/%()]+$/.test(t.trim()))return 0;try{return Function(`return (`+t+`)`)()}catch{return 0}}async _runAndCapture(e){let t=new globalThis.shell({cwd:this.context.fs.cwd,filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions(),subshell:!0});t.context.source(this.context);let n=[];return t.on(`stdOut`,e=>n.push(e)),await t.onCommand(e,!1),n.join(`
54
+ `),this._redrawPromptLine())}_splitInput(e){return this._parseOperators(e)}_parseOperators(t){let n=[],r=``,i=0,a=!1,o=!1;for(;i<t.length;){let s=t[i];if(!a&&s===`$`&&(t[i+1]===`(`||t[i+1]===`{`)){let n=e._skipGroup(t,i);if(n>-1){r+=t.slice(i,n),i=n;continue}}if(s===`'`&&!o){a=!a,r+=s,i++;continue}if(s===`"`&&!a){o=!o,r+=s,i++;continue}if(!a&&!o){if(s===`#`&&(r.trim()===``||/\s/.test(t[i-1]))){let e=t.indexOf(`
55
+ `,i);if(e===-1)break;i=e;continue}if(s===`&`&&t[i+1]===`&`){n.push({command:r.trim(),op:`&&`}),r=``,i+=2;continue}if(s===`|`&&t[i+1]===`|`){n.push({command:r.trim(),op:`||`}),r=``,i+=2;continue}if(s===`|`){n.push({command:r.trim(),op:`|`}),r=``,i++;continue}if(s===`;`){n.push({command:r.trim(),op:`;`}),r=``,i++;continue}}r+=s,i++}return r.trim()&&n.push({command:r.trim(),op:null}),n}_loadJsCommand(e,t){return this._jsCommandCache||=new Map,o.load(this.context.fs,e,t,this._jsCommandCache)}_findExecutablePath(e){return this.context.fs.exists(e)?e:!e.endsWith(`.wasm`)&&this.context.fs.exists(`${e}.wasm`)?`${e}.wasm`:!e.endsWith(`.js`)&&this.context.fs.exists(`${e}.js`)?`${e}.js`:null}_resolveCommandFromPath(e){let t=this.context.fs.realpath(e);if(!this.context.fs.isExecutable(e)&&!this.context.fs.isExecutable(t))throw Error(`${e}: permission denied`);let n=this.context.fs.getFileByPath(t);return o.isCommandClass(n)?n:typeof n==`string`&&n.startsWith(`#!`)?i.bind(this,n):a.isWasmFile(t,n)?a.bind(null,t):o.isJsFile(t,n)?this._loadJsCommand(t,n):null}_parseCommand(e){if(e.startsWith(`./`)||e.startsWith(`/`)||e.startsWith(`../`)||e.includes(`/`)){let t=this._findExecutablePath(this.context.fs.absolutePath(e));if(!t)throw Error(`${e}: No such file or directory`);let n=this.context.fs.stat(t);if(n&&n.isDirectory)throw Error(`${e}: is a directory`);let r=this._resolveCommandFromPath(t);if(!r)throw Error(`${e}: permission denied`);return r}let t=this.context.getCommand(e)||!e.endsWith(`.wasm`)&&this.context.getCommand(`${e}.wasm`)||!e.endsWith(`.js`)&&this.context.getCommand(`${e}.js`);if(o.isCommandClass(t))return t;if(typeof t==`string`&&t.startsWith(`#!`))return i.bind(this,t);let n=(this.context.getVar(`PATH`)||`/bin`).split(`:`).filter(Boolean);for(let t of n){let n=this._findExecutablePath(`${t}/${e}`);if(n){let e=this._resolveCommandFromPath(n);if(e)return e}}throw Error(`${e}: Command not found`)}async _parseCommandLine(t){let n=e._splitCommand(t),r=n.length>0?n[0].value:``,i=r===`export`||r===`alias`||r===`local`,a=[];for(let e=0;e<n.length;e++){let{value:t,hasQuote:r}=n[e];if(r&&t===`$@`){let e=parseInt(this.context.getVar(`#`)||`0`,10)||0;for(let t=1;t<=e;t++)a.push({value:String(this.context.getVar(String(t))),hasQuote:!0});continue}let o=(await this._replaceVariables(t)).replaceAll(S,`$`),s=n.length===1&&/^[A-Za-z_]\w*=/.test(t),c=e>0&&i&&/^[A-Za-z_]\w*=/.test(t);if(r||s||c||!t.includes(`$`)){(o.length>0||r)&&a.push({value:o,hasQuote:r});continue}let l=o.trim().split(/\s+/).filter(Boolean);for(let e of l)a.push({value:e,hasQuote:!1})}return a}static _sanitiseCommandPart(e){return e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`)?e.substring(1,e.length-1):e}static _sanitiseArray(e){return e.filter(e=>e.length>0)}async _replaceVariables(t){let n=``;for(let r=0;r<t.length;r++){if(t[r]!==`$`){n+=t[r];continue}if(t[r+1]===`(`||t[r+1]===`{`){let i=e._skipGroup(t,r);if(i>-1){n+=await this._expandGroup(t.slice(r,i)),r=i-1;continue}}let i=/^\$(?:([\w]+)|([?#@*-]))/.exec(t.slice(r,r+256));if(i){n+=String(this.context.getVar(i[1]||i[2])),r+=i[0].length-1;continue}n+=`$`}return n}async _expandGroup(t){if(t.startsWith(`$((`)&&t.endsWith(`))`))return String(this._evalArithmetic(t.slice(3,-2)));if(t.startsWith(`$(`))return this._runAndCapture(t.slice(2,-1));let n=t.slice(2,-1),r=/^#(\w+)$/.exec(n);if(r)return String(this.context.getVar(r[1]).length);let i=/^(\w+|[?#@*-])(?::?([-=?+])([\s\S]*))?$/.exec(n);if(!i)return t;let[,a,o,s=``]=i,c=String(this.context.getVar(a)),l=()=>this._replaceVariables(e._sanitiseCommandPart(s));if(!o)return c;if(o===`+`)return c===``?``:l();if(c!==``)return c;if(o===`-`)return l();if(o===`=`){let e=await l();return this.context.setVar(a,e),e}throw Error(`${a}: ${s||`parameter null or not set`}`)}static _skipGroup(e,t){let n=[];for(let r=t;r<e.length;r++){let t=e[r],i=n[n.length-1];if(i===`'`)t===`'`&&n.pop();else if(t===`\\`)r++;else if(t===`"`)i===`"`?n.pop():n.push(`"`);else if(t===`'`&&i!==`"`)n.push(`'`);else if(t===`$`&&(e[r+1]===`{`||e[r+1]===`(`))n.push(e[r+1]===`{`?`}`:`)`),r++;else if(t===`(`&&i!==`"`)n.push(`)`);else if(t===i&&(n.pop(),n.length<1))return r+1}return-1}_evalArithmetic(e){let t=e.replace(/\${?([\w\d]+)}?/g,(e,t)=>String(parseInt(this.context.getVar(t))||0));if(t=t.replace(/\b([A-Za-z_]\w*)\b/g,(e,t)=>String(parseInt(this.context.getVar(t))||0)),!/^[\d\s+\-*/%()]+$/.test(t.trim()))return 0;try{return Function(`return (`+t+`)`)()}catch{return 0}}async _runAndCapture(e){let t=new globalThis.shell({cwd:this.context.fs.cwd,filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions(),subshell:!0});t.context.source(this.context);let n=[];return t.on(`stdOut`,e=>n.push(e)),await t.onCommand(e,!1),n.join(`
48
56
  `).trimEnd()}_groupPipes(e){let t=[],n=[];for(let{command:r,op:i}of e)n.push(r),i!==`|`&&(t.push({commands:n,op:i}),n=[]);return n.length&&t.push({commands:n,op:null}),t}async _runPipeChain(t){if(t.length===1)return this._runCommand(t[0]);let n=!1;try{let r=e._splitCommand(t[0]),i=t[0],a=!1;for(;r.length>0&&!r[0].hasQuote&&r[0].value===`!`;)n=!n,a=!0,r.shift(),i=i.replace(/^\s*!\s*/,``);a&&(t=[i,...t.slice(1)])}catch{}let r;for(let e=0;e<t.length;e++)if(e===t.length-1){r!==void 0&&(this._stdin=r);try{await this._runCommand(t[e])}finally{delete this._stdin}}else r=await this._captureForPipe(t[e],r);n&&(this.lastCode=+(this.lastCode===0),this.emit(`exitCode`,this.lastCode))}async _captureForPipe(e,t){let n=new globalThis.shell({cwd:this.context.fs.cwd,filesystem:this.context.fs.getRaw(),permissions:this.context.fs.getRawPermissions(),subshell:!0});n.context.source(this.context),t!==void 0&&(n.stdin=t);let r=[];return n.on(`stdOut`,e=>r.push(e)),n.on(`stdErr`,e=>this.emit(`stdErr`,e)),await n.onCommand(e,!1),this.lastCode=n.lastCode,r.join(`
49
- `)}static _splitCommand(e){let t=/\s/g,n=!1,r=!1,i=0,a=[],o=!1,s=[];for(let c=0;c<e.length;c++){let l=e[c];if(i>0){a.push(l),l===`(`?i++:l===`)`&&i--;continue}if(r&&l===`\\`&&c+1<e.length){let t=e[c+1];if(t===`"`||t===`\\`||t===`$`){a.push(t),c++;continue}}if(!n&&!r&&l===`\\`&&c+1<e.length){let t=e[++c];a.push(t),(t===`"`||t===`'`)&&(o=!0);continue}if(l===`'`&&!r){n=!n,o=!0;continue}if(l===`"`&&!n){r=!r,o=!0;continue}if(!n&&!r){if(l===`$`&&c+1<e.length&&e[c+1]===`(`){i=1,a.push(`$`),a.push(`(`),c++;continue}if(l.match(t)){(a.length>0||o)&&(s.push({value:a.join(``),hasQuote:o}),a=[],o=!1);continue}}a.push(l)}if((a.length>0||o)&&s.push({value:a.join(``),hasQuote:o}),n||r)throw Error(`quote expression not closed`);return s}static _escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}static async create(t={}){let{filesystem:n,permissions:r,...i}=t;if(g(n)||n&&typeof n==`object`&&g(n.filesystem)){let e=await _(n,r);n=e.filesystem,r=e.permissions}let a=new e(Object.assign({},i,{filesystem:n,permissions:r}));return await a.ready,a}static async fromContainer(t,n={}){return e.create(Object.assign({},n,{filesystem:t}))}};D.STATUS_READY=`READY`,D.STATUS_WORKING=`WORKING`,D.STATUS_DESTROYED=`DESTROYED`,D.Command=s,D.InteractiveCommand=c,D.WasmCommand=a,D.createWasmCommand=a.createGenericWasmCommand||a.createCommand,D.ReplCommand=A(),D.JsCommand=o,D.FS=h,D.BinaryContainer=q(),D.Storage=D.BinaryContainer.FilesystemStorage,globalThis.shell=D,globalThis.Shell=D,t.exports=D}))()})();
57
+ `)}static _splitCommand(t){let n=/\s/g,r=!1,i=!1,a=[],o=!1,s=[];for(let c=0;c<t.length;c++){let l=t[c];if(!r&&l===`$`&&(t[c+1]===`(`||t[c+1]===`{`)){let n=e._skipGroup(t,c);if(n>-1){a.push(t.slice(c,n)),c=n-1;continue}}if(i&&l===`\\`&&c+1<t.length){let e=t[c+1];if(e===`"`||e===`\\`||e===`$`){a.push(e===`$`?S:e),c++;continue}}if(!r&&!i&&l===`\\`&&c+1<t.length){let e=t[++c];a.push(e===`$`?S:e),(e===`"`||e===`'`)&&(o=!0);continue}if(l===`'`&&!i){r=!r,o=!0;continue}if(l===`"`&&!r){i=!i,o=!0;continue}if(!r&&!i&&l.match(n)){(a.length>0||o)&&(s.push({value:a.join(``),hasQuote:o}),a=[],o=!1);continue}a.push(l===`$`&&r?S:l)}if((a.length>0||o)&&s.push({value:a.join(``),hasQuote:o}),r||i)throw Error(`quote expression not closed`);return s}static _escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}static async create(t={}){let{filesystem:n,permissions:r,...i}=t;if(g(n)||n&&typeof n==`object`&&g(n.filesystem)){let e=await _(n,r);n=e.filesystem,r=e.permissions}let a=new e(Object.assign({},i,{filesystem:n,permissions:r}));return await a.ready,a}static async fromContainer(t,n={}){return e.create(Object.assign({},n,{filesystem:t}))}};D.STATUS_READY=`READY`,D.STATUS_WORKING=`WORKING`,D.STATUS_DESTROYED=`DESTROYED`,D.Command=s,D.InteractiveCommand=c,D.WasmCommand=a,D.createWasmCommand=a.createGenericWasmCommand||a.createCommand,D.ReplCommand=A(),D.JsCommand=o,D.FS=h,D.BinaryContainer=q(),D.Storage=D.BinaryContainer.FilesystemStorage,globalThis.shell=D,globalThis.Shell=D,t.exports=D}))()})();
50
58
  //# sourceMappingURL=shell.min.js.map