cmdbox 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/dist/cmdbox.js +162 -95
  2. package/package.json +2 -2
package/dist/cmdbox.js CHANGED
@@ -1,100 +1,167 @@
1
1
  #!/usr/bin/env node
2
- import{notStrictEqual as e,strictEqual as t}from"assert";import{basename as n,dirname as r,extname as i,join as a,normalize as o,relative as s,resolve as c}from"path";import{readFileSync as l,readdirSync as u,statSync as d,writeFile as f}from"fs";import{format as p,inspect as m}from"util";import{fileURLToPath as h}from"url";import{createRequire as g}from"node:module";import{readFileSync as ee,readdirSync as _}from"node:fs";import te,{EOL as v}from"node:os";import ne from"node:readline";import{Writable as re}from"node:stream";import ie from"node:events";import{stripVTControlCharacters as y,styleText as b}from"node:util";import x from"node:process";import{access as ae,readFile as S,writeFile as C}from"node:fs/promises";import oe from"node:path";import{execSync as se}from"node:child_process";var ce=Object.create,le=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,de=Object.getOwnPropertyNames,fe=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty,me=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),w=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=de(t),a=0,o=i.length,s;a<o;a++)s=i[a],!pe.call(e,s)&&s!==n&&le(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ue(t,s))||r.enumerable});return e},he=(e,t,n)=>(n=e==null?{}:ce(fe(e)),w(t||!e||!e.__esModule?le(n,`default`,{value:e,enumerable:!0}):n,e));const ge={right:xe,center:Se};var _e=class{constructor(e){this.width=e.width,this.wrap=e.wrap??!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0&&this.div(``),this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==`string`)return this.applyLayoutDSL(e[0]);let t=e.map(e=>typeof e==`string`?this.colFromString(e):e);return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==`string`&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
3
- `).map(e=>e.split(` `)),n=0;return t.forEach(e=>{e.length>1&&T.stringWidth(e[0])>n&&(n=Math.min(Math.floor(this.width*.5),T.stringWidth(e[0])))}),t.forEach(e=>{this.div(...e.map((t,r)=>({text:t.trim(),padding:this.measurePadding(t),width:r===0&&e.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=T.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach(t=>{this.rowToString(t,e)}),e.filter(e=>!e.hidden).map(e=>e.text).join(`
4
- `)}rowToString(e,t){return this.rasterize(e).forEach((n,r)=>{let i=``;n.forEach((n,a)=>{let{width:o}=e[a],s=this.negatePadding(e[a]),c=n;if(s>T.stringWidth(n)&&(c+=` `.repeat(s-T.stringWidth(n))),e[a].align&&e[a].align!==`left`&&this.wrap){let t=ge[e[a].align];c=t(c,s),T.stringWidth(c)<s&&(c+=` `.repeat((o||0)-T.stringWidth(c)-1))}let l=e[a].padding||[0,0,0,0];l[3]&&(i+=` `.repeat(l[3])),i+=ve(e[a],c,`| `),i+=c,i+=ve(e[a],c,` |`),l[1]&&(i+=` `.repeat(l[1])),r===0&&t.length>0&&(i=this.renderInline(i,t[t.length-1]))}),t.push({text:i.replace(/ +$/,``),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),r=n?n[0].length:0,i=t.text,a=T.stringWidth(i.trimRight());return t.span?this.wrap?r<a?e:(t.hidden=!0,i.trimRight()+` `.repeat(r-a)+e.trimLeft()):(t.hidden=!0,i+e):e}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((e,i)=>{e.width=n[i],r=this.wrap?T.wrap(e.text,this.negatePadding(e),{hard:!0}).split(`
5
- `):e.text.split(`
6
- `),e.border&&(r.unshift(`.`+`-`.repeat(this.negatePadding(e)+2)+`.`),r.push(`'`+`-`.repeat(this.negatePadding(e)+2)+`'`)),e.padding&&(r.unshift(...Array(e.padding[0]||0).fill(``)),r.push(...Array(e.padding[2]||0).fill(``))),r.forEach((e,n)=>{t[n]||t.push([]);let r=t[n];for(let e=0;e<i;e++)r[e]===void 0&&r.push(``);r.push(e)})}),t}negatePadding(e){let t=e.width||0;return e.padding&&(t-=(e.padding[3]||0)+(e.padding[1]||0)),e.border&&(t-=4),t}columnWidths(e){if(!this.wrap)return e.map(e=>e.width||T.stringWidth(e.text));let t=e.length,n=this.width,r=e.map(e=>{if(e.width)return t--,n-=e.width,e.width}),i=t?Math.floor(n/t):0;return r.map((t,n)=>t===void 0?Math.max(i,ye(e[n])):t)}};function ve(e,t,n){return e.border?/[.']-+[.']/.test(t)?``:t.trim().length===0?` `:n:``}function ye(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);return e.border?n+4:n}function be(){return typeof process==`object`&&process.stdout&&process.stdout.columns?process.stdout.columns:80}function xe(e,t){e=e.trim();let n=T.stringWidth(e);return n<t?` `.repeat(t-n)+e:e}function Se(e,t){e=e.trim();let n=T.stringWidth(e);return n>=t?e:` `.repeat(t-n>>1)+e}let T;function Ce(e,t){return T=t,new _e({width:e?.width||be(),wrap:e?.wrap})}function we({onlyFirst:e=!1}={}){return RegExp(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`,e?void 0:`g`)}const Te=we();function Ee(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Te,``)}function De(e){return e===161||e===164||e===167||e===168||e===170||e===173||e===174||e>=176&&e<=180||e>=182&&e<=186||e>=188&&e<=191||e===198||e===208||e===215||e===216||e>=222&&e<=225||e===230||e>=232&&e<=234||e===236||e===237||e===240||e===242||e===243||e>=247&&e<=250||e===252||e===254||e===257||e===273||e===275||e===283||e===294||e===295||e===299||e>=305&&e<=307||e===312||e>=319&&e<=322||e===324||e>=328&&e<=331||e===333||e===338||e===339||e===358||e===359||e===363||e===462||e===464||e===466||e===468||e===470||e===472||e===474||e===476||e===593||e===609||e===708||e===711||e>=713&&e<=715||e===717||e===720||e>=728&&e<=731||e===733||e===735||e>=768&&e<=879||e>=913&&e<=929||e>=931&&e<=937||e>=945&&e<=961||e>=963&&e<=969||e===1025||e>=1040&&e<=1103||e===1105||e===8208||e>=8211&&e<=8214||e===8216||e===8217||e===8220||e===8221||e>=8224&&e<=8226||e>=8228&&e<=8231||e===8240||e===8242||e===8243||e===8245||e===8251||e===8254||e===8308||e===8319||e>=8321&&e<=8324||e===8364||e===8451||e===8453||e===8457||e===8467||e===8470||e===8481||e===8482||e===8486||e===8491||e===8531||e===8532||e>=8539&&e<=8542||e>=8544&&e<=8555||e>=8560&&e<=8569||e===8585||e>=8592&&e<=8601||e===8632||e===8633||e===8658||e===8660||e===8679||e===8704||e===8706||e===8707||e===8711||e===8712||e===8715||e===8719||e===8721||e===8725||e===8730||e>=8733&&e<=8736||e===8739||e===8741||e>=8743&&e<=8748||e===8750||e>=8756&&e<=8759||e===8764||e===8765||e===8776||e===8780||e===8786||e===8800||e===8801||e>=8804&&e<=8807||e===8810||e===8811||e===8814||e===8815||e===8834||e===8835||e===8838||e===8839||e===8853||e===8857||e===8869||e===8895||e===8978||e>=9312&&e<=9449||e>=9451&&e<=9547||e>=9552&&e<=9587||e>=9600&&e<=9615||e>=9618&&e<=9621||e===9632||e===9633||e>=9635&&e<=9641||e===9650||e===9651||e===9654||e===9655||e===9660||e===9661||e===9664||e===9665||e>=9670&&e<=9672||e===9675||e>=9678&&e<=9681||e>=9698&&e<=9701||e===9711||e===9733||e===9734||e===9737||e===9742||e===9743||e===9756||e===9758||e===9792||e===9794||e===9824||e===9825||e>=9827&&e<=9829||e>=9831&&e<=9834||e===9836||e===9837||e===9839||e===9886||e===9887||e===9919||e>=9926&&e<=9933||e>=9935&&e<=9939||e>=9941&&e<=9953||e===9955||e===9960||e===9961||e>=9963&&e<=9969||e===9972||e>=9974&&e<=9977||e===9979||e===9980||e===9982||e===9983||e===10045||e>=10102&&e<=10111||e>=11094&&e<=11097||e>=12872&&e<=12879||e>=57344&&e<=63743||e>=65024&&e<=65039||e===65533||e>=127232&&e<=127242||e>=127248&&e<=127277||e>=127280&&e<=127337||e>=127344&&e<=127373||e===127375||e===127376||e>=127387&&e<=127404||e>=917760&&e<=917999||e>=983040&&e<=1048573||e>=1048576&&e<=1114109}function Oe(e){return e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510}function ke(e){return e>=4352&&e<=4447||e===8986||e===8987||e===9001||e===9002||e>=9193&&e<=9196||e===9200||e===9203||e===9725||e===9726||e===9748||e===9749||e>=9776&&e<=9783||e>=9800&&e<=9811||e===9855||e>=9866&&e<=9871||e===9875||e===9889||e===9898||e===9899||e===9917||e===9918||e===9924||e===9925||e===9934||e===9940||e===9962||e===9970||e===9971||e===9973||e===9978||e===9981||e===9989||e===9994||e===9995||e===10024||e===10060||e===10062||e>=10067&&e<=10069||e===10071||e>=10133&&e<=10135||e===10160||e===10175||e===11035||e===11036||e===11088||e===11093||e>=11904&&e<=11929||e>=11931&&e<=12019||e>=12032&&e<=12245||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12353&&e<=12438||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12773||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=42124||e>=42128&&e<=42182||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=94176&&e<=94180||e>=94192&&e<=94198||e>=94208&&e<=101589||e>=101631&&e<=101662||e>=101760&&e<=101874||e>=110576&&e<=110579||e>=110581&&e<=110587||e===110589||e===110590||e>=110592&&e<=110882||e===110898||e>=110928&&e<=110930||e===110933||e>=110948&&e<=110951||e>=110960&&e<=111355||e>=119552&&e<=119638||e>=119648&&e<=119670||e===126980||e===127183||e===127374||e>=127377&&e<=127386||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e===127568||e===127569||e>=127584&&e<=127589||e>=127744&&e<=127776||e>=127789&&e<=127797||e>=127799&&e<=127868||e>=127870&&e<=127891||e>=127904&&e<=127946||e>=127951&&e<=127955||e>=127968&&e<=127984||e===127988||e>=127992&&e<=128062||e===128064||e>=128066&&e<=128252||e>=128255&&e<=128317||e>=128331&&e<=128334||e>=128336&&e<=128359||e===128378||e===128405||e===128406||e===128420||e>=128507&&e<=128591||e>=128640&&e<=128709||e===128716||e>=128720&&e<=128722||e>=128725&&e<=128728||e>=128732&&e<=128735||e===128747||e===128748||e>=128756&&e<=128764||e>=128992&&e<=129003||e===129008||e>=129292&&e<=129338||e>=129340&&e<=129349||e>=129351&&e<=129535||e>=129648&&e<=129660||e>=129664&&e<=129674||e>=129678&&e<=129734||e===129736||e>=129741&&e<=129756||e>=129759&&e<=129770||e>=129775&&e<=129784||e>=131072&&e<=196605||e>=196608&&e<=262141}function Ae(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function je(e,{ambiguousAsWide:t=!1}={}){return Ae(e),Oe(e)||ke(e)||t&&De(e)?2:1}var Me=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;const Ne=new Intl.Segmenter,Pe=/^\p{Default_Ignorable_Code_Point}$/u;function Fe(e,t={}){if(typeof e!=`string`||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(r||(e=Ee(e)),e.length===0)return 0;let i=0,a={ambiguousAsWide:!n};for(let{segment:t}of Ne.segment(e)){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159)&&!(e>=8203&&e<=8207||e===65279)&&!(e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071)&&!(e>=55296&&e<=57343)&&!(e>=65024&&e<=65039)&&!Pe.test(t)){if(Me().test(t)){i+=2;continue}i+=je(e,a)}}return i}const Ie=(e=0)=>t=>`\u001B[${t+e}m`,Le=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,Re=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,E={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(E.modifier);const ze=Object.keys(E.color),Be=Object.keys(E.bgColor);[...ze,...Be];function Ve(){let e=new Map;for(let[t,n]of Object.entries(E)){for(let[t,r]of Object.entries(n))E[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=E[t],e.set(r[0],r[1]);Object.defineProperty(E,t,{value:n,enumerable:!1})}return Object.defineProperty(E,`codes`,{value:e,enumerable:!1}),E.color.close=`\x1B[39m`,E.bgColor.close=`\x1B[49m`,E.color.ansi=Ie(),E.color.ansi256=Le(),E.color.ansi16m=Re(),E.bgColor.ansi=Ie(10),E.bgColor.ansi256=Le(10),E.bgColor.ansi16m=Re(10),Object.defineProperties(E,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>E.rgbToAnsi256(...E.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>E.ansi256ToAnsi(E.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>E.ansi256ToAnsi(E.hexToAnsi256(e)),enumerable:!1}}),E}var He=Ve();const Ue=new Set([`\x1B`,`›`]),We=`]8;;`,Ge=e=>`${Ue.values().next().value}[${e}m`,Ke=e=>`${Ue.values().next().value}${We}${e}`,qe=e=>e.split(` `).map(e=>Fe(e)),Je=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=Fe(Ee(e.at(-1)));for(let[t,s]of r.entries()){let c=Fe(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Ue.has(s)&&(i=!0,a=r.slice(t+1,t+1+4).join(``)===We),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e.at(-1).length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Ye=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(Fe(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Xe=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=qe(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s.at(-1).trimStart());let e=Fe(s.at(-1));if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),Je(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){Je(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){Je(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Ye(e)));let c=s.join(`
7
- `),l=[...c],u=0;for(let[e,t]of l.entries()){if(r+=t,Ue.has(t)){let{groups:e}=RegExp(`(?:\\[(?<code>\\d+)m|\\${We}(?<uri>.*))`).exec(c.slice(u))||{groups:{}};if(e.code!==void 0){let t=Number.parseFloat(e.code);i=t===39?void 0:t}else e.uri!==void 0&&(a=e.uri.length===0?void 0:e.uri)}let n=He.codes.get(Number(i));l[e+1]===`
8
- `?(a&&(r+=Ke(``)),i&&n&&(r+=Ge(n))):t===`
9
- `&&(i&&n&&(r+=Ge(i)),a&&(r+=Ke(a))),u+=t.length}return r};function Ze(e,t,n){return String(e).normalize().replaceAll(`\r
10
- `,`
11
- `).split(`
12
- `).map(e=>Xe(e,t,n)).join(`
13
- `)}function Qe(e){return Ce(e,{stringWidth:Fe,stripAnsi:Ee,wrap:Ze})}function $e(e,t){let n=c(`.`,e),i;for(d(n).isDirectory()||(n=r(n));;){if(i=t(n,u(n)),i)return c(n,i);if(n=r(i=n),i===n)break}}
14
- /**
15
- * @license
16
- * Copyright (c) 2016, Contributors
17
- * SPDX-License-Identifier: ISC
18
- */
19
- function et(e){if(e!==e.toLowerCase()&&e!==e.toUpperCase()||(e=e.toLowerCase()),e.indexOf(`-`)===-1&&e.indexOf(`_`)===-1)return e;{let t=``,n=!1,r=e.match(/^-+/);for(let i=r?r[0].length:0;i<e.length;i++){let r=e.charAt(i);n&&(n=!1,r=r.toUpperCase()),i!==0&&(r===`-`||r===`_`)?n=!0:r!==`-`&&r!==`_`&&(t+=r)}return t}}function tt(e,t){let n=e.toLowerCase();t||=`-`;let r=``;for(let i=0;i<e.length;i++){let a=n.charAt(i),o=e.charAt(i);a!==o&&i>0?r+=`${t}${n.charAt(i)}`:r+=o}return r}function nt(e){return e==null?!1:typeof e==`number`||/^0x[0-9a-f]+$/i.test(e)?!0:/^0[^.]/.test(e)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}
20
- /**
21
- * @license
22
- * Copyright (c) 2016, Contributors
23
- * SPDX-License-Identifier: ISC
24
- */
25
- function rt(e){if(Array.isArray(e))return e.map(e=>typeof e==`string`?e:e+``);e=e.trim();let t=0,n=null,r=null,i=null,a=[];for(let o=0;o<e.length;o++){if(n=r,r=e.charAt(o),r===` `&&!i){n!==` `&&t++;continue}r===i?i=null:(r===`'`||r===`"`)&&!i&&(i=r),a[t]||(a[t]=``),a[t]+=r}return a}
26
- /**
27
- * @license
28
- * Copyright (c) 2016, Contributors
29
- * SPDX-License-Identifier: ISC
30
- */
31
- var D;(function(e){e.BOOLEAN=`boolean`,e.STRING=`string`,e.NUMBER=`number`,e.ARRAY=`array`})(D||={});
32
- /**
33
- * @license
34
- * Copyright (c) 2016, Contributors
35
- * SPDX-License-Identifier: ISC
36
- */
37
- let O;var it=class{constructor(e){O=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),r=rt(e),i=typeof e==`string`,a=at(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":`no-`,"parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),s=Object.assign(Object.create(null),n.default),c=n.configObjects||[],l=n.envPrefix,u=o[`populate--`],d=u?`--`:`_`,f=Object.create(null),p=Object.create(null),m=n.__||O.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},g=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,ee=RegExp(`^--`+o[`negation-prefix`]+`(.+)`);[].concat(n.array||[]).filter(Boolean).forEach(function(e){let t=typeof e==`object`?e.key:e,n=Object.keys(e).map(function(e){return{boolean:`bools`,string:`strings`,number:`numbers`}[e]}).filter(Boolean).pop();n&&(h[n][t]=!0),h.arrays[t]=!0,h.keys.push(t)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(e){h.bools[e]=!0,h.keys.push(e)}),[].concat(n.string||[]).filter(Boolean).forEach(function(e){h.strings[e]=!0,h.keys.push(e)}),[].concat(n.number||[]).filter(Boolean).forEach(function(e){h.numbers[e]=!0,h.keys.push(e)}),[].concat(n.count||[]).filter(Boolean).forEach(function(e){h.counts[e]=!0,h.keys.push(e)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(e){h.normalize[e]=!0,h.keys.push(e)}),typeof n.narg==`object`&&Object.entries(n.narg).forEach(([e,t])=>{typeof t==`number`&&(h.nargs[e]=t,h.keys.push(e))}),typeof n.coerce==`object`&&Object.entries(n.coerce).forEach(([e,t])=>{typeof t==`function`&&(h.coercions[e]=t,h.keys.push(e))}),n.config!==void 0&&(Array.isArray(n.config)||typeof n.config==`string`?[].concat(n.config).filter(Boolean).forEach(function(e){h.configs[e]=!0}):typeof n.config==`object`&&Object.entries(n.config).forEach(([e,t])=>{(typeof t==`boolean`||typeof t==`function`)&&(h.configs[e]=t)})),me(n.key,a,n.default,h.arrays),Object.keys(s).forEach(function(e){(h.aliases[e]||[]).forEach(function(t){s[t]=s[e]})});let _=null;Ce();let te=[],v=Object.assign(Object.create(null),{_:[]}),ne={};for(let e=0;e<r.length;e++){let t=r[e],n=t.replace(/^-{3,}/,`---`),i,a,s,c,l,u;if(t!==`--`&&/^-/.test(t)&&ve(t))re(t);else if(n.match(/^---+(=|$)/)){re(t);continue}else if(t.match(/^--.+=/)||!o[`short-option-groups`]&&t.match(/^-.+=/))c=t.match(/^--?([^=]+)=([\s\S]*)$/),c!==null&&Array.isArray(c)&&c.length>=3&&(w(c[1],h.arrays)?e=y(e,c[1],r,c[2]):w(c[1],h.nargs)===!1?b(c[1],c[2],!0):e=ie(e,c[1],r,c[2]));else if(t.match(ee)&&o[`boolean-negation`])c=t.match(ee),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],b(a,w(a,h.arrays)?[!1]:!1));else if(t.match(/^--.+/)||!o[`short-option-groups`]&&t.match(/^-[^-]+/))c=t.match(/^--?(.+)/),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],w(a,h.arrays)?e=y(e,a,r):w(a,h.nargs)===!1?(l=r[e+1],l!==void 0&&(!l.match(/^-/)||l.match(g))&&!w(a,h.bools)&&!w(a,h.counts)||/^(true|false)$/.test(l)?(b(a,l),e++):b(a,be(a))):e=ie(e,a,r));else if(t.match(/^-.\..+=/))c=t.match(/^-([^=]+)=([\s\S]*)$/),c!==null&&Array.isArray(c)&&c.length>=3&&b(c[1],c[2]);else if(t.match(/^-.\..+/)&&!t.match(g))l=r[e+1],c=t.match(/^-(.\..+)/),c!==null&&Array.isArray(c)&&c.length>=2&&(a=c[1],l!==void 0&&!l.match(/^-/)&&!w(a,h.bools)&&!w(a,h.counts)?(b(a,l),e++):b(a,be(a)));else if(t.match(/^-[^-]+/)&&!t.match(g)){s=t.slice(1,-1).split(``),i=!1;for(let n=0;n<s.length;n++){if(l=t.slice(n+2),s[n+1]&&s[n+1]===`=`){u=t.slice(n+3),a=s[n],w(a,h.arrays)?e=y(e,a,r,u):w(a,h.nargs)===!1?b(a,u):e=ie(e,a,r,u),i=!0;break}if(l===`-`){b(s[n],l);continue}if(/[A-Za-z]/.test(s[n])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(l)&&w(l,h.bools)===!1){b(s[n],l),i=!0;break}if(s[n+1]&&s[n+1].match(/\W/)){b(s[n],l),i=!0;break}else b(s[n],be(s[n]))}a=t.slice(-1)[0],!i&&a!==`-`&&(w(a,h.arrays)?e=y(e,a,r):w(a,h.nargs)===!1?(l=r[e+1],l!==void 0&&(!/^(-|--)[^-]/.test(l)||l.match(g))&&!w(a,h.bools)&&!w(a,h.counts)||/^(true|false)$/.test(l)?(b(a,l),e++):b(a,be(a))):e=ie(e,a,r))}else if(t.match(/^-[0-9]$/)&&t.match(g)&&w(t.slice(1),h.bools))a=t.slice(1),b(a,be(a));else if(t===`--`){te=r.slice(e+1);break}else if(o[`halt-at-non-option`]){te=r.slice(e);break}else re(t)}ce(v,!0),ce(v,!1),C(v),se(),de(v,h.aliases,s,!0),le(v),o[`set-placeholder-key`]&&ue(v),Object.keys(h.counts).forEach(function(e){fe(v,e.split(`.`))||b(e,0)}),u&&te.length&&(v[d]=[]),te.forEach(function(e){v[d].push(e)}),o[`camel-case-expansion`]&&o[`strip-dashed`]&&Object.keys(v).filter(e=>e!==`--`&&e.includes(`-`)).forEach(e=>{delete v[e]}),o[`strip-aliased`]&&[].concat(...Object.keys(a).map(e=>a[e])).forEach(e=>{o[`camel-case-expansion`]&&e.includes(`-`)&&delete v[e.split(`.`).map(e=>et(e)).join(`.`)],delete v[e]});function re(e){let t=S(`_`,e);(typeof t==`string`||typeof t==`number`)&&v._.push(t)}function ie(e,t,n,r){let i,a=w(t,h.nargs);if(a=typeof a!=`number`||isNaN(a)?1:a,a===0)return T(r)||(_=Error(m(`Argument unexpected for: %s`,t))),b(t,be(t)),e;let s=T(r)?0:1;if(o[`nargs-eats-options`])n.length-(e+1)+s<a&&(_=Error(m(`Not enough arguments following: %s`,t))),s=a;else{for(i=e+1;i<n.length&&(!n[i].match(/^-[^0-9]/)||n[i].match(g)||ve(n[i]));i++)s++;s<a&&(_=Error(m(`Not enough arguments following: %s`,t)))}let c=Math.min(s,a);for(!T(r)&&c>0&&(b(t,r),c--),i=e+1;i<c+e+1;i++)b(t,n[i]);return e+c}function y(e,t,n,r){let a=[],c=r||n[e+1],l=w(t,h.nargs);if(w(t,h.bools)&&!/^(true|false)$/.test(c))a.push(!0);else if(T(c)||T(r)&&/^-/.test(c)&&!g.test(c)&&!ve(c)){if(s[t]!==void 0){let e=s[t];a=Array.isArray(e)?e:[e]}}else{T(r)||a.push(ae(t,r,!0));for(let r=e+1;r<n.length&&!(!o[`greedy-arrays`]&&a.length>0||l&&typeof l==`number`&&a.length>=l||(c=n[r],/^-/.test(c)&&!g.test(c)&&!ve(c)));r++)e=r,a.push(ae(t,c,i))}return typeof l==`number`&&(l&&a.length<l||isNaN(l)&&a.length===0)&&(_=Error(m(`Not enough arguments following: %s`,t))),b(t,a),e}function b(e,t,n=i){/-/.test(e)&&o[`camel-case-expansion`]&&x(e,e.split(`.`).map(function(e){return et(e)}).join(`.`));let r=ae(e,t,n),a=e.split(`.`);pe(v,a,r),h.aliases[e]&&h.aliases[e].forEach(function(e){pe(v,e.split(`.`),r)}),a.length>1&&o[`dot-notation`]&&(h.aliases[a[0]]||[]).forEach(function(t){let n=t.split(`.`),i=[].concat(a);i.shift(),n=n.concat(i),(h.aliases[e]||[]).includes(n.join(`.`))||pe(v,n,r)}),w(e,h.normalize)&&!w(e,h.arrays)&&[e].concat(h.aliases[e]||[]).forEach(function(e){Object.defineProperty(ne,e,{enumerable:!0,get(){return t},set(e){t=typeof e==`string`?O.normalize(e):e}})})}function x(e,t){h.aliases[e]&&h.aliases[e].length||(h.aliases[e]=[t],f[t]=!0),h.aliases[t]&&h.aliases[t].length||x(t,e)}function ae(e,t,n){n&&(t=ct(t)),(w(e,h.bools)||w(e,h.counts))&&typeof t==`string`&&(t=t===`true`);let r=Array.isArray(t)?t.map(function(t){return S(e,t)}):S(e,t);return w(e,h.counts)&&(T(r)||typeof r==`boolean`)&&(r=ot()),w(e,h.normalize)&&w(e,h.arrays)&&(r=Array.isArray(t)?t.map(e=>O.normalize(e)):O.normalize(t)),r}function S(e,t){return!o[`parse-positional-numbers`]&&e===`_`||!w(e,h.strings)&&!w(e,h.bools)&&!Array.isArray(t)&&(nt(t)&&o[`parse-numbers`]&&Number.isSafeInteger(Math.floor(parseFloat(`${t}`)))||!T(t)&&w(e,h.numbers))&&(t=Number(t)),t}function C(e){let t=Object.create(null);de(t,h.aliases,s),Object.keys(h.configs).forEach(function(n){let r=e[n]||t[n];if(r)try{let e=null,t=O.resolve(O.cwd(),r),i=h.configs[n];if(typeof i==`function`){try{e=i(t)}catch(t){e=t}if(e instanceof Error){_=e;return}}else e=O.require(t);oe(e)}catch(t){t.name===`PermissionDenied`?_=t:e[n]&&(_=Error(m(`Invalid JSON config file: %s`,r)))}})}function oe(e,t){Object.keys(e).forEach(function(n){let r=e[n],i=t?t+`.`+n:n;typeof r==`object`&&r&&!Array.isArray(r)&&o[`dot-notation`]?oe(r,i):(!fe(v,i.split(`.`))||w(i,h.arrays)&&o[`combine-arrays`])&&b(i,r)})}function se(){c!==void 0&&c.forEach(function(e){oe(e)})}function ce(e,t){if(l===void 0)return;let n=typeof l==`string`?l:``,r=O.env();Object.keys(r).forEach(function(i){if(n===``||i.lastIndexOf(n,0)===0){let a=i.split(`__`).map(function(e,t){return t===0&&(e=e.substring(n.length)),et(e)});(t&&h.configs[a.join(`.`)]||!t)&&!fe(e,a)&&b(a.join(`.`),r[i])}})}function le(e){let t,n=new Set;Object.keys(e).forEach(function(r){if(!n.has(r)&&(t=w(r,h.coercions),typeof t==`function`))try{let i=S(r,t(e[r]));[].concat(h.aliases[r]||[],r).forEach(t=>{n.add(t),e[t]=i})}catch(e){_=e}})}function ue(e){return h.keys.forEach(t=>{~t.indexOf(`.`)||e[t]===void 0&&(e[t]=void 0)}),e}function de(e,t,n,r=!1){Object.keys(n).forEach(function(i){fe(e,i.split(`.`))||(pe(e,i.split(`.`),n[i]),r&&(p[i]=!0),(t[i]||[]).forEach(function(t){fe(e,t.split(`.`))||pe(e,t.split(`.`),n[i])}))})}function fe(e,t){let n=e;o[`dot-notation`]||(t=[t.join(`.`)]),t.slice(0,-1).forEach(function(e){n=n[e]||{}});let r=t[t.length-1];return typeof n==`object`?r in n:!1}function pe(e,t,n){let r=e;o[`dot-notation`]||(t=[t.join(`.`)]),t.slice(0,-1).forEach(function(e){e=st(e),typeof r==`object`&&r[e]===void 0&&(r[e]={}),typeof r[e]!=`object`||Array.isArray(r[e])?(Array.isArray(r[e])?r[e].push({}):r[e]=[r[e],{}],r=r[e][r[e].length-1]):r=r[e]});let i=st(t[t.length-1]),a=w(t.join(`.`),h.arrays),s=Array.isArray(n),c=o[`duplicate-arguments-array`];!c&&w(i,h.nargs)&&(c=!0,(!T(r[i])&&h.nargs[i]===1||Array.isArray(r[i])&&r[i].length===h.nargs[i])&&(r[i]=void 0)),n===ot()?r[i]=ot(r[i]):Array.isArray(r[i])?c&&a&&s?r[i]=o[`flatten-duplicate-arrays`]?r[i].concat(n):(Array.isArray(r[i][0])?r[i]:[r[i]]).concat([n]):!c&&!!a==!!s?r[i]=n:r[i]=r[i].concat([n]):r[i]===void 0&&a?r[i]=s?n:[n]:c&&!(r[i]===void 0||w(i,h.counts)||w(i,h.bools))?r[i]=[r[i],n]:r[i]=n}function me(...e){e.forEach(function(e){Object.keys(e||{}).forEach(function(e){h.aliases[e]||(h.aliases[e]=[].concat(a[e]||[]),h.aliases[e].concat(e).forEach(function(t){if(/-/.test(t)&&o[`camel-case-expansion`]){let n=et(t);n!==e&&h.aliases[e].indexOf(n)===-1&&(h.aliases[e].push(n),f[n]=!0)}}),h.aliases[e].concat(e).forEach(function(t){if(t.length>1&&/[A-Z]/.test(t)&&o[`camel-case-expansion`]){let n=tt(t,`-`);n!==e&&h.aliases[e].indexOf(n)===-1&&(h.aliases[e].push(n),f[n]=!0)}}),h.aliases[e].forEach(function(t){h.aliases[t]=[e].concat(h.aliases[e].filter(function(e){return t!==e}))}))})})}function w(e,t){let n=[].concat(h.aliases[e]||[],e),r=Object.keys(t),i=n.find(e=>r.includes(e));return i?t[i]:!1}function he(e){let t=Object.keys(h);return[].concat(t.map(e=>h[e])).some(function(t){return Array.isArray(t)?t.includes(e):t[e]})}function ge(e,...t){return[].concat(...t).some(function(t){let n=e.match(t);return n&&he(n[1])})}function _e(e){if(e.match(g)||!e.match(/^-[^-]+/))return!1;let t=!0,n,r=e.slice(1).split(``);for(let i=0;i<r.length;i++){if(n=e.slice(i+2),!he(r[i])){t=!1;break}if(r[i+1]&&r[i+1]===`=`||n===`-`||/[A-Za-z]/.test(r[i])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(n)||r[i+1]&&r[i+1].match(/\W/))break}return t}function ve(e){return o[`unknown-options-as-args`]&&ye(e)}function ye(e){return e=e.replace(/^-{3,}/,`--`),e.match(g)||_e(e)?!1:!ge(e,/^-+([^=]+?)=[\s\S]*$/,ee,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function be(e){return!w(e,h.bools)&&!w(e,h.counts)&&`${e}`in s?s[e]:xe(Se(e))}function xe(e){return{[D.BOOLEAN]:!0,[D.STRING]:``,[D.NUMBER]:void 0,[D.ARRAY]:[]}[e]}function Se(e){let t=D.BOOLEAN;return w(e,h.strings)?t=D.STRING:w(e,h.numbers)?t=D.NUMBER:w(e,h.bools)?t=D.BOOLEAN:w(e,h.arrays)&&(t=D.ARRAY),t}function T(e){return e===void 0}function Ce(){Object.keys(h.counts).find(e=>w(e,h.arrays)?(_=Error(m(`Invalid configuration: %s, opts.count excludes opts.array.`,e)),!0):w(e,h.nargs)?(_=Error(m(`Invalid configuration: %s, opts.count excludes opts.narg.`,e)),!0):!1)}return{aliases:Object.assign({},h.aliases),argv:Object.assign(ne,v),configuration:o,defaulted:Object.assign({},p),error:_,newAliases:Object.assign({},f)}}};function at(e){let t=[],n=Object.create(null),r=!0;for(Object.keys(e).forEach(function(n){t.push([].concat(e[n],n))});r;){r=!1;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++)if(t[e].filter(function(e){return t[n].indexOf(e)!==-1}).length){t[e]=t[e].concat(t[n]),t.splice(n,1),r=!0;break}}return t.forEach(function(e){e=e.filter(function(e,t,n){return n.indexOf(e)===t});let t=e.pop();t!==void 0&&typeof t==`string`&&(n[t]=e)}),n}function ot(e){return e===void 0?1:e+1}function st(e){return e===`__proto__`?`___proto___`:e}function ct(e){return typeof e==`string`&&(e[0]===`'`||e[0]===`"`)&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}const lt=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,ut=(process==null?void 0:process.versions)?.node??(process==null?void 0:process.version)?.slice(1);if(ut&&Number(ut.match(/^([^.]+)/)[1])<lt)throw Error(`yargs parser supports a minimum Node.js version of ${lt}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const dt=process?process.env:{},ft=g?g(import.meta.url):void 0,pt=new it({cwd:process.cwd,env:()=>dt,format:p,normalize:o,resolve:c,require:e=>{if(ft!==void 0)return ft(e);if(e.match(/\.json$/))return JSON.parse(l(e,`utf8`));throw Error(`only .json config files are supported in ESM`)}}),mt=function(e,t){return pt.parse(e.slice(),t).argv};mt.detailed=function(e,t){return pt.parse(e.slice(),t)},mt.camelCase=et,mt.decamelize=tt,mt.looksLikeNumber=nt;var ht=mt;function gt(){return _t()?0:1}function _t(){return vt()&&!process.defaultApp}function vt(){return!!process.versions.electron}function yt(e){return e.slice(gt()+1)}function bt(){return process.argv[gt()]}var xt={fs:{readFileSync:l,writeFile:f},format:p,resolve:c,exists:e=>{try{return d(e).isFile()}catch{return!1}}};let k;var St=class{constructor(e){e||={},this.directory=e.directory||`./locales`,this.updateFiles=typeof e.updateFiles==`boolean`?e.updateFiles:!0,this.locale=e.locale||`en`,this.fallbackToLanguage=typeof e.fallbackToLanguage==`boolean`?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=`string`)return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};return typeof e[e.length-1]==`function`&&(n=e.pop()),n||=function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n})):n(),k.format.apply(k.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),r=e.shift(),i=function(){};typeof e[e.length-1]==`function`&&(i=e.pop()),this.cache[this.locale]||this._readLocaleFile();let a=r===1?t:n;this.cache[this.locale][t]&&(a=this.cache[this.locale][t][r===1?`one`:`other`]),!this.cache[this.locale][t]&&this.updateFiles?(this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i})):i();let o=[a];return~a.indexOf(`%d`)&&o.push(r),k.format.apply(k.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){for(let t in this.cache[this.locale]||this._readLocaleFile(),e)Object.prototype.hasOwnProperty.call(e,t)&&(this.cache[this.locale][t]=e[t])}_taggedLiteral(e,...t){let n=``;return e.forEach(function(e,r){let i=t[r+1];n+=e,i!==void 0&&(n+=`%s`)}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){this.writeQueue.push(e),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],n=t.directory,r=t.locale,i=t.cb,a=this._resolveLocaleFile(n,r),o=JSON.stringify(this.cache[r],null,2);k.fs.writeFile(a,o,`utf-8`,function(t){e.writeQueue.shift(),e.writeQueue.length>0&&e._processWriteQueue(),i(t)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{k.fs.readFileSync&&(e=JSON.parse(k.fs.readFileSync(t,`utf-8`)))}catch(n){if(n instanceof SyntaxError&&(n.message=`syntax error in `+t),n.code===`ENOENT`)e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=k.resolve(e,`./`,t+`.json`);if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf(`_`)){let r=k.resolve(e,`./`,t.split(`_`)[0]+`.json`);this._fileExistsSync(r)&&(n=r)}return n}_fileExistsSync(e){return k.exists(e)}};function Ct(e,t){k=t;let n=new St(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var wt=e=>Ct(e,xt),Tt=he(me(((e,t)=>{t.exports=function(e){if(e===void 0&&(e=2),e>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+e+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var t=Error.prepareStackTrace;Error.prepareStackTrace=function(e,t){return t};var n=Error().stack;if(Error.prepareStackTrace=t,typeof n==`object`&&n)return n[e]?n[e].getFileName():void 0}}))(),1);const Et=h(import.meta.url),Dt=Et.substring(0,Et.lastIndexOf(`node_modules`)),Ot=g(import.meta.url);var kt={assert:{notStrictEqual:e,strictEqual:t},cliui:Qe,findUp:$e,getEnv:e=>process.env[e],inspect:m,getProcessArgvBin:bt,mainFilename:Dt||process.cwd(),Parser:ht,path:{basename:n,dirname:r,extname:i,relative:s,resolve:c,join:a},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:e=>{process.exit(e)},nextTick:process.nextTick,stdColumns:process.stdout.columns===void 0?null:process.stdout.columns},readFileSync:ee,readdirSync:_,require:Ot,getCallerFile:()=>{let e=(0,Tt.default)(3);return e.match(/^file:\/\//)?h(e):e},stringWidth:Fe,y18n:wt({directory:c(Et,`../../../locales`),updateFiles:!1})};function A(e,t,n,r){n.assert.notStrictEqual(e,t,r)}function At(e,t){t.assert.strictEqual(typeof e,`string`)}function jt(e){return Object.keys(e)}function j(e){return!!e&&!!e.then&&typeof e.then==`function`}var M=class e extends Error{constructor(t){super(t||`yargs error`),this.name=`YError`,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};function Mt(e){let t=e.replace(/\s{2,}/g,` `).split(/\s+(?![^[]*]|[^<]*>)/),n=/\.*[\][<>]/g,r=t.shift();if(!r)throw Error(`No command found in: ${e}`);let i={cmd:r.replace(n,``),demanded:[],optional:[]};return t.forEach((e,r)=>{let a=!1;e=e.replace(/\s/g,``),/\.+[\]>]/.test(e)&&r===t.length-1&&(a=!0),/^\[/.test(e)?i.optional.push({cmd:e.replace(n,``).split(`|`),variadic:a}):i.demanded.push({cmd:e.replace(n,``).split(`|`),variadic:a})}),i}const Nt=[`first`,`second`,`third`,`fourth`,`fifth`,`sixth`];function N(e,t,n){function r(){return typeof e==`object`?[{demanded:[],optional:[]},e,t]:[Mt(`cmd ${e}`),t,n]}try{let e=0,[t,n,i]=r(),a=[].slice.call(n);for(;a.length&&a[a.length-1]===void 0;)a.pop();let o=i||a.length;if(o<t.demanded.length)throw new M(`Not enough arguments provided. Expected ${t.demanded.length} but received ${a.length}.`);let s=t.demanded.length+t.optional.length;if(o>s)throw new M(`Too many arguments provided. Expected max ${s} but received ${o}.`);t.demanded.forEach(t=>{let n=Pt(a.shift());t.cmd.filter(e=>e===n||e===`*`).length===0&&Ft(n,t.cmd,e),e+=1}),t.optional.forEach(t=>{if(a.length===0)return;let n=Pt(a.shift());t.cmd.filter(e=>e===n||e===`*`).length===0&&Ft(n,t.cmd,e),e+=1})}catch(e){console.warn(e.stack)}}function Pt(e){return Array.isArray(e)?`array`:e===null?`null`:typeof e}function Ft(e,t,n){throw new M(`Invalid ${Nt[n]||`manyith`} argument. Expected ${t.join(` or `)} but received ${e}.`)}var It=class{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(N(`<array|function> [boolean] [boolean] [boolean]`,[e,t,n],arguments.length),Array.isArray(e)){for(let r=0;r<e.length;r++){if(typeof e[r]!=`function`)throw Error(`middleware must be a function`);let i=e[r];i.applyBeforeValidation=t,i.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==`function`){let i=e;i.applyBeforeValidation=t,i.global=n,i.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter(e=>{let r=[...n[t]||[],t];return e.option?!r.includes(e.option):!0}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();e!==void 0&&(this.globalMiddleware=e)}reset(){this.globalMiddleware=this.globalMiddleware.filter(e=>e.global)}};function Lt(e){return e?e.map(e=>(e.applyBeforeValidation=!1,e)):[]}function Rt(e,t,n,r){return n.reduce((e,n)=>{if(n.applyBeforeValidation!==r)return e;if(n.mutates){if(n.applied)return e;n.applied=!0}if(j(e))return e.then(e=>Promise.all([e,n(e,t)])).then(([e,t])=>Object.assign(e,t));{let r=n(e,t);return j(r)?r.then(t=>Object.assign(e,t)):Object.assign(e,r)}},e)}function zt(e,t,n=e=>{throw e}){try{let n=Bt(e)?e():e;return j(n)?n.then(e=>t(e)):t(n)}catch(e){return n(e)}}function Bt(e){return typeof e==`function`}const Vt=/(^\*)|(^\$0)/;var Ht=class{constructor(e,t,n,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,r){r||={},this.requireCache.add(n);let i=this.shim.path.resolve(this.shim.path.dirname(n),e),a=this.shim.readdirSync(i,{recursive:!!r.recurse});Array.isArray(r.extensions)||(r.extensions=[`js`]);let o=typeof r.visit==`function`?r.visit:e=>e;for(let e of a){let n=e.toString();if(r.exclude){let e=!1;if(e=typeof r.exclude==`function`?r.exclude(n):r.exclude.test(n),e)continue}if(r.include){let e=!1;if(e=typeof r.include==`function`?r.include(n):r.include.test(n),!e)continue}let a=!1;for(let e of r.extensions)n.endsWith(e)&&(a=!0);if(a){let e=this.shim.path.join(i,n),r=t(e),a=Object.create(null,Object.getOwnPropertyDescriptors({...r}));if(o(a,e,n)){if(this.requireCache.has(e))continue;this.requireCache.add(e),a.command||=this.shim.path.basename(e,this.shim.path.extname(e)),this.addHandler(a)}}}}addHandler(e,t,n,r,i,a){let o=[],s=Lt(i);if(r||=(()=>{}),Array.isArray(e))if(Gt(e))[e,...o]=e;else for(let t of e)this.addHandler(t);else if(Jt(e)){let t=Array.isArray(e.command)||typeof e.command==`string`?e.command:null;if(t===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);e.aliases&&(t=[].concat(t,e.aliases)),this.addHandler(t,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(Wt(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==`string`){let i=Mt(e);o=o.map(e=>Mt(e).cmd);let c=!1,l=[i.cmd].concat(o).filter(e=>Vt.test(e)?(c=!0,!1):!0);l.length===0&&c&&l.push(`$0`),c&&(i.cmd=l[0],o=l.slice(1),e=e.replace(Vt,i.cmd)),o.forEach(e=>{this.aliasMap[e]=i.cmd}),t!==!1&&this.usage.command(e,t,c,o,a),this.handlers[i.cmd]={original:e,description:t,handler:r,builder:n||{},middlewares:s,deprecated:a,demanded:i.demanded,optional:i.optional},c&&(this.defaultCommand=this.handlers[i.cmd])}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,r,i,a){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,s=t.getInternalMethods().getContext(),c=s.commands.slice(),l=!e;e&&(s.commands.push(e),s.fullCommands.push(o.original));let u=this.applyBuilderUpdateUsageAndParse(l,o,t,n.aliases,c,r,i,a);return j(u)?u.then(e=>this.applyMiddlewareAndGetResult(l,o,e.innerArgv,s,i,e.aliases,t)):this.applyMiddlewareAndGetResult(l,o,u.innerArgv,s,i,u.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,r,i,a,o,s){let c=t.builder,l=n;if(Kt(c)){n.getInternalMethods().getUsageInstance().freeze();let u=c(n.getInternalMethods().reset(r),s);if(j(u))return u.then(r=>(l=br(r)?r:n,this.parseAndUpdateUsage(e,t,l,i,a,o)))}else qt(c)&&(n.getInternalMethods().getUsageInstance().freeze(),l=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach(e=>{l.option(e,c[e])}));return this.parseAndUpdateUsage(e,t,l,i,a,o)}parseAndUpdateUsage(e,t,n,r,i,a){e&&n.getInternalMethods().getUsageInstance().unfreeze(!0),this.shouldUpdateUsage(n)&&n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,a);return j(o)?o.then(e=>({aliases:n.parsed.aliases,innerArgv:e})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=Vt.test(t.original)?t.original.replace(Vt,``).trim():t.original,r=e.filter(e=>!Vt.test(e));return r.push(n),`$0 ${r.join(` `)}`}handleValidationAndGetResult(e,t,n,r,i,a,o,s){if(!a.getInternalMethods().getHasOutput()){let t=a.getInternalMethods().runValidation(i,s,a.parsed.error,e);n=zt(n,e=>(t(e),e))}if(t.handler&&!a.getInternalMethods().getHasOutput()){a.getInternalMethods().setHasOutput();let r=!!a.getOptions().configuration[`populate--`];a.getInternalMethods().postProcess(n,r,!1,!1),n=Rt(n,a,o,!1),n=zt(n,e=>{let n=t.handler(e);return j(n)?n.then(()=>e):e}),e||a.getInternalMethods().getUsageInstance().cacheHelpMessage(),j(n)&&!a.getInternalMethods().hasParseCallback()&&n.catch(e=>{try{a.getInternalMethods().getUsageInstance().fail(null,e)}catch{}})}return e||(r.commands.pop(),r.fullCommands.pop()),n}applyMiddlewareAndGetResult(e,t,n,r,i,a,o){let s={};if(i)return n;o.getInternalMethods().getHasOutput()||(s=this.populatePositionals(t,n,r,o));let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),l=Rt(n,o,c,!0);return j(l)?l.then(n=>this.handleValidationAndGetResult(e,t,n,r,a,o,c,s)):this.handleValidationAndGetResult(e,t,l,r,a,o,c,s)}populatePositionals(e,t,n,r){t._=t._.slice(n.commands.length);let i=e.demanded.slice(0),a=e.optional.slice(0),o={};for(this.validation.positionalCount(i.length,t._.length);i.length;){let e=i.shift();this.populatePositional(e,t,o)}for(;a.length;){let e=a.shift();this.populatePositional(e,t,o)}return t._=n.commands.concat(t._.map(e=>``+e)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),r),o}populatePositional(e,t,n){let r=e.cmd[0];e.variadic?n[r]=t._.splice(0).map(String):t._.length&&(n[r]=[String(t._.shift())])}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Mt(e);return n.demanded.forEach(e=>{let[n,...r]=e.cmd;e.variadic&&(t.array.push(n),t.default[n]=[]),t.alias[n]=r,t.demand[n]=!0}),n.optional.forEach(e=>{let[n,...r]=e.cmd;e.variadic&&(t.array.push(n),t.default[n]=[]),t.alias[n]=r}),t}postProcessPositionals(e,t,n,r){let i=Object.assign({},r.getOptions());i.default=Object.assign(n.default,i.default);for(let e of Object.keys(n.alias))i.alias[e]=(i.alias[e]||[]).concat(n.alias[e]);i.array=i.array.concat(n.array),i.config={};let a=[];if(Object.keys(t).forEach(e=>{t[e].map(t=>{i.configuration[`unknown-options-as-args`]&&(i.key[e]=!0),a.push(`--${e}`),a.push(t)})}),!a.length)return;let o=Object.assign({},i.configuration,{"populate--":!1}),s=this.shim.Parser.detailed(a,Object.assign({},i,{configuration:o}));if(s.error)r.getInternalMethods().getUsageInstance().fail(s.error.message,s.error);else{let n=Object.keys(t);Object.keys(t).forEach(e=>{n.push(...s.aliases[e])}),Object.keys(s.argv).forEach(i=>{n.includes(i)&&(t[i]||(t[i]=s.argv[i]),!this.isInConfigs(r,i)&&!this.isDefaulted(r,i)&&Object.prototype.hasOwnProperty.call(e,i)&&Object.prototype.hasOwnProperty.call(s.argv,i)&&(Array.isArray(e[i])||Array.isArray(s.argv[i]))?e[i]=[].concat(e[i],s.argv[i]):e[i]=s.argv[i])})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some(e=>Object.prototype.hasOwnProperty.call(e,t))||n.some(e=>Object.prototype.hasOwnProperty.call(e,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let t=Vt.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,`$0 `);e.getInternalMethods().getUsageInstance().usage(t,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Kt(t))return t(e,!0);Wt(t)||Object.keys(t).forEach(n=>{e.option(n,t[n])})}extractDesc({describe:e,description:t,desc:n}){for(let r of[e,t,n]){if(typeof r==`string`||r===!1)return r;A(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();A(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}};function Ut(e,t,n,r){return new Ht(e,t,n,r)}function Wt(e){return typeof e==`object`&&!!e.builder&&typeof e.handler==`function`}function Gt(e){return e.every(e=>typeof e==`string`)}function Kt(e){return typeof e==`function`}function qt(e){return typeof e==`object`}function Jt(e){return typeof e==`object`&&!Array.isArray(e)}function Yt(e={},t=()=>!0){let n={};return jt(e).forEach(r=>{t(r,e[r])&&(n[r]=e[r])}),n}function Xt(e){typeof process>`u`||[process.stdout,process.stderr].forEach(t=>{let n=t;n._handle&&n.isTTY&&typeof n._handle.setBlocking==`function`&&n._handle.setBlocking(e)})}function Zt(e){return typeof e==`boolean`}function Qt(e,t){let n=t.y18n.__,r={},i=[];r.failFn=function(e){i.push(e)};let a=null,o=null,s=!0;r.showHelpOnFail=function(t=!0,n){let[i,c]=typeof t==`string`?[!0,t]:[t,n];return e.getInternalMethods().isGlobalContext()&&(o=c),a=c,s=i,r};let c=!1;r.fail=function(t,n){let l=e.getInternalMethods().getLoggerInstance();if(i.length)for(let e=i.length-1;e>=0;--e){let a=i[e];if(Zt(a)){if(n)throw n;if(t)throw Error(t)}else a(t,n,r)}else{if(e.getExitProcess()&&Xt(!0),!c){c=!0,s&&(e.showHelp(`error`),l.error()),(t||n)&&l.error(t||n);let r=a||o;r&&((t||n)&&l.error(``),l.error(r))}if(n||=new M(t),e.getExitProcess())return e.exit(1);if(e.getInternalMethods().hasParseCallback())return e.exit(1,n);throw n}};let l=[],u=!1;r.usage=(e,t)=>e===null?(u=!0,l=[],r):(u=!1,l.push([e,t||``]),r),r.getUsage=()=>l,r.getUsageDisabled=()=>u,r.getPositionalGroupName=()=>n(`Positionals:`);let d=[];r.example=(e,t)=>{d.push([e,t||``])};let f=[];r.command=function(e,t,n,r,i=!1){n&&(f=f.map(e=>(e[2]=!1,e))),f.push([e,t||``,n,r,i])},r.getCommands=()=>f;let p={};r.describe=function(e,t){Array.isArray(e)?e.forEach(e=>{r.describe(e,t)}):typeof e==`object`?Object.keys(e).forEach(t=>{r.describe(t,e[t])}):p[e]=t},r.getDescriptions=()=>p;let m=[];r.epilog=e=>{m.push(e)};let h=!1,g;r.wrap=e=>{h=!0,g=e},r.getWrap=()=>t.getEnv(`YARGS_DISABLE_WRAP`)?null:(h||=(g=y(),!0),g);let ee=`__yargsString__:`;r.deferY18nLookup=e=>ee+e,r.help=function(){if(v)return v;te();let i=e.customScriptName?e.$0:t.path.basename(e.$0),a=e.getDemandedOptions(),o=e.getDemandedCommands(),s=e.getDeprecatedOptions(),c=e.getGroups(),h=e.getOptions(),g=[];g=g.concat(Object.keys(p)),g=g.concat(Object.keys(a)),g=g.concat(Object.keys(o)),g=g.concat(Object.keys(h.default)),g=g.filter(re),g=Object.keys(g.reduce((e,t)=>(t!==`_`&&(e[t]=!0),e),{}));let y=r.getWrap(),b=t.cliui({width:y,wrap:!!y});if(!u){if(l.length)l.forEach(e=>{b.div({text:`${e[0].replace(/\$0/g,i)}`}),e[1]&&b.div({text:`${e[1]}`,padding:[1,0,0,0]})}),b.div();else if(f.length){let e=null;e=o._?`${i} <${n(`command`)}>\n`:`${i} [${n(`command`)}]\n`,b.div(`${e}`)}}if(f.length>1||f.length===1&&!f[0][2]){b.div(n(`Commands:`));let t=e.getInternalMethods().getContext(),r=t.commands.length?`${t.commands.join(` `)} `:``;e.getInternalMethods().getParserConfiguration()[`sort-commands`]===!0&&(f=f.sort((e,t)=>e[0].localeCompare(t[0])));let a=i?`${i} `:``;f.forEach(e=>{let t=`${a}${r}${e[0].replace(/^\$0 ?/,``)}`;b.span({text:t,padding:[0,2,0,2],width:_(f,y,`${i}${r}`)+4},{text:e[1]});let o=[];e[2]&&o.push(`[${n(`default`)}]`),e[3]&&e[3].length&&o.push(`[${n(`aliases:`)} ${e[3].join(`, `)}]`),e[4]&&(typeof e[4]==`string`?o.push(`[${n(`deprecated: %s`,e[4])}]`):o.push(`[${n(`deprecated`)}]`)),o.length?b.div({text:o.join(` `),padding:[0,0,0,2],align:`right`}):b.div()}),b.div()}let x=(Object.keys(h.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);g=g.filter(t=>!e.parsed.newAliases[t]&&x.every(e=>(h.alias[e]||[]).indexOf(t)===-1));let ae=n(`Options:`);c[ae]||(c[ae]=[]),ne(g,h.alias,c,ae);let S=e=>/^--/.test(nn(e)),C=Object.keys(c).filter(e=>c[e].length>0).map(e=>({groupName:e,normalizedKeys:c[e].filter(re).map(e=>{if(x.includes(e))return e;for(let t=0,n;(n=x[t])!==void 0;t++)if((h.alias[n]||[]).includes(e))return n;return e})})).filter(({normalizedKeys:e})=>e.length>0).map(({groupName:e,normalizedKeys:t})=>({groupName:e,normalizedKeys:t,switches:t.reduce((t,n)=>(t[n]=[n].concat(h.alias[n]||[]).map(t=>e===r.getPositionalGroupName()?t:(/^[0-9]$/.test(t)?h.boolean.includes(n)?`-`:`--`:t.length>1?`--`:`-`)+t).sort((e,t)=>S(e)===S(t)?0:S(e)?1:-1).join(`, `),t),{})}));if(C.filter(({groupName:e})=>e!==r.getPositionalGroupName()).some(({normalizedKeys:e,switches:t})=>!e.every(e=>S(t[e])))&&C.filter(({groupName:e})=>e!==r.getPositionalGroupName()).forEach(({normalizedKeys:e,switches:t})=>{e.forEach(e=>{S(t[e])&&(t[e]=en(t[e],4))})}),C.forEach(({groupName:t,normalizedKeys:i,switches:o})=>{b.div(t),i.forEach(t=>{let i=o[t],c=p[t]||``,l=null;c.includes(ee)&&(c=n(c.substring(16))),h.boolean.includes(t)&&(l=`[${n(`boolean`)}]`),h.count.includes(t)&&(l=`[${n(`count`)}]`),h.string.includes(t)&&(l=`[${n(`string`)}]`),h.normalize.includes(t)&&(l=`[${n(`string`)}]`),h.array.includes(t)&&(l=`[${n(`array`)}]`),h.number.includes(t)&&(l=`[${n(`number`)}]`);let u=[t in s?(e=>typeof e==`string`?`[${n(`deprecated: %s`,e)}]`:`[${n(`deprecated`)}]`)(s[t]):null,l,t in a?`[${n(`required`)}]`:null,h.choices&&h.choices[t]?`[${n(`choices:`)} ${r.stringifiedValues(h.choices[t])}]`:null,ie(h.default[t],h.defaultDescription[t])].filter(Boolean).join(` `);b.span({text:nn(i),padding:[0,2,0,2+tn(i)],width:_(o,y)+4},c);let d=e.getInternalMethods().getUsageConfiguration()[`hide-types`]===!0;u&&!d?b.div({text:u,padding:[0,0,0,2],align:`right`}):b.div()}),b.div()}),d.length&&(b.div(n(`Examples:`)),d.forEach(e=>{e[0]=e[0].replace(/\$0/g,i)}),d.forEach(e=>{e[1]===``?b.div({text:e[0],padding:[0,2,0,2]}):b.div({text:e[0],padding:[0,2,0,2],width:_(d,y)+4},{text:e[1]})}),b.div()),m.length>0){let e=m.map(e=>e.replace(/\$0/g,i)).join(`
38
- `);b.div(`${e}\n`)}return b.toString().replace(/\s*$/,``)};function _(e,n,r){let i=0;return Array.isArray(e)||(e=Object.values(e).map(e=>[e])),e.forEach(e=>{i=Math.max(t.stringWidth(r?`${r} ${nn(e[0])}`:nn(e[0]))+tn(e[0]),i)}),n&&(i=Math.min(i,parseInt((n*.5).toString(),10))),i}function te(){let t=e.getDemandedOptions(),n=e.getOptions();(Object.keys(n.alias)||[]).forEach(i=>{n.alias[i].forEach(a=>{p[a]&&r.describe(i,p[a]),a in t&&e.demandOption(i,t[a]),n.boolean.includes(a)&&e.boolean(i),n.count.includes(a)&&e.count(i),n.string.includes(a)&&e.string(i),n.normalize.includes(a)&&e.normalize(i),n.array.includes(a)&&e.array(i),n.number.includes(a)&&e.number(i)})})}let v;r.cacheHelpMessage=function(){v=this.help()},r.clearCachedHelpMessage=function(){v=void 0},r.hasCachedHelpMessage=function(){return!!v};function ne(e,t,n,r){let i=[],a=null;return Object.keys(n).forEach(e=>{i=i.concat(n[e])}),e.forEach(e=>{a=[e].concat(t[e]),a.some(e=>i.indexOf(e)!==-1)||n[r].push(e)}),i}function re(t){return e.getOptions().hiddenOptions.indexOf(t)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}r.showHelp=t=>{let n=e.getInternalMethods().getLoggerInstance();t||=`error`,(typeof t==`function`?t:n[t])(r.help())},r.functionDescription=e=>[`(`,e.name?t.Parser.decamelize(e.name,`-`):n(`generated-value`),`)`].join(``),r.stringifiedValues=function(e,t){let n=``,r=t||`, `,i=[].concat(e);return!e||!i.length||i.forEach(e=>{n.length&&(n+=r),n+=JSON.stringify(e)}),n};function ie(e,t){let r=`[${n(`default:`)} `;if(e===void 0&&!t)return null;if(t)r+=t;else switch(typeof e){case`string`:r+=`"${e}"`;break;case`object`:r+=JSON.stringify(e);break;default:r+=e}return`${r}]`}function y(){return t.process.stdColumns?Math.min(80,t.process.stdColumns):80}let b=null;r.version=e=>{b=e},r.showVersion=t=>{let n=e.getInternalMethods().getLoggerInstance();t||=`error`,(typeof t==`function`?t:n[t])(b)},r.reset=function(e){return a=null,c=!1,l=[],u=!1,m=[],d=[],f=[],p=Yt(p,t=>!e[t]),r};let x=[];return r.freeze=function(){x.push({failMessage:a,failureOutput:c,usages:l,usageDisabled:u,epilogs:m,examples:d,commands:f,descriptions:p})},r.unfreeze=function(e=!1){let t=x.pop();t&&(e?(p={...t.descriptions,...p},f=[...t.commands,...f],l=[...t.usages,...l],d=[...t.examples,...d],m=[...t.epilogs,...m]):{failMessage:a,failureOutput:c,usages:l,usageDisabled:u,epilogs:m,examples:d,commands:f,descriptions:p}=t)},r}function $t(e){return typeof e==`object`}function en(e,t){return $t(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function tn(e){return $t(e)?e.indentation:0}function nn(e){return $t(e)?e.text:e}var rn=class{constructor(e,t,n,r){this.yargs=e,this.usage=t,this.command=n,this.shim=r,this.completionKey=`get-yargs-completions`,this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(this.shim.getEnv(`SHELL`)?.includes(`zsh`)||this.shim.getEnv(`ZSH_NAME`)?.includes(`zsh`))??!1}defaultCompletion(e,t,n,r){let i=this.command.getCommandHandlers();for(let t=0,n=e.length;t<n;++t)if(i[e[t]]&&i[e[t]].builder){let n=i[e[t]].builder;if(Kt(n)){this.indexAfterLastReset=t+1;let e=this.yargs.getInternalMethods().reset();return n(e,!0),e.argv}}let a=[];this.commandCompletions(a,e,n),this.optionCompletions(a,e,t,n),this.choicesFromOptionsCompletions(a,e,t,n),this.choicesFromPositionalsCompletions(a,e,t,n),r(null,a)}commandCompletions(e,t,n){let r=this.yargs.getInternalMethods().getContext().commands;!n.match(/^-/)&&r[r.length-1]!==n&&!this.previousArgHasChoices(t)&&this.usage.getCommands().forEach(n=>{let r=Mt(n[0]).cmd;if(t.indexOf(r)===-1)if(!this.zshShell)e.push(r);else{let t=n[1]||``;e.push(r.replace(/:/g,`\\:`)+`:`+t)}})}optionCompletions(e,t,n,r){if((r.match(/^-/)||r===``&&e.length===0)&&!this.previousArgHasChoices(t)){let n=this.yargs.getOptions(),i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(n.key).forEach(a=>{let o=!!n.configuration[`boolean-negation`]&&n.boolean.includes(a);!i.includes(a)&&!n.hiddenOptions.includes(a)&&!this.argsContainKey(t,a,o)&&this.completeOptionKey(a,e,r,o&&!!n.default[a])})}}choicesFromOptionsCompletions(e,t,n,r){if(this.previousArgHasChoices(t)){let n=this.getPreviousArgChoices(t);n&&n.length>0&&e.push(...n.map(e=>e.replace(/:/g,`\\:`)))}}choicesFromPositionalsCompletions(e,t,n,r){if(r===``&&e.length>0&&this.previousArgHasChoices(t))return;let i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],a=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[n._.length-a-1];if(!o)return;let s=this.yargs.getOptions().choices[o]||[];for(let t of s)t.startsWith(r)&&e.push(t.replace(/:/g,`\\:`))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n=``;if(!t.startsWith(`-`)&&e.length>1&&(n=t,t=e[e.length-2]),!t.startsWith(`-`))return;let r=t.replace(/^-+/,``),i=this.yargs.getOptions(),a=[r,...this.yargs.getAliases()[r]||[]],o;for(let e of a)if(Object.prototype.hasOwnProperty.call(i.key,e)&&Array.isArray(i.choices[e])){o=i.choices[e];break}if(o)return o.filter(e=>!n||e.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let r=t=>e.indexOf((/^[^0-9]$/.test(t)?`-`:`--`)+t)!==-1;if(r(t)||n&&r(`no-${t}`))return!0;if(this.aliases){for(let e of this.aliases[t])if(r(e))return!0}return!1}completeOptionKey(e,t,n,r){let i=e;if(this.zshShell){let t=this.usage.getDescriptions(),n=((this===null||this===void 0?void 0:this.aliases)?.[e])?.find(e=>{let n=t[e];return typeof n==`string`&&n.length>0}),r=n?t[n]:void 0,a=t[e]??r??``;i=`${e.replace(/:/g,`\\:`)}:${a.replace(`__yargsString__:`,``).replace(/(\r\n|\n|\r)/gm,` `)}`}let a=!(e=>/^--/.test(e))(n)&&(e=>/^[^0-9]$/.test(e))(e)?`-`:`--`;t.push(a+i),r&&t.push(a+`no-`+i)}customCompletion(e,t,n,r){if(A(this.customCompletionFunction,null,this.shim),on(this.customCompletionFunction)){let e=this.customCompletionFunction(n,t);return j(e)?e.then(e=>{this.shim.process.nextTick(()=>{r(null,e)})}).catch(e=>{this.shim.process.nextTick(()=>{r(e,void 0)})}):r(null,e)}else if(sn(this.customCompletionFunction))return this.customCompletionFunction(n,t,(i=r)=>this.defaultCompletion(e,t,n,i),e=>{r(null,e)});else return this.customCompletionFunction(n,t,e=>{r(null,e)})}getCompletion(e,t){let n=e.length?e[e.length-1]:``,r=this.yargs.parse(e,!0),i=this.customCompletionFunction?r=>this.customCompletion(e,r,n,t):r=>this.defaultCompletion(e,r,n,t);return j(r)?r.then(i):i(r)}generateCompletionScript(e,t){let n=this.zshShell?`#compdef {{app_name}}
39
- ###-begin-{{app_name}}-completions-###
40
- #
41
- # yargs command completion script
42
- #
43
- # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
44
- # or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
45
- #
46
- _{{app_name}}_yargs_completions()
47
- {
48
- local reply
49
- local si=$IFS
50
- IFS=$'
51
- ' reply=($(COMP_CWORD="$((CURRENT-1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" {{app_path}} --get-yargs-completions "\${words[@]}"))
52
- IFS=$si
53
- if [[ \${#reply} -gt 0 ]]; then
54
- _describe 'values' reply
55
- else
56
- _default
57
- fi
58
- }
59
- if [[ "'\${zsh_eval_context[-1]}" == "loadautofunc" ]]; then
60
- _{{app_name}}_yargs_completions "$@"
61
- else
62
- compdef _{{app_name}}_yargs_completions {{app_name}}
63
- fi
64
- ###-end-{{app_name}}-completions-###
65
- `:`###-begin-{{app_name}}-completions-###
66
- #
67
- # yargs command completion script
68
- #
69
- # Installation: {{app_path}} {{completion_command}} >> ~/.bashrc
70
- # or {{app_path}} {{completion_command}} >> ~/.bash_profile on OSX.
71
- #
72
- _{{app_name}}_yargs_completions()
73
- {
74
- local cur_word args type_list
2
+ import yargs from "yargs";
3
+ import { hideBin } from "yargs/helpers";
4
+ import { confirm, question, required, select } from "@topcli/prompts";
5
+ import { access, readFile, writeFile } from "node:fs/promises";
6
+ import os from "node:os";
7
+ import path from "node:path";
8
+ import { execSync } from "node:child_process";
75
9
 
76
- cur_word="\${COMP_WORDS[COMP_CWORD]}"
77
- args=("\${COMP_WORDS[@]}")
10
+ //#region src/consts.ts
11
+ const STORE_FILE_PATH = path.join(os.homedir(), ".cmdbox");
12
+ const SCRIPT_NAME = "cmdbox";
78
13
 
79
- # ask yargs to generate completions.
80
- # see https://stackoverflow.com/a/40944195/7080036 for the spaces-handling awk
81
- mapfile -t type_list < <({{app_path}} --get-yargs-completions "\${args[@]}")
82
- mapfile -t COMPREPLY < <(compgen -W "$( printf '%q ' "\${type_list[@]}" )" -- "\${cur_word}" |
83
- awk '/ / { print "\\""$0"\\"" } /^[^ ]+$/ { print $0 }')
14
+ //#endregion
15
+ //#region src/uitls.ts
16
+ const fileExists = async (filePath) => {
17
+ try {
18
+ await access(filePath);
19
+ return true;
20
+ } catch {
21
+ return false;
22
+ }
23
+ };
24
+ const formatCommand = (cmd) => `Name\t\t${cmd.name}
25
+ Description\t${cmd.description ? cmd.description : "empty"}
26
+ Command\t\t${cmd.command}`;
84
27
 
85
- # if no match was found, fall back to filename completion
86
- if [ \${#COMPREPLY[@]} -eq 0 ]; then
87
- COMPREPLY=()
88
- fi
28
+ //#endregion
29
+ //#region src/store.ts
30
+ const createStoreFile = async () => {
31
+ try {
32
+ await writeFile(STORE_FILE_PATH, JSON.stringify([]), "utf8");
33
+ } catch (err) {
34
+ console.error(err);
35
+ }
36
+ };
37
+ const readStoreFile = async () => {
38
+ try {
39
+ return await readFile(STORE_FILE_PATH, "utf8");
40
+ } catch (err) {
41
+ throw err;
42
+ }
43
+ };
44
+ const store = {
45
+ init: async function() {
46
+ if (await fileExists(STORE_FILE_PATH)) return;
47
+ await createStoreFile();
48
+ },
49
+ getCommands: async function() {
50
+ const storeContent = await readStoreFile();
51
+ return JSON.parse(storeContent);
52
+ },
53
+ findCommand: async function(name) {
54
+ const result = (await this.getCommands()).find((v) => v.name === name);
55
+ if (!result) {
56
+ console.error(`Command "${name}" does not exist`);
57
+ process.exit(1);
58
+ }
59
+ return result;
60
+ },
61
+ addCommand: async function(cmd) {
62
+ try {
63
+ const result = [cmd, ...await this.getCommands()];
64
+ await writeFile(STORE_FILE_PATH, JSON.stringify(result, null, 2), "utf8");
65
+ } catch (err) {
66
+ console.error(err);
67
+ }
68
+ },
69
+ removeCommand: async function(name) {
70
+ try {
71
+ const result = (await this.getCommands()).filter((v) => v.name !== name);
72
+ await writeFile(STORE_FILE_PATH, JSON.stringify(result, null, 2));
73
+ } catch (err) {
74
+ console.error(err);
75
+ }
76
+ }
77
+ };
89
78
 
90
- return 0
91
- }
92
- complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
93
- ###-end-{{app_name}}-completions-###
94
- `,r=this.shim.path.basename(e);return e.match(/\.js$/)&&(e=`./${e}`),n=n.replace(/{{app_name}}/g,r),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}};function an(e,t,n,r){return new rn(e,t,n,r)}function on(e){return e.length<3}function sn(e){return e.length>3}function cn(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],r;for(r=0;r<=t.length;r++)n[r]=[r];let i;for(i=0;i<=e.length;i++)n[0][i]=i;for(r=1;r<=t.length;r++)for(i=1;i<=e.length;i++)t.charAt(r-1)===e.charAt(i-1)?n[r][i]=n[r-1][i-1]:r>1&&i>1&&t.charAt(r-2)===e.charAt(i-1)&&t.charAt(r-1)===e.charAt(i-2)?n[r][i]=n[r-2][i-2]+1:n[r][i]=Math.min(n[r-1][i-1]+1,Math.min(n[r][i-1]+1,n[r-1][i]+1));return n[t.length][e.length]}const ln=[`$0`,`--`,`_`];function un(e,t,n){let r=n.y18n.__,i=n.y18n.__n,a={};a.nonOptionCount=function(n){let r=e.getDemandedCommands(),a=n._.length+(n[`--`]?n[`--`].length:0)-e.getInternalMethods().getContext().commands.length;r._&&(a<r._.min||a>r._.max)&&(a<r._.min?r._.minMsg===void 0?t.fail(i(`Not enough non-option arguments: got %s, need at least %s`,`Not enough non-option arguments: got %s, need at least %s`,a,a.toString(),r._.min.toString())):t.fail(r._.minMsg?r._.minMsg.replace(/\$0/g,a.toString()).replace(/\$1/,r._.min.toString()):null):a>r._.max&&(r._.maxMsg===void 0?t.fail(i(`Too many non-option arguments: got %s, maximum of %s`,`Too many non-option arguments: got %s, maximum of %s`,a,a.toString(),r._.max.toString())):t.fail(r._.maxMsg?r._.maxMsg.replace(/\$0/g,a.toString()).replace(/\$1/,r._.max.toString()):null)))},a.positionalCount=function(e,n){n<e&&t.fail(i(`Not enough non-option arguments: got %s, need at least %s`,`Not enough non-option arguments: got %s, need at least %s`,n,n+``,e+``))},a.requiredArguments=function(e,n){let r=null;for(let t of Object.keys(n))(!Object.prototype.hasOwnProperty.call(e,t)||e[t]===void 0)&&(r||={},r[t]=n[t]);if(r){let e=[];for(let t of Object.keys(r)){let n=r[t];n&&e.indexOf(n)<0&&e.push(n)}let n=e.length?`\n${e.join(`
95
- `)}`:``;t.fail(i(`Missing required argument: %s`,`Missing required arguments: %s`,Object.keys(r).length,Object.keys(r).join(`, `)+n))}},a.unknownArguments=function(n,r,o,s,c=!0){let l=e.getInternalMethods().getCommandInstance().getCommands(),u=[],d=e.getInternalMethods().getContext();if(Object.keys(n).forEach(t=>{!ln.includes(t)&&!Object.prototype.hasOwnProperty.call(o,t)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),t)&&!a.isValidAndSomeAliasIsNotNew(t,r)&&u.push(t)}),c&&(d.commands.length>0||l.length>0||s)&&n._.slice(d.commands.length).forEach(e=>{l.includes(``+e)||u.push(``+e)}),c){let t=e.getDemandedCommands()._?.max||0,r=d.commands.length+t;r<n._.length&&n._.slice(r).forEach(e=>{e=String(e),!d.commands.includes(e)&&!u.includes(e)&&u.push(e)})}u.length&&t.fail(i(`Unknown argument: %s`,`Unknown arguments: %s`,u.length,u.map(e=>e.trim()?e:`"${e}"`).join(`, `)))},a.unknownCommands=function(n){let r=e.getInternalMethods().getCommandInstance().getCommands(),a=[],o=e.getInternalMethods().getContext();return(o.commands.length>0||r.length>0)&&n._.slice(o.commands.length).forEach(e=>{r.includes(``+e)||a.push(``+e)}),a.length>0?(t.fail(i(`Unknown command: %s`,`Unknown commands: %s`,a.length,a.join(`, `))),!0):!1},a.isValidAndSomeAliasIsNotNew=function(t,n){if(!Object.prototype.hasOwnProperty.call(n,t))return!1;let r=e.parsed.newAliases;return[t,...n[t]].some(e=>!Object.prototype.hasOwnProperty.call(r,e)||!r[t])},a.limitedChoices=function(n){let i=e.getOptions(),a={};if(!Object.keys(i.choices).length)return;Object.keys(n).forEach(e=>{ln.indexOf(e)===-1&&Object.prototype.hasOwnProperty.call(i.choices,e)&&[].concat(n[e]).forEach(t=>{i.choices[e].indexOf(t)===-1&&t!==void 0&&(a[e]=(a[e]||[]).concat(t))})});let o=Object.keys(a);if(!o.length)return;let s=r(`Invalid values:`);o.forEach(e=>{s+=`\n ${r(`Argument: %s, Given: %s, Choices: %s`,e,t.stringifiedValues(a[e]),t.stringifiedValues(i.choices[e]))}`}),t.fail(s)};let o={};a.implies=function(t,r){N(`<string|object> [array|number|string]`,[t,r],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.implies(e,t[e])}):(e.global(t),o[t]||(o[t]=[]),Array.isArray(r)?r.forEach(e=>a.implies(t,e)):(A(r,void 0,n),o[t].push(r)))},a.getImplied=function(){return o};function s(e,t){let n=Number(t);return t=isNaN(n)?t:n,typeof t==`number`?t=e._.length>=t:t.match(/^--no-.+/)?(t=t.match(/^--no-(.+)/)[1],t=!Object.prototype.hasOwnProperty.call(e,t)):t=Object.prototype.hasOwnProperty.call(e,t),t}a.implications=function(e){let n=[];if(Object.keys(o).forEach(t=>{let r=t;(o[t]||[]).forEach(t=>{let i=r,a=t;i=s(e,i),t=s(e,t),i&&!t&&n.push(` ${r} -> ${a}`)})}),n.length){let e=`${r(`Implications failed:`)}\n`;n.forEach(t=>{e+=t}),t.fail(e)}};let c={};a.conflicts=function(t,n){N(`<string|object> [array|string]`,[t,n],arguments.length),typeof t==`object`?Object.keys(t).forEach(e=>{a.conflicts(e,t[e])}):(e.global(t),c[t]||(c[t]=[]),Array.isArray(n)?n.forEach(e=>a.conflicts(t,e)):c[t].push(n))},a.getConflicting=()=>c,a.conflicting=function(i){Object.keys(i).forEach(e=>{c[e]&&c[e].forEach(n=>{n&&i[e]!==void 0&&i[n]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,n))})}),e.getInternalMethods().getParserConfiguration()[`strip-dashed`]&&Object.keys(c).forEach(e=>{c[e].forEach(a=>{a&&i[n.Parser.camelCase(e)]!==void 0&&i[n.Parser.camelCase(a)]!==void 0&&t.fail(r(`Arguments %s and %s are mutually exclusive`,e,a))})})},a.recommendCommands=function(e,n){n=n.sort((e,t)=>t.length-e.length);let i=null,a=1/0;for(let t=0,r;(r=n[t])!==void 0;t++){let t=cn(e,r);t<=3&&t<a&&(a=t,i=r)}i&&t.fail(r(`Did you mean %s?`,i))},a.reset=function(e){return o=Yt(o,t=>!e[t]),c=Yt(c,t=>!e[t]),a};let l=[];return a.freeze=function(){l.push({implied:o,conflicting:c})},a.unfreeze=function(){let e=l.pop();A(e,void 0,n),{implied:o,conflicting:c}=e},a}let dn=[],fn;function pn(e,t,n,r){fn=r;let i={};if(Object.prototype.hasOwnProperty.call(e,`extends`)){if(typeof e.extends!=`string`)return i;let a=/\.json|\..*rc$/.test(e.extends),o=null;if(a)o=hn(t,e.extends);else try{o=import.meta.resolve(e.extends)}catch{return e}mn(o),dn.push(o),i=a?JSON.parse(fn.readFileSync(o,`utf8`)):r.require(e.extends),delete e.extends,i=pn(i,fn.path.dirname(o),n,fn)}return dn=[],n?gn(i,e):Object.assign({},i,e)}function mn(e){if(dn.indexOf(e)>-1)throw new M(`Circular extended configurations: '${e}'.`)}function hn(e,t){return fn.path.resolve(e,t)}function gn(e,t){let n={};function r(e){return e&&typeof e==`object`&&!Array.isArray(e)}Object.assign(n,e);for(let i of Object.keys(t))r(t[i])&&r(n[i])?n[i]=gn(e[i],t[i]):n[i]=t[i];return n}var P=function(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n},F=function(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)},I,_n,vn,L,R,yn,z,bn,xn,B,Sn,V,H,U,W,Cn,wn,G,K,Tn,En,q,Dn,On,kn,An,jn,J,Mn,Nn,Pn,Y,Fn,X,Z;function In(e){return(t=[],n=e.process.cwd(),r)=>{let i=new yr(t,n,r,e);return Object.defineProperty(i,`argv`,{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}const Ln=Symbol(`copyDoubleDash`),Rn=Symbol(`copyDoubleDash`),zn=Symbol(`deleteFromParserHintObject`),Bn=Symbol(`emitWarning`),Vn=Symbol(`freeze`),Hn=Symbol(`getDollarZero`),Un=Symbol(`getParserConfiguration`),Wn=Symbol(`getUsageConfiguration`),Gn=Symbol(`guessLocale`),Kn=Symbol(`guessVersion`),qn=Symbol(`parsePositionalNumbers`),Jn=Symbol(`pkgUp`),Yn=Symbol(`populateParserHintArray`),Xn=Symbol(`populateParserHintSingleValueDictionary`),Zn=Symbol(`populateParserHintArrayDictionary`),Qn=Symbol(`populateParserHintDictionary`),$n=Symbol(`sanitizeKey`),er=Symbol(`setKey`),tr=Symbol(`unfreeze`),nr=Symbol(`validateAsync`),rr=Symbol(`getCommandInstance`),ir=Symbol(`getContext`),ar=Symbol(`getHasOutput`),or=Symbol(`getLoggerInstance`),sr=Symbol(`getParseContext`),cr=Symbol(`getUsageInstance`),lr=Symbol(`getValidationInstance`),ur=Symbol(`hasParseCallback`),dr=Symbol(`isGlobalContext`),fr=Symbol(`postProcess`),pr=Symbol(`rebase`),mr=Symbol(`reset`),hr=Symbol(`runYargsParserAndExecuteCommands`),gr=Symbol(`runValidation`),_r=Symbol(`setHasOutput`),vr=Symbol(`kTrackManuallySetKeys`);var yr=class{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,I.set(this,void 0),_n.set(this,void 0),vn.set(this,{commands:[],fullCommands:[]}),L.set(this,null),R.set(this,null),yn.set(this,`show-hidden`),z.set(this,null),bn.set(this,!0),xn.set(this,{}),B.set(this,!0),Sn.set(this,[]),V.set(this,void 0),H.set(this,{}),U.set(this,!1),W.set(this,null),Cn.set(this,!0),wn.set(this,void 0),G.set(this,``),K.set(this,void 0),Tn.set(this,void 0),En.set(this,{}),q.set(this,null),Dn.set(this,null),On.set(this,{}),kn.set(this,{}),An.set(this,void 0),jn.set(this,!1),J.set(this,void 0),Mn.set(this,!1),Nn.set(this,!1),Pn.set(this,!1),Y.set(this,void 0),Fn.set(this,{}),X.set(this,null),Z.set(this,void 0),P(this,J,r,`f`),P(this,An,e,`f`),P(this,_n,t,`f`),P(this,Tn,n,`f`),P(this,V,new It(this),`f`),this.$0=this[Hn](),this[mr](),P(this,I,F(this,I,`f`),`f`),P(this,Y,F(this,Y,`f`),`f`),P(this,Z,F(this,Z,`f`),`f`),P(this,K,F(this,K,`f`),`f`),F(this,K,`f`).showHiddenOpt=F(this,yn,`f`),P(this,wn,this[Rn](),`f`),F(this,J,`f`).y18n.setLocale(`en_US`)}addHelpOpt(e,t){return N(`[string|boolean] [string]`,[e,t],arguments.length),F(this,W,`f`)&&(this[zn](F(this,W,`f`)),P(this,W,null,`f`)),e===!1&&t===void 0?this:(P(this,W,typeof e==`string`?e:`help`,`f`),this.boolean(F(this,W,`f`)),this.describe(F(this,W,`f`),t||F(this,Y,`f`).deferY18nLookup(`Show help`)),this)}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(N(`[string|boolean] [string]`,[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==`string`?e:F(this,yn,`f`);return this.boolean(n),this.describe(n,t||F(this,Y,`f`).deferY18nLookup(`Show hidden options`)),F(this,K,`f`).showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return N(`<object|string|array> [string|array]`,[e,t],arguments.length),this[Zn](this.alias.bind(this),`alias`,e,t),this}array(e){return N(`<array|string>`,[e],arguments.length),this[Yn](`array`,e),this[vr](e),this}boolean(e){return N(`<array|string>`,[e],arguments.length),this[Yn](`boolean`,e),this[vr](e),this}check(e,t){return N(`<function> [boolean]`,[e,t],arguments.length),this.middleware((t,n)=>zt(()=>e(t,n.getOptions()),n=>(n?(typeof n==`string`||n instanceof Error)&&F(this,Y,`f`).fail(n.toString(),n):F(this,Y,`f`).fail(F(this,J,`f`).y18n.__(`Argument check failed: %s`,e.toString())),t),e=>(F(this,Y,`f`).fail(e.message?e.message:e.toString(),e),t)),!1,t),this}choices(e,t){return N(`<object|string|array> [string|array]`,[e,t],arguments.length),this[Zn](this.choices.bind(this),`choices`,e,t),this}coerce(e,t){if(N(`<object|string|array> [function]`,[e,t],arguments.length),Array.isArray(e)){if(!t)throw new M(`coerce callback must be provided`);for(let n of e)this.coerce(n,t);return this}else if(typeof e==`object`){for(let t of Object.keys(e))this.coerce(t,e[t]);return this}if(!t)throw new M(`coerce callback must be provided`);let n=e;return F(this,K,`f`).key[n]=!0,F(this,V,`f`).addCoerceMiddleware((e,r)=>{let i=[n,...r.getAliases()[n]??[]].filter(t=>Object.prototype.hasOwnProperty.call(e,t));return i.length===0?e:zt(()=>t(e[i[0]]),t=>(i.forEach(n=>{e[n]=t}),e),e=>{throw new M(e.message)})},n),this}conflicts(e,t){return N(`<string|object> [string|array]`,[e,t],arguments.length),F(this,Z,`f`).conflicts(e,t),this}config(e=`config`,t,n){return N(`[object|string] [string|function] [function]`,[e,t,n],arguments.length),typeof e==`object`&&!Array.isArray(e)?(e=pn(e,F(this,_n,`f`),this[Un]()[`deep-merge-config`]||!1,F(this,J,`f`)),F(this,K,`f`).configObjects=(F(this,K,`f`).configObjects||[]).concat(e),this):(typeof t==`function`&&(n=t,t=void 0),this.describe(e,t||F(this,Y,`f`).deferY18nLookup(`Path to JSON config file`)),(Array.isArray(e)?e:[e]).forEach(e=>{F(this,K,`f`).config[e]=n||!0}),this)}completion(e,t,n){return N(`[string] [string|boolean|function] [function]`,[e,t,n],arguments.length),typeof t==`function`&&(n=t,t=void 0),P(this,R,e||F(this,R,`f`)||`completion`,`f`),!t&&t!==!1&&(t=`generate completion script`),this.command(F(this,R,`f`),t),n&&F(this,L,`f`).registerFunction(n),this}command(e,t,n,r,i,a){return N(`<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]`,[e,t,n,r,i,a],arguments.length),F(this,I,`f`).addHandler(e,t,n,r,i,a),this}commands(e,t,n,r,i,a){return this.command(e,t,n,r,i,a)}commandDir(e,t){N(`<string> [object]`,[e,t],arguments.length);let n=F(this,Tn,`f`)||F(this,J,`f`).require;return F(this,I,`f`).addDirectory(e,n,F(this,J,`f`).getCallerFile(),t),this}count(e){return N(`<array|string>`,[e],arguments.length),this[Yn](`count`,e),this[vr](e),this}default(e,t,n){return N(`<object|string|array> [*] [string]`,[e,t,n],arguments.length),n&&(At(e,F(this,J,`f`)),F(this,K,`f`).defaultDescription[e]=n),typeof t==`function`&&(At(e,F(this,J,`f`)),F(this,K,`f`).defaultDescription[e]||(F(this,K,`f`).defaultDescription[e]=F(this,Y,`f`).functionDescription(t)),t=t.call()),this[Xn](this.default.bind(this),`default`,e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){return N(`[number] [number|string] [string|null|undefined] [string|null|undefined]`,[e,t,n,r],arguments.length),typeof t!=`number`&&(n=t,t=1/0),this.global(`_`,!1),F(this,K,`f`).demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){return Array.isArray(t)?(t.forEach(e=>{A(n,!0,F(this,J,`f`)),this.demandOption(e,n)}),t=1/0):typeof t!=`number`&&(n=t,t=1/0),typeof e==`number`?(A(n,!0,F(this,J,`f`)),this.demandCommand(e,t,n,n)):Array.isArray(e)?e.forEach(e=>{A(n,!0,F(this,J,`f`)),this.demandOption(e,n)}):typeof n==`string`?this.demandOption(e,n):(n===!0||n===void 0)&&this.demandOption(e),this}demandOption(e,t){return N(`<object|string|array> [string]`,[e,t],arguments.length),this[Xn](this.demandOption.bind(this),`demandedOptions`,e,t),this}deprecateOption(e,t){return N(`<string> [string|boolean]`,[e,t],arguments.length),F(this,K,`f`).deprecatedOptions[e]=t,this}describe(e,t){return N(`<object|string|array> [string]`,[e,t],arguments.length),this[er](e,!0),F(this,Y,`f`).describe(e,t),this}detectLocale(e){return N(`<boolean>`,[e],arguments.length),P(this,bn,e,`f`),this}env(e){return N(`[string|boolean]`,[e],arguments.length),e===!1?delete F(this,K,`f`).envPrefix:F(this,K,`f`).envPrefix=e||``,this}epilogue(e){return N(`<string>`,[e],arguments.length),F(this,Y,`f`).epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){return N(`<string|array> [string]`,[e,t],arguments.length),Array.isArray(e)?e.forEach(e=>this.example(...e)):F(this,Y,`f`).example(e,t),this}exit(e,t){P(this,U,!0,`f`),P(this,z,t,`f`),F(this,B,`f`)&&F(this,J,`f`).process.exit(e)}exitProcess(e=!0){return N(`[boolean]`,[e],arguments.length),P(this,B,e,`f`),this}fail(e){if(N(`<function|boolean>`,[e],arguments.length),typeof e==`boolean`&&e!==!1)throw new M(`Invalid first argument. Expected function or boolean 'false'`);return F(this,Y,`f`).failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){return N(`<array> [function]`,[e,t],arguments.length),t?F(this,L,`f`).getCompletion(e,t):new Promise((t,n)=>{F(this,L,`f`).getCompletion(e,(e,r)=>{e?n(e):t(r)})})}getDemandedOptions(){return N([],0),F(this,K,`f`).demandedOptions}getDemandedCommands(){return N([],0),F(this,K,`f`).demandedCommands}getDeprecatedOptions(){return N([],0),F(this,K,`f`).deprecatedOptions}getDetectLocale(){return F(this,bn,`f`)}getExitProcess(){return F(this,B,`f`)}getGroups(){return Object.assign({},F(this,H,`f`),F(this,kn,`f`))}getHelp(){if(P(this,U,!0,`f`),!F(this,Y,`f`).hasCachedHelpMessage()){if(!this.parsed){let e=this[hr](F(this,An,`f`),void 0,void 0,0,!0);if(j(e))return e.then(()=>F(this,Y,`f`).help())}let e=F(this,I,`f`).runDefaultBuilderOn(this);if(j(e))return e.then(()=>F(this,Y,`f`).help())}return Promise.resolve(F(this,Y,`f`).help())}getOptions(){return F(this,K,`f`)}getStrict(){return F(this,Mn,`f`)}getStrictCommands(){return F(this,Nn,`f`)}getStrictOptions(){return F(this,Pn,`f`)}global(e,t){return N(`<string|array> [boolean]`,[e,t],arguments.length),e=[].concat(e),t===!1?e.forEach(e=>{F(this,K,`f`).local.includes(e)||F(this,K,`f`).local.push(e)}):F(this,K,`f`).local=F(this,K,`f`).local.filter(t=>e.indexOf(t)===-1),this}group(e,t){N(`<string|array> <string>`,[e,t],arguments.length);let n=F(this,kn,`f`)[t]||F(this,H,`f`)[t];F(this,kn,`f`)[t]&&delete F(this,kn,`f`)[t];let r={};return F(this,H,`f`)[t]=(n||[]).concat(e).filter(e=>r[e]?!1:r[e]=!0),this}hide(e){return N(`<string>`,[e],arguments.length),F(this,K,`f`).hiddenOptions.push(e),this}implies(e,t){return N(`<string|object> [number|string|array]`,[e,t],arguments.length),F(this,Z,`f`).implies(e,t),this}locale(e){return N(`[string]`,[e],arguments.length),e===void 0?(this[Gn](),F(this,J,`f`).y18n.getLocale()):(P(this,bn,!1,`f`),F(this,J,`f`).y18n.setLocale(e),this)}middleware(e,t,n){return F(this,V,`f`).addMiddleware(e,!!t,n)}nargs(e,t){return N(`<string|object|array> [number]`,[e,t],arguments.length),this[Xn](this.nargs.bind(this),`narg`,e,t),this}normalize(e){return N(`<array|string>`,[e],arguments.length),this[Yn](`normalize`,e),this}number(e){return N(`<array|string>`,[e],arguments.length),this[Yn](`number`,e),this[vr](e),this}option(e,t){if(N(`<string|object> [object]`,[e,t],arguments.length),typeof e==`object`)Object.keys(e).forEach(t=>{this.options(t,e[t])});else{typeof t!=`object`&&(t={}),this[vr](e),F(this,X,`f`)&&(e===`version`||t?.alias===`version`)&&this[Bn]([`"version" is a reserved word.`,`Please do one of the following:`,'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)",`- Use a different option key`,`https://yargs.js.org/docs/#api-reference-version`].join(`
96
- `),void 0,`versionWarning`),F(this,K,`f`).key[e]=!0,t.alias&&this.alias(e,t.alias);let n=t.deprecate||t.deprecated;n&&this.deprecateOption(e,n);let r=t.demand||t.required||t.require;r&&this.demand(e,r),t.demandOption&&this.demandOption(e,typeof t.demandOption==`string`?t.demandOption:void 0),t.conflicts&&this.conflicts(e,t.conflicts),`default`in t&&this.default(e,t.default),t.implies!==void 0&&this.implies(e,t.implies),t.nargs!==void 0&&this.nargs(e,t.nargs),t.config&&this.config(e,t.configParser),t.normalize&&this.normalize(e),t.choices&&this.choices(e,t.choices),t.coerce&&this.coerce(e,t.coerce),t.group&&this.group(e,t.group),(t.boolean||t.type===`boolean`)&&(this.boolean(e),t.alias&&this.boolean(t.alias)),(t.array||t.type===`array`)&&(this.array(e),t.alias&&this.array(t.alias)),(t.number||t.type===`number`)&&(this.number(e),t.alias&&this.number(t.alias)),(t.string||t.type===`string`)&&(this.string(e),t.alias&&this.string(t.alias)),(t.count||t.type===`count`)&&this.count(e),typeof t.global==`boolean`&&this.global(e,t.global),t.defaultDescription&&(F(this,K,`f`).defaultDescription[e]=t.defaultDescription),t.skipValidation&&this.skipValidation(e);let i=t.describe||t.description||t.desc,a=F(this,Y,`f`).getDescriptions();(!Object.prototype.hasOwnProperty.call(a,e)||typeof i==`string`)&&this.describe(e,i),t.hidden&&this.hide(e),t.requiresArg&&this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){N(`[string|array] [function|boolean|object] [function]`,[e,t,n],arguments.length),this[Vn](),e===void 0&&(e=F(this,An,`f`)),typeof t==`object`&&(P(this,Dn,t,`f`),t=n),typeof t==`function`&&(P(this,q,t,`f`),t=!1),t||P(this,An,e,`f`),F(this,q,`f`)&&P(this,B,!1,`f`);let r=this[hr](e,!!t),i=this.parsed;return F(this,L,`f`).setParsed(this.parsed),j(r)?r.then(e=>(F(this,q,`f`)&&F(this,q,`f`).call(this,F(this,z,`f`),e,F(this,G,`f`)),e)).catch(e=>{throw F(this,q,`f`)&&F(this,q,`f`)(e,this.parsed.argv,F(this,G,`f`)),e}).finally(()=>{this[tr](),this.parsed=i}):(F(this,q,`f`)&&F(this,q,`f`).call(this,F(this,z,`f`),r,F(this,G,`f`)),this[tr](),this.parsed=i,r)}parseAsync(e,t,n){let r=this.parse(e,t,n);return j(r)?r:Promise.resolve(r)}parseSync(e,t,n){let r=this.parse(e,t,n);if(j(r))throw new M(`.parseSync() must not be used with asynchronous builders, handlers, or middleware`);return r}parserConfiguration(e){return N(`<object>`,[e],arguments.length),P(this,En,e,`f`),this}pkgConf(e,t){N(`<string> [string]`,[e,t],arguments.length);let n=null,r=this[Jn](t||F(this,_n,`f`));return r[e]&&typeof r[e]==`object`&&(n=pn(r[e],t||F(this,_n,`f`),this[Un]()[`deep-merge-config`]||!1,F(this,J,`f`)),F(this,K,`f`).configObjects=(F(this,K,`f`).configObjects||[]).concat(n)),this}positional(e,t){N(`<string> <object>`,[e,t],arguments.length);let n=[`default`,`defaultDescription`,`implies`,`normalize`,`choices`,`conflicts`,`coerce`,`type`,`describe`,`desc`,`description`,`alias`];t=Yt(t,(e,t)=>e===`type`&&![`string`,`number`,`boolean`].includes(t)?!1:n.includes(e));let r=F(this,vn,`f`).fullCommands[F(this,vn,`f`).fullCommands.length-1],i=r?F(this,I,`f`).cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return jt(i).forEach(n=>{let r=i[n];Array.isArray(r)?r.indexOf(e)!==-1&&(t[n]=!0):r[e]&&!(n in t)&&(t[n]=r[e])}),this.group(e,F(this,Y,`f`).getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return N(`[boolean]`,[e],arguments.length),P(this,jn,e,`f`),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){return N(`<array|string|object> [number]`,[e],arguments.length),typeof e==`string`&&F(this,K,`f`).narg[e]||this[Xn](this.requiresArg.bind(this),`narg`,e,NaN),this}showCompletionScript(e,t){return N(`[string] [string]`,[e,t],arguments.length),e||=this.$0,F(this,wn,`f`).log(F(this,L,`f`).generateCompletionScript(e,t||F(this,R,`f`)||`completion`)),this}showHelp(e){if(N(`[string|function]`,[e],arguments.length),P(this,U,!0,`f`),!F(this,Y,`f`).hasCachedHelpMessage()){if(!this.parsed){let t=this[hr](F(this,An,`f`),void 0,void 0,0,!0);if(j(t))return t.then(()=>{F(this,Y,`f`).showHelp(e)}),this}let t=F(this,I,`f`).runDefaultBuilderOn(this);if(j(t))return t.then(()=>{F(this,Y,`f`).showHelp(e)}),this}return F(this,Y,`f`).showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return N(`[boolean|string] [string]`,[e,t],arguments.length),F(this,Y,`f`).showHelpOnFail(e,t),this}showVersion(e){return N(`[string|function]`,[e],arguments.length),F(this,Y,`f`).showVersion(e),this}skipValidation(e){return N(`<array|string>`,[e],arguments.length),this[Yn](`skipValidation`,e),this}strict(e){return N(`[boolean]`,[e],arguments.length),P(this,Mn,e!==!1,`f`),this}strictCommands(e){return N(`[boolean]`,[e],arguments.length),P(this,Nn,e!==!1,`f`),this}strictOptions(e){return N(`[boolean]`,[e],arguments.length),P(this,Pn,e!==!1,`f`),this}string(e){return N(`<array|string>`,[e],arguments.length),this[Yn](`string`,e),this[vr](e),this}terminalWidth(){return N([],0),F(this,J,`f`).process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return N(`<object>`,[e],arguments.length),P(this,bn,!1,`f`),F(this,J,`f`).y18n.updateLocale(e),this}usage(e,t,n,r){if(N(`<string|null|undefined> [string|boolean] [function|object] [function]`,[e,t,n,r],arguments.length),t!==void 0){if(A(e,null,F(this,J,`f`)),(e||``).match(/^\$0( |$)/))return this.command(e,t,n,r);throw new M(`.usage() description must start with $0 if being used as alias for .command()`)}else return F(this,Y,`f`).usage(e),this}usageConfiguration(e){return N(`<object>`,[e],arguments.length),P(this,Fn,e,`f`),this}version(e,t,n){let r=`version`;if(N(`[boolean|string] [string] [string]`,[e,t,n],arguments.length),F(this,X,`f`)&&(this[zn](F(this,X,`f`)),F(this,Y,`f`).version(void 0),P(this,X,null,`f`)),arguments.length===0)n=this[Kn](),e=r;else if(arguments.length===1){if(e===!1)return this;n=e,e=r}else arguments.length===2&&(n=t,t=void 0);return P(this,X,typeof e==`string`?e:r,`f`),t||=F(this,Y,`f`).deferY18nLookup(`Show version number`),F(this,Y,`f`).version(n||void 0),this.boolean(F(this,X,`f`)),this.describe(F(this,X,`f`),t),this}wrap(e){return N(`<number|null|undefined>`,[e],arguments.length),F(this,Y,`f`).wrap(e),this}[(I=new WeakMap,_n=new WeakMap,vn=new WeakMap,L=new WeakMap,R=new WeakMap,yn=new WeakMap,z=new WeakMap,bn=new WeakMap,xn=new WeakMap,B=new WeakMap,Sn=new WeakMap,V=new WeakMap,H=new WeakMap,U=new WeakMap,W=new WeakMap,Cn=new WeakMap,wn=new WeakMap,G=new WeakMap,K=new WeakMap,Tn=new WeakMap,En=new WeakMap,q=new WeakMap,Dn=new WeakMap,On=new WeakMap,kn=new WeakMap,An=new WeakMap,jn=new WeakMap,J=new WeakMap,Mn=new WeakMap,Nn=new WeakMap,Pn=new WeakMap,Y=new WeakMap,Fn=new WeakMap,X=new WeakMap,Z=new WeakMap,Ln)](e){if(!e._||!e[`--`])return e;e._.push.apply(e._,e[`--`]);try{delete e[`--`]}catch{}return e}[Rn](){return{log:(...e)=>{this[ur]()||console.log(...e),P(this,U,!0,`f`),F(this,G,`f`).length&&P(this,G,F(this,G,`f`)+`
97
- `,`f`),P(this,G,F(this,G,`f`)+e.join(` `),`f`)},error:(...e)=>{this[ur]()||console.error(...e),P(this,U,!0,`f`),F(this,G,`f`).length&&P(this,G,F(this,G,`f`)+`
98
- `,`f`),P(this,G,F(this,G,`f`)+e.join(` `),`f`)}}}[zn](e){jt(F(this,K,`f`)).forEach(t=>{if((e=>e===`configObjects`)(t))return;let n=F(this,K,`f`)[t];Array.isArray(n)?n.includes(e)&&n.splice(n.indexOf(e),1):typeof n==`object`&&delete n[e]}),delete F(this,Y,`f`).getDescriptions()[e]}[Bn](e,t,n){F(this,xn,`f`)[n]||(F(this,J,`f`).process.emitWarning(e,t),F(this,xn,`f`)[n]=!0)}[Vn](){F(this,Sn,`f`).push({options:F(this,K,`f`),configObjects:F(this,K,`f`).configObjects.slice(0),exitProcess:F(this,B,`f`),groups:F(this,H,`f`),strict:F(this,Mn,`f`),strictCommands:F(this,Nn,`f`),strictOptions:F(this,Pn,`f`),completionCommand:F(this,R,`f`),output:F(this,G,`f`),exitError:F(this,z,`f`),hasOutput:F(this,U,`f`),parsed:this.parsed,parseFn:F(this,q,`f`),parseContext:F(this,Dn,`f`)}),F(this,Y,`f`).freeze(),F(this,Z,`f`).freeze(),F(this,I,`f`).freeze(),F(this,V,`f`).freeze()}[Hn](){let e=``,t;return t=/\b(node|iojs|electron)(\.exe)?$/.test(F(this,J,`f`).process.argv()[0])?F(this,J,`f`).process.argv().slice(1,2):F(this,J,`f`).process.argv().slice(0,1),e=t.map(e=>{let t=this[pr](F(this,_n,`f`),e);return e.match(/^(\/|([a-zA-Z]:)?\\)/)&&t.length<e.length?t:e}).join(` `).trim(),F(this,J,`f`).getEnv(`_`)&&F(this,J,`f`).getProcessArgvBin()===F(this,J,`f`).getEnv(`_`)&&(e=F(this,J,`f`).getEnv(`_`).replace(`${F(this,J,`f`).path.dirname(F(this,J,`f`).process.execPath())}/`,``)),e}[Un](){return F(this,En,`f`)}[Wn](){return F(this,Fn,`f`)}[Gn](){if(!F(this,bn,`f`))return;let e=F(this,J,`f`).getEnv(`LC_ALL`)||F(this,J,`f`).getEnv(`LC_MESSAGES`)||F(this,J,`f`).getEnv(`LANG`)||F(this,J,`f`).getEnv(`LANGUAGE`)||`en_US`;this.locale(e.replace(/[.:].*/,``))}[Kn](){return this[Jn]().version||`unknown`}[qn](e){let t=e[`--`]?e[`--`]:e._;for(let e=0,n;(n=t[e])!==void 0;e++)F(this,J,`f`).Parser.looksLikeNumber(n)&&Number.isSafeInteger(Math.floor(parseFloat(`${n}`)))&&(t[e]=Number(n));return e}[Jn](e){let t=e||`*`;if(F(this,On,`f`)[t])return F(this,On,`f`)[t];let n={};try{let t=e||F(this,J,`f`).mainFilename;F(this,J,`f`).path.extname(t)&&(t=F(this,J,`f`).path.dirname(t));let r=F(this,J,`f`).findUp(t,(e,t)=>{if(t.includes(`package.json`))return`package.json`});A(r,void 0,F(this,J,`f`)),n=JSON.parse(F(this,J,`f`).readFileSync(r,`utf8`))}catch{}return F(this,On,`f`)[t]=n||{},F(this,On,`f`)[t]}[Yn](e,t){t=[].concat(t),t.forEach(t=>{t=this[$n](t),F(this,K,`f`)[e].push(t)})}[Xn](e,t,n,r){this[Qn](e,t,n,r,(e,t,n)=>{F(this,K,`f`)[e][t]=n})}[Zn](e,t,n,r){this[Qn](e,t,n,r,(e,t,n)=>{F(this,K,`f`)[e][t]=(F(this,K,`f`)[e][t]||[]).concat(n)})}[Qn](e,t,n,r,i){if(Array.isArray(n))n.forEach(t=>{e(t,r)});else if((e=>typeof e==`object`)(n))for(let t of jt(n))e(t,n[t]);else i(t,this[$n](n),r)}[$n](e){return e===`__proto__`?`___proto___`:e}[er](e,t){return this[Xn](this[er].bind(this),`key`,e,t),this}[tr](){var e,t,n,r,i,a,o,s,c,l,u,d;let f=F(this,Sn,`f`).pop();A(f,void 0,F(this,J,`f`));let p;e=this,t=this,n=this,r=this,i=this,a=this,o=this,s=this,c=this,l=this,u=this,d=this,{options:{set value(t){P(e,K,t,`f`)}}.value,configObjects:p,exitProcess:{set value(e){P(t,B,e,`f`)}}.value,groups:{set value(e){P(n,H,e,`f`)}}.value,output:{set value(e){P(r,G,e,`f`)}}.value,exitError:{set value(e){P(i,z,e,`f`)}}.value,hasOutput:{set value(e){P(a,U,e,`f`)}}.value,parsed:this.parsed,strict:{set value(e){P(o,Mn,e,`f`)}}.value,strictCommands:{set value(e){P(s,Nn,e,`f`)}}.value,strictOptions:{set value(e){P(c,Pn,e,`f`)}}.value,completionCommand:{set value(e){P(l,R,e,`f`)}}.value,parseFn:{set value(e){P(u,q,e,`f`)}}.value,parseContext:{set value(e){P(d,Dn,e,`f`)}}.value}=f,F(this,K,`f`).configObjects=p,F(this,Y,`f`).unfreeze(),F(this,Z,`f`).unfreeze(),F(this,I,`f`).unfreeze(),F(this,V,`f`).unfreeze()}[nr](e,t){return zt(t,t=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[rr].bind(this),getContext:this[ir].bind(this),getHasOutput:this[ar].bind(this),getLoggerInstance:this[or].bind(this),getParseContext:this[sr].bind(this),getParserConfiguration:this[Un].bind(this),getUsageConfiguration:this[Wn].bind(this),getUsageInstance:this[cr].bind(this),getValidationInstance:this[lr].bind(this),hasParseCallback:this[ur].bind(this),isGlobalContext:this[dr].bind(this),postProcess:this[fr].bind(this),reset:this[mr].bind(this),runValidation:this[gr].bind(this),runYargsParserAndExecuteCommands:this[hr].bind(this),setHasOutput:this[_r].bind(this)}}[rr](){return F(this,I,`f`)}[ir](){return F(this,vn,`f`)}[ar](){return F(this,U,`f`)}[or](){return F(this,wn,`f`)}[sr](){return F(this,Dn,`f`)||{}}[cr](){return F(this,Y,`f`)}[lr](){return F(this,Z,`f`)}[ur](){return!!F(this,q,`f`)}[dr](){return F(this,Cn,`f`)}[fr](e,t,n,r){return n||j(e)?e:(t||(e=this[Ln](e)),(this[Un]()[`parse-positional-numbers`]||this[Un]()[`parse-positional-numbers`]===void 0)&&(e=this[qn](e)),r&&(e=Rt(e,this,F(this,V,`f`).getMiddleware(),!1)),e)}[mr](e={}){P(this,K,F(this,K,`f`)||{},`f`);let t={};t.local=F(this,K,`f`).local||[],t.configObjects=F(this,K,`f`).configObjects||[];let n={};return t.local.forEach(t=>{n[t]=!0,(e[t]||[]).forEach(e=>{n[e]=!0})}),Object.assign(F(this,kn,`f`),Object.keys(F(this,H,`f`)).reduce((e,t)=>{let r=F(this,H,`f`)[t].filter(e=>!(e in n));return r.length>0&&(e[t]=r),e},{})),P(this,H,{},`f`),[`array`,`boolean`,`string`,`skipValidation`,`count`,`normalize`,`number`,`hiddenOptions`].forEach(e=>{t[e]=(F(this,K,`f`)[e]||[]).filter(e=>!n[e])}),[`narg`,`key`,`alias`,`default`,`defaultDescription`,`config`,`choices`,`demandedOptions`,`demandedCommands`,`deprecatedOptions`].forEach(e=>{t[e]=Yt(F(this,K,`f`)[e],e=>!n[e])}),t.envPrefix=F(this,K,`f`).envPrefix,P(this,K,t,`f`),P(this,Y,F(this,Y,`f`)?F(this,Y,`f`).reset(n):Qt(this,F(this,J,`f`)),`f`),P(this,Z,F(this,Z,`f`)?F(this,Z,`f`).reset(n):un(this,F(this,Y,`f`),F(this,J,`f`)),`f`),P(this,I,F(this,I,`f`)?F(this,I,`f`).reset():Ut(F(this,Y,`f`),F(this,Z,`f`),F(this,V,`f`),F(this,J,`f`)),`f`),F(this,L,`f`)||P(this,L,an(this,F(this,Y,`f`),F(this,I,`f`),F(this,J,`f`)),`f`),F(this,V,`f`).reset(),P(this,R,null,`f`),P(this,G,``,`f`),P(this,z,null,`f`),P(this,U,!1,`f`),this.parsed=!1,this}[pr](e,t){return F(this,J,`f`).path.relative(e,t)}[hr](e,t,n,r=0,i=!1){let a=!!n||i;e||=F(this,An,`f`),F(this,K,`f`).__=F(this,J,`f`).y18n.__,F(this,K,`f`).configuration=this[Un]();let o=!!F(this,K,`f`).configuration[`populate--`],s=Object.assign({},F(this,K,`f`).configuration,{"populate--":!0}),c=F(this,J,`f`).Parser.detailed(e,Object.assign({},F(this,K,`f`),{configuration:{"parse-positional-numbers":!1,...s}})),l=Object.assign(c.argv,F(this,Dn,`f`)),u,d=c.aliases,f=!1,p=!1;Object.keys(l).forEach(e=>{e===F(this,W,`f`)&&l[e]?f=!0:e===F(this,X,`f`)&&l[e]&&(p=!0)}),l.$0=this.$0,this.parsed=c,r===0&&F(this,Y,`f`).clearCachedHelpMessage();try{if(this[Gn](),t)return this[fr](l,o,!!n,!1);F(this,W,`f`)&&[F(this,W,`f`)].concat(d[F(this,W,`f`)]||[]).filter(e=>e.length>1).includes(``+l._[l._.length-1])&&(l._.pop(),f=!0),P(this,Cn,!1,`f`);let s=F(this,I,`f`).getCommands(),m=F(this,L,`f`)?.completionKey?[F(this,L,`f`)?.completionKey,...this.getAliases()[F(this,L,`f`)?.completionKey]??[]].some(e=>Object.prototype.hasOwnProperty.call(l,e)):!1,h=f||m||i;if(l._.length){if(s.length){let e;for(let t=r||0,a;l._[t]!==void 0;t++)if(a=String(l._[t]),s.includes(a)&&a!==F(this,R,`f`)){let e=F(this,I,`f`).runCommand(a,this,c,t+1,i,f||p||i);return this[fr](e,o,!!n,!1)}else if(!e&&a!==F(this,R,`f`)){e=a;break}!F(this,I,`f`).hasDefaultCommand()&&F(this,jn,`f`)&&e&&!h&&F(this,Z,`f`).recommendCommands(e,s)}F(this,R,`f`)&&l._.includes(F(this,R,`f`))&&!m&&(F(this,B,`f`)&&Xt(!0),this.showCompletionScript(),this.exit(0))}if(F(this,I,`f`).hasDefaultCommand()&&!h){let e=F(this,I,`f`).runCommand(null,this,c,0,i,f||p||i);return this[fr](e,o,!!n,!1)}if(m){F(this,B,`f`)&&Xt(!0),e=[].concat(e);let t=e.slice(e.indexOf(`--${F(this,L,`f`).completionKey}`)+1);return F(this,L,`f`).getCompletion(t,(e,t)=>{if(e)throw new M(e.message);(t||[]).forEach(e=>{F(this,wn,`f`).log(e)}),this.exit(0)}),this[fr](l,!o,!!n,!1)}if(F(this,U,`f`)||(f?(F(this,B,`f`)&&Xt(!0),a=!0,this.showHelp(e=>{F(this,wn,`f`).log(e),this.exit(0)})):p&&(F(this,B,`f`)&&Xt(!0),a=!0,F(this,Y,`f`).showVersion(`log`),this.exit(0))),!a&&F(this,K,`f`).skipValidation.length>0&&(a=Object.keys(l).some(e=>F(this,K,`f`).skipValidation.indexOf(e)>=0&&l[e]===!0)),!a){if(c.error)throw new M(c.error.message);if(!m){let e=this[gr](d,{},c.error);n||(u=Rt(l,this,F(this,V,`f`).getMiddleware(),!0)),u=this[nr](e,u??l),j(u)&&!n&&(u=u.then(()=>Rt(l,this,F(this,V,`f`).getMiddleware(),!1)))}}}catch(e){if(e instanceof M)F(this,Y,`f`).fail(e.message,e);else throw e}return this[fr](u??l,o,!!n,!0)}[gr](e,t,n,r){let i={...this.getDemandedOptions()};return a=>{if(n)throw new M(n.message);F(this,Z,`f`).nonOptionCount(a),F(this,Z,`f`).requiredArguments(a,i);let o=!1;F(this,Nn,`f`)&&(o=F(this,Z,`f`).unknownCommands(a)),F(this,Mn,`f`)&&!o?F(this,Z,`f`).unknownArguments(a,e,t,!!r):F(this,Pn,`f`)&&F(this,Z,`f`).unknownArguments(a,e,{},!1,!1),F(this,Z,`f`).limitedChoices(a),F(this,Z,`f`).implications(a),F(this,Z,`f`).conflicting(a)}}[_r](){P(this,U,!0,`f`)}[vr](e){if(typeof e==`string`)F(this,K,`f`).key[e]=!0;else for(let t of e)F(this,K,`f`).key[t]=!0}};function br(e){return!!e&&typeof e.getInternalMethods==`function`}var xr=In(kt);function Sr(){return{validate:e=>{let t=Array.isArray(e)?e.length>0:!!e;return t?null:{isValid:t,error:`required`}}}}function Cr(e){return typeof e==`object`?e?.isValid!==!1:typeof e==`string`?e.length>0:!0}function wr(e){return typeof e==`object`?e.error:e}var Tr=Symbol(`instancier`),Er=class e{nextAnswers=[];static#e;static agent(){return this.#e??=new e(Tr)}constructor(e){if(e!==Tr)throw Error(`Cannot instanciate PromptAgent, use PromptAgent.agent() instead`)}nextAnswer(e){if(Array.isArray(e)){this.nextAnswers.push(...e);return}this.nextAnswers.push(e)}},Dr=class extends Error{constructor(e){super(e),this.name=`AbortError`}};function Or(e){return e}var kr=class e extends ie{stdin;stdout;message;signal;skip;history;agent;transformer=Or;rl;#e;constructor(t){if(super(),this.constructor===e)throw Error(`AbstractPrompt can't be instantiated.`);let{stdin:n=process.stdin,stdout:r=process.stdout,message:i,signal:a,skip:o=!1}=t;if(typeof i!=`string`)throw TypeError(`message must be string, ${typeof i} given.`);r.isTTY||Object.assign(r,{moveCursor:()=>void 0,clearScreenDown:()=>void 0}),this.stdin=n,this.stdout=r,this.message=i,this.signal=a,this.skip=o,this.history=[],this.agent=Er.agent(),this.stdout.isTTY&&this.stdin.setRawMode(!0),this.rl=ne.createInterface({input:n,output:new re({write:(e,t,n)=>{if(e){let n=this.transformer(Buffer.isBuffer(e)?e:Buffer.from(e));n!==null&&this.stdout.write(n,t)}n()}}),terminal:!0}),this.signal&&(this.#e=()=>{this.rl.close();for(let e=0;e<this.history.length;e++)this.clearLastLine();this.emit(`error`,new Dr(`Prompt aborted`))},this.signal.aborted&&this.#e(),this.signal.addEventListener(`abort`,this.#e,{once:!0}))}reset(){this.transformer=Or}write(e){let t=y(e).replace(v,``);return t&&this.history.push(t),this.stdout.write(e)}clearLastLine(){let e=this.history.pop();if(!e)return;let t=Math.ceil(y(e).length/this.stdout.columns);this.stdout.moveCursor(-this.stdout.columns,-t),this.stdout.clearScreenDown()}destroy(){this.rl.close(),this.signal&&this.signal.removeEventListener(`abort`,this.#e)}},Ar=new Intl.Segmenter;function jr(){return x.platform===`win32`?!!x.env.WT_SESSION||!!x.env.TERMINUS_SUBLIME||x.env.ConEmuTask===`{cmd::Cmder}`||x.env.TERM_PROGRAM===`Terminus-Sublime`||x.env.TERM_PROGRAM===`vscode`||x.env.TERM===`xterm-256color`||x.env.TERM===`alacritty`||x.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:x.env.TERM!==`linux`}function Mr(e){if(e===``)return 0;let t=0;for(let n of Ar.segment(y(e)))t++;return t}var Nr=jr()||process.env.CI?{tick:`✔`,cross:`✖`,pointer:`›`,previous:`⭡`,next:`⭣`,active:`●`,inactive:`○`}:{tick:`√`,cross:`×`,pointer:`>`,previous:`↑`,next:`↓`,active:`(+)`,inactive:`(-)`},Pr=b(`gray`,Nr.pointer),Q={QuestionMark:b([`blue`,`bold`],`?`),Tick:b([`green`,`bold`],Nr.tick),Cross:b([`red`,`bold`],Nr.cross),Pointer:Pr,Previous:Nr.previous,Next:Nr.next,ShowCursor:`\x1B[?25h`,HideCursor:`\x1B[?25l`,Active:b(`cyan`,Nr.active),Inactive:b(`gray`,Nr.inactive)},Fr=class extends kr{defaultValue;tip;questionSuffixError;answer;answerBuffer;#e;#t;#n=null;constructor(e){let{defaultValue:t,validators:n=[],secure:r=!1,...i}=e;if(super({...i}),t&&typeof t!=`string`)throw TypeError(`defaultValue must be a string`);this.defaultValue=t,this.tip=this.defaultValue?` (${this.defaultValue})`:``,this.#e=n,typeof r==`object`?(this.#t=!0,this.#n=r.placeholder):this.#t=!!r,this.questionSuffixError=``}#r(){return new Promise(e=>{let t=this.#i();this.history.push(t),this.rl.question(t,n=>{this.history.push(t+n),this.reset(),e(n)}),this.#n!==null&&(this.transformer=e=>Buffer.from(this.#n.repeat(e.length),`utf-8`))})}#i(){return`${b(`bold`,`${Q.QuestionMark} ${this.message}${this.tip}`)} ${this.questionSuffixError}`}#a(e){this.questionSuffixError=b(`red`,`[${e}] `)}#o(){let e=this.answer?Q.Tick:Q.Cross,t=this.answer??``,n=this.#n?this.#n.repeat(t.length):t,r=b(`yellow`,this.#t&&this.#n===null?`CONFIDENTIAL`:n);this.write(`${e} ${b(`bold`,this.message)} ${Q.Pointer} ${r}${v}`)}#s(){let e=Math.ceil(Mr(this.#i()+this.answer)/this.stdout.columns);this.stdout.moveCursor(-this.stdout.columns,-e),this.stdout.clearScreenDown();for(let e of this.#e){let t=e.validate(this.answer);if(Cr(t)===!1){this.#a(wr(t)),this.answerBuffer=this.#r();return}}this.answerBuffer=void 0,this.#o()}async question(){return this.skip?(this.destroy(),this.defaultValue??``):new Promise(async(e,t)=>{if(this.answer=this.agent.nextAnswers.shift(),this.answer!==void 0){this.#o(),this.destroy(),e(this.answer);return}for(this.once(`error`,e=>{t(e)}),this.answer=await this.#r(),this.answer===``&&this.defaultValue&&(this.answer=this.defaultValue),this.#s();this.answerBuffer!==void 0;)this.answer=await this.answerBuffer,this.#s();this.destroy(),e(this.answer)})}},Ir=new Set([`left`,`right`,`tab`,`q`,`a`,`d`,`h`,`j`,`k`,`l`,`space`]),Lr=class extends kr{initial;selectedValue;fastAnswer;#e;#t;constructor(e){let{initial:t=!1,...n}=e;super({...n}),this.initial=t,this.selectedValue=t}#n(){let e=b([`cyan`,`bold`,`underline`],`Yes`),t=b([`cyan`,`bold`,`underline`],`No`);return this.selectedValue?`${e}/No`:`Yes/${t}`}#r(){this.write(this.#s())}#i(){return new Promise(e=>{let t=this.#s();this.write(t),this.#e=this.#a.bind(this,e),this.stdin.on(`keypress`,this.#e),this.#t=this.#o.bind(this),process.once(`exit`,this.#t)})}#a(e,t,n){if(this.stdout.moveCursor(-this.stdout.columns,-Math.floor(Mr(this.#s())/this.stdout.columns)),this.stdout.clearScreenDown(),n.name===`return`){e(this.selectedValue);return}Ir.has(n.name??``)&&(this.selectedValue=!this.selectedValue),n.name===`y`?(this.selectedValue=!0,e(!0),this.fastAnswer=!0):n.name===`n`&&(this.selectedValue=!1,e(!1),this.fastAnswer=!0),this.fastAnswer||this.#r()}#o(){this.stdin.off(`keypress`,this.#e)}#s(){return`${b(`bold`,`${Q.QuestionMark} ${this.message}`)} ${this.#n()}`}#c(){this.clearLastLine(),this.stdout.moveCursor(-this.stdout.columns,-Math.floor(Mr(this.#s())/this.stdout.columns)),this.stdout.clearScreenDown(),this.write(`${this.selectedValue?Q.Tick:Q.Cross} ${b(`bold`,this.message)}${v}`)}async confirm(){return this.skip?(this.destroy(),this.initial):new Promise(async(e,t)=>{let n=this.agent.nextAnswers.shift();if(n!==void 0){this.selectedValue=n,this.#c(),this.destroy(),e(n);return}this.once(`error`,e=>{t(e)}),this.write(Q.HideCursor);try{await this.#i(),this.#c(),e(this.selectedValue)}finally{this.write(Q.ShowCursor),this.#o(),process.off(`exit`,this.#t),this.destroy()}})}},Rr=[`label`,`value`],zr=class extends kr{#e=()=>void 0;#t=()=>void 0;#n;activeIndex=0;questionMessage;autocompleteValue=``;options;lastRender;get choices(){return this.options.choices}get filteredChoices(){if(!(this.options.autocomplete&&this.autocompleteValue.length>0))return this.choices;let e=this.options.caseSensitive,t=e?this.autocompleteValue:this.autocompleteValue.toLowerCase();return this.choices.filter(n=>this.#r(n,t,e))}#r(e,t,n=!1){let r=typeof e==`string`?n?e:e.toLowerCase():n?e.label:e.label.toLowerCase();return t.includes(` `)?this.#i(r,t,n):r.includes(t)}#i(e,t,n){return t.split(` `).every(r=>{let i=n?r:r.toLowerCase();return e.includes(i)||e.includes(t)})}get longestChoice(){return Math.max(...this.filteredChoices.map(e=>typeof e==`string`?e.length:e.label.length))}constructor(e){let{choices:t,validators:n=[],...r}=e;if(super({...r}),this.options=e,!t?.length)throw this.destroy(),TypeError(`Missing required param: choices`);this.#n=n;for(let e of t)if(typeof e!=`string`){for(let t of Rr)if(!e[t])throw this.destroy(),TypeError(`Missing ${t} for choice ${JSON.stringify(e)}`)}}#a(e){let t=this.filteredChoices[e];return typeof t==`string`?{value:t,label:t}:t}#o(){let e=this.options.maxVisible||8,t=Math.min(this.filteredChoices.length-e,this.activeIndex-Math.floor(e/2));t<0&&(t=0);let n=Math.min(t+e,this.filteredChoices.length);return{startIndex:t,endIndex:n}}#s(){let{startIndex:e,endIndex:t}=this.#o();this.lastRender={startIndex:e,endIndex:t},this.options.autocomplete&&this.write(`${Q.Pointer} ${this.autocompleteValue}${v}`);for(let n=e;n<t;n++){let r=this.#a(n),i=n===this.activeIndex,a=e>0&&n===e,o=t<this.filteredChoices.length&&n===t-1,s=` `;a?s=Q.Previous:o&&(s=Q.Next);let c=`${s}${i?`${Q.Pointer} `:` `}`,l=r.label.padEnd(this.longestChoice<10?this.longestChoice:0),u=r.description?` - ${r.description}`:``,d=`${c}${b(i?[`white`,`bold`]:[`gray`],`${l}${u}`)}${v}`;this.write(d)}}#c(e){let t=`${e===``?Q.Cross:Q.Tick} ${b(`bold`,this.message)} ${Q.Pointer}`,n=b(`yellow`,e);this.write(`${t} ${n}${v}`)}#l(){this.stdin.off(`keypress`,this.#t),this.stdout.moveCursor(-this.stdout.columns,0),this.stdout.clearScreenDown(),this.write(Q.ShowCursor)}#u(...e){let[t,n,,r]=e;if(r.name===`up`)this.activeIndex=this.activeIndex===0?this.filteredChoices.length-1:this.activeIndex-1,n();else if(r.name===`down`)this.activeIndex=this.activeIndex===this.filteredChoices.length-1?0:this.activeIndex+1,n();else if(r.name===`return`){let e=this.filteredChoices[this.activeIndex]||``,r=typeof e==`string`?e:e.label,i=typeof e==`string`?e:e.value;for(let e of this.#n){let t=e.validate(i);if(Cr(t)===!1){n({error:wr(t)});return}}n({clearRender:!0}),this.options.ignoreValues?.includes(i)||this.#c(r),this.write(Q.ShowCursor),this.destroy(),this.#l(),process.off(`exit`,this.#e),t(i)}else !r.ctrl&&this.options.autocomplete&&(this.activeIndex=0,r.name===`backspace`&&this.autocompleteValue.length>0?this.autocompleteValue=this.autocompleteValue.slice(0,-1):r.name!==`backspace`&&(this.autocompleteValue+=r.sequence)),n()}async select(){if(this.skip){this.destroy();let e=this.options.choices[0];return typeof e==`string`?e:e.value}return new Promise((e,t)=>{let n=this.agent.nextAnswers.shift();if(n!==void 0){this.#c(n),this.destroy(),e(n);return}this.once(`error`,e=>{t(e)}),this.write(Q.HideCursor),this.#d();let r=(e={})=>{let{initialRender:t=!1,clearRender:n=!1,error:r=null}=e;if(!t){let e=this.lastRender.endIndex-this.lastRender.startIndex;for(;e>0;)this.clearLastLine(),e--;if(this.options.autocomplete){let e=Math.ceil(Mr(`${Q.Pointer} ${this.autocompleteValue}`)/this.stdout.columns);for(;e>0;)this.clearLastLine(),e--}}if(n){let e=Math.ceil(Mr(this.questionMessage)/this.stdout.columns);this.stdout.moveCursor(-this.stdout.columns,-(1+e)),this.stdout.clearScreenDown();return}if(r){let e=Math.ceil(Mr(this.questionMessage)/this.stdout.columns)+1;this.stdout.moveCursor(0,-e),this.stdout.clearScreenDown(),this.#d(r)}this.#s()};r({initialRender:!0}),this.#t=this.#u.bind(this,e,r),this.stdin.on(`keypress`,this.#t),this.#e=this.#l.bind(this),process.once(`exit`,this.#e)})}#d(e=null){let t=``;e&&(t=` ${t.length>0?` `:``}${b([`red`,`bold`],`[${e}]`)}`),this.questionMessage=`${Q.QuestionMark} ${b(`bold`,this.message)}${t}`,this.write(`${this.questionMessage}${v}`)}};function Br(e,t={}){return new Fr({...t,message:e}).question()}function Vr(e,t){return new zr({...t,message:e}).select()}function Hr(e,t={}){return new Lr({...t,message:e}).confirm()}const Ur=oe.join(te.homedir(),`.cmdbox`),Wr=async e=>{try{return await ae(e),!0}catch{return!1}},Gr=e=>`Name\t\t${e.name}
99
- Description\t${e.description?e.description:`empty`}
100
- Command\t\t${e.command}`,Kr=async()=>{try{await C(Ur,JSON.stringify([]),`utf8`)}catch(e){console.error(e)}},qr=async()=>{try{return await S(Ur,`utf8`)}catch(e){throw e}},$={init:async function(){await Wr(Ur)||await Kr()},getCommands:async function(){let e=await qr();return JSON.parse(e)},findCommand:async function(e){let t=(await this.getCommands()).find(t=>t.name===e);return t||(console.error(`Command "${e}" does not exist`),process.exit(1)),t},addCommand:async function(e){try{let t=[e,...await this.getCommands()];await C(Ur,JSON.stringify(t,null,2),`utf8`)}catch(e){console.error(e)}},removeCommand:async function(e){try{let t=(await this.getCommands()).filter(t=>t.name!==e);await C(Ur,JSON.stringify(t,null,2))}catch(e){console.error(e)}}},Jr=async()=>{let e=await $.getCommands(),t;for(;t=await Br(`Name?`,{validators:[Sr()]}),e.some(e=>e.name===t.trim());)console.log(`Command "${t.trim()}" already exists`);let n=await Br(`Description?`),r=await Br(`Command?`,{validators:[Sr()]});await $.addCommand({name:t.trim(),description:n.trim(),command:r.trim()}),console.log(`Command has been added`)},Yr=async()=>{for(let e of await $.getCommands())console.log(`\n${Gr(e)}\n`)},Xr=async()=>{try{if(!await Hr(`Purge command store?`,{initial:!1}))return;await C(Ur,`[]`,`utf8`),console.log(`Command store cleared`)}catch(e){console.error(e)}},Zr=async e=>{let t=(await $.getCommands()).map(e=>e.name);t.length<=0&&(console.error(`No commands stored yet`),process.exit(1));let n;n=e||await Vr(`Choose a command`,{choices:t});let r=await $.findCommand(n);console.log(Gr(r)),await Hr(`Remove this command?`,{initial:!0})&&(await $.removeCommand(n),console.log(`Command removed`))},Qr=async e=>{let t=(await $.getCommands()).map(e=>e.name);t.length<=0&&(console.error(`No commands stored yet`),process.exit(1));let n;n=e||await Vr(`Choose a command`,{choices:t});let r=await $.findCommand(n);console.log(`$ ${r.command}`),await Hr(`Execute this command?`,{initial:!0})&&se(r.command,{stdio:`inherit`})};await $.init(),xr(yt(process.argv)).scriptName(`cmdbox`).strictCommands().demandCommand(1).recommendCommands().command(`add`,`Add a new command to the store`,{},Jr).command(`list`,`List all stored commands`,{},Yr).command(`purge`,`Remove all stored commands`,{},Xr).command(`run [name]`,`Run a stored command`,e=>e.positional(`name`,{describe:`The name of the stored command`,type:`string`}),e=>Qr(e.name)).command(`remove [name]`,`Remove a stored command`,e=>e.positional(`name`,{describe:`The name of the stored command`,type:`string`}),e=>Zr(e.name)).help().alias(`h`,`help`).version().alias(`v`,`version`).parse();
79
+ //#endregion
80
+ //#region src/cmd/add.ts
81
+ const handler$4 = async () => {
82
+ const cmds = await store.getCommands();
83
+ let name;
84
+ while (true) {
85
+ name = await question("Name?", { validators: [required()] });
86
+ if (cmds.some((cmd) => cmd.name === name.trim())) console.log(`Command "${name.trim()}" already exists`);
87
+ else break;
88
+ }
89
+ const description = await question("Description?");
90
+ const command = await question("Command?", { validators: [required()] });
91
+ await store.addCommand({
92
+ name: name.trim(),
93
+ description: description.trim(),
94
+ command: command.trim()
95
+ });
96
+ console.log("Command has been added");
97
+ };
98
+
99
+ //#endregion
100
+ //#region src/cmd/list.ts
101
+ const handler$3 = async () => {
102
+ for (const cmd of await store.getCommands()) console.log(`\n${formatCommand(cmd)}\n`);
103
+ };
104
+
105
+ //#endregion
106
+ //#region src/cmd/purge.ts
107
+ const handler$2 = async () => {
108
+ try {
109
+ if (!await confirm("Purge command store?", { initial: false })) return;
110
+ await writeFile(STORE_FILE_PATH, "[]", "utf8");
111
+ console.log("Command store cleared");
112
+ } catch (err) {
113
+ console.error(err);
114
+ }
115
+ };
116
+
117
+ //#endregion
118
+ //#region src/cmd/remove.ts
119
+ const handler$1 = async (name) => {
120
+ const cmds = (await store.getCommands()).map((v) => v.name);
121
+ if (cmds.length <= 0) {
122
+ console.error("No commands stored yet");
123
+ process.exit(1);
124
+ }
125
+ let _name;
126
+ if (!name) _name = await select("Choose a command", { choices: cmds });
127
+ else _name = name;
128
+ const cmd = await store.findCommand(_name);
129
+ console.log(formatCommand(cmd));
130
+ if (await confirm("Remove this command?", { initial: true })) {
131
+ await store.removeCommand(_name);
132
+ console.log("Command removed");
133
+ }
134
+ };
135
+
136
+ //#endregion
137
+ //#region src/cmd/run.ts
138
+ const handler = async (name) => {
139
+ const cmds = (await store.getCommands()).map((v) => v.name);
140
+ if (cmds.length <= 0) {
141
+ console.error("No commands stored yet");
142
+ process.exit(1);
143
+ }
144
+ let _name;
145
+ if (!name) _name = await select("Choose a command", { choices: cmds });
146
+ else _name = name;
147
+ const cmd = await store.findCommand(_name);
148
+ console.log(`$ ${cmd.command}`);
149
+ if (await confirm("Execute this command?", { initial: true })) execSync(cmd.command, { stdio: "inherit" });
150
+ };
151
+
152
+ //#endregion
153
+ //#region src/cmdbox.ts
154
+ await store.init();
155
+ yargs(hideBin(process.argv)).scriptName(SCRIPT_NAME).strictCommands().demandCommand(1).recommendCommands().command("add", "Add a new command to the store", {}, handler$4).command("list", "List all stored commands", {}, handler$3).command("purge", "Remove all stored commands", {}, handler$2).command("run [name]", "Run a stored command", (yargs$1) => {
156
+ return yargs$1.positional("name", {
157
+ describe: "The name of the stored command",
158
+ type: "string"
159
+ });
160
+ }, (argv) => handler(argv.name)).command("remove [name]", "Remove a stored command", (yargs$1) => {
161
+ return yargs$1.positional("name", {
162
+ describe: "The name of the stored command",
163
+ type: "string"
164
+ });
165
+ }, (argv) => handler$1(argv.name)).help().alias("h", "help").version().alias("v", "version").parse();
166
+
167
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cmdbox",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "cmdbox": "dist/cmdbox.js"
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "scripts": {
42
42
  "build": "rolldown -c",
43
- "dev": "cross-env DEV=true rolldown -wc",
43
+ "dev": "rolldown -wc",
44
44
  "link-cli": "pnpm run build && pnpm -g link",
45
45
  "unlink-cli": "pnpm rm -g cmdbox"
46
46
  }