text: #!/usr/bin/env node
  var Dr=Object.create,ke=Object.defineProperty,Ur=Object.getPrototypeOf,Gr=Object.prototype.hasOwnProperty,qr=Object.getOwnPropertyNames,Yr=Object.getOwnPropertyDescriptor;var ht=e=>ke(e,"__esModule",{value:!0});var bt=(e,t)=>()=>(t||(t={exports:{}},e(t.exports,t)),t.exports),yt=(e,t)=>{for(var r in t)ke(e,r,{get:t[r],enumerable:!0})},Hr=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of qr(t))!Gr.call(e,n)&&n!=="default"&&ke(e,n,{get:()=>t[n],enumerable:!(r=Yr(t,n))||r.enumerable});return e},h=e=>Hr(ht(ke(e!=null?Dr(Ur(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var Ot=bt(xt=>{var wt=Object.defineProperty,Kr=e=>wt(e,"__esModule",{value:!0}),zr=(e,t)=>{Kr(e);for(var r in t)wt(e,r,{get:t[r],enumerable:!0})};zr(xt,{PatternError:()=>ae,glob:()=>Jr,match:()=>Ge});var{readdirSync:St,statSync:qe}=require("fs"),se=(()=>{try{return require("path").sep}catch(e){return"/"}})(),q=se.charCodeAt(0),Vr=se==":"?/\:+/g:se=="\\"?/\\+/g:/\/+/g,we=process.platform=="win32",ae=class extends Error{constructor(){super("bad pattern")}};function Jr(e){if(e.indexOf("**")<0)return Ye(e);let t=[],r=new Set;return Pt("",e.split(/\*{2,}/),0,t,r),t}function z(){}var Xr=we?e=>{if(e.length<2)return 0;let t=e[0];return e[1]==":"&&("a"<=t&&t<="z"||"A"<=t&&t<="Z")?2:0}:e=>0,Zr=we?(e,t)=>{let r=t(e);return e==""?[0,"."]:r+1==e.length&&Ct(e,e.length-1)?[r+1,e]:r==e.length&&e.length==2?[r,e+"."]:(r>=e.length&&(r=e.length-1),[r,e.substr(0,e.length-1)])}:(e,t)=>e==""?[t,"."]:e==se?[t,e]:[t,e.substr(0,e.length-1)];function Ct(e,t){return e.charCodeAt(t)===q}function Qr(e){let t=e.length-1,r=t;for(;e.charCodeAt(r)===q;)r--;return r!=t?e.substr(0,r+1):e}function en(e){let t=0,r=t;for(;e.charCodeAt(r)===q;)r++;return r!=t?e.substr(r):e}function Pt(e,t,r,n,o){r>=t.length&&(r=t.length-1);let i=t[r],s=i;r===0?i.charCodeAt(i.length-1)!=q&&(s+="*"):r===t.length-1?i.charCodeAt(0)!=q&&(s="*"+s):(i.charCodeAt(0)!=q&&(s="*"+s),i.charCodeAt(i.length-1)!=q&&(s+="*"));function l(m){return o.has(m)?!1:(o.add(m),!0)}function c(m){let P=m,T=P.lastIndexOf(se);T!=-1&&(P=P.substr(T+1));let R=Math.min(r+1,t.length-1),L=t.slice(R).join("*");L.charCodeAt(0)==q?L=en(L):L[0]!="*"&&(L="*"+L),Ge(L,P)&&n.push(m)}e&&(s[0]!=se?s=e+se+s:s=e+s);let u=!1;s.charCodeAt(s.length-1)===q&&(u=!0,s=Qr(s));let d=Ye(s);for(let m of d)qe(m).isDirectory()?l(m)&&tn(m,(T,R)=>{l(T)&&(R.isDirectory()?Pt(T,t,r+1,n,o):c(T))}):!u&&l(m)&&c(m);return n}function tn(e,t){e=rn(e);let r=qe(e);r.isDirectory()&&_t(e,t,new Set([r.ino]))}function _t(e,t,r){for(let n of St(e)){let o=Tt(e,n),i=He(o),s=t(o,i);(s||s===void 0)&&i&&i.isDirectory()&&!r.has(i.ino)&&(r.add(i.ino),_t(o,t,r))}}function Ye(e){let t=[];if(!It(e))return He(e)?[e]:t;let r=Xr(e),n=e.length-1;for(;n>=r&&!Ct(e,n);)n--;let o=e.substr(0,n+1),i=e.substr(n+1);if([r,o]=Zr(o,r),!It(o.substr(r)))Et(o,i,t);else{if(o==e)throw new ae;let s=Ye(o);for(let l of s)Et(l,i,t)}return t}function Et(e,t,r){let n=He(e);if(n===null||!n.isDirectory())return;let o;try{o=St(e)}catch(i){return}o.sort();for(let i of o)Ge(t,i)&&r.push(Tt(e,i))}function It(e){for(let t=0;t<e.length;++t)switch(e.charCodeAt(t)){case 42:case 63:case 91:case 123:return!0}return!1}function nn(e,t){for(let r=0;r<e.length;++r)if(e.charCodeAt(r)===t)return!0;return!1}function Ge(e,t){e:for(;e.length>0;){let r=!1,n="",o=e;if([r,n,e]=on(e),z("scanChunk(%o) => %o",o,[r,n,e]),r&&n=="")return z("ret"),!nn(t,q);let[i,s]=kt(n,t);if(z("matchChunk(%o, %o) => %o",n,t,[i,s]),s&&(i.length==0||e.length>0)){t=i;continue}if(r){for(let l=0;l<t.length&&t.charCodeAt(l)!=q;l++)if([i,s]=kt(n,t.substr(l+1)),s){if(e.length==0&&i.length>0)continue;t=i;continue e}}return!1}return t.length==0}function on(e){let t=!1;for(;e.length>0&&e.charCodeAt(0)==42;)e=e.substr(1),t=!0;let r=!1,n=0>>0;e:for(;n<e.length;n++)switch(e.charCodeAt(n)){case 92:we||n+1<e.length&&n++;break;case 91:r=!0;break;case 93:r=!1;break;case 42:if(!r)break e;break}return[t,e.substr(0,n),e.substr(n)]}function kt(e,t){for(z("enter matchChunk(%o, %o)",e,t);e.length>0;){if(t.length==0)return["",!1];switch(e.charCodeAt(0)){case 91:{let o=t.codePointAt(0),i=o<=65535?1:2;if(t=t.substr(i),e=e.substr(1),z('"[" s reduced to %o, chunk reduced to %o, r = 0x%s',t,e,o.toString(16)),e.length==0)throw new ae;let s=e.charCodeAt(0)==94;s&&(z('"[" negation from "^"'),e=e.substr(1));let l=!1,c=0;for(;;){if(e.length>0&&e.charCodeAt(0)==93&&c>0){z('"[" loop break at A'),e=e.substr(1);break}let u,d,m=e;if([d,e,u]=Ft(e),z('"[" loop getEsc(%o) => %o',m,[d,e,u]),!u)return z('"[" loop return at B from failed getEsc'),["",!1];let P=d;if(e.charCodeAt(0)==45&&([P,e,u]=Ft(e.substr(1)),!u))return["",!1];d<=o&&o<=P&&(l=!0),c++}if(l==s)return["",!1];break}case 63:if(t.charCodeAt(0)==q)return["",!1];let r=t.codePointAt(0),n=r<=65535?1:2;t=t.substr(n),e=e.substr(1);break;case 92:if(!we&&(z('"\\" consume'),e=e.substr(1),e.length==0))throw new ae;default:if(e.charCodeAt(0)!=t.charCodeAt(0))return z("[def] chunk[0] != s[0] (%o != %o) (0x%s != 0x%s) -- return",e[0],t[0],e.charCodeAt(0).toString(16),t.charCodeAt(0).toString(16)),["",!1];t=t.substr(1),e=e.substr(1),z("[def] s reduced to %o, chunk reduced to %o",t,e);break}}return[t,!0]}function Ft(e){let t=0,r="",n=e.charCodeAt(0);if(e.length==0||n==45||n==93)throw new ae;if(n==92&&!we&&(e=e.substr(1),e.length==0))throw new ae;t=e.codePointAt(0);let o=t<=65535?1:2;if(t==65535&&o==1)throw new ae;if(r=e.substr(o),r.length==0)throw new ae;return[t,r,!0]}function He(e){try{return qe(e)}catch(t){}return null}function Tt(e,t){return e=="."||e==""?t:e+se+t}function rn(e){let t=e.length-1,r=t;for(;r&&e.charCodeAt(r)===q;)--r;return r!=t&&(e=e.substr(0,r+1)),e.split(Vr).join(se)}});var D=bt((exports,module)=>{ht(exports);yt(exports,{TYPE:()=>TYPE,clock:()=>clock,expandTildePath:()=>expandTildePath,findInPATH:()=>findInPATH,fmtByteSize:()=>fmtByteSize,fmtDuration:()=>fmtDuration,getModulePackageJSON:()=>getModulePackageJSON,isCLI:()=>isCLI,isWindows:()=>isWindows,json:()=>json,jsonparse:()=>jsonparse,jsonparseFile:()=>jsonparseFile,repr:()=>repr,resolveModulePackageFile:()=>resolveModulePackageFile,runtimeRequire:()=>runtimeRequire,tildePath:()=>tildePath,tmpdir:()=>tmpdir});var Z=h(require("fs")),W=h(require("path")),Se=h(require("os")),At=h(require("perf_hooks")),Rt=h(require("util")),json=(e,t,r)=>JSON.stringify(e,r,t),clock=()=>At.performance.now(),isWindows=process.platform.startsWith("win"),TYPE=Symbol("TYPE"),runtimeRequire=eval("require"),isCLI=module.id=="."||process.mainModule.filename==__filename;function repr(e,t){let r={colors:$.ncolors>0};return typeof t=="object"?r={...t}:t!==void 0&&(r.compact=!t),(0,Rt.inspect)(e,r)}function resolveModulePackageFile(e){let t=runtimeRequire.resolve(e),r=W.dirname(W.resolve(t)),n=W.sep;for(;r!=n;){let o=W.join(r,"package.json");if(Z.existsSync(o))return o;r=W.dirname(r)}throw new Error(`package.json not found for module ${e}`)}function getModulePackageJSON(e){let t=resolveModulePackageFile(e);return jsonparseFile(t)}var _tmpdir="";function tmpdir(){return _tmpdir||(_tmpdir=Z.realpathSync.native(Se.tmpdir())),_tmpdir}function fmtDuration(e){return e>=59500?(e/6e4).toFixed(0)+"min":e>=999.5?(e/1e3).toFixed(1)+"s":e.toFixed(2)+"ms"}function fmtByteSize(e){return e>=1024*1e3?(e/(1024*1e3)).toFixed(1)+"MB":e>=1e3?(e/1024).toFixed(1)+"kB":e+"B"}function findInPATH(e){let t=isWindows?4294967295:Z.constants.X_OK,r=new Set((process.env.PATH||"").split(W.delimiter));for(let n of r){let o=W.join(W.resolve(n),e);for(isWindows&&(o+=".cmd");;){try{let i=Z.statSync(o);if(i.isSymbolicLink()){o=Z.realpathSync.native(o);continue}else if(i.isFile()&&i.mode&t)return o}catch(i){if(isWindows&&o.endsWith(".cmd")){o=W.join(W.resolve(n),e)+".exe";continue}}break}}return null}function jsonparse(e,t){try{return JSON.parse(json)}catch(r){return require("vm").runInNewContext("("+e+")",{},{filename:t,displayErrors:!0})}}function jsonparseFile(e){let t=Z.readFileSync(e,"utf8");try{return jsonparse(t)}catch(r){throw new Error(`failed to parse ${e}: ${r.message||r}`)}}function expandTildePath(e){let t=Se.homedir();return e=="~"?t:e.startsWith("~"+W.sep)?t+e.substr(1):e}function tildePath(e){let t=W.resolve(e),r=Se.homedir();return t.startsWith(r)?"~"+t.substr(r.length):t}});var Fr=h(require("esbuild")),oe=h(require("fs")),ei=h(require("os")),Ee=h(require("path")),fe=h(Ot());function Bt(e,t,r){}Bt.throws=!1;global.assert=Bt;var Dt=h(require("path"));function vt(e,t){let r=0;if(t===!0){let n=process.env.TERM||"";r=n&&["xterm","screen","vt100"].some(o=>n.indexOf(o)!=-1)?n.indexOf("256color")!=-1?8:4:2}else t!==!1&&e.isTTY&&(r=e.getColorDepth());return r}function Fe(e,t){return jt(vt(e,t),t)}function jt(e,t){let r=i=>`[${i}m`,n=e>0||t?(i,s)=>{let l=r(i),c=r(s);return u=>l+u+c}:i=>s=>s,o=e>=8?(i,s,l)=>{let c="["+s+"m",u="["+l+"m";return d=>c+d+u}:e>0?(i,s,l)=>{let c="["+i+"m",u="["+l+"m";return d=>c+d+u}:(i,s,l)=>c=>c;return{_hint:t,ncolors:e,reset:t||e>0?"e[0m":"",bold:n("1","22"),italic:n("3","23"),underline:n("4","24"),inverse:n("7","27"),white:o("37","38;2;255;255;255","39"),grey:o("90","38;5;244","39"),black:o("30","38;5;16","39"),blue:o("34","38;5;75","39"),cyan:o("36","38;5;87","39"),green:o("32","38;5;84","39"),magenta:o("35","38;5;213","39"),purple:o("35","38;5;141","39"),pink:o("35","38;5;211","39"),red:o("31","38;2;255;110;80","39"),yellow:o("33","38;5;227","39"),lightyellow:o("93","38;5;229","39"),orange:o("33","38;5;215","39"),reconfigure(i,s){let l=vt(i,s);return l!=this.ncolors&&s!=this._hint&&Object.assign(this,jt(l,s)),this}}}var $=Fe(process.stdout),le=Fe(process.stderr);var Ut=h(D());var $t=h(require("console"));var Y=h(require("path")),Oe=h(D()),J=(()=>{let e=process.env._,t=process.argv[1];if(!t)return e||process.argv[0];if(e&&!Y.isAbsolute(e))return e;let r="";if(e){let n=Y.basename(process.execPath);e.endsWith(Y.sep+n)&&(r=n+" ")}if(t.startsWith(process.cwd())){let n=Y.relative(process.cwd(),t);if(!n.startsWith("node_modules"+Y.sep)&&n.indexOf(Y.sep+"node_modules"+Y.sep)==-1)return Y.sep=="/"&&(n="./"+n),n}return r+Y.basename(t)})();function Be(e,t){let[r,n]=sn(t.flags.filter(u=>u)),o={},i=!1,s=[],l=0,c=()=>{s.push(e.splice(l,1)[0]),l--};for(;l<e.length;l++){let u=e[l];if(u=="--"){l++;break}if(u[0]!="-"){c();continue}u=u.replace(/^\-+/,"");let d=u.indexOf("="),m;d!=-1&&(m=u.substr(d+1),u=u.substr(0,d));let P=r.get(u);if(!P){if(u=="h"||u=="help")i=!0,t.help||(console.log(ze(n,t.usage,t.trailer)),process.exit(0));else if(t.unknownFlagAsArg){c();continue}else Ke([e[l]]);break}let T=!0;if(P.valueName){if(m===void 0)if(m=e[l+1],m!==void 0&&m[0]!="-")l++;else{console.error(`missing value for option -${u} (see ${J} -help)`),process.exit(1);break}try{T=P.valueParser?P.valueParser(m):m}catch(R){console.error(`invalid value for option -${u} (${R.message})`)}}else m!==void 0&&(console.error(`unexpected value provided for flag -${u}`),process.exit(1));o[u]=T;for(let R of P.names)R!=u&&(o[R]=T)}return l<e.length&&(s=s.concat(e.slice(l))),i&&t.help&&t.help(n,o,s),[o,s]}function Ke(e){console.error(`unknown option${e.length>1?"s":""} ${e.join(", ")} (see ${J} -help)`),process.exit(1)}function sn(e){let t=new Map,r=[];for(let n of e){let o=ln(n);r.push(o);for(let i of o.names){if(t.has(i))throw new Error(`duplicate CLI flag ${(0,Oe.json)(i)} in definition ${(0,Oe.json)(n)}`);t.set(i,o)}}return[t,r]}function ln(e){let t=o=>o.replace(/(?:^|[\s,])\-+/g,""),r=o=>o.split(/\s*,\s*/);if(typeof e=="string")return{names:r(t(e))};let n={names:typeof e[0]=="string"?r(t(e[0])):e[0].map(t),description:e[1]||void 0};if(e[2]){let[o,i]=e[2].replace(/^[<>]+|[<>]+$/g,"").split(/:/,2);if(i)switch(i.toLowerCase()){case"string":case"str":i="string";break;case"bool":case"boolean":i="boolean",n.valueParser=s=>(s=s.toLowerCase(),s!="false"&&s!="0"&&s!="no"&&s!="off");break;case"number":case"num":case"float":case"int":i="number",n.valueParser=s=>{let l=Number(s);if(isNaN(l))throw new Error(`${(0,Oe.json)(s)} is not a number`);return l};break;default:throw new Error(`invalid argument type "${i}"`)}else i="string";n.valueName=o||i,n.valueType=i}return n}function ze(e,t,r){let n={prog:J,"0":J},o=s=>s.replace(/\$(\w+)/g,(l,c)=>{let u=n[c];if(!u)throw new Error(`unknown variable $${c} (to print a dollar sign, use '\\$')`);return u}),i=o(t?typeof t=="function"?t():String(t):e.length>0?"Usage: $prog [options]":"Usage: $prog");if(e.length>0){i+=`
  options:
  `;let s=0,l=[];for(let c of e){let u="  -"+(c.valueName?c.names.join("=,-")+"="+(c.valueType=="boolean"?"on|off":"<"+c.valueName+">"):c.names.join(", -"));s=Math.max(s,u.length),l.push(u)}for(let c=0;c<e.length;c++){let u=e[c],d=l[c],m=u.description;u.description||(m=u.valueType?"Set ":"Enable "+u.names.reduce((P,T)=>T.length>P.length?T:P,"")),i+=`${d.padEnd(s," ")}  ${m}`,c+1<e.length&&(i+=`
  `)}}return r&&(i+=`
  `+o(r.replace(/[\n\s]+$/,""))),i}var V;(function(e){e[e.Silent=-1]="Silent",e[e.Error=0]="Error",e[e.Warn=1]="Warn",e[e.Info=2]="Info",e[e.Debug=3]="Debug"})(V||(V={}));var pe=console,Je,ue=new class{constructor(){this.SILENT=-1;this.ERROR=0;this.WARN=1;this.INFO=2;this.DEBUG=3;this.level=2;this.infoOnce=this.info;this.debug=an}error(...t){ue.level>=0&&(ve(t),pe.error(le.red(`${J}:`),...t))}warn(...t){ue.level>=1&&(ve(t),pe.error(le.magenta(`${J}:`),...t))}info(...t){ue.level>=2&&(ve(t),pe.log(...t))}get colorMode(){return Je}set colorMode(t){Je!==t&&(Je=t,t===void 0?pe=console:pe=new $t.Console({stdout:process.stdout,stderr:process.stderr,colorMode:t}))}},a=ue;function ve(e){typeof e[0]=="function"&&(e[0]=e[0]())}function an(...e){if(ue.level>=3){let t="";if(ve(e),e.length==0||e.length==1&&(e[0]===""||e[0]===void 0))return;pe.log($.bold($.blue(`[DEBUG${t}]`)),...e)}}var Ve={};yt(Ve,{_ts_check_file:()=>dn,file:()=>A,fileModificationLog:()=>Xe,fileModificationLogAppend:()=>me,fileWasModifiedRecentlyByUser:()=>cn,scandir:()=>Ze});var U=h(require("fs")),G=h(require("path")),Lt=h(require("crypto"));var re=h(require("fs")),je=h(D()),Mt=String.fromCharCode,un=(e,t)=>e.charCodeAt(t||0);function Nt(e,t){if(typeof t=="number")return re.chmodSync(e,t),t;let r=re.statSync(e).mode,n=Ae(r,t);return r!=n&&re.chmodSync(e,n),n}function Wt(e,t){return new Promise((r,n)=>{if(typeof t=="number")return re.chmod(e,t,o=>{o?n(o):r(t)});re.stat(e,(o,i)=>{if(o)return n(o);let s=Ae(i.mode,t);if(i.mode==s)return r(s);re.chmod(e,s,l=>{l?n(l):r(s)})})})}function Ae(e,t){let r="Expected format: [ugoa]*[+-=][rwx]+",n=(i,s)=>new Error(`${i} in modifier ${(0,je.json)(s)}. ${r}`),o=[];for(let i of Array.isArray(t)?t:[t])o=o.concat(i.trim().split(/\s*,+\s*/));for(let i of o){let s=[],l=!1,c=0,u=0;for(let m=0;m<i.length;m++){let P=un(i,m);if(c==0)switch(P){case 117:case 103:case 111:l||s.push(P);break;case 97:s=[117,103,111],l=!0;break;case 43:case 45:case 61:c=P;break;default:if(c==0)throw n(`Invalid target or operation ${(0,je.json)(Mt(P))}`,i);break}else switch(P){case 114:u|=4;break;case 119:u|=2;break;case 120:u|=1;break;default:throw n(`Invalid permission ${(0,je.json)(Mt(P))}`,i)}}if(c==0)throw n("Missing operation",i);s.length==0&&(s=[117]),u==0&&(u=4|2|1);let d=0;for(let m of s)switch(m){case 117:d|=u<<6;break;case 103:d|=u<<3;break;case 111:d|=u;break}switch(c){case 43:e|=d;break;case 45:e&=~d;break;case 61:e=d;break}}return e}var Pe=h(D());var Q=U.promises,Xe={};function me(e){Xe[G.resolve(String(e))]=(0,Pe.clock)()}function cn(e){let t=3e4,r=Xe[G.resolve(e)];return r!==void 0&&(0,Pe.clock)()-r<=t}var dn=A;function A(e,t){return Q.readFile(e,t)}A.editMode=Ae;A.chmod=(e,t)=>(me(e),Wt(e,t));function fn(e,t){return Q.readFile(e,t)}A.read=fn;function pn(e,t){return U.readFileSync(e,t)}A.readSync=pn;A.stat=Q.stat;function mn(...e){return Promise.all(e.map(t=>Q.stat(t).then(r=>r.mtimeMs).catch(r=>null))).then(t=>t.length==1?t[0]:t)}A.mtime=mn;A.readall=(...e)=>Promise.all(e.map(t=>Q.readFile(t)));A.readallText=(e,...t)=>Promise.all(t.map(r=>Q.readFile(r,{encoding:e||"utf8"})));A.write=async(e,t,r)=>{me(e);let n=r&&typeof r=="object"?r:{};try{await Q.writeFile(e,t,r)}catch(o){if(!n.mkdirOff&&o.code=="ENOENT")await A.mkdirs(G.dirname(String(e)),n.mkdirMode),await Q.writeFile(e,t,r);else throw o}if(n.log){let o=G.relative(process.cwd(),String(e));o.startsWith(".."+G.sep)&&(o=(0,Pe.tildePath)(e)),a.info($.green(`Wrote ${o}`))}};A.writeSync=(e,t,r)=>{me(e),U.writeFileSync(e,t,r)};function gn(e,t){return new Promise((r,n)=>{let o=U.createReadStream(e),i=Lt.createHash("sha1");o.on("error",n),o.on("end",()=>{i.end(),r(t?i.digest(t):i.digest())}),o.pipe(i)})}A.sha1=gn;A.copy=(e,t,r)=>{let n=U.constants.COPYFILE_FICLONE;return r&&(n|=U.constants.COPYFILE_EXCL),me(t),Q.copyFile(e,t,n)};A.move=(e,t)=>(me(t),Q.rename(e,t));A.mkdirs=(e,t)=>Q.mkdir(e,{recursive:!0,mode:t}).then(r=>!!r&&r.length>0);async function Ze(e,t,r){if(r||(r={}),!U.promises||!U.promises.opendir)throw new Error("scandir not implemented for nodejs <12.12.0");let n=[],o=new Set,i=r.recursive!==void 0?r.recursive?Infinity:0:r.depth!==void 0?r.depth:Infinity;async function s(c,u,d){if(o.has(c))return;o.add(c);let m=await U.promises.opendir(c);for await(let P of m){let T=P.name;P.isDirectory()?i<d&&await s(G.join(c,T),G.join(u,T),d+1):(P.isFile()||P.isSymbolicLink())&&t&&t.test(T)&&n.push(G.join(u,T))}}let l=Array.isArray(e)?e:[e];return Promise.all(l.map(c=>s(G.resolve(c),".",0))).then(()=>n.sort())}var hn=__dirname;function Gt(e){let t=null;return function(){return t||(ue.debug(`loading ${e} module`),t=(0,Ut.runtimeRequire)(Dt.join(hn,e)),t.initModule(ue.level,Ve)),t}}var ge=Gt("debug.js"),Qe=Gt("watch.js");var ce=class extends Error{constructor(t){super(t);this.name="UserError"}};function qt(e,t){return ge().bugReportMessage(e,t)}function Yt(e,t){return ge().printErrorAndExit(e,t)}function Ht(e,t){Error.prepareStackTrace=void 0;try{if(ge().installSourceMapSupport(),Error.prepareStackTrace!==Ht)return Error.prepareStackTrace(e,t)}catch(r){}return e.stack||String(e)}Error.prepareStackTrace=Ht;process.on("uncaughtException",Yt);process.on("unhandledRejection",(e,t)=>{Yt(e||"PromiseRejection","unhandledRejection")});var y=h(D());var bn=h(D()),uo=new Map,co=Symbol("isMemoized");var Kt=!!process.stdout.isTTY,yn=!!process.stderr.isTTY,ne={width:60,height:20,clear(){},banner(e){return e||(e="-"),e.repeat(Math.floor((ne.width-1)/e.length))}};if(Kt||yn){let e=Kt&&process.stdout||process.stderr,t=()=>{ne.width=e.columns,ne.height=e.rows};e.on("resize",t),t(),ne.clear=()=>{e.write("c")}}var nt=h(require("path")),bo=h(require("fs")),Zt=h(require("child_process")),be=h(D());var ee=h(require("path")),zt=h(require("fs")),Re=h(D());var Jt=Symbol("TS_CONFIG_FILE"),Vt=Symbol("TS_CONFIG"),{dirname:xn,basename:go}=ee;function Xt(e){let t="",r=process.cwd(),n=Re.isWindows?"tsc.cmd":"tsc";e&&process.chdir(e);try{t=require.resolve("typescript")}catch(o){}if(e&&process.chdir(r),t){let o=ee.sep+"node_modules"+ee.sep,i=t.indexOf(o);if(i!=-1)return ee.join(t.substr(0,i+o.length-ee.sep.length),".bin",n)}return n}function tt(e,t){for(let r of et(e,t))try{if(zt.statSync(r).isFile())return r}catch(n){}return null}function*et(e,t){e=ee.resolve(e);let r=ee.parse(e).root;for(t=t?ee.resolve(t):r;yield ee.join(e,"tsconfig.json"),!(e==t||(e=xn(e),e==r)););}function rt(e){let t=e.cwd||process.cwd();return e.entryPoints&&e.entryPoints.length>0&&(t=ee.resolve(t,ee.dirname(e.entryPoints[0]))),t}function he(e){let t=e[Jt];if(t===void 0){if(e.tslint==="off"||e.tslint===!1||e.tsc==="off"||e.tsc===!1)t=null;else{let r=rt(e);t=tt(r,e.cwd)}Object.defineProperty(e,Jt,{value:t})}return t}function Ce(e){let t=e[Vt];if(t===void 0){let r=he(e);if(r)try{t=(0,Re.jsonparseFile)(r)}catch(n){a.warn(()=>`failed to parse ${r}: ${n.stack||n}`)}t||(t=null),Object.defineProperty(e,Vt,{value:t})}return t}var{dirname:wn,basename:To}=nt,ot={6031:"IGNORE",6194:"IGNORE",6133:"WARNING",2531:"WARNING",7006:"WARNING",7015:"WARNING",7053:"WARNING"},Qt=0,er=1,tr=2,Sn=3,rr={IGNORE:Qt,INFO:er,WARNING:tr,ERROR:Sn};function nr(e,t){for(let r of Object.keys(t)){let n=rr[String(t[r]).toUpperCase()];if(n===void 0)throw new ce(`Invalid value for TS rule ${r}: ${(0,be.json)(n)} -- expected value to be one of: `+Object.keys(rr).map(be.json).join(", "));e[r]=n}}function it(e){e||(e={});let t={cancelled:!1,cancel(){}},r=new Promise((n,o)=>{if(e.mode=="off")return n(!0);let i=e.cwd||process.cwd(),s=e.tsconfigFile;if(s===void 0&&(s=tt(e.srcdir?nt.resolve(i,e.srcdir):i)),e.mode!="on"&&!s)return n(!0);let l=e.format?e.format.toLowerCase():"",c=l.startsWith("short"),u=l.startsWith("short"),d=l=="short-all",m=Xt(e.cwd);if(m=="tsc"&&e.mode!="on"&&!(m=(0,be.findInPATH)(m)))return a.warn("tsc not found in node_modules or PATH. However a tsconfig.json file was found in "+nt.relative(process.cwd(),wn(s))+'. Set tslint options.tslint="off" or pass -no-diag on the command line to disable tsc.'),n(!0);let P={};nr(P,ot),e.rules&&nr(P,e.rules);let T=["--noEmit",e.colors&&"--pretty",e.watch&&"--watch",s&&"--project",s].concat(e.args||[]).filter(S=>S);a.debug(()=>`spawning process ${m} ${(0,be.json)(T,2)}`);let R=(0,Zt.spawn)(m,T,{stdio:["inherit","pipe","inherit"],cwd:i}),L=()=>{try{R.kill()}catch(S){}};process.on("exit",L),t.cancel=()=>{R.kill()};let f=S=>S,g=$.orange,C=$.red,k=$.green,F=Buffer.from(" TS"),_=Buffer.from("Found "),B=Buffer.from("c"),E=Buffer.from("tarting compilation"),H=Buffer.from("tarting incremental compilation"),O=[],p=0,b=!1,x={errors:0,warnings:0,other:0,reset(){this.errors=0,this.warnings=0,this.other=0}},I=!1;function w(){if(!e.quiet||x.errors>=0){e.watch&&console.log(ne.banner("\u2014"));let S=[];x.errors>0?S.push(C("TS: "+Ue("$ error","$ errors",x.errors))):S.push(k("TS: OK")),x.warnings>0&&S.push(g(Ue("$ warning","$ warnings",x.warnings))),x.other>0&&S.push(Ue("$ message","$ messages",x.other)),console.log(S.join("   ")),e.watch&&console.log(ne.banner("\u2014"))}b=x.errors>0,e.onEnd&&e.onEnd(x),x.reset(),I=!0}function K(S){let v=O.slice();if(O.length=0,p==0){let j=0,N=v[j++];for(;N.length==0||N[0]==10&&j<v.length;)N=v[j++];if(N.includes(E)||N.includes(H))return x.reset(),S&&w();if(v.every(ie=>ie.length<=1))return S&&w()}else{let j=/(?:\x1b\[\d+m|)error(?:\x1b\[\d+m|)/g,N=v.shift().toString("utf8");switch(P[p]){case Qt:return S&&w();case er:N=N.replace(j,f("info")),c?v=[]:Ie(v,f),x.other++;break;case tr:N=N.replace(j,g("warning")),u?v=[]:Ie(v,g),x.warnings++;break;default:d&&(v=[]),j.test(N)?x.errors++:x.other++;break}process.stdout.write(N)}v.forEach(j=>process.stdout.write(j)),S&&w()}function Ie(S,v){for(let j=1;j<S.length;j++){let N=S[j];if(N.includes(126)){let ie=N.toString("utf8");ie=ie.replace(/\x1b\[\d+m(\s*~+)/g,v("$1")),S[j]=ie}}}function Ue(S,v,j){return(j==1?S:v).replace(/\$/g,j)}Pn(R.stdout,(S,v)=>{if(e.clearScreen||(S=Lr(S)),v){S.length>0&&O.push(S),O.length>0&&K();return}if(I&&S.length>1&&(I=!1,e.onRestart&&e.onRestart()),S.includes(_)){let j=Wr(S.toString("utf8"));if(/^(?:\[[^\]]+\] |[\d\:PAM \-]+|)Found \d+ error/.test(j)){K(!0),p=0;return}else K(!1);p=0}else if(S.includes(F)){let j=S.toString("utf8"),N=/(?:\x1b\[\d+m|)error(?:\x1b\[\d+m\x1b\[\d+m|) TS(\d+)\:/.exec(j),ie=N?parseInt(N[1]):0;ie>0&&!isNaN(ie)&&(O.length>0&&K(),p=ie)}O.push(S)}),R.on("close",S=>{process.removeListener("exit",L),n(!b)});function Wr(S){return S.replace(/\x1b\[\d+m/g,"")}function Lr(S){let v=S.indexOf(B);return v==-1?S:v==0?S.subarray(3):Buffer.concat([S.subarray(0,v),S.subarray(v+3)],S.length-3)}});return r.cancel=()=>(t.cancelled||(t.cancelled=!0,t.cancel()),r),r}var Cn=Buffer.allocUnsafe(0);function Pn(e,t){let r=[],n=0,o=s=>{let l=0;for(;;){let c=s.indexOf(10,l);if(c==-1){if(l<s.length-1){let d=s.subarray(l);r.push(d),n+=d.length}break}c++;let u=s.subarray(l,c);n>0&&(u=Buffer.concat(r.concat(u),n+u.length),r.length=0,n=0),t(u,!1),l=c}},i=()=>{r.length>0?t(Buffer.concat(r,n),!0):t(Cn,!0)};e.on("data",o),e.on("close",i),e.on("end",i)}var br=h(require("fs"));var dt=h(D());var te=h(require("fs")),dr=h(require("os")),fr=h(require("child_process")),pr=h(require("stream"));var _n=h(require("fs")),ye=h(D());function or(e){return e&&e.read}function ir(e){return e&&e.write}var st=Buffer.allocUnsafe(0);function sr(e){return e&&typeof e=="object"&&e[ye.TYPE]=="Reader"}function $e(e){return e?new lr(e):Tn}function lt(e){return e?{[ye.TYPE]:"Writer",stream:e}:En}var Fo,Tn=new class{constructor(){this[Fo]="Reader"}_E(){return new Error("stream not readable")}get stream(){throw this._E()}[(Fo=ye.TYPE,Symbol.asyncIterator)](){throw this._E()}read(){return Promise.reject(this._E())}},Bo,ar,En=new(ar=class{constructor(){this[Bo]="Writer"}_E(){return new Error("stream not writable")}get stream(){throw this._E()}},Bo=ye.TYPE,ar),vo,lr=class{constructor(t){this[vo]="Reader";this._ended=!1;this.stream=t,t.pause(),t.once("end",()=>{this._ended=!0})}[(vo=ye.TYPE,Symbol.asyncIterator)](){return this.stream[Symbol.asyncIterator]()}async read(t,r){let n=this.stream;if(n.pause(),typeof t=="string")r=t,t=Number.MAX_SAFE_INTEGER;else if(t==null||t<0)t=Number.MAX_SAFE_INTEGER;else if(t==0)return r?"":st;if(n.readable){let l=n.read(this._ended?void 0:t);if(l)return r?l.toString(r):l}if(this._ended)return r?"":st;let o=[],i=0;if(n.readable){let l=n.read();l&&(o.push(l),i+=l.length)}for(;i<t&&!this._ended;){await new Promise((c,u)=>{n.once("error",u),n.once("end",c),n.once("readable",c)});let l=n.read(t-i);l||(l=n.read()),l&&(o.push(l),i+=l.length)}let s=ur(o);return r?s.toString(r):s}};function ur(e,t){return e.length==0?st:e.length==1?e[0]:Buffer.concat(e,t)}function at(){let e=[],t=0,r=e.push;return e.push=n=>(t+=n.length,r.call(e,n)),e.buffer=()=>ur(e,t),e}function ut(e){return ge().libuv_errors[e]||""}function cr(e,t,r){let n=setTimeout(()=>{let o=new Error("timeout");o.name="Timeout",r(o)},t);return e.then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}var de=h(D());var mr="process not started",Me=class{constructor(t,...r){this.dir="";this.env={...process.env};this.shell=!1;this.stdin=null;this.stdout=null;this.stderr=null;this.extraFiles=[];this.windowsHide=!0;this.process=null;this.running=!1;this.pid=0;this.exitCode=-1;this._resolve=()=>{};this._reject=()=>{};this._onerror=t=>{a.debug(()=>`${this} error:
  ${t.stack||t}`),this._reject(t)};this._onexit=(t,r)=>{let n=this;a.debug(()=>`${n} exited status=${t} signal=${r}`),n.running=!1,t===null||r!==null?(assert(typeof r=="string"),n.exitCode=-(dr.constants.signals[r]||1)):n.exitCode=t||0,n._resolve(n.exitCode)};this.command=t,this.args=r,this.promise=Promise.reject(new Error(mr)),this.promise.catch(n=>{})}start(){return null}run(t){return this.start(),this.wait(t)}output(t,r){this.stdout="pipe",this.stderr||(this.stderr="pipe");let{stdout:n,stderr:o}=this.start(),i=at(),s=at();return n.stream.on("data",l=>{i.push(l)}),o&&o.stream.on("data",l=>{s.push(l)}),this.wait(r||0).then(l=>{if(l!=0){let u="",d=s.buffer();try{u=d.toString("utf8")}catch(m){u=d.toString("ascii")}throw u.length>0&&(u=`. stderr output:
  `+u),new Error(`command exited with status ${l}${u}`)}let c=i.buffer();return t?c.toString(t):c})}wait(t,r){return t===void 0||t<=0?this.promise:this._waitTimeout(t,(n,o,i)=>(a.debug(()=>`${this} wait timeout reached; killing process`),n.message="Cmd.wait timeout",this.kill(r).then(()=>i(n))))}signal(t,r){let n=this._checkproc();if(r=="group")try{return process.kill(-n.pid,t),!0}catch(o){}return n.kill(t)}async kill(t="SIGTERM",r=500,n){let o=this._checkproc();return this.signal(t,n||"group")?r<=0?this.promise:this._waitTimeout(r,(i,s)=>(a.debug(()=>`${this} kill timeout reached; sending SIGKILL`),o.kill("SIGKILL"),this.promise.then(s))):o.exitCode||0}toString(){return this.process?`Cmd[${this.pid}]`:"Cmd"}_checkproc(){if(!this.process)throw new Error(mr);return this.process}_rejectAndKill(t){this._reject(t)}_waitTimeout(t,r){return new Promise((n,o)=>{let i=!1;return this.promise.then(s=>{i||n(s)}),cr(this.promise,t,s=>{i=!0,r(s,n,o)})})}};Me.prototype.start=function(){let t=this;if(t.running)throw new Error("start() called while command is running");t.exitCode=-1,t.promise=new Promise((l,c)=>{t._resolve=l,t._reject=c});let r=null,n=null;t.stdin instanceof Buffer?r="pipe":sr(t.stdin)?typeof t.stdin.stream.fd=="string"?r=t.stdin.stream:(r="pipe",n=t.stdin.stream):r=t.stdin;let o={stdio:[r||"ignore",t.stdout===process.stdout?1:t.stdout||"ignore",t.stderr===process.stderr?2:t.stderr?t.stderr:"ignore",...t.extraFiles],cwd:t.dir?(0,de.expandTildePath)(t.dir):void 0,env:t.env,shell:t.shell,windowsHide:t.windowsHide,detached:!de.isWindows},i=fr.spawn(t.command,t.args,o);if(i.pid===void 0){t.process=null,t.pid=0;let l=In(t);throw t._reject(l),l}if(t.running=!0,t.process=i,t.pid=i.pid,i.on("exit",t._onexit),i.on("error",t._reject),a.debug(()=>`${t} started (${(0,de.repr)(t.command)})`),i.stdin)if(t.stdin instanceof Buffer){let l=new pr.PassThrough;l.end(t.stdin),l.pipe(i.stdin),i.stdin=null}else n&&(n.pipe(i.stdin),i.stdin=null);return!i.stdin&&!i.stdout&&!i.stderr&&i.stdio.length<4?null:{stdin:i.stdin?lt(i.stdin):null,stdout:i.stdout?$e(i.stdout):null,stderr:i.stderr?$e(i.stderr):null,extraFiles:i.stdio.slice(3).map(l=>or(l)?$e(l):ir(l)?lt(l):null)}};function In(e){let t="",r="unspecified error";if(e.shell==!1){try{te.accessSync(e.dir,te.constants.R_OK|te.constants.X_OK),(te.statSync(e.command).mode&te.constants.S_IFREG)==0?t="EACCES":t="EIO"}catch(o){t=o.code||"ENOENT"}r=ut(t)||r}if(!t){try{te.accessSync(e.dir,te.constants.R_OK|te.constants.X_OK),t="EIO"}catch(o){t=o.code||"ENOENT"}r=ut(t)||r,t&&(r=r+"; cmd.dir="+(0,de.repr)(e.dir))}t||(t="UNKNOWN");let n=new Error(`failed to spawn process ${(0,de.repr)(e.command)} (${t} ${r})`);return n.code=t,n}var ct=h(require("fs")),gr=h(require("os")),hr=new Map;function _e(e,t){let r=o=>ct.writeSync(process.stderr.fd,o+`
  `),n=hr.get(e);if(n)n.listeners.add(t);else{let o=new Set([t]),i=s=>{s=="SIGINT"&&ct.writeSync(1,`
  `);try{for(let l of o)l(s)}catch(l){r(`error in signal listener: ${l.stack||l}`)}process.exit(-(gr.constants.signals[s]||1))};process.on(e,i),hr.set(e,{rootListener:i,listeners:o})}}var yr=!1,xr=!1,Ne=new Set;function kn(){if(yr)return;yr=!0,process.on("beforeExit",t=>ft(!1)),process.on("exit",t=>ft(!1));let e=t=>ft(!1);_e("SIGINT",e),_e("SIGHUP",e),_e("SIGTERM",e),_e("SIGPIPE",e)}function ft(e){if(xr)return;xr=!0;let t=r=>br.writeSync(process.stderr.fd,r+`
  `);try{for(let r of Ne)if(r.cmd.running)try{r.cmd.signal("SIGTERM")}catch(n){}Ne.clear()}catch(r){t(`ignoring error in run.atexit: ${r.stack||r}`)}}function Sr(e){if(!e.run)return;a.debug(()=>`run.configure run=${(0,dt.repr)(e.run)}`);let t=new wr(e);Ne.add(t);let r=e.onEnd;e.onEnd=async(n,o,i)=>{if(await t.onEndBuild(o),typeof r=="function")return r(n,o,i)},kn()}function Pr(){return Promise.all(Array.from(Ne).map(e=>e.cmd.promise)).then(e=>e.reduce((t,r)=>Math.max(t,r),0))}var wr=class{constructor(t){this._logOnExit=!0;if(this.config=t,this.cmd=new Me(""),this.cmd.stdout="inherit",this.cmd.stderr="inherit",this.cmd.env.ESTRELLA_PATH=__filename,this.cmd.env.ESTRELLA_VERSION="1.4.0",typeof t.run=="string")this.cmd.command=t.run,this.cmd.shell=!0,this.cmdname=t.run;else if(typeof t.run=="boolean"){if(!t.outfile)throw new ce("please set config.outfile=<file> or config.run=<file>");this.cmd.command=process.execPath,this.cmd.args=[t.outfileAbs],this.cmdname=t.outfile}else{if(!t.run||t.run.length==0)throw new ce("config.run is an empty list");this.cmd.command=t.run[0],this.cmd.args=t.run.slice(1),this.cmdname=t.run.join(" "),this.cmdname.length>60&&(this.cmdname=this.cmdname.substr(0,57)+"...")}}async onEndBuild(t){if(t.errors.length>0)return;let r=this.cmd,n=$.pink,o=r.running;r.running&&(this._logOnExit=!1,a.debug(()=>`Stopping ${this.cmdname} [${r.pid}] ...`),await r.kill()),a.debug(()=>`Starting command ${(0,dt.repr)([r.command,...r.args])}`),r.start(),this.config.watch&&(a.info(()=>n(`${o?"Restarted":"Running"} ${this.cmdname} [${r.pid}]`)),this._logOnExit=!0,r.promise.then(i=>{this._logOnExit&&a.info(()=>n(`${this.cmdname} exited (${i})`))}))}};var We=h(D());function Cr(e){let t=e;if(!t){a.debug("typescript API requested; attempting to load typescript module");try{let f=require;if(t=f("typescript"),parseFloat(t.versionMajorMinor)<3.5)return a.warn(`typescript ${t.version} is too old; disabling "ts" API.
    You are seeing this message because you are importing the ts API.
    Either install a more recent version of typescript or remove the ts import.`),null;a.debug(()=>`loaded typescript ${t.version} from ${(0,We.tildePath)(f.resolve("typescript"))}`)}catch(f){return a.debug(()=>"failed to load typescript; module unavailable"),null}}let r=new Map;function n(f){let g=(0,We.json)(Object.keys(f).sort().map(_=>[_,f[_]])),C=r.get(g);if(C)return a.debug("ts.getCompilerHost cache hit"),C;f={newLine:t.NewLineKind.LineFeed,...f};let F=[t.createCompilerHost(f,!0),f];return r.set(g,F),a.debug("ts.getCompilerHost cache miss"),F}async function o(f,g){let C=typeof f=="string"?{"/<source>/a.ts":f}:f,k=Object.keys(C),[F,_]=n(g||{}),B=F.readFile;F.readFile=O=>O in C?C[O]:B(O);let E=t.createProgram(k,_,F);if(typeof f=="string")return E.getSourceFile(k[0]);let H={};for(let O of k)H[O]=E.getSourceFile(O);return H}async function i(f,g){return s(f,g)}function s(f,g){let[C,k]=n(g||{}),_=t.createProgram([f],k,C).getSourceFile(f);if(!_)throw new Error(`${f}: file not found`);return _}function l(f,g,C){return c(f,[g],C).then(k=>k[0])}async function c(f,g,C){let k=s(f,C);return u(k,g)}function u(f,g){let C=T(f),k=new Map,F=[];for(let _ of g||C.keys()){let B=C.get(_);if(!B){F.push(null);continue}F.push(d(f,B,C,k))}return F}function d(f,g,C,k){let F=k.get(g);if(F)return F;let _={heritage:[],name:g.name.escapedText,props:{},computedProps(){let B={};for(let E of _.heritage)Object.assign(B,E.props);return Object.assign(B,_.props),B},lookupProp(B){let E=_.props[B];if(!E){for(let H of _.heritage)if(E=H.lookupProp(B))break}return E}};if(k.set(g,_),g.heritageClauses)for(let B of g.heritageClauses)for(let E of B.types){let H=E.expression;if(t.isIdentifier(H)){let O=C.get(H.escapedText);O&&_.heritage.push(d(f,O,C,k))}}return g.forEachChild(B=>{if(t.isPropertySignature(B)){let E=m(B,f,_);_.props[E.name]=E}}),_}function m(f,g,C){let k=t.getLineAndCharacterOfPosition(g,f.pos),F=null,_=f.type,E={name:P(f.name),type:_,get typestr(){return F===null&&(F=_?L(_,g):"any"),Object.defineProperty(E,"typestr",{enumerable:!0,value:F}),F},srcfile:g.fileName,srcline:k.line,srccol:k.character,parent:C};return E}function P(f){switch(f.kind){case t.SyntaxKind.Identifier:case t.SyntaxKind.PrivateIdentifier:return f.escapedText;case t.SyntaxKind.StringLiteral:case t.SyntaxKind.NumericLiteral:return f.text;case t.SyntaxKind.ComputedPropertyName:return"[computed]";default:return"?"}}function T(f){let g=new Map;return t.forEachChild(f,C=>{C.kind==t.SyntaxKind.InterfaceDeclaration&&g.set(C.name.escapedText,C)}),g}let R=t.createPrinter({removeComments:!0,newLine:t.NewLineKind.LineFeed,omitTrailingSemicolon:!0,noEmitHelpers:!0});function L(f,g){if(!g){let C=f;for(;C.kind!=t.SyntaxKind.SourceFile;)if(C=C.parent,!C)throw new Error("node without SourceFile parent (provide file to ts.fmt)");g=C}return R.printNode(t.EmitHint.Unspecified,f,g)}return{ts:t,getCompilerHost:n,parse:o,parseFile:i,interfaceInfo:l,interfacesInfo:c,interfacesInfoAST:u,fmt:L}}var _r={version:"0.9.0",BuildOptions:new Set(["sourcemap","sourcesContent","format","globalName","target","minify","minifyWhitespace","minifyIdentifiers","minifySyntax","charset","treeShaking","jsxFactory","jsxFragment","define","pure","keepNames","color","logLevel","logLimit","bundle","splitting","preserveSymlinks","outfile","metafile","outdir","outbase","platform","external","loader","resolveExtensions","mainFields","conditions","write","tsconfig","outExtension","publicPath","chunkNames","assetNames","inject","banner","footer","incremental","entryPoints","stdin","plugins","absWorkingDir","nodePaths","watch"])},Tr={BuildConfig:new Set(["entry","debug","watch","cwd","quiet","silent","clear","tslint","onStart","onEnd","outfileMode","run","tsc","tsrules","title"])};var Te=h(require("path"));var Er=h(require("crypto"));function Le(e,t){let r=Er.createHash("sha1").update(e);return t?r.digest(t):r.digest()}var Ir=h(D());function kr(e,t){let r=!1,n=!1,o=!1,i=!1,s="";function l(d){let m=[d.cwd,d.outfile||"",...Array.isArray(d.entryPoints)?d.entryPoints:d.entryPoints?[d.entryPoints]:[]].join(Te.delimiter);return Fn(Le(Buffer.from(m,"utf8")))}let c="",u=Object.create({get outfileAbs(){return s},setOutfile(d){u.outfile=d,s=d&&d!="-"?Te.resolve(u.cwd,d):""},get projectID(){return c},updateProjectID(){return c=l(u),c},get buildIsCancelled(){return r},set buildIsCancelled(d){r=d},get outfileIsTemporary(){return n},set outfileIsTemporary(d){n=d},get outfileCopyToStdout(){return o},set outfileCopyToStdout(d){o=d},get metafileIsTemporary(){return i},set metafileIsTemporary(d){i=d}});return Object.assign(u,e),u.cwd=e.cwd?Te.resolve(e.cwd):!Ir.isCLI&&process.mainModule?process.mainModule.path:t,u.setOutfile(e.outfile||""),u.updateProjectID(),u}function Fn(e){let t="";for(let r=0;r<e.length;r+=4)t+=e.readUInt32LE(r).toString(36);return t}var{dirname:pt,basename:On}=Ee,xe={usage:"usage: $0 [options]",flags:[["-w, watch","Watch source files for changes and rebuild."],["-g, debug","Do not optimize and define DEBUG=true."],["-r, run","Run the output file after a successful build."],["-sourcemap","Generate sourcemap."],["-inline-sourcemap","Generate inline sourcemap."],["-no-color","Disable use of colors."],["-no-clear","Disable clearing of the screen, regardless of TTY status."],["-no-diag","Disable TypeScript diagnostics."],["-color","Color terminal output, regardless of TTY status."],["-diag","Only run TypeScript diagnostics (no esbuild.)"],["-quiet","Only log warnings and errors but nothing else."],["-silent","Don't log anything, not even errors."],["-estrella-version","Print version of estrella and exit 0."],["-estrella-debug","Enable debug logging of estrella itself."]]},Bn={usage:"usage: $0 [options] <srcfile> ...",flags:xe.flags.concat([["-o, outfile","Write output to <file> instead of stdout.","<file>"],["-bundle","Include all dependencies."],["-minify","Simplify and compress generated code."],["-outdir","Write output to <dir> instead of stdout.","<dir>"],["-esbuild","Pass arbitrary JSON to esbuild's build function.","<json>"]]),trailer:`
  Example of using estrella without a build script:
    $0 -o out/app.js main.ts
      This compile main.ts and writes the output to out/app.js
  
  Example of using estrella with a build script:
    1. Create a file called build.js with the following contents:
         #!/usr/bin/env node
         const { build } = require("estrella")
         build({
           entry: "main.ts",
           outfile: "out/main.js",
         })
    2. Make that file executable and run it:
         chmod +x build.js
         ./build.js
    You can now customize your build behavior by changing build.js.
    Try ./build.js -help
  
  See https://github.com/rsms/estrella#readme for documentation.
    `},mt=Promise.resolve(),M={},X=[],De=Symbol("IS_MAIN_CALL");var Or=!1;function Br(e){if(!Or){Or=!0;let t=e||1;process.exitCode=t,process.on("exit",r=>{process.exit(r||t)})}}function vn(e){if(a.debug(()=>`input config ${(0,y.repr)(e)}`),e.entryPoints||(e.entryPoints=[]),e.entry&&(Array.isArray(e.entry)?e.entryPoints=e.entryPoints.concat(e.entry):e.entryPoints.push(e.entry)),delete e.entry,e.entryPoints.length==0&&(a.debug(()=>"missing entryPoints; attempting inference"),e.entryPoints=vr(e),e.entryPoints.length==0)){let t=Ce(e)?" (could not guess from tsconfig.json)":"";throw new ce(`config.entryPoints is empty or not set${t}`)}if(e.sourcemap?e.sourcemap!="inline"&&e.sourcemap!="external"&&(e.sourcemap=!0):e.sourcemap=!1,!e.outfile&&!e.outdir){e.setOutfile("-");let t=e.updateProjectID();e.setOutfile(Ee.join((0,y.tmpdir)(),`esbuild.${t}.out.js`)),e.outfileIsTemporary=!0}e.updateProjectID(),a.debug(()=>`effective config for project#${e.projectID}: ${(0,y.repr)(e)}`)}function jn(e,t){let r=(0,y.clock)(),n=JSON.parse(oe.readFileSync(e));for(let o in t){let i=t[o];i===void 0?delete n[o]:(typeof i=="function"&&(i=i(n[o])),n[o]=i)}oe.writeFileSync(e,JSON.stringify(n)),a.debug(()=>`patched source map ${e} with overrides ${(0,y.repr)(t)} (${(0,y.fmtDuration)((0,y.clock)()-r)})`)}function vr(e){let t=Ce(e);if(t){if(a.debug(()=>`tsconfig file found at ${he(e)}`),t.files)return t.files;if(t.include){let r=[];for(let n of t.include)a.debug(`guessing entry points: glob.glob(${n}) =>`,fe.glob(n)),r=r.concat(fe.glob(n));if(t.exclude)for(let n of t.exclude)r=r.filter(o=>!fe.match(n,o));return r.slice(0,1)}}return[]}function An(e){let t={},r={},n={name:"globalName"};for(let o of Object.keys(e))Tr.BuildConfig.has(o)||(_r.BuildOptions.has(o)||(r[o]=e[o]),o=n[o]||o,t[o]=e[o]);return Object.keys(r).length>0&&a.info(`Notice: Potentially invalid esbuild.BuildOption(s): ${(0,y.repr)(r)}
  `+qt("guess",(0,y.json)(Object.keys(r)))),t.outfile||delete t.outfile,t}var jr=new Set;function Rn(...e){if(a.level>=a.INFO){let t=e.join(" ");jr.has(t)||(jr.add(t),a.info(...e))}}function Ar(e){e=kr(e||{},e[De]?process.cwd():process.mainModule&&pt(process.mainModule.filename)||__dirname);let t={resolve(){},reject(){}},r=[];function n(l){e.isCancelled?l():r.push(l)}function o(l){if(!e.isCancelled){a.debug("build cancelled",{reason:l}),e.isCancelled=!0;for(let c of r)c&&c();r.length=0,l?t.reject(l):t.resolve(!0)}}let i={addCancelCallback:n,buildCounter:0,rebuild(){return a.warn("rebuild() called before initial build completed. Ignoring"),Promise.resolve(!0)}},s=mt.then(()=>new Promise((l,c)=>{if(e.isCancelled)return a.debug("build cancelled immediately"),!1;t.resolve=l,t.reject=c,$n(e,i).then(l).catch(c)}));return s.rebuild=()=>i.rebuild(),Object.defineProperty(s,"buildCounter",{get(){return i.buildCounter}}),s.cancel=o,s}async function $n(e,t){let r=De in e;delete e[De];let n=M,o=X;if(e.run===void 0&&(e.run=n.run),e.outfile=="-"||n.outfile=="-"||r&&!n.outfile&&!n.outdir){e.setOutfile("-");let p=e.updateProjectID();n.outfile=Ee.join((0,y.tmpdir)(),`esbuild.${p}.out.js`),e.setOutfile(n.outfile),e.outfileIsTemporary=!0,e.outfileCopyToStdout=!0}if(!r)vn(e);else{if(o.length==0){let p=vr(e);a.debug(()=>`no input files provided; best guess: ${(0,y.repr)(p)}`),p.length==0&&(a.error(`missing <srcfile> argument (see ${J} -help)`),process.exit(1)),o.splice(o.length-1,0,...p);let b=Ce(e);!n.outfile&&!n.outdir&&b&&(n.outfile=b.outFile,n.outfile||(n.outdir=b.outDir)),o.length==0&&(a.error(`missing <srcfile> argument (see ${J} -help)`),process.exit(1))}if(e.setOutfile(n.outfile||void 0),e.entryPoints=o,e.outdir=n.outdir||void 0,e.bundle=n.bundle||void 0,e.minify=n.minify||void 0,n.esbuild){let p=(0,y.jsonparse)(n.esbuild,"-esbuild");if(!p||typeof p!="object")return a.error(`-esbuild needs a JS object, for example '{key:"value"}'. Got ${typeof p}.`),!1;a.debug(()=>`applying custom esbuild config ${(0,y.repr)(p)}`);for(let b in p)e[b]=p[b]}}let i=e.debug=n.debug=!!(n.debug||e.debug),s=e.silent=n.silent=!!(n.silent||e.silent),l=e.quiet=n.quiet=s||!!(n.quiet||e.quiet);n.watch=!!(n.watch||e.watch),(!e.watch||typeof e.watch!="object")&&(e.watch=n.watch),e.color!==void 0&&(a.colorMode=e.color,$.reconfigure(process.stdout,e.color),le.reconfigure(process.stderr,e.color)),l&&a.level<a.DEBUG&&(a.level=s?a.SILENT:a.WARN),e.sourcemap=n["inline-sourcemap"]?"inline":n.sourcemap?!0:e.sourcemap,e.outfileIsTemporary&&e.outfileCopyToStdout&&e.sourcemap===!0&&(e.sourcemap="inline"),e.clear=n["no-clear"]?!1:e.clear===void 0?!!process.stdout.isTTY:e.clear,a.debug(()=>`project directory ${(0,y.repr)(e.cwd)} (config.cwd)`),e.title||(e.title=e.name||(0,y.tildePath)(e.cwd));let c=n.diag===!0?"on":n.diag===!1?"off":"auto";c!=="off"&&(e.tsc!==void 0&&(a.info("the 'tsc' property is deprecated. Please rename to 'tslint'."),e.tslint===void 0&&(e.tslint=e.tsc)),e.tslint&&e.tslint!=="auto"&&(c=e.tslint),c==="auto"||typeof c=="object"&&(e.tslint.mode==="auto"||!e.tslint.mode)?he(e)||(a.debug(()=>{let b=rt(e);return`skipping tslint in auto mode since no tsconfig.json file was found in project.
  Tried the following filenames:${Array.from(et(b,e.cwd)).map(I=>`
    ${(0,y.tildePath)(I)}`)}`}),c="off"):e.tslint!==void 0&&e.tslint!=="auto"&&(c=e.tslint)),e.run&&Sr(e);let u=0;function d(){ne.clear(),u=(0,y.clock)()}let m=!1,P=e.onEnd,T=P?async(p,b)=>{m=!0;let x;try{let w=P(e,p,t);x=w instanceof Promise?await w:w}catch(w){throw a.debug(()=>`error in onEnd handler: ${w.stack||w}`),w}finally{m=!1}return x===void 0?b:!!x}:(p,b)=>b;function R(p){let b=T;T=async(x,I)=>{let w=await p(x,I);return w!==void 0&&(I=w),b(x,I)}}e.outfileMode&&e.outfile&&R(async(p,b)=>{if(a.debug("onEnd chmod"),p.errors.length==0)try{Nt(e.outfileAbs,e.outfileMode)}catch(x){a.error("configuration error: outfileMode: "+x.message),Br(1)}}),e.outfileCopyToStdout&&!e.run&&e.write!==!1&&R(async(p,b)=>{if(a.debug("onEnd copyToStdout"),p.errors.length==0)return new Promise((x,I)=>{let w=oe.createReadStream(e.outfileAbs);w.on("end",()=>x(b)),w.on("error",I),w.pipe(process.stdout)})}),e.outfileIsTemporary&&!e.outfileCopyToStdout&&e.write!==!1&&R(async(p,b)=>{if(a.debug("onEnd load results"),p.js=oe.readFileSync(e.outfile,{encoding:"utf8"}),e.sourcemap===!0){try{p.map=oe.readFileSync(e.outfile+".map",{encoding:"utf8"})}catch(I){a.debug(`failed to load temporary source map at ${e.outfile}.map: ${I.stack||I}`)}let x=p.js.lastIndexOf(`
  //# sourceMappingURL`);x!=-1&&(p.js=p.js.substr(0,x+1))}}),e.watch&&R(async(p,b)=>{Rn("Watching files for changes...")});let L={DEBUG:i?"true":"false",...e.define||{}},f={minify:!i,sourcemap:e.sourcemap,sourcesContent:!1,color:le.ncolors>0,logLevel:e.silent?"silent":e.quiet?"error":"warning",...An(e),define:L};if(e.watch){let p=e.projectID;f.metafile=!0,(!f.outfile&&!f.outdir||f.write===!1)&&(f.outfile=Ee.join((0,y.tmpdir)(),`esbuild.${p}.out.js`),e.outfileIsTemporary=!0,delete f.write)}t.rebuild=()=>_([]).then(p=>(m&&a.warn("waiting for rebuild() inside onEnd handler may cause a deadlock"),p));let g={warnings:[],errors:[],metafile:null},C=!0;if(e.watch&&e.entryPoints){g.metafile={inputs:{},outputs:{}};for(let p of e.entryPoints)g.metafile.inputs[p]={}}function k(p,b){a.debug("esbuild finished with result",b),Rr(b.warnings||[]);let x=(0,y.fmtDuration)((0,y.clock)()-p);if(!e.outfile)a.info($.green(e.outdir?`Wrote to dir ${e.outdir} (${x})`:`Finished (write=false, ${x})`));else{let I=e.outfile;e.sourcemap&&e.outfileIsTemporary&&e.sourcemap!="inline"&&e.write!==!1&&jn(e.outfileAbs+".map",{sources:K=>K&&K.map(Ie=>Ee.relative(e.cwd,Ie))});let w=0;try{w=oe.statSync(e.outfileAbs).size}catch(K){}e.outfileIsTemporary||a.info($.green(`Wrote ${I}`)+` (${(0,y.fmtByteSize)(w)}, ${x})`)}return g.warnings=b.warnings,g.errors=[],g.metafile=b.metafile||null,T(g,!0)}function F(p,b){a.debug("esbuild finished with error:",b?b.stack||b:null);let x=b.warnings||[],I=b.errors||[];return I.length==0&&(a.error(b.message),I.push({text:String(b),location:null})),Rr(x),g.warnings=x,g.errors=I,C?C=!0:g.metafile=null,T(g,!1)}async function _(p){e.watch&&e.clear&&d();let b=[];for(let w of p)if(w.type=="move"){let K=e.entryPoints?e.entryPoints.indexOf(w.name):-1;K!=-1&&(a.debug("detected entryPoint file rename",w.name,"->",w.newname),e.entryPoints[K]=w.newname,f.entryPoints[K]=w.newname),b.push(w.newname)}else b.push(w.name);if(e.onStart)try{let w=e.onStart(e,b,t);w instanceof Promise&&await w}catch(w){throw a.debug(()=>`error in onStart handler: ${w.stack||w}`),w}if(e.isCancelled)return;a.debug(()=>`invoking esbuild.build() in ${process.cwd()} with options: ${(0,y.repr)(f)}`);let x=process.cwd();process.chdir(e.cwd);let I=Fr.build(f);return process.chdir(x),I.then(k.bind(null,(0,y.clock)()),F.bind(null,(0,y.clock)()))}let B=n.diag?null:_([]),[E,H]=c!=="off"?Mn(c,n,e):[null,!1];E&&!H&&(E.catch(p=>(a.error(p.stack||String(p)),!1)),t.addCancelCallback(()=>{E.cancel()}),M.diag&&e.watch&&e.clear&&ne.clear());let O=!0;if(B&&(a.debug("awaiting esbuild"),O=await B,e.isCancelled))return!1;if(e.watch){let p=function(){return g.metafile};return await Qe().watchFiles(e,p,t,b=>{let x=b.length,I=b.map(w=>w.type=="move"?w.newname:w.name);return a.info(`${x} ${x>1?"files":"file"} changed: ${I.join(", ")}`),_(b)}),a.debug("fswatch ended"),!0}if(E){let p=null;O?(a.debug("awaiting eslint"),!H&&!n.diag&&(p=setTimeout(()=>a.info("Waiting for TypeScript... (^C to skip)"),1e3)),O=await E.catch(()=>!1)):(a.debug("cancelling eslint since esbuild reported an error"),E.cancel()),clearTimeout(p)}if(!e.isCancelled&&!O&&Br(),O){let p=await Pr();process.exitCode=p}return O}var $r=new Map;function Mn(e,t,r){let n=e,o={};if(e&&typeof e=="object"&&(n=void 0,o=e,o.mode=="off"))return a.debug(()=>'tslint disabled by tslint config {mode:"off"}'),[null,!1];r.tsrules&&r.tsrules.length&&(a.info("The 'tsrules' property is deprecated. Please use 'tslint.rules' instead"),o.rules={...r.tsrules,...o.rules});let i=t.diag&&r.watch&&r.clear,s=he(r),l=`${s||r.cwd}`,c=$r.get(l);if(c)return a.debug(()=>"tslint sharing process (no new process created)"),[c,!0];let u={colors:$.ncolors>0,quiet:r.quiet,mode:n,...o,watch:r.watch,cwd:r.cwd,clearScreen:i,srcdir:pt(r.entryPoints[0]),tsconfigFile:s,onRestart(){a.debug("tsc restarting")}};a.debug(()=>`starting tslint with options ${(0,y.repr)(u)}`);let d=it(u);return $r.set(l,d),[d,!1]}function Rr(e){e.length>0&&a.warn("[warn] "+e.map(t=>t.text).join(`
  `))}function Nn(){return Ar({[De]:1}).catch(e=>{console.error(le.red(J+": "+(e?e.stack||e:"error")));let t=process.exitCode||0;process.exit(t>0?t:1)}).then(e=>{let t=process.exitCode||0;process.exit(e||t>0?t:1)})}function Mr(){M["no-color"]&&(M.color=!1),M["no-diag"]&&(M.diag=!1),a.colorMode=M.color,$.reconfigure(process.stdout,M.color),le.reconfigure(process.stderr,M.color),M.color!==void 0,M["estrella-version"]&&(console.log("estrella 1.4.0"),process.exit(0)),M["estrella-debug"]&&(a.level=a.DEBUG),M.diag&&M.run&&(a.info("Disabling -run since -diag is set"),M.run=void 0),a.debug(()=>`Parsed initial CLI arguments: ${(0,y.repr)({options:M,args:X},2)}`)}y.isCLI?([M,X]=Be(process.argv.slice(2),Bn),Mr(),Nn()):([M,X]=Be(process.argv.slice(2),{...xe,unknownFlagAsArg:!0,help(e,t,r){mt=new Promise(n=>{process.nextTick(()=>{console.log(ze(e,xe.usage,xe.trailer)),process.exit(0),n()})})}}),Mr(),X.length>0&&mt.then(()=>{X.length>0&&Ke(X)}),M.parse=(...e)=>{a.debug(()=>`Parsing custom CLI arguments ${(0,y.json)(X.join)} via cliopts.parse(`+(0,y.repr)(e)+")");let t=Be(X,{...xe,flags:xe.flags.concat(e)});return a.debug(()=>"Parsed extra CLI arguments: "+(0,y.json)({options:t[0],args:t[1]},2)),X.splice(0,X.length),t});function Nr(e,t,r){return Qe().watch(e,t,r)}function Wn(e,t,r,n){return a.info(()=>"estrella.watchdir is deprecated. Please use estrella.watch instead"),n===void 0&&(r===void 0?(n=t,r={}):(n=r,r={...r,filter:t},r.recursive!==void 0&&(r.recursive||(r.depth=0),delete r.recursive))),Nr(e,r,n)}var gt;module.exports={version:"1.4.0",prog:J,cliopts:M,cliargs:X,dirname:pt,basename:On,watch:Nr,watchdir:Wn,scandir:Ze,tslint:it,defaultTSRules:ot,termStyle:Fe,stdoutStyle:$,stderrStyle:le,chmod:A.chmod,editFileMode:A.editMode,fmtDuration:y.fmtDuration,tildePath:y.tildePath,findInPATH:y.findInPATH,tsconfig:Ce,tsconfigFile:he,glob:fe.glob,globmatch:fe.match,file:A,sha1:Le,log:a,get ts(){return gt===void 0&&(gt=Cr()),gt},build:Ar};
  //# sourceMappingURL=estrella.js.map
  