@crossdelta/platform-sdk 0.12.0 → 0.13.0

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/bin/cli.js CHANGED
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var pd=Object.create;var Vs=Object.defineProperty;var fd=Object.getOwnPropertyDescriptor;var dd=Object.getOwnPropertyNames;var hd=Object.getPrototypeOf,md=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gd=(e,t)=>{for(var r in t)Vs(e,r,{get:t[r],enumerable:!0})},Dd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of dd(t))!md.call(e,s)&&s!==r&&Vs(e,s,{get:()=>t[s],enumerable:!(n=fd(t,s))||n.enumerable});return e};var b=(e,t,r)=>(r=e!=null?pd(hd(e)):{},Dd(t||!e||!e.__esModule?Vs(r,"default",{value:e,enumerable:!0}):r,e));var Ys=P((ZC,ua)=>{"use strict";ua.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),s=t.indexOf("--");return n!==-1&&(s===-1||n<s)}});var fa=P((XC,pa)=>{"use strict";var qd=require("os"),la=require("tty"),pt=Ys(),{env:j}=process,ne;pt("no-color")||pt("no-colors")||pt("color=false")||pt("color=never")?ne=0:(pt("color")||pt("colors")||pt("color=true")||pt("color=always"))&&(ne=1);"FORCE_COLOR"in j&&(j.FORCE_COLOR==="true"?ne=1:j.FORCE_COLOR==="false"?ne=0:ne=j.FORCE_COLOR.length===0?1:Math.min(parseInt(j.FORCE_COLOR,10),3));function Zs(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Xs(e,t){if(ne===0)return 0;if(pt("color=16m")||pt("color=full")||pt("color=truecolor"))return 3;if(pt("color=256"))return 2;if(e&&!t&&ne===void 0)return 0;let r=ne||0;if(j.TERM==="dumb")return r;if(process.platform==="win32"){let n=qd.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in j)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in j)||j.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in j)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(j.TEAMCITY_VERSION)?1:0;if(j.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in j){let n=parseInt((j.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(j.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(j.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(j.TERM)||"COLORTERM"in j?1:r}function Yd(e){let t=Xs(e,e&&e.isTTY);return Zs(t)}pa.exports={supportsColor:Yd,stdout:Zs(Xs(!0,la.isatty(1))),stderr:Zs(Xs(!0,la.isatty(2)))}});var ma=P((QC,ha)=>{"use strict";var Zd=fa(),Ne=Ys();function da(e){if(/^\d{3,4}$/.test(e)){let r=/(\d{1,2})(\d{2})/.exec(e)||[];return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}let t=(e||"").split(".").map(r=>parseInt(r,10));return{major:t[0],minor:t[1],patch:t[2]}}function Qs(e){let{CI:t,FORCE_HYPERLINK:r,NETLIFY:n,TEAMCITY_VERSION:s,TERM_PROGRAM:o,TERM_PROGRAM_VERSION:i,VTE_VERSION:a,TERM:c}=process.env;if(r)return!(r.length>0&&parseInt(r,10)===0);if(Ne("no-hyperlink")||Ne("no-hyperlinks")||Ne("hyperlink=false")||Ne("hyperlink=never"))return!1;if(Ne("hyperlink=true")||Ne("hyperlink=always")||n)return!0;if(!Zd.supportsColor(e)||e&&!e.isTTY)return!1;if("WT_SESSION"in process.env)return!0;if(process.platform==="win32"||t||s)return!1;if(o){let u=da(i||"");switch(o){case"iTerm.app":return u.major===3?u.minor>=1:u.major>3;case"WezTerm":return u.major>=20200620;case"vscode":return u.major>1||u.major===1&&u.minor>=72;case"ghostty":return!0}}if(a){if(a==="0.50.0")return!1;let u=da(a);return u.major>0||u.minor>=50}switch(c){case"alacritty":return!0}return!1}ha.exports={supportsHyperlink:Qs,stdout:Qs(process.stdout),stderr:Qs(process.stderr)}});var tu=P((Nx,fg)=>{fg.exports={name:"dotenv",version:"17.2.3",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var iu=P((Ox,Vt)=>{var Bo=require("fs"),os=require("path"),dg=require("os"),hg=require("crypto"),mg=tu(),jo=mg.version,eu=["\u{1F510} encrypt with Dotenvx: https://dotenvx.com","\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit","\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild","\u{1F4E1} add observability to secrets: https://dotenvx.com/ops","\u{1F465} sync secrets across teammates & machines: https://dotenvx.com/ops","\u{1F5C2}\uFE0F backup and recover secrets: https://dotenvx.com/ops","\u2705 audit secrets and track compliance: https://dotenvx.com/ops","\u{1F504} add secrets lifecycle management: https://dotenvx.com/ops","\u{1F511} add access controls to secrets: https://dotenvx.com/ops","\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`","\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }","\u2699\uFE0F enable debug logging with { debug: true }","\u2699\uFE0F override existing env vars with { override: true }","\u2699\uFE0F suppress all logs with { quiet: true }","\u2699\uFE0F write to custom object with { processEnv: myObject }","\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"];function gg(){return eu[Math.floor(Math.random()*eu.length)]}function Xe(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function Dg(){return process.stdout.isTTY}function yg(e){return Dg()?`\x1B[2m${e}\x1B[0m`:e}var wg=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Cg(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,`
3
- `);let n;for(;(n=wg.exec(r))!=null;){let s=n[1],o=n[2]||"";o=o.trim();let i=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(o=o.replace(/\\n/g,`
4
- `),o=o.replace(/\\r/g,"\r")),t[s]=o}return t}function bg(e){e=e||{};let t=ou(e);e.path=t;let r=B.configDotenv(e);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=su(e).split(","),s=n.length,o;for(let i=0;i<s;i++)try{let a=n[i].trim(),c=xg(r,a);o=B.decrypt(c.ciphertext,c.key);break}catch(a){if(i+1>=s)throw a}return B.parse(o)}function vg(e){console.error(`[dotenv@${jo}][WARN] ${e}`)}function Qr(e){console.log(`[dotenv@${jo}][DEBUG] ${e}`)}function nu(e){console.log(`[dotenv@${jo}] ${e}`)}function su(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function xg(e,t){let r;try{r=new URL(t)}catch(a){if(a.code==="ERR_INVALID_URL"){let c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw a}let n=r.password;if(!n){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let s=r.searchParams.get("environment");if(!s){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let o=`DOTENV_VAULT_${s.toUpperCase()}`,i=e.parsed[o];if(!i){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${o} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:i,key:n}}function ou(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)Bo.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=os.resolve(process.cwd(),".env.vault");return Bo.existsSync(t)?t:null}function ru(e){return e[0]==="~"?os.join(dg.homedir(),e.slice(1)):e}function kg(e){let t=Xe(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),r=Xe(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!r)&&nu("Loading env from encrypted .env.vault");let n=B._parseVault(e),s=process.env;return e&&e.processEnv!=null&&(s=e.processEnv),B.populate(s,n,e),{parsed:n}}function Eg(e){let t=os.resolve(process.cwd(),".env"),r="utf8",n=process.env;e&&e.processEnv!=null&&(n=e.processEnv);let s=Xe(n.DOTENV_CONFIG_DEBUG||e&&e.debug),o=Xe(n.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?r=e.encoding:s&&Qr("No encoding is specified. UTF-8 is used by default");let i=[t];if(e&&e.path)if(!Array.isArray(e.path))i=[ru(e.path)];else{i=[];for(let l of e.path)i.push(ru(l))}let a,c={};for(let l of i)try{let p=B.parse(Bo.readFileSync(l,{encoding:r}));B.populate(c,p,e)}catch(p){s&&Qr(`Failed to load ${l} ${p.message}`),a=p}let u=B.populate(n,c,e);if(s=Xe(n.DOTENV_CONFIG_DEBUG||s),o=Xe(n.DOTENV_CONFIG_QUIET||o),s||!o){let l=Object.keys(u).length,p=[];for(let d of i)try{let f=os.relative(process.cwd(),d);p.push(f)}catch(f){s&&Qr(`Failed to load ${d} ${f.message}`),a=f}nu(`injecting env (${l}) from ${p.join(",")} ${yg(`-- tip: ${gg()}`)}`)}return a?{parsed:c,error:a}:{parsed:c}}function Sg(e){if(su(e).length===0)return B.configDotenv(e);let t=ou(e);return t?B._configVault(e):(vg(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),B.configDotenv(e))}function Fg(e,t){let r=Buffer.from(t.slice(-64),"hex"),n=Buffer.from(e,"base64"),s=n.subarray(0,12),o=n.subarray(-16);n=n.subarray(12,-16);try{let i=hg.createDecipheriv("aes-256-gcm",r,s);return i.setAuthTag(o),`${i.update(n)}${i.final()}`}catch(i){let a=i instanceof RangeError,c=i.message==="Invalid key length",u=i.message==="Unsupported state or unable to authenticate data";if(a||c){let l=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw l.code="INVALID_DOTENV_KEY",l}else if(u){let l=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw l.code="DECRYPTION_FAILED",l}else throw i}}function Tg(e,t,r={}){let n=!!(r&&r.debug),s=!!(r&&r.override),o={};if(typeof t!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(t))Object.prototype.hasOwnProperty.call(e,i)?(s===!0&&(e[i]=t[i],o[i]=t[i]),n&&Qr(s===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(e[i]=t[i],o[i]=t[i]);return o}var B={configDotenv:Eg,_configVault:kg,_parseVault:bg,config:Sg,decrypt:Fg,parse:Cg,populate:Tg};Vt.exports.configDotenv=B.configDotenv;Vt.exports._configVault=B._configVault;Vt.exports._parseVault=B._parseVault;Vt.exports.config=B.config;Vt.exports.decrypt=B.decrypt;Vt.exports.parse=B.parse;Vt.exports.populate=B.populate;Vt.exports=B});var As=P((xS,Bl)=>{var wi=[],$l=0,V=(e,t)=>{$l>=t&&wi.push(e)};V.WARN=1;V.INFO=2;V.DEBUG=3;V.reset=()=>{wi=[]};V.setDebugLevel=e=>{$l=e};V.warn=e=>V(e,V.WARN);V.info=e=>V(e,V.INFO);V.debug=e=>V(e,V.DEBUG);V.debugMessages=()=>wi;Bl.exports=V});var _l=P((kS,jl)=>{"use strict";jl.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var Wl=P((ES,Ll)=>{"use strict";var gy=_l();Ll.exports=e=>typeof e=="string"?e.replace(gy(),""):e});var Hl=P((SS,Ci)=>{"use strict";var Gl=e=>Number.isNaN(e)?!1:e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141);Ci.exports=Gl;Ci.exports.default=Gl});var zl=P((FS,Ul)=>{"use strict";Ul.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var Jl=P((TS,bi)=>{"use strict";var Dy=Wl(),yy=Hl(),wy=zl(),Kl=e=>{if(typeof e!="string"||e.length===0||(e=Dy(e),e.length===0))return 0;e=e.replace(wy()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=yy(n)?2:1)}return t};bi.exports=Kl;bi.exports.default=Kl});var vi=P((AS,Zl)=>{var Vl=Jl();function Ps(e){return e?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function jt(e){let t=Ps();return(""+e).replace(t,"").split(`
5
- `).reduce(function(s,o){return Vl(o)>s?Vl(o):s},0)}function dn(e,t){return Array(t+1).join(e)}function Cy(e,t,r,n){let s=jt(e);if(t+1>=s){let o=t-s;switch(n){case"right":{e=dn(r,o)+e;break}case"center":{let i=Math.ceil(o/2),a=o-i;e=dn(r,a)+e+dn(r,i);break}default:{e=e+dn(r,o);break}}}return e}var lr={};function hn(e,t,r){t="\x1B["+t+"m",r="\x1B["+r+"m",lr[t]={set:e,to:!0},lr[r]={set:e,to:!1},lr[e]={on:t,off:r}}hn("bold",1,22);hn("italics",3,23);hn("underline",4,24);hn("inverse",7,27);hn("strikethrough",9,29);function ql(e,t){let r=t[1]?parseInt(t[1].split(";")[0]):0;if(r>=30&&r<=39||r>=90&&r<=97){e.lastForegroundAdded=t[0];return}if(r>=40&&r<=49||r>=100&&r<=107){e.lastBackgroundAdded=t[0];return}if(r===0){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&delete e[s];return}let n=lr[t[0]];n&&(e[n.set]=n.to)}function by(e){let t=Ps(!0),r=t.exec(e),n={};for(;r!==null;)ql(n,r),r=t.exec(e);return n}function Yl(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t+=lr[s].off)}),r&&r!="\x1B[49m"&&(t+="\x1B[49m"),n&&n!="\x1B[39m"&&(t+="\x1B[39m"),t}function vy(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t=lr[s].on+t)}),r&&r!="\x1B[49m"&&(t=r+t),n&&n!="\x1B[39m"&&(t=n+t),t}function xy(e,t){if(e.length===jt(e))return e.substr(0,t);for(;jt(e)>t;)e=e.slice(0,-1);return e}function ky(e,t){let r=Ps(!0),n=e.split(Ps()),s=0,o=0,i="",a,c={};for(;o<t;){a=r.exec(e);let u=n[s];if(s++,o+jt(u)>t&&(u=xy(u,t-o)),i+=u,o+=jt(u),o<t){if(!a)break;i+=a[0],ql(c,a)}}return Yl(c,i)}function Ey(e,t,r){if(r=r||"\u2026",jt(e)<=t)return e;t-=jt(r);let s=ky(e,t);s+=r;let o="\x1B]8;;\x07";return e.includes(o)&&!s.includes(o)&&(s+=o),s}function Sy(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}function Fy(e,t){e=e||{},t=t||Sy();let r=Object.assign({},t,e);return r.chars=Object.assign({},t.chars,e.chars),r.style=Object.assign({},t.style,e.style),r}function Ty(e,t){let r=[],n=t.split(/(\s+)/g),s=[],o=0,i;for(let a=0;a<n.length;a+=2){let c=n[a],u=o+jt(c);o>0&&i&&(u+=i.length),u>e?(o!==0&&r.push(s.join("")),s=[c],o=jt(c)):(s.push(i||"",c),o=u),i=n[a+1]}return o&&r.push(s.join("")),r}function Ay(e,t){let r=[],n="";function s(i,a){for(n.length&&a&&(n+=a),n+=i;n.length>e;)r.push(n.slice(0,e)),n=n.slice(e)}let o=t.split(/(\s+)/g);for(let i=0;i<o.length;i+=2)s(o[i],i&&o[i-1]);return n.length&&r.push(n),r}function Py(e,t,r=!0){let n=[];t=t.split(`
6
- `);let s=r?Ty:Ay;for(let o=0;o<t.length;o++)n.push.apply(n,s(e,t[o]));return n}function Ry(e){let t={},r=[];for(let n=0;n<e.length;n++){let s=vy(t,e[n]);t=by(s);let o=Object.assign({},t);r.push(Yl(o,s))}return r}function Iy(e,t){return["\x1B]","8",";",";",e||t,"\x07",t,"\x1B]","8",";",";","\x07"].join("")}Zl.exports={strlen:jt,repeat:dn,pad:Cy,truncate:Ey,mergeOptions:Fy,wordWrap:Py,colorizeLines:Ry,hyperlink:Iy}});var ep=P((PS,tp)=>{var Ql={};tp.exports=Ql;var Xl={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(Xl).forEach(function(e){var t=Xl[e],r=Ql[e]=[];r.open="\x1B["+t[0]+"m",r.close="\x1B["+t[1]+"m"})});var np=P((RS,rp)=>{"use strict";rp.exports=function(e,t){t=t||process.argv;var r=t.indexOf("--"),n=/^-{1,2}/.test(e)?"":"--",s=t.indexOf(n+e);return s!==-1&&(r===-1?!0:s<r)}});var op=P((IS,sp)=>{"use strict";var Ny=require("os"),Ft=np(),tt=process.env,pr=void 0;Ft("no-color")||Ft("no-colors")||Ft("color=false")?pr=!1:(Ft("color")||Ft("colors")||Ft("color=true")||Ft("color=always"))&&(pr=!0);"FORCE_COLOR"in tt&&(pr=tt.FORCE_COLOR.length===0||parseInt(tt.FORCE_COLOR,10)!==0);function Oy(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function My(e){if(pr===!1)return 0;if(Ft("color=16m")||Ft("color=full")||Ft("color=truecolor"))return 3;if(Ft("color=256"))return 2;if(e&&!e.isTTY&&pr!==!0)return 0;var t=pr?1:0;if(process.platform==="win32"){var r=Ny.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in tt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(s){return s in tt})||tt.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in tt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(tt.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in tt){var n=parseInt((tt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(tt.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(tt.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(tt.TERM)||"COLORTERM"in tt?1:(tt.TERM==="dumb",t)}function xi(e){var t=My(e);return Oy(t)}sp.exports={supportsColor:xi,stdout:xi(process.stdout),stderr:xi(process.stderr)}});var ap=P((NS,ip)=>{ip.exports=function(t,r){var n="";t=t||"Run the trap, drop the bass",t=t.split("");var s={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return t.forEach(function(o){o=o.toLowerCase();var i=s[o]||[" "],a=Math.floor(Math.random()*i.length);typeof s[o]<"u"?n+=s[o][a]:n+=o}),n}});var up=P((OS,cp)=>{cp.exports=function(t,r){t=t||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},s=[].concat(n.up,n.down,n.mid);function o(c){var u=Math.floor(Math.random()*c);return u}function i(c){var u=!1;return s.filter(function(l){u=l===c}),u}function a(c,u){var l="",p,d;u=u||{},u.up=typeof u.up<"u"?u.up:!0,u.mid=typeof u.mid<"u"?u.mid:!0,u.down=typeof u.down<"u"?u.down:!0,u.size=typeof u.size<"u"?u.size:"maxi",c=c.split("");for(d in c)if(!i(d)){switch(l=l+c[d],p={up:0,down:0,mid:0},u.size){case"mini":p.up=o(8),p.mid=o(2),p.down=o(8);break;case"maxi":p.up=o(16)+3,p.mid=o(4)+1,p.down=o(64)+3;break;default:p.up=o(8)+1,p.mid=o(6)/2,p.down=o(8)+1;break}var f=["up","mid","down"];for(var m in f)for(var h=f[m],D=0;D<=p[h];D++)u[h]&&(l=l+n[h][o(n[h].length)])}return l}return a(t,r)}});var pp=P((MS,lp)=>{lp.exports=function(e){return function(t,r,n){if(t===" ")return t;switch(r%3){case 0:return e.red(t);case 1:return e.white(t);case 2:return e.blue(t)}}}});var dp=P(($S,fp)=>{fp.exports=function(e){return function(t,r,n){return r%2===0?t:e.inverse(t)}}});var mp=P((BS,hp)=>{hp.exports=function(e){var t=["red","yellow","green","blue","magenta"];return function(r,n,s){return r===" "?r:e[t[n++%t.length]](r)}}});var Dp=P((jS,gp)=>{gp.exports=function(e){var t=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,n,s){return r===" "?r:e[t[Math.round(Math.random()*(t.length-2))]](r)}}});var xp=P((LS,vp)=>{var x={};vp.exports=x;x.themes={};var $y=require("util"),Ee=x.styles=ep(),wp=Object.defineProperties,By=new RegExp(/[\r\n]+/g);x.supportsColor=op().supportsColor;typeof x.enabled>"u"&&(x.enabled=x.supportsColor()!==!1);x.enable=function(){x.enabled=!0};x.disable=function(){x.enabled=!1};x.stripColors=x.strip=function(e){return(""+e).replace(/\x1B\[\d+m/g,"")};var _S=x.stylize=function(t,r){if(!x.enabled)return t+"";var n=Ee[r];return!n&&r in x?x[r](t):n.open+t+n.close},jy=/[|\\{}()[\]^$+*?.]/g,_y=function(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(jy,"\\$&")};function Cp(e){var t=function r(){return Wy.apply(r,arguments)};return t._styles=e,t.__proto__=Ly,t}var bp=(function(){var e={};return Ee.grey=Ee.gray,Object.keys(Ee).forEach(function(t){Ee[t].closeRe=new RegExp(_y(Ee[t].close),"g"),e[t]={get:function(){return Cp(this._styles.concat(t))}}}),e})(),Ly=wp(function(){},bp);function Wy(){var e=Array.prototype.slice.call(arguments),t=e.map(function(i){return i!=null&&i.constructor===String?i:$y.inspect(i)}).join(" ");if(!x.enabled||!t)return t;for(var r=t.indexOf(`
7
- `)!=-1,n=this._styles,s=n.length;s--;){var o=Ee[n[s]];t=o.open+t.replace(o.closeRe,o.open)+o.close,r&&(t=t.replace(By,function(i){return o.close+i+o.open}))}return t}x.setTheme=function(e){if(typeof e=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var t in e)(function(r){x[r]=function(n){if(typeof e[r]=="object"){var s=n;for(var o in e[r])s=x[e[r][o]](s);return s}return x[e[r]](n)}})(t)};function Gy(){var e={};return Object.keys(bp).forEach(function(t){e[t]={get:function(){return Cp([t])}}}),e}var Hy=function(t,r){var n=r.split("");return n=n.map(t),n.join("")};x.trap=ap();x.zalgo=up();x.maps={};x.maps.america=pp()(x);x.maps.zebra=dp()(x);x.maps.rainbow=mp()(x);x.maps.random=Dp()(x);for(yp in x.maps)(function(e){x[e]=function(t){return Hy(x.maps[e],t)}})(yp);var yp;wp(x,Gy())});var Ep=P((WS,kp)=>{var Uy=xp();kp.exports=Uy});var Ap=P((GS,Rs)=>{var{info:zy,debug:Tp}=As(),at=vi(),Ei=class e{constructor(t){this.setOptions(t),this.x=null,this.y=null}setOptions(t){["boolean","number","bigint","string"].indexOf(typeof t)!==-1&&(t={content:""+t}),t=t||{},this.options=t;let r=t.content;if(["boolean","number","bigint","string"].indexOf(typeof r)!==-1)this.content=String(r);else if(!r)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof r);this.colSpan=t.colSpan||1,this.rowSpan=t.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(t,r){this.cells=r;let n=this.options.chars||{},s=t.chars,o=this.chars={};Jy.forEach(function(c){ki(n,s,c,o)}),this.truncate=this.options.truncate||t.truncate;let i=this.options.style=this.options.style||{},a=t.style;ki(i,a,"padding-left",this),ki(i,a,"padding-right",this),this.head=i.head||a.head,this.border=i.border||a.border,this.fixedWidth=t.colWidths[this.x],this.lines=this.computeLines(t),this.desiredWidth=at.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(t){let r=t.wordWrap||t.textWrap,{wordWrap:n=r}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let i=1;for(;i<this.colSpan;)this.fixedWidth+=t.colWidths[this.x+i],i++}let{wrapOnWordBoundary:s=!0}=t,{wrapOnWordBoundary:o=s}=this.options;return this.wrapLines(at.wordWrap(this.fixedWidth,this.content,o))}return this.wrapLines(this.content.split(`
8
- `))}wrapLines(t){let r=at.colorizeLines(t);return this.href?r.map(n=>at.hyperlink(this.href,n)):r}init(t){let r=this.x,n=this.y;this.widths=t.colWidths.slice(r,r+this.colSpan),this.heights=t.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(Fp,-1),this.height=this.heights.reduce(Fp,-1),this.hAlign=this.options.hAlign||t.colAligns[r],this.vAlign=this.options.vAlign||t.rowAligns[n],this.drawRight=r+this.colSpan==t.colWidths.length}draw(t,r){if(t=="top")return this.drawTop(this.drawRight);if(t=="bottom")return this.drawBottom(this.drawRight);let n=at.truncate(this.content,10,this.truncate);t||zy(`${this.y}-${this.x}: ${this.rowSpan-t}x${this.colSpan} Cell ${n}`);let s=Math.max(this.height-this.lines.length,0),o;switch(this.vAlign){case"center":o=Math.ceil(s/2);break;case"bottom":o=s;break;default:o=0}if(t<o||t>=o+this.lines.length)return this.drawEmpty(this.drawRight,r);let i=this.lines.length>this.height&&t+1>=this.height;return this.drawLine(t-o,this.drawRight,i,r)}drawTop(t){let r=[];return this.cells?this.widths.forEach(function(n,s){r.push(this._topLeftChar(s)),r.push(at.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(r.push(this._topLeftChar(0)),r.push(at.repeat(this.chars[this.y==0?"top":"mid"],this.width))),t&&r.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",r.join(""))}_topLeftChar(t){let r=this.x+t,n;if(this.y==0)n=r==0?"topLeft":t==0?"topMid":"top";else if(r==0)n="leftMid";else if(n=t==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][r]instanceof e.ColSpanCell&&(n=t==0?"topMid":"mid"),t==0)){let o=1;for(;this.cells[this.y][r-o]instanceof e.ColSpanCell;)o++;this.cells[this.y][r-o]instanceof e.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(t,r){if(this[t]&&this[t].length)try{let n=Ep();for(let s=this[t].length-1;s>=0;s--)n=n[this[t][s]];return n(r)}catch{return r}else return r}drawLine(t,r,n,s){let o=this.chars[this.x==0?"left":"middle"];if(this.x&&s&&this.cells){let d=this.cells[this.y+s][this.x-1];for(;d instanceof mn;)d=this.cells[d.y][d.x-1];d instanceof gn||(o=this.chars.rightMid)}let i=at.repeat(" ",this.paddingLeft),a=r?this.chars.right:"",c=at.repeat(" ",this.paddingRight),u=this.lines[t],l=this.width-(this.paddingLeft+this.paddingRight);n&&(u+=this.truncate||"\u2026");let p=at.truncate(u,l,this.truncate);return p=at.pad(p,l," ",this.hAlign),p=i+p+c,this.stylizeLine(o,p,a)}stylizeLine(t,r,n){return t=this.wrapWithStyleColors("border",t),n=this.wrapWithStyleColors("border",n),this.y===0&&(r=this.wrapWithStyleColors("head",r)),t+r+n}drawBottom(t){let r=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=at.repeat(this.chars.bottom,this.width),s=t?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",r+n+s)}drawEmpty(t,r){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&r&&this.cells){let i=this.cells[this.y+r][this.x-1];for(;i instanceof mn;)i=this.cells[i.y][i.x-1];i instanceof gn||(n=this.chars.rightMid)}let s=t?this.chars.right:"",o=at.repeat(" ",this.width);return this.stylizeLine(n,o,s)}},mn=class{constructor(){}draw(t){return typeof t=="number"&&Tp(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},gn=class{constructor(t){this.originalCell=t}init(t){let r=this.y,n=this.originalCell.y;this.cellOffset=r-n,this.offset=Ky(t.rowHeights,n,this.cellOffset)}draw(t){return t=="top"?this.originalCell.draw(this.offset,this.cellOffset):t=="bottom"?this.originalCell.draw("bottom"):(Tp(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+t))}mergeTableOptions(){}};function Sp(...e){return e.filter(t=>t!=null).shift()}function ki(e,t,r,n){let s=r.split("-");s.length>1?(s[1]=s[1].charAt(0).toUpperCase()+s[1].substr(1),s=s.join(""),n[s]=Sp(e[s],e[r],t[s],t[r])):n[r]=Sp(e[r],t[r])}function Ky(e,t,r){let n=e[t];for(let s=1;s<r;s++)n+=1+e[t+s];return n}function Fp(e,t){return e+t+1}var Jy=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];Rs.exports=Ei;Rs.exports.ColSpanCell=mn;Rs.exports.RowSpanCell=gn});var Ip=P((HS,Rp)=>{var{warn:Vy,debug:qy}=As(),Si=Ap(),{ColSpanCell:Yy,RowSpanCell:Zy}=Si;(function(){function e(f,m){return f[m]>0?e(f,m+1):m}function t(f){let m={};f.forEach(function(h,D){let g=0;h.forEach(function(y){y.y=D,y.x=D?e(m,g):g;let v=y.rowSpan||1,C=y.colSpan||1;if(v>1)for(let A=0;A<C;A++)m[y.x+A]=v;g=y.x+C}),Object.keys(m).forEach(y=>{m[y]--,m[y]<1&&delete m[y]})})}function r(f){let m=0;return f.forEach(function(h){h.forEach(function(D){m=Math.max(m,D.x+(D.colSpan||1))})}),m}function n(f){return f.length}function s(f,m){let h=f.y,D=f.y-1+(f.rowSpan||1),g=m.y,y=m.y-1+(m.rowSpan||1),v=!(h>y||g>D),C=f.x,A=f.x-1+(f.colSpan||1),lt=m.x,re=m.x-1+(m.colSpan||1),Fe=!(C>re||lt>A);return v&&Fe}function o(f,m,h){let D=Math.min(f.length-1,h),g={x:m,y:h};for(let y=0;y<=D;y++){let v=f[y];for(let C=0;C<v.length;C++)if(s(g,v[C]))return!0}return!1}function i(f,m,h,D){for(let g=h;g<D;g++)if(o(f,g,m))return!1;return!0}function a(f){f.forEach(function(m,h){m.forEach(function(D){for(let g=1;g<D.rowSpan;g++){let y=new Zy(D);y.x=D.x,y.y=D.y+g,y.colSpan=D.colSpan,u(y,f[h+g])}})})}function c(f){for(let m=f.length-1;m>=0;m--){let h=f[m];for(let D=0;D<h.length;D++){let g=h[D];for(let y=1;y<g.colSpan;y++){let v=new Yy;v.x=g.x+y,v.y=g.y,h.splice(D+1,0,v)}}}}function u(f,m){let h=0;for(;h<m.length&&m[h].x<f.x;)h++;m.splice(h,0,f)}function l(f){let m=n(f),h=r(f);qy(`Max rows: ${m}; Max cols: ${h}`);for(let D=0;D<m;D++)for(let g=0;g<h;g++)if(!o(f,g,D)){let y={x:g,y:D,colSpan:1,rowSpan:1};for(g++;g<h&&!o(f,g,D);)y.colSpan++,g++;let v=D+1;for(;v<m&&i(f,v,y.x,y.x+y.colSpan);)y.rowSpan++,v++;let C=new Si(y);C.x=y.x,C.y=y.y,Vy(`Missing cell at ${C.y}-${C.x}.`),u(C,f[D])}}function p(f){return f.map(function(m){if(!Array.isArray(m)){let h=Object.keys(m)[0];m=m[h],Array.isArray(m)?(m=m.slice(),m.unshift(h)):m=[h,m]}return m.map(function(h){return new Si(h)})})}function d(f){let m=p(f);return t(m),l(m),a(m),c(m),m}Rp.exports={makeTableLayout:d,layoutTable:t,addRowSpanCells:a,maxWidth:r,fillInTable:l,computeWidths:Pp("colSpan","desiredWidth","x",1),computeHeights:Pp("rowSpan","desiredHeight","y",1)}})();function Pp(e,t,r,n){return function(s,o){let i=[],a=[],c={};o.forEach(function(u){u.forEach(function(l){(l[e]||1)>1?a.push(l):i[l[r]]=Math.max(i[l[r]]||0,l[t]||0,n)})}),s.forEach(function(u,l){typeof u=="number"&&(i[l]=u)});for(let u=a.length-1;u>=0;u--){let l=a[u],p=l[e],d=l[r],f=i[d],m=typeof s[d]=="number"?0:1;if(typeof f=="number")for(let h=1;h<p;h++)f+=1+i[d+h],typeof s[d+h]!="number"&&m++;else f=t==="desiredWidth"?l.desiredWidth-1:1,(!c[d]||c[d]<f)&&(c[d]=f);if(l[t]>f){let h=0;for(;m>0&&l[t]>f;){if(typeof s[d+h]!="number"){let D=Math.round((l[t]-f)/m);f+=D,i[d+h]+=D,m--}h++}}}Object.assign(s,i,c);for(let u=0;u<s.length;u++)s[u]=Math.max(n,s[u]||0)}}});var Op=P((US,Np)=>{var Xt=As(),Xy=vi(),Fi=Ip(),Is=class extends Array{constructor(t){super();let r=Xy.mergeOptions(t);if(Object.defineProperty(this,"options",{value:r,enumerable:r.debug}),r.debug){switch(typeof r.debug){case"boolean":Xt.setDebugLevel(Xt.WARN);break;case"number":Xt.setDebugLevel(r.debug);break;case"string":Xt.setDebugLevel(parseInt(r.debug,10));break;default:Xt.setDebugLevel(Xt.WARN),Xt.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof r.debug}`)}Object.defineProperty(this,"messages",{get(){return Xt.debugMessages()}})}}toString(){let t=this,r=this.options.head&&this.options.head.length;r?(t=[this.options.head],this.length&&t.push.apply(t,this)):this.options.style.head=[];let n=Fi.makeTableLayout(t);n.forEach(function(o){o.forEach(function(i){i.mergeTableOptions(this.options,n)},this)},this),Fi.computeWidths(this.options.colWidths,n),Fi.computeHeights(this.options.rowHeights,n),n.forEach(function(o){o.forEach(function(i){i.init(this.options)},this)},this);let s=[];for(let o=0;o<n.length;o++){let i=n[o],a=this.options.rowHeights[o];(o===0||!this.options.style.compact||o==1&&r)&&Ti(i,"top",s);for(let c=0;c<a;c++)Ti(i,c,s);o+1==n.length&&Ti(i,"bottom",s)}return s.join(`
2
+ "use strict";var kd=Object.create;var Zs=Object.defineProperty;var Ed=Object.getOwnPropertyDescriptor;var Sd=Object.getOwnPropertyNames;var Fd=Object.getPrototypeOf,Td=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ad=(e,t)=>{for(var r in t)Zs(e,r,{get:t[r],enumerable:!0})},Pd=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Sd(t))!Td.call(e,s)&&s!==r&&Zs(e,s,{get:()=>t[s],enumerable:!(n=Ed(t,s))||n.enumerable});return e};var b=(e,t,r)=>(r=e!=null?kd(Fd(e)):{},Pd(t||!e||!e.__esModule?Zs(r,"default",{value:e,enumerable:!0}):r,e));var Qs=P((Eb,da)=>{"use strict";da.exports=(e,t=process.argv)=>{let r=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(r+e),s=t.indexOf("--");return n!==-1&&(s===-1||n<s)}});var ga=P((Sb,ma)=>{"use strict";var ch=require("os"),ha=require("tty"),ht=Qs(),{env:L}=process,se;ht("no-color")||ht("no-colors")||ht("color=false")||ht("color=never")?se=0:(ht("color")||ht("colors")||ht("color=true")||ht("color=always"))&&(se=1);"FORCE_COLOR"in L&&(L.FORCE_COLOR==="true"?se=1:L.FORCE_COLOR==="false"?se=0:se=L.FORCE_COLOR.length===0?1:Math.min(parseInt(L.FORCE_COLOR,10),3));function to(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function eo(e,t){if(se===0)return 0;if(ht("color=16m")||ht("color=full")||ht("color=truecolor"))return 3;if(ht("color=256"))return 2;if(e&&!t&&se===void 0)return 0;let r=se||0;if(L.TERM==="dumb")return r;if(process.platform==="win32"){let n=ch.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in L)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in L)||L.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in L)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(L.TEAMCITY_VERSION)?1:0;if(L.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in L){let n=parseInt((L.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(L.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(L.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(L.TERM)||"COLORTERM"in L?1:r}function lh(e){let t=eo(e,e&&e.isTTY);return to(t)}ma.exports={supportsColor:lh,stdout:to(eo(!0,ha.isatty(1))),stderr:to(eo(!0,ha.isatty(2)))}});var wa=P((Fb,ya)=>{"use strict";var uh=ga(),Me=Qs();function Da(e){if(/^\d{3,4}$/.test(e)){let r=/(\d{1,2})(\d{2})/.exec(e)||[];return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}let t=(e||"").split(".").map(r=>parseInt(r,10));return{major:t[0],minor:t[1],patch:t[2]}}function ro(e){let{CI:t,FORCE_HYPERLINK:r,NETLIFY:n,TEAMCITY_VERSION:s,TERM_PROGRAM:o,TERM_PROGRAM_VERSION:i,VTE_VERSION:a,TERM:c}=process.env;if(r)return!(r.length>0&&parseInt(r,10)===0);if(Me("no-hyperlink")||Me("no-hyperlinks")||Me("hyperlink=false")||Me("hyperlink=never"))return!1;if(Me("hyperlink=true")||Me("hyperlink=always")||n)return!0;if(!uh.supportsColor(e)||e&&!e.isTTY)return!1;if("WT_SESSION"in process.env)return!0;if(process.platform==="win32"||t||s)return!1;if(o){let l=Da(i||"");switch(o){case"iTerm.app":return l.major===3?l.minor>=1:l.major>3;case"WezTerm":return l.major>=20200620;case"vscode":return l.major>1||l.major===1&&l.minor>=72;case"ghostty":return!0}}if(a){if(a==="0.50.0")return!1;let l=Da(a);return l.major>0||l.minor>=50}switch(c){case"alacritty":return!0}return!1}ya.exports={supportsHyperlink:ro,stdout:ro(process.stdout),stderr:ro(process.stderr)}});var sl=P((ak,Eg)=>{Eg.exports={name:"dotenv",version:"17.2.3",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var ul=P((ck,Vt)=>{var Lo=require("fs"),cs=require("path"),Sg=require("os"),Fg=require("crypto"),Tg=sl(),Wo=Tg.version,ol=["\u{1F510} encrypt with Dotenvx: https://dotenvx.com","\u{1F510} prevent committing .env to code: https://dotenvx.com/precommit","\u{1F510} prevent building .env in docker: https://dotenvx.com/prebuild","\u{1F4E1} add observability to secrets: https://dotenvx.com/ops","\u{1F465} sync secrets across teammates & machines: https://dotenvx.com/ops","\u{1F5C2}\uFE0F backup and recover secrets: https://dotenvx.com/ops","\u2705 audit secrets and track compliance: https://dotenvx.com/ops","\u{1F504} add secrets lifecycle management: https://dotenvx.com/ops","\u{1F511} add access controls to secrets: https://dotenvx.com/ops","\u{1F6E0}\uFE0F run anywhere with `dotenvx run -- yourcommand`","\u2699\uFE0F specify custom .env file path with { path: '/custom/path/.env' }","\u2699\uFE0F enable debug logging with { debug: true }","\u2699\uFE0F override existing env vars with { override: true }","\u2699\uFE0F suppress all logs with { quiet: true }","\u2699\uFE0F write to custom object with { processEnv: myObject }","\u2699\uFE0F load multiple .env files with { path: ['.env.local', '.env'] }"];function Ag(){return ol[Math.floor(Math.random()*ol.length)]}function tr(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}function Pg(){return process.stdout.isTTY}function Rg(e){return Pg()?`\x1B[2m${e}\x1B[0m`:e}var Ig=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function Ng(e){let t={},r=e.toString();r=r.replace(/\r\n?/mg,`
3
+ `);let n;for(;(n=Ig.exec(r))!=null;){let s=n[1],o=n[2]||"";o=o.trim();let i=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),i==='"'&&(o=o.replace(/\\n/g,`
4
+ `),o=o.replace(/\\r/g,"\r")),t[s]=o}return t}function Og(e){e=e||{};let t=ll(e);e.path=t;let r=_.configDotenv(e);if(!r.parsed){let i=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw i.code="MISSING_DATA",i}let n=cl(e).split(","),s=n.length,o;for(let i=0;i<s;i++)try{let a=n[i].trim(),c=$g(r,a);o=_.decrypt(c.ciphertext,c.key);break}catch(a){if(i+1>=s)throw a}return _.parse(o)}function Mg(e){console.error(`[dotenv@${Wo}][WARN] ${e}`)}function en(e){console.log(`[dotenv@${Wo}][DEBUG] ${e}`)}function al(e){console.log(`[dotenv@${Wo}] ${e}`)}function cl(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function $g(e,t){let r;try{r=new URL(t)}catch(a){if(a.code==="ERR_INVALID_URL"){let c=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw c.code="INVALID_DOTENV_KEY",c}throw a}let n=r.password;if(!n){let a=new Error("INVALID_DOTENV_KEY: Missing key part");throw a.code="INVALID_DOTENV_KEY",a}let s=r.searchParams.get("environment");if(!s){let a=new Error("INVALID_DOTENV_KEY: Missing environment part");throw a.code="INVALID_DOTENV_KEY",a}let o=`DOTENV_VAULT_${s.toUpperCase()}`,i=e.parsed[o];if(!i){let a=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${o} in your .env.vault file.`);throw a.code="NOT_FOUND_DOTENV_ENVIRONMENT",a}return{ciphertext:i,key:n}}function ll(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)Lo.existsSync(r)&&(t=r.endsWith(".vault")?r:`${r}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=cs.resolve(process.cwd(),".env.vault");return Lo.existsSync(t)?t:null}function il(e){return e[0]==="~"?cs.join(Sg.homedir(),e.slice(1)):e}function Bg(e){let t=tr(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),r=tr(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!r)&&al("Loading env from encrypted .env.vault");let n=_._parseVault(e),s=process.env;return e&&e.processEnv!=null&&(s=e.processEnv),_.populate(s,n,e),{parsed:n}}function jg(e){let t=cs.resolve(process.cwd(),".env"),r="utf8",n=process.env;e&&e.processEnv!=null&&(n=e.processEnv);let s=tr(n.DOTENV_CONFIG_DEBUG||e&&e.debug),o=tr(n.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?r=e.encoding:s&&en("No encoding is specified. UTF-8 is used by default");let i=[t];if(e&&e.path)if(!Array.isArray(e.path))i=[il(e.path)];else{i=[];for(let u of e.path)i.push(il(u))}let a,c={};for(let u of i)try{let p=_.parse(Lo.readFileSync(u,{encoding:r}));_.populate(c,p,e)}catch(p){s&&en(`Failed to load ${u} ${p.message}`),a=p}let l=_.populate(n,c,e);if(s=tr(n.DOTENV_CONFIG_DEBUG||s),o=tr(n.DOTENV_CONFIG_QUIET||o),s||!o){let u=Object.keys(l).length,p=[];for(let d of i)try{let f=cs.relative(process.cwd(),d);p.push(f)}catch(f){s&&en(`Failed to load ${d} ${f.message}`),a=f}al(`injecting env (${u}) from ${p.join(",")} ${Rg(`-- tip: ${Ag()}`)}`)}return a?{parsed:c,error:a}:{parsed:c}}function _g(e){if(cl(e).length===0)return _.configDotenv(e);let t=ll(e);return t?_._configVault(e):(Mg(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),_.configDotenv(e))}function Lg(e,t){let r=Buffer.from(t.slice(-64),"hex"),n=Buffer.from(e,"base64"),s=n.subarray(0,12),o=n.subarray(-16);n=n.subarray(12,-16);try{let i=Fg.createDecipheriv("aes-256-gcm",r,s);return i.setAuthTag(o),`${i.update(n)}${i.final()}`}catch(i){let a=i instanceof RangeError,c=i.message==="Invalid key length",l=i.message==="Unsupported state or unable to authenticate data";if(a||c){let u=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw u.code="INVALID_DOTENV_KEY",u}else if(l){let u=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw u.code="DECRYPTION_FAILED",u}else throw i}}function Wg(e,t,r={}){let n=!!(r&&r.debug),s=!!(r&&r.override),o={};if(typeof t!="object"){let i=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw i.code="OBJECT_REQUIRED",i}for(let i of Object.keys(t))Object.prototype.hasOwnProperty.call(e,i)?(s===!0&&(e[i]=t[i],o[i]=t[i]),n&&en(s===!0?`"${i}" is already defined and WAS overwritten`:`"${i}" is already defined and was NOT overwritten`)):(e[i]=t[i],o[i]=t[i]);return o}var _={configDotenv:jg,_configVault:Bg,_parseVault:Og,config:_g,decrypt:Lg,parse:Ng,populate:Wg};Vt.exports.configDotenv=_.configDotenv;Vt.exports._configVault=_._configVault;Vt.exports._parseVault=_._parseVault;Vt.exports.config=_.config;Vt.exports.decrypt=_.decrypt;Vt.exports.parse=_.parse;Vt.exports.populate=_.populate;Vt.exports=_});var Ps=P((t0,Ju)=>{var ki=[],Ku=0,Y=(e,t)=>{Ku>=t&&ki.push(e)};Y.WARN=1;Y.INFO=2;Y.DEBUG=3;Y.reset=()=>{ki=[]};Y.setDebugLevel=e=>{Ku=e};Y.warn=e=>Y(e,Y.WARN);Y.info=e=>Y(e,Y.INFO);Y.debug=e=>Y(e,Y.DEBUG);Y.debugMessages=()=>ki;Ju.exports=Y});var Vu=P((e0,qu)=>{"use strict";qu.exports=({onlyFirst:e=!1}={})=>{let t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")}});var Zu=P((r0,Yu)=>{"use strict";var zy=Vu();Yu.exports=e=>typeof e=="string"?e.replace(zy(),""):e});var Qu=P((n0,Ei)=>{"use strict";var Xu=e=>Number.isNaN(e)?!1:e>=4352&&(e<=4447||e===9001||e===9002||11904<=e&&e<=12871&&e!==12351||12880<=e&&e<=19903||19968<=e&&e<=42182||43360<=e&&e<=43388||44032<=e&&e<=55203||63744<=e&&e<=64255||65040<=e&&e<=65049||65072<=e&&e<=65131||65281<=e&&e<=65376||65504<=e&&e<=65510||110592<=e&&e<=110593||127488<=e&&e<=127569||131072<=e&&e<=262141);Ei.exports=Xu;Ei.exports.default=Xu});var ep=P((s0,tp)=>{"use strict";tp.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});var np=P((o0,Si)=>{"use strict";var Ky=Zu(),Jy=Qu(),qy=ep(),rp=e=>{if(typeof e!="string"||e.length===0||(e=Ky(e),e.length===0))return 0;e=e.replace(qy()," ");let t=0;for(let r=0;r<e.length;r++){let n=e.codePointAt(r);n<=31||n>=127&&n<=159||n>=768&&n<=879||(n>65535&&r++,t+=Jy(n)?2:1)}return t};Si.exports=rp;Si.exports.default=rp});var Fi=P((i0,ap)=>{var sp=np();function Rs(e){return e?/\u001b\[((?:\d*;){0,5}\d*)m/g:/\u001b\[(?:\d*;){0,5}\d*m/g}function _t(e){let t=Rs();return(""+e).replace(t,"").split(`
5
+ `).reduce(function(s,o){return sp(o)>s?sp(o):s},0)}function gn(e,t){return Array(t+1).join(e)}function Vy(e,t,r,n){let s=_t(e);if(t+1>=s){let o=t-s;switch(n){case"right":{e=gn(r,o)+e;break}case"center":{let i=Math.ceil(o/2),a=o-i;e=gn(r,a)+e+gn(r,i);break}default:{e=e+gn(r,o);break}}}return e}var dr={};function Dn(e,t,r){t="\x1B["+t+"m",r="\x1B["+r+"m",dr[t]={set:e,to:!0},dr[r]={set:e,to:!1},dr[e]={on:t,off:r}}Dn("bold",1,22);Dn("italics",3,23);Dn("underline",4,24);Dn("inverse",7,27);Dn("strikethrough",9,29);function op(e,t){let r=t[1]?parseInt(t[1].split(";")[0]):0;if(r>=30&&r<=39||r>=90&&r<=97){e.lastForegroundAdded=t[0];return}if(r>=40&&r<=49||r>=100&&r<=107){e.lastBackgroundAdded=t[0];return}if(r===0){for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&delete e[s];return}let n=dr[t[0]];n&&(e[n.set]=n.to)}function Yy(e){let t=Rs(!0),r=t.exec(e),n={};for(;r!==null;)op(n,r),r=t.exec(e);return n}function ip(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t+=dr[s].off)}),r&&r!="\x1B[49m"&&(t+="\x1B[49m"),n&&n!="\x1B[39m"&&(t+="\x1B[39m"),t}function Zy(e,t){let r=e.lastBackgroundAdded,n=e.lastForegroundAdded;return delete e.lastBackgroundAdded,delete e.lastForegroundAdded,Object.keys(e).forEach(function(s){e[s]&&(t=dr[s].on+t)}),r&&r!="\x1B[49m"&&(t=r+t),n&&n!="\x1B[39m"&&(t=n+t),t}function Xy(e,t){if(e.length===_t(e))return e.substr(0,t);for(;_t(e)>t;)e=e.slice(0,-1);return e}function Qy(e,t){let r=Rs(!0),n=e.split(Rs()),s=0,o=0,i="",a,c={};for(;o<t;){a=r.exec(e);let l=n[s];if(s++,o+_t(l)>t&&(l=Xy(l,t-o)),i+=l,o+=_t(l),o<t){if(!a)break;i+=a[0],op(c,a)}}return ip(c,i)}function tw(e,t,r){if(r=r||"\u2026",_t(e)<=t)return e;t-=_t(r);let s=Qy(e,t);s+=r;let o="\x1B]8;;\x07";return e.includes(o)&&!s.includes(o)&&(s+=o),s}function ew(){return{chars:{top:"\u2500","top-mid":"\u252C","top-left":"\u250C","top-right":"\u2510",bottom:"\u2500","bottom-mid":"\u2534","bottom-left":"\u2514","bottom-right":"\u2518",left:"\u2502","left-mid":"\u251C",mid:"\u2500","mid-mid":"\u253C",right:"\u2502","right-mid":"\u2524",middle:"\u2502"},truncate:"\u2026",colWidths:[],rowHeights:[],colAligns:[],rowAligns:[],style:{"padding-left":1,"padding-right":1,head:["red"],border:["grey"],compact:!1},head:[]}}function rw(e,t){e=e||{},t=t||ew();let r=Object.assign({},t,e);return r.chars=Object.assign({},t.chars,e.chars),r.style=Object.assign({},t.style,e.style),r}function nw(e,t){let r=[],n=t.split(/(\s+)/g),s=[],o=0,i;for(let a=0;a<n.length;a+=2){let c=n[a],l=o+_t(c);o>0&&i&&(l+=i.length),l>e?(o!==0&&r.push(s.join("")),s=[c],o=_t(c)):(s.push(i||"",c),o=l),i=n[a+1]}return o&&r.push(s.join("")),r}function sw(e,t){let r=[],n="";function s(i,a){for(n.length&&a&&(n+=a),n+=i;n.length>e;)r.push(n.slice(0,e)),n=n.slice(e)}let o=t.split(/(\s+)/g);for(let i=0;i<o.length;i+=2)s(o[i],i&&o[i-1]);return n.length&&r.push(n),r}function ow(e,t,r=!0){let n=[];t=t.split(`
6
+ `);let s=r?nw:sw;for(let o=0;o<t.length;o++)n.push.apply(n,s(e,t[o]));return n}function iw(e){let t={},r=[];for(let n=0;n<e.length;n++){let s=Zy(t,e[n]);t=Yy(s);let o=Object.assign({},t);r.push(ip(o,s))}return r}function aw(e,t){return["\x1B]","8",";",";",e||t,"\x07",t,"\x1B]","8",";",";","\x07"].join("")}ap.exports={strlen:_t,repeat:gn,pad:Vy,truncate:tw,mergeOptions:rw,wordWrap:ow,colorizeLines:iw,hyperlink:aw}});var pp=P((a0,up)=>{var lp={};up.exports=lp;var cp={reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],grey:[90,39],brightRed:[91,39],brightGreen:[92,39],brightYellow:[93,39],brightBlue:[94,39],brightMagenta:[95,39],brightCyan:[96,39],brightWhite:[97,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgGray:[100,49],bgGrey:[100,49],bgBrightRed:[101,49],bgBrightGreen:[102,49],bgBrightYellow:[103,49],bgBrightBlue:[104,49],bgBrightMagenta:[105,49],bgBrightCyan:[106,49],bgBrightWhite:[107,49],blackBG:[40,49],redBG:[41,49],greenBG:[42,49],yellowBG:[43,49],blueBG:[44,49],magentaBG:[45,49],cyanBG:[46,49],whiteBG:[47,49]};Object.keys(cp).forEach(function(e){var t=cp[e],r=lp[e]=[];r.open="\x1B["+t[0]+"m",r.close="\x1B["+t[1]+"m"})});var dp=P((c0,fp)=>{"use strict";fp.exports=function(e,t){t=t||process.argv;var r=t.indexOf("--"),n=/^-{1,2}/.test(e)?"":"--",s=t.indexOf(n+e);return s!==-1&&(r===-1?!0:s<r)}});var mp=P((l0,hp)=>{"use strict";var cw=require("os"),Tt=dp(),nt=process.env,hr=void 0;Tt("no-color")||Tt("no-colors")||Tt("color=false")?hr=!1:(Tt("color")||Tt("colors")||Tt("color=true")||Tt("color=always"))&&(hr=!0);"FORCE_COLOR"in nt&&(hr=nt.FORCE_COLOR.length===0||parseInt(nt.FORCE_COLOR,10)!==0);function lw(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function uw(e){if(hr===!1)return 0;if(Tt("color=16m")||Tt("color=full")||Tt("color=truecolor"))return 3;if(Tt("color=256"))return 2;if(e&&!e.isTTY&&hr!==!0)return 0;var t=hr?1:0;if(process.platform==="win32"){var r=cw.release().split(".");return Number(process.versions.node.split(".")[0])>=8&&Number(r[0])>=10&&Number(r[2])>=10586?Number(r[2])>=14931?3:2:1}if("CI"in nt)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI"].some(function(s){return s in nt})||nt.CI_NAME==="codeship"?1:t;if("TEAMCITY_VERSION"in nt)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(nt.TEAMCITY_VERSION)?1:0;if("TERM_PROGRAM"in nt){var n=parseInt((nt.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(nt.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Hyper":return 3;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(nt.TERM)?2:/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(nt.TERM)||"COLORTERM"in nt?1:(nt.TERM==="dumb",t)}function Ti(e){var t=uw(e);return lw(t)}hp.exports={supportsColor:Ti,stdout:Ti(process.stdout),stderr:Ti(process.stderr)}});var Dp=P((u0,gp)=>{gp.exports=function(t,r){var n="";t=t||"Run the trap, drop the bass",t=t.split("");var s={a:["@","\u0104","\u023A","\u0245","\u0394","\u039B","\u0414"],b:["\xDF","\u0181","\u0243","\u026E","\u03B2","\u0E3F"],c:["\xA9","\u023B","\u03FE"],d:["\xD0","\u018A","\u0500","\u0501","\u0502","\u0503"],e:["\xCB","\u0115","\u018E","\u0258","\u03A3","\u03BE","\u04BC","\u0A6C"],f:["\u04FA"],g:["\u0262"],h:["\u0126","\u0195","\u04A2","\u04BA","\u04C7","\u050A"],i:["\u0F0F"],j:["\u0134"],k:["\u0138","\u04A0","\u04C3","\u051E"],l:["\u0139"],m:["\u028D","\u04CD","\u04CE","\u0520","\u0521","\u0D69"],n:["\xD1","\u014B","\u019D","\u0376","\u03A0","\u048A"],o:["\xD8","\xF5","\xF8","\u01FE","\u0298","\u047A","\u05DD","\u06DD","\u0E4F"],p:["\u01F7","\u048E"],q:["\u09CD"],r:["\xAE","\u01A6","\u0210","\u024C","\u0280","\u042F"],s:["\xA7","\u03DE","\u03DF","\u03E8"],t:["\u0141","\u0166","\u0373"],u:["\u01B1","\u054D"],v:["\u05D8"],w:["\u0428","\u0460","\u047C","\u0D70"],x:["\u04B2","\u04FE","\u04FC","\u04FD"],y:["\xA5","\u04B0","\u04CB"],z:["\u01B5","\u0240"]};return t.forEach(function(o){o=o.toLowerCase();var i=s[o]||[" "],a=Math.floor(Math.random()*i.length);typeof s[o]<"u"?n+=s[o][a]:n+=o}),n}});var wp=P((p0,yp)=>{yp.exports=function(t,r){t=t||" he is here ";var n={up:["\u030D","\u030E","\u0304","\u0305","\u033F","\u0311","\u0306","\u0310","\u0352","\u0357","\u0351","\u0307","\u0308","\u030A","\u0342","\u0313","\u0308","\u034A","\u034B","\u034C","\u0303","\u0302","\u030C","\u0350","\u0300","\u0301","\u030B","\u030F","\u0312","\u0313","\u0314","\u033D","\u0309","\u0363","\u0364","\u0365","\u0366","\u0367","\u0368","\u0369","\u036A","\u036B","\u036C","\u036D","\u036E","\u036F","\u033E","\u035B","\u0346","\u031A"],down:["\u0316","\u0317","\u0318","\u0319","\u031C","\u031D","\u031E","\u031F","\u0320","\u0324","\u0325","\u0326","\u0329","\u032A","\u032B","\u032C","\u032D","\u032E","\u032F","\u0330","\u0331","\u0332","\u0333","\u0339","\u033A","\u033B","\u033C","\u0345","\u0347","\u0348","\u0349","\u034D","\u034E","\u0353","\u0354","\u0355","\u0356","\u0359","\u035A","\u0323"],mid:["\u0315","\u031B","\u0300","\u0301","\u0358","\u0321","\u0322","\u0327","\u0328","\u0334","\u0335","\u0336","\u035C","\u035D","\u035E","\u035F","\u0360","\u0362","\u0338","\u0337","\u0361"," \u0489"]},s=[].concat(n.up,n.down,n.mid);function o(c){var l=Math.floor(Math.random()*c);return l}function i(c){var l=!1;return s.filter(function(u){l=u===c}),l}function a(c,l){var u="",p,d;l=l||{},l.up=typeof l.up<"u"?l.up:!0,l.mid=typeof l.mid<"u"?l.mid:!0,l.down=typeof l.down<"u"?l.down:!0,l.size=typeof l.size<"u"?l.size:"maxi",c=c.split("");for(d in c)if(!i(d)){switch(u=u+c[d],p={up:0,down:0,mid:0},l.size){case"mini":p.up=o(8),p.mid=o(2),p.down=o(8);break;case"maxi":p.up=o(16)+3,p.mid=o(4)+1,p.down=o(64)+3;break;default:p.up=o(8)+1,p.mid=o(6)/2,p.down=o(8)+1;break}var f=["up","mid","down"];for(var m in f)for(var h=f[m],D=0;D<=p[h];D++)l[h]&&(u=u+n[h][o(n[h].length)])}return u}return a(t,r)}});var bp=P((f0,Cp)=>{Cp.exports=function(e){return function(t,r,n){if(t===" ")return t;switch(r%3){case 0:return e.red(t);case 1:return e.white(t);case 2:return e.blue(t)}}}});var vp=P((d0,xp)=>{xp.exports=function(e){return function(t,r,n){return r%2===0?t:e.inverse(t)}}});var Ep=P((h0,kp)=>{kp.exports=function(e){var t=["red","yellow","green","blue","magenta"];return function(r,n,s){return r===" "?r:e[t[n++%t.length]](r)}}});var Fp=P((m0,Sp)=>{Sp.exports=function(e){var t=["underline","inverse","grey","yellow","red","green","blue","white","cyan","magenta","brightYellow","brightRed","brightGreen","brightBlue","brightWhite","brightCyan","brightMagenta"];return function(r,n,s){return r===" "?r:e[t[Math.round(Math.random()*(t.length-2))]](r)}}});var Np=P((D0,Ip)=>{var v={};Ip.exports=v;v.themes={};var pw=require("util"),Fe=v.styles=pp(),Ap=Object.defineProperties,fw=new RegExp(/[\r\n]+/g);v.supportsColor=mp().supportsColor;typeof v.enabled>"u"&&(v.enabled=v.supportsColor()!==!1);v.enable=function(){v.enabled=!0};v.disable=function(){v.enabled=!1};v.stripColors=v.strip=function(e){return(""+e).replace(/\x1B\[\d+m/g,"")};var g0=v.stylize=function(t,r){if(!v.enabled)return t+"";var n=Fe[r];return!n&&r in v?v[r](t):n.open+t+n.close},dw=/[|\\{}()[\]^$+*?.]/g,hw=function(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(dw,"\\$&")};function Pp(e){var t=function r(){return gw.apply(r,arguments)};return t._styles=e,t.__proto__=mw,t}var Rp=(function(){var e={};return Fe.grey=Fe.gray,Object.keys(Fe).forEach(function(t){Fe[t].closeRe=new RegExp(hw(Fe[t].close),"g"),e[t]={get:function(){return Pp(this._styles.concat(t))}}}),e})(),mw=Ap(function(){},Rp);function gw(){var e=Array.prototype.slice.call(arguments),t=e.map(function(i){return i!=null&&i.constructor===String?i:pw.inspect(i)}).join(" ");if(!v.enabled||!t)return t;for(var r=t.indexOf(`
7
+ `)!=-1,n=this._styles,s=n.length;s--;){var o=Fe[n[s]];t=o.open+t.replace(o.closeRe,o.open)+o.close,r&&(t=t.replace(fw,function(i){return o.close+i+o.open}))}return t}v.setTheme=function(e){if(typeof e=="string"){console.log("colors.setTheme now only accepts an object, not a string. If you are trying to set a theme from a file, it is now your (the caller's) responsibility to require the file. The old syntax looked like colors.setTheme(__dirname + '/../themes/generic-logging.js'); The new syntax looks like colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));");return}for(var t in e)(function(r){v[r]=function(n){if(typeof e[r]=="object"){var s=n;for(var o in e[r])s=v[e[r][o]](s);return s}return v[e[r]](n)}})(t)};function Dw(){var e={};return Object.keys(Rp).forEach(function(t){e[t]={get:function(){return Pp([t])}}}),e}var yw=function(t,r){var n=r.split("");return n=n.map(t),n.join("")};v.trap=Dp();v.zalgo=wp();v.maps={};v.maps.america=bp()(v);v.maps.zebra=vp()(v);v.maps.rainbow=Ep()(v);v.maps.random=Fp()(v);for(Tp in v.maps)(function(e){v[e]=function(t){return yw(v.maps[e],t)}})(Tp);var Tp;Ap(v,Dw())});var Mp=P((y0,Op)=>{var ww=Np();Op.exports=ww});var _p=P((w0,Is)=>{var{info:Cw,debug:jp}=Ps(),ut=Fi(),Pi=class e{constructor(t){this.setOptions(t),this.x=null,this.y=null}setOptions(t){["boolean","number","bigint","string"].indexOf(typeof t)!==-1&&(t={content:""+t}),t=t||{},this.options=t;let r=t.content;if(["boolean","number","bigint","string"].indexOf(typeof r)!==-1)this.content=String(r);else if(!r)this.content=this.options.href||"";else throw new Error("Content needs to be a primitive, got: "+typeof r);this.colSpan=t.colSpan||1,this.rowSpan=t.rowSpan||1,this.options.href&&Object.defineProperty(this,"href",{get(){return this.options.href}})}mergeTableOptions(t,r){this.cells=r;let n=this.options.chars||{},s=t.chars,o=this.chars={};xw.forEach(function(c){Ai(n,s,c,o)}),this.truncate=this.options.truncate||t.truncate;let i=this.options.style=this.options.style||{},a=t.style;Ai(i,a,"padding-left",this),Ai(i,a,"padding-right",this),this.head=i.head||a.head,this.border=i.border||a.border,this.fixedWidth=t.colWidths[this.x],this.lines=this.computeLines(t),this.desiredWidth=ut.strlen(this.content)+this.paddingLeft+this.paddingRight,this.desiredHeight=this.lines.length}computeLines(t){let r=t.wordWrap||t.textWrap,{wordWrap:n=r}=this.options;if(this.fixedWidth&&n){if(this.fixedWidth-=this.paddingLeft+this.paddingRight,this.colSpan){let i=1;for(;i<this.colSpan;)this.fixedWidth+=t.colWidths[this.x+i],i++}let{wrapOnWordBoundary:s=!0}=t,{wrapOnWordBoundary:o=s}=this.options;return this.wrapLines(ut.wordWrap(this.fixedWidth,this.content,o))}return this.wrapLines(this.content.split(`
8
+ `))}wrapLines(t){let r=ut.colorizeLines(t);return this.href?r.map(n=>ut.hyperlink(this.href,n)):r}init(t){let r=this.x,n=this.y;this.widths=t.colWidths.slice(r,r+this.colSpan),this.heights=t.rowHeights.slice(n,n+this.rowSpan),this.width=this.widths.reduce(Bp,-1),this.height=this.heights.reduce(Bp,-1),this.hAlign=this.options.hAlign||t.colAligns[r],this.vAlign=this.options.vAlign||t.rowAligns[n],this.drawRight=r+this.colSpan==t.colWidths.length}draw(t,r){if(t=="top")return this.drawTop(this.drawRight);if(t=="bottom")return this.drawBottom(this.drawRight);let n=ut.truncate(this.content,10,this.truncate);t||Cw(`${this.y}-${this.x}: ${this.rowSpan-t}x${this.colSpan} Cell ${n}`);let s=Math.max(this.height-this.lines.length,0),o;switch(this.vAlign){case"center":o=Math.ceil(s/2);break;case"bottom":o=s;break;default:o=0}if(t<o||t>=o+this.lines.length)return this.drawEmpty(this.drawRight,r);let i=this.lines.length>this.height&&t+1>=this.height;return this.drawLine(t-o,this.drawRight,i,r)}drawTop(t){let r=[];return this.cells?this.widths.forEach(function(n,s){r.push(this._topLeftChar(s)),r.push(ut.repeat(this.chars[this.y==0?"top":"mid"],n))},this):(r.push(this._topLeftChar(0)),r.push(ut.repeat(this.chars[this.y==0?"top":"mid"],this.width))),t&&r.push(this.chars[this.y==0?"topRight":"rightMid"]),this.wrapWithStyleColors("border",r.join(""))}_topLeftChar(t){let r=this.x+t,n;if(this.y==0)n=r==0?"topLeft":t==0?"topMid":"top";else if(r==0)n="leftMid";else if(n=t==0?"midMid":"bottomMid",this.cells&&(this.cells[this.y-1][r]instanceof e.ColSpanCell&&(n=t==0?"topMid":"mid"),t==0)){let o=1;for(;this.cells[this.y][r-o]instanceof e.ColSpanCell;)o++;this.cells[this.y][r-o]instanceof e.RowSpanCell&&(n="leftMid")}return this.chars[n]}wrapWithStyleColors(t,r){if(this[t]&&this[t].length)try{let n=Mp();for(let s=this[t].length-1;s>=0;s--)n=n[this[t][s]];return n(r)}catch{return r}else return r}drawLine(t,r,n,s){let o=this.chars[this.x==0?"left":"middle"];if(this.x&&s&&this.cells){let d=this.cells[this.y+s][this.x-1];for(;d instanceof yn;)d=this.cells[d.y][d.x-1];d instanceof wn||(o=this.chars.rightMid)}let i=ut.repeat(" ",this.paddingLeft),a=r?this.chars.right:"",c=ut.repeat(" ",this.paddingRight),l=this.lines[t],u=this.width-(this.paddingLeft+this.paddingRight);n&&(l+=this.truncate||"\u2026");let p=ut.truncate(l,u,this.truncate);return p=ut.pad(p,u," ",this.hAlign),p=i+p+c,this.stylizeLine(o,p,a)}stylizeLine(t,r,n){return t=this.wrapWithStyleColors("border",t),n=this.wrapWithStyleColors("border",n),this.y===0&&(r=this.wrapWithStyleColors("head",r)),t+r+n}drawBottom(t){let r=this.chars[this.x==0?"bottomLeft":"bottomMid"],n=ut.repeat(this.chars.bottom,this.width),s=t?this.chars.bottomRight:"";return this.wrapWithStyleColors("border",r+n+s)}drawEmpty(t,r){let n=this.chars[this.x==0?"left":"middle"];if(this.x&&r&&this.cells){let i=this.cells[this.y+r][this.x-1];for(;i instanceof yn;)i=this.cells[i.y][i.x-1];i instanceof wn||(n=this.chars.rightMid)}let s=t?this.chars.right:"",o=ut.repeat(" ",this.width);return this.stylizeLine(n,o,s)}},yn=class{constructor(){}draw(t){return typeof t=="number"&&jp(`${this.y}-${this.x}: 1x1 ColSpanCell`),""}init(){}mergeTableOptions(){}},wn=class{constructor(t){this.originalCell=t}init(t){let r=this.y,n=this.originalCell.y;this.cellOffset=r-n,this.offset=bw(t.rowHeights,n,this.cellOffset)}draw(t){return t=="top"?this.originalCell.draw(this.offset,this.cellOffset):t=="bottom"?this.originalCell.draw("bottom"):(jp(`${this.y}-${this.x}: 1x${this.colSpan} RowSpanCell for ${this.originalCell.content}`),this.originalCell.draw(this.offset+1+t))}mergeTableOptions(){}};function $p(...e){return e.filter(t=>t!=null).shift()}function Ai(e,t,r,n){let s=r.split("-");s.length>1?(s[1]=s[1].charAt(0).toUpperCase()+s[1].substr(1),s=s.join(""),n[s]=$p(e[s],e[r],t[s],t[r])):n[r]=$p(e[r],t[r])}function bw(e,t,r){let n=e[t];for(let s=1;s<r;s++)n+=1+e[t+s];return n}function Bp(e,t){return e+t+1}var xw=["top","top-mid","top-left","top-right","bottom","bottom-mid","bottom-left","bottom-right","left","left-mid","mid","mid-mid","right","right-mid","middle"];Is.exports=Pi;Is.exports.ColSpanCell=yn;Is.exports.RowSpanCell=wn});var Gp=P((C0,Wp)=>{var{warn:vw,debug:kw}=Ps(),Ri=_p(),{ColSpanCell:Ew,RowSpanCell:Sw}=Ri;(function(){function e(f,m){return f[m]>0?e(f,m+1):m}function t(f){let m={};f.forEach(function(h,D){let g=0;h.forEach(function(y){y.y=D,y.x=D?e(m,g):g;let x=y.rowSpan||1,C=y.colSpan||1;if(x>1)for(let A=0;A<C;A++)m[y.x+A]=x;g=y.x+C}),Object.keys(m).forEach(y=>{m[y]--,m[y]<1&&delete m[y]})})}function r(f){let m=0;return f.forEach(function(h){h.forEach(function(D){m=Math.max(m,D.x+(D.colSpan||1))})}),m}function n(f){return f.length}function s(f,m){let h=f.y,D=f.y-1+(f.rowSpan||1),g=m.y,y=m.y-1+(m.rowSpan||1),x=!(h>y||g>D),C=f.x,A=f.x-1+(f.colSpan||1),dt=m.x,ne=m.x-1+(m.colSpan||1),Ae=!(C>ne||dt>A);return x&&Ae}function o(f,m,h){let D=Math.min(f.length-1,h),g={x:m,y:h};for(let y=0;y<=D;y++){let x=f[y];for(let C=0;C<x.length;C++)if(s(g,x[C]))return!0}return!1}function i(f,m,h,D){for(let g=h;g<D;g++)if(o(f,g,m))return!1;return!0}function a(f){f.forEach(function(m,h){m.forEach(function(D){for(let g=1;g<D.rowSpan;g++){let y=new Sw(D);y.x=D.x,y.y=D.y+g,y.colSpan=D.colSpan,l(y,f[h+g])}})})}function c(f){for(let m=f.length-1;m>=0;m--){let h=f[m];for(let D=0;D<h.length;D++){let g=h[D];for(let y=1;y<g.colSpan;y++){let x=new Ew;x.x=g.x+y,x.y=g.y,h.splice(D+1,0,x)}}}}function l(f,m){let h=0;for(;h<m.length&&m[h].x<f.x;)h++;m.splice(h,0,f)}function u(f){let m=n(f),h=r(f);kw(`Max rows: ${m}; Max cols: ${h}`);for(let D=0;D<m;D++)for(let g=0;g<h;g++)if(!o(f,g,D)){let y={x:g,y:D,colSpan:1,rowSpan:1};for(g++;g<h&&!o(f,g,D);)y.colSpan++,g++;let x=D+1;for(;x<m&&i(f,x,y.x,y.x+y.colSpan);)y.rowSpan++,x++;let C=new Ri(y);C.x=y.x,C.y=y.y,vw(`Missing cell at ${C.y}-${C.x}.`),l(C,f[D])}}function p(f){return f.map(function(m){if(!Array.isArray(m)){let h=Object.keys(m)[0];m=m[h],Array.isArray(m)?(m=m.slice(),m.unshift(h)):m=[h,m]}return m.map(function(h){return new Ri(h)})})}function d(f){let m=p(f);return t(m),u(m),a(m),c(m),m}Wp.exports={makeTableLayout:d,layoutTable:t,addRowSpanCells:a,maxWidth:r,fillInTable:u,computeWidths:Lp("colSpan","desiredWidth","x",1),computeHeights:Lp("rowSpan","desiredHeight","y",1)}})();function Lp(e,t,r,n){return function(s,o){let i=[],a=[],c={};o.forEach(function(l){l.forEach(function(u){(u[e]||1)>1?a.push(u):i[u[r]]=Math.max(i[u[r]]||0,u[t]||0,n)})}),s.forEach(function(l,u){typeof l=="number"&&(i[u]=l)});for(let l=a.length-1;l>=0;l--){let u=a[l],p=u[e],d=u[r],f=i[d],m=typeof s[d]=="number"?0:1;if(typeof f=="number")for(let h=1;h<p;h++)f+=1+i[d+h],typeof s[d+h]!="number"&&m++;else f=t==="desiredWidth"?u.desiredWidth-1:1,(!c[d]||c[d]<f)&&(c[d]=f);if(u[t]>f){let h=0;for(;m>0&&u[t]>f;){if(typeof s[d+h]!="number"){let D=Math.round((u[t]-f)/m);f+=D,i[d+h]+=D,m--}h++}}}Object.assign(s,i,c);for(let l=0;l<s.length;l++)s[l]=Math.max(n,s[l]||0)}}});var Up=P((b0,Hp)=>{var Qt=Ps(),Fw=Fi(),Ii=Gp(),Ns=class extends Array{constructor(t){super();let r=Fw.mergeOptions(t);if(Object.defineProperty(this,"options",{value:r,enumerable:r.debug}),r.debug){switch(typeof r.debug){case"boolean":Qt.setDebugLevel(Qt.WARN);break;case"number":Qt.setDebugLevel(r.debug);break;case"string":Qt.setDebugLevel(parseInt(r.debug,10));break;default:Qt.setDebugLevel(Qt.WARN),Qt.warn(`Debug option is expected to be boolean, number, or string. Received a ${typeof r.debug}`)}Object.defineProperty(this,"messages",{get(){return Qt.debugMessages()}})}}toString(){let t=this,r=this.options.head&&this.options.head.length;r?(t=[this.options.head],this.length&&t.push.apply(t,this)):this.options.style.head=[];let n=Ii.makeTableLayout(t);n.forEach(function(o){o.forEach(function(i){i.mergeTableOptions(this.options,n)},this)},this),Ii.computeWidths(this.options.colWidths,n),Ii.computeHeights(this.options.rowHeights,n),n.forEach(function(o){o.forEach(function(i){i.init(this.options)},this)},this);let s=[];for(let o=0;o<n.length;o++){let i=n[o],a=this.options.rowHeights[o];(o===0||!this.options.style.compact||o==1&&r)&&Ni(i,"top",s);for(let c=0;c<a;c++)Ni(i,c,s);o+1==n.length&&Ni(i,"bottom",s)}return s.join(`
9
9
  `)}get width(){return this.toString().split(`
10
- `)[0].length}};Is.reset=()=>Xt.reset();function Ti(e,t,r){let n=[];e.forEach(function(o){n.push(o.draw(t))});let s=n.join("");s.length&&r.push(s)}Np.exports=Is});var Ai=P((zS,Mp)=>{Mp.exports=Op()});var id=require("node:process"),Se=b(require("chalk")),ad=require("commander");var xn={};gd(xn,{ConEmu:()=>ca,beep:()=>zd,clearScreen:()=>_d,clearTerminal:()=>Gd,clearViewport:()=>Ld,cursorBackward:()=>kd,cursorDown:()=>vd,cursorForward:()=>xd,cursorGetPosition:()=>Fd,cursorHide:()=>Pd,cursorLeft:()=>oa,cursorMove:()=>bd,cursorNextLine:()=>Td,cursorPrevLine:()=>Ad,cursorRestorePosition:()=>Sd,cursorSavePosition:()=>Ed,cursorShow:()=>Rd,cursorTo:()=>Cd,cursorUp:()=>sa,enterAlternativeScreen:()=>Hd,eraseDown:()=>Md,eraseEndLine:()=>Nd,eraseLine:()=>ia,eraseLines:()=>Id,eraseScreen:()=>vn,eraseStartLine:()=>Od,eraseUp:()=>$d,exitAlternativeScreen:()=>Ud,iTerm:()=>aa,image:()=>Jd,link:()=>Kd,scrollDown:()=>jd,scrollUp:()=>Bd,setCwd:()=>Vd});var me=b(require("node:process"),1),ra=b(require("node:os"),1);var Pe=globalThis.window?.document!==void 0,NC=globalThis.process?.versions?.node!==void 0,OC=globalThis.process?.versions?.bun!==void 0,MC=globalThis.Deno?.version?.deno!==void 0,$C=globalThis.process?.versions?.electron!==void 0,BC=globalThis.navigator?.userAgent?.includes("jsdom")===!0,jC=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,_C=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,LC=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,WC=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Fr=globalThis.navigator?.userAgentData?.platform,GC=Fr==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",HC=Fr==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",UC=Fr==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",zC=Fr==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),KC=Fr==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var E="\x1B[",Re="\x1B]",ge="\x07",Tr=";",na=!Pe&&me.default.env.TERM_PROGRAM==="Apple_Terminal",yd=!Pe&&me.default.platform==="win32",wd=!Pe&&(me.default.env.TERM?.startsWith("screen")||me.default.env.TERM?.startsWith("tmux")||me.default.env.TMUX!==void 0),qs=Pe?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:me.default.cwd,Ie=e=>wd?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,Cd=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?E+(e+1)+"G":E+(t+1)+Tr+(e+1)+"H"},bd=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=E+-e+"D":e>0&&(r+=E+e+"C"),t<0?r+=E+-t+"A":t>0&&(r+=E+t+"B"),r},sa=(e=1)=>E+e+"A",vd=(e=1)=>E+e+"B",xd=(e=1)=>E+e+"C",kd=(e=1)=>E+e+"D",oa=E+"G",Ed=na?"\x1B7":E+"s",Sd=na?"\x1B8":E+"u",Fd=E+"6n",Td=E+"E",Ad=E+"F",Pd=E+"?25l",Rd=E+"?25h",Id=e=>{let t="";for(let r=0;r<e;r++)t+=ia+(r<e-1?sa():"");return e&&(t+=oa),t},Nd=E+"K",Od=E+"1K",ia=E+"2K",Md=E+"J",$d=E+"1J",vn=E+"2J",Bd=E+"S",jd=E+"T",_d="\x1Bc",Ld=`${vn}${E}H`,Wd=()=>{if(Pe||!yd)return!1;let e=ra.default.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},Gd=Wd()?`${vn}${E}0f`:`${vn}${E}3J${E}H`,Hd=E+"?1049h",Ud=E+"?1049l",zd=ge,Kd=(e,t)=>{let r=Ie(`${Re}8${Tr}${Tr}${t}${ge}`),n=Ie(`${Re}8${Tr}${Tr}${ge}`);return r+e+n},Jd=(e,t={})=>{let r=`${Re}1337;File=inline=1`;t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0");let n=Buffer.from(e);return Ie(r+`;size=${n.byteLength}:`+n.toString("base64")+ge)},aa={setCwd:(e=qs())=>Ie(`${Re}50;CurrentDir=${e}${ge}`),annotation(e,t={}){let r=`${Re}1337;`,n=t.x!==void 0,s=t.y!==void 0;if((n||s)&&!(n&&s&&t.length!==void 0))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replaceAll("|",""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(n?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,Ie(r+ge)}},ca={setCwd:(e=qs())=>Ie(`${Re}9;9;${e}${ge}`)},Vd=(e=qs())=>aa.setCwd(e)+ca.setCwd(e);var kn=b(ma(),1);function Ut(e,t,{target:r="stdout",...n}={}){return kn.default[r]?xn.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}Ut.isSupported=kn.default.stdout;Ut.stderr=(e,t,r={})=>Ut(e,t,{target:"stderr",...r});Ut.stderr.isSupported=kn.default.stderr;var xu=b(require("chalk")),ku=require("commander");var bt=require("node:fs"),rt=require("node:path"),be=require("fs-extra");var ga=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],to="start:dev";var Ar=b(require("chalk"));function eo(e,t){if(e.length===0)return"No entries to display.";let r=t?.title||"Benchmark Results",n=t?.footer||"",s=t?.maxBarWidth||50,o=t?.unit||"",i=Math.max(...e.map(c=>c.value)),a=[];a.push(""),a.push(r),a.push("");for(let c of e){let u=Xd(c.barColor??t?.barColor),l=Qd(c,i,s,u,o,t?.labelColor);a.push(l)}return n&&(a.push(""),a.push(n)),a.join(`
11
- `)}function Xd(e){return e?Ar.default[e]("\u2587"):"\u2587"}function Qd(e,t,r,n,s,o){let i=Math.round(e.value/t*r),a=e.barColor?Ar.default[e.barColor](n.repeat(i)):n.repeat(i),c=e.color??o;return`${Ar.default.bold(c?Ar.default[c](e.label.padEnd(12)):e.label.padEnd(12))} ${a} ${e.value.toLocaleString()}${s?` ${s}`:""}`}var ro=b(require("chalk")),ya=require("commander"),no=require("listr2");var Pr=b(require("chalk")),w={logs:[],breakLine:()=>(console.log(),w),success:(e,...t)=>(console.log(Pr.default.green(`\u2714 ${e}`),...t),w),info:(e,...t)=>(console.log(Pr.default.cyan(`\u{1F6C8} ${e}`),...t),w),warn:(e,...t)=>(console.warn(Pr.default.yellow(`\u26A0\uFE0E ${e}`),...t),w),error:(e,...t)=>(console.error(Pr.default.red(`\u2716 ${e}`),...t),w),log:(e,...t)=>(console.log(e,...t),w.logs.push({message:e,context:t.join()}),w),getStoredLogs:e=>e?w.logs.filter(t=>t.context?.includes(e)):w.logs,storeLog:(e,t)=>w.logs.push({message:e,context:t})};function se(e){let t=new ya.Command(e.name).description(e.description).showHelpAfterError();return e.arguments?.map(([r,n])=>t.argument(r,n)),e.options?.map(([r,n])=>t.option(r,n)),e.exampleUsage&&t.addHelpText("after",()=>`${ro.default.cyan.bold(`
10
+ `)[0].length}};Ns.reset=()=>Qt.reset();function Ni(e,t,r){let n=[];e.forEach(function(o){n.push(o.draw(t))});let s=n.join("");s.length&&r.push(s)}Hp.exports=Ns});var Oi=P((x0,zp)=>{zp.exports=Up()});var wd=require("node:process"),Te=b(require("chalk")),Cd=require("commander");var Sn={};Ad(Sn,{ConEmu:()=>fa,beep:()=>sh,clearScreen:()=>Xd,clearTerminal:()=>eh,clearViewport:()=>Qd,cursorBackward:()=>Bd,cursorDown:()=>Md,cursorForward:()=>$d,cursorGetPosition:()=>Ld,cursorHide:()=>Hd,cursorLeft:()=>la,cursorMove:()=>Od,cursorNextLine:()=>Wd,cursorPrevLine:()=>Gd,cursorRestorePosition:()=>_d,cursorSavePosition:()=>jd,cursorShow:()=>Ud,cursorTo:()=>Nd,cursorUp:()=>ca,enterAlternativeScreen:()=>rh,eraseDown:()=>qd,eraseEndLine:()=>Kd,eraseLine:()=>ua,eraseLines:()=>zd,eraseScreen:()=>En,eraseStartLine:()=>Jd,eraseUp:()=>Vd,exitAlternativeScreen:()=>nh,iTerm:()=>pa,image:()=>ih,link:()=>oh,scrollDown:()=>Zd,scrollUp:()=>Yd,setCwd:()=>ah});var De=b(require("node:process"),1),ia=b(require("node:os"),1);var Ie=globalThis.window?.document!==void 0,ab=globalThis.process?.versions?.node!==void 0,cb=globalThis.process?.versions?.bun!==void 0,lb=globalThis.Deno?.version?.deno!==void 0,ub=globalThis.process?.versions?.electron!==void 0,pb=globalThis.navigator?.userAgent?.includes("jsdom")===!0,fb=typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope,db=typeof DedicatedWorkerGlobalScope<"u"&&globalThis instanceof DedicatedWorkerGlobalScope,hb=typeof SharedWorkerGlobalScope<"u"&&globalThis instanceof SharedWorkerGlobalScope,mb=typeof ServiceWorkerGlobalScope<"u"&&globalThis instanceof ServiceWorkerGlobalScope,Ar=globalThis.navigator?.userAgentData?.platform,gb=Ar==="macOS"||globalThis.navigator?.platform==="MacIntel"||globalThis.navigator?.userAgent?.includes(" Mac ")===!0||globalThis.process?.platform==="darwin",Db=Ar==="Windows"||globalThis.navigator?.platform==="Win32"||globalThis.process?.platform==="win32",yb=Ar==="Linux"||globalThis.navigator?.platform?.startsWith("Linux")===!0||globalThis.navigator?.userAgent?.includes(" Linux ")===!0||globalThis.process?.platform==="linux",wb=Ar==="iOS"||globalThis.navigator?.platform==="MacIntel"&&globalThis.navigator?.maxTouchPoints>1||/iPad|iPhone|iPod/.test(globalThis.navigator?.platform),Cb=Ar==="Android"||globalThis.navigator?.platform==="Android"||globalThis.navigator?.userAgent?.includes(" Android ")===!0||globalThis.process?.platform==="android";var E="\x1B[",Ne="\x1B]",ye="\x07",Pr=";",aa=!Ie&&De.default.env.TERM_PROGRAM==="Apple_Terminal",Rd=!Ie&&De.default.platform==="win32",Id=!Ie&&(De.default.env.TERM?.startsWith("screen")||De.default.env.TERM?.startsWith("tmux")||De.default.env.TMUX!==void 0),Xs=Ie?()=>{throw new Error("`process.cwd()` only works in Node.js, not the browser.")}:De.default.cwd,Oe=e=>Id?"\x1BPtmux;"+e.replaceAll("\x1B","\x1B\x1B")+"\x1B\\":e,Nd=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");return typeof t!="number"?E+(e+1)+"G":E+(t+1)+Pr+(e+1)+"H"},Od=(e,t)=>{if(typeof e!="number")throw new TypeError("The `x` argument is required");let r="";return e<0?r+=E+-e+"D":e>0&&(r+=E+e+"C"),t<0?r+=E+-t+"A":t>0&&(r+=E+t+"B"),r},ca=(e=1)=>E+e+"A",Md=(e=1)=>E+e+"B",$d=(e=1)=>E+e+"C",Bd=(e=1)=>E+e+"D",la=E+"G",jd=aa?"\x1B7":E+"s",_d=aa?"\x1B8":E+"u",Ld=E+"6n",Wd=E+"E",Gd=E+"F",Hd=E+"?25l",Ud=E+"?25h",zd=e=>{let t="";for(let r=0;r<e;r++)t+=ua+(r<e-1?ca():"");return e&&(t+=la),t},Kd=E+"K",Jd=E+"1K",ua=E+"2K",qd=E+"J",Vd=E+"1J",En=E+"2J",Yd=E+"S",Zd=E+"T",Xd="\x1Bc",Qd=`${En}${E}H`,th=()=>{if(Ie||!Rd)return!1;let e=ia.default.release().split("."),t=Number(e[0]),r=Number(e[2]??0);return t<10||t===10&&r<10586},eh=th()?`${En}${E}0f`:`${En}${E}3J${E}H`,rh=E+"?1049h",nh=E+"?1049l",sh=ye,oh=(e,t)=>{let r=Oe(`${Ne}8${Pr}${Pr}${t}${ye}`),n=Oe(`${Ne}8${Pr}${Pr}${ye}`);return r+e+n},ih=(e,t={})=>{let r=`${Ne}1337;File=inline=1`;t.width&&(r+=`;width=${t.width}`),t.height&&(r+=`;height=${t.height}`),t.preserveAspectRatio===!1&&(r+=";preserveAspectRatio=0");let n=Buffer.from(e);return Oe(r+`;size=${n.byteLength}:`+n.toString("base64")+ye)},pa={setCwd:(e=Xs())=>Oe(`${Ne}50;CurrentDir=${e}${ye}`),annotation(e,t={}){let r=`${Ne}1337;`,n=t.x!==void 0,s=t.y!==void 0;if((n||s)&&!(n&&s&&t.length!==void 0))throw new Error("`x`, `y` and `length` must be defined when `x` or `y` is defined");return e=e.replaceAll("|",""),r+=t.isHidden?"AddHiddenAnnotation=":"AddAnnotation=",t.length>0?r+=(n?[e,t.length,t.x,t.y]:[t.length,e]).join("|"):r+=e,Oe(r+ye)}},fa={setCwd:(e=Xs())=>Oe(`${Ne}9;9;${e}${ye}`)},ah=(e=Xs())=>pa.setCwd(e)+fa.setCwd(e);var Fn=b(wa(),1);function zt(e,t,{target:r="stdout",...n}={}){return Fn.default[r]?Sn.link(e,t):n.fallback===!1?e:typeof n.fallback=="function"?n.fallback(e,t):`${e} (\u200B${t}\u200B)`}zt.isSupported=Fn.default.stdout;zt.stderr=(e,t,r={})=>zt(e,t,{target:"stderr",...r});zt.stderr.isSupported=Fn.default.stderr;var Fl=b(require("chalk")),Tl=require("commander");var vt=require("node:fs"),ot=require("node:path"),ve=require("fs-extra");var Ca=["bun.lock","bun.lockb","package-lock.json","yarn.lock","pnpm-lock.yaml"],no="start:dev";var Rr=b(require("chalk"));function so(e,t){if(e.length===0)return"No entries to display.";let r=t?.title||"Benchmark Results",n=t?.footer||"",s=t?.maxBarWidth||50,o=t?.unit||"",i=Math.max(...e.map(c=>c.value)),a=[];a.push(""),a.push(r),a.push("");for(let c of e){let l=ph(c.barColor??t?.barColor),u=fh(c,i,s,l,o,t?.labelColor);a.push(u)}return n&&(a.push(""),a.push(n)),a.join(`
11
+ `)}function ph(e){return e?Rr.default[e]("\u2587"):"\u2587"}function fh(e,t,r,n,s,o){let i=Math.round(e.value/t*r),a=e.barColor?Rr.default[e.barColor](n.repeat(i)):n.repeat(i),c=e.color??o;return`${Rr.default.bold(c?Rr.default[c](e.label.padEnd(12)):e.label.padEnd(12))} ${a} ${e.value.toLocaleString()}${s?` ${s}`:""}`}var oo=b(require("chalk")),xa=require("commander"),io=require("listr2");var Ir=b(require("chalk")),w={logs:[],breakLine:()=>(console.log(),w),success:(e,...t)=>(console.log(Ir.default.green(`\u2714 ${e}`),...t),w),info:(e,...t)=>(console.log(Ir.default.cyan(`\u{1F6C8} ${e}`),...t),w),warn:(e,...t)=>(console.warn(Ir.default.yellow(`\u26A0\uFE0E ${e}`),...t),w),error:(e,...t)=>(console.error(Ir.default.red(`\u2716 ${e}`),...t),w),log:(e,...t)=>(console.log(e,...t),w.logs.push({message:e,context:t.join()}),w),getStoredLogs:e=>e?w.logs.filter(t=>t.context?.includes(e)):w.logs,storeLog:(e,t)=>w.logs.push({message:e,context:t})};function oe(e){let t=new xa.Command(e.name).description(e.description).showHelpAfterError();return e.arguments?.map(([r,n])=>t.argument(r,n)),e.options?.map(([r,n])=>t.option(r,n)),e.exampleUsage&&t.addHelpText("after",()=>`${oo.default.cyan.bold(`
12
12
  Example:`)}
13
- ${ro.default.bold(e.exampleUsage)}
14
- `),e.additionalInfo&&t.addHelpText("after",()=>(typeof e.additionalInfo=="function"?e.additionalInfo():e.additionalInfo)??""),t.action(async(...r)=>{try{let n=r.at(-1),s=n.args,o=n.opts(),i=th(e.arguments??[],s);if(e.shouldSkipWorkflow?.(i,o)){await e.onSkipWorkflow?.(i,o);return}let a=await e.buildContext(i,o);e.prompts?.length&&await new no.Listr(Da(e.prompts,a),{rendererOptions:{lazy:!0,showErrorMessage:!1}}).run(a),await new no.Listr(Da(e.actions,a),{rendererOptions:{lazy:!1,showErrorMessage:!1,clearOutput:!0}}).run(a),await e.onComplete?.(a)}catch(n){let s=n;w.error(s.message)}}),t}function th(e,t){let r={};return e.forEach(([n],s)=>{let o=n.replace(/[<>[\]]/g,"");r[o]=t[s]}),r}function Da(e,t){return e.map(r=>typeof r=="function"?r(t):r)}function En(e,t,r){let n=t.split("."),s=e;for(;n.length>1;){let o=n.shift();o in s||(s[o]={}),s=s[o]}s[n[0]]=r}var wa=require("execa");function Rr(e){try{return(0,wa.execaSync)(e,["--version"]),!0}catch{return!1}}var Ye=require("node:path"),qc=require("fs-extra");var Ea=b(require("node:process"),1);var ba=b(require("node:process"),1);var va=require("node:url"),xa=b(require("node:fs"),1),De=b(require("node:path"),1),Ca=e=>e instanceof URL?(0,va.fileURLToPath)(e):e;function ka(e,{cwd:t=ba.default.cwd(),type:r="file",stopAt:n}={}){let s=De.default.resolve(Ca(t)??""),{root:o}=De.default.parse(s);n=De.default.resolve(s,Ca(n)??o);let i=De.default.isAbsolute(e);for(;s;){let a=i?e:De.default.join(s,e);try{let c=xa.default.statSync(a,{throwIfNoEntry:!1});if(r==="file"&&c?.isFile()||r==="directory"&&c?.isDirectory())return a}catch{}if(s===n||s===o)break;s=De.default.dirname(s)}}function Sa({cwd:e=Ea.default.cwd()}={}){return ka("package.json",{cwd:e})}var so=(e,t,r)=>{let n=e instanceof RegExp?Fa(e,r):e,s=t instanceof RegExp?Fa(t,r):t,o=n!==null&&s!=null&&eh(n,s,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+s.length)}},Fa=(e,t)=>{let r=t.match(e);return r?r[0]:null},eh=(e,t,r)=>{let n,s,o,i,a,c=r.indexOf(e),u=r.indexOf(t,c+1),l=c;if(c>=0&&u>0){if(e===t)return[c,u];for(n=[],o=r.length;l>=0&&!a;){if(l===c)n.push(l),c=r.indexOf(e,l+1);else if(n.length===1){let p=n.pop();p!==void 0&&(a=[p,u])}else s=n.pop(),s!==void 0&&s<o&&(o=s,i=u),u=r.indexOf(t,l+1);l=c<u&&c>=0?c:u}n.length&&i!==void 0&&(a=[o,i])}return a};var Ta="\0SLASH"+Math.random()+"\0",Aa="\0OPEN"+Math.random()+"\0",io="\0CLOSE"+Math.random()+"\0",Pa="\0COMMA"+Math.random()+"\0",Ra="\0PERIOD"+Math.random()+"\0",rh=new RegExp(Ta,"g"),nh=new RegExp(Aa,"g"),sh=new RegExp(io,"g"),oh=new RegExp(Pa,"g"),ih=new RegExp(Ra,"g"),ah=/\\\\/g,ch=/\\{/g,uh=/\\}/g,lh=/\\,/g,ph=/\\./g;function oo(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function fh(e){return e.replace(ah,Ta).replace(ch,Aa).replace(uh,io).replace(lh,Pa).replace(ph,Ra)}function dh(e){return e.replace(rh,"\\").replace(nh,"{").replace(sh,"}").replace(oh,",").replace(ih,".")}function Ia(e){if(!e)return[""];let t=[],r=so("{","}",e);if(!r)return e.split(",");let{pre:n,body:s,post:o}=r,i=n.split(",");i[i.length-1]+="{"+s+"}";let a=Ia(o);return o.length&&(i[i.length-1]+=a.shift(),i.push.apply(i,a)),t.push.apply(t,i),t}function Na(e){return e?(e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Ir(fh(e),!0).map(dh)):[]}function hh(e){return"{"+e+"}"}function mh(e){return/^-?0\d/.test(e)}function gh(e,t){return e<=t}function Dh(e,t){return e>=t}function Ir(e,t){let r=[],n=so("{","}",e);if(!n)return[e];let s=n.pre,o=n.post.length?Ir(n.post,!1):[""];if(/\$$/.test(n.pre))for(let i=0;i<o.length;i++){let a=s+"{"+n.body+"}"+o[i];r.push(a)}else{let i=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=i||a,u=n.body.indexOf(",")>=0;if(!c&&!u)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+io+n.post,Ir(e)):[e];let l;if(c)l=n.body.split(/\.\./);else if(l=Ia(n.body),l.length===1&&l[0]!==void 0&&(l=Ir(l[0],!1).map(hh),l.length===1))return o.map(d=>n.pre+l[0]+d);let p;if(c&&l[0]!==void 0&&l[1]!==void 0){let d=oo(l[0]),f=oo(l[1]),m=Math.max(l[0].length,l[1].length),h=l.length===3&&l[2]!==void 0?Math.abs(oo(l[2])):1,D=gh;f<d&&(h*=-1,D=Dh);let y=l.some(mh);p=[];for(let v=d;D(v,f);v+=h){let C;if(a)C=String.fromCharCode(v),C==="\\"&&(C="");else if(C=String(v),y){let A=m-C.length;if(A>0){let lt=new Array(A+1).join("0");v<0?C="-"+lt+C.slice(1):C=lt+C}}p.push(C)}}else{p=[];for(let d=0;d<l.length;d++)p.push.apply(p,Ir(l[d],!1))}for(let d=0;d<p.length;d++)for(let f=0;f<o.length;f++){let m=s+p[d]+o[f];(!t||c||m)&&r.push(m)}}return r}var Nr=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var yh={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Or=e=>e.replace(/[[\]\\-]/g,"\\$&"),wh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),Oa=e=>e.join(""),Ma=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=r+1,i=!1,a=!1,c=!1,u=!1,l=r,p="";t:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){u=!0,o++;continue}if(h==="]"&&i&&!c){l=o+1;break}if(i=!0,h==="\\"&&!c){c=!0,o++;continue}if(h==="["&&!c){for(let[D,[g,y,v]]of Object.entries(yh))if(e.startsWith(D,o)){if(p)return["$.",!1,e.length-r,!0];o+=D.length,v?s.push(g):n.push(g),a=a||y;continue t}}if(c=!1,p){h>p?n.push(Or(p)+"-"+Or(h)):h===p&&n.push(Or(h)),p="",o++;continue}if(e.startsWith("-]",o+1)){n.push(Or(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=h,o+=2;continue}n.push(Or(h)),o++}if(l<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!u){let h=n[0].length===2?n[0].slice(-1):n[0];return[wh(h),!1,l-r,!1]}let d="["+(u?"^":"")+Oa(n)+"]",f="["+(u?"":"^")+Oa(s)+"]";return[n.length&&s.length?"("+d+"|"+f+")":n.length?d:f,a,l-r,!0]};var Dt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Ch=new Set(["!","?","+","*","@"]),$a=e=>Ch.has(e),bh="(?!(?:^|/)\\.\\.?(?:$|/))",Sn="(?!\\.)",vh=new Set(["[","."]),xh=new Set(["..","."]),kh=new Set("().*{}+?[]^$\\!"),Eh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ao="[^/]",Ba=ao+"*?",ja=ao+"+?",Oe=class e{type;#t;#r;#o=!1;#s=[];#i;#C;#D;#l=!1;#a;#f;#p=!1;constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#t=this.#i?this.#i.#t:this,this.#a=this.#t===this?n:this.#t.#a,this.#D=this.#t===this?[]:this.#t.#D,t==="!"&&!this.#t.#l&&this.#D.push(this),this.#C=this.#i?this.#i.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#f=this.#s.map(t=>String(t)).join("")}#c(){if(this!==this.#t)throw new Error("should only call on root");if(this.#l)return this;this.toString(),this.#l=!0;let t;for(;t=this.#D.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let s=r.#C+1;!n.type&&s<n.#s.length;s++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#s[s])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#i===this))throw new Error("invalid part: "+r);this.#s.push(r)}}toJSON(){let t=this.type===null?this.#s.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#s.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#l&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#C===0)return!0;let t=this.#i;for(let r=0;r<this.#C;r++){let n=t.#s[r];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#s.length:0;return this.#C===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#s)r.copyIn(n);return r}static#n(t,r,n,s){let o=!1,i=!1,a=-1,c=!1;if(r.type===null){let f=n,m="";for(;f<t.length;){let h=t.charAt(f++);if(o||h==="\\"){o=!o,m+=h;continue}if(i){f===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(f===a+2&&c)&&(i=!1),m+=h;continue}else if(h==="["){i=!0,a=f,c=!1,m+=h;continue}if(!s.noext&&$a(h)&&t.charAt(f)==="("){r.push(m),m="";let D=new e(h,r);f=e.#n(t,D,f,s),r.push(D);continue}m+=h}return r.push(m),f}let u=n+1,l=new e(null,r),p=[],d="";for(;u<t.length;){let f=t.charAt(u++);if(o||f==="\\"){o=!o,d+=f;continue}if(i){u===a+1?(f==="^"||f==="!")&&(c=!0):f==="]"&&!(u===a+2&&c)&&(i=!1),d+=f;continue}else if(f==="["){i=!0,a=u,c=!1,d+=f;continue}if($a(f)&&t.charAt(u)==="("){l.push(d),d="";let m=new e(f,l);l.push(m),u=e.#n(t,m,u,s);continue}if(f==="|"){l.push(d),d="",p.push(l),l=new e(null,r);continue}if(f===")")return d===""&&r.#s.length===0&&(r.#p=!0),l.push(d),d="",r.push(...p,l),u;d+=f}return r.type=null,r.#r=void 0,r.#s=[t.substring(n-1)],u}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#n(t,n,0,r),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[r,n,s,o]=this.toRegExpSource();if(!(s||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#t===this&&this.#c(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#s.some(f=>typeof f!="string"),u=this.#s.map(f=>{let[m,h,D,g]=typeof f=="string"?e.#b(f,this.#r,c):f.toRegExpSource(t);return this.#r=this.#r||D,this.#o=this.#o||g,m}).join(""),l="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&xh.has(this.#s[0]))){let m=vh,h=r&&m.has(u.charAt(0))||u.startsWith("\\.")&&m.has(u.charAt(2))||u.startsWith("\\.\\.")&&m.has(u.charAt(4)),D=!r&&!t&&m.has(u.charAt(0));l=h?bh:D?Sn:""}let p="";return this.isEnd()&&this.#t.#l&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[l+u+p,Dt(u),this.#r=!!this.#r,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#d(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString();return this.#s=[c],this.type=null,this.#r=void 0,[c,Dt(this.toString()),!1,!1]}let i=!n||t||r||!Sn?"":this.#d(!0);i===o&&(i=""),i&&(o=`(?:${o})(?:${i})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?Sn:"")+ja;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?Sn:"")+Ba+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&i?")":this.type==="*"&&i?")?":`)${this.type}`;a=s+o+c}return[a,Dt(o),this.#r=!!this.#r,this.#o]}#d(t){return this.#s.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,o,i]=r.toRegExpSource(t);return this.#o=this.#o||i,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#b(t,r,n=!1){let s=!1,o="",i=!1;for(let a=0;a<t.length;a++){let c=t.charAt(a);if(s){s=!1,o+=(kh.has(c)?"\\":"")+c;continue}if(c==="\\"){a===t.length-1?o+="\\\\":s=!0;continue}if(c==="["){let[u,l,p,d]=Ma(t,a);if(p){o+=u,i=i||l,a+=p-1,r=r||d;continue}}if(c==="*"){o+=n&&t==="*"?ja:Ba,r=!0;continue}if(c==="?"){o+=ao,r=!0;continue}o+=Eh(c)}return[o,Dt(t),!!r,i]}};var Me=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var q=(e,t,r={})=>(Nr(t),!r.nocomment&&t.charAt(0)==="#"?!1:new ot(t,r).match(e)),Sh=/^\*+([^+@!?\*\[\(]*)$/,Fh=e=>t=>!t.startsWith(".")&&t.endsWith(e),Th=e=>t=>t.endsWith(e),Ah=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Ph=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Rh=/^\*+\.\*+$/,Ih=e=>!e.startsWith(".")&&e.includes("."),Nh=e=>e!=="."&&e!==".."&&e.includes("."),Oh=/^\.\*+$/,Mh=e=>e!=="."&&e!==".."&&e.startsWith("."),$h=/^\*+$/,Bh=e=>e.length!==0&&!e.startsWith("."),jh=e=>e.length!==0&&e!=="."&&e!=="..",_h=/^\?+([^+@!?\*\[\(]*)?$/,Lh=([e,t=""])=>{let r=Wa([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Wh=([e,t=""])=>{let r=Ga([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},Gh=([e,t=""])=>{let r=Ga([e]);return t?n=>r(n)&&n.endsWith(t):r},Hh=([e,t=""])=>{let r=Wa([e]);return t?n=>r(n)&&n.endsWith(t):r},Wa=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Ga=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Ha=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",_a={win32:{sep:"\\"},posix:{sep:"/"}},Uh=Ha==="win32"?_a.win32.sep:_a.posix.sep;q.sep=Uh;var H=Symbol("globstar **");q.GLOBSTAR=H;var zh="[^/]",Kh=zh+"*?",Jh="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",Vh="(?:(?!(?:\\/|^)\\.).)*?",qh=(e,t={})=>r=>q(r,e,t);q.filter=qh;var ft=(e,t={})=>Object.assign({},e,t),Yh=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return q;let t=q;return Object.assign((n,s,o={})=>t(n,s,ft(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,ft(e,o))}static defaults(s){return t.defaults(ft(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,i={}){super(s,o,ft(e,i))}static fromGlob(s,o={}){return t.AST.fromGlob(s,ft(e,o))}},unescape:(n,s={})=>t.unescape(n,ft(e,s)),escape:(n,s={})=>t.escape(n,ft(e,s)),filter:(n,s={})=>t.filter(n,ft(e,s)),defaults:n=>t.defaults(ft(e,n)),makeRe:(n,s={})=>t.makeRe(n,ft(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,ft(e,s)),match:(n,s,o={})=>t.match(n,s,ft(e,o)),sep:t.sep,GLOBSTAR:H})};q.defaults=Yh;var Ua=(e,t={})=>(Nr(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Na(e));q.braceExpand=Ua;var Zh=(e,t={})=>new ot(e,t).makeRe();q.makeRe=Zh;var Xh=(e,t,r={})=>{let n=new ot(t,r);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};q.match=Xh;var La=/[?*]|[+@!]\(.*?\)|\[|\]/,Qh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ot=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){Nr(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||Ha,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let s=this.globParts.map((o,i,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=o[0]===""&&o[1]===""&&(o[2]==="?"||!La.test(o[2]))&&!La.test(o[3]),u=/^[a-z]:/i.test(o[0]);if(c)return[...o.slice(0,4),...o.slice(4).map(l=>this.parse(l))];if(u)return[o[0],...o.slice(1).map(l=>this.parse(l))]}return o.map(c=>this.parse(c))});if(this.debug(this.pattern,s),this.set=s.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let i=this.set[o];i[0]===""&&i[1]===""&&this.globParts[o][2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3])&&(i[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let i=s;for(;n[i+1]==="**";)i++;i>s&&n.splice(s+1,i-s);let a=n[s+1],c=n[s+2],u=n[s+3];if(a!==".."||!c||c==="."||c===".."||!u||u==="."||u==="..")continue;r=!0,n.splice(s,1);let l=n.slice(0);l[s]="**",t.push(l),s--}if(!this.preserveMultipleSlashes){for(let i=1;i<n.length-1;i++){let a=n[i];i===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(i,1),i--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let i=n[o-1];if(i&&i!=="."&&i!==".."&&i!=="**"){r=!0;let c=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...c),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let s=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(s){t[r]=[],t[n]=s;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let s=0,o=0,i=[],a="";for(;s<t.length&&o<r.length;)if(t[s]===r[o])i.push(a==="b"?r[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&r[o]===t[s+1])i.push(t[s]),s++;else if(n&&r[o]==="**"&&t[s]===r[o+1])i.push(r[o]),o++;else if(t[s]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",i.push(t[s]),s++,o++}else if(r[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(a==="a")return!1;a="b",i.push(r[o]),s++,o++}else return!1;return t.length===r.length&&i}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let s=this.options;if(this.isWindows){let h=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),D=!h&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),g=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),y=!g&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),v=D?3:h?0:void 0,C=y?3:g?0:void 0;if(typeof v=="number"&&typeof C=="number"){let[A,lt]=[t[v],r[C]];A.toLowerCase()===lt.toLowerCase()&&(r[C]=A,C>v?r=r.slice(C):v>C&&(t=t.slice(v)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var i=0,a=0,c=t.length,u=r.length;i<c&&a<u;i++,a++){this.debug("matchOne loop");var l=r[a],p=t[i];if(this.debug(r,l,p),l===!1)return!1;if(l===H){this.debug("GLOBSTAR",[r,l,p]);var d=i,f=a+1;if(f===u){for(this.debug("** at the end");i<c;i++)if(t[i]==="."||t[i]===".."||!s.dot&&t[i].charAt(0)===".")return!1;return!0}for(;d<c;){var m=t[d];if(this.debug(`
13
+ ${oo.default.bold(e.exampleUsage)}
14
+ `),e.additionalInfo&&t.addHelpText("after",()=>(typeof e.additionalInfo=="function"?e.additionalInfo():e.additionalInfo)??""),t.action(async(...r)=>{try{let n=r.at(-1),s=n.args,o=n.opts(),i=dh(e.arguments??[],s);if(e.shouldSkipWorkflow?.(i,o)){await e.onSkipWorkflow?.(i,o);return}let a=await e.buildContext(i,o);e.prompts?.length&&await new io.Listr(ba(e.prompts,a),{rendererOptions:{lazy:!0,showErrorMessage:!1}}).run(a),await new io.Listr(ba(e.actions,a),{rendererOptions:{lazy:!1,showErrorMessage:!1,clearOutput:!0}}).run(a),await e.onComplete?.(a)}catch(n){let s=n;w.error(s.message)}}),t}function dh(e,t){let r={};return e.forEach(([n],s)=>{let o=n.replace(/[<>[\]]/g,"");r[o]=t[s]}),r}function ba(e,t){return e.map(r=>typeof r=="function"?r(t):r)}function Tn(e,t,r){let n=t.split("."),s=e;for(;n.length>1;){let o=n.shift();o in s||(s[o]={}),s=s[o]}s[n[0]]=r}var va=require("execa");function Nr(e){try{return(0,va.execaSync)(e,["--version"]),!0}catch{return!1}}var Xe=require("node:path"),Qc=require("fs-extra");var Aa=b(require("node:process"),1);var Ea=b(require("node:process"),1);var Sa=require("node:url"),Fa=b(require("node:fs"),1),we=b(require("node:path"),1),ka=e=>e instanceof URL?(0,Sa.fileURLToPath)(e):e;function Ta(e,{cwd:t=Ea.default.cwd(),type:r="file",stopAt:n}={}){let s=we.default.resolve(ka(t)??""),{root:o}=we.default.parse(s);n=we.default.resolve(s,ka(n)??o);let i=we.default.isAbsolute(e);for(;s;){let a=i?e:we.default.join(s,e);try{let c=Fa.default.statSync(a,{throwIfNoEntry:!1});if(r==="file"&&c?.isFile()||r==="directory"&&c?.isDirectory())return a}catch{}if(s===n||s===o)break;s=we.default.dirname(s)}}function Pa({cwd:e=Aa.default.cwd()}={}){return Ta("package.json",{cwd:e})}var ao=(e,t,r)=>{let n=e instanceof RegExp?Ra(e,r):e,s=t instanceof RegExp?Ra(t,r):t,o=n!==null&&s!=null&&hh(n,s,r);return o&&{start:o[0],end:o[1],pre:r.slice(0,o[0]),body:r.slice(o[0]+n.length,o[1]),post:r.slice(o[1]+s.length)}},Ra=(e,t)=>{let r=t.match(e);return r?r[0]:null},hh=(e,t,r)=>{let n,s,o,i,a,c=r.indexOf(e),l=r.indexOf(t,c+1),u=c;if(c>=0&&l>0){if(e===t)return[c,l];for(n=[],o=r.length;u>=0&&!a;){if(u===c)n.push(u),c=r.indexOf(e,u+1);else if(n.length===1){let p=n.pop();p!==void 0&&(a=[p,l])}else s=n.pop(),s!==void 0&&s<o&&(o=s,i=l),l=r.indexOf(t,u+1);u=c<l&&c>=0?c:l}n.length&&i!==void 0&&(a=[o,i])}return a};var Ia="\0SLASH"+Math.random()+"\0",Na="\0OPEN"+Math.random()+"\0",lo="\0CLOSE"+Math.random()+"\0",Oa="\0COMMA"+Math.random()+"\0",Ma="\0PERIOD"+Math.random()+"\0",mh=new RegExp(Ia,"g"),gh=new RegExp(Na,"g"),Dh=new RegExp(lo,"g"),yh=new RegExp(Oa,"g"),wh=new RegExp(Ma,"g"),Ch=/\\\\/g,bh=/\\{/g,xh=/\\}/g,vh=/\\,/g,kh=/\\./g;function co(e){return isNaN(e)?e.charCodeAt(0):parseInt(e,10)}function Eh(e){return e.replace(Ch,Ia).replace(bh,Na).replace(xh,lo).replace(vh,Oa).replace(kh,Ma)}function Sh(e){return e.replace(mh,"\\").replace(gh,"{").replace(Dh,"}").replace(yh,",").replace(wh,".")}function $a(e){if(!e)return[""];let t=[],r=ao("{","}",e);if(!r)return e.split(",");let{pre:n,body:s,post:o}=r,i=n.split(",");i[i.length-1]+="{"+s+"}";let a=$a(o);return o.length&&(i[i.length-1]+=a.shift(),i.push.apply(i,a)),t.push.apply(t,i),t}function Ba(e){return e?(e.slice(0,2)==="{}"&&(e="\\{\\}"+e.slice(2)),Or(Eh(e),!0).map(Sh)):[]}function Fh(e){return"{"+e+"}"}function Th(e){return/^-?0\d/.test(e)}function Ah(e,t){return e<=t}function Ph(e,t){return e>=t}function Or(e,t){let r=[],n=ao("{","}",e);if(!n)return[e];let s=n.pre,o=n.post.length?Or(n.post,!1):[""];if(/\$$/.test(n.pre))for(let i=0;i<o.length;i++){let a=s+"{"+n.body+"}"+o[i];r.push(a)}else{let i=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(n.body),a=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(n.body),c=i||a,l=n.body.indexOf(",")>=0;if(!c&&!l)return n.post.match(/,(?!,).*\}/)?(e=n.pre+"{"+n.body+lo+n.post,Or(e)):[e];let u;if(c)u=n.body.split(/\.\./);else if(u=$a(n.body),u.length===1&&u[0]!==void 0&&(u=Or(u[0],!1).map(Fh),u.length===1))return o.map(d=>n.pre+u[0]+d);let p;if(c&&u[0]!==void 0&&u[1]!==void 0){let d=co(u[0]),f=co(u[1]),m=Math.max(u[0].length,u[1].length),h=u.length===3&&u[2]!==void 0?Math.abs(co(u[2])):1,D=Ah;f<d&&(h*=-1,D=Ph);let y=u.some(Th);p=[];for(let x=d;D(x,f);x+=h){let C;if(a)C=String.fromCharCode(x),C==="\\"&&(C="");else if(C=String(x),y){let A=m-C.length;if(A>0){let dt=new Array(A+1).join("0");x<0?C="-"+dt+C.slice(1):C=dt+C}}p.push(C)}}else{p=[];for(let d=0;d<u.length;d++)p.push.apply(p,Or(u[d],!1))}for(let d=0;d<p.length;d++)for(let f=0;f<o.length;f++){let m=s+p[d]+o[f];(!t||c||m)&&r.push(m)}}return r}var Mr=e=>{if(typeof e!="string")throw new TypeError("invalid pattern");if(e.length>65536)throw new TypeError("pattern is too long")};var Rh={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},$r=e=>e.replace(/[[\]\\-]/g,"\\$&"),Ih=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),ja=e=>e.join(""),_a=(e,t)=>{let r=t;if(e.charAt(r)!=="[")throw new Error("not in a brace expression");let n=[],s=[],o=r+1,i=!1,a=!1,c=!1,l=!1,u=r,p="";t:for(;o<e.length;){let h=e.charAt(o);if((h==="!"||h==="^")&&o===r+1){l=!0,o++;continue}if(h==="]"&&i&&!c){u=o+1;break}if(i=!0,h==="\\"&&!c){c=!0,o++;continue}if(h==="["&&!c){for(let[D,[g,y,x]]of Object.entries(Rh))if(e.startsWith(D,o)){if(p)return["$.",!1,e.length-r,!0];o+=D.length,x?s.push(g):n.push(g),a=a||y;continue t}}if(c=!1,p){h>p?n.push($r(p)+"-"+$r(h)):h===p&&n.push($r(h)),p="",o++;continue}if(e.startsWith("-]",o+1)){n.push($r(h+"-")),o+=2;continue}if(e.startsWith("-",o+1)){p=h,o+=2;continue}n.push($r(h)),o++}if(u<o)return["",!1,0,!1];if(!n.length&&!s.length)return["$.",!1,e.length-r,!0];if(s.length===0&&n.length===1&&/^\\?.$/.test(n[0])&&!l){let h=n[0].length===2?n[0].slice(-1):n[0];return[Ih(h),!1,u-r,!1]}let d="["+(l?"^":"")+ja(n)+"]",f="["+(l?"":"^")+ja(s)+"]";return[n.length&&s.length?"("+d+"|"+f+")":n.length?d:f,a,u-r,!0]};var wt=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!0}={})=>r?t?e.replace(/\[([^\/\\])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1"):t?e.replace(/\[([^\/\\{}])\]/g,"$1"):e.replace(/((?!\\).|^)\[([^\/\\{}])\]/g,"$1$2").replace(/\\([^\/{}])/g,"$1");var Nh=new Set(["!","?","+","*","@"]),La=e=>Nh.has(e),Oh="(?!(?:^|/)\\.\\.?(?:$|/))",An="(?!\\.)",Mh=new Set(["[","."]),$h=new Set(["..","."]),Bh=new Set("().*{}+?[]^$\\!"),jh=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),uo="[^/]",Wa=uo+"*?",Ga=uo+"+?",$e=class e{type;#t;#r;#o=!1;#s=[];#i;#C;#D;#u=!1;#a;#f;#p=!1;constructor(t,r,n={}){this.type=t,t&&(this.#r=!0),this.#i=r,this.#t=this.#i?this.#i.#t:this,this.#a=this.#t===this?n:this.#t.#a,this.#D=this.#t===this?[]:this.#t.#D,t==="!"&&!this.#t.#u&&this.#D.push(this),this.#C=this.#i?this.#i.#s.length:0}get hasMagic(){if(this.#r!==void 0)return this.#r;for(let t of this.#s)if(typeof t!="string"&&(t.type||t.hasMagic))return this.#r=!0;return this.#r}toString(){return this.#f!==void 0?this.#f:this.type?this.#f=this.type+"("+this.#s.map(t=>String(t)).join("|")+")":this.#f=this.#s.map(t=>String(t)).join("")}#c(){if(this!==this.#t)throw new Error("should only call on root");if(this.#u)return this;this.toString(),this.#u=!0;let t;for(;t=this.#D.pop();){if(t.type!=="!")continue;let r=t,n=r.#i;for(;n;){for(let s=r.#C+1;!n.type&&s<n.#s.length;s++)for(let o of t.#s){if(typeof o=="string")throw new Error("string part in extglob AST??");o.copyIn(n.#s[s])}r=n,n=r.#i}}return this}push(...t){for(let r of t)if(r!==""){if(typeof r!="string"&&!(r instanceof e&&r.#i===this))throw new Error("invalid part: "+r);this.#s.push(r)}}toJSON(){let t=this.type===null?this.#s.slice().map(r=>typeof r=="string"?r:r.toJSON()):[this.type,...this.#s.map(r=>r.toJSON())];return this.isStart()&&!this.type&&t.unshift([]),this.isEnd()&&(this===this.#t||this.#t.#u&&this.#i?.type==="!")&&t.push({}),t}isStart(){if(this.#t===this)return!0;if(!this.#i?.isStart())return!1;if(this.#C===0)return!0;let t=this.#i;for(let r=0;r<this.#C;r++){let n=t.#s[r];if(!(n instanceof e&&n.type==="!"))return!1}return!0}isEnd(){if(this.#t===this||this.#i?.type==="!")return!0;if(!this.#i?.isEnd())return!1;if(!this.type)return this.#i?.isEnd();let t=this.#i?this.#i.#s.length:0;return this.#C===t-1}copyIn(t){typeof t=="string"?this.push(t):this.push(t.clone(this))}clone(t){let r=new e(this.type,t);for(let n of this.#s)r.copyIn(n);return r}static#n(t,r,n,s){let o=!1,i=!1,a=-1,c=!1;if(r.type===null){let f=n,m="";for(;f<t.length;){let h=t.charAt(f++);if(o||h==="\\"){o=!o,m+=h;continue}if(i){f===a+1?(h==="^"||h==="!")&&(c=!0):h==="]"&&!(f===a+2&&c)&&(i=!1),m+=h;continue}else if(h==="["){i=!0,a=f,c=!1,m+=h;continue}if(!s.noext&&La(h)&&t.charAt(f)==="("){r.push(m),m="";let D=new e(h,r);f=e.#n(t,D,f,s),r.push(D);continue}m+=h}return r.push(m),f}let l=n+1,u=new e(null,r),p=[],d="";for(;l<t.length;){let f=t.charAt(l++);if(o||f==="\\"){o=!o,d+=f;continue}if(i){l===a+1?(f==="^"||f==="!")&&(c=!0):f==="]"&&!(l===a+2&&c)&&(i=!1),d+=f;continue}else if(f==="["){i=!0,a=l,c=!1,d+=f;continue}if(La(f)&&t.charAt(l)==="("){u.push(d),d="";let m=new e(f,u);u.push(m),l=e.#n(t,m,l,s);continue}if(f==="|"){u.push(d),d="",p.push(u),u=new e(null,r);continue}if(f===")")return d===""&&r.#s.length===0&&(r.#p=!0),u.push(d),d="",r.push(...p,u),l;d+=f}return r.type=null,r.#r=void 0,r.#s=[t.substring(n-1)],l}static fromGlob(t,r={}){let n=new e(null,void 0,r);return e.#n(t,n,0,r),n}toMMPattern(){if(this!==this.#t)return this.#t.toMMPattern();let t=this.toString(),[r,n,s,o]=this.toRegExpSource();if(!(s||this.#r||this.#a.nocase&&!this.#a.nocaseMagicOnly&&t.toUpperCase()!==t.toLowerCase()))return n;let a=(this.#a.nocase?"i":"")+(o?"u":"");return Object.assign(new RegExp(`^${r}$`,a),{_src:r,_glob:t})}get options(){return this.#a}toRegExpSource(t){let r=t??!!this.#a.dot;if(this.#t===this&&this.#c(),!this.type){let c=this.isStart()&&this.isEnd()&&!this.#s.some(f=>typeof f!="string"),l=this.#s.map(f=>{let[m,h,D,g]=typeof f=="string"?e.#b(f,this.#r,c):f.toRegExpSource(t);return this.#r=this.#r||D,this.#o=this.#o||g,m}).join(""),u="";if(this.isStart()&&typeof this.#s[0]=="string"&&!(this.#s.length===1&&$h.has(this.#s[0]))){let m=Mh,h=r&&m.has(l.charAt(0))||l.startsWith("\\.")&&m.has(l.charAt(2))||l.startsWith("\\.\\.")&&m.has(l.charAt(4)),D=!r&&!t&&m.has(l.charAt(0));u=h?Oh:D?An:""}let p="";return this.isEnd()&&this.#t.#u&&this.#i?.type==="!"&&(p="(?:$|\\/)"),[u+l+p,wt(l),this.#r=!!this.#r,this.#o]}let n=this.type==="*"||this.type==="+",s=this.type==="!"?"(?:(?!(?:":"(?:",o=this.#d(r);if(this.isStart()&&this.isEnd()&&!o&&this.type!=="!"){let c=this.toString();return this.#s=[c],this.type=null,this.#r=void 0,[c,wt(this.toString()),!1,!1]}let i=!n||t||r||!An?"":this.#d(!0);i===o&&(i=""),i&&(o=`(?:${o})(?:${i})*?`);let a="";if(this.type==="!"&&this.#p)a=(this.isStart()&&!r?An:"")+Ga;else{let c=this.type==="!"?"))"+(this.isStart()&&!r&&!t?An:"")+Wa+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&i?")":this.type==="*"&&i?")?":`)${this.type}`;a=s+o+c}return[a,wt(o),this.#r=!!this.#r,this.#o]}#d(t){return this.#s.map(r=>{if(typeof r=="string")throw new Error("string type in extglob ast??");let[n,s,o,i]=r.toRegExpSource(t);return this.#o=this.#o||i,n}).filter(r=>!(this.isStart()&&this.isEnd())||!!r).join("|")}static#b(t,r,n=!1){let s=!1,o="",i=!1;for(let a=0;a<t.length;a++){let c=t.charAt(a);if(s){s=!1,o+=(Bh.has(c)?"\\":"")+c;continue}if(c==="\\"){a===t.length-1?o+="\\\\":s=!0;continue}if(c==="["){let[l,u,p,d]=_a(t,a);if(p){o+=l,i=i||u,a+=p-1,r=r||d;continue}}if(c==="*"){o+=n&&t==="*"?Ga:Wa,r=!0;continue}if(c==="?"){o+=uo,r=!0;continue}o+=jh(c)}return[o,wt(t),!!r,i]}};var Be=(e,{windowsPathsNoEscape:t=!1,magicalBraces:r=!1}={})=>r?t?e.replace(/[?*()[\]{}]/g,"[$&]"):e.replace(/[?*()[\]\\{}]/g,"\\$&"):t?e.replace(/[?*()[\]]/g,"[$&]"):e.replace(/[?*()[\]\\]/g,"\\$&");var Z=(e,t,r={})=>(Mr(t),!r.nocomment&&t.charAt(0)==="#"?!1:new at(t,r).match(e)),_h=/^\*+([^+@!?\*\[\(]*)$/,Lh=e=>t=>!t.startsWith(".")&&t.endsWith(e),Wh=e=>t=>t.endsWith(e),Gh=e=>(e=e.toLowerCase(),t=>!t.startsWith(".")&&t.toLowerCase().endsWith(e)),Hh=e=>(e=e.toLowerCase(),t=>t.toLowerCase().endsWith(e)),Uh=/^\*+\.\*+$/,zh=e=>!e.startsWith(".")&&e.includes("."),Kh=e=>e!=="."&&e!==".."&&e.includes("."),Jh=/^\.\*+$/,qh=e=>e!=="."&&e!==".."&&e.startsWith("."),Vh=/^\*+$/,Yh=e=>e.length!==0&&!e.startsWith("."),Zh=e=>e.length!==0&&e!=="."&&e!=="..",Xh=/^\?+([^+@!?\*\[\(]*)?$/,Qh=([e,t=""])=>{let r=za([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},tm=([e,t=""])=>{let r=Ka([e]);return t?(t=t.toLowerCase(),n=>r(n)&&n.toLowerCase().endsWith(t)):r},em=([e,t=""])=>{let r=Ka([e]);return t?n=>r(n)&&n.endsWith(t):r},rm=([e,t=""])=>{let r=za([e]);return t?n=>r(n)&&n.endsWith(t):r},za=([e])=>{let t=e.length;return r=>r.length===t&&!r.startsWith(".")},Ka=([e])=>{let t=e.length;return r=>r.length===t&&r!=="."&&r!==".."},Ja=typeof process=="object"&&process?typeof process.env=="object"&&process.env&&process.env.__MINIMATCH_TESTING_PLATFORM__||process.platform:"posix",Ha={win32:{sep:"\\"},posix:{sep:"/"}},nm=Ja==="win32"?Ha.win32.sep:Ha.posix.sep;Z.sep=nm;var U=Symbol("globstar **");Z.GLOBSTAR=U;var sm="[^/]",om=sm+"*?",im="(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?",am="(?:(?!(?:\\/|^)\\.).)*?",cm=(e,t={})=>r=>Z(r,e,t);Z.filter=cm;var mt=(e,t={})=>Object.assign({},e,t),lm=e=>{if(!e||typeof e!="object"||!Object.keys(e).length)return Z;let t=Z;return Object.assign((n,s,o={})=>t(n,s,mt(e,o)),{Minimatch:class extends t.Minimatch{constructor(s,o={}){super(s,mt(e,o))}static defaults(s){return t.defaults(mt(e,s)).Minimatch}},AST:class extends t.AST{constructor(s,o,i={}){super(s,o,mt(e,i))}static fromGlob(s,o={}){return t.AST.fromGlob(s,mt(e,o))}},unescape:(n,s={})=>t.unescape(n,mt(e,s)),escape:(n,s={})=>t.escape(n,mt(e,s)),filter:(n,s={})=>t.filter(n,mt(e,s)),defaults:n=>t.defaults(mt(e,n)),makeRe:(n,s={})=>t.makeRe(n,mt(e,s)),braceExpand:(n,s={})=>t.braceExpand(n,mt(e,s)),match:(n,s,o={})=>t.match(n,s,mt(e,o)),sep:t.sep,GLOBSTAR:U})};Z.defaults=lm;var qa=(e,t={})=>(Mr(e),t.nobrace||!/\{(?:(?!\{).)*\}/.test(e)?[e]:Ba(e));Z.braceExpand=qa;var um=(e,t={})=>new at(e,t).makeRe();Z.makeRe=um;var pm=(e,t,r={})=>{let n=new at(t,r);return e=e.filter(s=>n.match(s)),n.options.nonull&&!e.length&&e.push(t),e};Z.match=pm;var Ua=/[?*]|[+@!]\(.*?\)|\[|\]/,fm=e=>e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),at=class{options;set;pattern;windowsPathsNoEscape;nonegate;negate;comment;empty;preserveMultipleSlashes;partial;globSet;globParts;nocase;isWindows;platform;windowsNoMagicRoot;regexp;constructor(t,r={}){Mr(t),r=r||{},this.options=r,this.pattern=t,this.platform=r.platform||Ja,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!r.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!r.nonegate,this.comment=!1,this.empty=!1,this.partial=!!r.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=r.windowsNoMagicRoot!==void 0?r.windowsNoMagicRoot:!!(this.isWindows&&this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(let t of this.set)for(let r of t)if(typeof r!="string")return!0;return!1}debug(...t){}make(){let t=this.pattern,r=this.options;if(!r.nocomment&&t.charAt(0)==="#"){this.comment=!0;return}if(!t){this.empty=!0;return}this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],r.debug&&(this.debug=(...o)=>console.error(...o)),this.debug(this.pattern,this.globSet);let n=this.globSet.map(o=>this.slashSplit(o));this.globParts=this.preprocess(n),this.debug(this.pattern,this.globParts);let s=this.globParts.map((o,i,a)=>{if(this.isWindows&&this.windowsNoMagicRoot){let c=o[0]===""&&o[1]===""&&(o[2]==="?"||!Ua.test(o[2]))&&!Ua.test(o[3]),l=/^[a-z]:/i.test(o[0]);if(c)return[...o.slice(0,4),...o.slice(4).map(u=>this.parse(u))];if(l)return[o[0],...o.slice(1).map(u=>this.parse(u))]}return o.map(c=>this.parse(c))});if(this.debug(this.pattern,s),this.set=s.filter(o=>o.indexOf(!1)===-1),this.isWindows)for(let o=0;o<this.set.length;o++){let i=this.set[o];i[0]===""&&i[1]===""&&this.globParts[o][2]==="?"&&typeof i[3]=="string"&&/^[a-z]:$/i.test(i[3])&&(i[2]="?")}this.debug(this.pattern,this.set)}preprocess(t){if(this.options.noglobstar)for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]==="**"&&(t[n][s]="*");let{optimizationLevel:r=1}=this.options;return r>=2?(t=this.firstPhasePreProcess(t),t=this.secondPhasePreProcess(t)):r>=1?t=this.levelOneOptimize(t):t=this.adjascentGlobstarOptimize(t),t}adjascentGlobstarOptimize(t){return t.map(r=>{let n=-1;for(;(n=r.indexOf("**",n+1))!==-1;){let s=n;for(;r[s+1]==="**";)s++;s!==n&&r.splice(n,s-n)}return r})}levelOneOptimize(t){return t.map(r=>(r=r.reduce((n,s)=>{let o=n[n.length-1];return s==="**"&&o==="**"?n:s===".."&&o&&o!==".."&&o!=="."&&o!=="**"?(n.pop(),n):(n.push(s),n)},[]),r.length===0?[""]:r))}levelTwoFileOptimize(t){Array.isArray(t)||(t=this.slashSplit(t));let r=!1;do{if(r=!1,!this.preserveMultipleSlashes){for(let s=1;s<t.length-1;s++){let o=t[s];s===1&&o===""&&t[0]===""||(o==="."||o==="")&&(r=!0,t.splice(s,1),s--)}t[0]==="."&&t.length===2&&(t[1]==="."||t[1]==="")&&(r=!0,t.pop())}let n=0;for(;(n=t.indexOf("..",n+1))!==-1;){let s=t[n-1];s&&s!=="."&&s!==".."&&s!=="**"&&(r=!0,t.splice(n-1,2),n-=2)}}while(r);return t.length===0?[""]:t}firstPhasePreProcess(t){let r=!1;do{r=!1;for(let n of t){let s=-1;for(;(s=n.indexOf("**",s+1))!==-1;){let i=s;for(;n[i+1]==="**";)i++;i>s&&n.splice(s+1,i-s);let a=n[s+1],c=n[s+2],l=n[s+3];if(a!==".."||!c||c==="."||c===".."||!l||l==="."||l==="..")continue;r=!0,n.splice(s,1);let u=n.slice(0);u[s]="**",t.push(u),s--}if(!this.preserveMultipleSlashes){for(let i=1;i<n.length-1;i++){let a=n[i];i===1&&a===""&&n[0]===""||(a==="."||a==="")&&(r=!0,n.splice(i,1),i--)}n[0]==="."&&n.length===2&&(n[1]==="."||n[1]==="")&&(r=!0,n.pop())}let o=0;for(;(o=n.indexOf("..",o+1))!==-1;){let i=n[o-1];if(i&&i!=="."&&i!==".."&&i!=="**"){r=!0;let c=o===1&&n[o+1]==="**"?["."]:[];n.splice(o-1,2,...c),n.length===0&&n.push(""),o-=2}}}}while(r);return t}secondPhasePreProcess(t){for(let r=0;r<t.length-1;r++)for(let n=r+1;n<t.length;n++){let s=this.partsMatch(t[r],t[n],!this.preserveMultipleSlashes);if(s){t[r]=[],t[n]=s;break}}return t.filter(r=>r.length)}partsMatch(t,r,n=!1){let s=0,o=0,i=[],a="";for(;s<t.length&&o<r.length;)if(t[s]===r[o])i.push(a==="b"?r[o]:t[s]),s++,o++;else if(n&&t[s]==="**"&&r[o]===t[s+1])i.push(t[s]),s++;else if(n&&r[o]==="**"&&t[s]===r[o+1])i.push(r[o]),o++;else if(t[s]==="*"&&r[o]&&(this.options.dot||!r[o].startsWith("."))&&r[o]!=="**"){if(a==="b")return!1;a="a",i.push(t[s]),s++,o++}else if(r[o]==="*"&&t[s]&&(this.options.dot||!t[s].startsWith("."))&&t[s]!=="**"){if(a==="a")return!1;a="b",i.push(r[o]),s++,o++}else return!1;return t.length===r.length&&i}parseNegate(){if(this.nonegate)return;let t=this.pattern,r=!1,n=0;for(let s=0;s<t.length&&t.charAt(s)==="!";s++)r=!r,n++;n&&(this.pattern=t.slice(n)),this.negate=r}matchOne(t,r,n=!1){let s=this.options;if(this.isWindows){let h=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),D=!h&&t[0]===""&&t[1]===""&&t[2]==="?"&&/^[a-z]:$/i.test(t[3]),g=typeof r[0]=="string"&&/^[a-z]:$/i.test(r[0]),y=!g&&r[0]===""&&r[1]===""&&r[2]==="?"&&typeof r[3]=="string"&&/^[a-z]:$/i.test(r[3]),x=D?3:h?0:void 0,C=y?3:g?0:void 0;if(typeof x=="number"&&typeof C=="number"){let[A,dt]=[t[x],r[C]];A.toLowerCase()===dt.toLowerCase()&&(r[C]=A,C>x?r=r.slice(C):x>C&&(t=t.slice(x)))}}let{optimizationLevel:o=1}=this.options;o>=2&&(t=this.levelTwoFileOptimize(t)),this.debug("matchOne",this,{file:t,pattern:r}),this.debug("matchOne",t.length,r.length);for(var i=0,a=0,c=t.length,l=r.length;i<c&&a<l;i++,a++){this.debug("matchOne loop");var u=r[a],p=t[i];if(this.debug(r,u,p),u===!1)return!1;if(u===U){this.debug("GLOBSTAR",[r,u,p]);var d=i,f=a+1;if(f===l){for(this.debug("** at the end");i<c;i++)if(t[i]==="."||t[i]===".."||!s.dot&&t[i].charAt(0)===".")return!1;return!0}for(;d<c;){var m=t[d];if(this.debug(`
15
15
  globstar while`,t,d,r,f,m),this.matchOne(t.slice(d),r.slice(f),n))return this.debug("globstar found match!",d,c,m),!0;if(m==="."||m===".."||!s.dot&&m.charAt(0)==="."){this.debug("dot detected!",t,d,r,f);break}this.debug("globstar swallow a segment, and continue"),d++}return!!(n&&(this.debug(`
16
- >>> no match, partial?`,t,d,r,f),d===c))}let h;if(typeof l=="string"?(h=p===l,this.debug("string match",l,p,h)):(h=l.test(p),this.debug("pattern match",l,p,h)),!h)return!1}if(i===c&&a===u)return!0;if(i===c)return n;if(a===u)return i===c-1&&t[i]==="";throw new Error("wtf?")}braceExpand(){return Ua(this.pattern,this.options)}parse(t){Nr(t);let r=this.options;if(t==="**")return H;if(t==="")return"";let n,s=null;(n=t.match($h))?s=r.dot?jh:Bh:(n=t.match(Sh))?s=(r.nocase?r.dot?Ph:Ah:r.dot?Th:Fh)(n[1]):(n=t.match(_h))?s=(r.nocase?r.dot?Wh:Lh:r.dot?Gh:Hh)(n):(n=t.match(Rh))?s=r.dot?Nh:Ih:(n=t.match(Oh))&&(s=Mh);let o=Oe.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?Kh:r.dot?Jh:Vh,s=new Set(r.nocase?["i"]:[]),o=t.map(c=>{let u=c.map(p=>{if(p instanceof RegExp)for(let d of p.flags.split(""))s.add(d);return typeof p=="string"?Qh(p):p===H?H:p._src});u.forEach((p,d)=>{let f=u[d+1],m=u[d-1];p!==H||m===H||(m===void 0?f!==void 0&&f!==H?u[d+1]="(?:\\/|"+n+"\\/)?"+f:u[d]=n:f===void 0?u[d-1]=m+"(?:\\/|\\/"+n+")?":f!==H&&(u[d-1]=m+"(?:\\/|\\/"+n+"\\/)"+f,u[d+1]=H))});let l=u.filter(p=>p!==H);if(this.partial&&l.length>=1){let p=[];for(let d=1;d<=l.length;d++)p.push(l.slice(0,d).join("/"));return"(?:"+p.join("|")+")"}return l.join("/")}).join("|"),[i,a]=t.length>1?["(?:",")"]:["",""];o="^"+i+o+a+"$",this.partial&&(o="^(?:\\/|"+i+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let i=s[s.length-1];if(!i)for(let a=s.length-2;!i&&a>=0;a--)i=s[a];for(let a=0;a<o.length;a++){let c=o[a],u=s;if(n.matchBase&&c.length===1&&(u=[i]),this.matchOne(u,c,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return q.defaults(t).Minimatch}};q.AST=Oe;q.Minimatch=ot;q.escape=Me;q.unescape=Dt;var hc=require("node:url");var tm=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ka=new Set,co=typeof process=="object"&&process?process:{},Ja=(e,t,r,n)=>{typeof co.emitWarning=="function"?co.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},Fn=globalThis.AbortController,za=globalThis.AbortSignal;if(typeof Fn>"u"){za=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,s){this._onabort.push(s)}},Fn=class{constructor(){t()}signal=new za;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let s of this.signal._onabort)s(n);this.signal.onabort?.(n)}}};let e=co.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,Ja("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var em=e=>!Ka.has(e),jb=Symbol("type"),oe=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Va=e=>oe(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?$e:null:null,$e=class extends Array{constructor(t){super(t),this.fill(0)}},uo=class e{heap;length;static#t=!1;static create(t){let r=Va(t);if(!r)return[];e.#t=!0;let n=new e(t,r);return e.#t=!1,n}constructor(t,r){if(!e.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},ye=class e{#t;#r;#o;#s;#i;#C;#D;#l;get perf(){return this.#l}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#f;#p;#c;#n;#d;#b;#w;#h;#T;#m;#k;#E;#g;#y;#v;#S;#e;#O;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#g,autopurgeTimers:t.#y,sizes:t.#k,keyMap:t.#p,keyList:t.#c,valList:t.#n,next:t.#d,prev:t.#b,get head(){return t.#w},get tail(){return t.#h},free:t.#T,isBackgroundFetch:r=>t.#u(r),backgroundFetch:(r,n,s,o)=>t.#G(r,n,s,o),moveToTail:r=>t.#$(r),indexes:r=>t.#P(r),rindexes:r=>t.#R(r),isStale:r=>t.#x(r)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#f}get size(){return this.#a}get fetchMethod(){return this.#C}get memoMethod(){return this.#D}get dispose(){return this.#o}get onInsert(){return this.#s}get disposeAfter(){return this.#i}constructor(t){let{max:r=0,ttl:n,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:a,allowStale:c,dispose:u,onInsert:l,disposeAfter:p,noDisposeOnSet:d,noUpdateTTL:f,maxSize:m=0,maxEntrySize:h=0,sizeCalculation:D,fetchMethod:g,memoMethod:y,noDeleteOnFetchRejection:v,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:lt,ignoreFetchAbort:re,perf:Fe}=t;if(Fe!==void 0&&typeof Fe?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#l=Fe??tm,r!==0&&!oe(r))throw new TypeError("max option must be a nonnegative integer");let Te=r?Va(r):Array;if(!Te)throw new Error("invalid max value: "+r);if(this.#t=r,this.#r=m,this.maxEntrySize=h||this.#r,this.sizeCalculation=D,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#D=y,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#C=g,this.#S=!!g,this.#p=new Map,this.#c=new Array(r).fill(void 0),this.#n=new Array(r).fill(void 0),this.#d=new Te(r),this.#b=new Te(r),this.#w=0,this.#h=0,this.#T=uo.create(r),this.#a=0,this.#f=0,typeof u=="function"&&(this.#o=u),typeof l=="function"&&(this.#s=l),typeof p=="function"?(this.#i=p,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#v=!!this.#o,this.#O=!!this.#s,this.#e=!!this.#i,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!v,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!lt,this.ignoreFetchAbort=!!re,this.maxEntrySize!==0){if(this.#r!==0&&!oe(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!oe(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#U()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!a,this.ttlResolution=oe(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!oe(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#I()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Ae="LRU_CACHE_UNBOUNDED";em(Ae)&&(Ka.add(Ae),Ja("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ae,e))}}getRemainingTTL(t){return this.#p.has(t)?1/0:0}#I(){let t=new $e(this.#t),r=new $e(this.#t);this.#g=t,this.#E=r;let n=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=n,this.#j=(i,a,c=this.#l.now())=>{if(r[i]=a!==0?c:0,t[i]=a,n?.[i]&&(clearTimeout(n[i]),n[i]=void 0),a!==0&&n){let u=setTimeout(()=>{this.#x(i)&&this.#A(this.#c[i],"expire")},a+1);u.unref&&u.unref(),n[i]=u}},this.#F=i=>{r[i]=t[i]!==0?this.#l.now():0},this.#N=(i,a)=>{if(t[a]){let c=t[a],u=r[a];if(!c||!u)return;i.ttl=c,i.start=u,i.now=s||o();let l=i.now-u;i.remainingTTL=c-l}};let s=0,o=()=>{let i=this.#l.now();if(this.ttlResolution>0){s=i;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return i};this.getRemainingTTL=i=>{let a=this.#p.get(i);if(a===void 0)return 0;let c=t[a],u=r[a];if(!c||!u)return 1/0;let l=(s||o())-u;return c-l},this.#x=i=>{let a=r[i],c=t[i];return!!c&&!!a&&(s||o())-a>c}}#F=()=>{};#N=()=>{};#j=()=>{};#x=()=>!1;#U(){let t=new $e(this.#t);this.#f=0,this.#k=t,this.#B=r=>{this.#f-=t[r],t[r]=0},this.#_=(r,n,s,o)=>{if(this.#u(n))return 0;if(!oe(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(n,r),!oe(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#M=(r,n,s)=>{if(t[r]=n,this.#r){let o=this.#r-t[r];for(;this.#f>o;)this.#W(!0)}this.#f+=t[r],s&&(s.entrySize=n,s.totalCalculatedSize=this.#f)}}#B=t=>{};#M=(t,r,n)=>{};#_=(t,r,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#h;!(!this.#L(r)||((t||!this.#x(r))&&(yield r),r===this.#w));)r=this.#b[r]}*#R({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#w;!(!this.#L(r)||((t||!this.#x(r))&&(yield r),r===this.#h));)r=this.#d[r]}#L(t){return t!==void 0&&this.#p.get(this.#c[t])===t}*entries(){for(let t of this.#P())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#u(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*rentries(){for(let t of this.#R())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#u(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*keys(){for(let t of this.#P()){let r=this.#c[t];r!==void 0&&!this.#u(this.#n[t])&&(yield r)}}*rkeys(){for(let t of this.#R()){let r=this.#c[t];r!==void 0&&!this.#u(this.#n[t])&&(yield r)}}*values(){for(let t of this.#P())this.#n[t]!==void 0&&!this.#u(this.#n[t])&&(yield this.#n[t])}*rvalues(){for(let t of this.#R())this.#n[t]!==void 0&&!this.#u(this.#n[t])&&(yield this.#n[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,r={}){for(let n of this.#P()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,this.#c[n],this))return this.get(this.#c[n],r)}}forEach(t,r=this){for(let n of this.#P()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}rforEach(t,r=this){for(let n of this.#R()){let s=this.#n[n],o=this.#u(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}purgeStale(){let t=!1;for(let r of this.#R({allowStale:!0}))this.#x(r)&&(this.#A(this.#c[r],"expire"),t=!0);return t}info(t){let r=this.#p.get(t);if(r===void 0)return;let n=this.#n[r],s=this.#u(n)?n.__staleWhileFetching:n;if(s===void 0)return;let o={value:s};if(this.#g&&this.#E){let i=this.#g[r],a=this.#E[r];if(i&&a){let c=i-(this.#l.now()-a);o.ttl=c,o.start=Date.now()}}return this.#k&&(o.size=this.#k[r]),o}dump(){let t=[];for(let r of this.#P({allowStale:!0})){let n=this.#c[r],s=this.#n[r],o=this.#u(s)?s.__staleWhileFetching:s;if(o===void 0||n===void 0)continue;let i={value:o};if(this.#g&&this.#E){i.ttl=this.#g[r];let a=this.#l.now()-this.#E[r];i.start=Math.floor(Date.now()-a)}this.#k&&(i.size=this.#k[r]),t.unshift([n,i])}return t}load(t){this.clear();for(let[r,n]of t){if(n.start){let s=Date.now()-n.start;n.start=this.#l.now()-s}this.set(r,n.value,n)}}set(t,r,n={}){if(r===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:u=this.noUpdateTTL}=n,l=this.#_(t,r,n.size||0,a);if(this.maxEntrySize&&l>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let p=this.#a===0?void 0:this.#p.get(t);if(p===void 0)p=this.#a===0?this.#h:this.#T.length!==0?this.#T.pop():this.#a===this.#t?this.#W(!1):this.#a,this.#c[p]=t,this.#n[p]=r,this.#p.set(t,p),this.#d[this.#h]=p,this.#b[p]=this.#h,this.#h=p,this.#a++,this.#M(p,l,c),c&&(c.set="add"),u=!1,this.#O&&this.#s?.(r,t,"add");else{this.#$(p);let d=this.#n[p];if(r!==d){if(this.#S&&this.#u(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=d;f!==void 0&&!i&&(this.#v&&this.#o?.(f,t,"set"),this.#e&&this.#m?.push([f,t,"set"]))}else i||(this.#v&&this.#o?.(d,t,"set"),this.#e&&this.#m?.push([d,t,"set"]));if(this.#B(p),this.#M(p,l,c),this.#n[p]=r,c){c.set="replace";let f=d&&this.#u(d)?d.__staleWhileFetching:d;f!==void 0&&(c.oldValue=f)}}else c&&(c.set="update");this.#O&&this.onInsert?.(r,t,r===d?"update":"replace")}if(s!==0&&!this.#g&&this.#I(),this.#g&&(u||this.#j(p,s,o),c&&this.#N(c,p)),!i&&this.#e&&this.#m){let d=this.#m,f;for(;f=d?.shift();)this.#i?.(...f)}return this}pop(){try{for(;this.#a;){let t=this.#n[this.#w];if(this.#W(!0),this.#u(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#i?.(...r)}}}#W(t){let r=this.#w,n=this.#c[r],s=this.#n[r];return this.#S&&this.#u(s)?s.__abortController.abort(new Error("evicted")):(this.#v||this.#e)&&(this.#v&&this.#o?.(s,n,"evict"),this.#e&&this.#m?.push([s,n,"evict"])),this.#B(r),this.#y?.[r]&&(clearTimeout(this.#y[r]),this.#y[r]=void 0),t&&(this.#c[r]=void 0,this.#n[r]=void 0,this.#T.push(r)),this.#a===1?(this.#w=this.#h=0,this.#T.length=0):this.#w=this.#d[r],this.#p.delete(n),this.#a--,r}has(t,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=r,o=this.#p.get(t);if(o!==void 0){let i=this.#n[o];if(this.#u(i)&&i.__staleWhileFetching===void 0)return!1;if(this.#x(o))s&&(s.has="stale",this.#N(s,o));else return n&&this.#F(o),s&&(s.has="hit",this.#N(s,o)),!0}else s&&(s.has="miss");return!1}peek(t,r={}){let{allowStale:n=this.allowStale}=r,s=this.#p.get(t);if(s===void 0||!n&&this.#x(s))return;let o=this.#n[s];return this.#u(o)?o.__staleWhileFetching:o}#G(t,r,n,s){let o=r===void 0?void 0:this.#n[r];if(this.#u(o))return o;let i=new Fn,{signal:a}=n;a?.addEventListener("abort",()=>i.abort(a.reason),{signal:i.signal});let c={signal:i.signal,options:n,context:s},u=(h,D=!1)=>{let{aborted:g}=i.signal,y=n.ignoreFetchAbort&&h!==void 0;if(n.status&&(g&&!D?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,y&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),g&&!y&&!D)return p(i.signal.reason);let v=f,C=this.#n[r];return(C===f||y&&D&&C===void 0)&&(h===void 0?v.__staleWhileFetching!==void 0?this.#n[r]=v.__staleWhileFetching:this.#A(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,h,c.options))),h},l=h=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=h),p(h)),p=h=>{let{aborted:D}=i.signal,g=D&&n.allowStaleOnFetchAbort,y=g||n.allowStaleOnFetchRejection,v=y||n.noDeleteOnFetchRejection,C=f;if(this.#n[r]===f&&(!v||C.__staleWhileFetching===void 0?this.#A(t,"fetch"):g||(this.#n[r]=C.__staleWhileFetching)),y)return n.status&&C.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),C.__staleWhileFetching;if(C.__returned===C)throw h},d=(h,D)=>{let g=this.#C?.(t,o,c);g&&g instanceof Promise&&g.then(y=>h(y===void 0?void 0:y),D),i.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(h(void 0),n.allowStaleOnFetchAbort&&(h=y=>u(y,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(u,l),m=Object.assign(f,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(t,m,{...c.options,status:void 0}),r=this.#p.get(t)):this.#n[r]=m,m}#u(t){if(!this.#S)return!1;let r=t;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof Fn}async fetch(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:u=this.sizeCalculation,noUpdateTTL:l=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:h,forceRefresh:D=!1,status:g,signal:y}=r;if(!this.#S)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:g});let v={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:a,size:c,sizeCalculation:u,noUpdateTTL:l,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:m,ignoreFetchAbort:f,status:g,signal:y},C=this.#p.get(t);if(C===void 0){g&&(g.fetch="miss");let A=this.#G(t,C,v,h);return A.__returned=A}else{let A=this.#n[C];if(this.#u(A)){let Ae=n&&A.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Ae&&(g.returnedStale=!0)),Ae?A.__staleWhileFetching:A.__returned=A}let lt=this.#x(C);if(!D&&!lt)return g&&(g.fetch="hit"),this.#$(C),s&&this.#F(C),g&&this.#N(g,C),A;let re=this.#G(t,C,v,h),Te=re.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=lt?"stale":"refresh",Te&&lt&&(g.returnedStale=!0)),Te?re.__staleWhileFetching:re.__returned=re}}async forceFetch(t,r={}){let n=await this.fetch(t,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,r={}){let n=this.#D;if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...i}=r,a=this.get(t,i);if(!o&&a!==void 0)return a;let c=n(t,a,{options:i,context:s});return this.set(t,c,i),c}get(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=r,a=this.#p.get(t);if(a!==void 0){let c=this.#n[a],u=this.#u(c);return i&&this.#N(i,a),this.#x(a)?(i&&(i.get="stale"),u?(i&&n&&c.__staleWhileFetching!==void 0&&(i.returnedStale=!0),n?c.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),i&&n&&(i.returnedStale=!0),n?c:void 0)):(i&&(i.get="hit"),u?c.__staleWhileFetching:(this.#$(a),s&&this.#F(a),c))}else i&&(i.get="miss")}#H(t,r){this.#b[r]=t,this.#d[t]=r}#$(t){t!==this.#h&&(t===this.#w?this.#w=this.#d[t]:this.#H(this.#b[t],this.#d[t]),this.#H(this.#h,t),this.#h=t)}delete(t){return this.#A(t,"delete")}#A(t,r){let n=!1;if(this.#a!==0){let s=this.#p.get(t);if(s!==void 0)if(this.#y?.[s]&&(clearTimeout(this.#y?.[s]),this.#y[s]=void 0),n=!0,this.#a===1)this.#z(r);else{this.#B(s);let o=this.#n[s];if(this.#u(o)?o.__abortController.abort(new Error("deleted")):(this.#v||this.#e)&&(this.#v&&this.#o?.(o,t,r),this.#e&&this.#m?.push([o,t,r])),this.#p.delete(t),this.#c[s]=void 0,this.#n[s]=void 0,s===this.#h)this.#h=this.#b[s];else if(s===this.#w)this.#w=this.#d[s];else{let i=this.#b[s];this.#d[i]=this.#d[s];let a=this.#d[s];this.#b[a]=this.#b[s]}this.#a--,this.#T.push(s)}}if(this.#e&&this.#m?.length){let s=this.#m,o;for(;o=s?.shift();)this.#i?.(...o)}return n}clear(){return this.#z("delete")}#z(t){for(let r of this.#R({allowStale:!0})){let n=this.#n[r];if(this.#u(n))n.__abortController.abort(new Error("deleted"));else{let s=this.#c[r];this.#v&&this.#o?.(n,s,t),this.#e&&this.#m?.push([n,s,t])}}if(this.#p.clear(),this.#n.fill(void 0),this.#c.fill(void 0),this.#g&&this.#E){this.#g.fill(0),this.#E.fill(0);for(let r of this.#y??[])r!==void 0&&clearTimeout(r);this.#y?.fill(void 0)}if(this.#k&&this.#k.fill(0),this.#w=0,this.#h=0,this.#T.length=0,this.#f=0,this.#a=0,this.#e&&this.#m){let r=this.#m,n;for(;n=r?.shift();)this.#i?.(...n)}}};var _e=require("node:path"),sc=require("node:url"),It=require("fs"),pm=b(require("node:fs"),1),ce=require("node:fs/promises");var On=require("node:events"),Do=b(require("node:stream"),1),Qa=require("node:string_decoder"),qa=typeof process=="object"&&process?process:{stdout:null,stderr:null},rm=e=>!!e&&typeof e=="object"&&(e instanceof ae||e instanceof Do.default||nm(e)||sm(e)),nm=e=>!!e&&typeof e=="object"&&e instanceof On.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Do.default.Writable.prototype.pipe,sm=e=>!!e&&typeof e=="object"&&e instanceof On.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",zt=Symbol("EOF"),Kt=Symbol("maybeEmitEnd"),ie=Symbol("emittedEnd"),Tn=Symbol("emittingEnd"),Mr=Symbol("emittedError"),An=Symbol("closed"),Ya=Symbol("read"),Pn=Symbol("flush"),Za=Symbol("flushChunk"),yt=Symbol("encoding"),Be=Symbol("decoder"),_=Symbol("flowing"),$r=Symbol("paused"),je=Symbol("resume"),L=Symbol("buffer"),Y=Symbol("pipes"),W=Symbol("bufferLength"),lo=Symbol("bufferPush"),Rn=Symbol("bufferShift"),U=Symbol("objectMode"),M=Symbol("destroyed"),po=Symbol("error"),fo=Symbol("emitData"),Xa=Symbol("emitEnd"),ho=Symbol("emitEnd2"),Pt=Symbol("async"),mo=Symbol("abort"),In=Symbol("aborted"),Br=Symbol("signal"),we=Symbol("dataListeners"),it=Symbol("discarded"),jr=e=>Promise.resolve().then(e),om=e=>e(),im=e=>e==="end"||e==="finish"||e==="prefinish",am=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,cm=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),Nn=class{src;dest;opts;ondrain;constructor(t,r,n){this.src=t,this.dest=r,this.opts=n,this.ondrain=()=>t[je](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},go=class extends Nn{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,r,n){super(t,r,n),this.proxyErrors=s=>r.emit("error",s),t.on("error",this.proxyErrors)}},um=e=>!!e.objectMode,lm=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",ae=class extends On.EventEmitter{[_]=!1;[$r]=!1;[Y]=[];[L]=[];[U];[yt];[Pt];[Be];[zt]=!1;[ie]=!1;[Tn]=!1;[An]=!1;[Mr]=null;[W]=0;[M]=!1;[Br];[In]=!1;[we]=0;[it]=!1;writable=!0;readable=!0;constructor(...t){let r=t[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");um(r)?(this[U]=!0,this[yt]=null):lm(r)?(this[yt]=r.encoding,this[U]=!1):(this[U]=!1,this[yt]=null),this[Pt]=!!r.async,this[Be]=this[yt]?new Qa.StringDecoder(this[yt]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[L]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Y]});let{signal:n}=r;n&&(this[Br]=n,n.aborted?this[mo]():n.addEventListener("abort",()=>this[mo]()))}get bufferLength(){return this[W]}get encoding(){return this[yt]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[U]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Pt]}set async(t){this[Pt]=this[Pt]||!!t}[mo](){this[In]=!0,this.emit("abort",this[Br]?.reason),this.destroy(this[Br]?.reason)}get aborted(){return this[In]}set aborted(t){}write(t,r,n){if(this[In])return!1;if(this[zt])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let s=this[Pt]?jr:om;if(!this[U]&&!Buffer.isBuffer(t)){if(cm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(am(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[U]?(this[_]&&this[W]!==0&&this[Pn](!0),this[_]?this.emit("data",t):this[lo](t),this[W]!==0&&this.emit("readable"),n&&s(n),this[_]):t.length?(typeof t=="string"&&!(r===this[yt]&&!this[Be]?.lastNeed)&&(t=Buffer.from(t,r)),Buffer.isBuffer(t)&&this[yt]&&(t=this[Be].write(t)),this[_]&&this[W]!==0&&this[Pn](!0),this[_]?this.emit("data",t):this[lo](t),this[W]!==0&&this.emit("readable"),n&&s(n),this[_]):(this[W]!==0&&this.emit("readable"),n&&s(n),this[_])}read(t){if(this[M])return null;if(this[it]=!1,this[W]===0||t===0||t&&t>this[W])return this[Kt](),null;this[U]&&(t=null),this[L].length>1&&!this[U]&&(this[L]=[this[yt]?this[L].join(""):Buffer.concat(this[L],this[W])]);let r=this[Ya](t||null,this[L][0]);return this[Kt](),r}[Ya](t,r){if(this[U])this[Rn]();else{let n=r;t===n.length||t===null?this[Rn]():typeof n=="string"?(this[L][0]=n.slice(t),r=n.slice(0,t),this[W]-=t):(this[L][0]=n.subarray(t),r=n.subarray(0,t),this[W]-=t)}return this.emit("data",r),!this[L].length&&!this[zt]&&this.emit("drain"),r}end(t,r,n){return typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r="utf8"),t!==void 0&&this.write(t,r),n&&this.once("end",n),this[zt]=!0,this.writable=!1,(this[_]||!this[$r])&&this[Kt](),this}[je](){this[M]||(!this[we]&&!this[Y].length&&(this[it]=!0),this[$r]=!1,this[_]=!0,this.emit("resume"),this[L].length?this[Pn]():this[zt]?this[Kt]():this.emit("drain"))}resume(){return this[je]()}pause(){this[_]=!1,this[$r]=!0,this[it]=!1}get destroyed(){return this[M]}get flowing(){return this[_]}get paused(){return this[$r]}[lo](t){this[U]?this[W]+=1:this[W]+=t.length,this[L].push(t)}[Rn](){return this[U]?this[W]-=1:this[W]-=this[L][0].length,this[L].shift()}[Pn](t=!1){do;while(this[Za](this[Rn]())&&this[L].length);!t&&!this[L].length&&!this[zt]&&this.emit("drain")}[Za](t){return this.emit("data",t),this[_]}pipe(t,r){if(this[M])return t;this[it]=!1;let n=this[ie];return r=r||{},t===qa.stdout||t===qa.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&t.end():(this[Y].push(r.proxyErrors?new go(this,t,r):new Nn(this,t,r)),this[Pt]?jr(()=>this[je]()):this[je]()),t}unpipe(t){let r=this[Y].find(n=>n.dest===t);r&&(this[Y].length===1?(this[_]&&this[we]===0&&(this[_]=!1),this[Y]=[]):this[Y].splice(this[Y].indexOf(r),1),r.unpipe())}addListener(t,r){return this.on(t,r)}on(t,r){let n=super.on(t,r);if(t==="data")this[it]=!1,this[we]++,!this[Y].length&&!this[_]&&this[je]();else if(t==="readable"&&this[W]!==0)super.emit("readable");else if(im(t)&&this[ie])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Mr]){let s=r;this[Pt]?jr(()=>s.call(this,this[Mr])):s.call(this,this[Mr])}return n}removeListener(t,r){return this.off(t,r)}off(t,r){let n=super.off(t,r);return t==="data"&&(this[we]=this.listeners("data").length,this[we]===0&&!this[it]&&!this[Y].length&&(this[_]=!1)),n}removeAllListeners(t){let r=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[we]=0,!this[it]&&!this[Y].length&&(this[_]=!1)),r}get emittedEnd(){return this[ie]}[Kt](){!this[Tn]&&!this[ie]&&!this[M]&&this[L].length===0&&this[zt]&&(this[Tn]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[An]&&this.emit("close"),this[Tn]=!1)}emit(t,...r){let n=r[0];if(t!=="error"&&t!=="close"&&t!==M&&this[M])return!1;if(t==="data")return!this[U]&&!n?!1:this[Pt]?(jr(()=>this[fo](n)),!0):this[fo](n);if(t==="end")return this[Xa]();if(t==="close"){if(this[An]=!0,!this[ie]&&!this[M])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Mr]=n,super.emit(po,n);let o=!this[Br]||this.listeners("error").length?super.emit("error",n):!1;return this[Kt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Kt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let s=super.emit(t,...r);return this[Kt](),s}[fo](t){for(let n of this[Y])n.dest.write(t)===!1&&this.pause();let r=this[it]?!1:super.emit("data",t);return this[Kt](),r}[Xa](){return this[ie]?!1:(this[ie]=!0,this.readable=!1,this[Pt]?(jr(()=>this[ho]()),!0):this[ho]())}[ho](){if(this[Be]){let r=this[Be].end();if(r){for(let n of this[Y])n.dest.write(r);this[it]||super.emit("data",r)}}for(let r of this[Y])r.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[U]||(t.dataLength=0);let r=this.promise();return this.on("data",n=>{t.push(n),this[U]||(t.dataLength+=n.length)}),await r,t}async concat(){if(this[U])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[yt]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,r)=>{this.on(M,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[it]=!1;let t=!1,r=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return r();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[zt])return r();let o,i,a=p=>{this.off("data",c),this.off("end",u),this.off(M,l),r(),i(p)},c=p=>{this.off("error",a),this.off("end",u),this.off(M,l),this.pause(),o({value:p,done:!!this[zt]})},u=()=>{this.off("error",a),this.off("data",c),this.off(M,l),r(),o({done:!0,value:void 0})},l=()=>a(new Error("stream destroyed"));return new Promise((p,d)=>{i=d,o=p,this.once(M,l),this.once("error",a),this.once("end",u),this.once("data",c)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[it]=!1;let t=!1,r=()=>(this.pause(),this.off(po,r),this.off(M,r),this.off("end",r),t=!0,{done:!0,value:void 0}),n=()=>{if(t)return r();let s=this.read();return s===null?r():{done:!1,value:s}};return this.once("end",r),this.once(po,r),this.once(M,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(t){if(this[M])return t?this.emit("error",t):this.emit(M),this;this[M]=!0,this[it]=!0,this[L].length=0,this[W]=0;let r=this;return typeof r.close=="function"&&!this[An]&&r.close(),t?this.emit("error",t):this.emit(M),this}static get isStream(){return rm}};var fm=It.realpathSync.native,Lr={lstatSync:It.lstatSync,readdir:It.readdir,readdirSync:It.readdirSync,readlinkSync:It.readlinkSync,realpathSync:fm,promises:{lstat:ce.lstat,readdir:ce.readdir,readlink:ce.readlink,realpath:ce.realpath}},oc=e=>!e||e===Lr||e===pm?Lr:{...Lr,...e,promises:{...Lr.promises,...e.promises||{}}},ic=/^\\\\\?\\([a-z]:)\\?$/i,dm=e=>e.replace(/\//g,"\\").replace(ic,"$1\\"),hm=/[\\\/]/,ht=0,ac=1,cc=2,Rt=4,uc=6,lc=8,Ce=10,pc=12,dt=15,_r=~dt,yo=16,tc=32,Wr=64,wt=128,Mn=256,Bn=512,ec=Wr|wt|Bn,mm=1023,wo=e=>e.isFile()?lc:e.isDirectory()?Rt:e.isSymbolicLink()?Ce:e.isCharacterDevice()?cc:e.isBlockDevice()?uc:e.isSocket()?pc:e.isFIFO()?ac:ht,rc=new ye({max:2**12}),Gr=e=>{let t=rc.get(e);if(t)return t;let r=e.normalize("NFKD");return rc.set(e,r),r},nc=new ye({max:2**12}),$n=e=>{let t=nc.get(e);if(t)return t;let r=Gr(e.toLowerCase());return nc.set(e,r),r},jn=class extends ye{constructor(){super({max:256})}},Co=class extends ye{constructor(t=16*1024){super({maxSize:t,sizeCalculation:r=>r.length+1})}},fc=Symbol("PathScurry setAsCwd"),z=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#o;get mode(){return this.#o}#s;get nlink(){return this.#s}#i;get uid(){return this.#i}#C;get gid(){return this.#C}#D;get rdev(){return this.#D}#l;get blksize(){return this.#l}#a;get ino(){return this.#a}#f;get size(){return this.#f}#p;get blocks(){return this.#p}#c;get atimeMs(){return this.#c}#n;get mtimeMs(){return this.#n}#d;get ctimeMs(){return this.#d}#b;get birthtimeMs(){return this.#b}#w;get atime(){return this.#w}#h;get mtime(){return this.#h}#T;get ctime(){return this.#T}#m;get birthtime(){return this.#m}#k;#E;#g;#y;#v;#S;#e;#O;#I;#F;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,r=ht,n,s,o,i,a){this.name=t,this.#k=o?$n(t):Gr(t),this.#e=r&mm,this.nocase=o,this.roots=s,this.root=n||this,this.#O=i,this.#g=a.fullpath,this.#v=a.relative,this.#S=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=oc(a.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#O}resolve(t){if(!t)return this;let r=this.getRootString(t),s=t.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#N(s):this.#N(s)}#N(t){let r=this;for(let n of t)r=r.child(n);return r}children(){let t=this.#O.get(this);if(t)return t;let r=Object.assign([],{provisional:0});return this.#O.set(this,r),this.#e&=~yo,r}child(t,r){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let n=this.children(),s=this.nocase?$n(t):Gr(t);for(let c of n)if(c.#k===s)return c;let o=this.parent?this.sep:"",i=this.#g?this.#g+o+t:void 0,a=this.newChild(t,ht,{...r,parent:this,fullpath:i});return this.canReaddir()||(a.#e|=wt),n.push(a),a}relative(){if(this.isCWD)return"";if(this.#v!==void 0)return this.#v;let t=this.name,r=this.parent;if(!r)return this.#v=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#S!==void 0)return this.#S;let t=this.name,r=this.parent;if(!r)return this.#S=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+t}fullpath(){if(this.#g!==void 0)return this.#g;let t=this.name,r=this.parent;if(!r)return this.#g=this.name;let s=r.fullpath()+(r.parent?this.sep:"")+t;return this.#g=s}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(s)?this.#y=`//?/${s}`:this.#y=s}let t=this.parent,r=t.fullpathPosix(),n=r+(!r||!t.parent?"":"/")+this.name;return this.#y=n}isUnknown(){return(this.#e&dt)===ht}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#e&dt)===lc}isDirectory(){return(this.#e&dt)===Rt}isCharacterDevice(){return(this.#e&dt)===cc}isBlockDevice(){return(this.#e&dt)===uc}isFIFO(){return(this.#e&dt)===ac}isSocket(){return(this.#e&dt)===pc}isSymbolicLink(){return(this.#e&Ce)===Ce}lstatCached(){return this.#e&tc?this:void 0}readlinkCached(){return this.#I}realpathCached(){return this.#F}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#I)return!0;if(!this.parent)return!1;let t=this.#e&dt;return!(t!==ht&&t!==Ce||this.#e&Mn||this.#e&wt)}calledReaddir(){return!!(this.#e&yo)}isENOENT(){return!!(this.#e&wt)}isNamed(t){return this.nocase?this.#k===$n(t):this.#k===Gr(t)}async readlink(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=await this.#t.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}readlinkSync(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=this.#t.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}#j(t){this.#e|=yo;for(let r=t.provisional;r<t.length;r++){let n=t[r];n&&n.#x()}}#x(){this.#e&wt||(this.#e=(this.#e|wt)&_r,this.#U())}#U(){let t=this.children();t.provisional=0;for(let r of t)r.#x()}#B(){this.#e|=Bn,this.#M()}#M(){if(this.#e&Wr)return;let t=this.#e;(t&dt)===Rt&&(t&=_r),this.#e=t|Wr,this.#U()}#_(t=""){t==="ENOTDIR"||t==="EPERM"?this.#M():t==="ENOENT"?this.#x():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#M():t==="ENOENT"&&this.#x()}#R(t=""){let r=this.#e;r|=Mn,t==="ENOENT"&&(r|=wt),(t==="EINVAL"||t==="UNKNOWN")&&(r&=_r),this.#e=r,t==="ENOTDIR"&&this.parent&&this.parent.#M()}#L(t,r){return this.#G(t,r)||this.#W(t,r)}#W(t,r){let n=wo(t),s=this.newChild(t.name,n,{parent:this}),o=s.#e&dt;return o!==Rt&&o!==Ce&&o!==ht&&(s.#e|=Wr),r.unshift(s),r.provisional++,s}#G(t,r){for(let n=r.provisional;n<r.length;n++){let s=r[n];if((this.nocase?$n(t.name):Gr(t.name))===s.#k)return this.#u(t,s,n,r)}}#u(t,r,n,s){let o=r.name;return r.#e=r.#e&_r|wo(t),o!==t.name&&(r.name=t.name),n!==s.provisional&&(n===s.length-1?s.pop():s.splice(n,1),s.unshift(r)),s.provisional++,r}async lstat(){if((this.#e&wt)===0)try{return this.#H(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if((this.#e&wt)===0)try{return this.#H(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#P(t.code)}}#H(t){let{atime:r,atimeMs:n,birthtime:s,birthtimeMs:o,blksize:i,blocks:a,ctime:c,ctimeMs:u,dev:l,gid:p,ino:d,mode:f,mtime:m,mtimeMs:h,nlink:D,rdev:g,size:y,uid:v}=t;this.#w=r,this.#c=n,this.#m=s,this.#b=o,this.#l=i,this.#p=a,this.#T=c,this.#d=u,this.#r=l,this.#C=p,this.#a=d,this.#o=f,this.#h=m,this.#n=h,this.#s=D,this.#D=g,this.#f=y,this.#i=v;let C=wo(t);this.#e=this.#e&_r|C|tc,C!==ht&&C!==Rt&&C!==Ce&&(this.#e|=Wr)}#$=[];#A=!1;#z(t){this.#A=!1;let r=this.#$.slice();this.#$.length=0,r.forEach(n=>n(null,t))}readdirCB(t,r=!1){if(!this.canReaddir()){r?t(null,[]):queueMicrotask(()=>t(null,[]));return}let n=this.children();if(this.calledReaddir()){let o=n.slice(0,n.provisional);r?t(null,o):queueMicrotask(()=>t(null,o));return}if(this.#$.push(t),this.#A)return;this.#A=!0;let s=this.fullpath();this.#t.readdir(s,{withFileTypes:!0},(o,i)=>{if(o)this.#_(o.code),n.provisional=0;else{for(let a of i)this.#L(a,n);this.#j(n)}this.#z(n.slice(0,n.provisional))})}#K;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();if(this.#K)await this.#K;else{let n=()=>{};this.#K=new Promise(s=>n=s);try{for(let s of await this.#t.promises.readdir(r,{withFileTypes:!0}))this.#L(s,t);this.#j(t)}catch(s){this.#_(s.code),t.provisional=0}this.#K=void 0,n()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();try{for(let n of this.#t.readdirSync(r,{withFileTypes:!0}))this.#L(n,t);this.#j(t)}catch(n){this.#_(n.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&ec)return!1;let t=dt&this.#e;return t===ht||t===Rt||t===Ce}shouldWalk(t,r){return(this.#e&Rt)===Rt&&!(this.#e&ec)&&!t.has(this)&&(!r||r(this))}async realpath(){if(this.#F)return this.#F;if(!((Bn|Mn|wt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}realpathSync(){if(this.#F)return this.#F;if(!((Bn|Mn|wt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}[fc](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],s=this;for(;s&&s.parent;)r.add(s),s.#v=n.join(this.sep),s.#S=n.join("/"),s=s.parent,n.push("..");for(s=t;s&&s.parent&&!r.has(s);)s.#v=void 0,s.#S=void 0,s=s.parent}},_n=class e extends z{sep="\\";splitSep=hm;constructor(t,r=ht,n,s,o,i,a){super(t,r,n,s,o,i,a)}newChild(t,r=ht,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(t){return _e.win32.parse(t).root}getRoot(t){if(t=dm(t.toUpperCase()),t===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(t,r))return this.roots[t]=n;return this.roots[t]=new Le(t,this).root}sameRoot(t,r=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(ic,"$1\\"),t===r}},Ln=class e extends z{splitSep="/";sep="/";constructor(t,r=ht,n,s,o,i,a){super(t,r,n,s,o,i,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,r=ht,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Wn=class{root;rootPath;roots;cwd;#t;#r;#o;nocase;#s;constructor(t=process.cwd(),r,n,{nocase:s,childrenCacheSize:o=16*1024,fs:i=Lr}={}){this.#s=oc(i),(t instanceof URL||t.startsWith("file://"))&&(t=(0,sc.fileURLToPath)(t));let a=r.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new jn,this.#r=new jn,this.#o=new Co(o);let c=a.substring(this.rootPath.length).split(n);if(c.length===1&&!c[0]&&c.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let u=this.root,l=c.length-1,p=r.sep,d=this.rootPath,f=!1;for(let m of c){let h=l--;u=u.child(m,{relative:new Array(h).fill("..").join(p),relativePosix:new Array(h).fill("..").join("/"),fullpath:d+=(f?"":p)+m}),f=!0}this.cwd=u}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#o}resolve(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#t.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpath();return this.#t.set(r,s),s}resolvePosix(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#r.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpathPosix();return this.#r.set(r,s),s}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n}=r;if(t.canReaddir()){let s=await t.readdir();return n?s:s.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0}=r;return t.canReaddir()?n?t.readdirSync():t.readdirSync().map(s=>s.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=await t.readlink();return r?n:n?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=t.readlinkSync();return r?n:n?.fullpath()}async realpath(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=await t.realpath();return r?n:n?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t.withFileTypes,t=this.cwd);let n=t.realpathSync();return r?n:n?.fullpath()}async walk(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set,u=(p,d)=>{c.add(p),p.readdirCB((f,m)=>{if(f)return d(f);let h=m.length;if(!h)return d();let D=()=>{--h===0&&d()};for(let g of m)(!o||o(g))&&a.push(n?g:g.fullpath()),s&&g.isSymbolicLink()?g.realpath().then(y=>y?.isUnknown()?y.lstat():y).then(y=>y?.shouldWalk(c,i)?u(y,D):D()):g.shouldWalk(c,i)?u(g,D):D()},!0)},l=t;return new Promise((p,d)=>{u(l,f=>{if(f)return d(f);p(a)})})}walkSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set([t]);for(let u of c){let l=u.readdirSync();for(let p of l){(!o||o(p))&&a.push(n?p:p.fullpath());let d=p;if(p.isSymbolicLink()){if(!(s&&(d=p.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,i)&&c.add(d)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,r={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd),this.stream(t,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r;(!o||o(t))&&(yield n?t:t.fullpath());let a=new Set([t]);for(let c of a){let u=c.readdirSync();for(let l of u){(!o||o(l))&&(yield n?l:l.fullpath());let p=l;if(l.isSymbolicLink()){if(!(s&&(p=l.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(a,i)&&a.add(p)}}}stream(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ae({objectMode:!0});(!o||o(t))&&a.write(n?t:t.fullpath());let c=new Set,u=[t],l=0,p=()=>{let d=!1;for(;!d;){let f=u.shift();if(!f){l===0&&a.end();return}l++,c.add(f);let m=(D,g,y=!1)=>{if(D)return a.emit("error",D);if(s&&!y){let v=[];for(let C of g)C.isSymbolicLink()&&v.push(C.realpath().then(A=>A?.isUnknown()?A.lstat():A));if(v.length){Promise.all(v).then(()=>m(null,g,!0));return}}for(let v of g)v&&(!o||o(v))&&(a.write(n?v:v.fullpath())||(d=!0));l--;for(let v of g){let C=v.realpathCached()||v;C.shouldWalk(c,i)&&u.push(C)}d&&!a.flowing?a.once("drain",p):h||p()},h=!0;f.readdirCB(m,!0),h=!1}};return p(),a}streamSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof z||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ae({objectMode:!0}),c=new Set;(!o||o(t))&&a.write(n?t:t.fullpath());let u=[t],l=0,p=()=>{let d=!1;for(;!d;){let f=u.shift();if(!f){l===0&&a.end();return}l++,c.add(f);let m=f.readdirSync();for(let h of m)(!o||o(h))&&(a.write(n?h:h.fullpath())||(d=!0));l--;for(let h of m){let D=h;if(h.isSymbolicLink()){if(!(s&&(D=h.realpathSync())))continue;D.isUnknown()&&D.lstatSync()}D.shouldWalk(c,i)&&u.push(D)}}d&&!a.flowing&&a.once("drain",p)};return p(),a}chdir(t=this.cwd){let r=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[fc](r)}},Le=class extends Wn{sep="\\";constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,_e.win32,"\\",{...r,nocase:n}),this.nocase=n;for(let s=this.cwd;s;s=s.parent)s.nocase=this.nocase}parseRootPath(t){return _e.win32.parse(t).root.toUpperCase()}newRoot(t){return new _n(this.rootPath,Rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},We=class extends Wn{sep="/";constructor(t=process.cwd(),r={}){let{nocase:n=!1}=r;super(t,_e.posix,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(t){return"/"}newRoot(t){return new Ln(this.rootPath,Rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},Hr=class extends We{constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,{...r,nocase:n})}},Hb=process.platform==="win32"?_n:Ln,dc=process.platform==="win32"?Le:process.platform==="darwin"?Hr:We;var gm=e=>e.length>=1,Dm=e=>e.length>=1,Ge=class e{#t;#r;#o;length;#s;#i;#C;#D;#l;#a;#f=!0;constructor(t,r,n,s){if(!gm(t))throw new TypeError("empty pattern list");if(!Dm(r))throw new TypeError("empty glob list");if(r.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=r,this.#o=n,this.#s=s,this.#o===0){if(this.isUNC()){let[o,i,a,c,...u]=this.#t,[l,p,d,f,...m]=this.#r;u[0]===""&&(u.shift(),m.shift());let h=[o,i,a,c,""].join("/"),D=[l,p,d,f,""].join("/");this.#t=[h,...u],this.#r=[D,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[o,...i]=this.#t,[a,...c]=this.#r;i[0]===""&&(i.shift(),c.shift());let u=o+"/",l=a+"/";this.#t=[u,...i],this.#r=[l,...c],this.length=this.#t.length}}}pattern(){return this.#t[this.#o]}isString(){return typeof this.#t[this.#o]=="string"}isGlobstar(){return this.#t[this.#o]===H}isRegExp(){return this.#t[this.#o]instanceof RegExp}globString(){return this.#C=this.#C||(this.#o===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#o).join("/"))}hasMore(){return this.length>this.#o+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new e(this.#t,this.#r,this.#o+1,this.#s),this.#i.#a=this.#a,this.#i.#l=this.#l,this.#i.#D=this.#D,this.#i):this.#i=null}isUNC(){let t=this.#t;return this.#l!==void 0?this.#l:this.#l=this.#s==="win32"&&this.#o===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#D!==void 0?this.#D:this.#D=this.#s==="win32"&&this.#o===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#o===0?t:""}checkFollowGlobstar(){return!(this.#o===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#o===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}};var ym=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",He=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:r,nocase:n,noext:s,noglobstar:o,platform:i=ym}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=i,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:s,noglobstar:o,optimizationLevel:2,platform:i,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let r=new ot(t,this.mmopts);for(let n=0;n<r.set.length;n++){let s=r.set[n],o=r.globParts[n];if(!s||!o)throw new Error("invalid pattern object");for(;s[0]==="."&&o[0]===".";)s.shift(),o.shift();let i=new Ge(s,o,0,this.platform),a=new ot(i.globString(),this.mmopts),c=o[o.length-1]==="**",u=i.isAbsolute();u?this.absolute.push(a):this.relative.push(a),c&&(u?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let r=t.fullpath(),n=`${r}/`,s=t.relative()||".",o=`${s}/`;for(let i of this.relative)if(i.match(s)||i.match(o))return!0;for(let i of this.absolute)if(i.match(r)||i.match(n))return!0;return!1}childrenIgnored(t){let r=t.fullpath()+"/",n=(t.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(n))return!0;for(let s of this.absoluteChildren)if(s.match(r))return!0;return!1}};var bo=class e{store;constructor(t=new Map){this.store=t}copy(){return new e(new Map(this.store))}hasWalked(t,r){return this.store.get(t.fullpath())?.has(r.globString())}storeWalked(t,r){let n=t.fullpath(),s=this.store.get(n);s?s.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},vo=class{store=new Map;add(t,r,n){let s=(r?2:0)|(n?1:0),o=this.store.get(t);this.store.set(t,o===void 0?s:s&o)}entries(){return[...this.store.entries()].map(([t,r])=>[t,!!(r&2),!!(r&1)])}},xo=class{store=new Map;add(t,r){if(!t.canReaddir())return;let n=this.store.get(t);n?n.find(s=>s.globString()===r.globString())||n.push(r):this.store.set(t,[r])}get(t){let r=this.store.get(t);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Ur=class e{hasWalkedCache;matches=new vo;subwalks=new xo;patterns;follow;dot;opts;constructor(t,r){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=r?r.copy():new bo}processPatterns(t,r){this.patterns=r;let n=r.map(s=>[t,s]);for(let[s,o]of n){this.hasWalkedCache.storeWalked(s,o);let i=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(i){s=s.resolve(i==="/"&&this.opts.root!==void 0?this.opts.root:i);let p=o.rest();if(p)o=p;else{this.matches.add(s,!0,!1);continue}}if(s.isENOENT())continue;let c,u,l=!1;for(;typeof(c=o.pattern())=="string"&&(u=o.rest());)s=s.resolve(c),o=u,l=!0;if(c=o.pattern(),u=o.rest(),l){if(this.hasWalkedCache.hasWalked(s,o))continue;this.hasWalkedCache.storeWalked(s,o)}if(typeof c=="string"){let p=c===".."||c===""||c===".";this.matches.add(s.resolve(c),a,p);continue}else if(c===H){(!s.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(s,o);let p=u?.pattern(),d=u?.rest();if(!u||(p===""||p===".")&&!d)this.matches.add(s,a,p===""||p===".");else if(p===".."){let f=s.parent||s;d?this.hasWalkedCache.hasWalked(f,d)||this.subwalks.add(f,d):this.matches.add(f,a,!0)}}else c instanceof RegExp&&this.subwalks.add(s,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(t,r){let n=this.subwalks.get(t),s=this.child();for(let o of r)for(let i of n){let a=i.isAbsolute(),c=i.pattern(),u=i.rest();c===H?s.testGlobstar(o,i,u,a):c instanceof RegExp?s.testRegExp(o,c,u,a):s.testString(o,c,u,a)}return s}testGlobstar(t,r,n,s){if((this.dot||!t.name.startsWith("."))&&(r.hasMore()||this.matches.add(t,s,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,r):t.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(t,n):r.markFollowGlobstar()&&this.subwalks.add(t,r)))),n){let o=n.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,n.rest(),s);else if(o===".."){let i=t.parent||t;this.subwalks.add(i,n)}else o instanceof RegExp&&this.testRegExp(t,o,n.rest(),s)}}testRegExp(t,r,n,s){r.test(t.name)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}testString(t,r,n,s){t.isNamed(r)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}};var wm=(e,t)=>typeof e=="string"?new He([e],t):Array.isArray(e)?new He(e,t):e,Gn=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#o;signal;maxDepth;includeChildMatches;constructor(t,r,n){if(this.patterns=t,this.path=r,this.opts=n,this.#o=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#r=wm(n.ignore??[],n),!this.includeChildMatches&&typeof this.#r.add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#s(t){return this.seen.has(t)||!!this.#r?.ignored?.(t)}#i(t){return!!this.#r?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||await t.realpath(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=await o.realpath();i&&(i.isUnknown()||this.opts.stat)&&await i.lstat()}return this.matchCheckTest(o,r)}matchCheckTest(t,r){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!r||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#s(t)?t:void 0}matchCheckSync(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||t.realpathSync(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=o.realpathSync();i&&(i?.isUnknown()||this.opts.stat)&&i.lstatSync()}return this.matchCheckTest(o,r)}matchFinish(t,r){if(this.#s(t))return;if(!this.includeChildMatches&&this.#r?.add){let o=`${t.relativePosix()}/**`;this.#r.add(o)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(t);let s=this.opts.mark&&t.isDirectory()?this.#o:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(n){let o=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(o+s)}else{let o=this.opts.posix?t.relativePosix():t.relative(),i=this.opts.dotRelative&&!o.startsWith(".."+this.#o)?"."+this.#o:"";this.matchEmit(o?i+o+s:"."+s)}}async match(t,r,n){let s=await this.matchCheck(t,n);s&&this.matchFinish(s,r)}matchSync(t,r,n){let s=this.matchCheckSync(t,n);s&&this.matchFinish(s,r)}walkCB(t,r,n){this.signal?.aborted&&n(),this.walkCB2(t,r,new Ur(this.opts),n)}walkCB2(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,u).then(()=>i()));for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,n,i):a.readdirCB((u,l)=>this.walkCB3(a,l,n,i),!0)}i()}walkCB3(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,u).then(()=>i()));for(let[a,c]of n.subwalks.entries())o++,this.walkCB2(a,c,n.child(),i);i()}walkCBSync(t,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(t,r,new Ur(this.opts),n)}walkCB2Sync(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||this.matchSync(a,c,u);for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirSync();this.walkCB3Sync(a,c,n,i)}i()}walkCB3Sync(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,u]of n.matches.entries())this.#s(a)||this.matchSync(a,c,u);for(let[a,c]of n.subwalks.entries())o++,this.walkCB2Sync(a,c,n.child(),i);i()}},zr=class extends Gn{matches=new Set;constructor(t,r,n){super(t,r,n)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},Kr=class extends Gn{results;constructor(t,r,n){super(t,r,n),this.results=new ae({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var Cm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",Ct=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=(0,hc.fileURLToPath)(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=t,this.platform=r.platform||Cm,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=r.platform==="win32"?Le:r.platform==="darwin"?Hr:r.platform?We:dc;this.scurry=new c(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",s={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(c=>new ot(c,s)),[i,a]=o.reduce((c,u)=>(c[0].push(...u.set),c[1].push(...u.globParts),c),[[],[]]);this.patterns=i.map((c,u)=>{let l=a[u];if(!l)throw new Error("invalid pattern object");return new Ge(c,l,0,this.platform)})}async walk(){return[...await new zr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new zr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new Kr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new Kr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var ko=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let r of e)if(new ot(r,t).hasMagic())return!0;return!1};function Un(e,t={}){return new Ct(e,t).streamSync()}function gc(e,t={}){return new Ct(e,t).stream()}function zn(e,t={}){return new Ct(e,t).walkSync()}async function mc(e,t={}){return new Ct(e,t).walk()}function Kn(e,t={}){return new Ct(e,t).iterateSync()}function Dc(e,t={}){return new Ct(e,t).iterate()}var bm=Un,vm=Object.assign(gc,{sync:Un}),xm=Kn,km=Object.assign(Dc,{sync:Kn}),Em=Object.assign(zn,{stream:Un,iterate:Kn}),Hn=Object.assign(mc,{glob:mc,globSync:zn,sync:Em,globStream:gc,stream:vm,globStreamSync:Un,streamSync:bm,globIterate:Dc,iterate:km,globIterateSync:Kn,iterateSync:xm,Glob:Ct,hasMagic:ko,escape:Me,unescape:Dt});Hn.glob=Hn;var ue=(e,t)=>typeof e>"u"||typeof e===t,yc=e=>!!e&&typeof e=="object"&&ue(e.preserveRoot,"boolean")&&ue(e.tmp,"string")&&ue(e.maxRetries,"number")&&ue(e.retryDelay,"number")&&ue(e.backoff,"number")&&ue(e.maxBackoff,"number")&&(ue(e.glob,"boolean")||e.glob&&typeof e.glob=="object")&&ue(e.filter,"function"),wc=e=>{if(!yc(e))throw new Error("invalid rimraf options")},Cc=e=>{wc(e);let{glob:t,...r}=e;if(!t)return r;let n=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...r,glob:{...n,absolute:!0,withFileTypes:!1}}},bc=(e={})=>Cc(e),vc=(e={})=>Cc(e);var Jr=require("path"),xc=require("util"),Sm=(e,t={})=>{let r=typeof e;if(r!=="string"){let s=e&&r==="object"&&e.constructor,i=`The "path" argument must be of type string. Received ${s&&s.name?`an instance of ${s.name}`:r==="object"?(0,xc.inspect)(e):`type ${r} ${e}`}`;throw Object.assign(new TypeError(i),{path:e,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(e)){let s="path must be a string without null bytes";throw Object.assign(new TypeError(s),{path:e,code:"ERR_INVALID_ARG_VALUE"})}e=(0,Jr.resolve)(e);let{root:n}=(0,Jr.parse)(e);if(e===n&&t.preserveRoot!==!1){let s="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(s),{path:e,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let s=/[*|"<>?:]/,{root:o}=(0,Jr.parse)(e);if(s.test(e.substring(o.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e},Vr=Sm;var kc=require("fs"),Nt=b(require("fs/promises"),1),k=require("fs"),Ec=e=>(0,kc.readdirSync)(e,{withFileTypes:!0}),et={chmod:Nt.default.chmod,mkdir:Nt.default.mkdir,readdir:e=>Nt.default.readdir(e,{withFileTypes:!0}),rename:Nt.default.rename,rm:Nt.default.rm,rmdir:Nt.default.rmdir,stat:Nt.default.stat,lstat:Nt.default.lstat,unlink:Nt.default.unlink};var Ke=require("path");var{readdir:Fm}=et,Ue=e=>Fm(e).catch(t=>t),ze=e=>{try{return Ec(e)}catch(t){return t}};var Sc=e=>!!e&&typeof e=="object",Eo=(e,t)=>t in e&&typeof e[t]=="string",So=e=>Sc(e)&&Eo(e,"code")&&Eo(e,"path"),I=e=>Sc(e)&&Eo(e,"code")?e.code:null;var Z=async(e,t)=>e.catch(r=>{if(I(r)!=="ENOENT")throw t??r}),X=(e,t)=>{try{return e()}catch(r){if(I(r)==="ENOENT")return;throw t??r}};var{lstat:Tm,rmdir:Am,unlink:Pm}=et,Jn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(Tm(e).then(r=>Fc(e,t,r)))??!0),Vn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Tc(e,t,(0,k.lstatSync)(e)))??!0),Fc=async(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?await Ue(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Z(Pm(e)),!0)}return!(await Promise.all(n.map(o=>Fc((0,Ke.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,Ke.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Z(Am(e)),!0)},Tc=(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?ze(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!t.filter(e,r)?!1:(X(()=>(0,k.unlinkSync)(e)),!0)}let s=!0;for(let o of n){let i=(0,Ke.resolve)(e,o.name);s=Tc(i,t,o)&&s}return t.preserveRoot===!1&&e===(0,Ke.parse)(e).root||!s||t.filter&&!t.filter(e,r)?!1:(X(()=>(0,k.rmdirSync)(e)),!0)};var Je=require("path");var{chmod:Rm}=et,qr=e=>async t=>{try{return void await Z(e(t))}catch(r){if(I(r)==="EPERM")return await Z(Rm(t,438).then(()=>!0),r)?void await e(t):void 0;throw r}},Yr=e=>t=>{try{return void X(()=>e(t))}catch(r){if(I(r)==="EPERM")return X(()=>((0,k.chmodSync)(t,438),!0),r)?void e(t):void 0;throw r}};var Ac=require("timers/promises");var Im=200,Nm=1.2,Pc=10,Rc=new Set(["EMFILE","ENFILE","EBUSY"]),Fo=e=>{let t=async(r,n,s=1,o=0)=>{let i=n.maxBackoff||Im,a=n.backoff||Nm,c=n.maxRetries||Pc,u=0;for(;;)try{return await e(r)}catch(l){if(So(l)&&l.path===r&&Rc.has(l.code)){if(s=Math.ceil(s*a),o=s+o,o<i)return await(0,Ac.setTimeout)(s),t(r,n,s,o);if(u<c){u++;continue}}throw l}};return t},To=e=>(r,n)=>{let s=n.maxRetries||Pc,o=0;for(;;)try{return e(r)}catch(i){if(So(i)&&i.path===r&&Rc.has(i.code)&&o<s){o++;continue}throw i}};var mt=require("path");var Zr=require("os"),le=require("path");var{stat:Om}=et,Mm=e=>{try{return(0,k.statSync)(e).isDirectory()}catch{return!1}},$m=e=>Om(e).then(t=>t.isDirectory(),()=>!1),Bm=async e=>{let{root:t}=(0,le.parse)(e),r=(0,Zr.tmpdir)(),{root:n}=(0,le.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,le.resolve)(t,"/temp");return await $m(s)?s:t},jm=e=>{let{root:t}=(0,le.parse)(e),r=(0,Zr.tmpdir)(),{root:n}=(0,le.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,le.resolve)(t,"/temp");return Mm(s)?s:t},_m=async()=>(0,Zr.tmpdir)(),Lm=()=>(0,Zr.tmpdir)(),Ic=process.platform==="win32"?Bm:_m,Nc=process.platform==="win32"?jm:Lm;var{lstat:Wm,rename:Gm,unlink:Hm,rmdir:Um}=et,$c=e=>`.${(0,mt.basename)(e)}.${Math.random()}`,zm=qr(Hm),Km=Yr(k.unlinkSync),qn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(Wm(e).then(r=>Ao(e,t,r)))??!0),Ao=async(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Ao(e,{...t,tmp:await Ic(e)},r);if(e===t.tmp&&(0,mt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let n=r.isDirectory()?await Ue(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Z(Oc(e,t.tmp,zm)),!0)}return!(await Promise.all(n.map(o=>Ao((0,mt.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,mt.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Z(Oc(e,t.tmp,Um)),!0)},Oc=async(e,t,r)=>{let n=(0,mt.resolve)(t,$c(e));return await Gm(e,n),await r(n)},Yn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Po(e,t,(0,k.lstatSync)(e)))??!0),Po=(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Po(e,{...t,tmp:Nc(e)},r);let n=t.tmp;if(e===t.tmp&&(0,mt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let s=r.isDirectory()?ze(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(X(()=>Mc(e,n,Km)),!0)}let o=!0;for(let i of s){let a=(0,mt.resolve)(e,i.name);o=Po(a,t,i)&&o}return!o||t.preserveRoot===!1&&e===(0,mt.parse)(e).root||t.filter&&!t.filter(e,r)?!1:(X(()=>Mc(e,n,k.rmdirSync)),!0)},Mc=(e,t,r)=>{let n=(0,mt.resolve)(t,$c(e));return(0,k.renameSync)(e,n),r(n)};var{unlink:Jm,rmdir:Vm,lstat:qm}=et,Ym=Fo(qr(Jm)),Zm=To(Yr(k.unlinkSync)),Xm=Fo(qr(Vm)),Qm=To(Yr(k.rmdirSync)),tg=async(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return await Xm(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return qn(e,r);throw n}},eg=(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return Qm(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return Yn(e,r);throw n}},pe=Symbol("start"),Bc=Symbol("child"),Zn=Symbol("finish"),Xn=async(e,t)=>(t?.signal?.throwIfAborted(),await Z(qm(e).then(r=>Ro(e,t,r,pe)))??!0),Qn=(e,t)=>(t?.signal?.throwIfAborted(),X(()=>Io(e,t,(0,k.lstatSync)(e),pe))??!0),Ro=async(e,t,r,n=pe)=>{t?.signal?.throwIfAborted();let s=r.isDirectory()?await Ue(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!await t.filter(e,r)?!1:(await Z(Ym(e,t)),!0)}let o=n===pe?Bc:n,i=(await Promise.all(s.map(a=>Ro((0,Je.resolve)(e,a.name),t,a,o)))).every(a=>a===!0);if(n===pe)return Ro(e,t,r,Zn);if(n===Zn){if(t.preserveRoot===!1&&e===(0,Je.parse)(e).root||!i||t.filter&&!await t.filter(e,r))return!1;await Z(tg(e,t))}return!0},Io=(e,t,r,n=pe)=>{let s=r.isDirectory()?ze(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(X(()=>Zm(e,t)),!0)}let o=!0;for(let i of s){let a=n===pe?Bc:n,c=(0,Je.resolve)(e,i.name);o=Io(c,t,i,a)&&o}if(n===pe)return Io(e,t,r,Zn);if(n===Zn){if(t.preserveRoot===!1&&e===(0,Je.parse)(e).root||!o||t.filter&&!t.filter(e,r))return!1;X(()=>eg(e,t))}return!0};var No=process.platform==="win32"?Xn:Jn,Oo=process.platform==="win32"?Qn:Vn;var{rm:rg}=et,Mo=async(e,t)=>(await rg(e,{...t,force:!0,recursive:!0}),!0),$o=(e,t)=>((0,k.rmSync)(e,{...t,force:!0,recursive:!0}),!0);var[jc=0,ng=0]=process.version.replace(/^v/,"").split(".").map(e=>parseInt(e,10)),_c=jc>14||jc===14&&ng>=14,Lc=!_c||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter,Wc=!_c||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter;var Ve=e=>async(t,r)=>{let n=bc(r);return n.glob&&(t=await Hn(t,n.glob)),Array.isArray(t)?!!(await Promise.all(t.map(s=>e(Vr(s,n),n)))).reduce((s,o)=>s&&o,!0):!!await e(Vr(t,n),n)},qe=e=>(t,r)=>{let n=vc(r);return n.glob&&(t=zn(t,n.glob)),Array.isArray(t)?!!t.map(s=>e(Vr(s,n),n)).reduce((s,o)=>s&&o,!0):!!e(Vr(t,n),n)},Uc=qe($o),sg=Object.assign(Ve(Mo),{sync:Uc}),zc=qe(Oo),og=Object.assign(Ve(No),{sync:zc}),Kc=qe(Qn),ig=Object.assign(Ve(Xn),{sync:Kc}),Jc=qe(Vn),ag=Object.assign(Ve(Jn),{sync:Jc}),Vc=qe(Yn),cg=Object.assign(Ve(qn),{sync:Vc}),Gc=qe((e,t)=>Wc(t)?$o(e,t):Oo(e,t));var Hc=Ve((e,t)=>Lc(t)?Mo(e,t):No(e,t)),ts=Object.assign(Hc,{rimraf:Hc,sync:Gc,rimrafSync:Gc,manual:og,manualSync:zc,native:sg,nativeSync:Uc,posix:ag,posixSync:Jc,windows:ig,windowsSync:Kc,moveRemove:cg,moveRemoveSync:Vc});ts.rimraf=ts;var S=e=>(0,Ye.join)(process.cwd(),e),es=e=>{try{return(0,qc.readdirSync)(e).length===0}catch{return!0}};function Yc(){let e=Sa({cwd:(0,Ye.dirname)(__filename)});if(!e)throw new Error("Could not find package.json");return(0,Ye.dirname)(e)}var Zc=e=>ts(e);var Xc=b(require("chalk"));async function K(e,t){let r=Date.now(),n=e.title,s=()=>Math.floor((Date.now()-r)/1e3),o=setInterval(()=>{s()>1&&(e.title=`${n} (${s()}s)`)},1e3);try{return await t(s)}finally{clearInterval(o)}}async function rs(e,t,r){for(let n=0;n<t.length;n++){let s=t[n];e.output=Xc.default.dim(`[${n+1}/${t.length}] ${s.title}`),await s.fn(r??{},e)}}var Ze=e=>{let t=e??O(),r=(0,rt.join)(t,"package.json");if(!(0,bt.existsSync)(r))return null;try{return JSON.parse((0,bt.readFileSync)(r,"utf-8"))}catch{return null}},vt=e=>{let t={services:"services",apps:"apps",packages:"packages",contracts:"packages/contracts"},r=Ze(e);if(!r)return t;let n=r.pf?.paths;return{services:(typeof n?.services=="object"?n.services.path:n?.services)??t.services,apps:(typeof n?.apps=="object"?n.apps.path:n?.apps)??t.apps,packages:(typeof n?.packages=="object"?n.packages.path:n?.packages)??t.packages,contracts:(typeof n?.contracts=="object"?n.contracts.path:n?.contracts)??t.contracts}},G=e=>{let t=e??O(),r=vt(t);return{packagePath:(0,rt.join)(t,r.contracts),eventsPath:(0,rt.join)(t,r.contracts,"src","events"),indexPath:(0,rt.join)(t,r.contracts,"src","index.ts"),relativePath:r.contracts}},ug=e=>{let t=(0,rt.join)(e,"package.json");if(!(0,bt.existsSync)(t))return!1;try{let r=JSON.parse((0,bt.readFileSync)(t,"utf-8"));if(!r.workspaces)return!1;if(r.pf||(0,bt.existsSync)((0,rt.join)(e,"turbo.json")))return!0;let n=ga.some(o=>(0,bt.existsSync)((0,rt.join)(e,o))),s=(0,bt.existsSync)((0,rt.join)(e,"infra"));return!!(n&&s)}catch{return!1}};function O(){let e=process.cwd();for(;!ug(e);){let t=e.slice(0,e.lastIndexOf("/"));if(t===e)throw new Error(`
16
+ >>> no match, partial?`,t,d,r,f),d===c))}let h;if(typeof u=="string"?(h=p===u,this.debug("string match",u,p,h)):(h=u.test(p),this.debug("pattern match",u,p,h)),!h)return!1}if(i===c&&a===l)return!0;if(i===c)return n;if(a===l)return i===c-1&&t[i]==="";throw new Error("wtf?")}braceExpand(){return qa(this.pattern,this.options)}parse(t){Mr(t);let r=this.options;if(t==="**")return U;if(t==="")return"";let n,s=null;(n=t.match(Vh))?s=r.dot?Zh:Yh:(n=t.match(_h))?s=(r.nocase?r.dot?Hh:Gh:r.dot?Wh:Lh)(n[1]):(n=t.match(Xh))?s=(r.nocase?r.dot?tm:Qh:r.dot?em:rm)(n):(n=t.match(Uh))?s=r.dot?Kh:zh:(n=t.match(Jh))&&(s=qh);let o=$e.fromGlob(t,this.options).toMMPattern();return s&&typeof o=="object"&&Reflect.defineProperty(o,"test",{value:s}),o}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;let t=this.set;if(!t.length)return this.regexp=!1,this.regexp;let r=this.options,n=r.noglobstar?om:r.dot?im:am,s=new Set(r.nocase?["i"]:[]),o=t.map(c=>{let l=c.map(p=>{if(p instanceof RegExp)for(let d of p.flags.split(""))s.add(d);return typeof p=="string"?fm(p):p===U?U:p._src});l.forEach((p,d)=>{let f=l[d+1],m=l[d-1];p!==U||m===U||(m===void 0?f!==void 0&&f!==U?l[d+1]="(?:\\/|"+n+"\\/)?"+f:l[d]=n:f===void 0?l[d-1]=m+"(?:\\/|\\/"+n+")?":f!==U&&(l[d-1]=m+"(?:\\/|\\/"+n+"\\/)"+f,l[d+1]=U))});let u=l.filter(p=>p!==U);if(this.partial&&u.length>=1){let p=[];for(let d=1;d<=u.length;d++)p.push(u.slice(0,d).join("/"));return"(?:"+p.join("|")+")"}return u.join("/")}).join("|"),[i,a]=t.length>1?["(?:",")"]:["",""];o="^"+i+o+a+"$",this.partial&&(o="^(?:\\/|"+i+o.slice(1,-1)+a+")$"),this.negate&&(o="^(?!"+o+").+$");try{this.regexp=new RegExp(o,[...s].join(""))}catch{this.regexp=!1}return this.regexp}slashSplit(t){return this.preserveMultipleSlashes?t.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(t)?["",...t.split(/\/+/)]:t.split(/\/+/)}match(t,r=this.partial){if(this.debug("match",t,this.pattern),this.comment)return!1;if(this.empty)return t==="";if(t==="/"&&r)return!0;let n=this.options;this.isWindows&&(t=t.split("\\").join("/"));let s=this.slashSplit(t);this.debug(this.pattern,"split",s);let o=this.set;this.debug(this.pattern,"set",o);let i=s[s.length-1];if(!i)for(let a=s.length-2;!i&&a>=0;a--)i=s[a];for(let a=0;a<o.length;a++){let c=o[a],l=s;if(n.matchBase&&c.length===1&&(l=[i]),this.matchOne(l,c,r))return n.flipNegate?!0:!this.negate}return n.flipNegate?!1:this.negate}static defaults(t){return Z.defaults(t).Minimatch}};Z.AST=$e;Z.Minimatch=at;Z.escape=Be;Z.unescape=wt;var yc=require("node:url");var dm=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Ya=new Set,po=typeof process=="object"&&process?process:{},Za=(e,t,r,n)=>{typeof po.emitWarning=="function"?po.emitWarning(e,t,r,n):console.error(`[${r}] ${t}: ${e}`)},Pn=globalThis.AbortController,Va=globalThis.AbortSignal;if(typeof Pn>"u"){Va=class{onabort;_onabort=[];reason;aborted=!1;addEventListener(n,s){this._onabort.push(s)}},Pn=class{constructor(){t()}signal=new Va;abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=!0;for(let s of this.signal._onabort)s(n);this.signal.onabort?.(n)}}};let e=po.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{e&&(e=!1,Za("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t))}}var hm=e=>!Ya.has(e),fx=Symbol("type"),ie=e=>e&&e===Math.floor(e)&&e>0&&isFinite(e),Xa=e=>ie(e)?e<=Math.pow(2,8)?Uint8Array:e<=Math.pow(2,16)?Uint16Array:e<=Math.pow(2,32)?Uint32Array:e<=Number.MAX_SAFE_INTEGER?je:null:null,je=class extends Array{constructor(t){super(t),this.fill(0)}},fo=class e{heap;length;static#t=!1;static create(t){let r=Xa(t);if(!r)return[];e.#t=!0;let n=new e(t,r);return e.#t=!1,n}constructor(t,r){if(!e.#t)throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new r(t),this.length=0}push(t){this.heap[this.length++]=t}pop(){return this.heap[--this.length]}},Ce=class e{#t;#r;#o;#s;#i;#C;#D;#u;get perf(){return this.#u}ttl;ttlResolution;ttlAutopurge;updateAgeOnGet;updateAgeOnHas;allowStale;noDisposeOnSet;noUpdateTTL;maxEntrySize;sizeCalculation;noDeleteOnFetchRejection;noDeleteOnStaleGet;allowStaleOnFetchAbort;allowStaleOnFetchRejection;ignoreFetchAbort;#a;#f;#p;#c;#n;#d;#b;#w;#h;#T;#m;#k;#E;#g;#y;#x;#S;#e;#O;static unsafeExposeInternals(t){return{starts:t.#E,ttls:t.#g,autopurgeTimers:t.#y,sizes:t.#k,keyMap:t.#p,keyList:t.#c,valList:t.#n,next:t.#d,prev:t.#b,get head(){return t.#w},get tail(){return t.#h},free:t.#T,isBackgroundFetch:r=>t.#l(r),backgroundFetch:(r,n,s,o)=>t.#G(r,n,s,o),moveToTail:r=>t.#$(r),indexes:r=>t.#P(r),rindexes:r=>t.#R(r),isStale:r=>t.#v(r)}}get max(){return this.#t}get maxSize(){return this.#r}get calculatedSize(){return this.#f}get size(){return this.#a}get fetchMethod(){return this.#C}get memoMethod(){return this.#D}get dispose(){return this.#o}get onInsert(){return this.#s}get disposeAfter(){return this.#i}constructor(t){let{max:r=0,ttl:n,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:i,updateAgeOnHas:a,allowStale:c,dispose:l,onInsert:u,disposeAfter:p,noDisposeOnSet:d,noUpdateTTL:f,maxSize:m=0,maxEntrySize:h=0,sizeCalculation:D,fetchMethod:g,memoMethod:y,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:dt,ignoreFetchAbort:ne,perf:Ae}=t;if(Ae!==void 0&&typeof Ae?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(this.#u=Ae??dm,r!==0&&!ie(r))throw new TypeError("max option must be a nonnegative integer");let Pe=r?Xa(r):Array;if(!Pe)throw new Error("invalid max value: "+r);if(this.#t=r,this.#r=m,this.maxEntrySize=h||this.#r,this.sizeCalculation=D,this.sizeCalculation){if(!this.#r&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(y!==void 0&&typeof y!="function")throw new TypeError("memoMethod must be a function if defined");if(this.#D=y,g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(this.#C=g,this.#S=!!g,this.#p=new Map,this.#c=new Array(r).fill(void 0),this.#n=new Array(r).fill(void 0),this.#d=new Pe(r),this.#b=new Pe(r),this.#w=0,this.#h=0,this.#T=fo.create(r),this.#a=0,this.#f=0,typeof l=="function"&&(this.#o=l),typeof u=="function"&&(this.#s=u),typeof p=="function"?(this.#i=p,this.#m=[]):(this.#i=void 0,this.#m=void 0),this.#x=!!this.#o,this.#O=!!this.#s,this.#e=!!this.#i,this.noDisposeOnSet=!!d,this.noUpdateTTL=!!f,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!dt,this.ignoreFetchAbort=!!ne,this.maxEntrySize!==0){if(this.#r!==0&&!ie(this.#r))throw new TypeError("maxSize must be a positive integer if specified");if(!ie(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");this.#U()}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!i,this.updateAgeOnHas=!!a,this.ttlResolution=ie(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=n||0,this.ttl){if(!ie(this.ttl))throw new TypeError("ttl must be a positive integer if specified");this.#I()}if(this.#t===0&&this.ttl===0&&this.#r===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!this.#t&&!this.#r){let Re="LRU_CACHE_UNBOUNDED";hm(Re)&&(Ya.add(Re),Za("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Re,e))}}getRemainingTTL(t){return this.#p.has(t)?1/0:0}#I(){let t=new je(this.#t),r=new je(this.#t);this.#g=t,this.#E=r;let n=this.ttlAutopurge?new Array(this.#t):void 0;this.#y=n,this.#j=(i,a,c=this.#u.now())=>{if(r[i]=a!==0?c:0,t[i]=a,n?.[i]&&(clearTimeout(n[i]),n[i]=void 0),a!==0&&n){let l=setTimeout(()=>{this.#v(i)&&this.#A(this.#c[i],"expire")},a+1);l.unref&&l.unref(),n[i]=l}},this.#F=i=>{r[i]=t[i]!==0?this.#u.now():0},this.#N=(i,a)=>{if(t[a]){let c=t[a],l=r[a];if(!c||!l)return;i.ttl=c,i.start=l,i.now=s||o();let u=i.now-l;i.remainingTTL=c-u}};let s=0,o=()=>{let i=this.#u.now();if(this.ttlResolution>0){s=i;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref()}return i};this.getRemainingTTL=i=>{let a=this.#p.get(i);if(a===void 0)return 0;let c=t[a],l=r[a];if(!c||!l)return 1/0;let u=(s||o())-l;return c-u},this.#v=i=>{let a=r[i],c=t[i];return!!c&&!!a&&(s||o())-a>c}}#F=()=>{};#N=()=>{};#j=()=>{};#v=()=>!1;#U(){let t=new je(this.#t);this.#f=0,this.#k=t,this.#B=r=>{this.#f-=t[r],t[r]=0},this.#_=(r,n,s,o)=>{if(this.#l(n))return 0;if(!ie(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(n,r),!ie(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s},this.#M=(r,n,s)=>{if(t[r]=n,this.#r){let o=this.#r-t[r];for(;this.#f>o;)this.#W(!0)}this.#f+=t[r],s&&(s.entrySize=n,s.totalCalculatedSize=this.#f)}}#B=t=>{};#M=(t,r,n)=>{};#_=(t,r,n,s)=>{if(n||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0};*#P({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#h;!(!this.#L(r)||((t||!this.#v(r))&&(yield r),r===this.#w));)r=this.#b[r]}*#R({allowStale:t=this.allowStale}={}){if(this.#a)for(let r=this.#w;!(!this.#L(r)||((t||!this.#v(r))&&(yield r),r===this.#h));)r=this.#d[r]}#L(t){return t!==void 0&&this.#p.get(this.#c[t])===t}*entries(){for(let t of this.#P())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*rentries(){for(let t of this.#R())this.#n[t]!==void 0&&this.#c[t]!==void 0&&!this.#l(this.#n[t])&&(yield[this.#c[t],this.#n[t]])}*keys(){for(let t of this.#P()){let r=this.#c[t];r!==void 0&&!this.#l(this.#n[t])&&(yield r)}}*rkeys(){for(let t of this.#R()){let r=this.#c[t];r!==void 0&&!this.#l(this.#n[t])&&(yield r)}}*values(){for(let t of this.#P())this.#n[t]!==void 0&&!this.#l(this.#n[t])&&(yield this.#n[t])}*rvalues(){for(let t of this.#R())this.#n[t]!==void 0&&!this.#l(this.#n[t])&&(yield this.#n[t])}[Symbol.iterator](){return this.entries()}[Symbol.toStringTag]="LRUCache";find(t,r={}){for(let n of this.#P()){let s=this.#n[n],o=this.#l(s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,this.#c[n],this))return this.get(this.#c[n],r)}}forEach(t,r=this){for(let n of this.#P()){let s=this.#n[n],o=this.#l(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}rforEach(t,r=this){for(let n of this.#R()){let s=this.#n[n],o=this.#l(s)?s.__staleWhileFetching:s;o!==void 0&&t.call(r,o,this.#c[n],this)}}purgeStale(){let t=!1;for(let r of this.#R({allowStale:!0}))this.#v(r)&&(this.#A(this.#c[r],"expire"),t=!0);return t}info(t){let r=this.#p.get(t);if(r===void 0)return;let n=this.#n[r],s=this.#l(n)?n.__staleWhileFetching:n;if(s===void 0)return;let o={value:s};if(this.#g&&this.#E){let i=this.#g[r],a=this.#E[r];if(i&&a){let c=i-(this.#u.now()-a);o.ttl=c,o.start=Date.now()}}return this.#k&&(o.size=this.#k[r]),o}dump(){let t=[];for(let r of this.#P({allowStale:!0})){let n=this.#c[r],s=this.#n[r],o=this.#l(s)?s.__staleWhileFetching:s;if(o===void 0||n===void 0)continue;let i={value:o};if(this.#g&&this.#E){i.ttl=this.#g[r];let a=this.#u.now()-this.#E[r];i.start=Math.floor(Date.now()-a)}this.#k&&(i.size=this.#k[r]),t.unshift([n,i])}return t}load(t){this.clear();for(let[r,n]of t){if(n.start){let s=Date.now()-n.start;n.start=this.#u.now()-s}this.set(r,n.value,n)}}set(t,r,n={}){if(r===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:i=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:c}=n,{noUpdateTTL:l=this.noUpdateTTL}=n,u=this.#_(t,r,n.size||0,a);if(this.maxEntrySize&&u>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=!0),this.#A(t,"set"),this;let p=this.#a===0?void 0:this.#p.get(t);if(p===void 0)p=this.#a===0?this.#h:this.#T.length!==0?this.#T.pop():this.#a===this.#t?this.#W(!1):this.#a,this.#c[p]=t,this.#n[p]=r,this.#p.set(t,p),this.#d[this.#h]=p,this.#b[p]=this.#h,this.#h=p,this.#a++,this.#M(p,u,c),c&&(c.set="add"),l=!1,this.#O&&this.#s?.(r,t,"add");else{this.#$(p);let d=this.#n[p];if(r!==d){if(this.#S&&this.#l(d)){d.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:f}=d;f!==void 0&&!i&&(this.#x&&this.#o?.(f,t,"set"),this.#e&&this.#m?.push([f,t,"set"]))}else i||(this.#x&&this.#o?.(d,t,"set"),this.#e&&this.#m?.push([d,t,"set"]));if(this.#B(p),this.#M(p,u,c),this.#n[p]=r,c){c.set="replace";let f=d&&this.#l(d)?d.__staleWhileFetching:d;f!==void 0&&(c.oldValue=f)}}else c&&(c.set="update");this.#O&&this.onInsert?.(r,t,r===d?"update":"replace")}if(s!==0&&!this.#g&&this.#I(),this.#g&&(l||this.#j(p,s,o),c&&this.#N(c,p)),!i&&this.#e&&this.#m){let d=this.#m,f;for(;f=d?.shift();)this.#i?.(...f)}return this}pop(){try{for(;this.#a;){let t=this.#n[this.#w];if(this.#W(!0),this.#l(t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(this.#e&&this.#m){let t=this.#m,r;for(;r=t?.shift();)this.#i?.(...r)}}}#W(t){let r=this.#w,n=this.#c[r],s=this.#n[r];return this.#S&&this.#l(s)?s.__abortController.abort(new Error("evicted")):(this.#x||this.#e)&&(this.#x&&this.#o?.(s,n,"evict"),this.#e&&this.#m?.push([s,n,"evict"])),this.#B(r),this.#y?.[r]&&(clearTimeout(this.#y[r]),this.#y[r]=void 0),t&&(this.#c[r]=void 0,this.#n[r]=void 0,this.#T.push(r)),this.#a===1?(this.#w=this.#h=0,this.#T.length=0):this.#w=this.#d[r],this.#p.delete(n),this.#a--,r}has(t,r={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:s}=r,o=this.#p.get(t);if(o!==void 0){let i=this.#n[o];if(this.#l(i)&&i.__staleWhileFetching===void 0)return!1;if(this.#v(o))s&&(s.has="stale",this.#N(s,o));else return n&&this.#F(o),s&&(s.has="hit",this.#N(s,o)),!0}else s&&(s.has="miss");return!1}peek(t,r={}){let{allowStale:n=this.allowStale}=r,s=this.#p.get(t);if(s===void 0||!n&&this.#v(s))return;let o=this.#n[s];return this.#l(o)?o.__staleWhileFetching:o}#G(t,r,n,s){let o=r===void 0?void 0:this.#n[r];if(this.#l(o))return o;let i=new Pn,{signal:a}=n;a?.addEventListener("abort",()=>i.abort(a.reason),{signal:i.signal});let c={signal:i.signal,options:n,context:s},l=(h,D=!1)=>{let{aborted:g}=i.signal,y=n.ignoreFetchAbort&&h!==void 0;if(n.status&&(g&&!D?(n.status.fetchAborted=!0,n.status.fetchError=i.signal.reason,y&&(n.status.fetchAbortIgnored=!0)):n.status.fetchResolved=!0),g&&!y&&!D)return p(i.signal.reason);let x=f,C=this.#n[r];return(C===f||y&&D&&C===void 0)&&(h===void 0?x.__staleWhileFetching!==void 0?this.#n[r]=x.__staleWhileFetching:this.#A(t,"fetch"):(n.status&&(n.status.fetchUpdated=!0),this.set(t,h,c.options))),h},u=h=>(n.status&&(n.status.fetchRejected=!0,n.status.fetchError=h),p(h)),p=h=>{let{aborted:D}=i.signal,g=D&&n.allowStaleOnFetchAbort,y=g||n.allowStaleOnFetchRejection,x=y||n.noDeleteOnFetchRejection,C=f;if(this.#n[r]===f&&(!x||C.__staleWhileFetching===void 0?this.#A(t,"fetch"):g||(this.#n[r]=C.__staleWhileFetching)),y)return n.status&&C.__staleWhileFetching!==void 0&&(n.status.returnedStale=!0),C.__staleWhileFetching;if(C.__returned===C)throw h},d=(h,D)=>{let g=this.#C?.(t,o,c);g&&g instanceof Promise&&g.then(y=>h(y===void 0?void 0:y),D),i.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(h(void 0),n.allowStaleOnFetchAbort&&(h=y=>l(y,!0)))})};n.status&&(n.status.fetchDispatched=!0);let f=new Promise(d).then(l,u),m=Object.assign(f,{__abortController:i,__staleWhileFetching:o,__returned:void 0});return r===void 0?(this.set(t,m,{...c.options,status:void 0}),r=this.#p.get(t)):this.#n[r]=m,m}#l(t){if(!this.#S)return!1;let r=t;return!!r&&r instanceof Promise&&r.hasOwnProperty("__staleWhileFetching")&&r.__abortController instanceof Pn}async fetch(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:i=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:c=0,sizeCalculation:l=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:p=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:d=this.allowStaleOnFetchRejection,ignoreFetchAbort:f=this.ignoreFetchAbort,allowStaleOnFetchAbort:m=this.allowStaleOnFetchAbort,context:h,forceRefresh:D=!1,status:g,signal:y}=r;if(!this.#S)return g&&(g.fetch="get"),this.get(t,{allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:g});let x={allowStale:n,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:i,noDisposeOnSet:a,size:c,sizeCalculation:l,noUpdateTTL:u,noDeleteOnFetchRejection:p,allowStaleOnFetchRejection:d,allowStaleOnFetchAbort:m,ignoreFetchAbort:f,status:g,signal:y},C=this.#p.get(t);if(C===void 0){g&&(g.fetch="miss");let A=this.#G(t,C,x,h);return A.__returned=A}else{let A=this.#n[C];if(this.#l(A)){let Re=n&&A.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",Re&&(g.returnedStale=!0)),Re?A.__staleWhileFetching:A.__returned=A}let dt=this.#v(C);if(!D&&!dt)return g&&(g.fetch="hit"),this.#$(C),s&&this.#F(C),g&&this.#N(g,C),A;let ne=this.#G(t,C,x,h),Pe=ne.__staleWhileFetching!==void 0&&n;return g&&(g.fetch=dt?"stale":"refresh",Pe&&dt&&(g.returnedStale=!0)),Pe?ne.__staleWhileFetching:ne.__returned=ne}}async forceFetch(t,r={}){let n=await this.fetch(t,r);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(t,r={}){let n=this.#D;if(!n)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...i}=r,a=this.get(t,i);if(!o&&a!==void 0)return a;let c=n(t,a,{options:i,context:s});return this.set(t,c,i),c}get(t,r={}){let{allowStale:n=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:i}=r,a=this.#p.get(t);if(a!==void 0){let c=this.#n[a],l=this.#l(c);return i&&this.#N(i,a),this.#v(a)?(i&&(i.get="stale"),l?(i&&n&&c.__staleWhileFetching!==void 0&&(i.returnedStale=!0),n?c.__staleWhileFetching:void 0):(o||this.#A(t,"expire"),i&&n&&(i.returnedStale=!0),n?c:void 0)):(i&&(i.get="hit"),l?c.__staleWhileFetching:(this.#$(a),s&&this.#F(a),c))}else i&&(i.get="miss")}#H(t,r){this.#b[r]=t,this.#d[t]=r}#$(t){t!==this.#h&&(t===this.#w?this.#w=this.#d[t]:this.#H(this.#b[t],this.#d[t]),this.#H(this.#h,t),this.#h=t)}delete(t){return this.#A(t,"delete")}#A(t,r){let n=!1;if(this.#a!==0){let s=this.#p.get(t);if(s!==void 0)if(this.#y?.[s]&&(clearTimeout(this.#y?.[s]),this.#y[s]=void 0),n=!0,this.#a===1)this.#z(r);else{this.#B(s);let o=this.#n[s];if(this.#l(o)?o.__abortController.abort(new Error("deleted")):(this.#x||this.#e)&&(this.#x&&this.#o?.(o,t,r),this.#e&&this.#m?.push([o,t,r])),this.#p.delete(t),this.#c[s]=void 0,this.#n[s]=void 0,s===this.#h)this.#h=this.#b[s];else if(s===this.#w)this.#w=this.#d[s];else{let i=this.#b[s];this.#d[i]=this.#d[s];let a=this.#d[s];this.#b[a]=this.#b[s]}this.#a--,this.#T.push(s)}}if(this.#e&&this.#m?.length){let s=this.#m,o;for(;o=s?.shift();)this.#i?.(...o)}return n}clear(){return this.#z("delete")}#z(t){for(let r of this.#R({allowStale:!0})){let n=this.#n[r];if(this.#l(n))n.__abortController.abort(new Error("deleted"));else{let s=this.#c[r];this.#x&&this.#o?.(n,s,t),this.#e&&this.#m?.push([n,s,t])}}if(this.#p.clear(),this.#n.fill(void 0),this.#c.fill(void 0),this.#g&&this.#E){this.#g.fill(0),this.#E.fill(0);for(let r of this.#y??[])r!==void 0&&clearTimeout(r);this.#y?.fill(void 0)}if(this.#k&&this.#k.fill(0),this.#w=0,this.#h=0,this.#T.length=0,this.#f=0,this.#a=0,this.#e&&this.#m){let r=this.#m,n;for(;n=r?.shift();)this.#i?.(...n)}}};var We=require("node:path"),cc=require("node:url"),It=require("fs"),km=b(require("node:fs"),1),le=require("node:fs/promises");var Bn=require("node:events"),Co=b(require("node:stream"),1),nc=require("node:string_decoder"),Qa=typeof process=="object"&&process?process:{stdout:null,stderr:null},mm=e=>!!e&&typeof e=="object"&&(e instanceof ce||e instanceof Co.default||gm(e)||Dm(e)),gm=e=>!!e&&typeof e=="object"&&e instanceof Bn.EventEmitter&&typeof e.pipe=="function"&&e.pipe!==Co.default.Writable.prototype.pipe,Dm=e=>!!e&&typeof e=="object"&&e instanceof Bn.EventEmitter&&typeof e.write=="function"&&typeof e.end=="function",Kt=Symbol("EOF"),Jt=Symbol("maybeEmitEnd"),ae=Symbol("emittedEnd"),Rn=Symbol("emittingEnd"),Br=Symbol("emittedError"),In=Symbol("closed"),tc=Symbol("read"),Nn=Symbol("flush"),ec=Symbol("flushChunk"),Ct=Symbol("encoding"),_e=Symbol("decoder"),W=Symbol("flowing"),jr=Symbol("paused"),Le=Symbol("resume"),G=Symbol("buffer"),X=Symbol("pipes"),H=Symbol("bufferLength"),ho=Symbol("bufferPush"),On=Symbol("bufferShift"),K=Symbol("objectMode"),M=Symbol("destroyed"),mo=Symbol("error"),go=Symbol("emitData"),rc=Symbol("emitEnd"),Do=Symbol("emitEnd2"),Pt=Symbol("async"),yo=Symbol("abort"),Mn=Symbol("aborted"),_r=Symbol("signal"),be=Symbol("dataListeners"),ct=Symbol("discarded"),Lr=e=>Promise.resolve().then(e),ym=e=>e(),wm=e=>e==="end"||e==="finish"||e==="prefinish",Cm=e=>e instanceof ArrayBuffer||!!e&&typeof e=="object"&&e.constructor&&e.constructor.name==="ArrayBuffer"&&e.byteLength>=0,bm=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e),$n=class{src;dest;opts;ondrain;constructor(t,r,n){this.src=t,this.dest=r,this.opts=n,this.ondrain=()=>t[Le](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(t){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},wo=class extends $n{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(t,r,n){super(t,r,n),this.proxyErrors=s=>r.emit("error",s),t.on("error",this.proxyErrors)}},xm=e=>!!e.objectMode,vm=e=>!e.objectMode&&!!e.encoding&&e.encoding!=="buffer",ce=class extends Bn.EventEmitter{[W]=!1;[jr]=!1;[X]=[];[G]=[];[K];[Ct];[Pt];[_e];[Kt]=!1;[ae]=!1;[Rn]=!1;[In]=!1;[Br]=null;[H]=0;[M]=!1;[_r];[Mn]=!1;[be]=0;[ct]=!1;writable=!0;readable=!0;constructor(...t){let r=t[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");xm(r)?(this[K]=!0,this[Ct]=null):vm(r)?(this[Ct]=r.encoding,this[K]=!1):(this[K]=!1,this[Ct]=null),this[Pt]=!!r.async,this[_e]=this[Ct]?new nc.StringDecoder(this[Ct]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[G]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[X]});let{signal:n}=r;n&&(this[_r]=n,n.aborted?this[yo]():n.addEventListener("abort",()=>this[yo]()))}get bufferLength(){return this[H]}get encoding(){return this[Ct]}set encoding(t){throw new Error("Encoding must be set at instantiation time")}setEncoding(t){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[K]}set objectMode(t){throw new Error("objectMode must be set at instantiation time")}get async(){return this[Pt]}set async(t){this[Pt]=this[Pt]||!!t}[yo](){this[Mn]=!0,this.emit("abort",this[_r]?.reason),this.destroy(this[_r]?.reason)}get aborted(){return this[Mn]}set aborted(t){}write(t,r,n){if(this[Mn])return!1;if(this[Kt])throw new Error("write after end");if(this[M])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let s=this[Pt]?Lr:ym;if(!this[K]&&!Buffer.isBuffer(t)){if(bm(t))t=Buffer.from(t.buffer,t.byteOffset,t.byteLength);else if(Cm(t))t=Buffer.from(t);else if(typeof t!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[K]?(this[W]&&this[H]!==0&&this[Nn](!0),this[W]?this.emit("data",t):this[ho](t),this[H]!==0&&this.emit("readable"),n&&s(n),this[W]):t.length?(typeof t=="string"&&!(r===this[Ct]&&!this[_e]?.lastNeed)&&(t=Buffer.from(t,r)),Buffer.isBuffer(t)&&this[Ct]&&(t=this[_e].write(t)),this[W]&&this[H]!==0&&this[Nn](!0),this[W]?this.emit("data",t):this[ho](t),this[H]!==0&&this.emit("readable"),n&&s(n),this[W]):(this[H]!==0&&this.emit("readable"),n&&s(n),this[W])}read(t){if(this[M])return null;if(this[ct]=!1,this[H]===0||t===0||t&&t>this[H])return this[Jt](),null;this[K]&&(t=null),this[G].length>1&&!this[K]&&(this[G]=[this[Ct]?this[G].join(""):Buffer.concat(this[G],this[H])]);let r=this[tc](t||null,this[G][0]);return this[Jt](),r}[tc](t,r){if(this[K])this[On]();else{let n=r;t===n.length||t===null?this[On]():typeof n=="string"?(this[G][0]=n.slice(t),r=n.slice(0,t),this[H]-=t):(this[G][0]=n.subarray(t),r=n.subarray(0,t),this[H]-=t)}return this.emit("data",r),!this[G].length&&!this[Kt]&&this.emit("drain"),r}end(t,r,n){return typeof t=="function"&&(n=t,t=void 0),typeof r=="function"&&(n=r,r="utf8"),t!==void 0&&this.write(t,r),n&&this.once("end",n),this[Kt]=!0,this.writable=!1,(this[W]||!this[jr])&&this[Jt](),this}[Le](){this[M]||(!this[be]&&!this[X].length&&(this[ct]=!0),this[jr]=!1,this[W]=!0,this.emit("resume"),this[G].length?this[Nn]():this[Kt]?this[Jt]():this.emit("drain"))}resume(){return this[Le]()}pause(){this[W]=!1,this[jr]=!0,this[ct]=!1}get destroyed(){return this[M]}get flowing(){return this[W]}get paused(){return this[jr]}[ho](t){this[K]?this[H]+=1:this[H]+=t.length,this[G].push(t)}[On](){return this[K]?this[H]-=1:this[H]-=this[G][0].length,this[G].shift()}[Nn](t=!1){do;while(this[ec](this[On]())&&this[G].length);!t&&!this[G].length&&!this[Kt]&&this.emit("drain")}[ec](t){return this.emit("data",t),this[W]}pipe(t,r){if(this[M])return t;this[ct]=!1;let n=this[ae];return r=r||{},t===Qa.stdout||t===Qa.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&t.end():(this[X].push(r.proxyErrors?new wo(this,t,r):new $n(this,t,r)),this[Pt]?Lr(()=>this[Le]()):this[Le]()),t}unpipe(t){let r=this[X].find(n=>n.dest===t);r&&(this[X].length===1?(this[W]&&this[be]===0&&(this[W]=!1),this[X]=[]):this[X].splice(this[X].indexOf(r),1),r.unpipe())}addListener(t,r){return this.on(t,r)}on(t,r){let n=super.on(t,r);if(t==="data")this[ct]=!1,this[be]++,!this[X].length&&!this[W]&&this[Le]();else if(t==="readable"&&this[H]!==0)super.emit("readable");else if(wm(t)&&this[ae])super.emit(t),this.removeAllListeners(t);else if(t==="error"&&this[Br]){let s=r;this[Pt]?Lr(()=>s.call(this,this[Br])):s.call(this,this[Br])}return n}removeListener(t,r){return this.off(t,r)}off(t,r){let n=super.off(t,r);return t==="data"&&(this[be]=this.listeners("data").length,this[be]===0&&!this[ct]&&!this[X].length&&(this[W]=!1)),n}removeAllListeners(t){let r=super.removeAllListeners(t);return(t==="data"||t===void 0)&&(this[be]=0,!this[ct]&&!this[X].length&&(this[W]=!1)),r}get emittedEnd(){return this[ae]}[Jt](){!this[Rn]&&!this[ae]&&!this[M]&&this[G].length===0&&this[Kt]&&(this[Rn]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[In]&&this.emit("close"),this[Rn]=!1)}emit(t,...r){let n=r[0];if(t!=="error"&&t!=="close"&&t!==M&&this[M])return!1;if(t==="data")return!this[K]&&!n?!1:this[Pt]?(Lr(()=>this[go](n)),!0):this[go](n);if(t==="end")return this[rc]();if(t==="close"){if(this[In]=!0,!this[ae]&&!this[M])return!1;let o=super.emit("close");return this.removeAllListeners("close"),o}else if(t==="error"){this[Br]=n,super.emit(mo,n);let o=!this[_r]||this.listeners("error").length?super.emit("error",n):!1;return this[Jt](),o}else if(t==="resume"){let o=super.emit("resume");return this[Jt](),o}else if(t==="finish"||t==="prefinish"){let o=super.emit(t);return this.removeAllListeners(t),o}let s=super.emit(t,...r);return this[Jt](),s}[go](t){for(let n of this[X])n.dest.write(t)===!1&&this.pause();let r=this[ct]?!1:super.emit("data",t);return this[Jt](),r}[rc](){return this[ae]?!1:(this[ae]=!0,this.readable=!1,this[Pt]?(Lr(()=>this[Do]()),!0):this[Do]())}[Do](){if(this[_e]){let r=this[_e].end();if(r){for(let n of this[X])n.dest.write(r);this[ct]||super.emit("data",r)}}for(let r of this[X])r.end();let t=super.emit("end");return this.removeAllListeners("end"),t}async collect(){let t=Object.assign([],{dataLength:0});this[K]||(t.dataLength=0);let r=this.promise();return this.on("data",n=>{t.push(n),this[K]||(t.dataLength+=n.length)}),await r,t}async concat(){if(this[K])throw new Error("cannot concat in objectMode");let t=await this.collect();return this[Ct]?t.join(""):Buffer.concat(t,t.dataLength)}async promise(){return new Promise((t,r)=>{this.on(M,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>t())})}[Symbol.asyncIterator](){this[ct]=!1;let t=!1,r=async()=>(this.pause(),t=!0,{value:void 0,done:!0});return{next:()=>{if(t)return r();let s=this.read();if(s!==null)return Promise.resolve({done:!1,value:s});if(this[Kt])return r();let o,i,a=p=>{this.off("data",c),this.off("end",l),this.off(M,u),r(),i(p)},c=p=>{this.off("error",a),this.off("end",l),this.off(M,u),this.pause(),o({value:p,done:!!this[Kt]})},l=()=>{this.off("error",a),this.off("data",c),this.off(M,u),r(),o({done:!0,value:void 0})},u=()=>a(new Error("stream destroyed"));return new Promise((p,d)=>{i=d,o=p,this.once(M,u),this.once("error",a),this.once("end",l),this.once("data",c)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[ct]=!1;let t=!1,r=()=>(this.pause(),this.off(mo,r),this.off(M,r),this.off("end",r),t=!0,{done:!0,value:void 0}),n=()=>{if(t)return r();let s=this.read();return s===null?r():{done:!1,value:s}};return this.once("end",r),this.once(mo,r),this.once(M,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(t){if(this[M])return t?this.emit("error",t):this.emit(M),this;this[M]=!0,this[ct]=!0,this[G].length=0,this[H]=0;let r=this;return typeof r.close=="function"&&!this[In]&&r.close(),t?this.emit("error",t):this.emit(M),this}static get isStream(){return mm}};var Em=It.realpathSync.native,Gr={lstatSync:It.lstatSync,readdir:It.readdir,readdirSync:It.readdirSync,readlinkSync:It.readlinkSync,realpathSync:Em,promises:{lstat:le.lstat,readdir:le.readdir,readlink:le.readlink,realpath:le.realpath}},lc=e=>!e||e===Gr||e===km?Gr:{...Gr,...e,promises:{...Gr.promises,...e.promises||{}}},uc=/^\\\\\?\\([a-z]:)\\?$/i,Sm=e=>e.replace(/\//g,"\\").replace(uc,"$1\\"),Fm=/[\\\/]/,Dt=0,pc=1,fc=2,Rt=4,dc=6,hc=8,xe=10,mc=12,gt=15,Wr=~gt,bo=16,sc=32,Hr=64,bt=128,jn=256,Ln=512,oc=Hr|bt|Ln,Tm=1023,xo=e=>e.isFile()?hc:e.isDirectory()?Rt:e.isSymbolicLink()?xe:e.isCharacterDevice()?fc:e.isBlockDevice()?dc:e.isSocket()?mc:e.isFIFO()?pc:Dt,ic=new Ce({max:2**12}),Ur=e=>{let t=ic.get(e);if(t)return t;let r=e.normalize("NFKD");return ic.set(e,r),r},ac=new Ce({max:2**12}),_n=e=>{let t=ac.get(e);if(t)return t;let r=Ur(e.toLowerCase());return ac.set(e,r),r},Wn=class extends Ce{constructor(){super({max:256})}},vo=class extends Ce{constructor(t=16*1024){super({maxSize:t,sizeCalculation:r=>r.length+1})}},gc=Symbol("PathScurry setAsCwd"),J=class{name;root;roots;parent;nocase;isCWD=!1;#t;#r;get dev(){return this.#r}#o;get mode(){return this.#o}#s;get nlink(){return this.#s}#i;get uid(){return this.#i}#C;get gid(){return this.#C}#D;get rdev(){return this.#D}#u;get blksize(){return this.#u}#a;get ino(){return this.#a}#f;get size(){return this.#f}#p;get blocks(){return this.#p}#c;get atimeMs(){return this.#c}#n;get mtimeMs(){return this.#n}#d;get ctimeMs(){return this.#d}#b;get birthtimeMs(){return this.#b}#w;get atime(){return this.#w}#h;get mtime(){return this.#h}#T;get ctime(){return this.#T}#m;get birthtime(){return this.#m}#k;#E;#g;#y;#x;#S;#e;#O;#I;#F;get parentPath(){return(this.parent||this).fullpath()}get path(){return this.parentPath}constructor(t,r=Dt,n,s,o,i,a){this.name=t,this.#k=o?_n(t):Ur(t),this.#e=r&Tm,this.nocase=o,this.roots=s,this.root=n||this,this.#O=i,this.#g=a.fullpath,this.#x=a.relative,this.#S=a.relativePosix,this.parent=a.parent,this.parent?this.#t=this.parent.#t:this.#t=lc(a.fs)}depth(){return this.#E!==void 0?this.#E:this.parent?this.#E=this.parent.depth()+1:this.#E=0}childrenCache(){return this.#O}resolve(t){if(!t)return this;let r=this.getRootString(t),s=t.substring(r.length).split(this.splitSep);return r?this.getRoot(r).#N(s):this.#N(s)}#N(t){let r=this;for(let n of t)r=r.child(n);return r}children(){let t=this.#O.get(this);if(t)return t;let r=Object.assign([],{provisional:0});return this.#O.set(this,r),this.#e&=~bo,r}child(t,r){if(t===""||t===".")return this;if(t==="..")return this.parent||this;let n=this.children(),s=this.nocase?_n(t):Ur(t);for(let c of n)if(c.#k===s)return c;let o=this.parent?this.sep:"",i=this.#g?this.#g+o+t:void 0,a=this.newChild(t,Dt,{...r,parent:this,fullpath:i});return this.canReaddir()||(a.#e|=bt),n.push(a),a}relative(){if(this.isCWD)return"";if(this.#x!==void 0)return this.#x;let t=this.name,r=this.parent;if(!r)return this.#x=this.name;let n=r.relative();return n+(!n||!r.parent?"":this.sep)+t}relativePosix(){if(this.sep==="/")return this.relative();if(this.isCWD)return"";if(this.#S!==void 0)return this.#S;let t=this.name,r=this.parent;if(!r)return this.#S=this.fullpathPosix();let n=r.relativePosix();return n+(!n||!r.parent?"":"/")+t}fullpath(){if(this.#g!==void 0)return this.#g;let t=this.name,r=this.parent;if(!r)return this.#g=this.name;let s=r.fullpath()+(r.parent?this.sep:"")+t;return this.#g=s}fullpathPosix(){if(this.#y!==void 0)return this.#y;if(this.sep==="/")return this.#y=this.fullpath();if(!this.parent){let s=this.fullpath().replace(/\\/g,"/");return/^[a-z]:\//i.test(s)?this.#y=`//?/${s}`:this.#y=s}let t=this.parent,r=t.fullpathPosix(),n=r+(!r||!t.parent?"":"/")+this.name;return this.#y=n}isUnknown(){return(this.#e&gt)===Dt}isType(t){return this[`is${t}`]()}getType(){return this.isUnknown()?"Unknown":this.isDirectory()?"Directory":this.isFile()?"File":this.isSymbolicLink()?"SymbolicLink":this.isFIFO()?"FIFO":this.isCharacterDevice()?"CharacterDevice":this.isBlockDevice()?"BlockDevice":this.isSocket()?"Socket":"Unknown"}isFile(){return(this.#e&gt)===hc}isDirectory(){return(this.#e&gt)===Rt}isCharacterDevice(){return(this.#e&gt)===fc}isBlockDevice(){return(this.#e&gt)===dc}isFIFO(){return(this.#e&gt)===pc}isSocket(){return(this.#e&gt)===mc}isSymbolicLink(){return(this.#e&xe)===xe}lstatCached(){return this.#e&sc?this:void 0}readlinkCached(){return this.#I}realpathCached(){return this.#F}readdirCached(){let t=this.children();return t.slice(0,t.provisional)}canReadlink(){if(this.#I)return!0;if(!this.parent)return!1;let t=this.#e&gt;return!(t!==Dt&&t!==xe||this.#e&jn||this.#e&bt)}calledReaddir(){return!!(this.#e&bo)}isENOENT(){return!!(this.#e&bt)}isNamed(t){return this.nocase?this.#k===_n(t):this.#k===Ur(t)}async readlink(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=await this.#t.promises.readlink(this.fullpath()),n=(await this.parent.realpath())?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}readlinkSync(){let t=this.#I;if(t)return t;if(this.canReadlink()&&this.parent)try{let r=this.#t.readlinkSync(this.fullpath()),n=this.parent.realpathSync()?.resolve(r);if(n)return this.#I=n}catch(r){this.#R(r.code);return}}#j(t){this.#e|=bo;for(let r=t.provisional;r<t.length;r++){let n=t[r];n&&n.#v()}}#v(){this.#e&bt||(this.#e=(this.#e|bt)&Wr,this.#U())}#U(){let t=this.children();t.provisional=0;for(let r of t)r.#v()}#B(){this.#e|=Ln,this.#M()}#M(){if(this.#e&Hr)return;let t=this.#e;(t&gt)===Rt&&(t&=Wr),this.#e=t|Hr,this.#U()}#_(t=""){t==="ENOTDIR"||t==="EPERM"?this.#M():t==="ENOENT"?this.#v():this.children().provisional=0}#P(t=""){t==="ENOTDIR"?this.parent.#M():t==="ENOENT"&&this.#v()}#R(t=""){let r=this.#e;r|=jn,t==="ENOENT"&&(r|=bt),(t==="EINVAL"||t==="UNKNOWN")&&(r&=Wr),this.#e=r,t==="ENOTDIR"&&this.parent&&this.parent.#M()}#L(t,r){return this.#G(t,r)||this.#W(t,r)}#W(t,r){let n=xo(t),s=this.newChild(t.name,n,{parent:this}),o=s.#e&gt;return o!==Rt&&o!==xe&&o!==Dt&&(s.#e|=Hr),r.unshift(s),r.provisional++,s}#G(t,r){for(let n=r.provisional;n<r.length;n++){let s=r[n];if((this.nocase?_n(t.name):Ur(t.name))===s.#k)return this.#l(t,s,n,r)}}#l(t,r,n,s){let o=r.name;return r.#e=r.#e&Wr|xo(t),o!==t.name&&(r.name=t.name),n!==s.provisional&&(n===s.length-1?s.pop():s.splice(n,1),s.unshift(r)),s.provisional++,r}async lstat(){if((this.#e&bt)===0)try{return this.#H(await this.#t.promises.lstat(this.fullpath())),this}catch(t){this.#P(t.code)}}lstatSync(){if((this.#e&bt)===0)try{return this.#H(this.#t.lstatSync(this.fullpath())),this}catch(t){this.#P(t.code)}}#H(t){let{atime:r,atimeMs:n,birthtime:s,birthtimeMs:o,blksize:i,blocks:a,ctime:c,ctimeMs:l,dev:u,gid:p,ino:d,mode:f,mtime:m,mtimeMs:h,nlink:D,rdev:g,size:y,uid:x}=t;this.#w=r,this.#c=n,this.#m=s,this.#b=o,this.#u=i,this.#p=a,this.#T=c,this.#d=l,this.#r=u,this.#C=p,this.#a=d,this.#o=f,this.#h=m,this.#n=h,this.#s=D,this.#D=g,this.#f=y,this.#i=x;let C=xo(t);this.#e=this.#e&Wr|C|sc,C!==Dt&&C!==Rt&&C!==xe&&(this.#e|=Hr)}#$=[];#A=!1;#z(t){this.#A=!1;let r=this.#$.slice();this.#$.length=0,r.forEach(n=>n(null,t))}readdirCB(t,r=!1){if(!this.canReaddir()){r?t(null,[]):queueMicrotask(()=>t(null,[]));return}let n=this.children();if(this.calledReaddir()){let o=n.slice(0,n.provisional);r?t(null,o):queueMicrotask(()=>t(null,o));return}if(this.#$.push(t),this.#A)return;this.#A=!0;let s=this.fullpath();this.#t.readdir(s,{withFileTypes:!0},(o,i)=>{if(o)this.#_(o.code),n.provisional=0;else{for(let a of i)this.#L(a,n);this.#j(n)}this.#z(n.slice(0,n.provisional))})}#K;async readdir(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();if(this.#K)await this.#K;else{let n=()=>{};this.#K=new Promise(s=>n=s);try{for(let s of await this.#t.promises.readdir(r,{withFileTypes:!0}))this.#L(s,t);this.#j(t)}catch(s){this.#_(s.code),t.provisional=0}this.#K=void 0,n()}return t.slice(0,t.provisional)}readdirSync(){if(!this.canReaddir())return[];let t=this.children();if(this.calledReaddir())return t.slice(0,t.provisional);let r=this.fullpath();try{for(let n of this.#t.readdirSync(r,{withFileTypes:!0}))this.#L(n,t);this.#j(t)}catch(n){this.#_(n.code),t.provisional=0}return t.slice(0,t.provisional)}canReaddir(){if(this.#e&oc)return!1;let t=gt&this.#e;return t===Dt||t===Rt||t===xe}shouldWalk(t,r){return(this.#e&Rt)===Rt&&!(this.#e&oc)&&!t.has(this)&&(!r||r(this))}async realpath(){if(this.#F)return this.#F;if(!((Ln|jn|bt)&this.#e))try{let t=await this.#t.promises.realpath(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}realpathSync(){if(this.#F)return this.#F;if(!((Ln|jn|bt)&this.#e))try{let t=this.#t.realpathSync(this.fullpath());return this.#F=this.resolve(t)}catch{this.#B()}}[gc](t){if(t===this)return;t.isCWD=!1,this.isCWD=!0;let r=new Set([]),n=[],s=this;for(;s&&s.parent;)r.add(s),s.#x=n.join(this.sep),s.#S=n.join("/"),s=s.parent,n.push("..");for(s=t;s&&s.parent&&!r.has(s);)s.#x=void 0,s.#S=void 0,s=s.parent}},Gn=class e extends J{sep="\\";splitSep=Fm;constructor(t,r=Dt,n,s,o,i,a){super(t,r,n,s,o,i,a)}newChild(t,r=Dt,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}getRootString(t){return We.win32.parse(t).root}getRoot(t){if(t=Sm(t.toUpperCase()),t===this.root.name)return this.root;for(let[r,n]of Object.entries(this.roots))if(this.sameRoot(t,r))return this.roots[t]=n;return this.roots[t]=new Ge(t,this).root}sameRoot(t,r=this.root.name){return t=t.toUpperCase().replace(/\//g,"\\").replace(uc,"$1\\"),t===r}},Hn=class e extends J{splitSep="/";sep="/";constructor(t,r=Dt,n,s,o,i,a){super(t,r,n,s,o,i,a)}getRootString(t){return t.startsWith("/")?"/":""}getRoot(t){return this.root}newChild(t,r=Dt,n={}){return new e(t,r,this.root,this.roots,this.nocase,this.childrenCache(),n)}},Un=class{root;rootPath;roots;cwd;#t;#r;#o;nocase;#s;constructor(t=process.cwd(),r,n,{nocase:s,childrenCacheSize:o=16*1024,fs:i=Gr}={}){this.#s=lc(i),(t instanceof URL||t.startsWith("file://"))&&(t=(0,cc.fileURLToPath)(t));let a=r.resolve(t);this.roots=Object.create(null),this.rootPath=this.parseRootPath(a),this.#t=new Wn,this.#r=new Wn,this.#o=new vo(o);let c=a.substring(this.rootPath.length).split(n);if(c.length===1&&!c[0]&&c.pop(),s===void 0)throw new TypeError("must provide nocase setting to PathScurryBase ctor");this.nocase=s,this.root=this.newRoot(this.#s),this.roots[this.rootPath]=this.root;let l=this.root,u=c.length-1,p=r.sep,d=this.rootPath,f=!1;for(let m of c){let h=u--;l=l.child(m,{relative:new Array(h).fill("..").join(p),relativePosix:new Array(h).fill("..").join("/"),fullpath:d+=(f?"":p)+m}),f=!0}this.cwd=l}depth(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.depth()}childrenCache(){return this.#o}resolve(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#t.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpath();return this.#t.set(r,s),s}resolvePosix(...t){let r="";for(let o=t.length-1;o>=0;o--){let i=t[o];if(!(!i||i===".")&&(r=r?`${i}/${r}`:i,this.isAbsolute(i)))break}let n=this.#r.get(r);if(n!==void 0)return n;let s=this.cwd.resolve(r).fullpathPosix();return this.#r.set(r,s),s}relative(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relative()}relativePosix(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.relativePosix()}basename(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.name}dirname(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),(t.parent||t).fullpath()}async readdir(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd);let{withFileTypes:n}=r;if(t.canReaddir()){let s=await t.readdir();return n?s:s.map(o=>o.name)}else return[]}readdirSync(t=this.cwd,r={withFileTypes:!0}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd);let{withFileTypes:n=!0}=r;return t.canReaddir()?n?t.readdirSync():t.readdirSync().map(s=>s.name):[]}async lstat(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstat()}lstatSync(t=this.cwd){return typeof t=="string"&&(t=this.cwd.resolve(t)),t.lstatSync()}async readlink(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t.withFileTypes,t=this.cwd);let n=await t.readlink();return r?n:n?.fullpath()}readlinkSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t.withFileTypes,t=this.cwd);let n=t.readlinkSync();return r?n:n?.fullpath()}async realpath(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t.withFileTypes,t=this.cwd);let n=await t.realpath();return r?n:n?.fullpath()}realpathSync(t=this.cwd,{withFileTypes:r}={withFileTypes:!1}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t.withFileTypes,t=this.cwd);let n=t.realpathSync();return r?n:n?.fullpath()}async walk(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set,l=(p,d)=>{c.add(p),p.readdirCB((f,m)=>{if(f)return d(f);let h=m.length;if(!h)return d();let D=()=>{--h===0&&d()};for(let g of m)(!o||o(g))&&a.push(n?g:g.fullpath()),s&&g.isSymbolicLink()?g.realpath().then(y=>y?.isUnknown()?y.lstat():y).then(y=>y?.shouldWalk(c,i)?l(y,D):D()):g.shouldWalk(c,i)?l(g,D):D()},!0)},u=t;return new Promise((p,d)=>{l(u,f=>{if(f)return d(f);p(a)})})}walkSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=[];(!o||o(t))&&a.push(n?t:t.fullpath());let c=new Set([t]);for(let l of c){let u=l.readdirSync();for(let p of u){(!o||o(p))&&a.push(n?p:p.fullpath());let d=p;if(p.isSymbolicLink()){if(!(s&&(d=p.realpathSync())))continue;d.isUnknown()&&d.lstatSync()}d.shouldWalk(c,i)&&c.add(d)}}return a}[Symbol.asyncIterator](){return this.iterate()}iterate(t=this.cwd,r={}){return typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd),this.stream(t,r)[Symbol.asyncIterator]()}[Symbol.iterator](){return this.iterateSync()}*iterateSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r;(!o||o(t))&&(yield n?t:t.fullpath());let a=new Set([t]);for(let c of a){let l=c.readdirSync();for(let u of l){(!o||o(u))&&(yield n?u:u.fullpath());let p=u;if(u.isSymbolicLink()){if(!(s&&(p=u.realpathSync())))continue;p.isUnknown()&&p.lstatSync()}p.shouldWalk(a,i)&&a.add(p)}}}stream(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ce({objectMode:!0});(!o||o(t))&&a.write(n?t:t.fullpath());let c=new Set,l=[t],u=0,p=()=>{let d=!1;for(;!d;){let f=l.shift();if(!f){u===0&&a.end();return}u++,c.add(f);let m=(D,g,y=!1)=>{if(D)return a.emit("error",D);if(s&&!y){let x=[];for(let C of g)C.isSymbolicLink()&&x.push(C.realpath().then(A=>A?.isUnknown()?A.lstat():A));if(x.length){Promise.all(x).then(()=>m(null,g,!0));return}}for(let x of g)x&&(!o||o(x))&&(a.write(n?x:x.fullpath())||(d=!0));u--;for(let x of g){let C=x.realpathCached()||x;C.shouldWalk(c,i)&&l.push(C)}d&&!a.flowing?a.once("drain",p):h||p()},h=!0;f.readdirCB(m,!0),h=!1}};return p(),a}streamSync(t=this.cwd,r={}){typeof t=="string"?t=this.cwd.resolve(t):t instanceof J||(r=t,t=this.cwd);let{withFileTypes:n=!0,follow:s=!1,filter:o,walkFilter:i}=r,a=new ce({objectMode:!0}),c=new Set;(!o||o(t))&&a.write(n?t:t.fullpath());let l=[t],u=0,p=()=>{let d=!1;for(;!d;){let f=l.shift();if(!f){u===0&&a.end();return}u++,c.add(f);let m=f.readdirSync();for(let h of m)(!o||o(h))&&(a.write(n?h:h.fullpath())||(d=!0));u--;for(let h of m){let D=h;if(h.isSymbolicLink()){if(!(s&&(D=h.realpathSync())))continue;D.isUnknown()&&D.lstatSync()}D.shouldWalk(c,i)&&l.push(D)}}d&&!a.flowing&&a.once("drain",p)};return p(),a}chdir(t=this.cwd){let r=this.cwd;this.cwd=typeof t=="string"?this.cwd.resolve(t):t,this.cwd[gc](r)}},Ge=class extends Un{sep="\\";constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,We.win32,"\\",{...r,nocase:n}),this.nocase=n;for(let s=this.cwd;s;s=s.parent)s.nocase=this.nocase}parseRootPath(t){return We.win32.parse(t).root.toUpperCase()}newRoot(t){return new Gn(this.rootPath,Rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")||t.startsWith("\\")||/^[a-z]:(\/|\\)/i.test(t)}},He=class extends Un{sep="/";constructor(t=process.cwd(),r={}){let{nocase:n=!1}=r;super(t,We.posix,"/",{...r,nocase:n}),this.nocase=n}parseRootPath(t){return"/"}newRoot(t){return new Hn(this.rootPath,Rt,void 0,this.roots,this.nocase,this.childrenCache(),{fs:t})}isAbsolute(t){return t.startsWith("/")}},zr=class extends He{constructor(t=process.cwd(),r={}){let{nocase:n=!0}=r;super(t,{...r,nocase:n})}},Dx=process.platform==="win32"?Gn:Hn,Dc=process.platform==="win32"?Ge:process.platform==="darwin"?zr:He;var Am=e=>e.length>=1,Pm=e=>e.length>=1,Ue=class e{#t;#r;#o;length;#s;#i;#C;#D;#u;#a;#f=!0;constructor(t,r,n,s){if(!Am(t))throw new TypeError("empty pattern list");if(!Pm(r))throw new TypeError("empty glob list");if(r.length!==t.length)throw new TypeError("mismatched pattern list and glob list lengths");if(this.length=t.length,n<0||n>=this.length)throw new TypeError("index out of range");if(this.#t=t,this.#r=r,this.#o=n,this.#s=s,this.#o===0){if(this.isUNC()){let[o,i,a,c,...l]=this.#t,[u,p,d,f,...m]=this.#r;l[0]===""&&(l.shift(),m.shift());let h=[o,i,a,c,""].join("/"),D=[u,p,d,f,""].join("/");this.#t=[h,...l],this.#r=[D,...m],this.length=this.#t.length}else if(this.isDrive()||this.isAbsolute()){let[o,...i]=this.#t,[a,...c]=this.#r;i[0]===""&&(i.shift(),c.shift());let l=o+"/",u=a+"/";this.#t=[l,...i],this.#r=[u,...c],this.length=this.#t.length}}}pattern(){return this.#t[this.#o]}isString(){return typeof this.#t[this.#o]=="string"}isGlobstar(){return this.#t[this.#o]===U}isRegExp(){return this.#t[this.#o]instanceof RegExp}globString(){return this.#C=this.#C||(this.#o===0?this.isAbsolute()?this.#r[0]+this.#r.slice(1).join("/"):this.#r.join("/"):this.#r.slice(this.#o).join("/"))}hasMore(){return this.length>this.#o+1}rest(){return this.#i!==void 0?this.#i:this.hasMore()?(this.#i=new e(this.#t,this.#r,this.#o+1,this.#s),this.#i.#a=this.#a,this.#i.#u=this.#u,this.#i.#D=this.#D,this.#i):this.#i=null}isUNC(){let t=this.#t;return this.#u!==void 0?this.#u:this.#u=this.#s==="win32"&&this.#o===0&&t[0]===""&&t[1]===""&&typeof t[2]=="string"&&!!t[2]&&typeof t[3]=="string"&&!!t[3]}isDrive(){let t=this.#t;return this.#D!==void 0?this.#D:this.#D=this.#s==="win32"&&this.#o===0&&this.length>1&&typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0])}isAbsolute(){let t=this.#t;return this.#a!==void 0?this.#a:this.#a=t[0]===""&&t.length>1||this.isDrive()||this.isUNC()}root(){let t=this.#t[0];return typeof t=="string"&&this.isAbsolute()&&this.#o===0?t:""}checkFollowGlobstar(){return!(this.#o===0||!this.isGlobstar()||!this.#f)}markFollowGlobstar(){return this.#o===0||!this.isGlobstar()||!this.#f?!1:(this.#f=!1,!0)}};var Rm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",ze=class{relative;relativeChildren;absolute;absoluteChildren;platform;mmopts;constructor(t,{nobrace:r,nocase:n,noext:s,noglobstar:o,platform:i=Rm}){this.relative=[],this.absolute=[],this.relativeChildren=[],this.absoluteChildren=[],this.platform=i,this.mmopts={dot:!0,nobrace:r,nocase:n,noext:s,noglobstar:o,optimizationLevel:2,platform:i,nocomment:!0,nonegate:!0};for(let a of t)this.add(a)}add(t){let r=new at(t,this.mmopts);for(let n=0;n<r.set.length;n++){let s=r.set[n],o=r.globParts[n];if(!s||!o)throw new Error("invalid pattern object");for(;s[0]==="."&&o[0]===".";)s.shift(),o.shift();let i=new Ue(s,o,0,this.platform),a=new at(i.globString(),this.mmopts),c=o[o.length-1]==="**",l=i.isAbsolute();l?this.absolute.push(a):this.relative.push(a),c&&(l?this.absoluteChildren.push(a):this.relativeChildren.push(a))}}ignored(t){let r=t.fullpath(),n=`${r}/`,s=t.relative()||".",o=`${s}/`;for(let i of this.relative)if(i.match(s)||i.match(o))return!0;for(let i of this.absolute)if(i.match(r)||i.match(n))return!0;return!1}childrenIgnored(t){let r=t.fullpath()+"/",n=(t.relative()||".")+"/";for(let s of this.relativeChildren)if(s.match(n))return!0;for(let s of this.absoluteChildren)if(s.match(r))return!0;return!1}};var ko=class e{store;constructor(t=new Map){this.store=t}copy(){return new e(new Map(this.store))}hasWalked(t,r){return this.store.get(t.fullpath())?.has(r.globString())}storeWalked(t,r){let n=t.fullpath(),s=this.store.get(n);s?s.add(r.globString()):this.store.set(n,new Set([r.globString()]))}},Eo=class{store=new Map;add(t,r,n){let s=(r?2:0)|(n?1:0),o=this.store.get(t);this.store.set(t,o===void 0?s:s&o)}entries(){return[...this.store.entries()].map(([t,r])=>[t,!!(r&2),!!(r&1)])}},So=class{store=new Map;add(t,r){if(!t.canReaddir())return;let n=this.store.get(t);n?n.find(s=>s.globString()===r.globString())||n.push(r):this.store.set(t,[r])}get(t){let r=this.store.get(t);if(!r)throw new Error("attempting to walk unknown path");return r}entries(){return this.keys().map(t=>[t,this.store.get(t)])}keys(){return[...this.store.keys()].filter(t=>t.canReaddir())}},Kr=class e{hasWalkedCache;matches=new Eo;subwalks=new So;patterns;follow;dot;opts;constructor(t,r){this.opts=t,this.follow=!!t.follow,this.dot=!!t.dot,this.hasWalkedCache=r?r.copy():new ko}processPatterns(t,r){this.patterns=r;let n=r.map(s=>[t,s]);for(let[s,o]of n){this.hasWalkedCache.storeWalked(s,o);let i=o.root(),a=o.isAbsolute()&&this.opts.absolute!==!1;if(i){s=s.resolve(i==="/"&&this.opts.root!==void 0?this.opts.root:i);let p=o.rest();if(p)o=p;else{this.matches.add(s,!0,!1);continue}}if(s.isENOENT())continue;let c,l,u=!1;for(;typeof(c=o.pattern())=="string"&&(l=o.rest());)s=s.resolve(c),o=l,u=!0;if(c=o.pattern(),l=o.rest(),u){if(this.hasWalkedCache.hasWalked(s,o))continue;this.hasWalkedCache.storeWalked(s,o)}if(typeof c=="string"){let p=c===".."||c===""||c===".";this.matches.add(s.resolve(c),a,p);continue}else if(c===U){(!s.isSymbolicLink()||this.follow||o.checkFollowGlobstar())&&this.subwalks.add(s,o);let p=l?.pattern(),d=l?.rest();if(!l||(p===""||p===".")&&!d)this.matches.add(s,a,p===""||p===".");else if(p===".."){let f=s.parent||s;d?this.hasWalkedCache.hasWalked(f,d)||this.subwalks.add(f,d):this.matches.add(f,a,!0)}}else c instanceof RegExp&&this.subwalks.add(s,o)}return this}subwalkTargets(){return this.subwalks.keys()}child(){return new e(this.opts,this.hasWalkedCache)}filterEntries(t,r){let n=this.subwalks.get(t),s=this.child();for(let o of r)for(let i of n){let a=i.isAbsolute(),c=i.pattern(),l=i.rest();c===U?s.testGlobstar(o,i,l,a):c instanceof RegExp?s.testRegExp(o,c,l,a):s.testString(o,c,l,a)}return s}testGlobstar(t,r,n,s){if((this.dot||!t.name.startsWith("."))&&(r.hasMore()||this.matches.add(t,s,!1),t.canReaddir()&&(this.follow||!t.isSymbolicLink()?this.subwalks.add(t,r):t.isSymbolicLink()&&(n&&r.checkFollowGlobstar()?this.subwalks.add(t,n):r.markFollowGlobstar()&&this.subwalks.add(t,r)))),n){let o=n.pattern();if(typeof o=="string"&&o!==".."&&o!==""&&o!==".")this.testString(t,o,n.rest(),s);else if(o===".."){let i=t.parent||t;this.subwalks.add(i,n)}else o instanceof RegExp&&this.testRegExp(t,o,n.rest(),s)}}testRegExp(t,r,n,s){r.test(t.name)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}testString(t,r,n,s){t.isNamed(r)&&(n?this.subwalks.add(t,n):this.matches.add(t,s,!1))}};var Im=(e,t)=>typeof e=="string"?new ze([e],t):Array.isArray(e)?new ze(e,t):e,zn=class{path;patterns;opts;seen=new Set;paused=!1;aborted=!1;#t=[];#r;#o;signal;maxDepth;includeChildMatches;constructor(t,r,n){if(this.patterns=t,this.path=r,this.opts=n,this.#o=!n.posix&&n.platform==="win32"?"\\":"/",this.includeChildMatches=n.includeChildMatches!==!1,(n.ignore||!this.includeChildMatches)&&(this.#r=Im(n.ignore??[],n),!this.includeChildMatches&&typeof this.#r.add!="function")){let s="cannot ignore child matches, ignore lacks add() method.";throw new Error(s)}this.maxDepth=n.maxDepth||1/0,n.signal&&(this.signal=n.signal,this.signal.addEventListener("abort",()=>{this.#t.length=0}))}#s(t){return this.seen.has(t)||!!this.#r?.ignored?.(t)}#i(t){return!!this.#r?.childrenIgnored?.(t)}pause(){this.paused=!0}resume(){if(this.signal?.aborted)return;this.paused=!1;let t;for(;!this.paused&&(t=this.#t.shift());)t()}onResume(t){this.signal?.aborted||(this.paused?this.#t.push(t):t())}async matchCheck(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||await t.realpath(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?await t.lstat():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=await o.realpath();i&&(i.isUnknown()||this.opts.stat)&&await i.lstat()}return this.matchCheckTest(o,r)}matchCheckTest(t,r){return t&&(this.maxDepth===1/0||t.depth()<=this.maxDepth)&&(!r||t.canReaddir())&&(!this.opts.nodir||!t.isDirectory())&&(!this.opts.nodir||!this.opts.follow||!t.isSymbolicLink()||!t.realpathCached()?.isDirectory())&&!this.#s(t)?t:void 0}matchCheckSync(t,r){if(r&&this.opts.nodir)return;let n;if(this.opts.realpath){if(n=t.realpathCached()||t.realpathSync(),!n)return;t=n}let o=t.isUnknown()||this.opts.stat?t.lstatSync():t;if(this.opts.follow&&this.opts.nodir&&o?.isSymbolicLink()){let i=o.realpathSync();i&&(i?.isUnknown()||this.opts.stat)&&i.lstatSync()}return this.matchCheckTest(o,r)}matchFinish(t,r){if(this.#s(t))return;if(!this.includeChildMatches&&this.#r?.add){let o=`${t.relativePosix()}/**`;this.#r.add(o)}let n=this.opts.absolute===void 0?r:this.opts.absolute;this.seen.add(t);let s=this.opts.mark&&t.isDirectory()?this.#o:"";if(this.opts.withFileTypes)this.matchEmit(t);else if(n){let o=this.opts.posix?t.fullpathPosix():t.fullpath();this.matchEmit(o+s)}else{let o=this.opts.posix?t.relativePosix():t.relative(),i=this.opts.dotRelative&&!o.startsWith(".."+this.#o)?"."+this.#o:"";this.matchEmit(o?i+o+s:"."+s)}}async match(t,r,n){let s=await this.matchCheck(t,n);s&&this.matchFinish(s,r)}matchSync(t,r,n){let s=this.matchCheckSync(t,n);s&&this.matchFinish(s,r)}walkCB(t,r,n){this.signal?.aborted&&n(),this.walkCB2(t,r,new Kr(this.opts),n)}walkCB2(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,l]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,l).then(()=>i()));for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirCached();a.calledReaddir()?this.walkCB3(a,c,n,i):a.readdirCB((l,u)=>this.walkCB3(a,u,n,i),!0)}i()}walkCB3(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,l]of n.matches.entries())this.#s(a)||(o++,this.match(a,c,l).then(()=>i()));for(let[a,c]of n.subwalks.entries())o++,this.walkCB2(a,c,n.child(),i);i()}walkCBSync(t,r,n){this.signal?.aborted&&n(),this.walkCB2Sync(t,r,new Kr(this.opts),n)}walkCB2Sync(t,r,n,s){if(this.#i(t))return s();if(this.signal?.aborted&&s(),this.paused){this.onResume(()=>this.walkCB2Sync(t,r,n,s));return}n.processPatterns(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,l]of n.matches.entries())this.#s(a)||this.matchSync(a,c,l);for(let a of n.subwalkTargets()){if(this.maxDepth!==1/0&&a.depth()>=this.maxDepth)continue;o++;let c=a.readdirSync();this.walkCB3Sync(a,c,n,i)}i()}walkCB3Sync(t,r,n,s){n=n.filterEntries(t,r);let o=1,i=()=>{--o===0&&s()};for(let[a,c,l]of n.matches.entries())this.#s(a)||this.matchSync(a,c,l);for(let[a,c]of n.subwalks.entries())o++,this.walkCB2Sync(a,c,n.child(),i);i()}},Jr=class extends zn{matches=new Set;constructor(t,r,n){super(t,r,n)}matchEmit(t){this.matches.add(t)}async walk(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&await this.path.lstat(),await new Promise((t,r)=>{this.walkCB(this.path,this.patterns,()=>{this.signal?.aborted?r(this.signal.reason):t(this.matches)})}),this.matches}walkSync(){if(this.signal?.aborted)throw this.signal.reason;return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>{if(this.signal?.aborted)throw this.signal.reason}),this.matches}},qr=class extends zn{results;constructor(t,r,n){super(t,r,n),this.results=new ce({signal:this.signal,objectMode:!0}),this.results.on("drain",()=>this.resume()),this.results.on("resume",()=>this.resume())}matchEmit(t){this.results.write(t),this.results.flowing||this.pause()}stream(){let t=this.path;return t.isUnknown()?t.lstat().then(()=>{this.walkCB(t,this.patterns,()=>this.results.end())}):this.walkCB(t,this.patterns,()=>this.results.end()),this.results}streamSync(){return this.path.isUnknown()&&this.path.lstatSync(),this.walkCBSync(this.path,this.patterns,()=>this.results.end()),this.results}};var Nm=typeof process=="object"&&process&&typeof process.platform=="string"?process.platform:"linux",xt=class{absolute;cwd;root;dot;dotRelative;follow;ignore;magicalBraces;mark;matchBase;maxDepth;nobrace;nocase;nodir;noext;noglobstar;pattern;platform;realpath;scurry;stat;signal;windowsPathsNoEscape;withFileTypes;includeChildMatches;opts;patterns;constructor(t,r){if(!r)throw new TypeError("glob options required");if(this.withFileTypes=!!r.withFileTypes,this.signal=r.signal,this.follow=!!r.follow,this.dot=!!r.dot,this.dotRelative=!!r.dotRelative,this.nodir=!!r.nodir,this.mark=!!r.mark,r.cwd?(r.cwd instanceof URL||r.cwd.startsWith("file://"))&&(r.cwd=(0,yc.fileURLToPath)(r.cwd)):this.cwd="",this.cwd=r.cwd||"",this.root=r.root,this.magicalBraces=!!r.magicalBraces,this.nobrace=!!r.nobrace,this.noext=!!r.noext,this.realpath=!!r.realpath,this.absolute=r.absolute,this.includeChildMatches=r.includeChildMatches!==!1,this.noglobstar=!!r.noglobstar,this.matchBase=!!r.matchBase,this.maxDepth=typeof r.maxDepth=="number"?r.maxDepth:1/0,this.stat=!!r.stat,this.ignore=r.ignore,this.withFileTypes&&this.absolute!==void 0)throw new Error("cannot set absolute and withFileTypes:true");if(typeof t=="string"&&(t=[t]),this.windowsPathsNoEscape=!!r.windowsPathsNoEscape||r.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(t=t.map(c=>c.replace(/\\/g,"/"))),this.matchBase){if(r.noglobstar)throw new TypeError("base matching requires globstar");t=t.map(c=>c.includes("/")?c:`./**/${c}`)}if(this.pattern=t,this.platform=r.platform||Nm,this.opts={...r,platform:this.platform},r.scurry){if(this.scurry=r.scurry,r.nocase!==void 0&&r.nocase!==r.scurry.nocase)throw new Error("nocase option contradicts provided scurry option")}else{let c=r.platform==="win32"?Ge:r.platform==="darwin"?zr:r.platform?He:Dc;this.scurry=new c(this.cwd,{nocase:r.nocase,fs:r.fs})}this.nocase=this.scurry.nocase;let n=this.platform==="darwin"||this.platform==="win32",s={...r,dot:this.dot,matchBase:this.matchBase,nobrace:this.nobrace,nocase:this.nocase,nocaseMagicOnly:n,nocomment:!0,noext:this.noext,nonegate:!0,optimizationLevel:2,platform:this.platform,windowsPathsNoEscape:this.windowsPathsNoEscape,debug:!!this.opts.debug},o=this.pattern.map(c=>new at(c,s)),[i,a]=o.reduce((c,l)=>(c[0].push(...l.set),c[1].push(...l.globParts),c),[[],[]]);this.patterns=i.map((c,l)=>{let u=a[l];if(!u)throw new Error("invalid pattern object");return new Ue(c,u,0,this.platform)})}async walk(){return[...await new Jr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walk()]}walkSync(){return[...new Jr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).walkSync()]}stream(){return new qr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).stream()}streamSync(){return new qr(this.patterns,this.scurry.cwd,{...this.opts,maxDepth:this.maxDepth!==1/0?this.maxDepth+this.scurry.cwd.depth():1/0,platform:this.platform,nocase:this.nocase,includeChildMatches:this.includeChildMatches}).streamSync()}iterateSync(){return this.streamSync()[Symbol.iterator]()}[Symbol.iterator](){return this.iterateSync()}iterate(){return this.stream()[Symbol.asyncIterator]()}[Symbol.asyncIterator](){return this.iterate()}};var Fo=(e,t={})=>{Array.isArray(e)||(e=[e]);for(let r of e)if(new at(r,t).hasMagic())return!0;return!1};function Jn(e,t={}){return new xt(e,t).streamSync()}function Cc(e,t={}){return new xt(e,t).stream()}function qn(e,t={}){return new xt(e,t).walkSync()}async function wc(e,t={}){return new xt(e,t).walk()}function Vn(e,t={}){return new xt(e,t).iterateSync()}function bc(e,t={}){return new xt(e,t).iterate()}var Om=Jn,Mm=Object.assign(Cc,{sync:Jn}),$m=Vn,Bm=Object.assign(bc,{sync:Vn}),jm=Object.assign(qn,{stream:Jn,iterate:Vn}),Kn=Object.assign(wc,{glob:wc,globSync:qn,sync:jm,globStream:Cc,stream:Mm,globStreamSync:Jn,streamSync:Om,globIterate:bc,iterate:Bm,globIterateSync:Vn,iterateSync:$m,Glob:xt,hasMagic:Fo,escape:Be,unescape:wt});Kn.glob=Kn;var ue=(e,t)=>typeof e>"u"||typeof e===t,xc=e=>!!e&&typeof e=="object"&&ue(e.preserveRoot,"boolean")&&ue(e.tmp,"string")&&ue(e.maxRetries,"number")&&ue(e.retryDelay,"number")&&ue(e.backoff,"number")&&ue(e.maxBackoff,"number")&&(ue(e.glob,"boolean")||e.glob&&typeof e.glob=="object")&&ue(e.filter,"function"),vc=e=>{if(!xc(e))throw new Error("invalid rimraf options")},kc=e=>{vc(e);let{glob:t,...r}=e;if(!t)return r;let n=t===!0?e.signal?{signal:e.signal}:{}:e.signal?{signal:e.signal,...t}:t;return{...r,glob:{...n,absolute:!0,withFileTypes:!1}}},Ec=(e={})=>kc(e),Sc=(e={})=>kc(e);var Vr=require("path"),Fc=require("util"),_m=(e,t={})=>{let r=typeof e;if(r!=="string"){let s=e&&r==="object"&&e.constructor,i=`The "path" argument must be of type string. Received ${s&&s.name?`an instance of ${s.name}`:r==="object"?(0,Fc.inspect)(e):`type ${r} ${e}`}`;throw Object.assign(new TypeError(i),{path:e,code:"ERR_INVALID_ARG_TYPE"})}if(/\0/.test(e)){let s="path must be a string without null bytes";throw Object.assign(new TypeError(s),{path:e,code:"ERR_INVALID_ARG_VALUE"})}e=(0,Vr.resolve)(e);let{root:n}=(0,Vr.parse)(e);if(e===n&&t.preserveRoot!==!1){let s="refusing to remove root directory without preserveRoot:false";throw Object.assign(new Error(s),{path:e,code:"ERR_PRESERVE_ROOT"})}if(process.platform==="win32"){let s=/[*|"<>?:]/,{root:o}=(0,Vr.parse)(e);if(s.test(e.substring(o.length)))throw Object.assign(new Error("Illegal characters in path."),{path:e,code:"EINVAL"})}return e},Yr=_m;var Tc=require("fs"),Nt=b(require("fs/promises"),1),k=require("fs"),Ac=e=>(0,Tc.readdirSync)(e,{withFileTypes:!0}),st={chmod:Nt.default.chmod,mkdir:Nt.default.mkdir,readdir:e=>Nt.default.readdir(e,{withFileTypes:!0}),rename:Nt.default.rename,rm:Nt.default.rm,rmdir:Nt.default.rmdir,stat:Nt.default.stat,lstat:Nt.default.lstat,unlink:Nt.default.unlink};var qe=require("path");var{readdir:Lm}=st,Ke=e=>Lm(e).catch(t=>t),Je=e=>{try{return Ac(e)}catch(t){return t}};var Pc=e=>!!e&&typeof e=="object",To=(e,t)=>t in e&&typeof e[t]=="string",Ao=e=>Pc(e)&&To(e,"code")&&To(e,"path"),I=e=>Pc(e)&&To(e,"code")?e.code:null;var Q=async(e,t)=>e.catch(r=>{if(I(r)!=="ENOENT")throw t??r}),tt=(e,t)=>{try{return e()}catch(r){if(I(r)==="ENOENT")return;throw t??r}};var{lstat:Wm,rmdir:Gm,unlink:Hm}=st,Yn=async(e,t)=>(t?.signal?.throwIfAborted(),await Q(Wm(e).then(r=>Rc(e,t,r)))??!0),Zn=(e,t)=>(t?.signal?.throwIfAborted(),tt(()=>Ic(e,t,(0,k.lstatSync)(e)))??!0),Rc=async(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?await Ke(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Q(Hm(e)),!0)}return!(await Promise.all(n.map(o=>Rc((0,qe.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,qe.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Q(Gm(e)),!0)},Ic=(e,t,r)=>{t?.signal?.throwIfAborted();let n=r.isDirectory()?Je(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!t.filter(e,r)?!1:(tt(()=>(0,k.unlinkSync)(e)),!0)}let s=!0;for(let o of n){let i=(0,qe.resolve)(e,o.name);s=Ic(i,t,o)&&s}return t.preserveRoot===!1&&e===(0,qe.parse)(e).root||!s||t.filter&&!t.filter(e,r)?!1:(tt(()=>(0,k.rmdirSync)(e)),!0)};var Ve=require("path");var{chmod:Um}=st,Zr=e=>async t=>{try{return void await Q(e(t))}catch(r){if(I(r)==="EPERM")return await Q(Um(t,438).then(()=>!0),r)?void await e(t):void 0;throw r}},Xr=e=>t=>{try{return void tt(()=>e(t))}catch(r){if(I(r)==="EPERM")return tt(()=>((0,k.chmodSync)(t,438),!0),r)?void e(t):void 0;throw r}};var Nc=require("timers/promises");var zm=200,Km=1.2,Oc=10,Mc=new Set(["EMFILE","ENFILE","EBUSY"]),Po=e=>{let t=async(r,n,s=1,o=0)=>{let i=n.maxBackoff||zm,a=n.backoff||Km,c=n.maxRetries||Oc,l=0;for(;;)try{return await e(r)}catch(u){if(Ao(u)&&u.path===r&&Mc.has(u.code)){if(s=Math.ceil(s*a),o=s+o,o<i)return await(0,Nc.setTimeout)(s),t(r,n,s,o);if(l<c){l++;continue}}throw u}};return t},Ro=e=>(r,n)=>{let s=n.maxRetries||Oc,o=0;for(;;)try{return e(r)}catch(i){if(Ao(i)&&i.path===r&&Mc.has(i.code)&&o<s){o++;continue}throw i}};var yt=require("path");var Qr=require("os"),pe=require("path");var{stat:Jm}=st,qm=e=>{try{return(0,k.statSync)(e).isDirectory()}catch{return!1}},Vm=e=>Jm(e).then(t=>t.isDirectory(),()=>!1),Ym=async e=>{let{root:t}=(0,pe.parse)(e),r=(0,Qr.tmpdir)(),{root:n}=(0,pe.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,pe.resolve)(t,"/temp");return await Vm(s)?s:t},Zm=e=>{let{root:t}=(0,pe.parse)(e),r=(0,Qr.tmpdir)(),{root:n}=(0,pe.parse)(r);if(t.toLowerCase()===n.toLowerCase())return r;let s=(0,pe.resolve)(t,"/temp");return qm(s)?s:t},Xm=async()=>(0,Qr.tmpdir)(),Qm=()=>(0,Qr.tmpdir)(),$c=process.platform==="win32"?Ym:Xm,Bc=process.platform==="win32"?Zm:Qm;var{lstat:tg,rename:eg,unlink:rg,rmdir:ng}=st,Lc=e=>`.${(0,yt.basename)(e)}.${Math.random()}`,sg=Zr(rg),og=Xr(k.unlinkSync),Xn=async(e,t)=>(t?.signal?.throwIfAborted(),await Q(tg(e).then(r=>Io(e,t,r)))??!0),Io=async(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return Io(e,{...t,tmp:await $c(e)},r);if(e===t.tmp&&(0,yt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let n=r.isDirectory()?await Ke(e):null;if(!Array.isArray(n)){if(n){if(I(n)==="ENOENT")return!0;if(I(n)!=="ENOTDIR")throw n}return t.filter&&!await t.filter(e,r)?!1:(await Q(jc(e,t.tmp,sg)),!0)}return!(await Promise.all(n.map(o=>Io((0,yt.resolve)(e,o.name),t,o)))).every(o=>o===!0)||t.preserveRoot===!1&&e===(0,yt.parse)(e).root||t.filter&&!await t.filter(e,r)?!1:(await Q(jc(e,t.tmp,ng)),!0)},jc=async(e,t,r)=>{let n=(0,yt.resolve)(t,Lc(e));return await eg(e,n),await r(n)},Qn=(e,t)=>(t?.signal?.throwIfAborted(),tt(()=>No(e,t,(0,k.lstatSync)(e)))??!0),No=(e,t,r)=>{if(t?.signal?.throwIfAborted(),!t.tmp)return No(e,{...t,tmp:Bc(e)},r);let n=t.tmp;if(e===t.tmp&&(0,yt.parse)(e).root!==e)throw new Error("cannot delete temp directory used for deletion");let s=r.isDirectory()?Je(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(tt(()=>_c(e,n,og)),!0)}let o=!0;for(let i of s){let a=(0,yt.resolve)(e,i.name);o=No(a,t,i)&&o}return!o||t.preserveRoot===!1&&e===(0,yt.parse)(e).root||t.filter&&!t.filter(e,r)?!1:(tt(()=>_c(e,n,k.rmdirSync)),!0)},_c=(e,t,r)=>{let n=(0,yt.resolve)(t,Lc(e));return(0,k.renameSync)(e,n),r(n)};var{unlink:ig,rmdir:ag,lstat:cg}=st,lg=Po(Zr(ig)),ug=Ro(Xr(k.unlinkSync)),pg=Po(Zr(ag)),fg=Ro(Xr(k.rmdirSync)),dg=async(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return await pg(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return Xn(e,r);throw n}},hg=(e,{filter:t,...r})=>{r?.signal?.throwIfAborted();try{return fg(e,r),!0}catch(n){if(I(n)==="ENOTEMPTY")return Qn(e,r);throw n}},fe=Symbol("start"),Wc=Symbol("child"),ts=Symbol("finish"),es=async(e,t)=>(t?.signal?.throwIfAborted(),await Q(cg(e).then(r=>Oo(e,t,r,fe)))??!0),rs=(e,t)=>(t?.signal?.throwIfAborted(),tt(()=>Mo(e,t,(0,k.lstatSync)(e),fe))??!0),Oo=async(e,t,r,n=fe)=>{t?.signal?.throwIfAborted();let s=r.isDirectory()?await Ke(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!await t.filter(e,r)?!1:(await Q(lg(e,t)),!0)}let o=n===fe?Wc:n,i=(await Promise.all(s.map(a=>Oo((0,Ve.resolve)(e,a.name),t,a,o)))).every(a=>a===!0);if(n===fe)return Oo(e,t,r,ts);if(n===ts){if(t.preserveRoot===!1&&e===(0,Ve.parse)(e).root||!i||t.filter&&!await t.filter(e,r))return!1;await Q(dg(e,t))}return!0},Mo=(e,t,r,n=fe)=>{let s=r.isDirectory()?Je(e):null;if(!Array.isArray(s)){if(s){if(I(s)==="ENOENT")return!0;if(I(s)!=="ENOTDIR")throw s}return t.filter&&!t.filter(e,r)?!1:(tt(()=>ug(e,t)),!0)}let o=!0;for(let i of s){let a=n===fe?Wc:n,c=(0,Ve.resolve)(e,i.name);o=Mo(c,t,i,a)&&o}if(n===fe)return Mo(e,t,r,ts);if(n===ts){if(t.preserveRoot===!1&&e===(0,Ve.parse)(e).root||!o||t.filter&&!t.filter(e,r))return!1;tt(()=>hg(e,t))}return!0};var $o=process.platform==="win32"?es:Yn,Bo=process.platform==="win32"?rs:Zn;var{rm:mg}=st,jo=async(e,t)=>(await mg(e,{...t,force:!0,recursive:!0}),!0),_o=(e,t)=>((0,k.rmSync)(e,{...t,force:!0,recursive:!0}),!0);var[Gc=0,gg=0]=process.version.replace(/^v/,"").split(".").map(e=>parseInt(e,10)),Hc=Gc>14||Gc===14&&gg>=14,Uc=!Hc||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter,zc=!Hc||process.platform==="win32"?()=>!1:e=>!e?.signal&&!e?.filter;var Ye=e=>async(t,r)=>{let n=Ec(r);return n.glob&&(t=await Kn(t,n.glob)),Array.isArray(t)?!!(await Promise.all(t.map(s=>e(Yr(s,n),n)))).reduce((s,o)=>s&&o,!0):!!await e(Yr(t,n),n)},Ze=e=>(t,r)=>{let n=Sc(r);return n.glob&&(t=qn(t,n.glob)),Array.isArray(t)?!!t.map(s=>e(Yr(s,n),n)).reduce((s,o)=>s&&o,!0):!!e(Yr(t,n),n)},qc=Ze(_o),Dg=Object.assign(Ye(jo),{sync:qc}),Vc=Ze(Bo),yg=Object.assign(Ye($o),{sync:Vc}),Yc=Ze(rs),wg=Object.assign(Ye(es),{sync:Yc}),Zc=Ze(Zn),Cg=Object.assign(Ye(Yn),{sync:Zc}),Xc=Ze(Qn),bg=Object.assign(Ye(Xn),{sync:Xc}),Kc=Ze((e,t)=>zc(t)?_o(e,t):Bo(e,t));var Jc=Ye((e,t)=>Uc(t)?jo(e,t):$o(e,t)),ns=Object.assign(Jc,{rimraf:Jc,sync:Kc,rimrafSync:Kc,manual:yg,manualSync:Vc,native:Dg,nativeSync:qc,posix:Cg,posixSync:Zc,windows:wg,windowsSync:Yc,moveRemove:bg,moveRemoveSync:Xc});ns.rimraf=ns;var S=e=>(0,Xe.join)(process.cwd(),e),ss=e=>{try{return(0,Qc.readdirSync)(e).length===0}catch{return!0}};function tl(){let e=Pa({cwd:(0,Xe.dirname)(__filename)});if(!e)throw new Error("Could not find package.json");return(0,Xe.dirname)(e)}var el=e=>ns(e);var rl=b(require("chalk"));async function q(e,t){let r=Date.now(),n=e.title,s=()=>Math.floor((Date.now()-r)/1e3),o=setInterval(()=>{s()>1&&(e.title=`${n} (${s()}s)`)},1e3);try{return await t(s)}finally{clearInterval(o)}}async function os(e,t,r){for(let n=0;n<t.length;n++){let s=t[n];e.output=rl.default.dim(`[${n+1}/${t.length}] ${s.title}`),await s.fn(r??{},e)}}var Qe=e=>{let t=e??O(),r=(0,ot.join)(t,"package.json");if(!(0,vt.existsSync)(r))return null;try{return JSON.parse((0,vt.readFileSync)(r,"utf-8"))}catch{return null}},kt=e=>{let t={services:"services",apps:"apps",packages:"packages",contracts:"packages/contracts"},r=Qe(e);if(!r)return t;let n=r.pf?.paths;return{services:(typeof n?.services=="object"?n.services.path:n?.services)??t.services,apps:(typeof n?.apps=="object"?n.apps.path:n?.apps)??t.apps,packages:(typeof n?.packages=="object"?n.packages.path:n?.packages)??t.packages,contracts:(typeof n?.contracts=="object"?n.contracts.path:n?.contracts)??t.contracts}},$=e=>{let t=e??O(),r=kt(t);return{packagePath:(0,ot.join)(t,r.contracts),eventsPath:(0,ot.join)(t,r.contracts,"src","events"),indexPath:(0,ot.join)(t,r.contracts,"src","index.ts"),relativePath:r.contracts}},xg=e=>{let t=(0,ot.join)(e,"package.json");if(!(0,vt.existsSync)(t))return!1;try{let r=JSON.parse((0,vt.readFileSync)(t,"utf-8"));if(!r.workspaces)return!1;if(r.pf||(0,vt.existsSync)((0,ot.join)(e,"turbo.json")))return!0;let n=Ca.some(o=>(0,vt.existsSync)((0,ot.join)(e,o))),s=(0,vt.existsSync)((0,ot.join)(e,"infra"));return!!(n&&s)}catch{return!1}};function O(){let e=process.cwd();for(;!xg(e);){let t=e.slice(0,e.lastIndexOf("/"));if(t===e)throw new Error(`
17
17
  \x1B[31m\u2716\x1B[0m Not in a workspace directory
18
18
 
19
19
  Current directory: ${process.cwd()}
@@ -23,66 +23,75 @@ This command must be run from within a workspace created with \x1B[36mpf new wor
23
23
  To create a new workspace, run:
24
24
 
25
25
  \x1B[36mpf new workspace my-platform\x1B[0m
26
- `);e=t}return e}function ns(){let e=O(),t=(0,rt.join)(e,"package.json");if(!(0,bt.existsSync)(t))return`@${e.split("/").pop()||"workspace"}`;try{let n=JSON.parse((0,bt.readFileSync)(t,"utf-8")).name;return n?n.startsWith("@")?n.split("/")[0]:`@${n}`:`@${e.split("/").pop()||"workspace"}`}catch{return`@${e.split("/").pop()||"workspace"}`}}function Jt(e,t,r=process.cwd()){let n=(0,rt.join)(r,"package.json"),s=(0,be.readJsonSync)(n);lg(s,e,t),(0,be.writeJsonSync)(n,s,{spaces:2,EOL:`
27
- `,encoding:"utf-8"})}function Qc(e,t=process.cwd()){let r=(0,rt.join)(t,"package.json"),n=(0,be.readJsonSync)(r),s=e.split("."),o=n;for(let i of s){if(o===null||typeof o!="object"||!(i in o))return;o=o[i]}return o}function lg(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++){let i=n[o];(!(i in s)||typeof s[i]!="object"||s[i]===null)&&(s[i]={}),s=s[i]}s[n[n.length-1]]=r}var ss=e=>{let t=Yc();return(0,be.readJSONSync)((0,rt.resolve)(t,e),{encoding:"utf-8"})},Ot=ss("package.json"),pg={docs:{base:["service.md"],frameworks:{}},serviceTypes:{hono:{commandType:"hono-micro",entryPoint:"src/index.ts",skipFiles:[]},nest:{commandType:"nest-micro",entryPoint:"src/main.ts",skipFiles:[]}}},Xr=()=>Ot.generatorConfig??pg;var mu=require("node:fs"),gu=require("node:path"),Go=require("node:process"),Du=require("execa");var Wo=require("node:child_process"),pu=require("node:path"),fu=require("execa");var au=require("node:fs"),cu=require("node:path"),uu=b(iu()),_o=(e,t)=>{let r=(0,cu.resolve)(t,e);return(0,au.existsSync)(r)?(0,uu.config)({path:r,processEnv:{}}).parsed||{}:{}},lu=(e,t)=>{let r=_o(e,t),n=[];for(let[s,o]of Object.entries(r))if(s.endsWith("_PORT")&&o){let i=Number.parseInt(o,10);!Number.isNaN(i)&&i>0&&n.push(i)}return n};var Lo={...process.env,NODE_NO_WARNINGS:"1"},Ag=(e,t,r)=>e?"pipe":t||r?["ignore","pipe","pipe"]:"inherit",Pg=(e,t,r)=>e?{...Lo,...e}:t||r?{...Lo,CI:"true"}:{...Lo},Rg=e=>e.includes("EEXIST")||e.includes("failed to link package");async function fe(e,t,{cwd:r=process.cwd(),task:n,shell:s,context:o=e,quiet:i=!1,nonInteractive:a=!1,env:c}={}){try{t.length===0&&(t=e.split(" ").slice(1));let u=(0,fu.execa)(e,t,{cwd:r,stdio:Ag(i,n,a),all:n||a?!0:void 0,shell:s??!0,env:Pg(c,n,a)});u.all&&u.all.on("data",l=>{let p=l.toString().trim();n?(n.output=p,p.length&&w.storeLog(p,o)):a&&p.length&&console.log(p)}),await u}catch(u){let l=u instanceof Error?u.message:String(u);if(Rg(l))return;throw new Error(Ig(l))}}var Ig=e=>{let t=e.match(/error: (.+)/);return t?t[1].trim():e};function du(e,t,r={}){let{cwd:n=process.cwd(),envFile:s,detached:o=!0,pipeStdout:i=!1,onStdout:a,onStderr:c,onExit:u}=r,l=s?_o(s,n):{},p=(0,pu.resolve)(n,"node_modules",".bin"),d=process.env.PATH||"",f=`${p}:${d}`,m={...process.env,...l,PATH:f,FORCE_COLOR:"1"},h=(0,Wo.spawn)(e,t,{cwd:n,env:m,stdio:["inherit",i?"pipe":"inherit","pipe"],detached:o});return a&&i&&h.stdout?.on("data",a),c&&h.stderr?.on("data",c),u&&h.on("exit",u),h}function is(e,t,r={}){let{cwd:n=process.cwd()}=r;(0,Wo.spawn)(e,t,{cwd:n,stdio:"inherit",shell:!0}).on("exit",o=>process.exit(o||0))}async function hu(e){let{execSync:t}=await import("node:child_process");for(let r of e)try{let s=t(`lsof -ti:${r}`,{encoding:"utf8",stdio:"pipe"}).trim().split(`
28
- `).filter(Boolean);for(let o of s)try{process.kill(Number.parseInt(o,10),"SIGKILL")}catch{}}catch{}}var as=e=>Rr(e);function Ho(e=process.cwd()){let t=r=>(0,mu.existsSync)((0,gu.join)(e,r));if(t("bun.lock")||t("bun.lockb"))return"bun";if(t("pnpm-lock.yaml"))return"pnpm";if(t("yarn.lock"))return"yarn";if(t("package-lock.json"))return"npm"}function $(e){return Ho(e)??Uo()}function Uo(){return as("bun")?"bun":as("pnpm")?"pnpm":as("yarn")?"yarn":"npm"}function yu(){return["bun","pnpm","yarn","npm"].filter(as)}async function xt(e,t){let r=Og(e,t),{mergedOptions:n,packages:s}=r,{cwd:o=process.cwd(),flags:i=[],task:a,quiet:c}=n,u=n.packageManager??$(),l=[],p=Array.isArray(s)?s:[s];u==="bun"&&(p=p.map(f=>f.replace("git+ssh://",""))),u==="pnpm"&&(l.push("--config.engine-strict=false"),l.push("--no-frozen-lockfile")),["yarn","npm"].includes(u)&&l.push("--ignore-engines");let d=p.length?u==="npm"?["install",...i,...l,...p]:["add",...i,...l,...p]:["install",...i,...l];await fe(u,d,{cwd:o,task:a,quiet:c})}async function wu(e){let t=["-g"],r=[...e.flags??[],...t];await xt({...e,flags:r,packageManager:e.packageManager??$()})}function Cu(e,t,r){let{args:n,mergedOptions:s}=vu(t??[],r),o=s.manager??$(),{command:i,args:a}=bu(o);console.log(`
26
+ `);e=t}return e}function is(){let e=O(),t=(0,ot.join)(e,"package.json");if(!(0,vt.existsSync)(t))return`@${e.split("/").pop()||"workspace"}`;try{let n=JSON.parse((0,vt.readFileSync)(t,"utf-8")).name;return n?n.startsWith("@")?n.split("/")[0]:`@${n}`:`@${e.split("/").pop()||"workspace"}`}catch{return`@${e.split("/").pop()||"workspace"}`}}function qt(e,t,r=process.cwd()){let n=(0,ot.join)(r,"package.json"),s=(0,ve.readJsonSync)(n);vg(s,e,t),(0,ve.writeJsonSync)(n,s,{spaces:2,EOL:`
27
+ `,encoding:"utf-8"})}function nl(e,t=process.cwd()){let r=(0,ot.join)(t,"package.json"),n=(0,ve.readJsonSync)(r),s=e.split("."),o=n;for(let i of s){if(o===null||typeof o!="object"||!(i in o))return;o=o[i]}return o}function vg(e,t,r){let n=t.split("."),s=e;for(let o=0;o<n.length-1;o++){let i=n[o];(!(i in s)||typeof s[i]!="object"||s[i]===null)&&(s[i]={}),s=s[i]}s[n[n.length-1]]=r}var as=e=>{let t=tl();return(0,ve.readJSONSync)((0,ot.resolve)(t,e),{encoding:"utf-8"})},Ot=as("package.json"),kg={docs:{base:["service.md"],frameworks:{}},serviceTypes:{hono:{commandType:"hono-micro",entryPoint:"src/index.ts",skipFiles:[]},nest:{commandType:"nest-micro",entryPoint:"src/main.ts",skipFiles:[]}}},tn=()=>Ot.generatorConfig??kg;var wl=require("node:fs"),Cl=require("node:path"),zo=require("node:process"),bl=require("execa");var Uo=require("node:child_process"),ml=require("node:path"),gl=require("execa");var pl=require("node:fs"),fl=require("node:path"),dl=b(ul()),Go=(e,t)=>{let r=(0,fl.resolve)(t,e);return(0,pl.existsSync)(r)?(0,dl.config)({path:r,processEnv:{}}).parsed||{}:{}},hl=(e,t)=>{let r=Go(e,t),n=[];for(let[s,o]of Object.entries(r))if(s.endsWith("_PORT")&&o){let i=Number.parseInt(o,10);!Number.isNaN(i)&&i>0&&n.push(i)}return n};var Ho={...process.env,NODE_NO_WARNINGS:"1"},Gg=(e,t,r)=>e?"pipe":t||r?["ignore","pipe","pipe"]:"inherit",Hg=(e,t,r)=>e?{...Ho,...e}:t||r?{...Ho,CI:"true"}:{...Ho},Ug=e=>e.includes("EEXIST")||e.includes("failed to link package");async function de(e,t,{cwd:r=process.cwd(),task:n,shell:s,context:o=e,quiet:i=!1,nonInteractive:a=!1,env:c}={}){try{t.length===0&&(t=e.split(" ").slice(1));let l=(0,gl.execa)(e,t,{cwd:r,stdio:Gg(i,n,a),all:n||a?!0:void 0,shell:s??!0,env:Hg(c,n,a)});l.all&&l.all.on("data",u=>{let p=u.toString().trim();n?(n.output=p,p.length&&w.storeLog(p,o)):a&&p.length&&console.log(p)}),await l}catch(l){let u=l instanceof Error?l.message:String(l);if(Ug(u))return;throw new Error(zg(u))}}var zg=e=>{let t=e.match(/error: (.+)/);return t?t[1].trim():e};function Dl(e,t,r={}){let{cwd:n=process.cwd(),envFile:s,detached:o=!0,pipeStdout:i=!1,onStdout:a,onStderr:c,onExit:l}=r,u=s?Go(s,n):{},p=(0,ml.resolve)(n,"node_modules",".bin"),d=process.env.PATH||"",f=`${p}:${d}`,m={...process.env,...u,PATH:f,FORCE_COLOR:"1"},h=(0,Uo.spawn)(e,t,{cwd:n,env:m,stdio:["inherit",i?"pipe":"inherit","pipe"],detached:o});return a&&i&&h.stdout?.on("data",a),c&&h.stderr?.on("data",c),l&&h.on("exit",l),h}function ls(e,t,r={}){let{cwd:n=process.cwd()}=r;(0,Uo.spawn)(e,t,{cwd:n,stdio:"inherit",shell:!0}).on("exit",o=>process.exit(o||0))}async function yl(e){let{execSync:t}=await import("node:child_process");for(let r of e)try{let s=t(`lsof -ti:${r}`,{encoding:"utf8",stdio:"pipe"}).trim().split(`
28
+ `).filter(Boolean);for(let o of s)try{process.kill(Number.parseInt(o,10),"SIGKILL")}catch{}}catch{}}var us=e=>Nr(e);function Ko(e=process.cwd()){let t=r=>(0,wl.existsSync)((0,Cl.join)(e,r));if(t("bun.lock")||t("bun.lockb"))return"bun";if(t("pnpm-lock.yaml"))return"pnpm";if(t("yarn.lock"))return"yarn";if(t("package-lock.json"))return"npm"}function B(e){return Ko(e)??Jo()}function Jo(){return us("bun")?"bun":us("pnpm")?"pnpm":us("yarn")?"yarn":"npm"}function xl(){return["bun","pnpm","yarn","npm"].filter(us)}async function Et(e,t){let r=Jg(e,t),{mergedOptions:n,packages:s}=r,{cwd:o=process.cwd(),flags:i=[],task:a,quiet:c}=n,l=n.packageManager??B(),u=[],p=Array.isArray(s)?s:[s];l==="bun"&&(p=p.map(f=>f.replace("git+ssh://",""))),l==="pnpm"&&(u.push("--config.engine-strict=false"),u.push("--no-frozen-lockfile")),["yarn","npm"].includes(l)&&u.push("--ignore-engines");let d=p.length?l==="npm"?["install",...i,...u,...p]:["add",...i,...u,...p]:["install",...i,...u];await de(l,d,{cwd:o,task:a,quiet:c})}async function vl(e){let t=["-g"],r=[...e.flags??[],...t];await Et({...e,flags:r,packageManager:e.packageManager??B()})}function kl(e,t,r){let{args:n,mergedOptions:s}=Sl(t??[],r),o=s.manager??B(),{command:i,args:a}=El(o);console.log(`
29
29
  Running command: ${i} ${[...a,e,...n].join(" ")}
30
- `),(0,Du.execaSync)(i,[...a,e,...n],{cwd:s.cwd??(0,Go.cwd)(),stdio:"inherit",preferLocal:!0})}async function qt(e,t,r){let{args:n,mergedOptions:s}=vu(t??[],r),o=s.manager??$(),{command:i,args:a}=bu(o);await fe(i,[...a,e,...n],s)}async function tn(e,t){let{script:r,mergedOptions:n}=Mg(e,t),s=n.packageManager??$();await fe(s,["run",r,...n.args??[]],{cwd:n.cwd??(0,Go.cwd)(),task:n.task})}function bu(e){let r={bun:"bunx",pnpm:"npx",yarn:"npx",npm:"npx"}[e];if(!r)throw new Error(`No executor found for the detected package manager: ${e}`);let[n,...s]=r.split(" ");return{command:n,args:s}}function Og(e,t){return Array.isArray(e)?{packages:e,mergedOptions:{...t,packages:e}}:{packages:e.packages??[],mergedOptions:e}}function vu(e,t){return Array.isArray(e)?{args:e,mergedOptions:t??{}}:{args:[],mergedOptions:e}}function Mg(e,t){return typeof e=="string"?{script:e,mergedOptions:t??{}}:{script:e.script,mergedOptions:e}}var $g=e=>e==="yarn"?["npm","audit"]:["audit"],Eu=new ku.Command("audit").description("Run security audit on dependencies").allowUnknownOption(!0).action((e,t)=>{let r=O(),n=$(),s=$g(n),o=t.args||[];console.log(xu.default.dim(`Running ${n} ${[...s,...o].join(" ")}`)),is(n,[...s,...o],{cwd:r})});var Mt=require("listr2"),Bg=Object.defineProperty,Su=(e,t)=>Bg(e,"name",{value:t,configurable:!0}),R=class extends Mt.ListrPromptAdapter{static{Su(this,"ListrEnquirerPromptAdapter")}error;prompt;get instance(){return this.prompt}async run(e,t){Array.isArray(e)?e.length===1&&(e=e.map(s=>({...s,name:"default"}))):e=[{...e,name:"default"}],e=e.map(s=>({onCancel:Su(()=>(this.error=new Mt.PromptError("Cancelled prompt."),!0),"onCancel"),...s,stdout:t?.stdout??this.wrapper.stdout(Mt.ListrTaskEventType.PROMPT)}));let r;if(t?.enquirer)r=t.enquirer;else try{r=await import("enquirer").then(s=>s.default?new s.default:new s)}catch{throw this.reportFailed(),new Mt.PromptError("Enquirer is a optional peer dependency that must be installed separately.")}this.reportStarted(),this.task.on(Mt.ListrTaskEventType.STATE,s=>{s===Mt.ListrTaskState.SKIPPED&&this.prompt&&!this.error&&this.cancel({throw:!1})});let n;try{n=await r.once("prompt",s=>this.prompt=s).prompt(e)}catch(s){throw this.reportFailed(),this.error?this.error:s}return this.reportCompleted(),e.length===1?n.default:n}cancel(e){!this.prompt||this.error||(e?.throw?this.prompt.cancel():this.prompt.submit(),this.reportFailed())}};var ee=b(require("chalk"));var tr=require("node:fs"),Nu=require("node:os"),Ou=require("node:path");var de=require("node:crypto"),Qe=require("node:fs"),ve=require("node:os"),Fu=require("node:path"),zo=(0,Fu.join)((0,ve.homedir)(),".platform-sdk-keys"),Tu="aes-256-gcm",Au=()=>{let e=`${(0,ve.hostname)()}:${(0,ve.userInfo)().username}:${(0,ve.homedir)()}`;return(0,de.createHash)("sha256").update(e).digest()},Pu=()=>{if(!(0,Qe.existsSync)(zo))return{};try{return JSON.parse((0,Qe.readFileSync)(zo,"utf-8"))}catch{return{}}},jg=e=>{(0,Qe.writeFileSync)(zo,JSON.stringify(e,null,2),{mode:384})},_g=e=>{let t=Au(),r=(0,de.randomBytes)(16),n=(0,de.createCipheriv)(Tu,t,r),s=n.update(e,"utf8","hex");return s+=n.final("hex"),{iv:r.toString("hex"),tag:n.getAuthTag().toString("hex"),data:s}},Lg=e=>{let t=Au(),r=Buffer.from(e.iv,"hex"),n=Buffer.from(e.tag,"hex"),s=(0,de.createDecipheriv)(Tu,t,r);s.setAuthTag(n);let o=s.update(e.data,"hex","utf8");return o+=s.final("utf8"),o};async function Ru(e,t){let r=Pu();r[e]=_g(t),jg(r)}async function cs(e){let r=Pu()[e];if(!r)return null;try{return Lg(r)}catch{return null}}var en={openai:{id:"openai",name:"OpenAI",defaultApiKeyEnvVar:"OPENAI_API_KEY",defaultModel:"gpt-4o-mini",modelsApiUrl:"https://api.openai.com/v1/models",apiKeyUrl:"https://platform.openai.com/api-keys",buildHeaders:e=>({Authorization:`Bearer ${e}`}),parseModelsResponse:e=>e.data??[],modelFilters:[/^gpt-4/,/^gpt-3\.5/,/^o1/,/^o3/]},anthropic:{id:"anthropic",name:"Anthropic (Claude)",defaultApiKeyEnvVar:"ANTHROPIC_API_KEY",defaultModel:"claude-sonnet-4-20250514",modelsApiUrl:"https://api.anthropic.com/v1/models",apiKeyUrl:"https://console.anthropic.com/settings/keys",buildHeaders:e=>({"x-api-key":e,"anthropic-version":"2023-06-01"}),parseModelsResponse:e=>(e.data??[]).map(r=>({id:r.id,created:new Date(r.created_at).getTime()})),modelFilters:[/^claude-/]}};function Iu(){return Object.entries(en).map(([e,t])=>({name:t.name,value:e}))}function rn(e){let t=en[e];if(!t)throw new Error(`Unknown AI provider: ${e}`);return t}var xe=(0,Ou.join)((0,Nu.homedir)(),".platform-sdk-ai.json"),Wg=()=>{let e="anthropic",t=en[e];return{provider:e,model:t.defaultModel}},Ko=Wg();function nn(){return(0,tr.existsSync)(xe)}function us(){if(!nn())throw new Error("AI configuration not found. Please run 'pf ai:setup' to configure your AI provider.");try{let e=(0,tr.readFileSync)(xe,"utf-8"),t=JSON.parse(e);return{...Ko,...t}}catch{throw new Error(`Failed to load AI configuration from ${xe}. Please run 'pf setup --ai' again.`)}}function Mu(e){let t=JSON.stringify(e,null,2);(0,tr.writeFileSync)(xe,t,"utf-8")}async function $u(e,t){await Ru(e,t)}async function Bu(e){let t=await cs(e.provider);if(t)return t;let r=en[e.provider],n=process.env[r.defaultApiKeyEnvVar];if(n)return n;throw new Error("API key not found. Please run 'pf setup --ai' to configure your API key.")}var Gg=async(e,t,r,n)=>{let{createOpenAI:s}=await import("@ai-sdk/openai"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),u=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),l="";for await(let p of(await u).textStream)l+=p,n.onToken(p);return l}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a},Hg=async(e,t,r,n)=>{let{createAnthropic:s}=await import("@ai-sdk/anthropic"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),u=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),l="";for await(let p of(await u).textStream)l+=p,n.onToken(p);return l}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a};async function ju(e,t,r={}){let{system:n,maxTokens:s=4096,temperature:o=.7,onToken:i}=r,a=await Bu(e);switch(e.provider){case"openai":return Gg(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});case"anthropic":return Hg(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});default:throw new Error(`Unsupported AI provider: ${e.provider}`)}}var Zt=require("node:fs"),ar=require("node:path"),Cl=require("@inquirer/prompts"),T=b(require("chalk")),bl=b(require("ora"));var er=require("node:fs"),sn=require("node:path"),ls=b(require("chokidar"));var on=".pf-generating",Ug=e=>(0,er.existsSync)((0,sn.join)(e,on)),zg=e=>{let t=(0,sn.join)(e,on);(0,er.existsSync)(t)&&(0,er.unlinkSync)(t)},Kg=e=>e?Object.values(e).filter(t=>typeof t=="object"&&t!==null&&t.watch===!0&&typeof t.path=="string").map(t=>t.path):["services","apps"],_u=(e,t)=>{zg(e);let r=Ze(e),n=Kg(r?.pf?.paths),s=(0,sn.join)(e,on),o=()=>{Ug(e)||t()};ls.default.watch(s,{ignoreInitial:!0}).on("unlink",()=>t());for(let i of n){let a=(0,sn.join)(e,i);(0,er.existsSync)(a)&&(ls.default.watch(a,{ignoreInitial:!0,depth:0}).on("addDir",o).on("unlinkDir",o),ls.default.watch(`${a}/*/package.json`,{ignoreInitial:!0}).on("add",o).on("change",o).on("unlink",o))}};var gs=require("node:fs"),Vu=require("node:path"),qu=require("ts-morph");var gt=require("node:fs"),an=require("node:path");var Jg=e=>e.replace(/\./g,"-").toLowerCase(),Vg=e=>e.split(/[-.]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),qg=e=>({string:"z.string()",number:"z.number()",boolean:"z.boolean()",date:"z.string().datetime()",array:"z.array(z.unknown())",object:"z.record(z.unknown())","string?":"z.string().optional()","number?":"z.number().optional()","boolean?":"z.boolean().optional()"})[e.toLowerCase()]||`z.${e}()`,Yg=e=>!e||Object.keys(e).length===0?` id: z.string(),
31
- createdAt: z.string(),`:Object.entries(e).map(([t,r])=>` ${t}: ${qg(r)},`).join(`
32
- `),kt=e=>{let t=Jg(e),r=Vg(e);return{eventName:t,contractName:`${r}Contract`,schemaName:`${r}Schema`,typeName:`${r}Data`}},Jo=e=>{let{eventsPath:t}=G(),{eventName:r}=kt(e);return(0,gt.existsSync)((0,an.join)(t,`${r}.ts`))},Vo=(e,t)=>{let{eventsPath:r}=G(),{eventName:n,contractName:s,schemaName:o,typeName:i}=kt(e),a=`import { createContract } from '@crossdelta/cloudevents'
30
+ `),(0,bl.execaSync)(i,[...a,e,...n],{cwd:s.cwd??(0,zo.cwd)(),stdio:"inherit",preferLocal:!0})}async function Yt(e,t,r){let{args:n,mergedOptions:s}=Sl(t??[],r),o=s.manager??B(),{command:i,args:a}=El(o);await de(i,[...a,e,...n],s)}async function rn(e,t){let{script:r,mergedOptions:n}=qg(e,t),s=n.packageManager??B();await de(s,["run",r,...n.args??[]],{cwd:n.cwd??(0,zo.cwd)(),task:n.task})}function El(e){let r={bun:"bunx",pnpm:"npx",yarn:"npx",npm:"npx"}[e];if(!r)throw new Error(`No executor found for the detected package manager: ${e}`);let[n,...s]=r.split(" ");return{command:n,args:s}}function Jg(e,t){return Array.isArray(e)?{packages:e,mergedOptions:{...t,packages:e}}:{packages:e.packages??[],mergedOptions:e}}function Sl(e,t){return Array.isArray(e)?{args:e,mergedOptions:t??{}}:{args:[],mergedOptions:e}}function qg(e,t){return typeof e=="string"?{script:e,mergedOptions:t??{}}:{script:e.script,mergedOptions:e}}var Vg=e=>e==="yarn"?["npm","audit"]:["audit"],Al=new Tl.Command("audit").description("Run security audit on dependencies").allowUnknownOption(!0).action((e,t)=>{let r=O(),n=B(),s=Vg(n),o=t.args||[];console.log(Fl.default.dim(`Running ${n} ${[...s,...o].join(" ")}`)),ls(n,[...s,...o],{cwd:r})});var Mt=require("listr2"),Yg=Object.defineProperty,Pl=(e,t)=>Yg(e,"name",{value:t,configurable:!0}),R=class extends Mt.ListrPromptAdapter{static{Pl(this,"ListrEnquirerPromptAdapter")}error;prompt;get instance(){return this.prompt}async run(e,t){Array.isArray(e)?e.length===1&&(e=e.map(s=>({...s,name:"default"}))):e=[{...e,name:"default"}],e=e.map(s=>({onCancel:Pl(()=>(this.error=new Mt.PromptError("Cancelled prompt."),!0),"onCancel"),...s,stdout:t?.stdout??this.wrapper.stdout(Mt.ListrTaskEventType.PROMPT)}));let r;if(t?.enquirer)r=t.enquirer;else try{r=await import("enquirer").then(s=>s.default?new s.default:new s)}catch{throw this.reportFailed(),new Mt.PromptError("Enquirer is a optional peer dependency that must be installed separately.")}this.reportStarted(),this.task.on(Mt.ListrTaskEventType.STATE,s=>{s===Mt.ListrTaskState.SKIPPED&&this.prompt&&!this.error&&this.cancel({throw:!1})});let n;try{n=await r.once("prompt",s=>this.prompt=s).prompt(e)}catch(s){throw this.reportFailed(),this.error?this.error:s}return this.reportCompleted(),e.length===1?n.default:n}cancel(e){!this.prompt||this.error||(e?.throw?this.prompt.cancel():this.prompt.submit(),this.reportFailed())}};var re=b(require("chalk"));var rr=require("node:fs"),Bl=require("node:os"),jl=require("node:path");var he=require("node:crypto"),er=require("node:fs"),ke=require("node:os"),Rl=require("node:path"),qo=(0,Rl.join)((0,ke.homedir)(),".platform-sdk-keys"),Il="aes-256-gcm",Nl=()=>{let e=`${(0,ke.hostname)()}:${(0,ke.userInfo)().username}:${(0,ke.homedir)()}`;return(0,he.createHash)("sha256").update(e).digest()},Ol=()=>{if(!(0,er.existsSync)(qo))return{};try{return JSON.parse((0,er.readFileSync)(qo,"utf-8"))}catch{return{}}},Zg=e=>{(0,er.writeFileSync)(qo,JSON.stringify(e,null,2),{mode:384})},Xg=e=>{let t=Nl(),r=(0,he.randomBytes)(16),n=(0,he.createCipheriv)(Il,t,r),s=n.update(e,"utf8","hex");return s+=n.final("hex"),{iv:r.toString("hex"),tag:n.getAuthTag().toString("hex"),data:s}},Qg=e=>{let t=Nl(),r=Buffer.from(e.iv,"hex"),n=Buffer.from(e.tag,"hex"),s=(0,he.createDecipheriv)(Il,t,r);s.setAuthTag(n);let o=s.update(e.data,"hex","utf8");return o+=s.final("utf8"),o};async function Ml(e,t){let r=Ol();r[e]=Xg(t),Zg(r)}async function ps(e){let r=Ol()[e];if(!r)return null;try{return Qg(r)}catch{return null}}var nn={openai:{id:"openai",name:"OpenAI",defaultApiKeyEnvVar:"OPENAI_API_KEY",defaultModel:"gpt-4o-mini",modelsApiUrl:"https://api.openai.com/v1/models",apiKeyUrl:"https://platform.openai.com/api-keys",buildHeaders:e=>({Authorization:`Bearer ${e}`}),parseModelsResponse:e=>e.data??[],modelFilters:[/^gpt-4/,/^gpt-3\.5/,/^o1/,/^o3/]},anthropic:{id:"anthropic",name:"Anthropic (Claude)",defaultApiKeyEnvVar:"ANTHROPIC_API_KEY",defaultModel:"claude-sonnet-4-20250514",modelsApiUrl:"https://api.anthropic.com/v1/models",apiKeyUrl:"https://console.anthropic.com/settings/keys",buildHeaders:e=>({"x-api-key":e,"anthropic-version":"2023-06-01"}),parseModelsResponse:e=>(e.data??[]).map(r=>({id:r.id,created:new Date(r.created_at).getTime()})),modelFilters:[/^claude-/]}};function $l(){return Object.entries(nn).map(([e,t])=>({name:t.name,value:e}))}function sn(e){let t=nn[e];if(!t)throw new Error(`Unknown AI provider: ${e}`);return t}var Ee=(0,jl.join)((0,Bl.homedir)(),".platform-sdk-ai.json"),tD=()=>{let e="anthropic",t=nn[e];return{provider:e,model:t.defaultModel}},Vo=tD();function on(){return(0,rr.existsSync)(Ee)}function fs(){if(!on())throw new Error("AI configuration not found. Please run 'pf ai:setup' to configure your AI provider.");try{let e=(0,rr.readFileSync)(Ee,"utf-8"),t=JSON.parse(e);return{...Vo,...t}}catch{throw new Error(`Failed to load AI configuration from ${Ee}. Please run 'pf setup --ai' again.`)}}function _l(e){let t=JSON.stringify(e,null,2);(0,rr.writeFileSync)(Ee,t,"utf-8")}async function Ll(e,t){await Ml(e,t)}async function Wl(e){let t=await ps(e.provider);if(t)return t;let r=nn[e.provider],n=process.env[r.defaultApiKeyEnvVar];if(n)return n;throw new Error("API key not found. Please run 'pf setup --ai' to configure your API key.")}var eD=async(e,t,r,n)=>{let{createOpenAI:s}=await import("@ai-sdk/openai"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),l=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),u="";for await(let p of(await l).textStream)u+=p,n.onToken(p);return u}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a},rD=async(e,t,r,n)=>{let{createAnthropic:s}=await import("@ai-sdk/anthropic"),o=s({apiKey:r});if(n.onToken){let{streamText:c}=await import("ai"),l=c({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature}),u="";for await(let p of(await l).textStream)u+=p,n.onToken(p);return u}let{generateText:i}=await import("ai"),{text:a}=await i({model:o(t),prompt:e,system:n.system,maxOutputTokens:n.maxTokens,temperature:n.temperature});return a};async function Gl(e,t,r={}){let{system:n,maxTokens:s=4096,temperature:o=.7,onToken:i}=r,a=await Wl(e);switch(e.provider){case"openai":return eD(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});case"anthropic":return rD(t,e.model,a,{system:n,maxTokens:s,temperature:o,onToken:i});default:throw new Error(`Unsupported AI provider: ${e.provider}`)}}var Xt=require("node:fs"),ur=require("node:path"),ku=require("@inquirer/prompts"),T=b(require("chalk")),Eu=b(require("ora"));var nr=require("node:fs"),an=require("node:path"),ds=b(require("chokidar"));var cn=".pf-generating",nD=e=>(0,nr.existsSync)((0,an.join)(e,cn)),sD=e=>{let t=(0,an.join)(e,cn);(0,nr.existsSync)(t)&&(0,nr.unlinkSync)(t)},oD=e=>e?Object.values(e).filter(t=>typeof t=="object"&&t!==null&&t.watch===!0&&typeof t.path=="string").map(t=>t.path):["services","apps"],Hl=(e,t)=>{sD(e);let r=Qe(e),n=oD(r?.pf?.paths),s=(0,an.join)(e,cn),o=()=>{nD(e)||t()};ds.default.watch(s,{ignoreInitial:!0}).on("unlink",()=>t());for(let i of n){let a=(0,an.join)(e,i);(0,nr.existsSync)(a)&&(ds.default.watch(a,{ignoreInitial:!0,depth:0}).on("addDir",o).on("unlinkDir",o),ds.default.watch(`${a}/*/package.json`,{ignoreInitial:!0}).on("add",o).on("change",o).on("unlink",o))}};var Ds=require("node:fs"),Xl=require("node:path"),Ql=require("ts-morph");var lt=require("node:fs"),ln=require("node:path");var Ul=e=>e.replace(/\./g,"-").toLowerCase(),iD=e=>e.split(/[-.]/).map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(""),aD=e=>({string:"z.string()",number:"z.number()",boolean:"z.boolean()",date:"z.string().datetime()",array:"z.array(z.unknown())",object:"z.record(z.unknown())","string?":"z.string().optional()","number?":"z.number().optional()","boolean?":"z.boolean().optional()"})[e.toLowerCase()]||`z.${e}()`,cD=e=>!e||Object.keys(e).length===0?` id: z.string(),
31
+ createdAt: z.string(),`:Object.entries(e).map(([t,r])=>` ${t}: ${aD(r)},`).join(`
32
+ `),lD=e=>e.endsWith("s")?e:e.endsWith("y")?`${e.slice(0,-1)}ies`:e.endsWith("ch")||e.endsWith("sh")?`${e}es`:`${e}s`,sr=e=>{let t=Ul(e),r=iD(e),n=e.split(".")[0],s=lD(n).toUpperCase();return{eventName:t,contractName:`${r}Contract`,schemaName:`${r}Schema`,typeName:`${r}Data`,streamName:s}},Yo=e=>{let t=or(e);if((0,lt.existsSync)(t))return!0;let{eventsPath:r}=$(),n=Ul(e),s=(0,ln.join)(r,`${n}.ts`);return(0,lt.existsSync)(s)},Zo=(e,t)=>{let{eventsPath:r}=$(),{contractName:n,schemaName:s,typeName:o,streamName:i}=sr(e),a=`import { createContract } from '@crossdelta/cloudevents'
33
33
  import { z } from 'zod'
34
34
 
35
- export const ${o} = z.object({
36
- ${Yg(t)}
35
+ export const ${s} = z.object({
36
+ ${cD(t)}
37
37
  })
38
38
 
39
- export const ${s} = createContract({
39
+ export const ${n} = createContract({
40
40
  type: '${e}',
41
- schema: ${o},
41
+ channel: { stream: '${i}' },
42
+ schema: ${s},
42
43
  })
43
44
 
44
- export type ${i} = z.infer<typeof ${s}.schema>
45
- `,c=(0,an.join)(r,`${n}.ts`);return(0,gt.existsSync)(r)||(0,gt.mkdirSync)(r,{recursive:!0}),(0,gt.writeFileSync)(c,a,"utf-8"),c},ps=e=>{let{eventsPath:t}=G(),{eventName:r}=kt(e);return(0,an.join)(t,`${r}.ts`)},qo=e=>{let t=ps(e);if(!(0,gt.existsSync)(t))return null;let r=(0,gt.readFileSync)(t,"utf-8"),n=r.match(/export const \w+Schema\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(n)return n[1];let s=r.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);return s?s[1]:null},Yo=()=>{let{packagePath:e}=G(),t=(0,an.join)(e,"package.json");if(!(0,gt.existsSync)(t))return"@my-platform";try{return JSON.parse((0,gt.readFileSync)(t,"utf-8")).name?.split("/")[0]??"@my-platform"}catch{return"@my-platform"}};var ds=require("node:fs"),Qo=require("node:path");var Q=require("node:fs"),rr=require("node:path");var fs=e=>e.split(".")[0].toUpperCase(),Lu=(e,t)=>{let r=(0,rr.join)(e,"src","index.ts");if(!(0,Q.existsSync)(r))return!1;let n=(0,Q.readFileSync)(r,"utf-8"),s=t.toLowerCase();return n.includes(`stream: '${t}'`)?!0:new RegExp(`subjects:\\s*\\[.*['"]${s}\\.[*>]`).test(n)},Zg=e=>{if(e.includes("@crossdelta/cloudevents"))return e;let t=`import { consumeJetStreamEvents, ensureJetStreamStream } from '@crossdelta/cloudevents'
45
+ export type ${o} = z.infer<typeof ${n}.schema>
46
+ `,c=e.split(".")[0],l=(0,ln.join)(r,c),u=or(e);return(0,lt.existsSync)(l)||(0,lt.mkdirSync)(l,{recursive:!0}),(0,lt.writeFileSync)(u,a,"utf-8"),u},or=e=>{let{eventsPath:t}=$(),r=e.split(".")[0],n=e.split(".").slice(1).join("-");return(0,ln.join)(t,r,`${n}.ts`)},Xo=e=>{let t=or(e);if(!(0,lt.existsSync)(t))return null;let r=(0,lt.readFileSync)(t,"utf-8"),n=r.match(/export const \w+Schema\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(n)return n[1];let s=r.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);return s?s[1]:null},Qo=()=>{let{packagePath:e}=$(),t=(0,ln.join)(e,"package.json");if(!(0,lt.existsSync)(t))return"@my-platform";try{return JSON.parse((0,lt.readFileSync)(t,"utf-8")).name?.split("/")[0]??"@my-platform"}catch{return"@my-platform"}};var ms=require("node:fs"),ri=require("node:path");var et=require("node:fs"),ir=require("node:path");var hs=e=>e.split(".")[0].toUpperCase(),zl=(e,t)=>{let r=(0,ir.join)(e,"src","index.ts");if(!(0,et.existsSync)(r))return!1;let n=(0,et.readFileSync)(r,"utf-8"),s=t.toLowerCase();return new RegExp(`streams:\\s*\\[[^\\]]*['"]${t}['"]`).test(n)||n.includes(`stream: '${t}'`)?!0:new RegExp(`subjects:\\s*\\[.*['"]${s}\\.[*>]`).test(n)},uD=e=>{if(e.includes("@crossdelta/cloudevents"))return e;let t=`import { consumeJetStreams } from '@crossdelta/cloudevents'
46
47
  `,r=e.match(/import\s+['"]@crossdelta\/telemetry['"]\s*\n/);if(r){let s=(r.index??0)+r[0].length;return`${e.slice(0,s)}
47
- ${t}${e.slice(s)}`}let n=e.match(/import\s+.*\n/);if(n){let s=(n.index??0)+n[0].length;return e.slice(0,s)+t+e.slice(s)}return e},Xg=(e,t,r)=>`
48
+ ${t}${e.slice(s)}`}let n=e.match(/import\s+.*\n/);if(n){let s=(n.index??0)+n[0].length;return e.slice(0,s)+t+e.slice(s)}return e},pD=(e,t,r)=>`
48
49
 
49
- // ${e} stream (${t}.* events)
50
- await ensureJetStreamStream({
51
- stream: '${e}',
52
- subjects: ['${t}.>'],
53
- })
54
-
55
- consumeJetStreamEvents({
56
- stream: '${e}',
50
+ // Consume from ${e} stream
51
+ consumeJetStreams({
52
+ streams: ['${e}'],
57
53
  consumer: '${r}-service',
58
- discover: './src/events/**/*.event.ts',
59
- })`,Zo=(e,t)=>{let r=fs(t),n=t.split(".")[0],s=(0,rr.join)(e,"src","index.ts"),o=(0,rr.join)(e,"src","main.ts");if(!(0,Q.existsSync)(s)&&(0,Q.existsSync)(o))return{added:!1,streamName:r};if(!(0,Q.existsSync)(s))return{added:!1,streamName:r,warning:"Entry point not found (index.ts or main.ts)"};if(Lu(e,r))return{added:!1,streamName:r};let i=(0,Q.readFileSync)(s,"utf-8"),a=e.split("/").pop()||"unknown";i.includes("consumeJetStreamEvents")||(i=Zg(i));let c=Xg(r,n,a),u=`${i.trimEnd()+c}
60
- `;return(0,Q.writeFileSync)(s,u,"utf-8"),{added:!0,streamName:r}},Xo=(e,t)=>{let{eventName:r,contractName:n,typeName:s}=kt(e),o=Yo(),i=(0,rr.join)(t,"src","events"),a=(0,rr.join)(i,`${r}.event.ts`);if((0,Q.existsSync)(a))return null;let c=`import { handleEvent } from '@crossdelta/cloudevents'
54
+ discover: './src/events/**/*.handler.ts',
55
+ })`,ti=(e,t)=>{let r=hs(t),n=t.split(".")[0],s=(0,ir.join)(e,"src","index.ts"),o=(0,ir.join)(e,"src","main.ts");if(!(0,et.existsSync)(s)&&(0,et.existsSync)(o))return{added:!1,streamName:r};if(!(0,et.existsSync)(s))return{added:!1,streamName:r,warning:"Entry point not found (index.ts or main.ts)"};if(zl(e,r))return{added:!1,streamName:r};let i=(0,et.readFileSync)(s,"utf-8"),a=e.split("/").pop()||"unknown";i.includes("consumeJetStreams")||(i=uD(i));let c=pD(r,n,a),l=`${i.trimEnd()+c}
56
+ `;return(0,et.writeFileSync)(s,l,"utf-8"),{added:!0,streamName:r}},ei=(e,t)=>{let{eventName:r,contractName:n,typeName:s}=sr(e),o=Qo(),i=(0,ir.join)(t,"src","events"),a=(0,ir.join)(i,`${r}.handler.ts`);if((0,et.existsSync)(a))return null;let c=`import { handleEvent } from '@crossdelta/cloudevents'
61
57
  import { ${n}, type ${s} } from '${o}/contracts'
62
58
 
63
59
  export default handleEvent(${n}, async (data: ${s}) => {
64
60
  // TODO: Implement event handling logic
65
61
  console.log('Received ${e}:', data)
66
62
  })
67
- `;return(0,Q.existsSync)(i)||(0,Q.mkdirSync)(i,{recursive:!0}),(0,Q.writeFileSync)(a,c,"utf-8"),a};var Wu=e=>{try{return(0,ds.readdirSync)(e,{withFileTypes:!0}).flatMap(r=>{let n=(0,Qo.join)(e,r.name);return r.isDirectory()?Wu(n):r.name.endsWith(".event.ts")?[n]:[]})}catch{return[]}},ti=e=>{let t=(0,Qo.join)(e,"src","events");return Wu(t).flatMap(n=>{let s=(0,ds.readFileSync)(n,"utf-8");return Qg(n,s)})},Qg=(e,t)=>{let r=tD(t);if(!r)return[];let o=(r.replace(/Contract$/,"").match(/[A-Z][a-z]*/g)??[]).map(i=>i.toLowerCase()).join(".");return[{filePath:e,eventType:o,contractName:r}]},tD=e=>{let r=/import\s+{([^}]+)}\s+from\s+['"]@[\w-]+\/contracts['"]/.exec(e);return r?r[1].split(",").map(o=>o.trim()).filter(o=>o.endsWith("Contract")).map(o=>o.replace(/\s+as\s+.+$/,"").trim()).at(0)??null:null},ei=e=>{let t=e.reduce((r,n)=>{let s=n.eventType.split(".")[0],o=r.get(s)??[];return r.set(s,[...o,n]),r},new Map);return Array.from(t.entries()).map(([r,n])=>eD(r,n)).sort((r,n)=>r.stream.localeCompare(n.stream))},eD=(e,t)=>{let r=fs(t[0]?.eventType??`${e}.event`),n=`${e}.>`;return{stream:r,subjects:[n],handlers:t}},ri=(e,t)=>e.length===0?"":` await ensureJetStreams({
68
- streams: [
69
- ${e.map(n=>{let s=n.subjects.map(o=>`'${o}'`).join(", ");return` { stream: '${n.stream}', subjects: [${s}] }`}).join(`,
70
- `)}
71
- ],
72
- })
63
+ `;return(0,et.existsSync)(i)||(0,et.mkdirSync)(i,{recursive:!0}),(0,et.writeFileSync)(a,c,"utf-8"),a};var Kl=e=>{try{return(0,ms.readdirSync)(e,{withFileTypes:!0}).flatMap(r=>{let n=(0,ri.join)(e,r.name);return r.isDirectory()?Kl(n):r.name.endsWith(".handler.ts")?[n]:[]})}catch{return[]}},ni=e=>{let t=(0,ri.join)(e,"src","events");return Kl(t).flatMap(n=>{let s=(0,ms.readFileSync)(n,"utf-8");return fD(n,s)})},fD=(e,t)=>{let r=dD(t);if(!r)return[];let o=(r.replace(/Contract$/,"").match(/[A-Z][a-z]*/g)??[]).map(i=>i.toLowerCase()).join(".");return[{filePath:e,eventType:o,contractName:r}]},dD=e=>{let r=/import\s+{([^}]+)}\s+from\s+['"]@[\w-]+\/contracts['"]/.exec(e);return r?r[1].split(",").map(o=>o.trim()).filter(o=>o.endsWith("Contract")).map(o=>o.replace(/\s+as\s+.+$/,"").trim()).at(0)??null:null},si=e=>{let t=e.reduce((r,n)=>{let s=n.eventType.split(".")[0],o=r.get(s)??[];return r.set(s,[...o,n]),r},new Map);return Array.from(t.entries()).map(([r,n])=>hD(r,n)).sort((r,n)=>r.stream.localeCompare(n.stream))},hD=(e,t)=>{let r=hs(t[0]?.eventType??`${e}.event`),n=`${e}.>`;return{stream:r,subjects:[n],handlers:t}},oi=(e,t)=>e.length===0?"":` // Services NEVER create streams!
64
+ // - Development: pf dev auto-creates ephemeral streams from contracts
65
+ // - Production: Pulumi materializes persistent streams
73
66
 
74
67
  consumeJetStreams({
75
- streams: [${e.map(n=>`'${n.stream}'`).join(", ")}],
68
+ streams: [${e.map(r=>`'${r.stream}'`).join(", ")}],
76
69
  consumer: '${t}',
77
- discover: './src/events/**/*.event.ts',
78
- })`;var nr=require("node:fs"),Gu=require("node:path");var hs=(e,t)=>{if(!(0,nr.existsSync)(e))return!1;let r=`export * from './events/${t}'`,n=(0,nr.readFileSync)(e,"utf-8");if(n.includes(`'./events/${t}'`))return!1;let s=n.split(`
79
- `),o=s.findLastIndex(i=>i.startsWith("export"));return o>=0?s.splice(o+1,0,r):s.push("",r),(0,nr.writeFileSync)(e,s.join(`
80
- `),"utf-8"),!0},ni=e=>{let{packagePath:t}=G(),{eventName:r}=kt(e),n=(0,Gu.join)(t,"src","index.ts");return hs(n,r)};var nt=require("node:fs"),Yt=require("node:path"),F=require("@faker-js/faker");var Hu=[{pattern:"email",generate:()=>F.faker.internet.email(),hint:"email"},{pattern:"id",generate:()=>F.faker.string.uuid(),hint:"uuid"},{pattern:"firstname",generate:()=>F.faker.person.firstName(),hint:"firstName"},{pattern:"lastname",generate:()=>F.faker.person.lastName(),hint:"lastName"},{pattern:"name",generate:()=>F.faker.person.fullName(),hint:"fullName"},{pattern:"phone",generate:()=>F.faker.phone.number(),hint:"phoneNumber"},{pattern:"address",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"street",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"city",generate:()=>F.faker.location.city(),hint:"city"},{pattern:"country",generate:()=>F.faker.location.country(),hint:"country"},{pattern:"price",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"amount",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"total",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"quantity",generate:()=>F.faker.number.int({min:1,max:10}),hint:"quantity"},{pattern:"date",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"createdat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"updatedat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"}],Uu=e=>({email:()=>F.faker.internet.email(),datetime:()=>F.faker.date.recent().toISOString(),url:()=>F.faker.internet.url(),uuid:()=>F.faker.string.uuid(),date:()=>F.faker.date.recent().toISOString().split("T")[0],time:()=>F.faker.date.recent().toISOString().split("T")[1]?.split(".")[0]})[e]?.()??F.faker.lorem.word(),zu=e=>{let t=e.toLowerCase(),r=Hu.find(n=>t.includes(n.pattern));return r?{value:r.generate(),hint:r.hint}:null},rD=(e,t)=>{if(e.format)return Uu(e.format);let r=zu(t);if(r)return r.value;switch(e.type){case"string":return F.faker.lorem.word();case"number":return F.faker.number.int({min:1,max:100});case"boolean":return F.faker.datatype.boolean();case"array":return e.element?[si(e.element)]:[];case"object":return si(e);default:return null}},si=e=>{let t={},r=e.shape??(typeof e.def?.shape=="function"?e.def.shape():void 0);if(!r)return t;for(let[n,s]of Object.entries(r))t[n]=rD(s,n);return t},nD=async e=>{try{let{createJiti:t}=await import("jiti"),n=t(process.cwd(),{interopDefault:!0})(e),s=Object.entries(n).find(([o])=>o.endsWith("Schema")||o==="schema");if(s?.[1]){let o=s[1],i=si(o);if(i&&typeof i=="object"&&Object.keys(i).length>0){let a={};return oi(i,a,""),{data:i,faker:a}}}}catch{}return null},oi=(e,t,r)=>{if(!(!e||typeof e!="object"))for(let[n,s]of Object.entries(e)){let o=r?`${r}.${n}`:n,i=n.toLowerCase(),a=Hu.find(c=>i.includes(c.pattern));a&&(a.hint!=="uuid"||typeof s=="string")&&(t[o]=a.hint),typeof s=="object"&&s!==null&&!Array.isArray(s)?oi(s,t,o):Array.isArray(s)&&s.length>0&&typeof s[0]=="object"&&oi(s[0],t,`${o}[0]`)}},sD=e=>({string:()=>F.faker.lorem.word(),number:()=>F.faker.number.int({min:1,max:100}),boolean:()=>F.faker.datatype.boolean()})[e]?.(),oD=(e,t,r)=>{let n=/(\w+):\s*z\.(\w+)\(/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s){if(i==="array"||i==="object")continue;let a=zu(o);if(a)t[o]=a.value,a.hint&&(r[o]=a.hint);else{let c=sD(i);c!==void 0&&(t[o]=c)}}},iD=(e,t,r)=>{let n=/(\w+):\s*z\.string\(\)\.(datetime|email|url|uuid)\(\)/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s)t[o]=Uu(i),r[o]=i==="datetime"?"date":i},Ku=e=>{let t={},r={};return oD(e,t,r),iD(e,t,r),{data:t,faker:r}},ms=async e=>{let{eventsPath:t}=G(),{eventName:r}=kt(e),n=ps(e);if(!(0,nt.existsSync)(n))return null;let o=(0,nt.readFileSync)(n,"utf-8").match(/type:\s*['"]([^'"]+)['"]/),i=o?o[1]:e,a=await nD(n);if(!a){let l=qo(e);l&&(a=Ku(l))}if(!a)return null;let c={eventName:i,description:`Mock data for ${i} event`,data:a.data};Object.keys(a.faker).length>0&&(c.faker=a.faker);let u=(0,Yt.join)(t,`${r}.mock.json`);return(0,nt.writeFileSync)(u,JSON.stringify(c,null,2),"utf-8"),u};var Ju=e=>{let t=e.match(/import\s+\{[^}]*?(\w+Contract)[^}]*?\}\s+from\s+['"][^'"]+\/contracts['"]/);return t?t[1].replace("Contract","").replace(/([A-Z])/g,(n,s,o)=>(o>0?".":"")+s.toLowerCase()):null},aD=(e,t,r)=>{if(!(0,nt.existsSync)(e))return!1;let n=(0,nt.readFileSync)(e,"utf-8"),s=n.match(/export const \w+(?:Schema|Data)\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m)??n.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(!s)return!1;let o=Ku(s[1]),i={eventName:r,description:`Mock data for ${r} event`,data:o.data};return Object.keys(o.faker).length>0&&(i.faker=o.faker),(0,nt.writeFileSync)(t,JSON.stringify(i,null,2)),!0},ii=async(e,t={})=>{let r=(0,Yt.join)(e,"src","events");if(!(0,nt.existsSync)(r))return{mockPaths:[],skippedHandlers:[]};let n=(0,nt.readdirSync)(r).filter(i=>i.endsWith(".event.ts")).map(i=>(0,Yt.join)(r,i)),s=[],o=[];for(let i of n){let a=(0,nt.readFileSync)(i,"utf-8"),c=Ju(a);if(!c){o.push(`${(0,Yt.basename)(i)} (Handler does not use contracts)`);continue}let{eventName:u}=kt(c),l=t.outputDir??G().eventsPath,p=(0,Yt.join)(l,`${u}.mock.json`);if((0,nt.existsSync)(p)&&!t.overwrite){o.push(`${(0,Yt.basename)(i)} (Mock already exists)`);continue}if(t.outputDir){let f=(0,Yt.join)(t.outputDir,`${u}.ts`);aD(f,p,c)&&s.push(p);continue}let d=await ms(c);d&&s.push(d)}return{mockPaths:s,skippedHandlers:o}};var Yu=e=>{let t=e.split("/").pop()||"service",r=(0,Vu.join)(e,"src","events","events.service.ts");if(!(0,gs.existsSync)(r))return!1;let n=ti(e);if(n.length===0||(0,gs.readFileSync)(r,"utf-8").replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").includes("await ensureJetStreams"))return!1;let a=ei(n),c=ri(a,t);if(!c)return!1;let u=new qu.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),l=u.addSourceFileAtPath(r),p=!1;for(let d of l.getClasses()){let f=d.getMethod("startConsumers");if(!f)continue;let h=[...c.split(`
70
+ discover: './src/events/**/*.handler.ts',
71
+ })`;var j=require("node:fs"),Zt=require("node:path");var mD=(e,t)=>{let r=`export * from './${t}'`;if(!(0,j.existsSync)(e)){let o=(0,Zt.dirname)(e);(0,j.existsSync)(o)||(0,j.mkdirSync)(o,{recursive:!0});let i=`/**
72
+ * ${(0,Zt.dirname)(e).split("/").pop()} Domain Events
73
+ */
74
+
75
+ `;return(0,j.writeFileSync)(e,i+r+`
76
+ `,"utf-8"),!0}let n=(0,j.readFileSync)(e,"utf-8");if(n.includes(`'./${t}'`))return!1;let s=n.trimEnd()+`
77
+ `+r+`
78
+ `;return(0,j.writeFileSync)(e,s,"utf-8"),!0},gD=(e,t)=>{let r=`export * from './${t}'`;if(!(0,j.existsSync)(e))return(0,j.writeFileSync)(e,`/**
79
+ * Event Contracts Index
80
+ *
81
+ * Re-exports all event contracts for convenient importing.
82
+ */
83
+
84
+ `+r+`
85
+ `,"utf-8"),!0;let s=(0,j.readFileSync)(e,"utf-8").split(`
86
+ `);if(s.some(i=>i.trim()===r))return!1;let o=s.findLastIndex(i=>i.startsWith("export"));return o>=0?s.splice(o+1,0,r):s.push(r),(0,j.writeFileSync)(e,s.join(`
87
+ `),"utf-8"),!0},DD=e=>{if(!(0,j.existsSync)(e))return!1;let t=(0,j.readFileSync)(e,"utf-8"),r=t;return r=r.replace(/\/\/ export \* from '\.\/events'/,"export * from './events'"),r=r.replace(/\/\/ export \* from '\.\/stream-policies'/,"export * from './stream-policies'"),r!==t?((0,j.writeFileSync)(e,r,"utf-8"),!0):!1},ii=e=>{let{packagePath:t}=$(),r=e.split(".")[0],n=e.split(".").slice(1).join("-"),s=(0,Zt.join)(t,"src","events"),o=(0,Zt.join)(s,r),i=(0,Zt.join)(o,"index.ts"),a=(0,Zt.join)(s,"index.ts"),c=(0,Zt.join)(t,"src","index.ts"),l=!1;return mD(i,n)&&(l=!0),gD(a,r)&&(l=!0),DD(c)&&(l=!0),l},ai=(e,t)=>{if(!(0,j.existsSync)(e))return!1;let r=`export * from './events/${t}'`,n=(0,j.readFileSync)(e,"utf-8");if(n.includes(`'./events/${t}'`))return!1;let s=n.split(`
88
+ `),o=s.findLastIndex(i=>i.startsWith("export"));return o>=0?s.splice(o+1,0,r):s.push("",r),(0,j.writeFileSync)(e,s.join(`
89
+ `),"utf-8"),!0};var z=require("node:fs"),$t=require("node:path"),F=require("@faker-js/faker");var Jl=[{pattern:"email",generate:()=>F.faker.internet.email(),hint:"email"},{pattern:"id",generate:()=>F.faker.string.uuid(),hint:"uuid"},{pattern:"firstname",generate:()=>F.faker.person.firstName(),hint:"firstName"},{pattern:"lastname",generate:()=>F.faker.person.lastName(),hint:"lastName"},{pattern:"name",generate:()=>F.faker.person.fullName(),hint:"fullName"},{pattern:"phone",generate:()=>F.faker.phone.number(),hint:"phoneNumber"},{pattern:"address",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"street",generate:()=>F.faker.location.streetAddress(),hint:"streetAddress"},{pattern:"city",generate:()=>F.faker.location.city(),hint:"city"},{pattern:"country",generate:()=>F.faker.location.country(),hint:"country"},{pattern:"price",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"amount",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"total",generate:()=>F.faker.number.float({min:10,max:1e3,fractionDigits:2}),hint:"price"},{pattern:"quantity",generate:()=>F.faker.number.int({min:1,max:10}),hint:"quantity"},{pattern:"date",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"createdat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"},{pattern:"updatedat",generate:()=>F.faker.date.recent().toISOString(),hint:"date"}],ql=e=>({email:()=>F.faker.internet.email(),datetime:()=>F.faker.date.recent().toISOString(),url:()=>F.faker.internet.url(),uuid:()=>F.faker.string.uuid(),date:()=>F.faker.date.recent().toISOString().split("T")[0],time:()=>F.faker.date.recent().toISOString().split("T")[1]?.split(".")[0]})[e]?.()??F.faker.lorem.word(),Vl=e=>{let t=e.toLowerCase(),r=Jl.find(n=>t.includes(n.pattern));return r?{value:r.generate(),hint:r.hint}:null},yD=(e,t)=>{if(e.format)return ql(e.format);let r=Vl(t);if(r)return r.value;switch(e.type){case"string":return F.faker.lorem.word();case"number":return F.faker.number.int({min:1,max:100});case"boolean":return F.faker.datatype.boolean();case"array":return e.element?[ci(e.element)]:[];case"object":return ci(e);default:return null}},ci=e=>{let t={},r=e.shape??(typeof e.def?.shape=="function"?e.def.shape():void 0);if(!r)return t;for(let[n,s]of Object.entries(r))t[n]=yD(s,n);return t},wD=async e=>{try{let{createJiti:t}=await import("jiti"),n=t(process.cwd(),{interopDefault:!0})(e),s=Object.entries(n).find(([o])=>o.endsWith("Schema")||o==="schema");if(s?.[1]){let o=s[1],i=ci(o);if(i&&typeof i=="object"&&Object.keys(i).length>0){let a={};return li(i,a,""),{data:i,faker:a}}}}catch{}return null},li=(e,t,r)=>{if(!(!e||typeof e!="object"))for(let[n,s]of Object.entries(e)){let o=r?`${r}.${n}`:n,i=n.toLowerCase(),a=Jl.find(c=>i.includes(c.pattern));a&&(a.hint!=="uuid"||typeof s=="string")&&(t[o]=a.hint),typeof s=="object"&&s!==null&&!Array.isArray(s)?li(s,t,o):Array.isArray(s)&&s.length>0&&typeof s[0]=="object"&&li(s[0],t,`${o}[0]`)}},CD=e=>({string:()=>F.faker.lorem.word(),number:()=>F.faker.number.int({min:1,max:100}),boolean:()=>F.faker.datatype.boolean()})[e]?.(),bD=(e,t,r)=>{let n=/(\w+):\s*z\.(\w+)\(/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s){if(i==="array"||i==="object")continue;let a=Vl(o);if(a)t[o]=a.value,a.hint&&(r[o]=a.hint);else{let c=CD(i);c!==void 0&&(t[o]=c)}}},xD=(e,t,r)=>{let n=/(\w+):\s*z\.string\(\)\.(datetime|email|url|uuid)\(\)/g,s=Array.from(e.matchAll(n));for(let[,o,i]of s)t[o]=ql(i),r[o]=i==="datetime"?"date":i},Yl=e=>{let t={},r={};return bD(e,t,r),xD(e,t,r),{data:t,faker:r}},gs=async e=>{let{eventsPath:t}=$(),r=or(e);if(!(0,z.existsSync)(r))return null;let s=(0,z.readFileSync)(r,"utf-8").match(/type:\s*['"]([^'"]+)['"]/),o=s?s[1]:e,i=await wD(r);if(!i){let d=Xo(e);d&&(i=Yl(d))}if(!i)return null;let a={eventName:o,description:`Mock data for ${o} event`,data:i.data};Object.keys(i.faker).length>0&&(a.faker=i.faker);let c=e.split(".")[0],l=e.split(".").slice(1).join("-"),u=(0,$t.join)(t,c,`${l}.mock.json`),p=(0,$t.join)(t,c);return(0,z.existsSync)(p)||(0,z.mkdirSync)(p,{recursive:!0}),(0,z.writeFileSync)(u,JSON.stringify(a,null,2),"utf-8"),u};var Zl=e=>{let t=e.match(/import\s+\{[^}]*?(\w+Contract)[^}]*?\}\s+from\s+['"][^'"]+\/contracts['"]/);return t?t[1].replace("Contract","").replace(/([A-Z])/g,(n,s,o)=>(o>0?".":"")+s.toLowerCase()):null},vD=(e,t,r)=>{if(!(0,z.existsSync)(e))return!1;let n=(0,z.readFileSync)(e,"utf-8"),s=n.match(/export const \w+(?:Schema|Data)\s*=\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m)??n.match(/schema:\s*z\.object\(\s*\{([\s\S]*?)\}\s*\)/m);if(!s)return!1;let o=Yl(s[1]),i={eventName:r,description:`Mock data for ${r} event`,data:o.data};return Object.keys(o.faker).length>0&&(i.faker=o.faker),(0,z.writeFileSync)(t,JSON.stringify(i,null,2)),!0},ui=async(e,t={})=>{let r=(0,$t.join)(e,"src","events");if(!(0,z.existsSync)(r))return{mockPaths:[],skippedHandlers:[]};let n=(0,z.readdirSync)(r).filter(i=>i.endsWith(".event.ts")).map(i=>(0,$t.join)(r,i)),s=[],o=[];for(let i of n){let a=(0,z.readFileSync)(i,"utf-8"),c=Zl(a);if(!c){o.push(`${(0,$t.basename)(i)} (Handler does not use contracts)`);continue}let{eventName:l}=sr(c),u=t.outputDir??$().eventsPath,p=(0,$t.join)(u,`${l}.mock.json`);if((0,z.existsSync)(p)&&!t.overwrite){o.push(`${(0,$t.basename)(i)} (Mock already exists)`);continue}if(t.outputDir){let f=(0,$t.join)(t.outputDir,`${l}.ts`);vD(f,p,c)&&s.push(p);continue}let d=await gs(c);d&&s.push(d)}return{mockPaths:s,skippedHandlers:o}};var tu=e=>{let t=e.split("/").pop()||"service",r=(0,Xl.join)(e,"src","events","events.service.ts");if(!(0,Ds.existsSync)(r))return!1;let n=ni(e);if(n.length===0||(0,Ds.readFileSync)(r,"utf-8").replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").includes("consumeJetStreams"))return!1;let a=si(n),c=oi(a,t);if(!c)return!1;let l=new Ql.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),u=l.addSourceFileAtPath(r),p=!1;for(let d of u.getClasses()){let f=d.getMethod("startConsumers");if(!f)continue;let h=[...c.split(`
81
90
  `),""," this.logger.log('Event consumers started successfully')"].join(`
82
- `);f.setBodyText(h),p=!0;break}return p&&u.saveSync(),p};var cD=e=>{let t=e.split(/\s+/),r=t[0],n=t.slice(1);return r==="pf"&&(r=process.argv[1]),{executable:r,args:n}},uD=async(e,t)=>{try{let{executable:r,args:n}=cD(e.command);return await fe(r,n,{cwd:t,shell:!1}),{command:e.command,success:!0}}catch(r){return{command:e.command,success:!1,error:r instanceof Error?r.message:String(r)}}},ai=async(e,t)=>{let r=[];for(let n of e){let s=await uD(n,t);if(r.push(s),!s.success)break}return r},ci=e=>{let t=[/^pf\s+/,/^bun\s+pf\s+/,/^npx\s+pf\s+/,/^bunx\s+pf\s+/];return e.filter(r=>t.some(n=>n.test(r.command)))},Zu=e=>{for(let t of e){let r=t.command.match(/(?:bun\s+)?pf\s+new\s+\S+\s+(\S+)/);if(r)return r[1]}return null};var cn=require("node:fs"),ys=require("node:path"),$t=b(require("chalk"));var ke=require("node:fs"),Ds=require("node:path"),lD=(e,t)=>{let n=e.path.startsWith("packages/")&&t.workspaceRoot?t.workspaceRoot:t.baseDir,s=(0,Ds.join)(n,e.path);try{if((0,ke.existsSync)(s)&&!t.overwrite)return{status:"skipped",path:e.path};if(t.dryRun)return{status:"written",path:e.path};let o=(0,Ds.dirname)(s);return(0,ke.existsSync)(o)||(0,ke.mkdirSync)(o,{recursive:!0}),(0,ke.writeFileSync)(s,e.content,"utf-8"),{status:"written",path:e.path}}catch(o){return{status:"failed",path:e.path,error:o.message}}},Xu=(e,t)=>{let r=e.map(n=>lD(n,t));return{written:r.filter(n=>n.status==="written").map(n=>n.path),skipped:r.filter(n=>n.status==="skipped").map(n=>n.path),failed:r.filter(n=>n.status==="failed").map(n=>({path:n.path,error:n.error}))}};var pD=(e,t)=>{let r=vt(t.workspaceRoot),n=(0,ys.join)(t.workspaceRoot,r.contracts);if(!(0,cn.existsSync)(n))return[];let s=/import\s+(?:type\s+)?{([^}]+)}\s+from\s+['"]@\w+\/contracts['"]/g,o=new Set;for(let i of e){let a=i.content.matchAll(s);for(let c of a){let l=c[1].split(",").map(p=>p.trim()).map(p=>p.replace(/^type\s+/,"").replace(/\s+as\s+.+$/,"").trim()).filter(p=>p.endsWith("Contract"));for(let p of l)o.add(p)}}return Array.from(o).sort()},fD=e=>{let t=(0,ys.join)(e,"packages/contracts/src/index.ts");if(!(0,cn.existsSync)(t))return new Set;try{let r=(0,cn.readFileSync)(t,"utf-8"),n=new Set,s=/export\s+(?:\*|{[^}]*Contract[^}]*})\s+from\s+['"]\.\/events\/([^'"]+)['"]/g,o=r.matchAll(s);for(let i of o){let a=i[0],c=/(\w+Contract)/g,u=a.matchAll(c);for(let l of u)n.add(l[1])}return n}catch{return new Set}},dD=e=>{let t=e.replace(/Contract$/,""),r=t.split(/(?=[A-Z])/).filter(Boolean);if(r.length<2)return t.toLowerCase();let n=r[0].toLowerCase(),s=r.slice(1).join("").toLowerCase();return`${n}.${s}`},hD=(e,t,r)=>{let n=fD(t),s=[],o=[],i=[];for(let a of e)if(n.has(a))s.push(a);else{o.push(a);let c=dD(a),u=r.replace(`${t}/`,"");i.push(`pf event add ${c} --service ${u}`)}return{existing:s,missing:o,suggestedCommands:i}},mD=(e,t)=>{if(e.length!==0){console.log($t.default.cyan(`\u{1F4E6} Using existing contracts:
83
- `));for(let r of e)console.log($t.default.dim(` ${t}/contracts \u2192 ${r}`));console.log()}},gD=(e,t)=>{let r=/^packages\/contracts\/src\/events\/([^/]+)\.ts$/,n=(0,ys.join)(t,"packages/contracts/src/index.ts");for(let s of e){let o=s.match(r);o&&o[1]!=="index"&&hs(n,o[1])}},Qu=async(e,t)=>{t.start("Applying code formatting...");try{await qt("biome",["check","--fix","--unsafe","."],{cwd:e,quiet:!0}),t.succeed("Code formatted!")}catch{t.warn("Code formatting completed with warnings")}},DD=async(e,t)=>{t.start("Scanning for event handlers...");let{mockPaths:r,skippedHandlers:n}=await ii(e);if(r.length+n.length===0){t.info("No event handlers found");return}if(r.length>0){t.succeed(`Generated ${r.length} event ${r.length===1?"mock":"mocks"}`),console.log();for(let o of r){let i=o.replace(`${e}/`,"");console.log($t.default.dim(` ${i}`))}console.log()}else t.succeed("Event handlers found");if(n.length>0){for(let o of n)console.log($t.default.dim(` \u2139 Skipped: ${o}`));console.log()}},tl=async(e,t,r,n)=>{n.start("Writing generated files...");let s=Xu(e,{baseDir:t,workspaceRoot:r.workspaceRoot,overwrite:!0});if(s.written.length>0){n.succeed(`Created ${s.written.length} files`),console.log();for(let u of s.written)console.log($t.default.dim(` ${u}`));console.log()}else n.succeed("No files to write");let o=pD(e,r),{existing:i,missing:a,suggestedCommands:c}=hD(o,r.workspaceRoot,t);if(i.length>0&&mD(i,r.scope),a.length>0){console.log($t.default.yellow(`\u26A0\uFE0F Missing contracts (not exported from @${r.scope}/contracts):
84
- `));for(let u of a)console.log($t.default.yellow(` ${u}`));console.log(),console.log($t.default.cyan(`\u{1F4A1} Run these commands to create the missing contracts:
85
- `));for(let u of c)console.log($t.default.dim(` ${u}`));console.log()}return gD(s.written,r.workspaceRoot),s.written.length>0&&await DD(t,n),{missingContractCommands:c}};var ws=require("node:fs"),or=require("node:path");var sr=require("node:fs"),el=require("node:path");var rl=e=>{let{eventsPath:t}=G(e);if(!(0,sr.existsSync)(t))return[];let r=[];try{let n=(0,sr.readdirSync)(t).filter(s=>s.endsWith(".ts")&&!s.endsWith(".mock.json")&&s!=="index.ts");for(let s of n){let o=(0,el.join)(t,s),i=(0,sr.readFileSync)(o,"utf-8"),a=yD(i,o);a&&r.push(a)}}catch(n){return console.warn("Warning: Could not scan contracts package:",n),[]}return r},yD=(e,t)=>{try{let r=e.match(/export const (\w+Contract) = createContract/);if(!r)return null;let n=r[1],s=e.match(/export type (\w+(?:Data|Event)) = z\.infer/);if(!s)return null;let o=s[1],i=e.match(/type:\s*['"]([^'"]+)['"]/);if(!i)return null;let a=i[1],c=CD(e);return{name:n,typeName:o,eventType:a,fields:c,filePath:t}}catch{return null}},wD={string:"string",number:"number",boolean:"boolean",array:"array",object:"object",date:"date"},CD=e=>{let t=e.match(/z\.object\({([^}]+)\}/);if(!t)return[];let r=t[1],n=/(\w+):\s*z\.(\w+)\([^)]*\)/g,s=[...r.matchAll(n)].map(([,a,c])=>{let u=wD[c]||c;return`${a}: ${u}`});if(!e.includes("z.array("))return s;let o=/(\w+):\s*z\.array\(/g,i=[...e.matchAll(o)].map(([,a])=>a).filter(a=>!s.some(c=>c.startsWith(a))).map(a=>`${a}: array`);return[...s,...i]},nl=(e,t)=>{if(e.length===0)return`
91
+ `);f.setBodyText(h),p=!0;break}return p&&l.saveSync(),p};var kD=e=>{let t=e.split(/\s+/),r=t[0],n=t.slice(1);return r==="pf"&&(r=process.argv[1]),{executable:r,args:n}},ED=async(e,t)=>{try{let{executable:r,args:n}=kD(e.command);return await de(r,n,{cwd:t,shell:!1}),{command:e.command,success:!0}}catch(r){return{command:e.command,success:!1,error:r instanceof Error?r.message:String(r)}}},pi=async(e,t)=>{let r=[];for(let n of e){let s=await ED(n,t);if(r.push(s),!s.success)break}return r},fi=e=>{let t=[/^pf\s+/,/^bun\s+pf\s+/,/^npx\s+pf\s+/,/^bunx\s+pf\s+/];return e.filter(r=>t.some(n=>n.test(r.command)))},eu=e=>{for(let t of e){let r=t.command.match(/(?:bun\s+)?pf\s+new\s+\S+\s+(\S+)/);if(r)return r[1]}return null};var un=require("node:fs"),ws=require("node:path"),Bt=b(require("chalk"));var Se=require("node:fs"),ys=require("node:path"),SD=(e,t)=>{let n=e.path.startsWith("packages/")&&t.workspaceRoot?t.workspaceRoot:t.baseDir,s=(0,ys.join)(n,e.path);try{if((0,Se.existsSync)(s)&&!t.overwrite)return{status:"skipped",path:e.path};if(t.dryRun)return{status:"written",path:e.path};let o=(0,ys.dirname)(s);return(0,Se.existsSync)(o)||(0,Se.mkdirSync)(o,{recursive:!0}),(0,Se.writeFileSync)(s,e.content,"utf-8"),{status:"written",path:e.path}}catch(o){return{status:"failed",path:e.path,error:o.message}}},ru=(e,t)=>{let r=e.map(n=>SD(n,t));return{written:r.filter(n=>n.status==="written").map(n=>n.path),skipped:r.filter(n=>n.status==="skipped").map(n=>n.path),failed:r.filter(n=>n.status==="failed").map(n=>({path:n.path,error:n.error}))}};var FD=(e,t)=>{let r=kt(t.workspaceRoot),n=(0,ws.join)(t.workspaceRoot,r.contracts);if(!(0,un.existsSync)(n))return[];let s=/import\s+(?:type\s+)?{([^}]+)}\s+from\s+['"]@\w+\/contracts['"]/g,o=new Set;for(let i of e){let a=i.content.matchAll(s);for(let c of a){let u=c[1].split(",").map(p=>p.trim()).map(p=>p.replace(/^type\s+/,"").replace(/\s+as\s+.+$/,"").trim()).filter(p=>p.endsWith("Contract"));for(let p of u)o.add(p)}}return Array.from(o).sort()},TD=e=>{let t=(0,ws.join)(e,"packages/contracts/src/index.ts");if(!(0,un.existsSync)(t))return new Set;try{let r=(0,un.readFileSync)(t,"utf-8"),n=new Set,s=/export\s+(?:\*|{[^}]*Contract[^}]*})\s+from\s+['"]\.\/events\/([^'"]+)['"]/g,o=r.matchAll(s);for(let i of o){let a=i[0],c=/(\w+Contract)/g,l=a.matchAll(c);for(let u of l)n.add(u[1])}return n}catch{return new Set}},AD=e=>{let t=e.replace(/Contract$/,""),r=t.split(/(?=[A-Z])/).filter(Boolean);if(r.length<2)return t.toLowerCase();let n=r[0].toLowerCase(),s=r.slice(1).join("").toLowerCase();return`${n}.${s}`},PD=(e,t,r)=>{let n=TD(t),s=[],o=[],i=[];for(let a of e)if(n.has(a))s.push(a);else{o.push(a);let c=AD(a),l=r.replace(`${t}/`,"");i.push(`pf event add ${c} --service ${l}`)}return{existing:s,missing:o,suggestedCommands:i}},RD=(e,t)=>{if(e.length!==0){console.log(Bt.default.cyan(`\u{1F4E6} Using existing contracts:
92
+ `));for(let r of e)console.log(Bt.default.dim(` ${t}/contracts \u2192 ${r}`));console.log()}},ID=(e,t)=>{let r=/^packages\/contracts\/src\/events\/([^/]+)\.ts$/,n=(0,ws.join)(t,"packages/contracts/src/index.ts");for(let s of e){let o=s.match(r);o&&o[1]!=="index"&&ai(n,o[1])}},nu=async(e,t)=>{t.start("Applying code formatting...");try{await Yt("biome",["check","--fix","--unsafe","."],{cwd:e,quiet:!0}),t.succeed("Code formatted!")}catch{t.warn("Code formatting completed with warnings")}},ND=async(e,t)=>{t.start("Scanning for event handlers...");let{mockPaths:r,skippedHandlers:n}=await ui(e);if(r.length+n.length===0){t.info("No event handlers found");return}if(r.length>0){t.succeed(`Generated ${r.length} event ${r.length===1?"mock":"mocks"}`),console.log();for(let o of r){let i=o.replace(`${e}/`,"");console.log(Bt.default.dim(` ${i}`))}console.log()}else t.succeed("Event handlers found");if(n.length>0){for(let o of n)console.log(Bt.default.dim(` \u2139 Skipped: ${o}`));console.log()}},su=async(e,t,r,n)=>{n.start("Writing generated files...");let s=ru(e,{baseDir:t,workspaceRoot:r.workspaceRoot,overwrite:!0});if(s.written.length>0){n.succeed(`Created ${s.written.length} files`),console.log();for(let l of s.written)console.log(Bt.default.dim(` ${l}`));console.log()}else n.succeed("No files to write");let o=FD(e,r),{existing:i,missing:a,suggestedCommands:c}=PD(o,r.workspaceRoot,t);if(i.length>0&&RD(i,r.scope),a.length>0){console.log(Bt.default.yellow(`\u26A0\uFE0F Missing contracts (not exported from @${r.scope}/contracts):
93
+ `));for(let l of a)console.log(Bt.default.yellow(` ${l}`));console.log(),console.log(Bt.default.cyan(`\u{1F4A1} Run these commands to create the missing contracts:
94
+ `));for(let l of c)console.log(Bt.default.dim(` ${l}`));console.log()}return ID(s.written,r.workspaceRoot),s.written.length>0&&await ND(t,n),{missingContractCommands:c}};var Cs=require("node:fs"),cr=require("node:path");var ar=require("node:fs"),ou=require("node:path");var iu=e=>{let{eventsPath:t}=$(e);if(!(0,ar.existsSync)(t))return[];let r=[];try{let n=(0,ar.readdirSync)(t).filter(s=>s.endsWith(".ts")&&!s.endsWith(".mock.json")&&s!=="index.ts");for(let s of n){let o=(0,ou.join)(t,s),i=(0,ar.readFileSync)(o,"utf-8"),a=OD(i,o);a&&r.push(a)}}catch(n){return console.warn("Warning: Could not scan contracts package:",n),[]}return r},OD=(e,t)=>{try{let r=e.match(/export const (\w+Contract) = createContract/);if(!r)return null;let n=r[1],s=e.match(/export type (\w+(?:Data|Event)) = z\.infer/);if(!s)return null;let o=s[1],i=e.match(/type:\s*['"]([^'"]+)['"]/);if(!i)return null;let a=i[1],c=$D(e);return{name:n,typeName:o,eventType:a,fields:c,filePath:t}}catch{return null}},MD={string:"string",number:"number",boolean:"boolean",array:"array",object:"object",date:"date"},$D=e=>{let t=e.match(/z\.object\({([^}]+)\}/);if(!t)return[];let r=t[1],n=/(\w+):\s*z\.(\w+)\([^)]*\)/g,s=[...r.matchAll(n)].map(([,a,c])=>{let l=MD[c]||c;return`${a}: ${l}`});if(!e.includes("z.array("))return s;let o=/(\w+):\s*z\.array\(/g,i=[...e.matchAll(o)].map(([,a])=>a).filter(a=>!s.some(c=>c.startsWith(a))).map(a=>`${a}: array`);return[...s,...i]},au=(e,t)=>{if(e.length===0)return`
86
95
  **Available Contracts:**
87
96
 
88
97
  No contracts are currently defined. Use Basic Mode with inline schemas for all events.
@@ -103,15 +112,15 @@ The following event contracts are available in \`${t}/contracts\`:
103
112
  ${r}
104
113
 
105
114
  If the event type your service consumes matches one of these, **you MUST use Advanced Mode**.
106
- `.trim()};var bD=(e,t)=>{let r=(0,or.join)(__dirname,"docs","generators"),n=Xr(),s=[];for(let o of n.docs.base)s.push((0,or.join)(r,o));if(e&&n.docs.frameworks[e]){let o=n.docs.frameworks[e];if(typeof o=="string")s.push((0,or.join)(r,o));else{let i=t==="bun"?"bun":"node";o[i]&&s.push((0,or.join)(r,o[i]))}}return s},sl={copilot:".github/copilot-instructions.md",projectGuidelines:"docs/ai-guidelines.md"},vD=1500,ol=e=>{try{return(0,ws.existsSync)(e)?(0,ws.readFileSync)(e,"utf-8"):null}catch{return null}},xD=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/\n{3,}/g,`
115
+ `.trim()};var BD=(e,t)=>{let r=(0,cr.join)(__dirname,"docs","generators"),n=tn(),s=[];for(let o of n.docs.base)s.push((0,cr.join)(r,o));if(e&&n.docs.frameworks[e]){let o=n.docs.frameworks[e];if(typeof o=="string")s.push((0,cr.join)(r,o));else{let i=t==="bun"?"bun":"node";o[i]&&s.push((0,cr.join)(r,o[i]))}}return s},cu={copilot:".github/copilot-instructions.md",projectGuidelines:"docs/ai-guidelines.md"},jD=1500,lu=e=>{try{return(0,Cs.existsSync)(e)?(0,Cs.readFileSync)(e,"utf-8"):null}catch{return null}},_D=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/\n{3,}/g,`
107
116
 
108
- `).replace(/[ \t]+$/gm,"").trim(),kD=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]{50,}`/g,"`...`").replace(/\n{3,}/g,`
117
+ `).replace(/[ \t]+$/gm,"").trim(),LD=e=>e.replace(/<!--[\s\S]*?-->/g,"").replace(/^\[.+\]:\s*.+$/gm,"").replace(/```[\s\S]*?```/g,"").replace(/`[^`]{50,}`/g,"`...`").replace(/\n{3,}/g,`
109
118
 
110
- `).replace(/[ \t]+$/gm,"").trim(),ED=e=>Math.ceil(e.length/4),SD=(e,t)=>{let r=e.split(/(?=^## )/m),n="",s=0;for(let o of r){let i=ED(o);if(s+i<=t)n+=o,s+=i;else if(s===0){n=o.slice(0,t*4);break}else break}return n.trim()},FD=(e,t)=>{let{workspaceRoot:r,scope:n}=t,s=rl(r),o=nl(s,n);return e.replace(/\{\{scope\}\}/g,n).replace(/\{\{AVAILABLE_CONTRACTS\}\}/g,o)},il=e=>{let{workspaceRoot:t,scope:r}=e,n=[],s=bD(e.serviceType,e.packageManager);for(let a of s){let c=ol(a);if(c){let u=FD(c,e),l=xD(u);n.push(l)}}let o=[sl.copilot,sl.projectGuidelines],i=Math.floor(vD/o.length);for(let a of o){let c=ol((0,or.join)(t,a));if(c){let u=kD(c),l=SD(u,i);l.length>50&&n.push(l)}}return n.length===0?(console.warn("\u26A0\uFE0F No instruction files found."),`Use ${r}/contracts for shared types.`):n.join(`
119
+ `).replace(/[ \t]+$/gm,"").trim(),WD=e=>Math.ceil(e.length/4),GD=(e,t)=>{let r=e.split(/(?=^## )/m),n="",s=0;for(let o of r){let i=WD(o);if(s+i<=t)n+=o,s+=i;else if(s===0){n=o.slice(0,t*4);break}else break}return n.trim()},HD=(e,t)=>{let{workspaceRoot:r,scope:n}=t,s=iu(r),o=au(s,n);return e.replace(/\{\{scope\}\}/g,n).replace(/\{\{AVAILABLE_CONTRACTS\}\}/g,o)},uu=e=>{let{workspaceRoot:t,scope:r}=e,n=[],s=BD(e.serviceType,e.packageManager);for(let a of s){let c=lu(a);if(c){let l=HD(c,e),u=_D(l);n.push(u)}}let o=[cu.copilot,cu.projectGuidelines],i=Math.floor(jD/o.length);for(let a of o){let c=lu((0,cr.join)(t,a));if(c){let l=LD(c),u=GD(l,i);u.length>50&&n.push(u)}}return n.length===0?(console.warn("\u26A0\uFE0F No instruction files found."),`Use ${r}/contracts for shared types.`):n.join(`
111
120
 
112
121
  ---
113
122
 
114
- `)};var TD=`You are an expert code generator. Generate clean, production-ready code.
123
+ `)};var UD=`You are an expert code generator. Generate clean, production-ready code.
115
124
 
116
125
  ## Output Format
117
126
 
@@ -125,72 +134,74 @@ Format your code blocks with the file path on the line before the code block:
125
134
  **IMPORTANT:** Always generate:
126
135
  - Source code files (src/**)
127
136
  - Test files (src/**/*.test.ts) for all business logic
128
- - README.md with service documentation`,AD=e=>e.replace(/-/g,"_").toUpperCase(),PD=e=>e.split("/").pop()||"my-service",al=(e,t,r)=>{let n=il({...e,serviceType:t,packageManager:r});return`${TD}
137
+ - README.md with service documentation`,zD=e=>e.replace(/-/g,"_").toUpperCase(),KD=e=>e.split("/").pop()||"my-service",pu=(e,t,r)=>{let n=uu({...e,serviceType:t,packageManager:r});return`${UD}
129
138
 
130
139
  ## Project Guidelines & Patterns
131
140
 
132
141
  Follow these project-specific conventions and patterns when generating code:
133
142
 
134
- ${n}`},cl=(e,t,r)=>{let n=PD(e),s=`${AD(n)}_PORT`;return`Generate source code for a microservice at path "${e}".
143
+ ${n}`},fu=(e,t,r,n)=>{let s=KD(e),o=`${zD(s)}_PORT`;return`Generate source code for a microservice at path "${e}".
135
144
 
136
145
  Use the patterns and conventions from the Project Guidelines above.
137
146
 
138
147
  Service purpose: ${t}
139
148
 
140
149
  **CRITICAL:**
141
- - Service name: "${n}"
142
- - Port env var: Use \`process.env.${s}\` (NOT SERVICE_NAME_PORT)
143
- - Consumer name: Use "${n}" as the consumer name in consumeJetStreams
150
+ - Service name: "${s}"
151
+ - Port env var: Use \`process.env.${o}\` (NOT SERVICE_NAME_PORT)
152
+ - Consumer name: Use "${s}" as the consumer name in consumeJetStreams
153
+ - You MAY modify \`src/index.ts\` or \`src/main.ts\` to add consumeJetStreams, env validation, or middleware
154
+ - BUT you MUST keep the existing port configuration line unchanged!
144
155
 
145
156
  Do NOT include the service path in file headers (use \`src/...\`, NOT \`${e}/src/...\`).
146
- `};var RD=()=>!1,ul=(e,t)=>{RD()&&console.log(`[AI Parser] ${e}`,t??"")},Cs={commandsBlock:/```commands\n([\s\S]*?)```/gi,postCommandsBlock:/```post-commands\n([\s\S]*?)```/gi,dependenciesBlock:/```dependencies\n([\s\S]*?)```/gi,fileHeader:/^#{1,4}\s+`([^`]+)`\s*$/},li=(e,t)=>[...e.matchAll(t)].flatMap(n=>n[1].split(`
147
- `).map(s=>s.trim()).filter(s=>s.length>0&&!s.startsWith("#"))),ll=e=>({command:e,isPfCommand:e.startsWith("pf ")||e.includes(" pf ")}),ID=e=>li(e,Cs.commandsBlock).map(ll),ND=e=>li(e,Cs.postCommandsBlock).map(ll),OD=e=>li(e,Cs.dependenciesBlock).filter(t=>!t.startsWith("@crossdelta/")&&t!=="zod"),MD=e=>{let t={ts:"typescript",js:"javascript",md:"markdown",yml:"yaml"},r=(e||"typescript").toLowerCase();return t[r]||r},$D=e=>{let t=e.split(".").pop()?.toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",yaml:"yaml",yml:"yaml",md:"markdown"}[t||""]||"plaintext"},BD=e=>e.replace(/^\s*\/\/ \.{3,}.*$/gm,"").replace(/^\s*\/\/ Lines? \d+.*omitted.*$/gim,"").replace(/^\s*\/\* Lines? \d+.*omitted.*\*\/$/gim,"").trim(),jD=e=>{let t=e.split(`
148
- `),r=[],n=0;for(let s of t){let o=Cs.fileHeader.exec(s);o&&r.push({path:o[1],index:n}),n+=s.length+1}return r},_D=(e,t)=>{let n=e.slice(t).match(/```(\w+)?\n([\s\S]*?)```/);return n?{language:n[1]?MD(n[1]):void 0,content:BD(n[2])}:null},LD=e=>jD(e).map(r=>{let n=_D(e,r.index);return!n||n.content.length===0?null:{path:r.path,language:n.language||$D(r.path),content:n.content,startIndex:r.index}}).filter(r=>r!==null),ui=e=>e.includes("packages/contracts")||e.includes("contracts/src"),WD=e=>{let t=e.filter(n=>ui(n.path)),r=e.filter(n=>!ui(n.path));return[...t,...r]},GD=e=>{let t=e.replace(/^\/+/,"").replace(/\/{2,}/g,"/");if(ui(t))return t;let r=t.match(/^services\/[^/]+\/(.+)$/);return r?r[1]:t},pl=(e,t)=>{ul("Parsing AI response",{length:e.length});let r=ID(e),n=ND(e),s=OD(e),o=LD(e),i=WD(o.map(a=>({path:GD(a.path),content:a.content,language:a.language})));return ul("Parsed response",{commands:r.length,postCommands:n.length,dependencies:s.length,files:i.length}),{commands:r,files:i,dependencies:s,postCommands:n}},fl=e=>{let t=e.filter(o=>!o.content||o.content.trim().length===0),r=e.length===0?["No files could be extracted from the AI response"]:t.map(o=>`File ${o.path} is empty`),n=e.some(o=>["src/index.ts","src/main.ts","index.ts"].includes(o.path)),s=e.length>0&&!n?["No entry point file (src/index.ts or src/main.ts) found - assuming it exists from scaffolding"]:[];return{valid:r.length===0,errors:r,warnings:s}};var dl=require("node:fs"),Et=b(require("chalk"));var hl=async(e,t,r)=>{if(e.length===0){(0,dl.mkdirSync)(t,{recursive:!0}),console.log(Et.default.yellow(`\u26A0 No scaffolding command found - creating empty directory
149
- `));return}let s=(await ai(e,r)).find(o=>!o.success);if(s)throw console.log(Et.default.red(`
150
- \u2717 Scaffolding failed: ${s.command}`)),s.error&&console.log(Et.default.red(` Error: ${s.error}`)),new Error(`Command failed: ${s.command}${s.error?` - ${s.error}`:""}`)},ml=async(e,t)=>{t.start("Linking workspace dependencies...");try{await xt({cwd:e,quiet:!0}),t.succeed("Workspace dependencies linked")}catch{let r=$();t.warn(`Workspace sync skipped (run ${r} install manually)`)}},gl=async(e,t,r)=>{if(e.length===0)return;r.stop();let n=e.length===1?"package":"packages";console.log(Et.default.cyan(`
157
+ `};var JD=()=>!1,du=(e,t)=>{JD()&&console.log(`[AI Parser] ${e}`,t??"")},bs={commandsBlock:/```commands\n([\s\S]*?)```/gi,postCommandsBlock:/```post-commands\n([\s\S]*?)```/gi,dependenciesBlock:/```dependencies\n([\s\S]*?)```/gi,fileHeader:/^#{1,4}\s+`([^`]+)`\s*$/},hi=(e,t)=>[...e.matchAll(t)].flatMap(n=>n[1].split(`
158
+ `).map(s=>s.trim()).filter(s=>s.length>0&&!s.startsWith("#"))),hu=e=>({command:e,isPfCommand:e.startsWith("pf ")||e.includes(" pf ")}),qD=e=>hi(e,bs.commandsBlock).map(hu),VD=e=>hi(e,bs.postCommandsBlock).map(hu),YD=e=>hi(e,bs.dependenciesBlock).filter(t=>!t.startsWith("@crossdelta/")&&t!=="zod"),ZD=e=>{let t={ts:"typescript",js:"javascript",md:"markdown",yml:"yaml"},r=(e||"typescript").toLowerCase();return t[r]||r},XD=e=>{let t=e.split(".").pop()?.toLowerCase();return{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",yaml:"yaml",yml:"yaml",md:"markdown"}[t||""]||"plaintext"},QD=e=>e.replace(/^\s*\/\/ \.{3,}.*$/gm,"").replace(/^\s*\/\/ Lines? \d+.*omitted.*$/gim,"").replace(/^\s*\/\* Lines? \d+.*omitted.*\*\/$/gim,"").trim(),ty=e=>{let t=e.split(`
159
+ `),r=[],n=0;for(let s of t){let o=bs.fileHeader.exec(s);o&&r.push({path:o[1],index:n}),n+=s.length+1}return r},ey=(e,t)=>{let n=e.slice(t).match(/```(\w+)?\n([\s\S]*?)```/);return n?{language:n[1]?ZD(n[1]):void 0,content:QD(n[2])}:null},ry=e=>ty(e).map(r=>{let n=ey(e,r.index);return!n||n.content.length===0?null:{path:r.path,language:n.language||XD(r.path),content:n.content,startIndex:r.index}}).filter(r=>r!==null),di=e=>e.includes("packages/contracts")||e.includes("contracts/src"),ny=e=>{let t=e.filter(n=>di(n.path)),r=e.filter(n=>!di(n.path));return[...t,...r]},sy=e=>{let t=e.replace(/^\/+/,"").replace(/\/{2,}/g,"/");if(di(t))return t;let r=t.match(/^services\/[^/]+\/(.+)$/);return r?r[1]:t},mu=(e,t)=>{du("Parsing AI response",{length:e.length});let r=qD(e),n=VD(e),s=YD(e),o=ry(e),i=ny(o.map(a=>({path:sy(a.path),content:a.content,language:a.language})));return du("Parsed response",{commands:r.length,postCommands:n.length,dependencies:s.length,files:i.length}),{commands:r,files:i,dependencies:s,postCommands:n}},gu=e=>{let t=e.filter(o=>!o.content||o.content.trim().length===0),r=e.length===0?["No files could be extracted from the AI response"]:t.map(o=>`File ${o.path} is empty`),n=e.some(o=>["src/index.ts","src/main.ts","index.ts"].includes(o.path)),s=e.length>0&&!n?["No entry point file (src/index.ts or src/main.ts) found - assuming it exists from scaffolding"]:[];return{valid:r.length===0,errors:r,warnings:s}};var Du=require("node:fs"),St=b(require("chalk"));var yu=async(e,t,r)=>{if(e.length===0){(0,Du.mkdirSync)(t,{recursive:!0}),console.log(St.default.yellow(`\u26A0 No scaffolding command found - creating empty directory
160
+ `));return}let s=(await pi(e,r)).find(o=>!o.success);if(s)throw console.log(St.default.red(`
161
+ \u2717 Scaffolding failed: ${s.command}`)),s.error&&console.log(St.default.red(` Error: ${s.error}`)),new Error(`Command failed: ${s.command}${s.error?` - ${s.error}`:""}`)},wu=async(e,t)=>{t.start("Linking workspace dependencies...");try{await Et({cwd:e,quiet:!0}),t.succeed("Workspace dependencies linked")}catch{let r=B();t.warn(`Workspace sync skipped (run ${r} install manually)`)}},Cu=async(e,t,r)=>{if(e.length===0)return;r.stop();let n=e.length===1?"package":"packages";console.log(St.default.cyan(`
151
162
  \u25B6 Installing ${e.length} additional ${n}...
152
- `));try{await xt({packages:e,cwd:t,flags:["--silent"]}),console.log(Et.default.green(`\u2713 Installed ${e.length} ${n}
153
- `))}catch(s){throw console.log(Et.default.red(`\u2717 Package installation failed
154
- `)),s}},pi=async(e,t)=>{if(e.length===0)return;console.log(Et.default.cyan(`
163
+ `));try{await Et({packages:e,cwd:t,flags:["--silent"]}),console.log(St.default.green(`\u2713 Installed ${e.length} ${n}
164
+ `))}catch(s){throw console.log(St.default.red(`\u2717 Package installation failed
165
+ `)),s}},mi=async(e,t)=>{if(e.length===0)return;console.log(St.default.cyan(`
155
166
  \u25B6 Running post-generation commands...
156
- `));let n=(await ai(e,t)).find(s=>!s.success);if(n){console.log(Et.default.yellow(`
157
- \u26A0 Post-command failed: ${n.command}`)),n.error&&console.log(Et.default.yellow(` Error: ${n.error}`));return}console.log(Et.default.green(`\u2713 Post-generation commands complete
158
- `))};var un=b(require("chalk")),HD=e=>`${un.default.dim(" \u2022 ")+un.default.cyan(e)}
159
- `,Dl=e=>un.default.dim(` \u2728 Generated ${un.default.white.bold(e)} tokens
160
- `),yl=()=>{let e="",t=0,r=Date.now(),n=[],s=()=>{let i=e.match(/####\s+`([^`]+)`/);if(!i)return!1;n.push(i[1]),process.stdout.write(HD(i[1]));let a=e.indexOf(i[0])+i[0].length;return e=e.slice(a),!0},o=i=>{e+=i,t++,s(),e.length>500&&(e=e.slice(-200))};return o.getStats=()=>{let i=((Date.now()-r)/1e3).toFixed(2),a=(t/Number.parseFloat(i)).toFixed(0);return{tokenCount:t,duration:i,tokensPerSec:a}},o.getFiles=()=>n,o};var UD=()=>{let e=O(),t=(0,ar.join)(e,"package.json"),r=(()=>{if(!(0,Zt.existsSync)(t))throw new Error("No package.json found in workspace root. Run from a valid workspace.");try{let s=JSON.parse((0,Zt.readFileSync)(t,"utf-8")).name;if(!s)throw new Error('package.json has no "name" field. Please add a name to your root package.json.');return s.startsWith("@")?s:`@${s}`}catch(n){throw n instanceof SyntaxError?new Error("Invalid JSON in package.json"):n}})();return{workspaceRoot:e,scope:r,cwd:process.cwd()}},zD=async(e,t,r,n,s,o)=>{let i=cl(r,n,s),a=al(t,s,o),c=yl(),u=await ju(e,i,{system:a,maxTokens:16384,temperature:.7,onToken:c}),l=c.getStats();return console.log(Dl(l.tokenCount)),console.log(),u},KD=(e,t)=>{let{serviceTypes:r}=Xr(),n=r[t]?.commandType;if(!n)return e;let s=Object.values(r).map(o=>o.commandType);return e.map(o=>{for(let i of s)if(i!==n&&o.command.includes(`pf new ${i}`))return{...o,command:o.command.replace(`pf new ${i}`,`pf new ${n}`)};return o})},JD=e=>e.length===0?"":`${[T.default.cyan(`
167
+ `));let n=(await pi(e,t)).find(s=>!s.success);if(n){console.log(St.default.yellow(`
168
+ \u26A0 Post-command failed: ${n.command}`)),n.error&&console.log(St.default.yellow(` Error: ${n.error}`));return}console.log(St.default.green(`\u2713 Post-generation commands complete
169
+ `))};var pn=b(require("chalk")),oy=e=>`${pn.default.dim(" \u2022 ")+pn.default.cyan(e)}
170
+ `,bu=e=>pn.default.dim(` \u2728 Generated ${pn.default.white.bold(e)} tokens
171
+ `),xu=()=>{let e="",t=0,r=Date.now(),n=[],s=()=>{let i=e.match(/####\s+`([^`]+)`/);if(!i)return!1;n.push(i[1]),process.stdout.write(oy(i[1]));let a=e.indexOf(i[0])+i[0].length;return e=e.slice(a),!0},o=i=>{e+=i,t++,s(),e.length>500&&(e=e.slice(-200))};return o.getStats=()=>{let i=((Date.now()-r)/1e3).toFixed(2),a=(t/Number.parseFloat(i)).toFixed(0);return{tokenCount:t,duration:i,tokensPerSec:a}},o.getFiles=()=>n,o};var iy=()=>{let e=O(),t=(0,ur.join)(e,"package.json"),r=(()=>{if(!(0,Xt.existsSync)(t))throw new Error("No package.json found in workspace root. Run from a valid workspace.");try{let s=JSON.parse((0,Xt.readFileSync)(t,"utf-8")).name;if(!s)throw new Error('package.json has no "name" field. Please add a name to your root package.json.');return s.startsWith("@")?s:`@${s}`}catch(n){throw n instanceof SyntaxError?new Error("Invalid JSON in package.json"):n}})();return{workspaceRoot:e,scope:r,cwd:process.cwd()}},ay=async(e,t,r,n,s,o)=>{let i=fu(r,n,s,t.workspaceRoot),a=pu(t,s,o),c=xu(),l=await Gl(e,i,{system:a,maxTokens:16384,temperature:.7,onToken:c}),u=c.getStats();return console.log(bu(u.tokenCount)),console.log(),l},cy=(e,t)=>{let{serviceTypes:r}=tn(),n=r[t]?.commandType;if(!n)return e;let s=Object.values(r).map(o=>o.commandType);return e.map(o=>{for(let i of s)if(i!==n&&o.command.includes(`pf new ${i}`))return{...o,command:o.command.replace(`pf new ${i}`,`pf new ${n}`)};return o})},ly=e=>e.length===0?"":`${[T.default.cyan(`
161
172
  \u{1F4C1} Files to create:`),...e.map(t=>` ${T.default.green("\u2022")} ${T.default.white(t.path)} ${T.default.dim(`(${t.language})`)}`)].join(`
162
173
  `)}
163
- `,wl=(e,t,r)=>e.length===0?"":`${[T.default.cyan(`
174
+ `,vu=(e,t,r)=>e.length===0?"":`${[T.default.cyan(`
164
175
  ${r} ${t}:`),...e.map(n=>` ${T.default.yellow("$")} ${T.default.white(n.command)}`)].join(`
165
176
  `)}
166
- `,VD=e=>e.length===0?"":`${[T.default.cyan(`
177
+ `,uy=e=>e.length===0?"":`${[T.default.cyan(`
167
178
  \u{1F4E6} Dependencies to install:`),...e.map(t=>` ${T.default.magenta("+")} ${T.default.white(t)}`)].join(`
168
179
  `)}
169
- `,qD=(e,t)=>`${[T.default.yellow(`
180
+ `,py=(e,t)=>`${[T.default.yellow(`
170
181
  Validation errors:`),...e.map(r=>T.default.yellow(` \u26A0 ${r}`)),T.default.dim(`
171
182
  Response preview:`),T.default.dim(t)].join(`
172
183
  `)}
173
- `,ir=e=>{e&&process.stdout.write(e)},YD=(e,t)=>{let r=pl(e,t),n=ci(r.commands),s=ci(r.postCommands),o=fl(r.files);return o.valid?{files:r.files,commands:n,dependencies:r.dependencies,postCommands:s}:(console.log(`${T.default.yellow("\u26A0")} Could not extract structured files from AI response`),ir(qD(o.errors,e.slice(0,500))),null)},ZD=e=>{console.log(`${T.default.green("\u2714")} Extracted ${e.files.length} files`),ir(JD(e.files)),ir(wl(e.commands,"Commands to run","\u{1F527}")),ir(wl(e.postCommands,"Post-generation commands","\u{1F4DD}")),ir(VD(e.dependencies)),ir(`
174
- `)},XD=(e,t,r)=>{let n=Zu(e);return n&&!n.includes("/")&&!n.startsWith(".")&&(n=`${vt().services}/${n}`),n?(0,ar.resolve)(r,n):(0,ar.resolve)(r,t)},QD=(e,t)=>{let{serviceTypes:r}=Xr(),n=r[t]?.skipFiles||["package.json","tsconfig.json","Dockerfile"];return e.filter(s=>!n.includes(s.path))},cr=()=>{if(!nn())return{valid:!1,error:T.default.red.bold(`\u274C AI configuration not found.
184
+ `,lr=e=>{e&&process.stdout.write(e)},fy=(e,t)=>{let r=mu(e,t),n=fi(r.commands),s=fi(r.postCommands),o=gu(r.files);return o.valid?{files:r.files,commands:n,dependencies:r.dependencies,postCommands:s}:(console.log(`${T.default.yellow("\u26A0")} Could not extract structured files from AI response`),lr(py(o.errors,e.slice(0,500))),null)},dy=e=>{console.log(`${T.default.green("\u2714")} Extracted ${e.files.length} files`),lr(ly(e.files)),lr(vu(e.commands,"Commands to run","\u{1F527}")),lr(vu(e.postCommands,"Post-generation commands","\u{1F4DD}")),lr(uy(e.dependencies)),lr(`
185
+ `)},hy=(e,t,r)=>{let n=eu(e);return n&&!n.includes("/")&&!n.startsWith(".")&&(n=`${kt().services}/${n}`),n?(0,ur.resolve)(r,n):(0,ur.resolve)(r,t)},my=(e,t)=>{let{serviceTypes:r}=tn(),n=r[t]?.skipFiles||["package.json","tsconfig.json","Dockerfile"];return e.filter(s=>!n.includes(s.path))},pr=()=>{if(!on())return{valid:!1,error:T.default.red.bold(`\u274C AI configuration not found.
175
186
  `)+T.default.yellow("Please run ")+T.default.cyan.bold("pf setup --ai")+T.default.yellow(` first to configure your AI provider.
176
- `)};try{return{valid:!0,config:us()}}catch(e){return{valid:!1,error:T.default.red.bold(`\u274C ${e.message}
177
- `)}}},bs=async e=>e||(0,Cl.input)({message:"\u{1F4DD} Describe what this service should do:",validate:t=>t.trim().length>0||"Please provide a description for the AI to generate code"}),vs=(e,t,r)=>{console.log(T.default.cyan.bold(`
187
+ `)};try{return{valid:!0,config:fs()}}catch(e){return{valid:!1,error:T.default.red.bold(`\u274C ${e.message}
188
+ `)}}},xs=async e=>e||(0,ku.input)({message:"\u{1F4DD} Describe what this service should do:",validate:t=>t.trim().length>0||"Please provide a description for the AI to generate code"}),vs=(e,t,r)=>{console.log(T.default.cyan.bold(`
178
189
  \u{1F916} AI-Powered Generation
179
190
  `)),console.log(T.default.dim(`Service: ${e.split("/").pop()}`)),console.log(T.default.dim(`Path: ${e}`)),console.log(T.default.dim(`Model: ${t.model}`)),console.log(T.default.dim(`Description: ${r}
180
- `))},xs=async(e,t)=>{let{servicePath:r,description:n="",serviceType:s,packageManager:o}=e,i=r.split("/").pop()||r,a=UD(),c=(0,ar.join)(a.workspaceRoot,on);(0,Zt.writeFileSync)(c,`generating:${r}`);let u=()=>{(0,Zt.existsSync)(c)&&(0,Zt.unlinkSync)(c)},l=()=>{u(),process.exit(130)};process.on("SIGINT",l),process.on("SIGTERM",l);try{console.log(T.default.cyan.bold(`
191
+ `))},ks=async(e,t)=>{let{servicePath:r,description:n="",serviceType:s,packageManager:o}=e,i=r.split("/").pop()||r,a=iy(),c=(0,ur.join)(a.workspaceRoot,cn);(0,Xt.writeFileSync)(c,`generating:${r}`);let l=()=>{(0,Xt.existsSync)(c)&&(0,Xt.unlinkSync)(c)},u=()=>{l(),process.exit(130)};process.on("SIGINT",u),process.on("SIGTERM",u);try{console.log(T.default.cyan.bold(`
181
192
  \u{1F916} AI Generation
182
- `));let p=await zD(t,a,r,n,s,o),d=YD(p,i);if(!d)return!1;ZD(d);let f=(0,bl.default)({text:"Processing files...",color:"cyan"}).start(),m=KD(d.commands,s),h=XD(m,r,a.cwd),D=QD(d.files,s);await hl(m,h,a.workspaceRoot);let{missingContractCommands:g}=await tl(D,h,a,f);if(d.postCommands.length>0)await pi(d.postCommands,a.workspaceRoot);else if(g.length>0){console.log(T.default.cyan(`\u{1F527} Auto-creating missing contracts...
183
- `));let y=g.map(v=>({command:v,isPfCommand:!0}));await pi(y,a.workspaceRoot)}return Yu(h),await gl(d.dependencies,h,f),await ml(a.workspaceRoot,f),await Qu(h,f),!0}finally{process.off("SIGINT",l),process.off("SIGTERM",l),u()}};var xl=require("node:fs"),ln=require("ts-morph"),vl=new ln.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),fi=e=>{if(!(0,xl.existsSync)(e))return null;let t=vl.getSourceFile(e);return t||vl.addSourceFileAtPath(e)},di=e=>{e.saveSync()},hi=(e,t,r)=>{let n=e.getImportDeclaration(t);if(n){let s=n.getNamedImports().map(i=>i.getName()),o=r.filter(i=>!s.includes(i));for(let i of o)n.addNamedImport(i);return}e.addImportDeclaration({moduleSpecifier:t,namedImports:r})},ty=e=>{for(let t of e.getClasses()){let r=t.getDecorator("Module");if(!r)continue;let n=r.getArguments();if(n.length===0)continue;let s=n[0];if(s.getKind()===ln.SyntaxKind.ObjectLiteralExpression)return s}return null},mi=(e,t)=>{let r=ty(e);if(!r)return!1;let n=r.getProperty("imports");if(n){let s=n.getFirstChildByKind(ln.SyntaxKind.ArrayLiteralExpression);return s?(s.getElements().map(i=>i.getText()).includes(t)||s.addElement(t),!0):!1}return r.addPropertyAssignment({name:"imports",initializer:`[${t}]`}),!0};var ks=require("node:fs"),pn=b(require("node:path")),gi=b(require("chalk"));var kl=async e=>{await fe("bash",["-c",`
193
+ `));let p=await ay(t,a,r,n,s,o),d=fy(p,i);if(!d)return!1;dy(d);let f=(0,Eu.default)({text:"Processing files...",color:"cyan"}).start(),m=cy(d.commands,s),h=hy(m,r,a.cwd),D=my(d.files,s);await yu(m,h,a.workspaceRoot);let{missingContractCommands:g}=await su(D,h,a,f);if(d.postCommands.length>0)await mi(d.postCommands,a.workspaceRoot);else if(g.length>0){console.log(T.default.cyan(`\u{1F527} Auto-creating missing contracts...
194
+ `));let y=g.map(x=>({command:x,isPfCommand:!0}));await mi(y,a.workspaceRoot)}return tu(h),await Cu(d.dependencies,h,f),await wu(a.workspaceRoot,f),await nu(h,f),!0}finally{process.off("SIGINT",u),process.off("SIGTERM",u),l()}};var Fu=require("node:fs"),fn=require("ts-morph"),Su=new fn.Project({skipAddingFilesFromTsConfig:!0,skipFileDependencyResolution:!0}),gi=e=>{if(!(0,Fu.existsSync)(e))return null;let t=Su.getSourceFile(e);return t||Su.addSourceFileAtPath(e)},Di=e=>{e.saveSync()},yi=(e,t,r)=>{let n=e.getImportDeclaration(t);if(n){let s=n.getNamedImports().map(i=>i.getName()),o=r.filter(i=>!s.includes(i));for(let i of o)n.addNamedImport(i);return}e.addImportDeclaration({moduleSpecifier:t,namedImports:r})},gy=e=>{for(let t of e.getClasses()){let r=t.getDecorator("Module");if(!r)continue;let n=r.getArguments();if(n.length===0)continue;let s=n[0];if(s.getKind()===fn.SyntaxKind.ObjectLiteralExpression)return s}return null},wi=(e,t)=>{let r=gy(e);if(!r)return!1;let n=r.getProperty("imports");if(n){let s=n.getFirstChildByKind(fn.SyntaxKind.ArrayLiteralExpression);return s?(s.getElements().map(i=>i.getText()).includes(t)||s.addElement(t),!0):!1}return r.addPropertyAssignment({name:"imports",initializer:`[${t}]`}),!0};var Es=require("node:fs"),dn=b(require("node:path")),Ci=b(require("chalk"));var Tu=async e=>{await de("bash",["-c",`
184
195
  curl -fsSL https://bun.sh/install | bash && if [ -f "$HOME/.bun/bin/bun" ]; then export PATH="$HOME/.bun/bin:$PATH"; fi
185
- `],{task:e,shell:!0}),await ey()},Di=()=>Rr("bun"),El=()=>eo([{label:"Bun",value:59026,color:"magenta",barColor:"magenta"},{label:"Deno",value:25335},{label:"Node.js",value:19039}],{title:'Express.js "hello world" HTTP requests per second (Linux x64)',barColor:"blackBright"}),Sl=()=>eo([{label:"Bun",value:.36,color:"magenta",barColor:"magenta"},{label:"pnpm",value:6.44},{label:"npm",value:10.58},{label:"yarn",value:12.08}],{title:"Bun is an npm-compatible package manager.",unit:"s",footer:gi.default.blackBright("* Installing dependencies from cache for a Remix app."),barColor:"blackBright"}),ey=async()=>{let e='export PATH="$HOME/.bun/bin:$PATH"',t=process.env.HOME;if(!t){w.error("Could not detect $HOME environment variable. Cannot update shell config.");return}let r=[pn.default.join(t,".zshrc"),pn.default.join(t,".bashrc"),pn.default.join(t,".bash_profile")];for(let n of r)try{if(await ks.promises.stat(n).then(()=>!0).catch(()=>!1)){(await ks.promises.readFile(n,"utf8")).includes(e)||(await ks.promises.appendFile(n,`
196
+ `],{task:e,shell:!0}),await Dy()},bi=()=>Nr("bun"),Au=()=>so([{label:"Bun",value:59026,color:"magenta",barColor:"magenta"},{label:"Deno",value:25335},{label:"Node.js",value:19039}],{title:'Express.js "hello world" HTTP requests per second (Linux x64)',barColor:"blackBright"}),Pu=()=>so([{label:"Bun",value:.36,color:"magenta",barColor:"magenta"},{label:"pnpm",value:6.44},{label:"npm",value:10.58},{label:"yarn",value:12.08}],{title:"Bun is an npm-compatible package manager.",unit:"s",footer:Ci.default.blackBright("* Installing dependencies from cache for a Remix app."),barColor:"blackBright"}),Dy=async()=>{let e='export PATH="$HOME/.bun/bin:$PATH"',t=process.env.HOME;if(!t){w.error("Could not detect $HOME environment variable. Cannot update shell config.");return}let r=[dn.default.join(t,".zshrc"),dn.default.join(t,".bashrc"),dn.default.join(t,".bash_profile")];for(let n of r)try{if(await Es.promises.stat(n).then(()=>!0).catch(()=>!1)){(await Es.promises.readFile(n,"utf8")).includes(e)||(await Es.promises.appendFile(n,`
186
197
  # Added by platform installer
187
198
  ${e}
188
- `),w.log(`Added Bun path to ${pn.default.basename(n)}`));return}}catch(s){w.error(`Failed to update ${n}: ${s.message}`)}w.warn("No shell config file (.zshrc, .bashrc, .bash_profile) found. Please add the following manually:"),w.log(gi.default.cyan(e))};var Bt=b(require("chalk"));var Es="integrations-run";var J=require("zod"),ry=J.z.object({name:J.z.string(),description:J.z.string(),link:J.z.string().url().optional(),install:J.z.union([J.z.string(),J.z.array(J.z.string())]).transform(e=>Array.isArray(e)?e:[e]),installFlags:J.z.array(J.z.string()).optional(),run:J.z.array(J.z.string()).optional(),initial:J.z.boolean().optional(),interactive:J.z.boolean().optional()}),Fl=J.z.array(ry);var Tl=e=>{try{return Fl.parse(e)}catch(t){throw new Error(t.issues.map(r=>` - Path ${r.path.join(". ")} : ${r.message}`).join(`
189
- `))}};var St=()=>{try{let e=ss("bin/integration.collection.json");return Tl(e)}catch(e){throw new Error(`Failed to load integrations!
199
+ `),w.log(`Added Bun path to ${dn.default.basename(n)}`));return}}catch(s){w.error(`Failed to update ${n}: ${s.message}`)}w.warn("No shell config file (.zshrc, .bashrc, .bash_profile) found. Please add the following manually:"),w.log(Ci.default.cyan(e))};var rt=b(require("chalk")),Ru=require("execa"),Iu=require("jiti");var hn=async e=>{let{stdout:t}=await(0,Ru.execa)("sh",["-c",e]);return t.trim()},xi="pf-local-nats",yy="2.10-alpine",wy=4222,Cy=8222,by=e=>({clientPort:e.clientPort??wy,monitoringPort:e.monitoringPort??Cy,containerName:e.containerName??xi,version:e.version??yy}),xy=e=>["run","--rm","--detach",`--name=${e.containerName}`,`-p=${e.clientPort}:4222`,`-p=${e.monitoringPort}:8222`,`nats:${e.version}`,"--jetstream","--store_dir=/data","--http_port=8222"],vy=e=>({containerName:e.containerName,clientUrl:`nats://localhost:${e.clientPort}`,monitoringUrl:`http://localhost:${e.monitoringPort}`}),ky=async()=>{try{return await hn("docker info"),!0}catch{return!1}},Nu=async e=>{try{return(await hn(`docker ps -q -f name=${e}`)).length>0}catch{return!1}},Ey=async e=>{try{await hn(`docker stop ${e} 2>/dev/null || true`),await hn(`docker rm ${e} 2>/dev/null || true`)}catch{}},Sy=async e=>{let t=xy(e);try{return await hn(`docker ${t.join(" ")}`),{success:!0,value:vy(e)}}catch{return{success:!1}}},Fy=e=>{console.log(rt.default.green("\u2713 NATS started")),console.log(rt.default.dim(` Client: ${e.clientUrl}`)),console.log(rt.default.dim(` Monitoring: ${e.monitoringUrl}`)),console.log(rt.default.dim(" Streams: ephemeral, auto-created by services")),console.log("")},Ou=async(e={})=>{let t=by(e);if(!await ky())return console.log(rt.default.yellow("\u26A0\uFE0F Docker not available - skipping NATS (services may fail)")),!1;if(await Nu(t.containerName))return console.log(rt.default.dim("\u2713 NATS already running")),!0;console.log(rt.default.cyan("\u{1F680} Starting development infrastructure...")),console.log(rt.default.dim(" NATS with JetStream (ephemeral)"));let r=await Sy(t);return r.success?(Fy(r.value),!0):(console.error(rt.default.red("\u2717 Failed to start NATS")),!1)},Ty=e=>e.map(t=>({stream:t,subjects:[`${t.toLowerCase()}.*`],config:{storage:"memory",retention:"limits",maxAge:36e5}})),Ay=e=>Array.from(new Set(Object.values(e).filter(t=>t!==null&&typeof t=="object"&&"channel"in t).map(t=>t.channel?.stream).filter(t=>!!t))),Mu=async e=>{try{let{ensureJetStreams:t}=await import("@crossdelta/cloudevents"),{indexPath:r}=$(e),s=await(0,Iu.createJiti)(e).import(r,{default:!0}),o=Ay(s);if(o.length===0){console.log(rt.default.dim(" No streams found in contracts"));return}let i=Ty(o);await t({streams:i}),console.log(rt.default.dim(` Created ${o.length} ephemeral stream(s): ${o.join(", ")}`))}catch(t){console.log(rt.default.yellow(` \u26A0\uFE0F Stream creation failed: ${t instanceof Error?t.message:"Unknown error"}`)),console.log(rt.default.dim(" Stream auto-creation will happen on first publish"))}},Py=async(e=xi)=>{await Nu(e)&&(console.log(rt.default.dim("Stopping NATS...")),await Ey(e))},$u=async(e=xi)=>{await Py(e)};var jt=b(require("chalk"));var Ss="integrations-run";var V=require("zod"),Ry=V.z.object({name:V.z.string(),description:V.z.string(),link:V.z.string().url().optional(),install:V.z.union([V.z.string(),V.z.array(V.z.string())]).transform(e=>Array.isArray(e)?e:[e]),installFlags:V.z.array(V.z.string()).optional(),run:V.z.array(V.z.string()).optional(),initial:V.z.boolean().optional(),interactive:V.z.boolean().optional()}),Bu=V.z.array(Ry);var ju=e=>{try{return Bu.parse(e)}catch(t){throw new Error(t.issues.map(r=>` - Path ${r.path.join(". ")} : ${r.message}`).join(`
200
+ `))}};var Ft=()=>{try{let e=as("bin/integration.collection.json");return ju(e)}catch(e){throw new Error(`Failed to load integrations!
190
201
  Check your integration.collection.json:
191
- ${e.message}`)}},ur=()=>St().reduce((t,r)=>(r.initial&&t.push(r.name),t),[]),ny=e=>!!e?.name&&!!e?.link&&!!e?.description,Ss=e=>{let t=St();if(!t?.length||!e?.length)return;let r=e.map(n=>t.find(s=>s.name===n)).filter(ny);r.length&&(w.breakLine().log("\u{1F50C} Installed Integrations:"),r.forEach(({name:n,link:s,description:o})=>{let i=w.getStoredLogs(`${Es}:${n}`);s&&w.log(`${Ut(Bt.default.cyan(n),s)} - ${o}`),i.length&&w.log(i.map(a=>` \u203A ${Bt.default.dim(a.message)}`).join(`
192
- `))}))},sy=e=>e.toUpperCase().replace(/-/g,"_"),Al=(e,t)=>{let r=sy(e);w.breakLine().log(Bt.default.bold("Environment variables:")).log(Bt.default.dim(" Local:")).log(Bt.default.cyan(` ${r}_PORT=${t}`)).log(Bt.default.cyan(` ${r}_URL=http://localhost:${t}`)).breakLine().log(Bt.default.dim(" Production (auto-configured):")).log(Bt.default.cyan(` ${r}_PORT=${t}`)).log(Bt.default.cyan(` ${r}_URL=http://${e}:${t}`))};var yi=b(require("chalk"));var oy=e=>{let t=e.match(/^(@?[^@]+)@(.+)$/);return t?{name:t[1],version:t[2]}:{name:e,version:"latest"}},Pl=async e=>{let{selectedIntegrations:t,cwd:r,packageManager:n=$(),task:s}=e;if(!t?.length||!s)return;let o=iy(t,r,n,s);await rs(s,o)},iy=(e,t,r,n)=>{let o=St()?.filter(a=>e.includes(a.name))?.flatMap(a=>a.install.map(c=>{let{name:u,version:l}=oy(c);return{title:yi.default.cyanBright(`Adding ${c} (${a.name})`),fn:async()=>{Jt(`dependencies.${u}`,l,t)}}})),i={title:yi.default.cyanBright("Installing packages..."),fn:async()=>{await xt({cwd:t,packageManager:r,task:n})}};return[...o??[],i]};var Rl=b(require("chalk"));var Il=async e=>{let{selectedIntegrations:t,cwd:r,task:n}=e;if(!t?.length||!n)return;let s=ay(t,r,n,e.packageManager);await rs(n,s)},ay=(e,t,r,n)=>St().filter(o=>e.includes(o.name)&&o.run?.length).flatMap(o=>(o.run||[]).map(i=>({title:Rl.default.cyanBright(`Running "${i}" for ${o.name}
193
- `),fn:()=>cy(o,i,t,r,n)}))),cy=async(e,t,r,n,s)=>{let o=`${Es}:${e.name}`;try{if(e.interactive)return Cu(t,[],{cwd:r,context:o,task:n,manager:s});await qt(t,[],{cwd:r,task:n,context:o})}catch(i){w.error(`Failed to run command "${t}" for ${e.name}: ${i.message}`)}};var Fs=require("node:fs"),fn=require("node:path");var Ts=(e,t)=>{try{let r=(0,Fs.readFileSync)(e,"utf-8"),n=JSON.parse(r);t(n),(0,Fs.writeFileSync)(e,JSON.stringify(n,null,2),"utf-8")}catch{}},uy=e=>{let t=(0,fn.join)(S(e),"tsconfig.json");Ts(t,r=>{r.compilerOptions.module="ESNext",r.compilerOptions.moduleResolution="bundler",r.compilerOptions.resolvePackageJsonExports=!0,r.compilerOptions.types=r.compilerOptions.types||[],r.compilerOptions.types.includes("bun-types")||r.compilerOptions.types.push("bun-types"),r.exclude=["node_modules","dist"]})},ly=e=>{let t=(0,fn.join)(S(e),"tsconfig.build.json");Ts(t,r=>{r.exclude=["node_modules","test","dist","**/*.spec.ts","**/*.test.ts"]})},py=e=>{let t=(0,fn.join)(S(e),"nest-cli.json");Ts(t,r=>{r.compilerOptions=r.compilerOptions||{},r.compilerOptions.tsConfigPath="tsconfig.build.json"})},fy=e=>{let t=(0,fn.join)(S(e),"package.json");Ts(t,r=>{delete r.jest})},Nl=e=>{uy(e),ly(e),py(e),fy(e)};var Ol=require("node:path");var dy=(e,t)=>{let r=fi(e);if(r){for(let{className:n,importPath:s}of t)hi(r,s,[n]),mi(r,n);di(r)}},Ml=e=>{let t=(0,Ol.join)(S(e),"src","app.module.ts");dy(t,[{className:"EventsModule",importPath:"./events/events.module"}])};var hy=require("fs-extra");var Qy=b(require("chalk")),tw=b(Ai());var Ns=require("node:fs"),$p=require("node:path"),Bp=b(require("handlebars")),fr=(e,t)=>{for(let r of e)if((0,Ns.existsSync)(r))return r;throw new Error(t??`Templates directory not found. Searched in: ${e.join(", ")}`)},Pi=(e,t={})=>{let r=(0,Ns.readFileSync)(e,"utf-8");return Bp.default.compile(r)(t)},Os=e=>(t,r={})=>{let n=(0,$p.join)(e,t);return Pi(n,r)};var Dn=e=>e.toUpperCase().replace(/-/g,"_");var jp=e=>e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ");function Ms(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}async function _p(e,t,r={},n=[],s=[]){if(!e){console.error("Subcommand is not defined.");return}let o=n.map(u=>t[u]).filter(u=>u!==void 0),i=s.map(u=>{let l=t[u];if(!(l===!1||l===void 0))return l===!0?`--${Ms(String(u))}`:`--${Ms(String(u))}=${String(l)}`}).filter(u=>u!==void 0),a=Object.entries(r).map(([u,l])=>{if(!(l===!1||l===void 0))return l===!0?`--${Ms(u)}`:`--${Ms(u)}=${String(l)}`}).filter(u=>u!==void 0),c=[...o,...i,...a].map(String);await e.parseAsync(c,{from:"user"})}var tf=require("node:path"),Qt=b(require("chalk"));var dr={title:"Confirm creation",enabled:e=>!e.userConfirmed,task:async(e,t)=>{if(e.userConfirmed=await t.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}),!e.userConfirmed)throw new Error("Project creation was canceled by the user.")}};var _t=require("node:fs"),hr=require("node:path");function Lp(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
202
+ ${e.message}`)}},fr=()=>Ft().reduce((t,r)=>(r.initial&&t.push(r.name),t),[]),Iy=e=>!!e?.name&&!!e?.link&&!!e?.description,Fs=e=>{let t=Ft();if(!t?.length||!e?.length)return;let r=e.map(n=>t.find(s=>s.name===n)).filter(Iy);r.length&&(w.breakLine().log("\u{1F50C} Installed Integrations:"),r.forEach(({name:n,link:s,description:o})=>{let i=w.getStoredLogs(`${Ss}:${n}`);s&&w.log(`${zt(jt.default.cyan(n),s)} - ${o}`),i.length&&w.log(i.map(a=>` \u203A ${jt.default.dim(a.message)}`).join(`
203
+ `))}))},Ny=e=>e.toUpperCase().replace(/-/g,"_"),_u=(e,t)=>{let r=Ny(e);w.breakLine().log(jt.default.bold("Environment variables:")).log(jt.default.dim(" Local:")).log(jt.default.cyan(` ${r}_PORT=${t}`)).log(jt.default.cyan(` ${r}_URL=http://localhost:${t}`)).breakLine().log(jt.default.dim(" Production (auto-configured):")).log(jt.default.cyan(` ${r}_PORT=${t}`)).log(jt.default.cyan(` ${r}_URL=http://${e}:${t}`))};var vi=b(require("chalk"));var Oy=e=>{let t=e.match(/^(@?[^@]+)@(.+)$/);return t?{name:t[1],version:t[2]}:{name:e,version:"latest"}},Lu=async e=>{let{selectedIntegrations:t,cwd:r,packageManager:n=B(),task:s}=e;if(!t?.length||!s)return;let o=My(t,r,n,s);await os(s,o)},My=(e,t,r,n)=>{let o=Ft()?.filter(a=>e.includes(a.name))?.flatMap(a=>a.install.map(c=>{let{name:l,version:u}=Oy(c);return{title:vi.default.cyanBright(`Adding ${c} (${a.name})`),fn:async()=>{qt(`dependencies.${l}`,u,t)}}})),i={title:vi.default.cyanBright("Installing packages..."),fn:async()=>{await Et({cwd:t,packageManager:r,task:n})}};return[...o??[],i]};var Wu=b(require("chalk"));var Gu=async e=>{let{selectedIntegrations:t,cwd:r,task:n}=e;if(!t?.length||!n)return;let s=$y(t,r,n,e.packageManager);await os(n,s)},$y=(e,t,r,n)=>Ft().filter(o=>e.includes(o.name)&&o.run?.length).flatMap(o=>(o.run||[]).map(i=>({title:Wu.default.cyanBright(`Running "${i}" for ${o.name}
204
+ `),fn:()=>By(o,i,t,r,n)}))),By=async(e,t,r,n,s)=>{let o=`${Ss}:${e.name}`;try{if(e.interactive)return kl(t,[],{cwd:r,context:o,task:n,manager:s});await Yt(t,[],{cwd:r,task:n,context:o})}catch(i){w.error(`Failed to run command "${t}" for ${e.name}: ${i.message}`)}};var Ts=require("node:fs"),mn=require("node:path");var As=(e,t)=>{try{let r=(0,Ts.readFileSync)(e,"utf-8"),n=JSON.parse(r);t(n),(0,Ts.writeFileSync)(e,JSON.stringify(n,null,2),"utf-8")}catch{}},jy=e=>{let t=(0,mn.join)(S(e),"tsconfig.json");As(t,r=>{r.compilerOptions.module="ESNext",r.compilerOptions.moduleResolution="bundler",r.compilerOptions.resolvePackageJsonExports=!0,r.compilerOptions.types=r.compilerOptions.types||[],r.compilerOptions.types.includes("bun-types")||r.compilerOptions.types.push("bun-types"),r.exclude=["node_modules","dist"]})},_y=e=>{let t=(0,mn.join)(S(e),"tsconfig.build.json");As(t,r=>{r.exclude=["node_modules","test","dist","**/*.spec.ts","**/*.test.ts"]})},Ly=e=>{let t=(0,mn.join)(S(e),"nest-cli.json");As(t,r=>{r.compilerOptions=r.compilerOptions||{},r.compilerOptions.tsConfigPath="tsconfig.build.json"})},Wy=e=>{let t=(0,mn.join)(S(e),"package.json");As(t,r=>{delete r.jest})},Hu=e=>{jy(e),_y(e),Ly(e),Wy(e)};var Uu=require("node:path");var Gy=(e,t)=>{let r=gi(e);if(r){for(let{className:n,importPath:s}of t)yi(r,s,[n]),wi(r,n);Di(r)}},zu=e=>{let t=(0,Uu.join)(S(e),"src","app.module.ts");Gy(t,[{className:"EventsModule",importPath:"./events/events.module"}])};var Hy=require("fs-extra");var Tw=b(require("chalk")),Aw=b(Oi());var Os=require("node:fs"),Kp=require("node:path"),Jp=b(require("handlebars")),mr=(e,t)=>{for(let r of e)if((0,Os.existsSync)(r))return r;throw new Error(t??`Templates directory not found. Searched in: ${e.join(", ")}`)},Mi=(e,t={})=>{let r=(0,Os.readFileSync)(e,"utf-8");return Jp.default.compile(r)(t)},Ms=e=>(t,r={})=>{let n=(0,Kp.join)(e,t);return Mi(n,r)};var $s=e=>e.toUpperCase().replace(/-/g,"_");var qp=e=>e.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ");function Bs(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}async function Vp(e,t,r={},n=[],s=[]){if(!e){console.error("Subcommand is not defined.");return}let o=n.map(l=>t[l]).filter(l=>l!==void 0),i=s.map(l=>{let u=t[l];if(!(u===!1||u===void 0))return u===!0?`--${Bs(String(l))}`:`--${Bs(String(l))}=${String(u)}`}).filter(l=>l!==void 0),a=Object.entries(r).map(([l,u])=>{if(!(u===!1||u===void 0))return u===!0?`--${Bs(l)}`:`--${Bs(l)}=${String(u)}`}).filter(l=>l!==void 0),c=[...o,...i,...a].map(String);await e.parseAsync(c,{from:"user"})}var ff=require("node:path"),te=b(require("chalk"));var gr={title:"Confirm creation",enabled:e=>!e.userConfirmed,task:async(e,t)=>{if(e.userConfirmed=await t.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}),!e.userConfirmed)throw new Error("Project creation was canceled by the user.")}};var Lt=require("node:fs"),Dr=require("node:path");function Yp(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
194
205
  import { ports } from '@crossdelta/infrastructure'
195
206
 
196
207
  /**
@@ -211,7 +222,7 @@ const config: K8sServiceConfig = {
211
222
  }
212
223
 
213
224
  export default config
214
- `}function Wp(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
225
+ `}function Zp(e,t){return`import type { K8sServiceConfig } from '@crossdelta/infrastructure'
215
226
  import { ports } from '@crossdelta/infrastructure'
216
227
 
217
228
  /**
@@ -232,73 +243,70 @@ const config: K8sServiceConfig = {
232
243
  }
233
244
 
234
245
  export default config
235
- `}var ew=4001,rw=4e3;function nw(e){let t=[],r=e.matchAll(/ports\(\)\.(?:http|https|grpc|primary)\((\d+)\)/g);for(let c of r)t.push(Number(c[1]));let n=e.matchAll(/\.add(?:Http|Grpc)?\((\d+)/g);for(let c of n)t.push(Number(c[1]));let s=e.match(/containerPort\s*:\s*(\d+)/);s&&t.push(Number(s[1]));let o=e.match(/internalPorts\s*:\s*\[([^\]]+)\]/);if(o){let c=o[1].match(/\d+/g);c&&t.push(...c.map(Number))}let i=e.match(/httpPort\s*:\s*(\d+)/);i&&t.push(Number(i[1]));let a=e.matchAll(/const\s+\w*[pP]ort\w*\s*=\s*(\d+)/g);for(let c of a)t.push(Number(c[1]));return t}function sw(e,t){let r=t?ew:rw,n=new Set;if(!(0,_t.existsSync)(e))return r;let s=(0,_t.readdirSync)(e).filter(i=>i.endsWith(".ts"));for(let i of s){let a=(0,hr.join)(e,i);try{let c=(0,_t.readFileSync)(a,"utf-8"),u=nw(c);for(let l of u)n.add(l)}catch{}}let o=r;for(;n.has(o);)o++;return o}function ow(e){return(0,hr.basename)(e)}var $s={title:"Creating infrastructure service config",task:async(e,t)=>{let r=ow(e.projectName),n=O(),s=(0,hr.join)(n,"infra","services");if(!(0,_t.existsSync)(s)){t.title="Skipping infra config (no infra/services directory found)";return}let o=(0,hr.join)(s,`${r}.ts`);if((0,_t.existsSync)(o)){t.title=`Service config already exists: infra/services/${r}.ts`;return}let i=sw(s,!0);e.assignedPort=i;let a=e.serviceType==="hono"?Lp(r,i):Wp(r,i);(0,_t.writeFileSync)(o,a),t.title=`Created infra/services/${r}.ts (port: ${i})`}};var yn=require("node:child_process"),Gp=require("node:fs"),Hp=require("node:path"),iw=()=>{try{return(0,yn.execSync)("git --version",{stdio:"ignore"}),!0}catch{return!1}},aw=e=>(0,Gp.existsSync)((0,Hp.join)(e,".git")),Up={title:"Initializing git repository",enabled:()=>iw(),skip:e=>aw(e.cwd)?"Already a git repository":!1,task:async(e,t)=>{try{(0,yn.execSync)("git init",{cwd:e.cwd,stdio:"ignore"}),(0,yn.execSync)("git add -A",{cwd:e.cwd,stdio:"ignore"}),(0,yn.execSync)('git commit -m "chore: initial commit"',{cwd:e.cwd,stdio:"ignore",env:{...process.env,GIT_AUTHOR_NAME:process.env.GIT_AUTHOR_NAME||"Platform SDK",GIT_AUTHOR_EMAIL:process.env.GIT_AUTHOR_EMAIL||"platform-sdk@localhost",GIT_COMMITTER_NAME:process.env.GIT_COMMITTER_NAME||"Platform SDK",GIT_COMMITTER_EMAIL:process.env.GIT_COMMITTER_EMAIL||"platform-sdk@localhost"}}),t.title="Git repository initialized with initial commit"}catch{t.title="Git initialization skipped (git error)"}}};var Ri=b(require("chalk"));var mr={title:"Installing Bun",enabled:e=>!!e.shouldInstallBun&&!Di(),task:async(e,t)=>K(t,async r=>{await kl(t),e.elapsedTime+=r(),t.title=`Bun installed successfully. (${e.elapsedTime}s)`})},gr={enabled:e=>!Di()&&!e.shouldInstallBun&&!e.packageManager,task:async(e,t)=>{e.shouldInstallBun=await t.prompt(R).run({type:"Toggle",message:"Would you like to use Bun? (recommended)",initial:!0,footer:["",`${Ri.default.magenta.bold("Bun")} is a fast JavaScript runtime, package manager, bundler, and test runner: ${Ri.default.underline("https://bun.sh")}`,El(),Sl()].join(`
236
- `)}),e.shouldInstallBun&&(e.packageManager="bun")}};var Ii=b(require("chalk"));var Bs={title:"Install integrations",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>K(t,async r=>{let{selectedIntegrations:n,cwd:s,packageManager:o}=e;await Pl({selectedIntegrations:n,packageManager:o,cwd:s,task:t}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}},js={title:"Select integrations",enabled:e=>e.selectedIntegrations.length===0,task:async(e,t)=>{e.selectedIntegrations=await t.prompt(R).run({type:"MultiSelect",hint:`
237
- Press <space> to select/deselect, <enter> to confirm, <i> to invert selection`,message:"Which integrations would you like to include?",initial:ur().map((r,n)=>n),choices:e.availableIntegrations.map(({name:r,description:n})=>({name:r,message:[Ii.default.bold(r),n].join(" - "),value:r}))}),!e.selectedIntegrations||e.selectedIntegrations.length===0?t.title="No integrations selected.":t.title=["Selected integrations:",...e.selectedIntegrations.map(r=>Ii.default.bold(`\u2022 ${r}`))].join(`
238
- `)}};var zp={title:"Install Nest CLI",task:async(e,t)=>K(t,async r=>{await wu({packages:["@nestjs/cli"],task:t,cwd:e.cwd}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}};var _s={title:"Install dependencies",task:async(e,t)=>K(t,async r=>{await xt({cwd:e.cwd,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()})};var Kp=b(require("chalk"));var Dr={enabled:e=>!e.removeDir&&!es(e.cwd),task:async(e,t)=>{if(e.removeDir=await t.prompt(R).run({type:"Toggle",message:Kp.default.bold("\u26A0\uFE0F Overwrite existing directory?"),initial:!1}),!e.removeDir)throw new Error("Project creation was canceled by the user.")}},yr={enabled:e=>!!e.removeDir,task:async e=>Zc(e.cwd)};var Ls={title:"Run integration commands",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>K(t,async r=>{let{selectedIntegrations:n,cwd:s}=e;await Il({selectedIntegrations:n,cwd:s,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1}};var cw=["services/my-hono-service","services/my-nest-service","my-platform"],wr={enabled:e=>e.skipInputPrompts||e.userConfirmed?!1:e.projectName?cw.includes(e.projectName):!0,task:async(e,t)=>{e.projectName=await t.prompt(R).run({type:"Input",initial:e.projectName,message:"Enter project name",validate:r=>r?!0:"Project name is required."}),e.cwd&&(e.cwd=S(e.projectName))}};var Ni=b(require("chalk"));var Cr={title:"Select Package manager",task:async(e,t)=>{if(e.packageManager??=Ho(),e.packageManager){t.title=`Using ${Ni.default.bold(e.packageManager)} as package manager.`;return}e.packageManager=await t.prompt(R).run({type:"Select",message:"Which package manager would you like to use?",initial:Uo(),choices:yu}),t.title=`Using ${Ni.default.bold(e.packageManager)} as package manager.`}};var wn=b(require("chalk")),Jp={title:"GitHub repository owner",task:async(e,t)=>{if(e.githubOwner){t.title=`GitHub owner: ${wn.default.bold(e.githubOwner)}`;return}e.githubOwner=await t.prompt(R).run({type:"Input",message:"Enter GitHub organization or username",initial:"my-org",validate:r=>r?.trim()?!0:"GitHub owner is required."}),t.title=`GitHub owner: ${wn.default.bold(e.githubOwner)}`}},Vp={title:"Include GitHub CI/CD",task:async(e,t)=>{if(e.includeGitHubCI!==void 0){t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD";return}e.includeGitHubCI=await t.prompt(R).run({type:"Toggle",message:"Include GitHub Actions workflows and CI/CD?",initial:!0,enabled:"Yes",disabled:"No"}),t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD"}};var qp={title:"Pulumi stack name",task:async(e,t)=>{if(e.pulumiStackBase){t.title=`Pulumi stack: ${wn.default.bold(e.pulumiStackBase)}`;return}let r=e.githubOwner||"myorg",n=e.projectName?.replace(/[^a-zA-Z0-9-]/g,"-")||"myproject",s=`${r}/${n}`;e.pulumiStackBase=await t.prompt(R).run({type:"Input",message:"Enter Pulumi stack base name (org/project)",initial:s,validate:o=>o?.trim()?o.includes("/")?!0:"Format should be org/project (e.g., myorg/myproject)":"Pulumi stack name is required."}),t.title=`Pulumi stack: ${wn.default.bold(e.pulumiStackBase)}`}};var Lt=require("node:fs"),Wt=require("node:path");var Mi=require("node:path");var uw=()=>fr([(0,Mi.join)(__dirname,"templates","hono-microservice"),(0,Mi.join)(__dirname,"..","hono-microservice","templates")],"Hono templates directory not found."),$i=(e,t={})=>Os(uw())(e,t);function Yp(){return $i("tsconfig.json.hbs")}function Zp(e="1.2.23"){return $i("Dockerfile.hbs",{bunVersion:e})}function Xp(){return $i("biome.json.hbs")}var lw=async({projectName:e,packageManager:t},r)=>{let n=t==="bun"?"bun":"nodejs";try{await qt("create-hono@latest",[e,"--pm",t,"--template",n,"--install"],{task:r})}catch(o){let i=(0,Wt.join)(S(e),"package.json");if(!(0,Lt.existsSync)(i))throw new Error(`Failed to scaffold: ${o instanceof Error?o.message:String(o)}`)}let s=(0,Wt.join)(S(e),"package.json");if(!(0,Lt.existsSync)(s))throw new Error("Failed to scaffold Hono app structure - package.json not created")},pw=({projectName:e,packageManager:t})=>{let r=(0,Wt.basename)(e),n=ns(),s=t==="npm"?"*":"workspace:*",o=S(e),i=Qc("scripts.dev",o);i&&Jt("scripts.start:dev",i,e),[{field:"name",value:`${n}/${r}`},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"devDependencies.bun-types",value:"latest",condition:t!=="bun"},{field:"devDependencies.@biomejs/biome",value:"latest"}].filter(({condition:c})=>c??!0).map(({field:c,value:u})=>Jt(c,u,e))},fw=({projectName:e})=>{let t=(0,Wt.basename)(e),r=(0,Wt.join)(S(e),"src","index.ts"),n=(0,Lt.readFileSync)(r,"utf-8");n.includes("@crossdelta/telemetry")||(n=`// IMPORTANT: telemetry must be imported first to patch modules before they're loaded
239
- import '@crossdelta/telemetry'
240
-
241
- `+n);let o=Dn(t);n=n.replace(/const port = .+/,`const port = Number(process.env.PORT || process.env.${o}_PORT) || 8080`),(0,Lt.writeFileSync)(r,n)},dw=({projectName:e})=>{let t=S(e),r=(0,Wt.join)(t,"tsconfig.json");(0,Lt.writeFileSync)(r,Yp());let n=(0,Wt.join)(t,"Dockerfile");(0,Lt.writeFileSync)(n,Zp());let s=(0,Wt.join)(t,"biome.json");(0,Lt.writeFileSync)(s,Xp())},Qp={title:"Create Hono app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>K(t,async r=>{await lw(e,t),pw(e),fw(e),dw(e),e.elapsedTime+=r()})};var hw=e=>{let t=(e||"my-hono-service").trim();return t.includes("/")||t.startsWith(".")?t:`${vt().services}/${t}`},mw=async(e,t)=>{let{valid:r,config:n,error:s}=cr();if(!r||!n){console.log(s);return}let o=hw(e.name),i=t.packageManager||$(),a=await bs(t.description);if(vs(o,n,a),await xs({servicePath:o,description:a,serviceType:"hono",packageManager:i},n))console.log(Qt.default.green.bold(`
246
+ `}var Pw=4001,Rw=4e3;function Iw(e){let t=[],r=e.matchAll(/ports\(\)\.(?:http|https|grpc|primary)\((\d+)\)/g);for(let c of r)t.push(Number(c[1]));let n=e.matchAll(/\.add(?:Http|Grpc)?\((\d+)/g);for(let c of n)t.push(Number(c[1]));let s=e.match(/containerPort\s*:\s*(\d+)/);s&&t.push(Number(s[1]));let o=e.match(/internalPorts\s*:\s*\[([^\]]+)\]/);if(o){let c=o[1].match(/\d+/g);c&&t.push(...c.map(Number))}let i=e.match(/httpPort\s*:\s*(\d+)/);i&&t.push(Number(i[1]));let a=e.matchAll(/const\s+\w*[pP]ort\w*\s*=\s*(\d+)/g);for(let c of a)t.push(Number(c[1]));return t}function Nw(e,t){let r=t?Pw:Rw,n=new Set;if(!(0,Lt.existsSync)(e))return r;let s=(0,Lt.readdirSync)(e).filter(i=>i.endsWith(".ts"));for(let i of s){let a=(0,Dr.join)(e,i);try{let c=(0,Lt.readFileSync)(a,"utf-8"),l=Iw(c);for(let u of l)n.add(u)}catch{}}let o=r;for(;n.has(o);)o++;return o}function Ow(e){return(0,Dr.basename)(e)}var js={title:"Creating infrastructure service config",task:async(e,t)=>{let r=Ow(e.projectName),n=O(),s=(0,Dr.join)(n,"infra","services");if(!(0,Lt.existsSync)(s)){t.title="Skipping infra config (no infra/services directory found)";return}let o=(0,Dr.join)(s,`${r}.ts`);if((0,Lt.existsSync)(o)){t.title=`Service config already exists: infra/services/${r}.ts`;return}let i=Nw(s,!0);e.assignedPort=i;let a=e.serviceType==="hono"?Yp(r,i):Zp(r,i);(0,Lt.writeFileSync)(o,a),t.title=`Created infra/services/${r}.ts (port: ${i})`}};var Cn=require("node:child_process"),Xp=require("node:fs"),Qp=require("node:path"),Mw=()=>{try{return(0,Cn.execSync)("git --version",{stdio:"ignore"}),!0}catch{return!1}},$w=e=>(0,Xp.existsSync)((0,Qp.join)(e,".git")),tf={title:"Initializing git repository",enabled:()=>Mw(),skip:e=>$w(e.cwd)?"Already a git repository":!1,task:async(e,t)=>{try{(0,Cn.execSync)("git init",{cwd:e.cwd,stdio:"ignore"}),(0,Cn.execSync)("git add -A",{cwd:e.cwd,stdio:"ignore"}),(0,Cn.execSync)('git commit -m "chore: initial commit"',{cwd:e.cwd,stdio:"ignore",env:{...process.env,GIT_AUTHOR_NAME:process.env.GIT_AUTHOR_NAME||"Platform SDK",GIT_AUTHOR_EMAIL:process.env.GIT_AUTHOR_EMAIL||"platform-sdk@localhost",GIT_COMMITTER_NAME:process.env.GIT_COMMITTER_NAME||"Platform SDK",GIT_COMMITTER_EMAIL:process.env.GIT_COMMITTER_EMAIL||"platform-sdk@localhost"}}),t.title="Git repository initialized with initial commit"}catch{t.title="Git initialization skipped (git error)"}}};var $i=b(require("chalk"));var yr={title:"Installing Bun",enabled:e=>!!e.shouldInstallBun&&!bi(),task:async(e,t)=>q(t,async r=>{await Tu(t),e.elapsedTime+=r(),t.title=`Bun installed successfully. (${e.elapsedTime}s)`})},wr={enabled:e=>!bi()&&!e.shouldInstallBun&&!e.packageManager,task:async(e,t)=>{e.shouldInstallBun=await t.prompt(R).run({type:"Toggle",message:"Would you like to use Bun? (recommended)",initial:!0,footer:["",`${$i.default.magenta.bold("Bun")} is a fast JavaScript runtime, package manager, bundler, and test runner: ${$i.default.underline("https://bun.sh")}`,Au(),Pu()].join(`
247
+ `)}),e.shouldInstallBun&&(e.packageManager="bun")}};var Bi=b(require("chalk"));var _s={title:"Install integrations",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>q(t,async r=>{let{selectedIntegrations:n,cwd:s,packageManager:o}=e;await Lu({selectedIntegrations:n,packageManager:o,cwd:s,task:t}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}},Ls={title:"Select integrations",enabled:e=>e.selectedIntegrations.length===0,task:async(e,t)=>{e.selectedIntegrations=await t.prompt(R).run({type:"MultiSelect",hint:`
248
+ Press <space> to select/deselect, <enter> to confirm, <i> to invert selection`,message:"Which integrations would you like to include?",initial:fr().map((r,n)=>n),choices:e.availableIntegrations.map(({name:r,description:n})=>({name:r,message:[Bi.default.bold(r),n].join(" - "),value:r}))}),!e.selectedIntegrations||e.selectedIntegrations.length===0?t.title="No integrations selected.":t.title=["Selected integrations:",...e.selectedIntegrations.map(r=>Bi.default.bold(`\u2022 ${r}`))].join(`
249
+ `)}};var ef={title:"Install Nest CLI",task:async(e,t)=>q(t,async r=>{await vl({packages:["@nestjs/cli"],task:t,cwd:e.cwd}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1e3}};var Ws={title:"Install dependencies",task:async(e,t)=>q(t,async r=>{await Et({cwd:e.cwd,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()})};var rf=b(require("chalk"));var Cr={enabled:e=>!e.removeDir&&!ss(e.cwd),task:async(e,t)=>{if(e.removeDir=await t.prompt(R).run({type:"Toggle",message:rf.default.bold("\u26A0\uFE0F Overwrite existing directory?"),initial:!1}),!e.removeDir)throw new Error("Project creation was canceled by the user.")}},br={enabled:e=>!!e.removeDir,task:async e=>el(e.cwd)};var Gs={title:"Run integration commands",enabled:e=>e.selectedIntegrations.length>0,task:async(e,t)=>q(t,async r=>{let{selectedIntegrations:n,cwd:s}=e;await Gu({selectedIntegrations:n,cwd:s,task:t,packageManager:e.packageManager}),e.elapsedTime+=r()}),rendererOptions:{outputBar:1}};var Bw=["services/my-hono-service","services/my-nest-service","my-platform"],xr={enabled:e=>e.skipInputPrompts||e.userConfirmed?!1:e.projectName?Bw.includes(e.projectName):!0,task:async(e,t)=>{e.projectName=await t.prompt(R).run({type:"Input",initial:e.projectName,message:"Enter project name",validate:r=>r?!0:"Project name is required."}),e.cwd&&(e.cwd=S(e.projectName))}};var ji=b(require("chalk"));var vr={title:"Select Package manager",task:async(e,t)=>{if(e.packageManager??=Ko(),e.packageManager){t.title=`Using ${ji.default.bold(e.packageManager)} as package manager.`;return}e.packageManager=await t.prompt(R).run({type:"Select",message:"Which package manager would you like to use?",initial:Jo(),choices:xl}),t.title=`Using ${ji.default.bold(e.packageManager)} as package manager.`}};var bn=b(require("chalk")),nf={title:"GitHub repository owner",task:async(e,t)=>{if(e.githubOwner){t.title=`GitHub owner: ${bn.default.bold(e.githubOwner)}`;return}e.githubOwner=await t.prompt(R).run({type:"Input",message:"Enter GitHub organization or username",initial:"my-org",validate:r=>r?.trim()?!0:"GitHub owner is required."}),t.title=`GitHub owner: ${bn.default.bold(e.githubOwner)}`}},sf={title:"Include GitHub CI/CD",task:async(e,t)=>{if(e.includeGitHubCI!==void 0){t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD";return}e.includeGitHubCI=await t.prompt(R).run({type:"Toggle",message:"Include GitHub Actions workflows and CI/CD?",initial:!0,enabled:"Yes",disabled:"No"}),t.title=e.includeGitHubCI?"Including GitHub CI/CD workflows":"Skipping GitHub CI/CD"}};var of={title:"Pulumi stack name",task:async(e,t)=>{if(e.pulumiStackBase){t.title=`Pulumi stack: ${bn.default.bold(e.pulumiStackBase)}`;return}let r=e.githubOwner||"myorg",n=e.projectName?.replace(/[^a-zA-Z0-9-]/g,"-")||"myproject",s=`${r}/${n}`;e.pulumiStackBase=await t.prompt(R).run({type:"Input",message:"Enter Pulumi stack base name (org/project)",initial:s,validate:o=>o?.trim()?o.includes("/")?!0:"Format should be org/project (e.g., myorg/myproject)":"Pulumi stack name is required."}),t.title=`Pulumi stack: ${bn.default.bold(e.pulumiStackBase)}`}};var me=require("node:fs"),Wt=require("node:path");var Li=require("node:path");var jw=()=>mr([(0,Li.join)(__dirname,"templates","hono-microservice"),(0,Li.join)(__dirname,"..","hono-microservice","templates")],"Hono templates directory not found."),Hs=(e,t={})=>Ms(jw())(e,t);function af(){return Hs("tsconfig.json.hbs")}function cf(e="1.2.23"){return Hs("Dockerfile.hbs",{bunVersion:e})}function lf(){return Hs("biome.json.hbs")}function uf(e){return Hs("src/index.ts.hbs",{envKey:$s(e)})}var _w=async({projectName:e,packageManager:t},r)=>{let n=t==="bun"?"bun":"nodejs";try{await Yt("create-hono@latest",[e,"--pm",t,"--template",n,"--install"],{task:r})}catch(o){let i=(0,Wt.join)(S(e),"package.json");if(!(0,me.existsSync)(i))throw new Error(`Failed to scaffold: ${o instanceof Error?o.message:String(o)}`)}let s=(0,Wt.join)(S(e),"package.json");if(!(0,me.existsSync)(s))throw new Error("Failed to scaffold Hono app structure - package.json not created")},Lw=({projectName:e,packageManager:t})=>{let r=(0,Wt.basename)(e),n=is(),s=t==="npm"?"*":"workspace:*",o=S(e),i=nl("scripts.dev",o);i&&qt("scripts.start:dev",i,e),[{field:"name",value:`${n}/${r}`},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"devDependencies.bun-types",value:"latest",condition:t!=="bun"},{field:"devDependencies.@biomejs/biome",value:"latest"}].filter(({condition:c})=>c??!0).map(({field:c,value:l})=>qt(c,l,e))},Ww=({projectName:e})=>{let t=(0,Wt.basename)(e),r=(0,Wt.join)(S(e),"src","index.ts"),n=uf(t);(0,me.writeFileSync)(r,n)},Gw=({projectName:e})=>{let t=S(e),r=(0,Wt.join)(t,"tsconfig.json");(0,me.writeFileSync)(r,af());let n=(0,Wt.join)(t,"Dockerfile");(0,me.writeFileSync)(n,cf());let s=(0,Wt.join)(t,"biome.json");(0,me.writeFileSync)(s,lf())},pf={title:"Create Hono app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>q(t,async r=>{await _w(e,t),Lw(e),Ww(e),Gw(e),e.elapsedTime+=r()})};var Hw=e=>{let t=(e||"my-hono-service").trim();return t.includes("/")||t.startsWith(".")?t:`${kt().services}/${t}`},Uw=async(e,t)=>{let{valid:r,config:n,error:s}=pr();if(!r||!n){console.log(s);return}let o=Hw(e.name),i=t.packageManager||B(),a=await xs(t.description);if(vs(o,n,a),await ks({servicePath:o,description:a,serviceType:"hono",packageManager:i},n))console.log(te.default.green.bold(`
242
250
  \u2705 Service generated successfully!
243
- `)),console.log(Qt.default.dim("Next steps:")),console.log(Qt.default.dim(` ${Qt.default.cyan("pf dev")} - Start all services`)),console.log(Qt.default.dim(` ${Qt.default.cyan(`cd ${o} && bun dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},ef=se({name:"hono-micro",description:"Create a new Hono microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new hono-micro my-service --ai -d "Payment processing service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:mw,buildContext:async(e,t)=>{let r=(e.name??"my-hono-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${vt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&$()),o=St(),i=t.yes?ur():[],a=t.packageManager==="bun",c=!!t.yes||!!e.name&&e.name!=="my-hono-service";return{cwd:n,projectName:r,packageManager:s,shouldInstallBun:a,availableIntegrations:o,selectedIntegrations:i,serviceType:"hono",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[wr,Dr,gr,Cr,js,dr],actions:[yr,mr,Qp,$s,Bs,Ls],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r,assignedPort:n})=>{w.breakLine().log(Qt.default.bold.green("Hono Microservice created successfully!")),Ss(r),Al((0,tf.basename)(e),n??8080);let s=t??$();w.breakLine().log(`To start the project, run:
244
- ${Qt.default.bold(`cd ${e} && ${s} run dev`)}`).breakLine().log("Happy shipping with Hono! \u26A1\uFE0F").breakLine()}});var te=b(require("chalk"));var Tt=require("node:fs"),ct=require("node:path");var Bi=require("node:path");var gw=()=>fr([(0,Bi.join)(__dirname,"templates","nest-microservice"),(0,Bi.join)(__dirname,"..","nest-microservice","templates")],"NestJS templates directory not found."),br=(e,t={})=>Os(gw())(e,t);function Ws(e,t=3e3){return br("src/main.ts.hbs",{serviceName:e,envKey:Dn(e),displayName:jp(e),defaultPort:t})}function rf(){return br("src/app.context.ts.hbs",{})}function nf(){return br("src/events/events.module.ts.hbs",{})}function sf(e){return br("src/events/events.service.ts.hbs",{serviceName:e})}function of(e="24",t="1.2.23"){return br("Dockerfile.hbs",{nodeVersion:e,bunVersion:t})}function af(){return br("biome.json.hbs",{})}var Dw=async(e,t)=>{await qt("@nestjs/cli",["new",e.projectName,"--skip-install","--skip-git","--package-manager",e.packageManager],{task:t})},yw=({projectName:e,packageManager:t})=>{let r=(0,ct.basename)(e),n=ns(),s=t==="npm"?"*":"workspace:*";[{field:"name",value:`${n}/${r}`},{field:"type",value:"module"},{field:"scripts.start",value:"bun src/main.ts"},{field:"scripts.start:dev",value:"bun --hot src/main.ts"},{field:"scripts.start:prod",value:"node dist/main.js"},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"dependencies.@nestjs/config",value:"^4"},{field:"devDependencies.bun-types",value:"latest"},{field:"devDependencies.@biomejs/biome",value:"latest"}].map(({field:a,value:c})=>Jt(a,c,e)),["jest","@types/jest","ts-jest","@nestjs/testing","supertest","@types/supertest","ts-node","tsconfig-paths","@nestjs/schematics","@nestjs/cli"].map(a=>Jt(`devDependencies.${a}`,void 0,e))},ww=({projectName:e})=>{let t=["eslint.config.mjs","src/app.controller.spec.ts"];for(let r of t)try{(0,Tt.unlinkSync)((0,ct.join)(S(e),r))}catch{}},Cw=({projectName:e})=>{let t=S(e),r=(0,ct.join)(t,"Dockerfile");(0,Tt.writeFileSync)(r,of());let n=(0,ct.join)(t,"biome.json");(0,Tt.writeFileSync)(n,af())},bw=({projectName:e})=>{let t=(0,ct.join)(S(e),"src","app.context.ts");(0,Tt.writeFileSync)(t,rf())},vw=({projectName:e})=>{let t=(0,ct.basename)(e),r=(0,ct.join)(S(e),"src","events");(0,Tt.mkdirSync)(r,{recursive:!0}),(0,Tt.writeFileSync)((0,ct.join)(r,"events.module.ts"),nf()),(0,Tt.writeFileSync)((0,ct.join)(r,"events.service.ts"),sf(t)),Ml(e)},xw=({projectName:e})=>{let t=(0,ct.basename)(e),r=(0,ct.join)(S(e),"src","main.ts");(0,Tt.writeFileSync)(r,Ws(t))},cf={title:"Create NestJS app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>K(t,async r=>{await Dw(e,t),yw(e),Nl(e.projectName),ww(e),Cw(e),bw(e),vw(e),xw(e),e.elapsedTime+=r()})};var uf=require("node:fs"),Gs=require("node:path");var lf={title:"Patch main.ts with PORT pattern",task:async(e,t)=>K(t,async r=>{let n=(0,Gs.basename)(e.projectName),s=e.assignedPort??3e3,o=(0,Gs.join)(S(e.projectName),"src","main.ts");(0,uf.writeFileSync)(o,Ws(n,s)),t.title=`Patched main.ts with PORT || ${n.toUpperCase().replace(/-/g,"_")}_PORT`,e.elapsedTime+=r()})};var kw=e=>{let t=(e||"my-nest-service").trim();return t.includes("/")||t.startsWith(".")?t:`${vt().services}/${t}`},Ew=async(e,t)=>{let{valid:r,config:n,error:s}=cr();if(!r||!n){console.log(s);return}let o=kw(e.name),i=t.packageManager||$(),a=await bs(t.description);if(vs(o,n,a),await xs({servicePath:o,description:a,serviceType:"nest",packageManager:i},n))console.log(te.default.green.bold(`
251
+ `)),console.log(te.default.dim("Next steps:")),console.log(te.default.dim(` ${te.default.cyan("pf dev")} - Start all services`)),console.log(te.default.dim(` ${te.default.cyan(`cd ${o} && bun dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},df=oe({name:"hono-micro",description:"Create a new Hono microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new hono-micro my-service --ai -d "Payment processing service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:Uw,buildContext:async(e,t)=>{let r=(e.name??"my-hono-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${kt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&B()),o=Ft(),i=t.yes?fr():[],a=t.packageManager==="bun",c=!!t.yes||!!e.name&&e.name!=="my-hono-service";return{cwd:n,projectName:r,packageManager:s,shouldInstallBun:a,availableIntegrations:o,selectedIntegrations:i,serviceType:"hono",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[xr,Cr,wr,vr,Ls,gr],actions:[br,yr,pf,js,_s,Gs],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r,assignedPort:n})=>{w.breakLine().log(te.default.bold.green("Hono Microservice created successfully!")),Fs(r),_u((0,ff.basename)(e),n??8080);let s=t??B();w.breakLine().log(`To start the project, run:
252
+ ${te.default.bold(`cd ${e} && ${s} run dev`)}`).breakLine().log("Happy shipping with Hono! \u26A1\uFE0F").breakLine()}});var ee=b(require("chalk"));var At=require("node:fs"),pt=require("node:path");var Wi=require("node:path");var zw=()=>mr([(0,Wi.join)(__dirname,"templates","nest-microservice"),(0,Wi.join)(__dirname,"..","nest-microservice","templates")],"NestJS templates directory not found."),kr=(e,t={})=>Ms(zw())(e,t);function Us(e,t=3e3){return kr("src/main.ts.hbs",{serviceName:e,envKey:$s(e),displayName:qp(e),defaultPort:t})}function hf(){return kr("src/app.context.ts.hbs",{})}function mf(){return kr("src/events/events.module.ts.hbs",{})}function gf(e){return kr("src/events/events.service.ts.hbs",{serviceName:e})}function Df(e="24",t="1.2.23"){return kr("Dockerfile.hbs",{nodeVersion:e,bunVersion:t})}function yf(){return kr("biome.json.hbs",{})}var Kw=async(e,t)=>{await Yt("@nestjs/cli",["new",e.projectName,"--skip-install","--skip-git","--package-manager",e.packageManager],{task:t})},Jw=({projectName:e,packageManager:t})=>{let r=(0,pt.basename)(e),n=is(),s=t==="npm"?"*":"workspace:*";[{field:"name",value:`${n}/${r}`},{field:"type",value:"module"},{field:"scripts.start",value:"bun src/main.ts"},{field:"scripts.start:dev",value:"bun --hot src/main.ts"},{field:"scripts.start:prod",value:"node dist/main.js"},{field:"scripts.test",value:"bun test"},{field:"scripts.lint",value:"biome lint --write ./src"},{field:`dependencies.${n}/contracts`,value:s},{field:"dependencies.@crossdelta/telemetry",value:"*"},{field:"dependencies.@nestjs/config",value:"^4"},{field:"devDependencies.bun-types",value:"latest"},{field:"devDependencies.@biomejs/biome",value:"latest"}].map(({field:a,value:c})=>qt(a,c,e)),["jest","@types/jest","ts-jest","@nestjs/testing","supertest","@types/supertest","ts-node","tsconfig-paths","@nestjs/schematics","@nestjs/cli"].map(a=>qt(`devDependencies.${a}`,void 0,e))},qw=({projectName:e})=>{let t=["eslint.config.mjs","src/app.controller.spec.ts"];for(let r of t)try{(0,At.unlinkSync)((0,pt.join)(S(e),r))}catch{}},Vw=({projectName:e})=>{let t=S(e),r=(0,pt.join)(t,"Dockerfile");(0,At.writeFileSync)(r,Df());let n=(0,pt.join)(t,"biome.json");(0,At.writeFileSync)(n,yf())},Yw=({projectName:e})=>{let t=(0,pt.join)(S(e),"src","app.context.ts");(0,At.writeFileSync)(t,hf())},Zw=({projectName:e})=>{let t=(0,pt.basename)(e),r=(0,pt.join)(S(e),"src","events");(0,At.mkdirSync)(r,{recursive:!0}),(0,At.writeFileSync)((0,pt.join)(r,"events.module.ts"),mf()),(0,At.writeFileSync)((0,pt.join)(r,"events.service.ts"),gf(t)),zu(e)},Xw=({projectName:e})=>{let t=(0,pt.basename)(e),r=(0,pt.join)(S(e),"src","main.ts");(0,At.writeFileSync)(r,Us(t))},wf={title:"Create NestJS app structure",rendererOptions:{outputBar:1e3},task:async(e,t)=>q(t,async r=>{await Kw(e,t),Jw(e),Hu(e.projectName),qw(e),Vw(e),Yw(e),Zw(e),Xw(e),e.elapsedTime+=r()})};var Cf=require("node:fs"),zs=require("node:path");var bf={title:"Patch main.ts with PORT pattern",task:async(e,t)=>q(t,async r=>{let n=(0,zs.basename)(e.projectName),s=e.assignedPort??3e3,o=(0,zs.join)(S(e.projectName),"src","main.ts");(0,Cf.writeFileSync)(o,Us(n,s)),t.title=`Patched main.ts with PORT || ${n.toUpperCase().replace(/-/g,"_")}_PORT`,e.elapsedTime+=r()})};var Qw=e=>{let t=(e||"my-nest-service").trim();return t.includes("/")||t.startsWith(".")?t:`${kt().services}/${t}`},tC=async(e,t)=>{let{valid:r,config:n,error:s}=pr();if(!r||!n){console.log(s);return}let o=Qw(e.name),i=t.packageManager||B(),a=await xs(t.description);if(vs(o,n,a),await ks({servicePath:o,description:a,serviceType:"nest",packageManager:i},n))console.log(ee.default.green.bold(`
245
253
  \u2705 Service generated successfully!
246
- `)),console.log(te.default.dim("Next steps:")),console.log(te.default.dim(` ${te.default.cyan("pf dev")} - Start all services`)),console.log(te.default.dim(` ${te.default.cyan(`cd ${o} && bun run start:dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},pf=se({name:"nest-micro",description:"Create a new NestJS microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new nest-micro my-service --ai -d "User authentication service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:Ew,buildContext:async(e,t)=>{let r=(e.name??"my-nest-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${vt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&$()),o=t.packageManager==="bun",i=St(),a=t.yes?ur():[],c=!!t.yes||!!e.name;return{cwd:n,projectName:r,shouldInstallBun:o,packageManager:s,availableIntegrations:i,selectedIntegrations:a,serviceType:"nest",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[wr,Dr,gr,Cr,js,dr],actions:[yr,mr,cf,$s,lf,_s,zp,Bs,Ls],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r})=>{w.breakLine().log(te.default.bold.green("NestJS Microservice created successfully!")),Ss(r),w.breakLine().log(`To start the project, run:
247
- ${te.default.bold(`cd ${e} && ${t} run start:dev`)}`).breakLine().log("Happy coding! \u{1F389}").breakLine()}});var ut=b(require("chalk"));var At=require("node:fs"),vr=require("node:path");var ff=require("node:fs"),Hs=require("node:path");var ji=()=>fr([(0,Hs.join)(__dirname,"templates","workspace"),(0,Hs.join)(__dirname,"..","..","..","..","templates","workspace")],"Workspace templates directory not found."),df=()=>{let e=ji(),t=(0,Hs.join)(e,"packages","contracts");if(!(0,ff.existsSync)(t))throw new Error(`Contracts templates directory not found at: ${t}`);return t},Us=(e,t)=>Pi(e,t);var Sw=()=>{let e=(0,vr.join)(process.cwd(),"package.json");if(!(0,At.existsSync)(e))throw new Error("Root package.json not found. Please run this command from the workspace root.");let r=JSON.parse((0,At.readFileSync)(e,"utf-8")).name;if(!r)throw new Error('package.json must have a "name" field');return r.startsWith("@")?r:`@${r}`},hf=()=>{let e=Sw(),{relativePath:t,packagePath:r}=G();if((0,At.existsSync)(r))throw new Error(`${t} already exists. Remove it first if you want to regenerate.`);console.log(`Creating contracts package with scope: ${e}`);let n=df(),s={scope:e};(0,At.mkdirSync)(r,{recursive:!0}),(0,At.mkdirSync)((0,vr.join)(r,"src","streams"),{recursive:!0}),(0,At.mkdirSync)((0,vr.join)(r,"src","events"),{recursive:!0});let o=[{template:"package.json.hbs",output:"package.json"},{template:"tsconfig.json.hbs",output:"tsconfig.json"},{template:"README.md.hbs",output:"README.md"},{template:"src/index.ts",output:"src/index.ts"}];for(let i of o){let a=(0,vr.join)(n,i.template),c=(0,vr.join)(r,i.output),u=Us(a,s);(0,At.writeFileSync)(c,u,"utf-8")}console.log(`\u2705 Created ${e}/contracts at ${t}`),console.log(`
248
- Next steps:`),console.log("1. Run: bun install"),console.log("2. Define your first event schema in src/events/"),console.log('3. Add contracts to services: "@scope/contracts": "workspace:*"')};var gf=require("node:child_process"),st=require("node:fs"),xr=require("node:path");var mf=e=>{e.endsWith(".sh")&&(0,st.chmodSync)(e,493)},Fw=[{template:"package.json.hbs",output:"package.json"},{template:"pnpm-workspace.yaml.hbs",output:"pnpm-workspace.yaml",forPackageManager:"pnpm"},{template:"biome.json.hbs",output:"biome.json"},{template:"turbo.json.hbs",output:"turbo.json"},{template:"bunfig.toml.hbs",output:"bunfig.toml"},{template:"gitignore.hbs",output:".gitignore"},{template:"editorconfig.hbs",output:".editorconfig"},{template:"npmrc.hbs",output:".npmrc"},{template:".vscode/settings.json",output:".vscode/settings.json",isStatic:!0},{template:".vscode/extensions.json",output:".vscode/extensions.json",isStatic:!0},{template:"infra/package.json.hbs",output:"infra/package.json"},{template:"infra/index.ts.hbs",output:"infra/index.ts"},{template:"infra/tsconfig.json.hbs",output:"infra/tsconfig.json"},{template:"infra/Pulumi.yaml.hbs",output:"infra/Pulumi.yaml"},{template:"infra/Pulumi.dev.yaml.hbs",output:"infra/Pulumi.dev.yaml"},{template:"infra/services/nats.ts.hbs",output:"infra/services/nats.ts"},{template:"services/nats/package.json.hbs",output:"services/nats/package.json"},{template:"services/nats/nats.conf",output:"services/nats/nats.conf",isStatic:!0},{template:"services/nats/nats.prod.conf",output:"services/nats/nats.prod.conf",isStatic:!0},{template:"services/nats/README.md",output:"services/nats/README.md",isStatic:!0},{template:"services/nats/scripts/start-dev.sh.hbs",output:"services/nats/scripts/start-dev.sh"},{template:"apps/.gitkeep",output:"apps/.gitkeep",isStatic:!0},{template:"packages/.gitkeep",output:"packages/.gitkeep",isStatic:!0},{template:"docs/.gitkeep",output:"docs/.gitkeep",isStatic:!0},{template:".github/copilot-instructions.md.hbs",output:".github/copilot-instructions.md"},{template:".github/README.md",output:".github/README.md",isStatic:!0,isGitHubCI:!0},{template:".github/dependabot.yml",output:".github/dependabot.yml",isStatic:!0,isGitHubCI:!0},{template:".github/workflows/lint-and-tests.yml.hbs",output:".github/workflows/lint-and-tests.yml",isGitHubCI:!0},{template:".github/workflows/build-and-deploy.yml.hbs",output:".github/workflows/build-and-deploy.yml",isGitHubCI:!0},{template:".github/workflows/publish-packages.yml",output:".github/workflows/publish-packages.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/setup-bun-install/action.yml.hbs",output:".github/actions/setup-bun-install/action.yml",isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/action.yml",output:".github/actions/check-image-tag-exists/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/index.js",output:".github/actions/check-image-tag-exists/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/action.yml",output:".github/actions/check-path-changes/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/index.js",output:".github/actions/check-path-changes/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/detect-skipped-services/action.yml",output:".github/actions/detect-skipped-services/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/action.yml",output:".github/actions/generate-scope-matrix/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/index.js",output:".github/actions/generate-scope-matrix/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/prepare-build-context/action.yml",output:".github/actions/prepare-build-context/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/action.yml",output:".github/actions/resolve-scope-tags/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/index.js",output:".github/actions/resolve-scope-tags/index.js",isStatic:!0,isGitHubCI:!0}],Df={title:"Creating workspace structure",task:async(e,t)=>{if((0,st.existsSync)(e.cwd)){t.title="Workspace directory already exists, skipping...";return}let r=ji(),n=e.includeGitHubCI??!0,s=e.packageManager||"bun",o=c=>{try{let p=(0,gf.spawnSync)(c,["--version"],{encoding:"utf-8",timeout:5e3}).stdout?.trim();if(p&&/^\d+\.\d+/.test(p))return`${c}@${p}`}catch{}return{bun:"bun@1.2.7",npm:"npm@10.9.2",yarn:"yarn@4.6.0",pnpm:"pnpm@9.15.2"}[c]||`${c}@latest`},i={projectName:e.projectName,githubOwner:e.githubOwner||"",pulumiStackBase:e.pulumiStackBase||e.projectName,packageManager:s,packageManagerVersion:o(s)},a=Fw.filter(c=>!(c.isGitHubCI&&!n||c.forPackageManager&&c.forPackageManager!==s));for(let c of a){let u=(0,xr.join)(e.cwd,c.output),l=(0,xr.dirname)(u);if((0,st.existsSync)(l)||(0,st.mkdirSync)(l,{recursive:!0}),c.isStatic){let p=(0,xr.join)(r,c.template);(0,st.existsSync)(p)?(0,st.writeFileSync)(u,(0,st.readFileSync)(p)):(0,st.writeFileSync)(u,""),mf(u)}else{let p=(0,xr.join)(r,c.template),d=Us(p,i);(0,st.writeFileSync)(u,d),mf(u)}}t.title="Workspace structure created"}};var yf=se({name:"workspace",description:"Create a new workspace with infrastructure setup",arguments:[["[name]","Name or path of the workspace"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["-o, --github-owner <owner>","GitHub organization or username"],["-s, --pulumi-stack <name>","Pulumi stack base name (org/project)"],["--no-github","Skip GitHub CI/CD workflows"],["--remove-dir","Remove existing directory before creating (internal use)"]],exampleUsage:"pf new workspace my-platform -o my-org",buildContext:(e,t)=>{let r=(e.name??"my-platform").trim(),n=S(r),s=!!t.yes,o=t.packageManager??(s?$():void 0),i=t.packageManager==="bun",a=t.githubOwner??(s?"my-org":void 0),c=t.pulumiStack??(s?`${a}/${r}`:void 0),u=t.github===!1?!1:s?!0:void 0,l=!!e.name,p=t.removeDir||s;return{cwd:n,projectName:r,shouldInstallBun:i,packageManager:o,elapsedTime:0,userConfirmed:s,skipInputPrompts:l&&!s,removeDir:p,githubOwner:a,pulumiStackBase:c,includeGitHubCI:u}},prompts:[{enabled:e=>!e.userConfirmed,task:async(e,t)=>{try{let r=O();if(!await t.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${r}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");t.title=ut.default.yellow("Warning: Creating nested workspace")}catch(r){if(r.message?.includes("cancelled"))throw r;t.title="No existing workspace detected"}}},wr,Dr,Jp,Vp,qp,gr,Cr,dr],actions:[yr,mr,Df,{title:"Initializing contracts package",task:(e,t)=>{let r=process.cwd();try{process.chdir(e.cwd),hf(),t.title="Contracts package initialized"}catch(n){throw t.title=ut.default.red(`Contracts package failed: ${n.message}`),n}finally{process.chdir(r)}}},_s,Up],onComplete:({projectName:e,includeGitHubCI:t})=>{w.breakLine().log(ut.default.bold.green("Workspace created successfully!")),w.breakLine().log(ut.default.bold("Next steps:")).log(` 1. ${ut.default.cyan(`cd ${e}`)}`).log(` 2. ${ut.default.cyan("bun pulumi login")}`).log(` 3. ${ut.default.cyan("bun pulumi up --stack dev")}`),t&&w.breakLine().log(ut.default.bold("GitHub Setup:")).log(" Configure these secrets in your GitHub repository:").log(` \u2022 ${ut.default.yellow("PULUMI_ACCESS_TOKEN")} - Pulumi Cloud access token`).log(` \u2022 ${ut.default.yellow("DIGITALOCEAN_TOKEN")} - DigitalOcean API token`).log(` \u2022 ${ut.default.yellow("NPM_TOKEN")} - (optional) NPM token for private packages`),w.breakLine().log(ut.default.bold("Structure created:")).log(" apps/ # Frontend applications").log(" services/ # Backend microservices").log(" packages/").log(" \u2514\u2500\u2500 contracts/ # Shared event contracts").log(" infra/").log(" \u251C\u2500\u2500 index.ts # Pulumi entry point").log(" \u251C\u2500\u2500 services/ # Service configs").log(" \u251C\u2500\u2500 Pulumi.yaml # Pulumi project config").log(" \u2514\u2500\u2500 Pulumi.dev.yaml # Dev stack config"),t&&w.log(" .github/").log(" \u251C\u2500\u2500 workflows/ # CI/CD workflows").log(" \u2514\u2500\u2500 actions/ # Custom actions"),w.breakLine().log("Happy coding! \u{1F389}").breakLine()}});var Cn=[{name:"Hono Microservice",value:"hono-micro",command:ef,supportsAi:!0},{name:"Nest Microservice",value:"nest-micro",command:pf,supportsAi:!0},{name:"Workspace (Infrastructure)",value:"workspace",command:yf,supportsAi:!1}],wf=()=>{let e=se({name:"new",description:"Create a new project",arguments:[["[type]","Type of the project (e.g., nest-micro, hono-micro, workspace)"]],exampleUsage:"platform new hono-micro test-service",buildContext:t=>({projectType:t.type??"",useAi:!1,aiDescription:"",elapsedTime:0,cwd:process.cwd()}),prompts:[{enabled:t=>!t.projectType,task:async(t,r)=>{let n=await r.prompt(R).run({type:"select",message:"Select Project type",choices:Cn});t.projectType=Cn.find(s=>s.name===n)?.value||"",r.title=`Using ${ee.default.bold(n)}`}},{enabled:t=>t.projectType!=="workspace"&&t.projectType!=="",task:async(t,r)=>{try{O(),r.title="Workspace detected"}catch{let n=["Not in a workspace directory","",`Current directory: ${process.cwd()}`,"","This command must be run from within a workspace created with pf new workspace","","To create a new workspace, run:",""," pf new workspace my-platform"].join(`
249
- `);throw new Error(n)}}},{enabled:t=>t.projectType==="workspace",task:async(t,r)=>{try{let n=O();if(!await r.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${n}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");r.title=ee.default.yellow("Warning: Creating nested workspace")}catch(n){if(n.message?.includes("cancelled"))throw n;r.title="No existing workspace detected"}}},{enabled:t=>!!t.projectType,task:async(t,r)=>{let s={"hono-micro":"services/my-hono-service","nest-micro":"services/my-nest-service",workspace:"my-platform"}[t.projectType]||"my-project",o=t.projectType==="workspace"?"\u{1F4E6} Workspace name:":"\u{1F4E6} Service path (e.g., services/my-service):",i=await r.prompt(R).run({type:"input",message:o,initial:s});t.servicePath=i.trim(),r.title=`Path: ${ee.default.dim(i)}`}},{enabled:t=>!!Cn.find(n=>n.value===t.projectType)?.supportsAi&&cr().valid,task:async(t,r)=>{let n=await r.prompt(R).run({type:"toggle",message:"Use AI to generate service code?",enabled:"Yes",disabled:"No",initial:!1});t.useAi=n,r.title=n?ee.default.cyan("\u{1F916} AI-powered generation"):"Standard scaffolding"}},{enabled:t=>t.useAi,task:async(t,r)=>{let n=await r.prompt(R).run({type:"input",message:"Describe what this service should do:"});t.aiDescription=n,r.title=`Description: ${ee.default.dim(n.slice(0,50))}${n.length>50?"...":""}`}},{enabled:t=>{if(!t.servicePath)return!1;let r=S(t.servicePath);return!es(r)},task:async(t,r)=>{if(!await r.prompt(R).run({type:"toggle",message:ee.default.bold("\u26A0\uFE0F Overwrite existing directory?"),enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Project creation was canceled by the user.");t.shouldRemoveDir=!0,r.title=ee.default.yellow("Will overwrite existing directory")}},{title:"Confirm creation",enabled:t=>t.projectType!=="workspace",task:async(t,r)=>{if(!await r.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}))throw new Error("Project creation was canceled by the user.")}}],actions:[],onComplete:async t=>{Cn.find(o=>o.value===t.projectType)||e.error(ee.default.red(`Project type ${t.projectType} is not supported.`));let r=e.commands.find(o=>o.name()===t.projectType),n={};t.projectType!=="workspace"&&(n.yes=!0);let s=[];t.servicePath&&s.push("servicePath"),t.shouldRemoveDir&&(n.removeDir=!0),t.useAi&&(n.ai=!0,n.description=t.aiDescription),await _p(r,t,n,s)}});for(let t of Cn)e.addCommand(t.command);return e};var vf=require("commander");var zs=b(require("chalk"));var Li=e=>new Promise(t=>setTimeout(t,e)),_i=e=>process.stdout.write(`${e}
250
- `),Tw=()=>{process.stdout.write("\x1B[?1049l"),process.stdout.write("\x1B[2J"),process.stdout.write("\x1B[3J"),process.stdout.write("\x1B[H"),process.stdout.write("\x1B[?25h"),process.stdout.isTTY&&process.stdout.write("\x1Bc")},Cf=()=>({turboProcess:null,isRestarting:!1,isShuttingDown:!1}),bf=async(e,t)=>{let r=lu(".env.local",t);r.length>0&&(await hu(r),await Li(50)),_i(zs.default.cyan("\u{1F525} Starting services...")),_i(zs.default.dim(` Command: turbo run ${to} --continue`)),e.isShuttingDown=!1,e.isRestarting=!1,e.turboProcess=du("turbo",["run",to,"--continue","--no-daemon"],{cwd:t,envFile:".env.local",onExit:n=>{!e.isRestarting&&!e.isShuttingDown&&(_i(`
251
- ${zs.default.red("Turbo exited with code")} ${n}`),process.exit(n??0))}})},Wi=async(e,t=!1)=>{let r=e.turboProcess?.pid;if(r){t?e.isRestarting=!0:e.isShuttingDown=!0;try{try{process.kill(-r,"SIGTERM")}catch{e.turboProcess?.kill("SIGTERM")}await Li(200);try{process.kill(-r,"SIGKILL")}catch{}await Li(30)}catch{}e.turboProcess=null,Tw()}};var Aw=300,xf=new vf.Command("dev").description("Start development mode with auto-reload").action(async()=>{let e=O(),t=Cf(),r=c=>tn("generate-env",{cwd:c}),n=()=>xt({cwd:e,quiet:!0}),s=async()=>{await n(),await r(e),await bf(t,e)},o=async()=>{if(!(t.isRestarting||t.isShuttingDown)){t.isRestarting=!0;try{await Wi(t,!0),await s()}catch{}finally{t.isRestarting=!1}}},i=(()=>{let c=null;return async()=>{t.isRestarting||t.isShuttingDown||(c&&clearTimeout(c),c=setTimeout(()=>o(),Aw))}})(),a=async()=>{await Wi(t,!1),process.exit(0)};await s(),_u(e,i),process.on("SIGINT",a),process.on("SIGTERM",a)});var _f=require("commander");var kf=require("node:fs"),Ef=require("node:path"),Gt=b(require("chalk")),Sf=require("commander");var Pw=e=>{if(e)try{return JSON.parse(e)}catch{return}},Rw=e=>{if(!e)return;let t={},r=e.split(",").map(n=>n.trim()).filter(Boolean);for(let n of r){let[s,o]=n.split(":").map(i=>i.trim());s&&o&&(t[s]=o)}return Object.keys(t).length>0?t:void 0},Iw=(e,t)=>{if(!t)return;let r=t.startsWith("/")?t:(0,Ef.resolve)(e,t);return(0,kf.existsSync)(r)?r:void 0},Nw=async(e,t)=>{let r=[],n=[],s=[];if(Jo(e)&&!t.force)n.push("Contract (already exists)");else{let i=Vo(e,t.schema);r.push(`Contract: ${i}`)}ni(e)&&r.push("Export: packages/contracts/src/index.ts");let o=await ms(e);if(o&&r.push(`Mock: ${o}`),t.servicePath){let i=Xo(e,t.servicePath);i?r.push(`Handler: ${i}`):n.push("Handler (already exists)");let a=Zo(t.servicePath,e);a.added?r.push(`Stream: ${a.streamName} added to index.ts`):a.warning&&s.push(a.warning)}return{created:r,skipped:n,warnings:s}},Ow=(e,t,r=[])=>{if(e.length>0){console.log(Gt.default.green(`\u2713 Created:
252
- `));for(let n of e)console.log(Gt.default.dim(` ${n}`))}if(t.length>0){console.log(Gt.default.yellow(`
254
+ `)),console.log(ee.default.dim("Next steps:")),console.log(ee.default.dim(` ${ee.default.cyan("pf dev")} - Start all services`)),console.log(ee.default.dim(` ${ee.default.cyan(`cd ${o} && bun run start:dev`)} - Start this service only`)),console.log();else throw new Error("Service generation failed")},xf=oe({name:"nest-micro",description:"Create a new NestJS microservice with the Crossdelta setup. Use --ai for AI-powered generation.",arguments:[["[name]","Name or path of the service"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["--ai","Use AI to generate service code based on a description"],["-d, --description <description>","Service description for AI generation (requires --ai)"],["--remove-dir","Remove existing directory before creating (used internally)"]],exampleUsage:'platform new nest-micro my-service --ai -d "User authentication service"',shouldSkipWorkflow:(e,t)=>!!t.ai,onSkipWorkflow:tC,buildContext:async(e,t)=>{let r=(e.name??"my-nest-service").trim();!r.includes("/")&&!r.startsWith(".")&&(r=`${kt().services}/${r}`);let n=S(r),s=t.packageManager??(t.yes&&B()),o=t.packageManager==="bun",i=Ft(),a=t.yes?fr():[],c=!!t.yes||!!e.name;return{cwd:n,projectName:r,shouldInstallBun:o,packageManager:s,availableIntegrations:i,selectedIntegrations:a,serviceType:"nest",elapsedTime:0,userConfirmed:!!t.yes,skipInputPrompts:c,removeDir:!!t.removeDir||!!t.yes}},prompts:[xr,Cr,wr,vr,Ls,gr],actions:[br,yr,wf,js,bf,Ws,ef,_s,Gs],onComplete:({projectName:e,packageManager:t,selectedIntegrations:r})=>{w.breakLine().log(ee.default.bold.green("NestJS Microservice created successfully!")),Fs(r),w.breakLine().log(`To start the project, run:
255
+ ${ee.default.bold(`cd ${e} && ${t} run start:dev`)}`).breakLine().log("Happy coding! \u{1F389}").breakLine()}});var ft=b(require("chalk"));var Gt=require("node:fs"),xn=require("node:path");var vf=require("node:fs"),Ks=require("node:path");var Gi=()=>mr([(0,Ks.join)(__dirname,"templates","workspace"),(0,Ks.join)(__dirname,"..","..","..","..","templates","workspace")],"Workspace templates directory not found."),kf=()=>{let e=Gi(),t=(0,Ks.join)(e,"packages","contracts");if(!(0,vf.existsSync)(t))throw new Error(`Contracts templates directory not found at: ${t}`);return t},Js=(e,t)=>Mi(e,t);var eC=()=>{let e=(0,xn.join)(process.cwd(),"package.json");if(!(0,Gt.existsSync)(e))throw new Error("Root package.json not found. Please run this command from the workspace root.");let r=JSON.parse((0,Gt.readFileSync)(e,"utf-8")).name;if(!r)throw new Error('package.json must have a "name" field');return r.startsWith("@")?r:`@${r}`},Ef=()=>{let e=eC(),{relativePath:t,packagePath:r}=$();if((0,Gt.existsSync)(r))throw new Error(`${t} already exists. Remove it first if you want to regenerate.`);console.log(`Creating contracts package with scope: ${e}`);let n=kf(),s={scope:e,workspaceName:e.replace("@","").replace("/","-")};(0,Gt.mkdirSync)(r,{recursive:!0}),(0,Gt.mkdirSync)((0,xn.join)(r,"src","events"),{recursive:!0});let o=[{template:"package.json.hbs",output:"package.json"},{template:"tsconfig.json.hbs",output:"tsconfig.json"},{template:"README.md.hbs",output:"README.md"},{template:"src/index.ts",output:"src/index.ts"},{template:"src/stream-policies.ts.hbs",output:"src/stream-policies.ts"},{template:"src/events/index.ts",output:"src/events/index.ts"}];for(let i of o){let a=(0,xn.join)(n,i.template),c=(0,xn.join)(r,i.output),l=Js(a,s);(0,Gt.writeFileSync)(c,l,"utf-8")}console.log(`\u2705 Created ${e}/contracts at ${t}`),console.log(`
256
+ Next steps:`),console.log("1. Run: bun install"),console.log("2. Define your first event schema in src/events/"),console.log('3. Add contracts to services: "@scope/contracts": "workspace:*"')};var Ff=require("node:child_process"),it=require("node:fs"),Er=require("node:path");var Sf=e=>{e.endsWith(".sh")&&(0,it.chmodSync)(e,493)},rC=[{template:"package.json.hbs",output:"package.json"},{template:"pnpm-workspace.yaml.hbs",output:"pnpm-workspace.yaml",forPackageManager:"pnpm"},{template:"biome.json.hbs",output:"biome.json"},{template:"turbo.json.hbs",output:"turbo.json"},{template:"bunfig.toml.hbs",output:"bunfig.toml"},{template:"gitignore.hbs",output:".gitignore"},{template:"editorconfig.hbs",output:".editorconfig"},{template:"npmrc.hbs",output:".npmrc"},{template:".vscode/settings.json",output:".vscode/settings.json",isStatic:!0},{template:".vscode/extensions.json",output:".vscode/extensions.json",isStatic:!0},{template:"infra/package.json.hbs",output:"infra/package.json"},{template:"infra/index.ts.hbs",output:"infra/index.ts"},{template:"infra/tsconfig.json.hbs",output:"infra/tsconfig.json"},{template:"infra/Pulumi.yaml.hbs",output:"infra/Pulumi.yaml"},{template:"infra/Pulumi.dev.yaml.hbs",output:"infra/Pulumi.dev.yaml"},{template:"apps/.gitkeep",output:"apps/.gitkeep",isStatic:!0},{template:"packages/.gitkeep",output:"packages/.gitkeep",isStatic:!0},{template:"docs/.gitkeep",output:"docs/.gitkeep",isStatic:!0},{template:"infra/services/.gitkeep",output:"infra/services/.gitkeep",isStatic:!0},{template:".github/copilot-instructions.md.hbs",output:".github/copilot-instructions.md"},{template:".github/README.md",output:".github/README.md",isStatic:!0,isGitHubCI:!0},{template:".github/dependabot.yml",output:".github/dependabot.yml",isStatic:!0,isGitHubCI:!0},{template:".github/workflows/lint-and-tests.yml.hbs",output:".github/workflows/lint-and-tests.yml",isGitHubCI:!0},{template:".github/workflows/build-and-deploy.yml.hbs",output:".github/workflows/build-and-deploy.yml",isGitHubCI:!0},{template:".github/workflows/publish-packages.yml",output:".github/workflows/publish-packages.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/setup-bun-install/action.yml.hbs",output:".github/actions/setup-bun-install/action.yml",isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/action.yml",output:".github/actions/check-image-tag-exists/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-image-tag-exists/index.js",output:".github/actions/check-image-tag-exists/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/action.yml",output:".github/actions/check-path-changes/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/check-path-changes/index.js",output:".github/actions/check-path-changes/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/detect-skipped-services/action.yml",output:".github/actions/detect-skipped-services/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/action.yml",output:".github/actions/generate-scope-matrix/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/generate-scope-matrix/index.js",output:".github/actions/generate-scope-matrix/index.js",isStatic:!0,isGitHubCI:!0},{template:".github/actions/prepare-build-context/action.yml",output:".github/actions/prepare-build-context/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/action.yml",output:".github/actions/resolve-scope-tags/action.yml",isStatic:!0,isGitHubCI:!0},{template:".github/actions/resolve-scope-tags/index.js",output:".github/actions/resolve-scope-tags/index.js",isStatic:!0,isGitHubCI:!0}],Tf={title:"Creating workspace structure",task:async(e,t)=>{if((0,it.existsSync)(e.cwd)){t.title="Workspace directory already exists, skipping...";return}let r=Gi(),n=e.includeGitHubCI??!0,s=e.packageManager||"bun",o=c=>{try{let p=(0,Ff.spawnSync)(c,["--version"],{encoding:"utf-8",timeout:5e3}).stdout?.trim();if(p&&/^\d+\.\d+/.test(p))return`${c}@${p}`}catch{}return{bun:"bun@1.2.7",npm:"npm@10.9.2",yarn:"yarn@4.6.0",pnpm:"pnpm@9.15.2"}[c]||`${c}@latest`},i={projectName:e.projectName,githubOwner:e.githubOwner||"",pulumiStackBase:e.pulumiStackBase||e.projectName,packageManager:s,packageManagerVersion:o(s)},a=rC.filter(c=>!(c.isGitHubCI&&!n||c.forPackageManager&&c.forPackageManager!==s));for(let c of a){let l=(0,Er.join)(e.cwd,c.output),u=(0,Er.dirname)(l);if((0,it.existsSync)(u)||(0,it.mkdirSync)(u,{recursive:!0}),c.isStatic){let p=(0,Er.join)(r,c.template);(0,it.existsSync)(p)?(0,it.writeFileSync)(l,(0,it.readFileSync)(p)):(0,it.writeFileSync)(l,""),Sf(l)}else{let p=(0,Er.join)(r,c.template),d=Js(p,i);(0,it.writeFileSync)(l,d),Sf(l)}}t.title="Workspace structure created"}};var Af=oe({name:"workspace",description:"Create a new workspace with infrastructure setup",arguments:[["[name]","Name or path of the workspace"]],options:[["-P, --package-manager <manager>","Specify the package manager (e.g., npm, yarn, pnpm, bun)"],["-y, --yes","Skip all prompts and use default values"],["-o, --github-owner <owner>","GitHub organization or username"],["-s, --pulumi-stack <name>","Pulumi stack base name (org/project)"],["--no-github","Skip GitHub CI/CD workflows"],["--remove-dir","Remove existing directory before creating (internal use)"]],exampleUsage:"pf new workspace my-platform -o my-org",buildContext:(e,t)=>{let r=(e.name??"my-platform").trim(),n=S(r),s=!!t.yes,o=t.packageManager??(s?B():void 0),i=t.packageManager==="bun",a=t.githubOwner??(s?"my-org":void 0),c=t.pulumiStack??(s?`${a}/${r}`:void 0),l=t.github===!1?!1:s?!0:void 0,u=!!e.name,p=t.removeDir||s;return{cwd:n,projectName:r,shouldInstallBun:i,packageManager:o,elapsedTime:0,userConfirmed:s,skipInputPrompts:u&&!s,removeDir:p,githubOwner:a,pulumiStackBase:c,includeGitHubCI:l}},prompts:[{enabled:e=>!e.userConfirmed,task:async(e,t)=>{try{let r=O();if(!await t.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${r}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");t.title=ft.default.yellow("Warning: Creating nested workspace")}catch(r){if(r.message?.includes("cancelled"))throw r;t.title="No existing workspace detected"}}},xr,Cr,nf,sf,of,wr,vr,gr],actions:[br,yr,Tf,{title:"Initializing contracts package",task:(e,t)=>{let r=process.cwd();try{process.chdir(e.cwd),Ef(),t.title="Contracts package initialized"}catch(n){throw t.title=ft.default.red(`Contracts package failed: ${n.message}`),n}finally{process.chdir(r)}}},Ws,tf],onComplete:({projectName:e,includeGitHubCI:t})=>{w.breakLine().log(ft.default.bold.green("Workspace created successfully!")),w.breakLine().log(ft.default.bold("Next steps:")).log(` 1. ${ft.default.cyan(`cd ${e}`)}`).log(` 2. ${ft.default.cyan("bun pulumi login")}`).log(` 3. ${ft.default.cyan("bun pulumi up --stack dev")}`),t&&w.breakLine().log(ft.default.bold("GitHub Setup:")).log(" Configure these secrets in your GitHub repository:").log(` \u2022 ${ft.default.yellow("PULUMI_ACCESS_TOKEN")} - Pulumi Cloud access token`).log(` \u2022 ${ft.default.yellow("DIGITALOCEAN_TOKEN")} - DigitalOcean API token`).log(` \u2022 ${ft.default.yellow("NPM_TOKEN")} - (optional) NPM token for private packages`),w.breakLine().log(ft.default.bold("Structure created:")).log(" apps/ # Frontend applications").log(" services/ # Backend microservices").log(" packages/").log(" \u2514\u2500\u2500 contracts/ # Shared event contracts").log(" infra/").log(" \u251C\u2500\u2500 index.ts # Pulumi entry point").log(" \u251C\u2500\u2500 services/ # Service configs").log(" \u251C\u2500\u2500 Pulumi.yaml # Pulumi project config").log(" \u2514\u2500\u2500 Pulumi.dev.yaml # Dev stack config"),t&&w.log(" .github/").log(" \u251C\u2500\u2500 workflows/ # CI/CD workflows").log(" \u2514\u2500\u2500 actions/ # Custom actions"),w.breakLine().log("Happy coding! \u{1F389}").breakLine()}});var vn=[{name:"Hono Microservice",value:"hono-micro",command:df,supportsAi:!0},{name:"Nest Microservice",value:"nest-micro",command:xf,supportsAi:!0},{name:"Workspace (Infrastructure)",value:"workspace",command:Af,supportsAi:!1}],Pf=()=>{let e=oe({name:"new",description:"Create a new project",arguments:[["[type]","Type of the project (e.g., nest-micro, hono-micro, workspace)"]],exampleUsage:"platform new hono-micro test-service",buildContext:t=>({projectType:t.type??"",useAi:!1,aiDescription:"",elapsedTime:0,cwd:process.cwd()}),prompts:[{enabled:t=>!t.projectType,task:async(t,r)=>{let n=await r.prompt(R).run({type:"select",message:"Select Project type",choices:vn});t.projectType=vn.find(s=>s.name===n)?.value||"",r.title=`Using ${re.default.bold(n)}`}},{enabled:t=>t.projectType!=="workspace"&&t.projectType!=="",task:async(t,r)=>{try{O(),r.title="Workspace detected"}catch{let n=["Not in a workspace directory","",`Current directory: ${process.cwd()}`,"","This command must be run from within a workspace created with pf new workspace","","To create a new workspace, run:",""," pf new workspace my-platform"].join(`
257
+ `);throw new Error(n)}}},{enabled:t=>t.projectType==="workspace",task:async(t,r)=>{try{let n=O();if(!await r.prompt(R).run({type:"toggle",message:`\u26A0\uFE0F You are inside an existing workspace (${n}). Create a nested workspace anyway?`,enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Workspace creation cancelled - already inside a workspace");r.title=re.default.yellow("Warning: Creating nested workspace")}catch(n){if(n.message?.includes("cancelled"))throw n;r.title="No existing workspace detected"}}},{enabled:t=>!!t.projectType,task:async(t,r)=>{let s={"hono-micro":"services/my-hono-service","nest-micro":"services/my-nest-service",workspace:"my-platform"}[t.projectType]||"my-project",o=t.projectType==="workspace"?"\u{1F4E6} Workspace name:":"\u{1F4E6} Service path (e.g., services/my-service):",i=await r.prompt(R).run({type:"input",message:o,initial:s});t.servicePath=i.trim(),r.title=`Path: ${re.default.dim(i)}`}},{enabled:t=>!!vn.find(n=>n.value===t.projectType)?.supportsAi&&pr().valid,task:async(t,r)=>{let n=await r.prompt(R).run({type:"toggle",message:"Use AI to generate service code?",enabled:"Yes",disabled:"No",initial:!1});t.useAi=n,r.title=n?re.default.cyan("\u{1F916} AI-powered generation"):"Standard scaffolding"}},{enabled:t=>t.useAi,task:async(t,r)=>{let n=await r.prompt(R).run({type:"input",message:"Describe what this service should do:"});t.aiDescription=n,r.title=`Description: ${re.default.dim(n.slice(0,50))}${n.length>50?"...":""}`}},{enabled:t=>{if(!t.servicePath)return!1;let r=S(t.servicePath);return!ss(r)},task:async(t,r)=>{if(!await r.prompt(R).run({type:"toggle",message:re.default.bold("\u26A0\uFE0F Overwrite existing directory?"),enabled:"Yes",disabled:"No",initial:!1}))throw new Error("Project creation was canceled by the user.");t.shouldRemoveDir=!0,r.title=re.default.yellow("Will overwrite existing directory")}},{title:"Confirm creation",enabled:t=>t.projectType!=="workspace",task:async(t,r)=>{if(!await r.prompt(R).run({type:"Toggle",initial:!0,message:"\u{1F680} Ready to launch your project?"}))throw new Error("Project creation was canceled by the user.")}}],actions:[],onComplete:async t=>{vn.find(o=>o.value===t.projectType)||e.error(re.default.red(`Project type ${t.projectType} is not supported.`));let r=e.commands.find(o=>o.name()===t.projectType),n={};t.projectType!=="workspace"&&(n.yes=!0);let s=[];t.servicePath&&s.push("servicePath"),t.shouldRemoveDir&&(n.removeDir=!0),t.useAi&&(n.ai=!0,n.description=t.aiDescription),await Vp(r,t,n,s)}});for(let t of vn)e.addCommand(t.command);return e};var Nf=require("commander");var qs=b(require("chalk"));var Ui=e=>new Promise(t=>setTimeout(t,e)),Hi=e=>process.stdout.write(`${e}
258
+ `),nC=()=>{process.stdout.write("\x1B[?1049l"),process.stdout.write("\x1B[2J"),process.stdout.write("\x1B[3J"),process.stdout.write("\x1B[H"),process.stdout.write("\x1B[?25h"),process.stdout.isTTY&&process.stdout.write("\x1Bc")},Rf=()=>({turboProcess:null,isRestarting:!1,isShuttingDown:!1}),If=async(e,t)=>{let r=hl(".env.local",t);r.length>0&&(await yl(r),await Ui(50)),Hi(qs.default.cyan("\u{1F525} Starting services...")),Hi(qs.default.dim(` Command: turbo run ${no} --continue`)),e.isShuttingDown=!1,e.isRestarting=!1,e.turboProcess=Dl("turbo",["run",no,"--continue","--no-daemon"],{cwd:t,envFile:".env.local",onExit:n=>{!e.isRestarting&&!e.isShuttingDown&&(Hi(`
259
+ ${qs.default.red("Turbo exited with code")} ${n}`),process.exit(n??0))}})},zi=async(e,t=!1)=>{let r=e.turboProcess?.pid;if(r){t?e.isRestarting=!0:e.isShuttingDown=!0;try{try{process.kill(-r,"SIGTERM")}catch{e.turboProcess?.kill("SIGTERM")}await Ui(200);try{process.kill(-r,"SIGKILL")}catch{}await Ui(30)}catch{}e.turboProcess=null,nC()}};var sC=300,Of=new Nf.Command("dev").description("Start development mode with auto-reload").action(async()=>{let e=O(),t=Rf(),r=c=>rn("generate-env",{cwd:c}),n=()=>Et({cwd:e,quiet:!0}),s=async()=>{await n(),await r(e),await Ou()&&await Mu(e),await If(t,e)},o=async()=>{if(!(t.isRestarting||t.isShuttingDown)){t.isRestarting=!0;try{await zi(t,!0),await s()}catch{}finally{t.isRestarting=!1}}},i=(()=>{let c=null;return async()=>{t.isRestarting||t.isShuttingDown||(c&&clearTimeout(c),c=setTimeout(()=>o(),sC))}})(),a=async()=>{await zi(t,!1),await $u(),process.exit(0)};await s(),Hl(e,i),process.on("SIGINT",a),process.on("SIGTERM",a)});var Xf=require("commander");var Mf=require("node:fs"),$f=require("node:path"),Ht=b(require("chalk")),Bf=require("commander");var oC=e=>{if(e)try{return JSON.parse(e)}catch{return}},iC=e=>{if(!e)return;let t={},r=e.split(",").map(n=>n.trim()).filter(Boolean);for(let n of r){let[s,o]=n.split(":").map(i=>i.trim());s&&o&&(t[s]=o)}return Object.keys(t).length>0?t:void 0},aC=(e,t)=>{if(!t)return;let r=t.startsWith("/")?t:(0,$f.resolve)(e,t);return(0,Mf.existsSync)(r)?r:void 0},cC=async(e,t)=>{let r=[],n=[],s=[];if(Yo(e)&&!t.force)n.push("Contract (already exists)");else{let i=Zo(e,t.schema);r.push(`Contract: ${i}`)}ii(e)&&r.push("Export: packages/contracts/src/index.ts");let o=await gs(e);if(o&&r.push(`Mock: ${o}`),t.servicePath){let i=ei(e,t.servicePath);i?r.push(`Handler: ${i}`):n.push("Handler (already exists)");let a=ti(t.servicePath,e);a.added?r.push(`Stream: ${a.streamName} added to index.ts`):a.warning&&s.push(a.warning)}return{created:r,skipped:n,warnings:s}},lC=(e,t,r=[])=>{if(e.length>0){console.log(Ht.default.green(`\u2713 Created:
260
+ `));for(let n of e)console.log(Ht.default.dim(` ${n}`))}if(t.length>0){console.log(Ht.default.yellow(`
253
261
  \u2139 Skipped:
254
- `));for(let n of t)console.log(Gt.default.dim(` ${n}`))}if(r.length>0){console.log(Gt.default.yellow(`
262
+ `));for(let n of t)console.log(Ht.default.dim(` ${n}`))}if(r.length>0){console.log(Ht.default.yellow(`
255
263
  \u26A0 Warning:
256
- `));for(let n of r)console.log(Gt.default.dim(` ${n}`))}},Gi=async(e,t)=>{let r=O();if(!r){w.error("Not in a pf workspace. Run this command from your workspace root.");return}if(!e.includes(".")){w.error("Event type must include a namespace (e.g., orders.created)");return}let n=Rw(t.fields)||Pw(t.schema);if(t.schema&&!n&&!t.fields){w.error(`Invalid schema JSON. Example: '{"orderId":"string","total":"number"}'`);return}if(t.fields&&!n){w.error("Invalid fields format. Example: orderId:string,total:number");return}let s=Iw(r,t.service);if(t.service&&!s){w.error(`Service directory not found: ${t.service}`);return}console.log(Gt.default.cyan(`
264
+ `));for(let n of r)console.log(Ht.default.dim(` ${n}`))}},Ki=async(e,t)=>{let r=O();if(!r){w.error("Not in a pf workspace. Run this command from your workspace root.");return}if(!e.includes(".")){w.error("Event type must include a namespace (e.g., orders.created)");return}let n=iC(t.fields)||oC(t.schema);if(t.schema&&!n&&!t.fields){w.error(`Invalid schema JSON. Example: '{"orderId":"string","total":"number"}'`);return}if(t.fields&&!n){w.error("Invalid fields format. Example: orderId:string,total:number");return}let s=aC(r,t.service);if(t.service&&!s){w.error(`Service directory not found: ${t.service}`);return}console.log(Ht.default.cyan(`
257
265
  \u{1F4E6} Adding event: ${e}
258
- `));let{created:o,skipped:i,warnings:a}=await Nw(e,{schema:n,servicePath:s,force:t.force});Ow(o,i,a),console.log(),t.service||(console.log(Gt.default.yellow(`\u{1F4A1} Tip: Use --service to also create an event handler:
259
- `)),console.log(Gt.default.dim(` pf event add ${e} --service services/my-service
260
- `)))},DT=new Sf.Command("event:add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("-f, --fields <fields>","Schema fields (e.g., orderId:string,total:number,customerId:string)").option("--schema <json>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(Gi);var Af=require("commander");var Ff=require("fs-extra"),Tf=require("globby"),he=require("zod");var Mw=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],$w=he.z.record(he.z.string()),Bw=he.z.object({description:he.z.string().optional(),eventName:he.z.string(),faker:$w.optional(),data:he.z.record(he.z.any())}),kr=(e=process.cwd())=>(0,Tf.globbySync)("**/*.mock.json",{cwd:e,absolute:!0,gitignore:!0,ignore:Mw}).map(r=>{try{let n=(0,Ff.readJSONSync)(r,{encoding:"utf8"}),s=Bw.safeParse(n);return s.success?{eventName:s.data.eventName,path:r,schema:s.data}:(w.warn(`\u26A0\uFE0F Invalid schema in ${r}`),console.log(s.error.format()),null)}catch{return w.warn(`\u26A0\uFE0F Failed to read or parse ${r}`),null}}).filter(r=>r!==null);var Hi=null,Pf=async()=>{if(!Hi){let{faker:e}=await import("@faker-js/faker");Hi=e}return Hi},Ui=async(e,t)=>{let r=await Pf(),s=kr().find(l=>l.eventName===e);if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await jw(o):o.data,c={message:{data:Buffer.from(JSON.stringify({...i,type:o.eventName})).toString("base64"),messageId:r.string.uuid(),attributes:{source:"platform-sdk"}}};if(t.print){console.dir(c,{colors:!0});return}let u=await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!u.ok){let l=await u.text();throw new Error(`Request failed: ${u.status} \u2013 ${l}`)}w.success("Event sent successfully.")},xT=new Af.Command("event:http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","The name of the event").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(Ui),jw=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await _w(n);En(t,r,s)})),t},_w=async e=>{let t=await Pf();switch(e){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"string":return t.lorem.word();case"number":return t.number.int();case"boolean":return t.datatype.boolean();case"date":return new Date().toISOString();case"productName":return t.commerce.productName();case"productDescription":return t.commerce.productDescription();case"firstName":return t.person.firstName();case"lastName":return t.person.lastName();case"url":return t.internet.url();case"phoneNumber":return t.phone.number();case"streetAddress":return t.location.streetAddress();case"city":return t.location.city();case"state":return t.location.state();case"country":return t.location.country();case"companyName":return t.company.name();case"zipCode":return t.location.zipCode();case"password":return t.internet.password();default:return null}};var Of=b(Ai()),Mf=require("commander");var zi=require("node:fs"),Rf=require("node:path"),Ki=require("globby");var Lw=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],Ww=e=>{let t=e.split("/"),r=t.findIndex(n=>n==="services");return r!==-1&&r+1<t.length?t[r+1]:"unknown"},Gw=(e,t)=>{try{let{eventsPath:r}=G(t),s=(0,Ki.globbySync)("**/*.ts",{cwd:r,absolute:!0}).map(i=>({file:i,content:(0,zi.readFileSync)(i,"utf-8")})).find(({content:i})=>i.includes(`export const ${e}`));if(!s)return null;let o=s.content.match(/type:\s*['"]([^'"]+)['"]/);return o?o[1]:null}catch{return null}},Hw=e=>e.replace(/Contract$/,"").replace(/([A-Z])/g,(t,r,n)=>(n>0?".":"")+r.toLowerCase()),Uw=(e,t)=>{let r=e.match(/handleEvent\s*\(\s*\{\s*[^}]*type:\s*['"]([^'"]+)['"]/s);if(r)return r[1];let n=e.match(/handleEvent\s*\(\s*['"]([^'"]+)['"]/s);if(n)return n[1];let s=e.match(/import\s+(?:type\s+)?{[^}]*?(\w+Contract)[^}]*?}\s+from/);if(!s)return null;let o=s[1];return Gw(o,t)||Hw(o)},zw=(e,t)=>{try{let r=(0,zi.readFileSync)(e,"utf-8"),n=Uw(r,t);return n?{serviceName:Ww(e),handlerPath:(0,Rf.relative)(t,e),eventType:n}:null}catch{return null}},If=(e=process.cwd())=>(0,Ki.globbySync)("services/**/src/events/*.event.ts",{cwd:e,absolute:!0,gitignore:!0,ignore:Lw}).map(r=>zw(r,e)).filter(r=>r!==null),Nf=e=>e.reduce((t,r)=>{let n=t.get(r.eventType)||[];return t.set(r.eventType,[...n,r]),t},new Map);var Kw=(e,t)=>{let r=t.get(e)||[],n=[...new Set(r.map(s=>s.serviceName))];return n.length>0?n.join(", "):"-"},Ji=()=>{let e=kr();if(e.length===0){w.error("No event schemas found.");return}let t=If(),r=Nf(t),n=new Of.default({head:["name","description","consumers"],style:{head:["dim","bold"],compact:!0}});for(let{eventName:s,schema:o}of e)n.push([s,o.description||"-",Kw(s,r)]);console.log(n.toString())},PT=new Mf.Command("event:list").description("List all available event mocks").action(Ji);var $f=require("node:path"),Bf=require("commander");var Yw={},Vi=null,qi=null,jf=async()=>{if(!Vi){let{faker:e}=await import("@faker-js/faker");Vi=e}return Vi},Jw=async()=>{if(!qi)try{let{createJiti:e}=await import("jiti"),t=e(Yw.url),r=O(),n=G(r),s=(0,$f.join)(n.packagePath,"node_modules","@crossdelta","cloudevents");qi=(await t.import(s)).publish}catch{throw new Error(`@crossdelta/cloudevents is required for event:publish.
261
- Install it in your contracts package with: cd packages/contracts && bun add @crossdelta/cloudevents`)}return qi},Yi=async(e,t)=>{let r=await jf(),s=kr().find(a=>a.eventName===e||a.path.includes(`${e}.mock.json`));if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await Vw(o):o.data;if(t.print){console.log(`
262
- \u{1F4E6} Event Type:`,o.eventName),console.log("\u{1F4C4} Payload:"),console.dir(i,{colors:!0,depth:null});return}try{let a=await Jw();if(!a)throw new Error("Failed to load publish function from cloudevents");await a(o.eventName,i,{source:"platform-sdk-cli",subject:r.string.uuid()}),w.success(`Event "${o.eventName}" published successfully to NATS JetStream.`),await new Promise(c=>setTimeout(c,100)),process.exit(0)}catch(a){w.error(`Failed to publish event: ${a instanceof Error?a.message:String(a)}`),w.info("Make sure NATS is running and NATS_URL is configured."),process.exit(1)}},MT=new Bf.Command("event:publish").description("Publish to NATS JetStream").argument("<eventName>","The name of the event (e.g., order-created)").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(Yi),Vw=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await qw(n);En(t,r,s)})),t},qw=async e=>{let t=await jf();switch(e.toLowerCase()){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"firstname":return t.person.firstName();case"lastname":return t.person.lastName();case"name":return t.person.fullName();case"url":return t.internet.url();case"phone":return t.phone.number();case"date":return t.date.recent().toISOString();case"boolean":return t.datatype.boolean();case"number":return t.number.int({min:1,max:1e3});case"string":return t.lorem.word();case"text":return t.lorem.sentence();default:return e}};var bn=new _f.Command("event").description("Event management commands");bn.command("add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("--schema <fields>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(Gi);bn.command("list").description("List all available event mocks").action(Ji);bn.command("publish").description("Publish to NATS JetStream").argument("<eventName>","Event name to publish").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(Yi);bn.command("http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","Event name to send").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(Ui);var Lf=bn;var Qi=b(require("chalk")),zf=require("commander");var Er=require("node:fs"),Xi=b(require("node:path")),Ks=b(require("chalk")),Wf=require("commander"),Gf=b(require("os"));var{name:Zw,publishConfig:Xw}=Ot,Qw=Xw?.registry,tC=Zw?.split("/")[0],UT=new Wf.Command("token:set").description(Ks.default.bold("Set a registry auth token in a .npmrc file")).argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",tC).option("--registry <registry>","Registry URL",Qw).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action((e,t)=>Hf(e,t.scope||"",t.registry||"",t.local,t.force)).addHelpText("after",()=>`${Ks.default.cyan(`
266
+ `));let{created:o,skipped:i,warnings:a}=await cC(e,{schema:n,servicePath:s,force:t.force});lC(o,i,a),console.log(),t.service||(console.log(Ht.default.yellow(`\u{1F4A1} Tip: Use --service to also create an event handler:
267
+ `)),console.log(Ht.default.dim(` pf event add ${e} --service services/my-service
268
+ `)))},VT=new Bf.Command("event:add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("-f, --fields <fields>","Schema fields (e.g., orderId:string,total:number,customerId:string)").option("--schema <json>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(Ki);var Lf=require("commander");var jf=require("fs-extra"),_f=require("globby"),ge=require("zod");var uC=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],pC=ge.z.record(ge.z.string()),fC=ge.z.object({description:ge.z.string().optional(),eventName:ge.z.string(),faker:pC.optional(),data:ge.z.record(ge.z.any())}),Sr=(e=process.cwd())=>(0,_f.globbySync)("**/*.mock.json",{cwd:e,absolute:!0,gitignore:!0,ignore:uC}).map(r=>{try{let n=(0,jf.readJSONSync)(r,{encoding:"utf8"}),s=fC.safeParse(n);return s.success?{eventName:s.data.eventName,path:r,schema:s.data}:(w.warn(`\u26A0\uFE0F Invalid schema in ${r}`),console.log(s.error.format()),null)}catch{return w.warn(`\u26A0\uFE0F Failed to read or parse ${r}`),null}}).filter(r=>r!==null);var Ji=null,Wf=async()=>{if(!Ji){let{faker:e}=await import("@faker-js/faker");Ji=e}return Ji},qi=async(e,t)=>{let r=await Wf(),s=Sr().find(u=>u.eventName===e);if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await dC(o):o.data,c={message:{data:Buffer.from(JSON.stringify({...i,type:o.eventName})).toString("base64"),messageId:r.string.uuid(),attributes:{source:"platform-sdk"}}};if(t.print){console.dir(c,{colors:!0});return}let l=await fetch(t.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)});if(!l.ok){let u=await l.text();throw new Error(`Request failed: ${l.status} \u2013 ${u}`)}w.success("Event sent successfully.")},eA=new Lf.Command("event:http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","The name of the event").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(qi),dC=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await hC(n);Tn(t,r,s)})),t},hC=async e=>{let t=await Wf();switch(e){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"string":return t.lorem.word();case"number":return t.number.int();case"boolean":return t.datatype.boolean();case"date":return new Date().toISOString();case"productName":return t.commerce.productName();case"productDescription":return t.commerce.productDescription();case"firstName":return t.person.firstName();case"lastName":return t.person.lastName();case"url":return t.internet.url();case"phoneNumber":return t.phone.number();case"streetAddress":return t.location.streetAddress();case"city":return t.location.city();case"state":return t.location.state();case"country":return t.location.country();case"companyName":return t.company.name();case"zipCode":return t.location.zipCode();case"password":return t.internet.password();default:return null}};var qf=require("commander");var Vi=require("node:fs"),Gf=require("node:path"),Yi=require("globby");var mC=["**/node_modules/**","**/.nats-data/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**"],gC=e=>{let t=e.split("/"),r=t.indexOf("services");return r!==-1&&r+1<t.length?t[r+1]:"unknown"},DC=(e,t)=>{try{let{eventsPath:r}=$(t),s=(0,Yi.globbySync)("**/*.ts",{cwd:r,absolute:!0}).map(i=>({file:i,content:(0,Vi.readFileSync)(i,"utf-8")})).find(({content:i})=>i.includes(`export const ${e}`));if(!s)return null;let o=s.content.match(/type:\s*['"]([^'"]+)['"]/);return o?o[1]:null}catch{return null}},yC=e=>e.replace(/Contract$/,"").replace(/([A-Z])/g,(t,r,n)=>(n>0?".":"")+r.toLowerCase()),wC=(e,t)=>{let r=e.match(/handleEvent\s*\(\s*\{\s*[^}]*type:\s*['"]([^'"]+)['"]/s);if(r)return r[1];let n=e.match(/handleEvent\s*\(\s*['"]([^'"]+)['"]/s);if(n)return n[1];let s=e.match(/import\s+(?:type\s+)?{[^}]*?(\w+Contract)[^}]*?}\s+from/);if(!s)return null;let o=s[1];return DC(o,t)||yC(o)},CC=(e,t)=>{try{let r=(0,Vi.readFileSync)(e,"utf-8"),n=wC(r,t);return n?{serviceName:gC(e),handlerPath:(0,Gf.relative)(t,e),eventType:n}:null}catch{return null}},Hf=(e=process.cwd())=>(0,Yi.globbySync)("services/**/src/events/*.handler.ts",{cwd:e,absolute:!0,gitignore:!0,ignore:mC}).map(r=>CC(r,e)).filter(r=>r!==null),Uf=e=>e.reduce((t,r)=>{let n=t.get(r.eventType)||[];return t.set(r.eventType,[...n,r]),t},new Map);var Kf=b(Oi());var zf=(e,t)=>{let r=t.get(e)||[],n=[...new Set(r.map(s=>s.serviceName))];return n.length>0?n.join(", "):"-"};var Jf=(e,t)=>{let r=new Kf.default({head:["name","description","consumers"],style:{head:["dim","bold"],compact:!0}});for(let{eventName:n,schema:s}of e)r.push([n,s.description||"-",zf(n,t)]);return r.toString()};var Zi=()=>{let e=Sr();if(e.length===0){w.error("No event schemas found.");return}let t=Hf(),r=Uf(t),n=Jf(e,r);console.log(n)},fA=new qf.Command("event:list").description("List all available event mocks").action(Zi);var Vf=require("node:path"),Yf=require("commander");var kC={},Xi=null,Qi=null,Zf=async()=>{if(!Xi){let{faker:e}=await import("@faker-js/faker");Xi=e}return Xi},bC=async()=>{if(!Qi)try{let{createJiti:e}=await import("jiti"),t=e(kC.url),r=O(),n=$(r),s=(0,Vf.join)(n.packagePath,"node_modules","@crossdelta","cloudevents");Qi=(await t.import(s)).publish}catch{throw new Error(`@crossdelta/cloudevents is required for event:publish.
269
+ Install it in your contracts package with: cd packages/contracts && bun add @crossdelta/cloudevents`)}return Qi},ta=async(e,t)=>{let r=await Zf(),s=Sr().find(a=>a.eventName===e||a.path.includes(`${e}.mock.json`));if(!s){w.error(`Event "${e}" not found. Use "pf event list" to see available events.`);return}let o=s.schema,i=t.fake?await xC(o):o.data;if(t.print){console.log(`
270
+ \u{1F4E6} Event Type:`,o.eventName),console.log("\u{1F4C4} Payload:"),console.dir(i,{colors:!0,depth:null});return}try{let a=await bC();if(!a)throw new Error("Failed to load publish function from cloudevents");await a(o.eventName,i,{source:"platform-sdk-cli",subject:r.string.uuid()}),w.success(`Event "${o.eventName}" published successfully to NATS JetStream.`),await new Promise(c=>setTimeout(c,100)),process.exit(0)}catch(a){w.error(`Failed to publish event: ${a instanceof Error?a.message:String(a)}`),w.info("Make sure NATS is running and NATS_URL is configured."),process.exit(1)}},DA=new Yf.Command("event:publish").description("Publish to NATS JetStream").argument("<eventName>","The name of the event (e.g., order-created)").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(ta),xC=async e=>{let t=structuredClone(e.data);return e.faker&&await Promise.all(Object.entries(e.faker).map(async([r,n])=>{let s=await vC(n);Tn(t,r,s)})),t},vC=async e=>{let t=await Zf();switch(e.toLowerCase()){case"uuid":return t.string.uuid();case"email":return t.internet.email();case"firstname":return t.person.firstName();case"lastname":return t.person.lastName();case"name":return t.person.fullName();case"url":return t.internet.url();case"phone":return t.phone.number();case"date":return t.date.recent().toISOString();case"boolean":return t.datatype.boolean();case"number":return t.number.int({min:1,max:1e3});case"string":return t.lorem.word();case"text":return t.lorem.sentence();default:return e}};var kn=new Xf.Command("event").description("Event management commands");kn.command("add").description("Add event contract, handler, and mock").argument("<event-type>","Event type (e.g., orders.created)").option("-s, --service <path>","Service path to create handler in (e.g., services/orders)").option("--schema <fields>",`Schema fields as JSON (e.g., '{"orderId":"string","total":"number"}')`).option("--force","Overwrite existing files",!1).action(Ki);kn.command("list").description("List all available event mocks").action(Zi);kn.command("publish").description("Publish to NATS JetStream").argument("<eventName>","Event name to publish").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated event data without publishing").action(ta);kn.command("http").description("Send via HTTP Pub/Sub endpoint").argument("<eventName>","Event name to send").option("--endpoint <url>","Target HTTP endpoint","http://localhost:3000").option("--fake","Apply fake values to fakeable fields").option("--print","Print the generated Pub/Sub event without sending").action(qi);var Qf=kn;var na=b(require("chalk")),sd=require("commander");var Fr=require("node:fs"),ra=b(require("node:path")),Vs=b(require("chalk")),td=require("commander"),ed=b(require("os"));var{name:EC,publishConfig:SC}=Ot,FC=SC?.registry,TC=EC?.split("/")[0],SA=new td.Command("token:set").description(Vs.default.bold("Set a registry auth token in a .npmrc file")).argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",TC).option("--registry <registry>","Registry URL",FC).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action((e,t)=>rd(e,t.scope||"",t.registry||"",t.local,t.force)).addHelpText("after",()=>`${Vs.default.cyan(`
263
271
  Example:`)}
264
- ${Ks.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
265
- `),eC=e=>e?Xi.default.join(process.cwd(),".npmrc"):Xi.default.join(Gf.default.homedir(),".npmrc"),rC=(e,t,r)=>{let n=new URL(r).host;return t?`${t}:registry=https://${n}
266
- //${n}/:_authToken=${e}`:`//${n}/:_authToken=${e}`},nC=e=>(0,Er.existsSync)(e)?(0,Er.readFileSync)(e,"utf8"):"",Zi=(e,t)=>(0,Er.writeFileSync)(e,t),Hf=(e,t,r,n=!1,s=!1)=>{let o=eC(n),i=rC(e,t,r),a=new URL(r).host,c=nC(o),u=new RegExp(`//${a}/:_authToken=\\S+`);if(!c){Zi(o,`${i}
267
- `),w.success(`Created new .npmrc and set token for ${a}`);return}if(u.test(c)){if(!s){w.warn(`Token for ${a} already exists in ${o}. Use --force to overwrite.`);return}c=c.replace(u,i),Zi(o,c),w.success(`Overwrote existing token for ${a} in ${o}`);return}c+=`
272
+ ${Vs.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
273
+ `),AC=e=>e?ra.default.join(process.cwd(),".npmrc"):ra.default.join(ed.default.homedir(),".npmrc"),PC=(e,t,r)=>{let n=new URL(r).host;return t?`${t}:registry=https://${n}
274
+ //${n}/:_authToken=${e}`:`//${n}/:_authToken=${e}`},RC=e=>(0,Fr.existsSync)(e)?(0,Fr.readFileSync)(e,"utf8"):"",ea=(e,t)=>(0,Fr.writeFileSync)(e,t),rd=(e,t,r,n=!1,s=!1)=>{let o=AC(n),i=PC(e,t,r),a=new URL(r).host,c=RC(o),l=new RegExp(`//${a}/:_authToken=\\S+`);if(!c){ea(o,`${i}
275
+ `),w.success(`Created new .npmrc and set token for ${a}`);return}if(l.test(c)){if(!s){w.warn(`Token for ${a} already exists in ${o}. Use --force to overwrite.`);return}c=c.replace(l,i),ea(o,c),w.success(`Overwrote existing token for ${a} in ${o}`);return}c+=`
268
276
  ${i}
269
- `,Zi(o,c),w.success(`Appended token for ${a} to ${o}`)},Uf=(e,t)=>Hf(e,t.scope||"",t.registry||"",t.local,t.force);var{name:sC,publishConfig:oC}=Ot,iC=oC?.registry,aC=sC?.split("/")[0],Kf=new zf.Command("token").description("Token management commands");Kf.command("set").description("Set a registry auth token in a .npmrc file").argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",aC).option("--registry <registry>","Registry URL",iC).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action(Uf).addHelpText("after",()=>`${Qi.default.cyan(`
277
+ `,ea(o,c),w.success(`Appended token for ${a} to ${o}`)},nd=(e,t)=>rd(e,t.scope||"",t.registry||"",t.local,t.force);var{name:IC,publishConfig:NC}=Ot,OC=NC?.registry,MC=IC?.split("/")[0],od=new sd.Command("token").description("Token management commands");od.command("set").description("Set a registry auth token in a .npmrc file").argument("<token>","Authentication token (e.g. GitHub or npm token)").option("--scope <scope>","Package scope (e.g. @my-workspace)",MC).option("--registry <registry>","Registry URL",OC).option("--local","Write token to a local .npmrc in the current directory",!1).option("--force","Force overwrite existing token if already present",!1).action(nd).addHelpText("after",()=>`${na.default.cyan(`
270
278
  Example:`)}
271
- ${Qi.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
272
- `);var Jf=Kf;var Ht=require("@inquirer/prompts"),N=b(require("chalk")),qf=require("commander");var cC=[/embed/i,/whisper/i,/tts/i,/dall-e/i,/davinci/i,/babbage/i,/curie/i,/ada(?!-)/i,/moderation/i,/realtime/i,/audio/i,/transcription/i,/search/i],uC=async(e,t,r=1e4)=>{let n=new AbortController,s=setTimeout(()=>n.abort(),r);try{return await fetch(e,{...t,signal:n.signal})}finally{clearTimeout(s)}},lC=e=>e.replace(/-(\d{8})$/," ($1)").replace(/^claude-/,"Claude ").replace(/^gpt-/,"GPT-").replace(/-/g," ").replace(/(\d)\.(\d)/g,"$1.$2").replace(/\s+/g," ").split(" ").map(t=>/^\d/.test(t)||/^\(\d+\)$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ").trim(),pC=async(e,t)=>{let r=rn(e),n=await uC(r.modelsApiUrl,{headers:r.buildHeaders(t)});if(!n.ok)throw new Error(`${r.name} API error: ${n.status}`);let s=await n.json(),o=r.parseModelsResponse(s);if(!Array.isArray(o)||o.length===0)throw new Error(`No models returned from ${r.name} API`);let i=o.filter(a=>{let c=r.modelFilters.some(l=>l.test(a.id)),u=cC.some(l=>l.test(a.id));return c&&!u}).sort((a,c)=>{let u=typeof a.created=="number"?a.created:new Date(a.created).getTime();return(typeof c.created=="number"?c.created:new Date(c.created).getTime())-u}).map(a=>({name:lC(a.id),value:a.id}));if(i.length===0)throw new Error(`No chat models found from ${r.name} API`);return i};async function Vf(e,t){if(!t)throw new Error("API key is required to fetch available models");return{models:await pC(e,t),fromApi:!0}}function fC(){if(!nn())return null;try{let e=us();return console.log(N.default.dim(`Found existing configuration at ${xe}
279
+ ${na.default.bold("pf token set <token> --scope @my-workspace --registry https://npm.pkg.github.com")}
280
+ `);var id=od;var Ut=require("@inquirer/prompts"),N=b(require("chalk")),cd=require("commander");var $C=[/embed/i,/whisper/i,/tts/i,/dall-e/i,/davinci/i,/babbage/i,/curie/i,/ada(?!-)/i,/moderation/i,/realtime/i,/audio/i,/transcription/i,/search/i],BC=async(e,t,r=1e4)=>{let n=new AbortController,s=setTimeout(()=>n.abort(),r);try{return await fetch(e,{...t,signal:n.signal})}finally{clearTimeout(s)}},jC=e=>e.replace(/-(\d{8})$/," ($1)").replace(/^claude-/,"Claude ").replace(/^gpt-/,"GPT-").replace(/-/g," ").replace(/(\d)\.(\d)/g,"$1.$2").replace(/\s+/g," ").split(" ").map(t=>/^\d/.test(t)||/^\(\d+\)$/.test(t)?t:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ").trim(),_C=async(e,t)=>{let r=sn(e),n=await BC(r.modelsApiUrl,{headers:r.buildHeaders(t)});if(!n.ok)throw new Error(`${r.name} API error: ${n.status}`);let s=await n.json(),o=r.parseModelsResponse(s);if(!Array.isArray(o)||o.length===0)throw new Error(`No models returned from ${r.name} API`);let i=o.filter(a=>{let c=r.modelFilters.some(u=>u.test(a.id)),l=$C.some(u=>u.test(a.id));return c&&!l}).sort((a,c)=>{let l=typeof a.created=="number"?a.created:new Date(a.created).getTime();return(typeof c.created=="number"?c.created:new Date(c.created).getTime())-l}).map(a=>({name:jC(a.id),value:a.id}));if(i.length===0)throw new Error(`No chat models found from ${r.name} API`);return i};async function ad(e,t){if(!t)throw new Error("API key is required to fetch available models");return{models:await _C(e,t),fromApi:!0}}function LC(){if(!on())return null;try{let e=fs();return console.log(N.default.dim(`Found existing configuration at ${Ee}
273
281
  `)),e}catch{return console.log(N.default.yellow(`Found corrupted configuration, starting fresh.
274
- `)),null}}async function dC(e,t){return console.log(N.default.dim(`
282
+ `)),null}}async function WC(e,t){return console.log(N.default.dim(`
275
283
  \u{1F4CB} Get your ${e} API key here:`)),console.log(N.default.cyan(` ${t}
276
- `)),(0,Ht.password)({message:`Enter your ${e} API key:`,mask:"*",validate:r=>r.trim()?r.length<10?"API key seems too short":!0:"API key cannot be empty"})}async function hC(e,t,r){let n=await(0,Ht.select)({message:"Select model:",choices:e,default:t?.provider===r?t.model:void 0});return await(0,Ht.confirm)({message:"Enter a custom model ID instead?",default:!1})?(0,Ht.input)({message:"Enter custom model ID:",default:n,validate:o=>o.trim()?!0:"Model ID cannot be empty"}):n}function Yf(e){return e.length<=12?"****":`${e.slice(0,4)}...${e.slice(-4)}`}function mC(e,t){console.log(N.default.green.bold(`
284
+ `)),(0,Ut.password)({message:`Enter your ${e} API key:`,mask:"*",validate:r=>r.trim()?r.length<10?"API key seems too short":!0:"API key cannot be empty"})}async function GC(e,t,r){let n=await(0,Ut.select)({message:"Select model:",choices:e,default:t?.provider===r?t.model:void 0});return await(0,Ut.confirm)({message:"Enter a custom model ID instead?",default:!1})?(0,Ut.input)({message:"Enter custom model ID:",default:n,validate:o=>o.trim()?!0:"Model ID cannot be empty"}):n}function ld(e){return e.length<=12?"****":`${e.slice(0,4)}...${e.slice(-4)}`}function HC(e,t){console.log(N.default.green.bold(`
277
285
  \u2705 AI configuration saved successfully!
278
- `)),console.log(N.default.dim(`Configuration file: ${xe}`)),console.log(N.default.dim("API Key: Stored securely in system keychain")),console.log(N.default.dim(`Provider: ${e.provider}`)),console.log(N.default.dim(`Model: ${e.model}`)),console.log(N.default.dim(`API Key: ${Yf(t)}
286
+ `)),console.log(N.default.dim(`Configuration file: ${Ee}`)),console.log(N.default.dim("API Key: Stored securely in system keychain")),console.log(N.default.dim(`Provider: ${e.provider}`)),console.log(N.default.dim(`Model: ${e.model}`)),console.log(N.default.dim(`API Key: ${ld(t)}
279
287
  `)),console.log(N.default.cyan("You can now use AI-powered service generation:")),console.log(N.default.dim(` pf new hono-micro services/my-service --ai
280
- `))}async function gC(e){let t=await cs(e);if(t)return t;let r=rn(e);return process.env[r.defaultApiKeyEnvVar]??null}async function DC(){console.log(N.default.cyan.bold(`
288
+ `))}async function UC(e){let t=await ps(e);if(t)return t;let r=sn(e);return process.env[r.defaultApiKeyEnvVar]??null}async function zC(){console.log(N.default.cyan.bold(`
281
289
  \u{1F916} AI Configuration Setup
282
- `));let e=fC();try{let t=await(0,Ht.select)({message:"Select AI provider:",choices:Iu(),default:e?.provider??Ko.provider}),r=rn(t),n,s=await gC(t);s&&(console.log(N.default.green(`
283
- \u2713 Found existing API key: ${Yf(s)}`)),await(0,Ht.confirm)({message:"Use this existing API key?",default:!0})&&(n=s)),n||(n=await dC(r.name,r.apiKeyUrl)),console.log(N.default.dim(`
284
- Fetching available models...`));let o;try{o=(await Vf(t,n)).models,console.log(N.default.green(`\u2713 Loaded ${o.length} models from ${r.name} API
290
+ `));let e=LC();try{let t=await(0,Ut.select)({message:"Select AI provider:",choices:$l(),default:e?.provider??Vo.provider}),r=sn(t),n,s=await UC(t);s&&(console.log(N.default.green(`
291
+ \u2713 Found existing API key: ${ld(s)}`)),await(0,Ut.confirm)({message:"Use this existing API key?",default:!0})&&(n=s)),n||(n=await WC(r.name,r.apiKeyUrl)),console.log(N.default.dim(`
292
+ Fetching available models...`));let o;try{o=(await ad(t,n)).models,console.log(N.default.green(`\u2713 Loaded ${o.length} models from ${r.name} API
285
293
  `))}catch(c){console.error(N.default.red(`
286
294
  \u274C Failed to fetch models: ${c.message}`)),console.log(N.default.yellow(`
287
295
  Please check your API key and try again.
288
- `)),process.exit(1)}let i=await hC(o,e,t),a={provider:t,model:i.trim()};Mu(a),await $u(t,n),mC(a,n)}catch(t){throw t.name==="ExitPromptError"&&(console.log(N.default.yellow(`
296
+ `)),process.exit(1)}let i=await GC(o,e,t),a={provider:t,model:i.trim()};_l(a),await Ll(t,n),HC(a,n)}catch(t){throw t.name==="ExitPromptError"&&(console.log(N.default.yellow(`
289
297
  Setup cancelled.
290
- `)),process.exit(0)),t}}var ta=new qf.Command("setup").description("Configure platform settings").option("--ai","Configure AI provider and API key for code generation").addHelpText("after",`
298
+ `)),process.exit(0)),t}}var sa=new cd.Command("setup").description("Configure platform settings").option("--ai","Configure AI provider and API key for code generation").addHelpText("after",`
291
299
  Examples:
292
300
  # Configure AI provider (OpenAI, Anthropic)
293
301
  $ pf setup --ai
294
- `).action(async e=>{if(e.ai){await DC();return}console.log(N.default.cyan.bold(`
302
+ `).action(async e=>{if(e.ai){await zC();return}console.log(N.default.cyan.bold(`
295
303
  \u2699\uFE0F Platform Setup
296
304
  `)),console.log(`Available setup options:
297
- `),console.log(N.default.dim(" --ai Configure AI provider for code generation")),console.log(),console.log(N.default.dim("Example: pf setup --ai")),console.log()});var Zf=require("node:fs"),Xf=require("node:path"),Sr=b(require("chalk"));var yC=(e,t)=>t.some(r=>r.name()===e),wC=(e,t)=>t.pf?.commands?.[e]??null,CC=(e,t)=>!!t.scripts?.[e],bC=(e,t)=>t.cwd?(0,Xf.join)(e,t.cwd):e,vC=(e,t)=>t.command||e,xC=(e,t,r,n)=>{let s=bC(n,r),o=vC(e,r);if(r.cwd&&!(0,Zf.existsSync)(s))return console.error(Sr.default.red(`
305
+ `),console.log(N.default.dim(" --ai Configure AI provider for code generation")),console.log(),console.log(N.default.dim("Example: pf setup --ai")),console.log()});var ud=require("node:fs"),pd=require("node:path"),Tr=b(require("chalk"));var KC=(e,t)=>t.some(r=>r.name()===e),JC=(e,t)=>t.pf?.commands?.[e]??null,qC=(e,t)=>!!t.scripts?.[e],VC=(e,t)=>t.cwd?(0,pd.join)(e,t.cwd):e,YC=(e,t)=>t.command||e,ZC=(e,t,r,n)=>{let s=VC(n,r),o=YC(e,r);if(r.cwd&&!(0,ud.existsSync)(s))return console.error(Tr.default.red(`
298
306
  \u2716 Directory not found: ${s}
299
- `)),!0;let i=r.cwd?Sr.default.dim(` in ${r.cwd}/`):"";return console.log(Sr.default.dim(`Running ${o}${i}`)),is(o,t,{cwd:s}),!0},kC=(e,t,r)=>(console.log(Sr.default.dim(`Running workspace script: ${e}`)),tn(e,{args:t,cwd:r}),!0);async function EC(e,t,r){if(yC(e,r))return!1;let n;try{n=O()}catch{return!1}let s=Ze(n);if(!s)return!1;let o=wC(e,s);return o?xC(e,t,o,n):CC(e,s)?kC(e,t,n):!1}function SC(){let e;try{e=Ze()}catch{return{configured:[],scripts:[]}}if(!e)return{configured:[],scripts:[]};let t=Object.keys(e.pf?.commands??{}),n=Object.keys(e.scripts??{}).filter(s=>!t.includes(s));return{configured:t,scripts:n}}function Qf(){let{configured:e,scripts:t}=SC(),r=[...e,...t];return r.length===0?"":[`
300
- Workspace Commands:`,...r.map(n=>Sr.default.cyan(` ${n}`))].join(`
301
- `)}function td(e,t,r){let n=t.slice(2);if(n.length>0&&!n[0].startsWith("-")){let s=n[0],o=n.slice(1);EC(s,o,r).then(i=>{i||e.parse(t)})}else e.parse(t)}process.on("SIGINT",()=>{process.exit(0)});process.on("unhandledRejection",e=>{throw(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),e});process.on("uncaughtException",e=>{(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),(e.message?.includes("Not in a workspace directory")||e.message?.includes("Could not locate workspace root"))&&(console.error(e.message),process.exit(1)),console.error(Se.default.red(`
302
- \u2716 An unexpected error occurred:`)),console.error(e),process.exit(1)});var Js=new ad.Command,ed=Object.keys(Ot.bin||{}),[cd="pf",ea]=ed.length>0?ed:["pf"],{description:rd,version:FC,repository:nd,homepage:TC}=Ot,sd=rd?.split(/ —|,|\./)[0]||rd||"Platform CLI",ud=nd?.url?`https://${nd.url.replace(/^(git\+|git@)/,"").replace(/\.git$/,"").replace(":","/")}`:null,od=ud||TC,AC=ud?"GitHub":"README",PC=od?[Se.default.bold(sd),`
307
+ `)),!0;let i=r.cwd?Tr.default.dim(` in ${r.cwd}/`):"";return console.log(Tr.default.dim(`Running ${o}${i}`)),ls(o,t,{cwd:s}),!0},XC=(e,t,r)=>(console.log(Tr.default.dim(`Running workspace script: ${e}`)),rn(e,{args:t,cwd:r}),!0);async function QC(e,t,r){if(KC(e,r))return!1;let n;try{n=O()}catch{return!1}let s=Qe(n);if(!s)return!1;let o=JC(e,s);return o?ZC(e,t,o,n):qC(e,s)?XC(e,t,n):!1}function tb(){let e;try{e=Qe()}catch{return{configured:[],scripts:[]}}if(!e)return{configured:[],scripts:[]};let t=Object.keys(e.pf?.commands??{}),n=Object.keys(e.scripts??{}).filter(s=>!t.includes(s));return{configured:t,scripts:n}}function fd(){let{configured:e,scripts:t}=tb(),r=[...e,...t];return r.length===0?"":[`
308
+ Workspace Commands:`,...r.map(n=>Tr.default.cyan(` ${n}`))].join(`
309
+ `)}function dd(e,t,r){let n=t.slice(2);if(n.length>0&&!n[0].startsWith("-")){let s=n[0],o=n.slice(1);QC(s,o,r).then(i=>{i||e.parse(t)})}else e.parse(t)}process.on("SIGINT",()=>{process.exit(0)});process.on("unhandledRejection",e=>{throw(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),e});process.on("uncaughtException",e=>{(e.name==="ExitPromptError"||e.message?.includes("ERR_USE_AFTER_CLOSE")||e.message?.includes("Cancelled prompt"))&&process.exit(0),(e.message?.includes("Not in a workspace directory")||e.message?.includes("Could not locate workspace root"))&&(console.error(e.message),process.exit(1)),console.error(Te.default.red(`
310
+ \u2716 An unexpected error occurred:`)),console.error(e),process.exit(1)});var Ys=new Cd.Command,hd=Object.keys(Ot.bin||{}),[bd="pf",oa]=hd.length>0?hd:["pf"],{description:md,version:eb,repository:gd,homepage:rb}=Ot,Dd=md?.split(/ —|,|\./)[0]||md||"Platform CLI",xd=gd?.url?`https://${gd.url.replace(/^(git\+|git@)/,"").replace(/\.git$/,"").replace(":","/")}`:null,yd=xd||rb,nb=xd?"GitHub":"README",sb=yd?[Te.default.bold(Dd),`
303
311
 
304
- `,Se.default.cyan("See more at: "),Se.default.bold(Ut(AC,od))].join(""):Se.default.bold(sd),ld=[ta,wf(),xf,Lf,Jf,Eu];Js.name(cd).description(PC).version(FC||"0.0.1").helpCommand(!1).configureHelp({subcommandTerm:e=>Se.default.cyan(e.name())}).addHelpText("after",Qf);ea&&ea!==cd&&Js.alias(ea);ld.forEach(e=>{Js.addCommand(e)});td(Js,id.argv,ld);
312
+ `,Te.default.cyan("See more at: "),Te.default.bold(zt(nb,yd))].join(""):Te.default.bold(Dd),vd=[sa,Pf(),Of,Qf,id,Al];Ys.name(bd).description(sb).version(eb||"0.0.1").helpCommand(!1).configureHelp({subcommandTerm:e=>Te.default.cyan(e.name())}).addHelpText("after",fd);oa&&oa!==bd&&Ys.alias(oa);vd.forEach(e=>{Ys.addCommand(e)});dd(Ys,wd.argv,vd);