@conterra/vuln-scan 1.0.10 → 1.0.11

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.
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var E=Object.create;var y=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var O=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var C=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of T(e))!A.call(t,o)&&o!==r&&y(t,o,{get:()=>e[o],enumerable:!(s=N(e,o))||s.enumerable});return t};var S=(t,e,r)=>(r=t!=null?E(O(t)):{},C(e||!t||!t.__esModule?y(r,"default",{value:t,enumerable:!0}):r,t));var d=S(require("path"));var a=require("fs/promises");async function m(t){try{return await k(t)?JSON.parse(await(0,a.readFile)(t,{encoding:"utf-8"})):void 0}catch(e){throw new Error(`Error reading JSON file ${t}: ${e}`,{cause:e})}}async function x(t,e){let r=JSON.stringify(e,null,4)+`
3
- `,s=await j(t,r);await(0,a.writeFile)(t,s,{encoding:"utf-8"})}async function k(t){try{return await(0,a.access)(t,a.constants.F_OK),!0}catch{return!1}}async function j(t,e){let r=await U();if(!r)return e;let s=await r.resolveConfig(t);return s?await r.format(e,{...s,filepath:t}):e}var L;function U(){return L??=import("prettier").catch(()=>{})}var w;async function F(t){if(w)return w;let e="https://repository.conterra.de/repository/maven-mirror-ct",r=l(t.workingDir,"input/vex"),s=l(t.workingDir,"output"),o=l(t.workingDir,"cache"),g=["grype","trivy","ossindex"],c=l(t.workingDir,"vuln-scan-conf.json"),n=await m(c);if(!n)throw new Error(`Missing project configuration file '${c}'`);let f=n.findNoLongerDetectedVulnerabilitiesOnlyForSnapshots??!1;return w={projectConfigFileLocation:c,onNewVulnerabilities:n.onNewVulnerabilities??(n.failOnNewVulnerabilities?"fail":"warn"),onNoLongerDetectedVulnerabilities:n.onNoLongerDetectedVulnerabilities??"ignore",reportNoLongerDetectedVulnerabilities:n.reportNoLongerDetectedVulnerabilities??!0,consoleReport:n.consoleReport||"BY_PROJECT_DETAILED",createSubDirsForProject:n.createSubDirsForProject??!0,mavenRepo:n.mavenRepo??e,vexUrls:n.vexUrls??[],vexDir:l(t.workingDir,n.vexDir)??r,outDir:l(t.workingDir,n.outDir)??s,cacheDir:l(t.workingDir,n.cacheDir)??o,scanners:(n.scanners??g).map(u=>{if(typeof u!="string")throw new Error(`Invalid scanner name '${u}' in configuration file '${c}'`);let i=u.split("@");if(i.length>2)throw new Error(`Invalid scanner name '${u}' in configuration file '${c}'`);let V=i[0],D=i[1]??"";return{name:V,version:D}}),projects:(n.projects??[]).map(u=>{let i=u;if(!i.name)throw new Error("Project name is missing on entry:"+JSON.stringify(i));if(!i.version)throw new Error("Project version is missing on entry:"+JSON.stringify(i));if(!i.purl)throw new Error("Project purl is missing on entry:"+JSON.stringify(i));return i.purlAliases||(i.purlAliases=[]),i.enabled==null&&(i.enabled=!0),i.silent==null&&(i.silent=!1),i.minimumSeverity||(i.minimumSeverity="UNKNOWN"),i.sbomFile?{...i,sbomFile:l(t.workingDir,i.sbomFile)}:(i.detectNoLongerUsedVulnerabilities=f?i.purl.endsWith("-SNAPSHOT"):!0,u)})}}function l(t,e){if(e)return d.default.isAbsolute(e)?e:(0,d.resolve)(t,e)}var p=require("fs/promises"),h=require("path");var v=class{constructor(e){this.location=e}location;async read(){let e=await m(this.location);if(!e)throw new Error("Invalid VEX file");return e}async write(e){await x(this.location,e)}async delete(){await(0,p.unlink)(this.location)}};async function P(t,e){for(let r of await(0,p.readdir)(t,{withFileTypes:!0}))r.name.endsWith(".json")?await e(new v((0,h.resolve)(r.parentPath,r.name))):r.isDirectory()&&await P((0,h.resolve)(r.parentPath,r.name),e)}async function b({workingDir:t,existingPurl:e,newPurl:r}){let s=await F({workingDir:t});await P(s.vexDir,async o=>{await $(o,e,r)})}async function $(t,e,r){let s=await t.read(),o=!1,g=s.statements;for(let c of g){if(!c.products||c.products.some(f=>f["@id"]===r))continue;let n=c.products.findIndex(f=>f["@id"]===e);n!==-1&&(c.products?.splice(n+1,0,{"@id":r}),o=!0)}o&&(console.info(`Add ${r} to ${t.location}`),await t.write(s))}var I=process.cwd();(async()=>{let{existingPurl:t,newPurl:e}=await J();await b({workingDir:I,existingPurl:t,newPurl:e})})();async function J(){let t=process.argv[2];if(!t)throw new Error("Existing purl parameter missing.");let e=process.argv[3];if(!e)throw new Error("New purl parameter missing.");return{existingPurl:t,newPurl:e}}
2
+ "use strict";var D=Object.create;var y=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var U=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of A(t))!j.call(r,i)&&i!==e&&y(r,i,{get:()=>t[i],enumerable:!(n=I(t,i))||n.enumerable});return r};var x=(r,t,e)=>(e=r!=null?D(T(r)):{},U(t||!r||!r.__esModule?y(e,"default",{value:r,enumerable:!0}):e,r));var c=x(require("path")),g=require("fs/promises");var a=require("fs/promises");async function m(r){try{return await L(r)?JSON.parse(await(0,a.readFile)(r,{encoding:"utf-8"})):void 0}catch(t){throw new Error(`Error reading JSON file ${r}: ${t}`,{cause:t})}}async function P(r,t){let e=JSON.stringify(t,null,4)+`
3
+ `,n=await _(r,e);await(0,a.writeFile)(r,n,{encoding:"utf-8"})}async function L(r){try{return await(0,a.access)(r,a.constants.F_OK),!0}catch{return!1}}async function _(r,t){let e=await $();if(!e)return t;let n=await e.resolveConfig(r);return n?await e.format(t,{...n,filepath:r}):t}var R;function $(){return R??=import("prettier").catch(()=>{})}var u=["UNKNOWN","LOW","MEDIUM","HIGH","CRITICAL"];var h=class r{constructor(t){this.workingDir=t}workingDir;static DEFAULT_MAVEN_REPO="https://repository.conterra.de/repository/maven-mirror-ct";static DEFAULT_VEX_SUBDIR="input/vex";static DEFAULT_OUT_SUBDIR="output";static DEFAULT_CACHE_SUBDIR="cache";static DEFAULT_SCANNERS=["grype","trivy","ossindex"];normalize(t,e){let n=t.findNoLongerDetectedVulnerabilitiesOnlyForSnapshots??!1;return{projectConfigFileLocation:e,onNewVulnerabilities:t.onNewVulnerabilities??(t.failOnNewVulnerabilities?"fail":"warn"),onNoLongerDetectedVulnerabilities:t.onNoLongerDetectedVulnerabilities??"ignore",reportNoLongerDetectedVulnerabilities:t.reportNoLongerDetectedVulnerabilities??!0,consoleReport:t.consoleReport??"BY_PROJECT_DETAILED",createSubDirsForProject:t.createSubDirsForProject??!0,mavenRepo:t.mavenRepo??r.DEFAULT_MAVEN_REPO,vexUrls:t.vexUrls??[],vexDir:this.resolvePath(t.vexDir)??(0,c.resolve)(this.workingDir,r.DEFAULT_VEX_SUBDIR),outDir:this.resolvePath(t.outDir)??(0,c.resolve)(this.workingDir,r.DEFAULT_OUT_SUBDIR),cacheDir:this.resolvePath(t.cacheDir)??(0,c.resolve)(this.workingDir,r.DEFAULT_CACHE_SUBDIR),scanners:this.normalizeScanners(t.scanners,e),projects:this.normalizeProjects(t.projects??[],n)}}normalizeScanners(t,e){return(t??r.DEFAULT_SCANNERS).map(i=>{if(typeof i!="string")throw new Error(`Invalid scanner name '${String(i)}' in configuration file '${e}'`);let o=i.split("@");if(o.length>2)throw new Error(`Invalid scanner name '${i}' in configuration file '${e}'`);return{name:o[0],version:o[1]??""}})}normalizeProjects(t,e){return t.map(n=>{let i=n;if(!i.name)throw new Error("Project name is missing on entry: "+JSON.stringify(i));if(!i.version)throw new Error("Project version is missing on entry: "+JSON.stringify(i));if(!i.purl)throw new Error("Project purl is missing on entry: "+JSON.stringify(i));let o={...i,purlAliases:i.purlAliases??[],enabled:i.enabled??!0,silent:i.silent??!1,minimumSeverity:i.minimumSeverity??"UNKNOWN"};return o.sbomFile?{...o,sbomFile:this.resolvePath(o.sbomFile)??o.sbomFile}:{...o,detectNoLongerUsedVulnerabilities:e?o.purl.endsWith("-SNAPSHOT"):!0}})}resolvePath(t){if(t)return c.default.isAbsolute(t)?t:(0,c.resolve)(this.workingDir,t)}},d=class{constructor(t){this.workingDir=t;this.normalizer=new h(t)}workingDir;normalizer;projectConfigCache;async loadProjectConfig(){return this.projectConfigCache??=this.doLoadProjectConfig(),this.projectConfigCache}async doLoadProjectConfig(){let t=(0,c.resolve)(this.workingDir,"vuln-scan-conf.json"),e=await m(t);if(!e)throw new Error(`Missing project configuration file '${t}'`);return this.normalizer.normalize(e,t)}async loadJiraConfig(t){let e=await(0,g.readFile)(t,"utf8"),n=JSON.parse(e);if(!n.issues&&n.issue&&(n.issues=n.issue),!n.jiraUrl||typeof n.jiraUrl!="string")throw new Error("jira-conf.json: missing or invalid 'jiraUrl' field");if(!Array.isArray(n.issues))throw new Error("jira-conf.json: missing or invalid 'issues' array");this.validateAutoCloseSeverity(n.autoCloseBelowSeverity,"jira-conf.json: invalid 'autoCloseBelowSeverity'");for(let[i,o]of n.issues.entries())o&&typeof o=="object"&&this.validateAutoCloseSeverity(o.autoCloseBelowSeverity,`jira-conf.json: invalid 'issues[${i}].autoCloseBelowSeverity'`);return n}validateAutoCloseSeverity(t,e){if(t!==void 0&&!u.includes(t))throw new Error(`${e} value '${String(t)}'. Must be one of: ${u.join(", ")}`)}async loadAutoVexConfig(t){let e=await(0,g.readFile)(t,"utf8"),n=JSON.parse(e);if(!n.impactStatement||typeof n.impactStatement!="string")throw new Error("auto-vex-conf.json: missing or invalid 'impactStatement' field (must be a non-empty string)");if(n.maxSeverity!==void 0&&!u.includes(n.maxSeverity))throw new Error(`auto-vex-conf.json: invalid 'maxSeverity' value '${String(n.maxSeverity)}'. Must be one of: ${u.join(", ")}`);return n}};var N=require("fs/promises"),v=require("path");var f=require("fs/promises"),p=require("path");var E=require("crypto");var M="https://openvex.dev/ns/v0.2.0";function b(r,t="conterra"){let n=`https://openvex.dev/docs/public/vex-${(0,E.randomUUID)()}`,i=r.timestamp??new Date().toISOString();return{"@context":M,"@id":n,author:t,timestamp:i,last_updated:i,version:1,statements:[r]}}function C(r,t){let e=t.timestamp??new Date().toISOString();return{...r,last_updated:e,version:r.version+1,statements:[...r.statements,t]}}var l=class{constructor(t){this.location=t}location;_content=void 0;_exists=!1;get exists(){return this._exists}get content(){return this._content}set content(t){this._content=t,this._exists=t!==void 0}async read(){let t=await m(this.location);this._content=t??void 0,this._exists=this._content!==void 0}async write(){if(this._content===void 0)throw new Error(`Cannot write VexFile: content is undefined (${this.location})`);await(0,f.mkdir)((0,p.dirname)((0,p.resolve)(this.location)),{recursive:!0}),await P(this.location,this._content)}async delete(){await(0,f.unlink)(this.location),this._exists=!1}upsert(t,e){return this._content===void 0?(this._content=b(t,e),this._exists=!0,{created:!0}):(this._content=C(this._content,t),{created:!1})}addProductId(t,e){this.assertContentLoaded("addProductId");let n=!1;for(let i of this._content.statements){if(!i.products||i.products.some(s=>s["@id"]===e))continue;let o=i.products.findIndex(s=>s["@id"]===t);o!==-1&&(i.products.splice(o+1,0,{"@id":e}),n=!0)}return n}removeProductId(t,e){this.assertContentLoaded("removeProductId");let n=this._content.statements,i=[],o=!1;for(let s of n){if(e&&!V(s).has(e)||!s.products)continue;let w=s.products.findIndex(F=>F["@id"]===t);w!==-1&&(s.products.splice(w,1),o=!0,s.products.length===0&&i.push(s))}if(!o)return"unchanged";for(let s of i)n.splice(n.indexOf(s),1);return n.length===0?"emptied":"changed"}hasStatementForProduct(t){return this.assertContentLoaded("hasStatementForProduct"),this._content.statements.some(e=>e.products?.some(n=>n["@id"]===t)??!1)}assertContentLoaded(t){if(this._content===void 0)throw new Error(`VexFile.${t}(): content is not loaded. Call read() first (${this.location})`)}};async function S(r,t){for(let e of await(0,N.readdir)(r,{withFileTypes:!0}))e.name.endsWith(".json")?await t(new l((0,v.resolve)(e.parentPath,e.name))):e.isDirectory()&&await S((0,v.resolve)(e.parentPath,e.name),t)}function V(r){let t=r.vulnerability.name;return new Set([t,...r.vulnerability.aliases??[]])}async function O({workingDir:r,existingPurl:t,newPurl:e}){let n=await new d(r).loadProjectConfig();await S(n.vexDir,async i=>{await i.read(),i.addProductId(t,e)&&(console.info(`Add ${e} to ${i.location}`),await i.write())})}var B=process.cwd();(async()=>{let{existingPurl:r,newPurl:t}=await k();await O({workingDir:B,existingPurl:r,newPurl:t})})();async function k(){let r=process.argv[2];if(!r)throw new Error("Existing purl parameter missing.");let t=process.argv[3];if(!t)throw new Error("New purl parameter missing.");return{existingPurl:r,newPurl:t}}
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var Wt=Object.create;var Xe=Object.defineProperty;var Kt=Object.getOwnPropertyDescriptor;var Ht=Object.getOwnPropertyNames;var Gt=Object.getPrototypeOf,qt=Object.prototype.hasOwnProperty;var Ye=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Jt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ht(t))!qt.call(e,i)&&i!==r&&Xe(e,i,{get:()=>t[i],enumerable:!(n=Kt(t,i))||n.enumerable});return e};var A=(e,t,r)=>(r=e!=null?Wt(Gt(e)):{},Jt(t||!e||!e.__esModule?Xe(r,"default",{value:e,enumerable:!0}):r,e));var ct=Ye((Ln,at)=>{"use strict";at.exports=ur;function cr(e){let t={defaultWidth:0,output:process.stdout,tty:require("tty")};return e?(Object.keys(t).forEach(function(r){e[r]||(e[r]=t[r])}),e):t}function ur(e){let t=cr(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let r=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(r)&&r!==0)return r}return t.defaultWidth}});var vt=Ye((On,Ft)=>{var Pr=require("stream"),_e=class extends Pr{#r=null;constructor(t={}){super(t),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=t.replace,this._prompt=t.prompt||null,this._hadControl=!1}#t(t,r){return this._dest?this._dest[t]:this._src?this._src[t]:r}#e(t,...r){typeof this._dest?.[t]=="function"&&this._dest[t](...r),typeof this._src?.[t]=="function"&&this._src[t](...r)}get isTTY(){return this.#r!==null?this.#r:this.#t("isTTY",!1)}set isTTY(t){this.#r=t}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(t){this._src=t}pipe(t,r){return this._dest=t,super.pipe(t,r)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(t){if(this.muted){if(!this.replace)return!0;if(t.match(/^\u001b/))return t.indexOf(this._prompt)===0&&(t=t.slice(this._prompt.length),t=t.replace(/./g,this.replace),t=this._prompt+t),this._hadControl=!0,this.emit("data",t);this._prompt&&this._hadControl&&t.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),t=t.slice(this._prompt.length)),t=t.toString().replace(/./g,this.replace)}this.emit("data",t)}end(t){this.muted&&(t&&this.replace?t=t.toString().replace(/./g,this.replace):t=null),t&&this.emit("data",t),this.emit("end")}destroy(...t){return this.#e("destroy",...t)}destroySoon(...t){return this.#e("destroySoon",...t)}close(...t){return this.#e("close",...t)}};Ft.exports=_e});var ce=A(require("path"));var U=require("fs/promises");async function J(e){try{return await Xt(e)?JSON.parse(await(0,U.readFile)(e,{encoding:"utf-8"})):void 0}catch(t){throw new Error(`Error reading JSON file ${e}: ${t}`,{cause:t})}}async function ae(e,t){let r=JSON.stringify(t,null,4)+`
3
- `,n=await Yt(e,r);await(0,U.writeFile)(e,n,{encoding:"utf-8"})}async function Xt(e){try{return await(0,U.access)(e,U.constants.F_OK),!0}catch{return!1}}async function Yt(e,t){let r=await Qt();if(!r)return t;let n=await r.resolveConfig(e);return n?await r.format(t,{...n,filepath:e}):t}var zt;function Qt(){return zt??=import("prettier").catch(()=>{})}var ye;async function X(e){if(ye)return ye;let t="https://repository.conterra.de/repository/maven-mirror-ct",r=O(e.workingDir,"input/vex"),n=O(e.workingDir,"output"),i=O(e.workingDir,"cache"),l=["grype","trivy","ossindex"],s=O(e.workingDir,"vuln-scan-conf.json"),o=await J(s);if(!o)throw new Error(`Missing project configuration file '${s}'`);let u=o.findNoLongerDetectedVulnerabilitiesOnlyForSnapshots??!1;return ye={projectConfigFileLocation:s,onNewVulnerabilities:o.onNewVulnerabilities??(o.failOnNewVulnerabilities?"fail":"warn"),onNoLongerDetectedVulnerabilities:o.onNoLongerDetectedVulnerabilities??"ignore",reportNoLongerDetectedVulnerabilities:o.reportNoLongerDetectedVulnerabilities??!0,consoleReport:o.consoleReport||"BY_PROJECT_DETAILED",createSubDirsForProject:o.createSubDirsForProject??!0,mavenRepo:o.mavenRepo??t,vexUrls:o.vexUrls??[],vexDir:O(e.workingDir,o.vexDir)??r,outDir:O(e.workingDir,o.outDir)??n,cacheDir:O(e.workingDir,o.cacheDir)??i,scanners:(o.scanners??l).map(f=>{if(typeof f!="string")throw new Error(`Invalid scanner name '${f}' in configuration file '${s}'`);let c=f.split("@");if(c.length>2)throw new Error(`Invalid scanner name '${f}' in configuration file '${s}'`);let a=c[0],d=c[1]??"";return{name:a,version:d}}),projects:(o.projects??[]).map(f=>{let c=f;if(!c.name)throw new Error("Project name is missing on entry:"+JSON.stringify(c));if(!c.version)throw new Error("Project version is missing on entry:"+JSON.stringify(c));if(!c.purl)throw new Error("Project purl is missing on entry:"+JSON.stringify(c));return c.purlAliases||(c.purlAliases=[]),c.enabled==null&&(c.enabled=!0),c.silent==null&&(c.silent=!1),c.minimumSeverity||(c.minimumSeverity="UNKNOWN"),c.sbomFile?{...c,sbomFile:O(e.workingDir,c.sbomFile)}:(c.detectNoLongerUsedVulnerabilities=u?c.purl.endsWith("-SNAPSHOT"):!0,f)})}}function O(e,t){if(t)return ce.default.isAbsolute(t)?t:(0,ce.resolve)(e,t)}var ue=require("fs/promises"),Le=require("path");var Pe=class{constructor(t){this.location=t}location;async read(){let t=await J(this.location);if(!t)throw new Error("Invalid VEX file");return t}async write(t){await ae(this.location,t)}async delete(){await(0,ue.unlink)(this.location)}};async function Fe(e,t){for(let r of await(0,ue.readdir)(e,{withFileTypes:!0}))r.name.endsWith(".json")?await t(new Pe((0,Le.resolve)(r.parentPath,r.name))):r.isDirectory()&&await Fe((0,Le.resolve)(r.parentPath,r.name),t)}async function ze({workingDir:e,existingPurl:t,newPurl:r}){let n=await X({workingDir:e});await Fe(n.vexDir,async i=>{await Zt(i,t,r)})}async function Zt(e,t,r){let n=await e.read(),i=!1,l=n.statements;for(let s of l){if(!s.products||s.products.some(u=>u["@id"]===r))continue;let o=s.products.findIndex(u=>u["@id"]===t);o!==-1&&(s.products?.splice(o+1,0,{"@id":r}),i=!0)}i&&(console.info(`Add ${r} to ${e.location}`),await e.write(n))}async function Qe({workingDir:e,projectName:t,referenceProjectVersion:r,targetProjectVersion:n}){let i=await X({workingDir:e});if(!i.projectConfigFileLocation)throw new Error("Missing project configuration file.");let l=i.projects.find(o=>o.name===t&&o.version===r);if(!l)throw new Error(`Project ${t} with version ${r} not found.`);let s=i.projects.find(o=>o.name===t&&o.version===n);s||(s=await er(t,i.projectConfigFileLocation,l,n)),await ze({workingDir:e,existingPurl:l.purl,newPurl:s.purl})}async function er(e,t,r,n){let i=await J(t),l=i.projects.findIndex(u=>u.name===r.name&&u.version===r.version),s=i.projects[l],o={...s};return o.version=n,o.purl=s.purl.replace(s.version,n),"sbomMavenCoordinates"in o?o.sbomMavenCoordinates=s.sbomMavenCoordinates.replace(s.version,n):"sbomFile"in o&&(o.sbomFile=s.sbomFile.replace(s.version,n)),i.projects.splice(l+1,0,o),console.info(`Add project ${e} with version ${n} to ${t}`),await ae(t,i),o}var te=(e,t=[])=>e.name==="up"||t.includes("vim")&&e.name==="k"||t.includes("emacs")&&e.ctrl&&e.name==="p",fe=(e,t=[])=>e.name==="down"||t.includes("vim")&&e.name==="j"||t.includes("emacs")&&e.ctrl&&e.name==="n";var re=e=>e.name==="backspace",ne=e=>e.name==="tab",ve=e=>"1234567890".includes(e.name),V=e=>e.name==="enter"||e.name==="return";var de=class extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(t){super(),this.cause=t?.cause}},pe=class extends Error{name="CancelPromptError";message="Prompt was canceled"},ie=class extends Error{name="ExitPromptError"},he=class extends Error{name="HookError"},Y=class extends Error{name="ValidationError"};var rt=require("node:async_hooks");var me=require("node:async_hooks");var Ze=new me.AsyncLocalStorage;function tr(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function et(e,t){let r=tr(e);return Ze.run(r,()=>{function n(i){r.handleChange=()=>{r.index=0,i()},r.handleChange()}return t(n)})}function M(){let e=Ze.getStore();if(!e)throw new he("[Inquirer] Hook functions can only be called from within a prompt");return e}function Te(){return M().rl}function Re(e){let t=(...r)=>{let n=M(),i=!1,l=n.handleChange;n.handleChange=()=>{i=!0};let s=e(...r);return i&&l(),n.handleChange=l,s};return me.AsyncResource.bind(t)}function z(e){let t=M(),{index:r}=t,n={get(){return t.hooks[r]},set(l){t.hooks[r]=l},initialized:r in t.hooks},i=e(n);return t.index++,i}function tt(){M().handleChange()}var $={queue(e){let t=M(),{index:r}=t;t.hooksEffect.push(()=>{t.hooksCleanup[r]?.();let n=e(Te());if(n!=null&&typeof n!="function")throw new Y("useEffect return value must be a cleanup function or nothing.");t.hooksCleanup[r]=n})},run(){let e=M();Re(()=>{e.hooksEffect.forEach(t=>{t()}),e.hooksEffect.length=0})()},clearAll(){let e=M();e.hooksCleanup.forEach(t=>{t?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function rr(e){return typeof e=="function"}function L(e){return z(t=>{let r=rt.AsyncResource.bind(function(l){t.get()!==l&&(t.set(l),tt())});if(t.initialized)return[t.get(),r];let n=rr(e)?e():e;return t.set(n),[n,r]})}function N(e,t){z(r=>{let n=r.get();(!Array.isArray(n)||t.some((l,s)=>!Object.is(l,n[s])))&&$.queue(e),r.set(t)})}var I=require("node:util");var B=A(require("node:process"),1);function nr(){return B.default.platform.startsWith("win")?!!B.default.env.CI||!!B.default.env.WT_SESSION||!!B.default.env.TERMINUS_SUBLIME||B.default.env.ConEmuTask==="{cmd::Cmder}"||B.default.env.TERM_PROGRAM==="Terminus-Sublime"||B.default.env.TERM_PROGRAM==="vscode"||B.default.env.TERM==="xterm-256color"||B.default.env.TERM==="alacritty"||B.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm":B.default.env.TERM!=="linux"}var nt={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},it={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},ir={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},or={...nt,...it},sr={...nt,...ir},lr=nr(),ar=lr?or:sr,Q=ar,sn=Object.entries(it);var ot={prefix:{idle:(0,I.styleText)("blue","?"),done:(0,I.styleText)("green",Q.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(e=>(0,I.styleText)("yellow",e))},style:{answer:e=>(0,I.styleText)("cyan",e),message:e=>(0,I.styleText)("bold",e),error:e=>(0,I.styleText)("red",`> ${e}`),defaultAnswer:e=>(0,I.styleText)("dim",`(${e})`),help:e=>(0,I.styleText)("dim",e),highlight:e=>(0,I.styleText)("cyan",e),key:e=>(0,I.styleText)("cyan",(0,I.styleText)("bold",`<${e}>`))}};function st(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function lt(...e){let t={};for(let r of e)for(let[n,i]of Object.entries(r)){let l=t[n];t[n]=st(l)&&st(i)?lt(l,i):i}return t}function j(...e){let t=[ot,...e.filter(r=>r!=null)];return lt(...t)}function W({status:e="idle",theme:t}){let[r,n]=L(!1),[i,l]=L(0),{prefix:s,spinner:o}=j(t);return N(()=>{if(e==="loading"){let f,c=-1,a=setTimeout(()=>{n(!0),f=setInterval(()=>{c=c+1,l(c%o.frames.length)},o.interval)},300);return()=>{clearTimeout(a),clearInterval(f)}}else n(!1)},[e]),r?o.frames[i]:typeof s=="string"?s:s[e==="loading"?"idle":e]??s.idle}function oe(e,t){return z(r=>{let n=r.get();if(!n||n.dependencies.length!==t.length||n.dependencies.some((i,l)=>i!==t[l])){let i=e();return r.set({value:i,dependencies:t}),i}return n.value})}function K(e){return L({current:e})[0]}function H(e){let t=K(e);t.current=e,N(r=>{let n=!1,i=Re((l,s)=>{n||t.current(s,r)});return r.input.on("keypress",i),()=>{n=!0,r.input.removeListener("keypress",i)}},[])}var Pt=A(ct(),1);var ut=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let r=0;for(e.lastIndex=0;e.test(t);)r+=1;return t.length-r}})(),ft=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,dt=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141;var fr=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,dr=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,pt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,pr=/\t{1,1000}/y,ht=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),hr=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,mr=new RegExp("\\p{M}+","gu"),gr={limit:1/0,ellipsis:""},mt=(e,t={},r={})=>{let n=t.limit??1/0,i=t.ellipsis??"",l=t?.ellipsisWidth??(i?mt(i,gr,r).width:0),s=0,o=r.controlWidth??0,u=r.tabWidth??8,f=r.emojiWidth??2,c=2,a=r.regularWidth??1,d=r.wideWidth??c,x=[[hr,a],[fr,s],[dr,o],[pr,u],[ht,f],[pt,d]],m=0,p=0,h=e.length,b=0,g=!1,D=h,S=Math.max(0,n-l),P=0,F=0,T=0,R=0;e:for(;;){if(F>P||p>=h&&p>m){let w=e.slice(P,F)||e.slice(m,p);b=0;for(let E of w.replaceAll(mr,"")){let y=E.codePointAt(0)||0;if(ft(y)?R=c:dt(y)?R=d:R=a,T+R>S&&(D=Math.min(D,Math.max(P,m)+b)),T+R>n){g=!0;break e}b+=E.length,T+=R}P=F=0}if(p>=h)break e;for(let w=0,E=x.length;w<E;w++){let[y,v]=x[w];if(y.lastIndex=p,y.test(e)){if(b=y===pt?ut(e.slice(p,y.lastIndex)):y===ht?1:y.lastIndex-p,R=b*v,T+R>S&&(D=Math.min(D,p+Math.floor((S-T)/v))),T+R>n){g=!0;break e}T+=R,P=m,F=p,p=m=y.lastIndex;continue e}}p+=1}return{width:g?S:T,index:g?D:h,truncated:g,ellipsed:g&&n>=l}},gt=mt;var wr={limit:1/0,ellipsis:"",ellipsisWidth:0},xr=(e,t={})=>gt(e,wr,t).width,k=xr;var ge="\x1B",St="\x9B",br=39,Ie="\x07",Et="[",Dr="]",yt="m",Ue=`${Dr}8;;`,wt=new RegExp(`(?:\\${Et}(?<code>\\d+)m|\\${Ue}(?<uri>.*)${Ie})`,"y"),xt=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},bt=e=>`${ge}${Et}${e}${yt}`,Dt=e=>`${ge}${Ue}${e}${Ie}`,Be=(e,t,r)=>{let n=t[Symbol.iterator](),i=!1,l=!1,s=e.at(-1),o=s===void 0?0:k(s),u=n.next(),f=n.next(),c=0;for(;!u.done;){let a=u.value,d=k(a);o+d<=r?e[e.length-1]+=a:(e.push(a),o=0),(a===ge||a===St)&&(i=!0,l=t.startsWith(Ue,c+1)),i?l?a===Ie&&(i=!1,l=!1):a===yt&&(i=!1):(o+=d,o===r&&!f.done&&(e.push(""),o=0)),u=f,f=n.next(),c+=a.length}s=e.at(-1),!o&&s!==void 0&&s.length&&e.length>1&&(e[e.length-2]+=e.pop())},Sr=e=>{let t=e.split(" "),r=t.length;for(;r&&!k(t[r-1]);)r--;return r===t.length?e:t.slice(0,r).join(" ")+t.slice(r).join("")},Er=(e,t,r={})=>{if(r.trim!==!1&&e.trim()==="")return"";let n="",i,l,s=e.split(" "),o=[""],u=0;for(let a=0;a<s.length;a++){let d=s[a];if(r.trim!==!1){let m=o.at(-1)??"",p=m.trimStart();m.length!==p.length&&(o[o.length-1]=p,u=k(p))}a!==0&&(u>=t&&(r.wordWrap===!1||r.trim===!1)&&(o.push(""),u=0),(u||r.trim===!1)&&(o[o.length-1]+=" ",u++));let x=k(d);if(r.hard&&x>t){let m=t-u,p=1+Math.floor((x-m-1)/t);Math.floor((x-1)/t)<p&&o.push(""),Be(o,d,t),u=k(o.at(-1)??"");continue}if(u+x>t&&u&&x){if(r.wordWrap===!1&&u<t){Be(o,d,t),u=k(o.at(-1)??"");continue}o.push(""),u=0}if(u+x>t&&r.wordWrap===!1){Be(o,d,t),u=k(o.at(-1)??"");continue}o[o.length-1]+=d,u+=x}r.trim!==!1&&(o=o.map(a=>Sr(a)));let f=o.join(`
4
- `),c=!1;for(let a=0;a<f.length;a++){let d=f[a];if(n+=d,c)c=!1;else if(c=d>="\uD800"&&d<="\uDBFF",c)continue;if(d===ge||d===St){wt.lastIndex=a+1;let m=wt.exec(f)?.groups;if(m?.code!==void 0){let p=Number.parseFloat(m.code);i=p===br?void 0:p}else m?.uri!==void 0&&(l=m.uri.length===0?void 0:m.uri)}if(f[a+1]===`
5
- `){l&&(n+=Dt(""));let x=i?xt(i):void 0;i&&x&&(n+=bt(x))}else d===`
6
- `&&(i&&xt(i)&&(n+=bt(i)),l&&(n+=Dt(l)))}return n},yr=/\r?\n/;function Lt(e,t,r){return String(e).normalize().split(yr).map(n=>Er(n,t,r)).join(`
7
- `)}function se(e,t){return e.split(`
8
- `).flatMap(r=>Lt(r,t,{trim:!1,hard:!0}).split(`
2
+ "use strict";var Qt=Object.create;var Qe=Object.defineProperty;var Zt=Object.getOwnPropertyDescriptor;var er=Object.getOwnPropertyNames;var tr=Object.getPrototypeOf,rr=Object.prototype.hasOwnProperty;var Ze=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var nr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of er(e))!rr.call(t,i)&&i!==r&&Qe(t,i,{get:()=>e[i],enumerable:!(n=Zt(e,i))||n.enumerable});return t};var k=(t,e,r)=>(r=t!=null?Qt(tr(t)):{},nr(e||!t||!t.__esModule?Qe(r,"default",{value:t,enumerable:!0}):r,t));var wt=Ze(($n,gt)=>{"use strict";gt.exports=xr;function Sr(t){let e={defaultWidth:0,output:process.stdout,tty:require("tty")};return t?(Object.keys(e).forEach(function(r){t[r]||(t[r]=e[r])}),t):e}function xr(t){let e=Sr(t);if(e.output.getWindowSize)return e.output.getWindowSize()[0]||e.defaultWidth;if(e.tty.getWindowSize)return e.tty.getWindowSize()[1]||e.defaultWidth;if(e.output.columns)return e.output.columns;if(process.env.CLI_WIDTH){let r=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(r)&&r!==0)return r}return e.defaultWidth}});var _t=Ze((ri,Ut)=>{var Ur=require("stream"),Oe=class extends Ur{#r=null;constructor(e={}){super(e),this.writable=this.readable=!0,this.muted=!1,this.on("pipe",this._onpipe),this.replace=e.replace,this._prompt=e.prompt||null,this._hadControl=!1}#t(e,r){return this._dest?this._dest[e]:this._src?this._src[e]:r}#e(e,...r){typeof this._dest?.[e]=="function"&&this._dest[e](...r),typeof this._src?.[e]=="function"&&this._src[e](...r)}get isTTY(){return this.#r!==null?this.#r:this.#t("isTTY",!1)}set isTTY(e){this.#r=e}get rows(){return this.#t("rows")}get columns(){return this.#t("columns")}mute(){this.muted=!0}unmute(){this.muted=!1}_onpipe(e){this._src=e}pipe(e,r){return this._dest=e,super.pipe(e,r)}pause(){if(this._src)return this._src.pause()}resume(){if(this._src)return this._src.resume()}write(e){if(this.muted){if(!this.replace)return!0;if(e.match(/^\u001b/))return e.indexOf(this._prompt)===0&&(e=e.slice(this._prompt.length),e=e.replace(/./g,this.replace),e=this._prompt+e),this._hadControl=!0,this.emit("data",e);this._prompt&&this._hadControl&&e.indexOf(this._prompt)===0&&(this._hadControl=!1,this.emit("data",this._prompt),e=e.slice(this._prompt.length)),e=e.toString().replace(/./g,this.replace)}this.emit("data",e)}end(e){this.muted&&(e&&this.replace?e=e.toString().replace(/./g,this.replace):e=null),e&&this.emit("data",e),this.emit("end")}destroy(...e){return this.#e("destroy",...e)}destroySoon(...e){return this.#e("destroySoon",...e)}close(...e){return this.#e("close",...e)}};Ut.exports=Oe});var A=k(require("path")),Le=require("fs/promises");var j=require("fs/promises");async function X(t){try{return await ir(t)?JSON.parse(await(0,j.readFile)(t,{encoding:"utf-8"})):void 0}catch(e){throw new Error(`Error reading JSON file ${t}: ${e}`,{cause:e})}}async function te(t,e){let r=JSON.stringify(e,null,4)+`
3
+ `,n=await or(t,r);await(0,j.writeFile)(t,n,{encoding:"utf-8"})}async function ir(t){try{return await(0,j.access)(t,j.constants.F_OK),!0}catch{return!1}}async function or(t,e){let r=await ar();if(!r)return e;let n=await r.resolveConfig(t);return n?await r.format(e,{...n,filepath:t}):e}var sr;function ar(){return sr??=import("prettier").catch(()=>{})}var re=["UNKNOWN","LOW","MEDIUM","HIGH","CRITICAL"];var Re=class t{constructor(e){this.workingDir=e}workingDir;static DEFAULT_MAVEN_REPO="https://repository.conterra.de/repository/maven-mirror-ct";static DEFAULT_VEX_SUBDIR="input/vex";static DEFAULT_OUT_SUBDIR="output";static DEFAULT_CACHE_SUBDIR="cache";static DEFAULT_SCANNERS=["grype","trivy","ossindex"];normalize(e,r){let n=e.findNoLongerDetectedVulnerabilitiesOnlyForSnapshots??!1;return{projectConfigFileLocation:r,onNewVulnerabilities:e.onNewVulnerabilities??(e.failOnNewVulnerabilities?"fail":"warn"),onNoLongerDetectedVulnerabilities:e.onNoLongerDetectedVulnerabilities??"ignore",reportNoLongerDetectedVulnerabilities:e.reportNoLongerDetectedVulnerabilities??!0,consoleReport:e.consoleReport??"BY_PROJECT_DETAILED",createSubDirsForProject:e.createSubDirsForProject??!0,mavenRepo:e.mavenRepo??t.DEFAULT_MAVEN_REPO,vexUrls:e.vexUrls??[],vexDir:this.resolvePath(e.vexDir)??(0,A.resolve)(this.workingDir,t.DEFAULT_VEX_SUBDIR),outDir:this.resolvePath(e.outDir)??(0,A.resolve)(this.workingDir,t.DEFAULT_OUT_SUBDIR),cacheDir:this.resolvePath(e.cacheDir)??(0,A.resolve)(this.workingDir,t.DEFAULT_CACHE_SUBDIR),scanners:this.normalizeScanners(e.scanners,r),projects:this.normalizeProjects(e.projects??[],n)}}normalizeScanners(e,r){return(e??t.DEFAULT_SCANNERS).map(i=>{if(typeof i!="string")throw new Error(`Invalid scanner name '${String(i)}' in configuration file '${r}'`);let s=i.split("@");if(s.length>2)throw new Error(`Invalid scanner name '${i}' in configuration file '${r}'`);return{name:s[0],version:s[1]??""}})}normalizeProjects(e,r){return e.map(n=>{let i=n;if(!i.name)throw new Error("Project name is missing on entry: "+JSON.stringify(i));if(!i.version)throw new Error("Project version is missing on entry: "+JSON.stringify(i));if(!i.purl)throw new Error("Project purl is missing on entry: "+JSON.stringify(i));let s={...i,purlAliases:i.purlAliases??[],enabled:i.enabled??!0,silent:i.silent??!1,minimumSeverity:i.minimumSeverity??"UNKNOWN"};return s.sbomFile?{...s,sbomFile:this.resolvePath(s.sbomFile)??s.sbomFile}:{...s,detectNoLongerUsedVulnerabilities:r?s.purl.endsWith("-SNAPSHOT"):!0}})}resolvePath(e){if(e)return A.default.isAbsolute(e)?e:(0,A.resolve)(this.workingDir,e)}},V=class{constructor(e){this.workingDir=e;this.normalizer=new Re(e)}workingDir;normalizer;projectConfigCache;async loadProjectConfig(){return this.projectConfigCache??=this.doLoadProjectConfig(),this.projectConfigCache}async doLoadProjectConfig(){let e=(0,A.resolve)(this.workingDir,"vuln-scan-conf.json"),r=await X(e);if(!r)throw new Error(`Missing project configuration file '${e}'`);return this.normalizer.normalize(r,e)}async loadJiraConfig(e){let r=await(0,Le.readFile)(e,"utf8"),n=JSON.parse(r);if(!n.issues&&n.issue&&(n.issues=n.issue),!n.jiraUrl||typeof n.jiraUrl!="string")throw new Error("jira-conf.json: missing or invalid 'jiraUrl' field");if(!Array.isArray(n.issues))throw new Error("jira-conf.json: missing or invalid 'issues' array");this.validateAutoCloseSeverity(n.autoCloseBelowSeverity,"jira-conf.json: invalid 'autoCloseBelowSeverity'");for(let[i,s]of n.issues.entries())s&&typeof s=="object"&&this.validateAutoCloseSeverity(s.autoCloseBelowSeverity,`jira-conf.json: invalid 'issues[${i}].autoCloseBelowSeverity'`);return n}validateAutoCloseSeverity(e,r){if(e!==void 0&&!re.includes(e))throw new Error(`${r} value '${String(e)}'. Must be one of: ${re.join(", ")}`)}async loadAutoVexConfig(e){let r=await(0,Le.readFile)(e,"utf8"),n=JSON.parse(r);if(!n.impactStatement||typeof n.impactStatement!="string")throw new Error("auto-vex-conf.json: missing or invalid 'impactStatement' field (must be a non-empty string)");if(n.maxSeverity!==void 0&&!re.includes(n.maxSeverity))throw new Error(`auto-vex-conf.json: invalid 'maxSeverity' value '${String(n.maxSeverity)}'. Must be one of: ${re.join(", ")}`);return n}};var ue=class{constructor(e){this.configFilePath=e}configFilePath;async readRawConfig(){let e=await X(this.configFilePath);if(!e)throw new Error(`Missing project configuration file '${this.configFilePath}'`);return e}async insertAfter(e,r){let n=await this.readRawConfig(),i=n.projects??[],s=i.findIndex(o=>o.name===e.name&&o.version===e.version);if(s===-1)throw new Error(`Reference project ${e.name}@${e.version} not found in config`);i.splice(s+1,0,r),n.projects=i,await te(this.configFilePath,n)}async remove(e,r){let n=await this.readRawConfig(),i=n.projects??[],s=i.findIndex(o=>o.name===e&&o.version===r);return s===-1?!1:(i.splice(s,1),n.projects=i,await te(this.configFilePath,n),!0)}};var it=require("fs/promises"),Fe=require("path");var de=require("fs/promises"),pe=require("path");var et=require("crypto");var lr="https://openvex.dev/ns/v0.2.0";function tt(t,e="conterra"){let n=`https://openvex.dev/docs/public/vex-${(0,et.randomUUID)()}`,i=t.timestamp??new Date().toISOString();return{"@context":lr,"@id":n,author:e,timestamp:i,last_updated:i,version:1,statements:[t]}}function rt(t,e){let r=e.timestamp??new Date().toISOString();return{...t,last_updated:r,version:t.version+1,statements:[...t.statements,e]}}var fe=class{constructor(e){this.location=e}location;_content=void 0;_exists=!1;get exists(){return this._exists}get content(){return this._content}set content(e){this._content=e,this._exists=e!==void 0}async read(){let e=await X(this.location);this._content=e??void 0,this._exists=this._content!==void 0}async write(){if(this._content===void 0)throw new Error(`Cannot write VexFile: content is undefined (${this.location})`);await(0,de.mkdir)((0,pe.dirname)((0,pe.resolve)(this.location)),{recursive:!0}),await te(this.location,this._content)}async delete(){await(0,de.unlink)(this.location),this._exists=!1}upsert(e,r){return this._content===void 0?(this._content=tt(e,r),this._exists=!0,{created:!0}):(this._content=rt(this._content,e),{created:!1})}addProductId(e,r){this.assertContentLoaded("addProductId");let n=!1;for(let i of this._content.statements){if(!i.products||i.products.some(o=>o["@id"]===r))continue;let s=i.products.findIndex(o=>o["@id"]===e);s!==-1&&(i.products.splice(s+1,0,{"@id":r}),n=!0)}return n}removeProductId(e,r){this.assertContentLoaded("removeProductId");let n=this._content.statements,i=[],s=!1;for(let o of n){if(r&&!nt(o).has(r)||!o.products)continue;let a=o.products.findIndex(c=>c["@id"]===e);a!==-1&&(o.products.splice(a,1),s=!0,o.products.length===0&&i.push(o))}if(!s)return"unchanged";for(let o of i)n.splice(n.indexOf(o),1);return n.length===0?"emptied":"changed"}hasStatementForProduct(e){return this.assertContentLoaded("hasStatementForProduct"),this._content.statements.some(r=>r.products?.some(n=>n["@id"]===e)??!1)}assertContentLoaded(e){if(this._content===void 0)throw new Error(`VexFile.${e}(): content is not loaded. Call read() first (${this.location})`)}};async function Ce(t,e){for(let r of await(0,it.readdir)(t,{withFileTypes:!0}))r.name.endsWith(".json")?await e(new fe((0,Fe.resolve)(r.parentPath,r.name))):r.isDirectory()&&await Ce((0,Fe.resolve)(r.parentPath,r.name),e)}function nt(t){let e=t.vulnerability.name;return new Set([e,...t.vulnerability.aliases??[]])}async function ot({workingDir:t,existingPurl:e,newPurl:r}){let n=await new V(t).loadProjectConfig();await Ce(n.vexDir,async i=>{await i.read(),i.addProductId(e,r)&&(console.info(`Add ${r} to ${i.location}`),await i.write())})}async function st({workingDir:t,projectName:e,referenceProjectVersion:r,targetProjectVersion:n}){let i=await new V(t).loadProjectConfig();if(!i.projectConfigFileLocation)throw new Error("Missing project configuration file.");let s=i.projects.find(a=>a.name===e&&a.version===r);if(!s)throw new Error(`Project ${e} with version ${r} not found.`);let o=i.projects.find(a=>a.name===e&&a.version===n);o||(o=await cr(e,i.projectConfigFileLocation,s,n)),await ot({workingDir:t,existingPurl:s.purl,newPurl:o.purl})}async function cr(t,e,r,n){let i=new ue(e),o=(await i.readRawConfig()).projects.find(c=>c.name===r.name&&c.version===r.version),a={...o};return a.version=n,a.purl=o.purl.replace(o.version,n),"sbomMavenCoordinates"in a?a.sbomMavenCoordinates=o.sbomMavenCoordinates.replace(o.version,n):"sbomFile"in a&&(a.sbomFile=o.sbomFile.replace(o.version,n)),console.info(`Add project ${t} with version ${n} to ${e}`),await i.insertAfter(r,a),a}var ne=(t,e=[])=>t.name==="up"||e.includes("vim")&&t.name==="k"||e.includes("emacs")&&t.ctrl&&t.name==="p",me=(t,e=[])=>t.name==="down"||e.includes("vim")&&t.name==="j"||e.includes("emacs")&&t.ctrl&&t.name==="n";var ie=t=>t.name==="backspace",oe=t=>t.name==="tab",Ie=t=>"1234567890".includes(t.name),M=t=>t.name==="enter"||t.name==="return";var he=class extends Error{name="AbortPromptError";message="Prompt was aborted";constructor(e){super(),this.cause=e?.cause}},ge=class extends Error{name="CancelPromptError";message="Prompt was canceled"},se=class extends Error{name="ExitPromptError"},we=class extends Error{name="HookError"},z=class extends Error{name="ValidationError"};var ut=require("node:async_hooks");var Se=require("node:async_hooks");var at=new Se.AsyncLocalStorage;function ur(t){return{rl:t,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function lt(t,e){let r=ur(t);return at.run(r,()=>{function n(i){r.handleChange=()=>{r.index=0,i()},r.handleChange()}return e(n)})}function $(){let t=at.getStore();if(!t)throw new we("[Inquirer] Hook functions can only be called from within a prompt");return t}function Te(){return $().rl}function je(t){let e=(...r)=>{let n=$(),i=!1,s=n.handleChange;n.handleChange=()=>{i=!0};let o=t(...r);return i&&s(),n.handleChange=s,o};return Se.AsyncResource.bind(e)}function Y(t){let e=$(),{index:r}=e,n={get(){return e.hooks[r]},set(s){e.hooks[r]=s},initialized:r in e.hooks},i=t(n);return e.index++,i}function ct(){$().handleChange()}var W={queue(t){let e=$(),{index:r}=e;e.hooksEffect.push(()=>{e.hooksCleanup[r]?.();let n=t(Te());if(n!=null&&typeof n!="function")throw new z("useEffect return value must be a cleanup function or nothing.");e.hooksCleanup[r]=n})},run(){let t=$();je(()=>{t.hooksEffect.forEach(e=>{e()}),t.hooksEffect.length=0})()},clearAll(){let t=$();t.hooksCleanup.forEach(e=>{e?.()}),t.hooksEffect.length=0,t.hooksCleanup.length=0}};function fr(t){return typeof t=="function"}function D(t){return Y(e=>{let r=ut.AsyncResource.bind(function(s){e.get()!==s&&(e.set(s),ct())});if(e.initialized)return[e.get(),r];let n=fr(t)?t():t;return e.set(n),[n,r]})}function _(t,e){Y(r=>{let n=r.get();(!Array.isArray(n)||e.some((s,o)=>!Object.is(s,n[o])))&&W.queue(t),r.set(e)})}var T=require("node:util");var I=k(require("node:process"),1);function dr(){return I.default.platform.startsWith("win")?!!I.default.env.CI||!!I.default.env.WT_SESSION||!!I.default.env.TERMINUS_SUBLIME||I.default.env.ConEmuTask==="{cmd::Cmder}"||I.default.env.TERM_PROGRAM==="Terminus-Sublime"||I.default.env.TERM_PROGRAM==="vscode"||I.default.env.TERM==="xterm-256color"||I.default.env.TERM==="alacritty"||I.default.env.TERMINAL_EMULATOR==="JetBrains-JediTerm":I.default.env.TERM!=="linux"}var ft={circleQuestionMark:"(?)",questionMarkPrefix:"(?)",square:"\u2588",squareDarkShade:"\u2593",squareMediumShade:"\u2592",squareLightShade:"\u2591",squareTop:"\u2580",squareBottom:"\u2584",squareLeft:"\u258C",squareRight:"\u2590",squareCenter:"\u25A0",bullet:"\u25CF",dot:"\u2024",ellipsis:"\u2026",pointerSmall:"\u203A",triangleUp:"\u25B2",triangleUpSmall:"\u25B4",triangleDown:"\u25BC",triangleDownSmall:"\u25BE",triangleLeftSmall:"\u25C2",triangleRightSmall:"\u25B8",home:"\u2302",heart:"\u2665",musicNote:"\u266A",musicNoteBeamed:"\u266B",arrowUp:"\u2191",arrowDown:"\u2193",arrowLeft:"\u2190",arrowRight:"\u2192",arrowLeftRight:"\u2194",arrowUpDown:"\u2195",almostEqual:"\u2248",notEqual:"\u2260",lessOrEqual:"\u2264",greaterOrEqual:"\u2265",identical:"\u2261",infinity:"\u221E",subscriptZero:"\u2080",subscriptOne:"\u2081",subscriptTwo:"\u2082",subscriptThree:"\u2083",subscriptFour:"\u2084",subscriptFive:"\u2085",subscriptSix:"\u2086",subscriptSeven:"\u2087",subscriptEight:"\u2088",subscriptNine:"\u2089",oneHalf:"\xBD",oneThird:"\u2153",oneQuarter:"\xBC",oneFifth:"\u2155",oneSixth:"\u2159",oneEighth:"\u215B",twoThirds:"\u2154",twoFifths:"\u2156",threeQuarters:"\xBE",threeFifths:"\u2157",threeEighths:"\u215C",fourFifths:"\u2158",fiveSixths:"\u215A",fiveEighths:"\u215D",sevenEighths:"\u215E",line:"\u2500",lineBold:"\u2501",lineDouble:"\u2550",lineDashed0:"\u2504",lineDashed1:"\u2505",lineDashed2:"\u2508",lineDashed3:"\u2509",lineDashed4:"\u254C",lineDashed5:"\u254D",lineDashed6:"\u2574",lineDashed7:"\u2576",lineDashed8:"\u2578",lineDashed9:"\u257A",lineDashed10:"\u257C",lineDashed11:"\u257E",lineDashed12:"\u2212",lineDashed13:"\u2013",lineDashed14:"\u2010",lineDashed15:"\u2043",lineVertical:"\u2502",lineVerticalBold:"\u2503",lineVerticalDouble:"\u2551",lineVerticalDashed0:"\u2506",lineVerticalDashed1:"\u2507",lineVerticalDashed2:"\u250A",lineVerticalDashed3:"\u250B",lineVerticalDashed4:"\u254E",lineVerticalDashed5:"\u254F",lineVerticalDashed6:"\u2575",lineVerticalDashed7:"\u2577",lineVerticalDashed8:"\u2579",lineVerticalDashed9:"\u257B",lineVerticalDashed10:"\u257D",lineVerticalDashed11:"\u257F",lineDownLeft:"\u2510",lineDownLeftArc:"\u256E",lineDownBoldLeftBold:"\u2513",lineDownBoldLeft:"\u2512",lineDownLeftBold:"\u2511",lineDownDoubleLeftDouble:"\u2557",lineDownDoubleLeft:"\u2556",lineDownLeftDouble:"\u2555",lineDownRight:"\u250C",lineDownRightArc:"\u256D",lineDownBoldRightBold:"\u250F",lineDownBoldRight:"\u250E",lineDownRightBold:"\u250D",lineDownDoubleRightDouble:"\u2554",lineDownDoubleRight:"\u2553",lineDownRightDouble:"\u2552",lineUpLeft:"\u2518",lineUpLeftArc:"\u256F",lineUpBoldLeftBold:"\u251B",lineUpBoldLeft:"\u251A",lineUpLeftBold:"\u2519",lineUpDoubleLeftDouble:"\u255D",lineUpDoubleLeft:"\u255C",lineUpLeftDouble:"\u255B",lineUpRight:"\u2514",lineUpRightArc:"\u2570",lineUpBoldRightBold:"\u2517",lineUpBoldRight:"\u2516",lineUpRightBold:"\u2515",lineUpDoubleRightDouble:"\u255A",lineUpDoubleRight:"\u2559",lineUpRightDouble:"\u2558",lineUpDownLeft:"\u2524",lineUpBoldDownBoldLeftBold:"\u252B",lineUpBoldDownBoldLeft:"\u2528",lineUpDownLeftBold:"\u2525",lineUpBoldDownLeftBold:"\u2529",lineUpDownBoldLeftBold:"\u252A",lineUpDownBoldLeft:"\u2527",lineUpBoldDownLeft:"\u2526",lineUpDoubleDownDoubleLeftDouble:"\u2563",lineUpDoubleDownDoubleLeft:"\u2562",lineUpDownLeftDouble:"\u2561",lineUpDownRight:"\u251C",lineUpBoldDownBoldRightBold:"\u2523",lineUpBoldDownBoldRight:"\u2520",lineUpDownRightBold:"\u251D",lineUpBoldDownRightBold:"\u2521",lineUpDownBoldRightBold:"\u2522",lineUpDownBoldRight:"\u251F",lineUpBoldDownRight:"\u251E",lineUpDoubleDownDoubleRightDouble:"\u2560",lineUpDoubleDownDoubleRight:"\u255F",lineUpDownRightDouble:"\u255E",lineDownLeftRight:"\u252C",lineDownBoldLeftBoldRightBold:"\u2533",lineDownLeftBoldRightBold:"\u252F",lineDownBoldLeftRight:"\u2530",lineDownBoldLeftBoldRight:"\u2531",lineDownBoldLeftRightBold:"\u2532",lineDownLeftRightBold:"\u252E",lineDownLeftBoldRight:"\u252D",lineDownDoubleLeftDoubleRightDouble:"\u2566",lineDownDoubleLeftRight:"\u2565",lineDownLeftDoubleRightDouble:"\u2564",lineUpLeftRight:"\u2534",lineUpBoldLeftBoldRightBold:"\u253B",lineUpLeftBoldRightBold:"\u2537",lineUpBoldLeftRight:"\u2538",lineUpBoldLeftBoldRight:"\u2539",lineUpBoldLeftRightBold:"\u253A",lineUpLeftRightBold:"\u2536",lineUpLeftBoldRight:"\u2535",lineUpDoubleLeftDoubleRightDouble:"\u2569",lineUpDoubleLeftRight:"\u2568",lineUpLeftDoubleRightDouble:"\u2567",lineUpDownLeftRight:"\u253C",lineUpBoldDownBoldLeftBoldRightBold:"\u254B",lineUpDownBoldLeftBoldRightBold:"\u2548",lineUpBoldDownLeftBoldRightBold:"\u2547",lineUpBoldDownBoldLeftRightBold:"\u254A",lineUpBoldDownBoldLeftBoldRight:"\u2549",lineUpBoldDownLeftRight:"\u2540",lineUpDownBoldLeftRight:"\u2541",lineUpDownLeftBoldRight:"\u253D",lineUpDownLeftRightBold:"\u253E",lineUpBoldDownBoldLeftRight:"\u2542",lineUpDownLeftBoldRightBold:"\u253F",lineUpBoldDownLeftBoldRight:"\u2543",lineUpBoldDownLeftRightBold:"\u2544",lineUpDownBoldLeftBoldRight:"\u2545",lineUpDownBoldLeftRightBold:"\u2546",lineUpDoubleDownDoubleLeftDoubleRightDouble:"\u256C",lineUpDoubleDownDoubleLeftRight:"\u256B",lineUpDownLeftDoubleRightDouble:"\u256A",lineCross:"\u2573",lineBackslash:"\u2572",lineSlash:"\u2571"},dt={tick:"\u2714",info:"\u2139",warning:"\u26A0",cross:"\u2718",squareSmall:"\u25FB",squareSmallFilled:"\u25FC",circle:"\u25EF",circleFilled:"\u25C9",circleDotted:"\u25CC",circleDouble:"\u25CE",circleCircle:"\u24DE",circleCross:"\u24E7",circlePipe:"\u24BE",radioOn:"\u25C9",radioOff:"\u25EF",checkboxOn:"\u2612",checkboxOff:"\u2610",checkboxCircleOn:"\u24E7",checkboxCircleOff:"\u24BE",pointer:"\u276F",triangleUpOutline:"\u25B3",triangleLeft:"\u25C0",triangleRight:"\u25B6",lozenge:"\u25C6",lozengeOutline:"\u25C7",hamburger:"\u2630",smiley:"\u32E1",mustache:"\u0DF4",star:"\u2605",play:"\u25B6",nodejs:"\u2B22",oneSeventh:"\u2150",oneNinth:"\u2151",oneTenth:"\u2152"},pr={tick:"\u221A",info:"i",warning:"\u203C",cross:"\xD7",squareSmall:"\u25A1",squareSmallFilled:"\u25A0",circle:"( )",circleFilled:"(*)",circleDotted:"( )",circleDouble:"( )",circleCircle:"(\u25CB)",circleCross:"(\xD7)",circlePipe:"(\u2502)",radioOn:"(*)",radioOff:"( )",checkboxOn:"[\xD7]",checkboxOff:"[ ]",checkboxCircleOn:"(\xD7)",checkboxCircleOff:"( )",pointer:">",triangleUpOutline:"\u2206",triangleLeft:"\u25C4",triangleRight:"\u25BA",lozenge:"\u2666",lozengeOutline:"\u25CA",hamburger:"\u2261",smiley:"\u263A",mustache:"\u250C\u2500\u2510",star:"\u2736",play:"\u25BA",nodejs:"\u2666",oneSeventh:"1/7",oneNinth:"1/9",oneTenth:"1/10"},mr={...ft,...dt},hr={...ft,...pr},gr=dr(),wr=gr?mr:hr,Q=wr,Dn=Object.entries(dt);var pt={prefix:{idle:(0,T.styleText)("blue","?"),done:(0,T.styleText)("green",Q.tick)},spinner:{interval:80,frames:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"].map(t=>(0,T.styleText)("yellow",t))},style:{answer:t=>(0,T.styleText)("cyan",t),message:t=>(0,T.styleText)("bold",t),error:t=>(0,T.styleText)("red",`> ${t}`),defaultAnswer:t=>(0,T.styleText)("dim",`(${t})`),help:t=>(0,T.styleText)("dim",t),highlight:t=>(0,T.styleText)("cyan",t),key:t=>(0,T.styleText)("cyan",(0,T.styleText)("bold",`<${t}>`))}};function mt(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function ht(...t){let e={};for(let r of t)for(let[n,i]of Object.entries(r)){let s=e[n];e[n]=mt(s)&&mt(i)?ht(s,i):i}return e}function N(...t){let e=[pt,...t.filter(r=>r!=null)];return ht(...e)}function H({status:t="idle",theme:e}){let[r,n]=D(!1),[i,s]=D(0),{prefix:o,spinner:a}=N(e);return _(()=>{if(t==="loading"){let u,f=-1,l=setTimeout(()=>{n(!0),u=setInterval(()=>{f=f+1,s(f%a.frames.length)},a.interval)},300);return()=>{clearTimeout(l),clearInterval(u)}}else n(!1)},[t]),r?a.frames[i]:typeof o=="string"?o:o[t==="loading"?"idle":t]??o.idle}function ae(t,e){return Y(r=>{let n=r.get();if(!n||n.dependencies.length!==e.length||n.dependencies.some((i,s)=>i!==e[s])){let i=t();return r.set({value:i,dependencies:e}),i}return n.value})}function K(t){return D({current:t})[0]}function G(t){let e=K(t);e.current=t,_(r=>{let n=!1,i=je((s,o)=>{n||e.current(o,r)});return r.input.on("keypress",i),()=>{n=!0,r.input.removeListener("keypress",i)}},[])}var Bt=k(wt(),1);var St=(()=>{let t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return e=>{let r=0;for(t.lastIndex=0;t.test(e);)r+=1;return e.length-r}})(),xt=t=>t===12288||t>=65281&&t<=65376||t>=65504&&t<=65510,bt=t=>t===8987||t===9001||t>=12272&&t<=12287||t>=12289&&t<=12350||t>=12441&&t<=12543||t>=12549&&t<=12591||t>=12593&&t<=12686||t>=12688&&t<=12771||t>=12783&&t<=12830||t>=12832&&t<=12871||t>=12880&&t<=19903||t>=65040&&t<=65049||t>=65072&&t<=65106||t>=65108&&t<=65126||t>=65128&&t<=65131||t>=127488&&t<=127490||t>=127504&&t<=127547||t>=127552&&t<=127560||t>=131072&&t<=196605||t>=196608&&t<=262141;var br=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,yr=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,yt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu,Er=/\t{1,1000}/y,Et=new RegExp("[\\u{1F1E6}-\\u{1F1FF}]{2}|\\u{1F3F4}[\\u{E0061}-\\u{E007A}]{2}[\\u{E0030}-\\u{E0039}\\u{E0061}-\\u{E007A}]{1,3}\\u{E007F}|(?:\\p{Emoji}\\uFE0F\\u20E3?|\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation})(?:\\u200D(?:\\p{Emoji_Modifier_Base}\\p{Emoji_Modifier}?|\\p{Emoji_Presentation}|\\p{Emoji}\\uFE0F\\u20E3?))*","yu"),vr=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,Dr=new RegExp("\\p{M}+","gu"),Pr={limit:1/0,ellipsis:""},vt=(t,e={},r={})=>{let n=e.limit??1/0,i=e.ellipsis??"",s=e?.ellipsisWidth??(i?vt(i,Pr,r).width:0),o=0,a=r.controlWidth??0,c=r.tabWidth??8,u=r.emojiWidth??2,f=2,l=r.regularWidth??1,p=r.wideWidth??f,S=[[vr,l],[br,o],[yr,a],[Er,c],[Et,u],[yt,p]],h=0,d=0,m=t.length,x=0,g=!1,b=m,y=Math.max(0,n-s),P=0,L=0,F=0,C=0;e:for(;;){if(L>P||d>=m&&d>h){let w=t.slice(P,L)||t.slice(h,d);x=0;for(let E of w.replaceAll(Dr,"")){let v=E.codePointAt(0)||0;if(xt(v)?C=f:bt(v)?C=p:C=l,F+C>y&&(b=Math.min(b,Math.max(P,h)+x)),F+C>n){g=!0;break e}x+=E.length,F+=C}P=L=0}if(d>=m)break e;for(let w=0,E=S.length;w<E;w++){let[v,R]=S[w];if(v.lastIndex=d,v.test(t)){if(x=v===yt?St(t.slice(d,v.lastIndex)):v===Et?1:v.lastIndex-d,C=x*R,F+C>y&&(b=Math.min(b,d+Math.floor((y-F)/R))),F+C>n){g=!0;break e}F+=C,P=h,L=d,d=h=v.lastIndex;continue e}}d+=1}return{width:g?y:F,index:g?b:m,truncated:g,ellipsed:g&&n>=s}},Dt=vt;var Lr={limit:1/0,ellipsis:"",ellipsisWidth:0},Rr=(t,e={})=>Dt(t,Lr,e).width,O=Rr;var xe="\x1B",Ct="\x9B",Fr=39,Ue="\x07",It="[",Cr="]",Tt="m",_e=`${Cr}8;;`,Pt=new RegExp(`(?:\\${It}(?<code>\\d+)m|\\${_e}(?<uri>.*)${Ue})`,"y"),Lt=t=>{if(t>=30&&t<=37||t>=90&&t<=97)return 39;if(t>=40&&t<=47||t>=100&&t<=107)return 49;if(t===1||t===2)return 22;if(t===3)return 23;if(t===4)return 24;if(t===7)return 27;if(t===8)return 28;if(t===9)return 29;if(t===0)return 0},Rt=t=>`${xe}${It}${t}${Tt}`,Ft=t=>`${xe}${_e}${t}${Ue}`,Be=(t,e,r)=>{let n=e[Symbol.iterator](),i=!1,s=!1,o=t.at(-1),a=o===void 0?0:O(o),c=n.next(),u=n.next(),f=0;for(;!c.done;){let l=c.value,p=O(l);a+p<=r?t[t.length-1]+=l:(t.push(l),a=0),(l===xe||l===Ct)&&(i=!0,s=e.startsWith(_e,f+1)),i?s?l===Ue&&(i=!1,s=!1):l===Tt&&(i=!1):(a+=p,a===r&&!u.done&&(t.push(""),a=0)),c=u,u=n.next(),f+=l.length}o=t.at(-1),!a&&o!==void 0&&o.length&&t.length>1&&(t[t.length-2]+=t.pop())},Ir=t=>{let e=t.split(" "),r=e.length;for(;r&&!O(e[r-1]);)r--;return r===e.length?t:e.slice(0,r).join(" ")+e.slice(r).join("")},Tr=(t,e,r={})=>{if(r.trim!==!1&&t.trim()==="")return"";let n="",i,s,o=t.split(" "),a=[""],c=0;for(let l=0;l<o.length;l++){let p=o[l];if(r.trim!==!1){let h=a.at(-1)??"",d=h.trimStart();h.length!==d.length&&(a[a.length-1]=d,c=O(d))}l!==0&&(c>=e&&(r.wordWrap===!1||r.trim===!1)&&(a.push(""),c=0),(c||r.trim===!1)&&(a[a.length-1]+=" ",c++));let S=O(p);if(r.hard&&S>e){let h=e-c,d=1+Math.floor((S-h-1)/e);Math.floor((S-1)/e)<d&&a.push(""),Be(a,p,e),c=O(a.at(-1)??"");continue}if(c+S>e&&c&&S){if(r.wordWrap===!1&&c<e){Be(a,p,e),c=O(a.at(-1)??"");continue}a.push(""),c=0}if(c+S>e&&r.wordWrap===!1){Be(a,p,e),c=O(a.at(-1)??"");continue}a[a.length-1]+=p,c+=S}r.trim!==!1&&(a=a.map(l=>Ir(l)));let u=a.join(`
4
+ `),f=!1;for(let l=0;l<u.length;l++){let p=u[l];if(n+=p,f)f=!1;else if(f=p>="\uD800"&&p<="\uDBFF",f)continue;if(p===xe||p===Ct){Pt.lastIndex=l+1;let h=Pt.exec(u)?.groups;if(h?.code!==void 0){let d=Number.parseFloat(h.code);i=d===Fr?void 0:d}else h?.uri!==void 0&&(s=h.uri.length===0?void 0:h.uri)}if(u[l+1]===`
5
+ `){s&&(n+=Ft(""));let S=i?Lt(i):void 0;i&&S&&(n+=Rt(S))}else p===`
6
+ `&&(i&&Lt(i)&&(n+=Rt(i)),s&&(n+=Ft(s)))}return n},jr=/\r?\n/;function jt(t,e,r){return String(t).normalize().split(jr).map(n=>Tr(n,e,r)).join(`
7
+ `)}function le(t,e){return t.split(`
8
+ `).flatMap(r=>jt(r,e,{trim:!1,hard:!0}).split(`
9
9
  `).map(n=>n.trimEnd())).join(`
10
- `)}function we(){return(0,Pt.default)({defaultWidth:80,output:Te().output})}function Lr({active:e,renderedItems:t,pageSize:r,loop:n}){let i=K({lastPointer:e,lastActive:void 0}),{lastPointer:l,lastActive:s}=i.current,o=Math.floor(r/2),u=t.reduce((a,d)=>a+d.length,0),f=t.slice(0,e).reduce((a,d)=>a+d.length,0),c=f;if(u>r)if(n)c=l,s!=null&&s<e&&e-s<r&&(c=Math.min(o,Math.abs(e-s)===1?Math.min(l+(t[s]?.length??0),Math.max(f,l)):l+e-s));else{let a=t.slice(e).reduce((d,x)=>d+x.length,0);c=a<r-o?r-a:Math.min(f,o)}return i.current.lastPointer=c,i.current.lastActive=e,c}function Ce({items:e,active:t,renderItem:r,pageSize:n,loop:i=!0}){let l=we(),s=b=>(b%e.length+e.length)%e.length,o=e.map((b,g)=>b==null?[]:se(r({item:b,index:g,isActive:g===t}),l).split(`
11
- `)),u=o.reduce((b,g)=>b+g.length,0),f=b=>o[b]??[],c=Lr({active:t,renderedItems:o,pageSize:n,loop:i}),a=f(t).slice(0,n),d=c+a.length<=n?c:n-a.length,x=Array.from({length:n});x.splice(d,a.length,...a);let m=new Set([t]),p=d+a.length,h=s(t+1);for(;p<n&&!m.has(h)&&(i&&u>n?h!==t:h>t);){let g=f(h).slice(0,n-p);x.splice(p,g.length,...g),m.add(h),p+=g.length,h=s(h+1)}for(p=d-1,h=s(t-1);p>=0&&!m.has(h)&&(i&&u>n?h!==t:h<t);){let b=f(h),g=b.slice(Math.max(0,b.length-p-1));x.splice(p-g.length+1,g.length,...g),m.add(h),p-=g.length,h=s(h-1)}return x.filter(b=>typeof b=="string").join(`
12
- `)}var _t=A(require("node:readline"),1),Nt=require("node:async_hooks"),jt=A(vt(),1);var G=[];G.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&G.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&G.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var xe=e=>!!e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function",Ne=Symbol.for("signal-exit emitter"),je=globalThis,Fr=Object.defineProperty.bind(Object),ke=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(je[Ne])return je[Ne];Fr(je,Ne,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(t,r){this.listeners[t].push(r)}removeListener(t,r){let n=this.listeners[t],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(t,r,n){if(this.emitted[t])return!1;this.emitted[t]=!0;let i=!1;for(let l of this.listeners[t])i=l(r,n)===!0||i;return t==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},be=class{},vr=e=>({onExit(t,r){return e.onExit(t,r)},load(){return e.load()},unload(){return e.unload()}}),Oe=class extends be{onExit(){return()=>{}}load(){}unload(){}},Ae=class extends be{#r=Ve.platform==="win32"?"SIGINT":"SIGHUP";#t=new ke;#e;#o;#s;#i={};#n=!1;constructor(t){super(),this.#e=t,this.#i={};for(let r of G)this.#i[r]=()=>{let n=this.#e.listeners(r),{count:i}=this.#t,l=t;if(typeof l.__signal_exit_emitter__=="object"&&typeof l.__signal_exit_emitter__.count=="number"&&(i+=l.__signal_exit_emitter__.count),n.length===i){this.unload();let s=this.#t.emit("exit",null,r),o=r==="SIGHUP"?this.#r:r;s||t.kill(t.pid,o)}};this.#s=t.reallyExit,this.#o=t.emit}onExit(t,r){if(!xe(this.#e))return()=>{};this.#n===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#t.on(n,t),()=>{this.#t.removeListener(n,t),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#n){this.#n=!0,this.#t.count+=1;for(let t of G)try{let r=this.#i[t];r&&this.#e.on(t,r)}catch{}this.#e.emit=(t,...r)=>this.#a(t,...r),this.#e.reallyExit=t=>this.#l(t)}}unload(){this.#n&&(this.#n=!1,G.forEach(t=>{let r=this.#i[t];if(!r)throw new Error("Listener not defined for signal: "+t);try{this.#e.removeListener(t,r)}catch{}}),this.#e.emit=this.#o,this.#e.reallyExit=this.#s,this.#t.count-=1)}#l(t){return xe(this.#e)?(this.#e.exitCode=t||0,this.#t.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)):0}#a(t,...r){let n=this.#o;if(t==="exit"&&xe(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let i=n.call(this.#e,t,...r);return this.#t.emit("exit",this.#e.exitCode,null),i}else return n.call(this.#e,t,...r)}},Ve=globalThis.process,{onExit:Tt,load:Mn,unload:$n}=vr(xe(Ve)?new Ae(Ve):new Oe);var Ct=require("node:util");var Bt="\x1B[?25l",It="\x1B[?25h",Me=(e=1)=>e>0?`\x1B[${e}A`:"",$e=(e=1)=>e>0?`\x1B[${e}B`:"",We=(e,t)=>typeof t=="number"&&!Number.isNaN(t)?`\x1B[${t+1};${e+1}H`:`\x1B[${e+1}G`,Rt="\x1B[2K",Ke=e=>e>0?(Rt+Me(1)).repeat(e-1)+Rt+"\x1B[G":"";var Ut=e=>e.split(`
13
- `).length,Tr=e=>e.split(`
14
- `).pop()??"",le=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(t){this.rl=t,this.cursorPos=t.getCursorPos()}write(t){this.rl.output.unmute(),this.rl.output.write(t),this.rl.output.mute()}render(t,r=""){let n=Tr(t),i=(0,Ct.stripVTControlCharacters)(n),l=i;this.rl.line.length>0&&(l=l.slice(0,-this.rl.line.length)),this.rl.setPrompt(l),this.cursorPos=this.rl.getCursorPos();let s=we();t=se(t,s),r=se(r,s),i.length%s===0&&(t+=`
15
- `);let o=t+(r?`
16
- `+r:""),f=Math.floor(i.length/s)-this.cursorPos.rows+(r?Ut(r):0);f>0&&(o+=Me(f)),o+=We(this.cursorPos.cols),this.write($e(this.extraLinesUnderPrompt)+Ke(this.height)+o),this.extraLinesUnderPrompt=f,this.height=Ut(o)}checkCursorPos(){let t=this.rl.getCursorPos();t.cols!==this.cursorPos.cols&&(this.write(We(t.cols)),this.cursorPos=t)}done({clearContent:t}){this.rl.setPrompt("");let r=$e(this.extraLinesUnderPrompt);r+=t?Ke(this.height):`
17
- `,r+=It,this.write(r),this.rl.close()}};var De=class extends Promise{static withResolver(){let t,r;return{promise:new Promise((i,l)=>{t=i,r=l}),resolve:t,reject:r}}};var kt=A(require("node:path"),1),Rr=globalThis.setImmediate;function Br(){let e=Error.prepareStackTrace,t=[];try{Error.prepareStackTrace=(r,n)=>{let i=n.slice(1);return t=i,i},new Error().stack}catch{return t}return Error.prepareStackTrace=e,t}function q(e){let t=Br();return(n,i={})=>{let{input:l=process.stdin,signal:s}=i,o=new Set,u=new jt.default;u.pipe(i.output??process.stdout);let f=_t.createInterface({terminal:!0,input:l,output:u});u.mute();let c=new le(f),{promise:a,resolve:d,reject:x}=De.withResolver(),m=()=>x(new pe);if(s){let h=()=>x(new de({cause:s.reason}));if(s.aborted)return h(),Object.assign(a,{cancel:m});s.addEventListener("abort",h),o.add(()=>s.removeEventListener("abort",h))}o.add(Tt((h,b)=>{x(new ie(`User force closed the prompt with ${h} ${b}`))}));let p=()=>x(new ie("User force closed the prompt with SIGINT"));return f.on("SIGINT",p),o.add(()=>f.removeListener("SIGINT",p)),et(f,h=>{let b=Nt.AsyncResource.bind(()=>$.clearAll());f.on("close",b),o.add(()=>f.removeListener("close",b));let g=()=>{let D=()=>c.checkCursorPos();f.input.on("keypress",D),o.add(()=>f.input.removeListener("keypress",D));let S=null;h(()=>{let P=!1;try{let F=e(n,w=>{P?d(w):S={value:w}});if(F===void 0){let w=t[1]?.getFileName();throw w&&!w.startsWith("file://")&&(w=kt.default.resolve(w)),new Error(`Prompt functions must return a string.
18
- at ${w}`)}let[T,R]=typeof F=="string"?[F]:F;c.render(T,R),$.run()}catch(F){x(F)}if(P=!0,S!==null){let{value:F}=S;S=null,d(F)}})};return"readableFlowing"in l?Rr(g):g(),Object.assign(a.then(D=>($.clearAll(),D),D=>{throw $.clearAll(),D}).finally(()=>{o.forEach(D=>D()),c.done({clearContent:!!i.clearPromptOnDone}),u.end()}).then(()=>a),{cancel:m})})}}var Ot=require("node:util");var C=class{separator=(0,Ot.styleText)("dim",Array.from({length:15}).join(Q.line));type="separator";constructor(t){t&&(this.separator=t)}static isSeparator(t){return!!(t&&typeof t=="object"&&"type"in t&&t.type==="separator")}};function At(e,t){let r=t!==!1;return/^(y|yes)/i.test(e)?r=!0:/^(n|no)/i.test(e)&&(r=!1),r}function Vt(e){return e?"Yes":"No"}var He=q((e,t)=>{let{transformer:r=Vt}=e,[n,i]=L("idle"),[l,s]=L(""),o=j(e.theme),u=W({status:n,theme:o});H((d,x)=>{if(n==="idle")if(V(d)){let m=At(l,e.default);s(r(m)),i("done"),t(m)}else if(ne(d)){let m=Vt(!At(l,e.default));x.clearLine(0),x.write(m),s(m)}else s(x.line)});let f=l,c="";n==="done"?f=o.style.answer(l):c=` ${o.style.defaultAnswer(e.default===!1?"y/N":"Y/n")}`;let a=o.style.message(e.message,n);return`${u} ${a}${c} ${f}`});var Ir={validationFailureMode:"keep"},Ge=q((e,t)=>{let{prefill:r="tab"}=e,n=j(Ir,e.theme),[i,l]=L("idle"),[s,o]=L(String(e.default??"")),[u,f]=L(),[c,a]=L(""),d=W({status:i,theme:n});async function x(g){let{required:D,pattern:S,patternError:P="Invalid input"}=e;return D&&!g?"You must provide a value":S&&!S.test(g)?P:typeof e.validate=="function"?await e.validate(g)||"You must provide a valid value":!0}H(async(g,D)=>{if(i==="idle")if(V(g)){let S=c||s;l("loading");let P=await x(S);P===!0?(a(S),l("done"),t(S)):(n.validationFailureMode==="clear"?a(""):D.write(c),f(P),l("idle"))}else re(g)&&!c?o(""):ne(g)&&!c?(o(""),D.clearLine(0),D.write(s),a(s)):(a(D.line),f(void 0))}),N(g=>{r==="editable"&&s&&(g.write(s),a(s))},[]);let m=n.style.message(e.message,i),p=c;typeof e.transformer=="function"?p=e.transformer(c,{isFinal:i==="done"}):i==="done"&&(p=n.style.answer(c));let h;s&&i!=="done"&&!c&&(h=n.style.defaultAnswer(s));let b="";return u&&(b=n.style.error(u)),[[d,m,h,p].filter(g=>g!==void 0).join(" "),b]});var Z=require("node:util");var Ur={icon:{cursor:Q.pointer},style:{disabled:e=>(0,Z.styleText)("dim",e),description:e=>(0,Z.styleText)("cyan",e),keysHelpTip:e=>e.map(([t,r])=>`${(0,Z.styleText)("bold",t)} ${(0,Z.styleText)("dim",r)}`).join((0,Z.styleText)("dim"," \u2022 "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden",keybindings:[]};function qe(e){return!C.isSeparator(e)&&!e.disabled}function Je(e){return!C.isSeparator(e)}function Cr(e){return e.map(t=>{if(C.isSeparator(t))return t;if(typeof t!="object"||t===null||!("value"in t)){let i=String(t);return{value:t,name:i,short:i,disabled:!1}}let r=t.name??String(t.value),n={value:t.value,name:r,short:t.short??r,disabled:t.disabled??!1};return t.description&&(n.description=t.description),n})}var Se=q((e,t)=>{let{loop:r=!0,pageSize:n=7}=e,i=j(Ur,e.theme),{keybindings:l}=i,[s,o]=L("idle"),u=W({status:s,theme:i}),f=K(),c=!l.includes("vim"),a=oe(()=>Cr(e.choices),[e.choices]),d=oe(()=>{let w=a.findIndex(Je),E=a.findLastIndex(Je);if(w===-1)throw new Y("[select prompt] No selectable choices. All choices are disabled.");return{first:w,last:E}},[a]),x=oe(()=>"default"in e?a.findIndex(w=>qe(w)&&w.value===e.default):-1,[e.default,a]),[m,p]=L(x===-1?d.first:x),h=a[m];if(h==null||C.isSeparator(h))throw new Error("Active index does not point to a choice");let[b,g]=L();H((w,E)=>{if(clearTimeout(f.current),b&&g(void 0),V(w))h.disabled?g(i.i18n.disabledError):(o("done"),t(h.value));else if(te(w,l)||fe(w,l)){if(E.clearLine(0),r||te(w,l)&&m!==d.first||fe(w,l)&&m!==d.last){let y=te(w,l)?-1:1,v=m;do v=(v+y+a.length)%a.length;while(!Je(a[v]));p(v)}}else if(ve(w)&&!Number.isNaN(Number(E.line))){let y=Number(E.line)-1,v=-1,_=a.findIndex(ee=>C.isSeparator(ee)?!1:(v++,v===y)),Ee=a[_];Ee!=null&&qe(Ee)&&p(_),f.current=setTimeout(()=>{E.clearLine(0)},700)}else if(re(w))E.clearLine(0);else if(c){let y=E.line.toLowerCase(),v=a.findIndex(_=>C.isSeparator(_)||!qe(_)?!1:_.name.toLowerCase().startsWith(y));v!==-1&&p(v),f.current=setTimeout(()=>{E.clearLine(0)},700)}}),N(()=>()=>{clearTimeout(f.current)},[]);let D=i.style.message(e.message,s),S=i.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]),P=0,F=Ce({items:a,active:m,renderItem({item:w,isActive:E,index:y}){if(C.isSeparator(w))return P++,` ${w.separator}`;let v=E?i.icon.cursor:" ",_=i.indexMode==="number"?`${y+1-P}. `:"";if(w.disabled){let ee=typeof w.disabled=="string"?w.disabled:"(disabled)",$t=E?i.icon.cursor:"-";return i.style.disabled(`${$t} ${_}${w.name} ${ee}`)}return(E?i.style.highlight:ee=>ee)(`${v} ${_}${w.name}`)},pageSize:n,loop:r});if(s==="done")return[u,D,i.style.answer(h.short)].filter(Boolean).join(" ");let{description:T}=h;return`${[[u,D].filter(Boolean).join(" "),F," ",T?i.style.description(T):"",b?i.style.error(b):"",S].filter(Boolean).join(`
19
- `).trimEnd()}${Bt}`});var Mt=process.cwd();(async()=>{let{projectName:e,referenceProjectVersion:t,targetProjectVersion:r}=await _r();await Qe({workingDir:Mt,projectName:e,referenceProjectVersion:t,targetProjectVersion:r})})();async function _r(){let e=process.argv[2];if(!e)return Nr();let t=process.argv[3];if(!t)throw new Error("Missing reference project version.");let r=process.argv[4];if(!r)throw new Error("Missing target project version.");return{projectName:e,referenceProjectVersion:t,targetProjectVersion:r}}async function Nr(){try{let e=await X({workingDir:Mt}),t=new Map;e.projects.forEach(u=>{let f=t.get(u.name);if(!f){t.set(u.name,[u.version]);return}f.push(u.version)});let r=Array.from(t.keys());r.sort();let n=await Se({message:"Choose project name:",choices:r.map(u=>({name:u,value:u})),pageSize:15}),i=t.get(n);i.sort();let l=await Se({message:"Choose reference project version:",choices:i.map(u=>({name:u,value:u})),pageSize:15}),s=await Ge({message:`Enter the target project version (e.g. ${l}):`,required:!0});return await He({message:`New project ${n}@${s} will be added based on ${l}.
20
- Do you want to proceed?`})||(console.log("Aborted."),process.exit(0)),{projectName:n,referenceProjectVersion:l,targetProjectVersion:s}}catch(e){console.log(`Aborted: ${e}`),process.exit(0)}}
10
+ `)}function be(){return(0,Bt.default)({defaultWidth:80,output:Te().output})}function Br({active:t,renderedItems:e,pageSize:r,loop:n}){let i=K({lastPointer:t,lastActive:void 0}),{lastPointer:s,lastActive:o}=i.current,a=Math.floor(r/2),c=e.reduce((l,p)=>l+p.length,0),u=e.slice(0,t).reduce((l,p)=>l+p.length,0),f=u;if(c>r)if(n)f=s,o!=null&&o<t&&t-o<r&&(f=Math.min(a,Math.abs(t-o)===1?Math.min(s+(e[o]?.length??0),Math.max(u,s)):s+t-o));else{let l=e.slice(t).reduce((p,S)=>p+S.length,0);f=l<r-a?r-l:Math.min(u,a)}return i.current.lastPointer=f,i.current.lastActive=t,f}function Ne({items:t,active:e,renderItem:r,pageSize:n,loop:i=!0}){let s=be(),o=x=>(x%t.length+t.length)%t.length,a=t.map((x,g)=>x==null?[]:le(r({item:x,index:g,isActive:g===e}),s).split(`
11
+ `)),c=a.reduce((x,g)=>x+g.length,0),u=x=>a[x]??[],f=Br({active:e,renderedItems:a,pageSize:n,loop:i}),l=u(e).slice(0,n),p=f+l.length<=n?f:n-l.length,S=Array.from({length:n});S.splice(p,l.length,...l);let h=new Set([e]),d=p+l.length,m=o(e+1);for(;d<n&&!h.has(m)&&(i&&c>n?m!==e:m>e);){let g=u(m).slice(0,n-d);S.splice(d,g.length,...g),h.add(m),d+=g.length,m=o(m+1)}for(d=p-1,m=o(e-1);d>=0&&!h.has(m)&&(i&&c>n?m!==e:m<e);){let x=u(m),g=x.slice(Math.max(0,x.length-d-1));S.splice(d-g.length+1,g.length,...g),h.add(m),d-=g.length,m=o(m-1)}return S.filter(x=>typeof x=="string").join(`
12
+ `)}var $t=k(require("node:readline"),1),Wt=require("node:async_hooks"),Ht=k(_t(),1);var J=[];J.push("SIGHUP","SIGINT","SIGTERM");process.platform!=="win32"&&J.push("SIGALRM","SIGABRT","SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&J.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT");var ye=t=>!!t&&typeof t=="object"&&typeof t.removeListener=="function"&&typeof t.emit=="function"&&typeof t.reallyExit=="function"&&typeof t.listeners=="function"&&typeof t.kill=="function"&&typeof t.pid=="number"&&typeof t.on=="function",Ae=Symbol.for("signal-exit emitter"),Ve=globalThis,_r=Object.defineProperty.bind(Object),ke=class{emitted={afterExit:!1,exit:!1};listeners={afterExit:[],exit:[]};count=0;id=Math.random();constructor(){if(Ve[Ae])return Ve[Ae];_r(Ve,Ae,{value:this,writable:!1,enumerable:!1,configurable:!1})}on(e,r){this.listeners[e].push(r)}removeListener(e,r){let n=this.listeners[e],i=n.indexOf(r);i!==-1&&(i===0&&n.length===1?n.length=0:n.splice(i,1))}emit(e,r,n){if(this.emitted[e])return!1;this.emitted[e]=!0;let i=!1;for(let s of this.listeners[e])i=s(r,n)===!0||i;return e==="exit"&&(i=this.emit("afterExit",r,n)||i),i}},Ee=class{},Nr=t=>({onExit(e,r){return t.onExit(e,r)},load(){return t.load()},unload(){return t.unload()}}),Me=class extends Ee{onExit(){return()=>{}}load(){}unload(){}},$e=class extends Ee{#r=We.platform==="win32"?"SIGINT":"SIGHUP";#t=new ke;#e;#o;#s;#i={};#n=!1;constructor(e){super(),this.#e=e,this.#i={};for(let r of J)this.#i[r]=()=>{let n=this.#e.listeners(r),{count:i}=this.#t,s=e;if(typeof s.__signal_exit_emitter__=="object"&&typeof s.__signal_exit_emitter__.count=="number"&&(i+=s.__signal_exit_emitter__.count),n.length===i){this.unload();let o=this.#t.emit("exit",null,r),a=r==="SIGHUP"?this.#r:r;o||e.kill(e.pid,a)}};this.#s=e.reallyExit,this.#o=e.emit}onExit(e,r){if(!ye(this.#e))return()=>{};this.#n===!1&&this.load();let n=r?.alwaysLast?"afterExit":"exit";return this.#t.on(n,e),()=>{this.#t.removeListener(n,e),this.#t.listeners.exit.length===0&&this.#t.listeners.afterExit.length===0&&this.unload()}}load(){if(!this.#n){this.#n=!0,this.#t.count+=1;for(let e of J)try{let r=this.#i[e];r&&this.#e.on(e,r)}catch{}this.#e.emit=(e,...r)=>this.#l(e,...r),this.#e.reallyExit=e=>this.#a(e)}}unload(){this.#n&&(this.#n=!1,J.forEach(e=>{let r=this.#i[e];if(!r)throw new Error("Listener not defined for signal: "+e);try{this.#e.removeListener(e,r)}catch{}}),this.#e.emit=this.#o,this.#e.reallyExit=this.#s,this.#t.count-=1)}#a(e){return ye(this.#e)?(this.#e.exitCode=e||0,this.#t.emit("exit",this.#e.exitCode,null),this.#s.call(this.#e,this.#e.exitCode)):0}#l(e,...r){let n=this.#o;if(e==="exit"&&ye(this.#e)){typeof r[0]=="number"&&(this.#e.exitCode=r[0]);let i=n.call(this.#e,e,...r);return this.#t.emit("exit",this.#e.exitCode,null),i}else return n.call(this.#e,e,...r)}},We=globalThis.process,{onExit:Nt,load:oi,unload:si}=Nr(ye(We)?new $e(We):new Me);var Mt=require("node:util");var At="\x1B[?25l",Vt="\x1B[?25h",He=(t=1)=>t>0?`\x1B[${t}A`:"",Ke=(t=1)=>t>0?`\x1B[${t}B`:"",Ge=(t,e)=>typeof e=="number"&&!Number.isNaN(e)?`\x1B[${e+1};${t+1}H`:`\x1B[${t+1}G`,Ot="\x1B[2K",Je=t=>t>0?(Ot+He(1)).repeat(t-1)+Ot+"\x1B[G":"";var kt=t=>t.split(`
13
+ `).length,Or=t=>t.split(`
14
+ `).pop()??"",ce=class{height=0;extraLinesUnderPrompt=0;cursorPos;rl;constructor(e){this.rl=e,this.cursorPos=e.getCursorPos()}write(e){this.rl.output.unmute(),this.rl.output.write(e),this.rl.output.mute()}render(e,r=""){let n=Or(e),i=(0,Mt.stripVTControlCharacters)(n),s=i;this.rl.line.length>0&&(s=s.slice(0,-this.rl.line.length)),this.rl.setPrompt(s),this.cursorPos=this.rl.getCursorPos();let o=be();e=le(e,o),r=le(r,o),i.length%o===0&&(e+=`
15
+ `);let a=e+(r?`
16
+ `+r:""),u=Math.floor(i.length/o)-this.cursorPos.rows+(r?kt(r):0);u>0&&(a+=He(u)),a+=Ge(this.cursorPos.cols),this.write(Ke(this.extraLinesUnderPrompt)+Je(this.height)+a),this.extraLinesUnderPrompt=u,this.height=kt(a)}checkCursorPos(){let e=this.rl.getCursorPos();e.cols!==this.cursorPos.cols&&(this.write(Ge(e.cols)),this.cursorPos=e)}done({clearContent:e}){this.rl.setPrompt("");let r=Ke(this.extraLinesUnderPrompt);r+=e?Je(this.height):`
17
+ `,r+=Vt,this.write(r),this.rl.close()}};var ve=class extends Promise{static withResolver(){let e,r;return{promise:new Promise((i,s)=>{e=i,r=s}),resolve:e,reject:r}}};var Kt=k(require("node:path"),1),Ar=globalThis.setImmediate;function Vr(){let t=Error.prepareStackTrace,e=[];try{Error.prepareStackTrace=(r,n)=>{let i=n.slice(1);return e=i,i},new Error().stack}catch{return e}return Error.prepareStackTrace=t,e}function q(t){let e=Vr();return(n,i={})=>{let{input:s=process.stdin,signal:o}=i,a=new Set,c=new Ht.default;c.pipe(i.output??process.stdout);let u=$t.createInterface({terminal:!0,input:s,output:c});c.mute();let f=new ce(u),{promise:l,resolve:p,reject:S}=ve.withResolver(),h=()=>S(new ge);if(o){let m=()=>S(new he({cause:o.reason}));if(o.aborted)return m(),Object.assign(l,{cancel:h});o.addEventListener("abort",m),a.add(()=>o.removeEventListener("abort",m))}a.add(Nt((m,x)=>{S(new se(`User force closed the prompt with ${m} ${x}`))}));let d=()=>S(new se("User force closed the prompt with SIGINT"));return u.on("SIGINT",d),a.add(()=>u.removeListener("SIGINT",d)),lt(u,m=>{let x=Wt.AsyncResource.bind(()=>W.clearAll());u.on("close",x),a.add(()=>u.removeListener("close",x));let g=()=>{let b=()=>f.checkCursorPos();u.input.on("keypress",b),a.add(()=>u.input.removeListener("keypress",b));let y=null;m(()=>{let P=!1;try{let L=t(n,w=>{P?p(w):y={value:w}});if(L===void 0){let w=e[1]?.getFileName();throw w&&!w.startsWith("file://")&&(w=Kt.default.resolve(w)),new Error(`Prompt functions must return a string.
18
+ at ${w}`)}let[F,C]=typeof L=="string"?[L]:L;f.render(F,C),W.run()}catch(L){S(L)}if(P=!0,y!==null){let{value:L}=y;y=null,p(L)}})};return"readableFlowing"in s?Ar(g):g(),Object.assign(l.then(b=>(W.clearAll(),b),b=>{throw W.clearAll(),b}).finally(()=>{a.forEach(b=>b()),f.done({clearContent:!!i.clearPromptOnDone}),c.end()}).then(()=>l),{cancel:h})})}}var Gt=require("node:util");var B=class{separator=(0,Gt.styleText)("dim",Array.from({length:15}).join(Q.line));type="separator";constructor(e){e&&(this.separator=e)}static isSeparator(e){return!!(e&&typeof e=="object"&&"type"in e&&e.type==="separator")}};function Jt(t,e){let r=e!==!1;return/^(y|yes)/i.test(t)?r=!0:/^(n|no)/i.test(t)&&(r=!1),r}function qt(t){return t?"Yes":"No"}var qe=q((t,e)=>{let{transformer:r=qt}=t,[n,i]=D("idle"),[s,o]=D(""),a=N(t.theme),c=H({status:n,theme:a});G((p,S)=>{if(n==="idle")if(M(p)){let h=Jt(s,t.default);o(r(h)),i("done"),e(h)}else if(oe(p)){let h=qt(!Jt(s,t.default));S.clearLine(0),S.write(h),o(h)}else o(S.line)});let u=s,f="";n==="done"?u=a.style.answer(s):f=` ${a.style.defaultAnswer(t.default===!1?"y/N":"Y/n")}`;let l=a.style.message(t.message,n);return`${c} ${l}${f} ${u}`});var kr={validationFailureMode:"keep"},Xe=q((t,e)=>{let{prefill:r="tab"}=t,n=N(kr,t.theme),[i,s]=D("idle"),[o,a]=D(String(t.default??"")),[c,u]=D(),[f,l]=D(""),p=H({status:i,theme:n});async function S(g){let{required:b,pattern:y,patternError:P="Invalid input"}=t;return b&&!g?"You must provide a value":y&&!y.test(g)?P:typeof t.validate=="function"?await t.validate(g)||"You must provide a valid value":!0}G(async(g,b)=>{if(i==="idle")if(M(g)){let y=f||o;s("loading");let P=await S(y);P===!0?(l(y),s("done"),e(y)):(n.validationFailureMode==="clear"?l(""):b.write(f),u(P),s("idle"))}else ie(g)&&!f?a(""):oe(g)&&!f?(a(""),b.clearLine(0),b.write(o),l(o)):(l(b.line),u(void 0))}),_(g=>{r==="editable"&&o&&(g.write(o),l(o))},[]);let h=n.style.message(t.message,i),d=f;typeof t.transformer=="function"?d=t.transformer(f,{isFinal:i==="done"}):i==="done"&&(d=n.style.answer(f));let m;o&&i!=="done"&&!f&&(m=n.style.defaultAnswer(o));let x="";return c&&(x=n.style.error(c)),[[p,h,m,d].filter(g=>g!==void 0).join(" "),x]});var Z=require("node:util");var Mr={icon:{cursor:Q.pointer},style:{disabled:t=>(0,Z.styleText)("dim",t),description:t=>(0,Z.styleText)("cyan",t),keysHelpTip:t=>t.map(([e,r])=>`${(0,Z.styleText)("bold",e)} ${(0,Z.styleText)("dim",r)}`).join((0,Z.styleText)("dim"," \u2022 "))},i18n:{disabledError:"This option is disabled and cannot be selected."},indexMode:"hidden",keybindings:[]};function ze(t){return!B.isSeparator(t)&&!t.disabled}function Ye(t){return!B.isSeparator(t)}function $r(t){return t.map(e=>{if(B.isSeparator(e))return e;if(typeof e!="object"||e===null||!("value"in e)){let i=String(e);return{value:e,name:i,short:i,disabled:!1}}let r=e.name??String(e.value),n={value:e.value,name:r,short:e.short??r,disabled:e.disabled??!1};return e.description&&(n.description=e.description),n})}var De=q((t,e)=>{let{loop:r=!0,pageSize:n=7}=t,i=N(Mr,t.theme),{keybindings:s}=i,[o,a]=D("idle"),c=H({status:o,theme:i}),u=K(),f=!s.includes("vim"),l=ae(()=>$r(t.choices),[t.choices]),p=ae(()=>{let w=l.findIndex(Ye),E=l.findLastIndex(Ye);if(w===-1)throw new z("[select prompt] No selectable choices. All choices are disabled.");return{first:w,last:E}},[l]),S=ae(()=>"default"in t?l.findIndex(w=>ze(w)&&w.value===t.default):-1,[t.default,l]),[h,d]=D(S===-1?p.first:S),m=l[h];if(m==null||B.isSeparator(m))throw new Error("Active index does not point to a choice");let[x,g]=D();G((w,E)=>{if(clearTimeout(u.current),x&&g(void 0),M(w))m.disabled?g(i.i18n.disabledError):(a("done"),e(m.value));else if(ne(w,s)||me(w,s)){if(E.clearLine(0),r||ne(w,s)&&h!==p.first||me(w,s)&&h!==p.last){let v=ne(w,s)?-1:1,R=h;do R=(R+v+l.length)%l.length;while(!Ye(l[R]));d(R)}}else if(Ie(w)&&!Number.isNaN(Number(E.line))){let v=Number(E.line)-1,R=-1,U=l.findIndex(ee=>B.isSeparator(ee)?!1:(R++,R===v)),Pe=l[U];Pe!=null&&ze(Pe)&&d(U),u.current=setTimeout(()=>{E.clearLine(0)},700)}else if(ie(w))E.clearLine(0);else if(f){let v=E.line.toLowerCase(),R=l.findIndex(U=>B.isSeparator(U)||!ze(U)?!1:U.name.toLowerCase().startsWith(v));R!==-1&&d(R),u.current=setTimeout(()=>{E.clearLine(0)},700)}}),_(()=>()=>{clearTimeout(u.current)},[]);let b=i.style.message(t.message,o),y=i.style.keysHelpTip([["\u2191\u2193","navigate"],["\u23CE","select"]]),P=0,L=Ne({items:l,active:h,renderItem({item:w,isActive:E,index:v}){if(B.isSeparator(w))return P++,` ${w.separator}`;let R=E?i.icon.cursor:" ",U=i.indexMode==="number"?`${v+1-P}. `:"";if(w.disabled){let ee=typeof w.disabled=="string"?w.disabled:"(disabled)",Yt=E?i.icon.cursor:"-";return i.style.disabled(`${Yt} ${U}${w.name} ${ee}`)}return(E?i.style.highlight:ee=>ee)(`${R} ${U}${w.name}`)},pageSize:n,loop:r});if(o==="done")return[c,b,i.style.answer(m.short)].filter(Boolean).join(" ");let{description:F}=m;return`${[[c,b].filter(Boolean).join(" "),L," ",F?i.style.description(F):"",x?i.style.error(x):"",y].filter(Boolean).join(`
19
+ `).trimEnd()}${At}`});async function Xt(t){let e=new Map;for(let o of t.projects){let a=e.get(o.name);a?a.push(o.version):e.set(o.name,[o.version])}let r=Array.from(e.keys()).sort(),n=await De({message:"Choose project name:",choices:r.map(o=>({name:o,value:o})),pageSize:15}),i=(e.get(n)??[]).sort(),s=await De({message:"Choose project version:",choices:i.map(o=>({name:o,value:o})),pageSize:15});return{projectName:n,projectVersion:s}}var zt=process.cwd();(async()=>{let{projectName:t,referenceProjectVersion:e,targetProjectVersion:r}=await Wr();await st({workingDir:zt,projectName:t,referenceProjectVersion:e,targetProjectVersion:r})})();async function Wr(){let t=process.argv[2];if(!t)return Hr();let e=process.argv[3];if(!e)throw new Error("Missing reference project version.");let r=process.argv[4];if(!r)throw new Error("Missing target project version.");return{projectName:t,referenceProjectVersion:e,targetProjectVersion:r}}async function Hr(){try{let t=await new V(zt).loadProjectConfig(),{projectName:e,projectVersion:r}=await Xt(t),n=await Xe({message:`Enter the target project version (e.g. ${r}):`,required:!0});return await qe({message:`New project ${e}@${n} will be added based on ${r}.
20
+ Do you want to proceed?`})||(console.log("Aborted."),process.exit(0)),{projectName:e,referenceProjectVersion:r,targetProjectVersion:n}}catch(t){console.error(`Error: ${t}`),process.exitCode=1;return}}