UNPKG

cursor-i18n

Version:

CLI tool to internationalize Cursor IDE interface with multiple language support

27 lines 278 kB
#!/usr/bin/env node var $t=Object.create;var{getPrototypeOf:Yt,defineProperty:V,getOwnPropertyNames:Vt}=Object;var Qt=Object.prototype.hasOwnProperty;var A=(e,a,c)=>{c=e!=null?$t(Yt(e)):{};let r=a||!e||!e.__esModule?V(c,"default",{value:e,enumerable:!0}):c;for(let i of Vt(e))if(!Qt.call(r,i))V(r,i,{get:()=>e[i],enumerable:!0});return r};var b=(e,a)=>()=>(a||e((a={exports:{}}).exports,a),a.exports);var Zt=(e,a)=>{for(var c in a)V(e,c,{get:a[c],enumerable:!0,configurable:!0,set:(r)=>a[c]=()=>r})};var Xt=(e,a)=>()=>(e&&(a=e(e=0)),a);var Z=b((Ar,we)=>{var Q={to(e,a){if(!a)return`\x1B[${e+1}G`;return`\x1B[${a+1};${e+1}H`},move(e,a){let c="";if(e<0)c+=`\x1B[${-e}D`;else if(e>0)c+=`\x1B[${e}C`;if(a<0)c+=`\x1B[${-a}A`;else if(a>0)c+=`\x1B[${a}B`;return c},up:(e=1)=>`\x1B[${e}A`,down:(e=1)=>`\x1B[${e}B`,forward:(e=1)=>`\x1B[${e}C`,backward:(e=1)=>`\x1B[${e}D`,nextLine:(e=1)=>"\x1B[E".repeat(e),prevLine:(e=1)=>"\x1B[F".repeat(e),left:"\x1B[G",hide:"\x1B[?25l",show:"\x1B[?25h",save:"\x1B7",restore:"\x1B8"},Jt={up:(e=1)=>"\x1B[S".repeat(e),down:(e=1)=>"\x1B[T".repeat(e)},Ot={screen:"\x1B[2J",up:(e=1)=>"\x1B[1J".repeat(e),down:(e=1)=>"\x1B[J".repeat(e),line:"\x1B[2K",lineEnd:"\x1B[K",lineStart:"\x1B[1K",lines(e){let a="";for(let c=0;c<e;c++)a+=this.line+(c<e-1?Q.up():"");if(e)a+=Q.left;return a}};we.exports={cursor:Q,scroll:Jt,erase:Ot,beep:"\x07"}});var Re=b((Sr,X)=>{var B=process||{},Pe=B.argv||[],M=B.env||{},Ft=!(!!M.NO_COLOR||Pe.includes("--no-color"))&&(!!M.FORCE_COLOR||Pe.includes("--color")||B.platform==="win32"||(B.stdout||{}).isTTY&&M.TERM!=="dumb"||!!M.CI),Dt=(e,a,c=e)=>(r)=>{let i=""+r,n=i.indexOf(a,e.length);return~n?e+ec(i,a,c,n)+a:e+i+a},ec=(e,a,c,r)=>{let i="",n=0;do i+=e.substring(n,r)+c,n=r+a.length,r=e.indexOf(a,n);while(~r);return i+e.substring(n)},Ie=(e=Ft)=>{let a=e?Dt:()=>String;return{isColorSupported:e,reset:a("\x1B[0m","\x1B[0m"),bold:a("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:a("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:a("\x1B[3m","\x1B[23m"),underline:a("\x1B[4m","\x1B[24m"),inverse:a("\x1B[7m","\x1B[27m"),hidden:a("\x1B[8m","\x1B[28m"),strikethrough:a("\x1B[9m","\x1B[29m"),black:a("\x1B[30m","\x1B[39m"),red:a("\x1B[31m","\x1B[39m"),green:a("\x1B[32m","\x1B[39m"),yellow:a("\x1B[33m","\x1B[39m"),blue:a("\x1B[34m","\x1B[39m"),magenta:a("\x1B[35m","\x1B[39m"),cyan:a("\x1B[36m","\x1B[39m"),white:a("\x1B[37m","\x1B[39m"),gray:a("\x1B[90m","\x1B[39m"),bgBlack:a("\x1B[40m","\x1B[49m"),bgRed:a("\x1B[41m","\x1B[49m"),bgGreen:a("\x1B[42m","\x1B[49m"),bgYellow:a("\x1B[43m","\x1B[49m"),bgBlue:a("\x1B[44m","\x1B[49m"),bgMagenta:a("\x1B[45m","\x1B[49m"),bgCyan:a("\x1B[46m","\x1B[49m"),bgWhite:a("\x1B[47m","\x1B[49m"),blackBright:a("\x1B[90m","\x1B[39m"),redBright:a("\x1B[91m","\x1B[39m"),greenBright:a("\x1B[92m","\x1B[39m"),yellowBright:a("\x1B[93m","\x1B[39m"),blueBright:a("\x1B[94m","\x1B[39m"),magentaBright:a("\x1B[95m","\x1B[39m"),cyanBright:a("\x1B[96m","\x1B[39m"),whiteBright:a("\x1B[97m","\x1B[39m"),bgBlackBright:a("\x1B[100m","\x1B[49m"),bgRedBright:a("\x1B[101m","\x1B[49m"),bgGreenBright:a("\x1B[102m","\x1B[49m"),bgYellowBright:a("\x1B[103m","\x1B[49m"),bgBlueBright:a("\x1B[104m","\x1B[49m"),bgMagentaBright:a("\x1B[105m","\x1B[49m"),bgCyanBright:a("\x1B[106m","\x1B[49m"),bgWhiteBright:a("\x1B[107m","\x1B[49m")}};X.exports=Ie();X.exports.createColors=Ie});var k=b((re)=>{class ce extends Error{constructor(e,a,c){super(c);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=a,this.exitCode=e,this.nestedError=void 0}}class Ye extends ce{constructor(e){super(1,"commander.invalidArgument",e);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}re.CommanderError=ce;re.InvalidArgumentError=Ye});var G=b((ie)=>{var{InvalidArgumentError:Bc}=k();class Ve{constructor(e,a){switch(this.description=a||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}if(this._name.length>3&&this._name.slice(-3)==="...")this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_concatValue(e,a){if(a===this.defaultValue||!Array.isArray(a))return[e];return a.concat(e)}default(e,a){return this.defaultValue=e,this.defaultValueDescription=a,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(a,c)=>{if(!this.argChoices.includes(a))throw new Bc(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(a,c);return a},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function Lc(e){let a=e.name()+(e.variadic===!0?"...":"");return e.required?"<"+a+">":"["+a+"]"}ie.Argument=Ve;ie.humanReadableArgName=Lc});var oe=b((ne)=>{var{humanReadableArgName:vc}=G();class Qe{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let a=e.commands.filter((r)=>!r._hidden),c=e._getHelpCommand();if(c&&!c._hidden)a.push(c);if(this.sortSubcommands)a.sort((r,i)=>{return r.name().localeCompare(i.name())});return a}compareOptions(e,a){let c=(r)=>{return r.short?r.short.replace(/^-/,""):r.long.replace(/^--/,"")};return c(e).localeCompare(c(a))}visibleOptions(e){let a=e.options.filter((r)=>!r.hidden),c=e._getHelpOption();if(c&&!c.hidden){let r=c.short&&e._findOption(c.short),i=c.long&&e._findOption(c.long);if(!r&&!i)a.push(c);else if(c.long&&!i)a.push(e.createOption(c.long,c.description));else if(c.short&&!r)a.push(e.createOption(c.short,c.description))}if(this.sortOptions)a.sort(this.compareOptions);return a}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let a=[];for(let c=e.parent;c;c=c.parent){let r=c.options.filter((i)=>!i.hidden);a.push(...r)}if(this.sortOptions)a.sort(this.compareOptions);return a}visibleArguments(e){if(e._argsDescription)e.registeredArguments.forEach((a)=>{a.description=a.description||e._argsDescription[a.name()]||""});if(e.registeredArguments.find((a)=>a.description))return e.registeredArguments;return[]}subcommandTerm(e){let a=e.registeredArguments.map((c)=>vc(c)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(a?" "+a:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,a){return a.visibleCommands(e).reduce((c,r)=>{return Math.max(c,this.displayWidth(a.styleSubcommandTerm(a.subcommandTerm(r))))},0)}longestOptionTermLength(e,a){return a.visibleOptions(e).reduce((c,r)=>{return Math.max(c,this.displayWidth(a.styleOptionTerm(a.optionTerm(r))))},0)}longestGlobalOptionTermLength(e,a){return a.visibleGlobalOptions(e).reduce((c,r)=>{return Math.max(c,this.displayWidth(a.styleOptionTerm(a.optionTerm(r))))},0)}longestArgumentTermLength(e,a){return a.visibleArguments(e).reduce((c,r)=>{return Math.max(c,this.displayWidth(a.styleArgumentTerm(a.argumentTerm(r))))},0)}commandUsage(e){let a=e._name;if(e._aliases[0])a=a+"|"+e._aliases[0];let c="";for(let r=e.parent;r;r=r.parent)c=r.name()+" "+c;return c+a+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let a=[];if(e.argChoices)a.push(`choices: ${e.argChoices.map((c)=>JSON.stringify(c)).join(", ")}`);if(e.defaultValue!==void 0){if(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue==="boolean")a.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(e.presetArg!==void 0&&e.optional)a.push(`preset: ${JSON.stringify(e.presetArg)}`);if(e.envVar!==void 0)a.push(`env: ${e.envVar}`);if(a.length>0){let c=`(${a.join(", ")})`;if(e.description)return`${e.description} ${c}`;return c}return e.description}argumentDescription(e){let a=[];if(e.argChoices)a.push(`choices: ${e.argChoices.map((c)=>JSON.stringify(c)).join(", ")}`);if(e.defaultValue!==void 0)a.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`);if(a.length>0){let c=`(${a.join(", ")})`;if(e.description)return`${e.description} ${c}`;return c}return e.description}formatItemList(e,a,c){if(a.length===0)return[];return[c.styleTitle(e),...a,""]}groupItems(e,a,c){let r=new Map;return e.forEach((i)=>{let n=c(i);if(!r.has(n))r.set(n,[])}),a.forEach((i)=>{let n=c(i);if(!r.has(n))r.set(n,[]);r.get(n).push(i)}),r}formatHelp(e,a){let c=a.padWidth(e,a),r=a.helpWidth??80;function i(x,l){return a.formatItem(x,c,l,a)}let n=[`${a.styleTitle("Usage:")} ${a.styleUsage(a.commandUsage(e))}`,""],t=a.commandDescription(e);if(t.length>0)n=n.concat([a.boxWrap(a.styleCommandDescription(t),r),""]);let o=a.visibleArguments(e).map((x)=>{return i(a.styleArgumentTerm(a.argumentTerm(x)),a.styleArgumentDescription(a.argumentDescription(x)))});if(n=n.concat(this.formatItemList("Arguments:",o,a)),this.groupItems(e.options,a.visibleOptions(e),(x)=>x.helpGroupHeading??"Options:").forEach((x,l)=>{let f=x.map((m)=>{return i(a.styleOptionTerm(a.optionTerm(m)),a.styleOptionDescription(a.optionDescription(m)))});n=n.concat(this.formatItemList(l,f,a))}),a.showGlobalOptions){let x=a.visibleGlobalOptions(e).map((l)=>{return i(a.styleOptionTerm(a.optionTerm(l)),a.styleOptionDescription(a.optionDescription(l)))});n=n.concat(this.formatItemList("Global Options:",x,a))}return this.groupItems(e.commands,a.visibleCommands(e),(x)=>x.helpGroup()||"Commands:").forEach((x,l)=>{let f=x.map((m)=>{return i(a.styleSubcommandTerm(a.subcommandTerm(m)),a.styleSubcommandDescription(a.subcommandDescription(m)))});n=n.concat(this.formatItemList(l,f,a))}),n.join(` `)}displayWidth(e){return Ze(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map((a)=>{if(a==="[options]")return this.styleOptionText(a);if(a==="[command]")return this.styleSubcommandText(a);if(a[0]==="["||a[0]==="<")return this.styleArgumentText(a);return this.styleCommandText(a)}).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map((a)=>{if(a==="[options]")return this.styleOptionText(a);if(a[0]==="["||a[0]==="<")return this.styleArgumentText(a);return this.styleSubcommandText(a)}).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,a){return Math.max(a.longestOptionTermLength(e,a),a.longestGlobalOptionTermLength(e,a),a.longestSubcommandTermLength(e,a),a.longestArgumentTermLength(e,a))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,a,c,r){let n=" ".repeat(2);if(!c)return n+e;let t=e.padEnd(a+e.length-r.displayWidth(e)),o=2,T=(this.helpWidth??80)-a-o-2,x;if(T<this.minWidthToWrap||r.preformatted(c))x=c;else x=r.boxWrap(c,T).replace(/\n/g,` `+" ".repeat(a+o));return n+t+" ".repeat(o)+x.replace(/\n/g,` ${n}`)}boxWrap(e,a){if(a<this.minWidthToWrap)return e;let c=e.split(/\r\n|\n/),r=/[\s]*[^\s]+/g,i=[];return c.forEach((n)=>{let t=n.match(r);if(t===null){i.push("");return}let o=[t.shift()],s=this.displayWidth(o[0]);t.forEach((T)=>{let x=this.displayWidth(T);if(s+x<=a){o.push(T),s+=x;return}i.push(o.join(""));let l=T.trimStart();o=[l],s=this.displayWidth(l)}),i.push(o.join(""))}),i.join(` `)}}function Ze(e){let a=/\x1b\[\d*(;\d*)*m/g;return e.replace(a,"")}ne.Help=Qe;ne.stripColor=Ze});var se=b((Te)=>{var{InvalidArgumentError:Uc}=k();class Je{constructor(e,a){this.flags=e,this.description=a||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;let c=qc(e);if(this.short=c.shortFlag,this.long=c.longFlag,this.negate=!1,this.long)this.negate=this.long.startsWith("--no-");this.defaultValue=void 0,this.defaultValueDescription=void 0,this.presetArg=void 0,this.envVar=void 0,this.parseArg=void 0,this.hidden=!1,this.argChoices=void 0,this.conflictsWith=[],this.implied=void 0,this.helpGroupHeading=void 0}default(e,a){return this.defaultValue=e,this.defaultValueDescription=a,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let a=e;if(typeof e==="string")a={[e]:!0};return this.implied=Object.assign(this.implied||{},a),this}env(e){return this.envVar=e,this}argParser(e){return this.parseArg=e,this}makeOptionMandatory(e=!0){return this.mandatory=!!e,this}hideHelp(e=!0){return this.hidden=!!e,this}_concatValue(e,a){if(a===this.defaultValue||!Array.isArray(a))return[e];return a.concat(e)}choices(e){return this.argChoices=e.slice(),this.parseArg=(a,c)=>{if(!this.argChoices.includes(a))throw new Uc(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._concatValue(a,c);return a},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return Xe(this.name().replace(/^no-/,""));return Xe(this.name())}helpGroup(e){return this.helpGroupHeading=e,this}is(e){return this.short===e||this.long===e}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class Oe{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((a)=>{if(a.negate)this.negativeOptions.set(a.attributeName(),a);else this.positiveOptions.set(a.attributeName(),a)}),this.negativeOptions.forEach((a,c)=>{if(this.positiveOptions.has(c))this.dualOptions.add(c)})}valueFromOption(e,a){let c=a.attributeName();if(!this.dualOptions.has(c))return!0;let r=this.negativeOptions.get(c).presetArg,i=r!==void 0?r:!1;return a.negate===(i===e)}}function Xe(e){return e.split("-").reduce((a,c)=>{return a+c[0].toUpperCase()+c.slice(1)})}function qc(e){let a,c,r=/^-[^-]$/,i=/^--[^-]/,n=e.split(/[ |,]+/).concat("guard");if(r.test(n[0]))a=n.shift();if(i.test(n[0]))c=n.shift();if(!a&&r.test(n[0]))a=n.shift();if(!a&&i.test(n[0]))a=c,c=n.shift();if(n[0].startsWith("-")){let t=n[0],o=`option creation failed due to '${t}' in option flags '${e}'`;if(/^-[^-][^-]/.test(t))throw new Error(`${o} - a short flag is a single dash and a single character - either use a single dash and a single character (for a short flag) - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(r.test(t))throw new Error(`${o} - too many short flags`);if(i.test(t))throw new Error(`${o} - too many long flags`);throw new Error(`${o} - unrecognised flag format`)}if(a===void 0&&c===void 0)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:a,longFlag:c}}Te.Option=Je;Te.DualOptions=Oe});var De=b((Fe)=>{function zc(e,a){if(Math.abs(e.length-a.length)>3)return Math.max(e.length,a.length);let c=[];for(let r=0;r<=e.length;r++)c[r]=[r];for(let r=0;r<=a.length;r++)c[0][r]=r;for(let r=1;r<=a.length;r++)for(let i=1;i<=e.length;i++){let n=1;if(e[i-1]===a[r-1])n=0;else n=1;if(c[i][r]=Math.min(c[i-1][r]+1,c[i][r-1]+1,c[i-1][r-1]+n),i>1&&r>1&&e[i-1]===a[r-2]&&e[i-2]===a[r-1])c[i][r]=Math.min(c[i][r],c[i-2][r-2]+1)}return c[e.length][a.length]}function Gc(e,a){if(!a||a.length===0)return"";a=Array.from(new Set(a));let c=e.startsWith("--");if(c)e=e.slice(2),a=a.map((t)=>t.slice(2));let r=[],i=3,n=0.4;if(a.forEach((t)=>{if(t.length<=1)return;let o=zc(e,t),s=Math.max(e.length,t.length);if((s-o)/s>n){if(o<i)i=o,r=[t];else if(o===i)r.push(t)}}),r.sort((t,o)=>t.localeCompare(o)),c)r=r.map((t)=>`--${t}`);if(r.length>1)return` (Did you mean one of ${r.join(", ")}?)`;if(r.length===1)return` (Did you mean ${r[0]}?)`;return""}Fe.suggestSimilar=Gc});var ca=b((ye)=>{var jc=require("node:events").EventEmitter,xe=require("node:child_process"),I=require("node:path"),j=require("node:fs"),h=require("node:process"),{Argument:Kc,humanReadableArgName:Wc}=G(),{CommanderError:le}=k(),{Help:$c,stripColor:Yc}=oe(),{Option:ea,DualOptions:Vc}=se(),{suggestSimilar:aa}=De();class ge extends jc{constructor(e){super();this.commands=[],this.options=[],this.parent=null,this._allowUnknownOption=!1,this._allowExcessArguments=!1,this.registeredArguments=[],this._args=this.registeredArguments,this.args=[],this.rawArgs=[],this.processedArgs=[],this._scriptPath=null,this._name=e||"",this._optionValues={},this._optionValueSources={},this._storeOptionsAsProperties=!1,this._actionHandler=null,this._executableHandler=!1,this._executableFile=null,this._executableDir=null,this._defaultCommandName=null,this._exitCallback=null,this._aliases=[],this._combineFlagAndOptionalValue=!0,this._description="",this._summary="",this._argsDescription=void 0,this._enablePositionalOptions=!1,this._passThroughOptions=!1,this._lifeCycleHooks={},this._showHelpAfterError=!1,this._showSuggestionAfterError=!0,this._savedState=null,this._outputConfiguration={writeOut:(a)=>h.stdout.write(a),writeErr:(a)=>h.stderr.write(a),outputError:(a,c)=>c(a),getOutHelpWidth:()=>h.stdout.isTTY?h.stdout.columns:void 0,getErrHelpWidth:()=>h.stderr.isTTY?h.stderr.columns:void 0,getOutHasColors:()=>he()??(h.stdout.isTTY&&h.stdout.hasColors?.()),getErrHasColors:()=>he()??(h.stderr.isTTY&&h.stderr.hasColors?.()),stripColor:(a)=>Yc(a)},this._hidden=!1,this._helpOption=void 0,this._addImplicitHelpCommand=void 0,this._helpCommand=void 0,this._helpConfiguration={},this._helpGroupHeading=void 0,this._defaultCommandGroup=void 0,this._defaultOptionGroup=void 0}copyInheritedSettings(e){return this._outputConfiguration=e._outputConfiguration,this._helpOption=e._helpOption,this._helpCommand=e._helpCommand,this._helpConfiguration=e._helpConfiguration,this._exitCallback=e._exitCallback,this._storeOptionsAsProperties=e._storeOptionsAsProperties,this._combineFlagAndOptionalValue=e._combineFlagAndOptionalValue,this._allowExcessArguments=e._allowExcessArguments,this._enablePositionalOptions=e._enablePositionalOptions,this._showHelpAfterError=e._showHelpAfterError,this._showSuggestionAfterError=e._showSuggestionAfterError,this}_getCommandAndAncestors(){let e=[];for(let a=this;a;a=a.parent)e.push(a);return e}command(e,a,c){let r=a,i=c;if(typeof r==="object"&&r!==null)i=r,r=null;i=i||{};let[,n,t]=e.match(/([^ ]+) *(.*)/),o=this.createCommand(n);if(r)o.description(r),o._executableHandler=!0;if(i.isDefault)this._defaultCommandName=o._name;if(o._hidden=!!(i.noHelp||i.hidden),o._executableFile=i.executableFile||null,t)o.arguments(t);if(this._registerCommand(o),o.parent=this,o.copyInheritedSettings(this),r)return this;return o}createCommand(e){return new ge(e)}createHelp(){return Object.assign(new $c,this.configureHelp())}configureHelp(e){if(e===void 0)return this._helpConfiguration;return this._helpConfiguration=e,this}configureOutput(e){if(e===void 0)return this._outputConfiguration;return this._outputConfiguration=Object.assign({},this._outputConfiguration,e),this}showHelpAfterError(e=!0){if(typeof e!=="string")e=!!e;return this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,a){if(!e._name)throw new Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);if(a=a||{},a.isDefault)this._defaultCommandName=e._name;if(a.noHelp||a.hidden)e._hidden=!0;return this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,a){return new Kc(e,a)}argument(e,a,c,r){let i=this.createArgument(e,a);if(typeof c==="function")i.default(r).argParser(c);else i.default(c);return this.addArgument(i),this}arguments(e){return e.trim().split(/ +/).forEach((a)=>{this.argument(a)}),this}addArgument(e){let a=this.registeredArguments.slice(-1)[0];if(a&&a.variadic)throw new Error(`only the last argument can be variadic '${a.name()}'`);if(e.required&&e.defaultValue!==void 0&&e.parseArg===void 0)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,a){if(typeof e==="boolean"){if(this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let c=e??"help [command]",[,r,i]=c.match(/([^ ]+) *(.*)/),n=a??"display help for command",t=this.createCommand(r);if(t.helpOption(!1),i)t.arguments(i);if(n)t.description(n);if(this._addImplicitHelpCommand=!0,this._helpCommand=t,e||a)this._initCommandGroup(t);return this}addHelpCommand(e,a){if(typeof e!=="object")return this.helpCommand(e,a),this;return this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this}_getHelpCommand(){if(this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))){if(this._helpCommand===void 0)this.helpCommand(void 0,void 0);return this._helpCommand}return null}hook(e,a){let c=["preSubcommand","preAction","postAction"];if(!c.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'. Expecting one of '${c.join("', '")}'`);if(this._lifeCycleHooks[e])this._lifeCycleHooks[e].push(a);else this._lifeCycleHooks[e]=[a];return this}exitOverride(e){if(e)this._exitCallback=e;else this._exitCallback=(a)=>{if(a.code!=="commander.executeSubCommandAsync")throw a};return this}_exit(e,a,c){if(this._exitCallback)this._exitCallback(new le(e,a,c));h.exit(e)}action(e){let a=(c)=>{let r=this.registeredArguments.length,i=c.slice(0,r);if(this._storeOptionsAsProperties)i[r]=this;else i[r]=this.opts();return i.push(this),e.apply(this,i)};return this._actionHandler=a,this}createOption(e,a){return new ea(e,a)}_callParseArg(e,a,c,r){try{return e.parseArg(a,c)}catch(i){if(i.code==="commander.invalidArgument"){let n=`${r} ${i.message}`;this.error(n,{exitCode:i.exitCode,code:i.code})}throw i}}_registerOption(e){let a=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(a){let c=e.long&&this._findOption(e.long)?e.long:e.short;throw new Error(`Cannot add option '${e.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${c}' - already used by option '${a.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){let a=(r)=>{return[r.name()].concat(r.aliases())},c=a(e).find((r)=>this._findCommand(r));if(c){let r=a(this._findCommand(c)).join("|"),i=a(e).join("|");throw new Error(`cannot add command '${i}' as already have command '${r}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);let a=e.name(),c=e.attributeName();if(e.negate){let i=e.long.replace(/^--no-/,"--");if(!this._findOption(i))this.setOptionValueWithSource(c,e.defaultValue===void 0?!0:e.defaultValue,"default")}else if(e.defaultValue!==void 0)this.setOptionValueWithSource(c,e.defaultValue,"default");let r=(i,n,t)=>{if(i==null&&e.presetArg!==void 0)i=e.presetArg;let o=this.getOptionValue(c);if(i!==null&&e.parseArg)i=this._callParseArg(e,i,o,n);else if(i!==null&&e.variadic)i=e._concatValue(i,o);if(i==null)if(e.negate)i=!1;else if(e.isBoolean()||e.optional)i=!0;else i="";this.setOptionValueWithSource(c,i,t)};if(this.on("option:"+a,(i)=>{let n=`error: option '${e.flags}' argument '${i}' is invalid.`;r(i,n,"cli")}),e.envVar)this.on("optionEnv:"+a,(i)=>{let n=`error: option '${e.flags}' value '${i}' from env '${e.envVar}' is invalid.`;r(i,n,"env")});return this}_optionEx(e,a,c,r,i){if(typeof a==="object"&&a instanceof ea)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");let n=this.createOption(a,c);if(n.makeOptionMandatory(!!e.mandatory),typeof r==="function")n.default(i).argParser(r);else if(r instanceof RegExp){let t=r;r=(o,s)=>{let T=t.exec(o);return T?T[0]:s},n.default(i).argParser(r)}else n.default(r);return this.addOption(n)}option(e,a,c,r){return this._optionEx({},e,a,c,r)}requiredOption(e,a,c,r){return this._optionEx({mandatory:!0},e,a,c,r)}combineFlagAndOptionalValue(e=!0){return this._combineFlagAndOptionalValue=!!e,this}allowUnknownOption(e=!0){return this._allowUnknownOption=!!e,this}allowExcessArguments(e=!0){return this._allowExcessArguments=!!e,this}enablePositionalOptions(e=!0){return this._enablePositionalOptions=!!e,this}passThroughOptions(e=!0){return this._passThroughOptions=!!e,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw new Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(e=!0){if(this.options.length)throw new Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw new Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!e,this}getOptionValue(e){if(this._storeOptionsAsProperties)return this[e];return this._optionValues[e]}setOptionValue(e,a){return this.setOptionValueWithSource(e,a,void 0)}setOptionValueWithSource(e,a,c){if(this._storeOptionsAsProperties)this[e]=a;else this._optionValues[e]=a;return this._optionValueSources[e]=c,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let a;return this._getCommandAndAncestors().forEach((c)=>{if(c.getOptionValueSource(e)!==void 0)a=c.getOptionValueSource(e)}),a}_prepareUserArgs(e,a){if(e!==void 0&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(a=a||{},e===void 0&&a.from===void 0){if(h.versions?.electron)a.from="electron";let r=h.execArgv??[];if(r.includes("-e")||r.includes("--eval")||r.includes("-p")||r.includes("--print"))a.from="eval"}if(e===void 0)e=h.argv;this.rawArgs=e.slice();let c;switch(a.from){case void 0:case"node":this._scriptPath=e[1],c=e.slice(2);break;case"electron":if(h.defaultApp)this._scriptPath=e[1],c=e.slice(2);else c=e.slice(1);break;case"user":c=e.slice(0);break;case"eval":c=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${a.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",c}parse(e,a){this._prepareForParse();let c=this._prepareUserArgs(e,a);return this._parseCommand([],c),this}async parseAsync(e,a){this._prepareForParse();let c=this._prepareUserArgs(e,a);return await this._parseCommand([],c),this}_prepareForParse(){if(this._savedState===null)this.saveStateBeforeParse();else this.restoreStateBeforeParse()}saveStateBeforeParse(){this._savedState={_name:this._name,_optionValues:{...this._optionValues},_optionValueSources:{...this._optionValueSources}}}restoreStateBeforeParse(){if(this._storeOptionsAsProperties)throw new Error(`Can not call parse again when storeOptionsAsProperties is true. - either make a new Command for each call to parse, or stop storing options as properties`);this._name=this._savedState._name,this._scriptPath=null,this.rawArgs=[],this._optionValues={...this._savedState._optionValues},this._optionValueSources={...this._savedState._optionValueSources},this.args=[],this.processedArgs=[]}_checkForMissingExecutable(e,a,c){if(j.existsSync(e))return;let r=a?`searched for local subcommand relative to directory '${a}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",i=`'${e}' does not exist - if '${c}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead - if the default executable name is not suitable, use the executableFile option to supply a custom name or path - ${r}`;throw new Error(i)}_executeSubCommand(e,a){a=a.slice();let c=!1,r=[".js",".ts",".tsx",".mjs",".cjs"];function i(T,x){let l=I.resolve(T,x);if(j.existsSync(l))return l;if(r.includes(I.extname(x)))return;let f=r.find((m)=>j.existsSync(`${l}${m}`));if(f)return`${l}${f}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let n=e._executableFile||`${this._name}-${e._name}`,t=this._executableDir||"";if(this._scriptPath){let T;try{T=j.realpathSync(this._scriptPath)}catch{T=this._scriptPath}t=I.resolve(I.dirname(T),t)}if(t){let T=i(t,n);if(!T&&!e._executableFile&&this._scriptPath){let x=I.basename(this._scriptPath,I.extname(this._scriptPath));if(x!==this._name)T=i(t,`${x}-${e._name}`)}n=T||n}c=r.includes(I.extname(n));let o;if(h.platform!=="win32")if(c)a.unshift(n),a=ta(h.execArgv).concat(a),o=xe.spawn(h.argv[0],a,{stdio:"inherit"});else o=xe.spawn(n,a,{stdio:"inherit"});else this._checkForMissingExecutable(n,t,e._name),a.unshift(n),a=ta(h.execArgv).concat(a),o=xe.spawn(h.execPath,a,{stdio:"inherit"});if(!o.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((x)=>{h.on(x,()=>{if(o.killed===!1&&o.exitCode===null)o.kill(x)})});let s=this._exitCallback;o.on("close",(T)=>{if(T=T??1,!s)h.exit(T);else s(new le(T,"commander.executeSubCommandAsync","(close)"))}),o.on("error",(T)=>{if(T.code==="ENOENT")this._checkForMissingExecutable(n,t,e._name);else if(T.code==="EACCES")throw new Error(`'${n}' not executable`);if(!s)h.exit(1);else{let x=new le(1,"commander.executeSubCommandAsync","(error)");x.nestedError=T,s(x)}}),this.runningCommand=o}_dispatchSubcommand(e,a,c){let r=this._findCommand(e);if(!r)this.help({error:!0});r._prepareForParse();let i;return i=this._chainOrCallSubCommandHook(i,r,"preSubcommand"),i=this._chainOrCall(i,()=>{if(r._executableHandler)this._executeSubCommand(r,a.concat(c));else return r._parseCommand(a,c)}),i}_dispatchHelpCommand(e){if(!e)this.help();let a=this._findCommand(e);if(a&&!a._executableHandler)a.help();return this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((e,a)=>{if(e.required&&this.args[a]==null)this.missingArgument(e.name())}),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic)return;if(this.args.length>this.registeredArguments.length)this._excessArguments(this.args)}_processArguments(){let e=(c,r,i)=>{let n=r;if(r!==null&&c.parseArg){let t=`error: command-argument value '${r}' is invalid for argument '${c.name()}'.`;n=this._callParseArg(c,r,i,t)}return n};this._checkNumberOfArguments();let a=[];this.registeredArguments.forEach((c,r)=>{let i=c.defaultValue;if(c.variadic){if(r<this.args.length){if(i=this.args.slice(r),c.parseArg)i=i.reduce((n,t)=>{return e(c,t,n)},c.defaultValue)}else if(i===void 0)i=[]}else if(r<this.args.length){if(i=this.args[r],c.parseArg)i=e(c,i,c.defaultValue)}a[r]=i}),this.processedArgs=a}_chainOrCall(e,a){if(e&&e.then&&typeof e.then==="function")return e.then(()=>a());return a()}_chainOrCallHooks(e,a){let c=e,r=[];if(this._getCommandAndAncestors().reverse().filter((i)=>i._lifeCycleHooks[a]!==void 0).forEach((i)=>{i._lifeCycleHooks[a].forEach((n)=>{r.push({hookedCommand:i,callback:n})})}),a==="postAction")r.reverse();return r.forEach((i)=>{c=this._chainOrCall(c,()=>{return i.callback(i.hookedCommand,this)})}),c}_chainOrCallSubCommandHook(e,a,c){let r=e;if(this._lifeCycleHooks[c]!==void 0)this._lifeCycleHooks[c].forEach((i)=>{r=this._chainOrCall(r,()=>{return i(this,a)})});return r}_parseCommand(e,a){let c=this.parseOptions(a);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(c.operands),a=c.unknown,this.args=e.concat(a),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),a);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(a),this._dispatchSubcommand(this._defaultCommandName,e,a);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(c.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let r=()=>{if(c.unknown.length>0)this.unknownOption(c.unknown[0])},i=`command:${this.name()}`;if(this._actionHandler){r(),this._processArguments();let n;if(n=this._chainOrCallHooks(n,"preAction"),n=this._chainOrCall(n,()=>this._actionHandler(this.processedArgs)),this.parent)n=this._chainOrCall(n,()=>{this.parent.emit(i,e,a)});return n=this._chainOrCallHooks(n,"postAction"),n}if(this.parent&&this.parent.listenerCount(i))r(),this._processArguments(),this.parent.emit(i,e,a);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,a);if(this.listenerCount("command:*"))this.emit("command:*",e,a);else if(this.commands.length)this.unknownCommand();else r(),this._processArguments()}else if(this.commands.length)r(),this.help({error:!0});else r(),this._processArguments()}_findCommand(e){if(!e)return;return this.commands.find((a)=>a._name===e||a._aliases.includes(e))}_findOption(e){return this.options.find((a)=>a.is(e))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e)=>{e.options.forEach((a)=>{if(a.mandatory&&e.getOptionValue(a.attributeName())===void 0)e.missingMandatoryOptionValue(a)})})}_checkForConflictingLocalOptions(){let e=this.options.filter((c)=>{let r=c.attributeName();if(this.getOptionValue(r)===void 0)return!1;return this.getOptionValueSource(r)!=="default"});e.filter((c)=>c.conflictsWith.length>0).forEach((c)=>{let r=e.find((i)=>c.conflictsWith.includes(i.attributeName()));if(r)this._conflictingOption(c,r)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e)=>{e._checkForConflictingLocalOptions()})}parseOptions(e){let a=[],c=[],r=a,i=e.slice();function n(s){return s.length>1&&s[0]==="-"}let t=(s)=>{if(!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(s))return!1;return!this._getCommandAndAncestors().some((T)=>T.options.map((x)=>x.short).some((x)=>/^-\d$/.test(x)))},o=null;while(i.length){let s=i.shift();if(s==="--"){if(r===c)r.push(s);r.push(...i);break}if(o&&(!n(s)||t(s))){this.emit(`option:${o.name()}`,s);continue}if(o=null,n(s)){let T=this._findOption(s);if(T){if(T.required){let x=i.shift();if(x===void 0)this.optionMissingArgument(T);this.emit(`option:${T.name()}`,x)}else if(T.optional){let x=null;if(i.length>0&&(!n(i[0])||t(i[0])))x=i.shift();this.emit(`option:${T.name()}`,x)}else this.emit(`option:${T.name()}`);o=T.variadic?T:null;continue}}if(s.length>2&&s[0]==="-"&&s[1]!=="-"){let T=this._findOption(`-${s[1]}`);if(T){if(T.required||T.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${T.name()}`,s.slice(2));else this.emit(`option:${T.name()}`),i.unshift(`-${s.slice(2)}`);continue}}if(/^--[^=]+=/.test(s)){let T=s.indexOf("="),x=this._findOption(s.slice(0,T));if(x&&(x.required||x.optional)){this.emit(`option:${x.name()}`,s.slice(T+1));continue}}if(r===a&&n(s)&&!(this.commands.length===0&&t(s)))r=c;if((this._enablePositionalOptions||this._passThroughOptions)&&a.length===0&&c.length===0){if(this._findCommand(s)){if(a.push(s),i.length>0)c.push(...i);break}else if(this._getHelpCommand()&&s===this._getHelpCommand().name()){if(a.push(s),i.length>0)a.push(...i);break}else if(this._defaultCommandName){if(c.push(s),i.length>0)c.push(...i);break}}if(this._passThroughOptions){if(r.push(s),i.length>0)r.push(...i);break}r.push(s)}return{operands:a,unknown:c}}opts(){if(this._storeOptionsAsProperties){let e={},a=this.options.length;for(let c=0;c<a;c++){let r=this.options[c].attributeName();e[r]=r===this._versionOptionName?this._version:this[r]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((e,a)=>Object.assign(e,a.opts()),{})}error(e,a){if(this._outputConfiguration.outputError(`${e} `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError} `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(` `),this.outputHelp({error:!0});let c=a||{},r=c.exitCode||1,i=c.code||"commander.error";this._exit(r,i,e)}_parseOptionsEnv(){this.options.forEach((e)=>{if(e.envVar&&e.envVar in h.env){let a=e.attributeName();if(this.getOptionValue(a)===void 0||["default","config","env"].includes(this.getOptionValueSource(a)))if(e.required||e.optional)this.emit(`optionEnv:${e.name()}`,h.env[e.envVar]);else this.emit(`optionEnv:${e.name()}`)}})}_parseOptionsImplied(){let e=new Vc(this.options),a=(c)=>{return this.getOptionValue(c)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(c))};this.options.filter((c)=>c.implied!==void 0&&a(c.attributeName())&&e.valueFromOption(this.getOptionValue(c.attributeName()),c)).forEach((c)=>{Object.keys(c.implied).filter((r)=>!a(r)).forEach((r)=>{this.setOptionValueWithSource(r,c.implied[r],"implied")})})}missingArgument(e){let a=`error: missing required argument '${e}'`;this.error(a,{code:"commander.missingArgument"})}optionMissingArgument(e){let a=`error: option '${e.flags}' argument missing`;this.error(a,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let a=`error: required option '${e.flags}' not specified`;this.error(a,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,a){let c=(n)=>{let t=n.attributeName(),o=this.getOptionValue(t),s=this.options.find((x)=>x.negate&&t===x.attributeName()),T=this.options.find((x)=>!x.negate&&t===x.attributeName());if(s&&(s.presetArg===void 0&&o===!1||s.presetArg!==void 0&&o===s.presetArg))return s;return T||n},r=(n)=>{let t=c(n),o=t.attributeName();if(this.getOptionValueSource(o)==="env")return`environment variable '${t.envVar}'`;return`option '${t.flags}'`},i=`error: ${r(e)} cannot be used with ${r(a)}`;this.error(i,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let a="";if(e.startsWith("--")&&this._showSuggestionAfterError){let r=[],i=this;do{let n=i.createHelp().visibleOptions(i).filter((t)=>t.long).map((t)=>t.long);r=r.concat(n),i=i.parent}while(i&&!i._enablePositionalOptions);a=aa(e,r)}let c=`error: unknown option '${e}'${a}`;this.error(c,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let a=this.registeredArguments.length,c=a===1?"":"s",i=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${a} argument${c} but got ${e.length}.`;this.error(i,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],a="";if(this._showSuggestionAfterError){let r=[];this.createHelp().visibleCommands(this).forEach((i)=>{if(r.push(i.name()),i.alias())r.push(i.alias())}),a=aa(e,r)}let c=`error: unknown command '${e}'${a}`;this.error(c,{code:"commander.unknownCommand"})}version(e,a,c){if(e===void 0)return this._version;this._version=e,a=a||"-V, --version",c=c||"output the version number";let r=this.createOption(a,c);return this._versionOptionName=r.attributeName(),this._registerOption(r),this.on("option:"+r.name(),()=>{this._outputConfiguration.writeOut(`${e} `),this._exit(0,"commander.version",e)}),this}description(e,a){if(e===void 0&&a===void 0)return this._description;if(this._description=e,a)this._argsDescription=a;return this}summary(e){if(e===void 0)return this._summary;return this._summary=e,this}alias(e){if(e===void 0)return this._aliases[0];let a=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)a=this.commands[this.commands.length-1];if(e===a._name)throw new Error("Command alias can't be the same as its name");let c=this.parent?._findCommand(e);if(c){let r=[c.name()].concat(c.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${r}'`)}return a._aliases.push(e),this}aliases(e){if(e===void 0)return this._aliases;return e.forEach((a)=>this.alias(a)),this}usage(e){if(e===void 0){if(this._usage)return this._usage;let a=this.registeredArguments.map((c)=>{return Wc(c)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?a:[]).join(" ")}return this._usage=e,this}name(e){if(e===void 0)return this._name;return this._name=e,this}helpGroup(e){if(e===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=e,this}commandsGroup(e){if(e===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=e,this}optionsGroup(e){if(e===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=e,this}_initOptionGroup(e){if(this._defaultOptionGroup&&!e.helpGroupHeading)e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){if(this._defaultCommandGroup&&!e.helpGroup())e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=I.basename(e,I.extname(e)),this}executableDir(e){if(e===void 0)return this._executableDir;return this._executableDir=e,this}helpInformation(e){let a=this.createHelp(),c=this._getOutputContext(e);a.prepareContext({error:c.error,helpWidth:c.helpWidth,outputHasColors:c.hasColors});let r=a.formatHelp(this,a);if(c.hasColors)return r;return this._outputConfiguration.stripColor(r)}_getOutputContext(e){e=e||{};let a=!!e.error,c,r,i;if(a)c=(t)=>this._outputConfiguration.writeErr(t),r=this._outputConfiguration.getErrHasColors(),i=this._outputConfiguration.getErrHelpWidth();else c=(t)=>this._outputConfiguration.writeOut(t),r=this._outputConfiguration.getOutHasColors(),i=this._outputConfiguration.getOutHelpWidth();return{error:a,write:(t)=>{if(!r)t=this._outputConfiguration.stripColor(t);return c(t)},hasColors:r,helpWidth:i}}outputHelp(e){let a;if(typeof e==="function")a=e,e=void 0;let c=this._getOutputContext(e),r={error:c.error,write:c.write,command:this};this._getCommandAndAncestors().reverse().forEach((n)=>n.emit("beforeAllHelp",r)),this.emit("beforeHelp",r);let i=this.helpInformation({error:c.error});if(a){if(i=a(i),typeof i!=="string"&&!Buffer.isBuffer(i))throw new Error("outputHelp callback must return a string or a Buffer")}if(c.write(i),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",r),this._getCommandAndAncestors().forEach((n)=>n.emit("afterAllHelp",r))}helpOption(e,a){if(typeof e==="boolean"){if(e){if(this._helpOption===null)this._helpOption=void 0;if(this._defaultOptionGroup)this._initOptionGroup(this._getHelpOption())}else this._helpOption=null;return this}if(this._helpOption=this.createOption(e??"-h, --help",a??"display help for command"),e||a)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let a=Number(h.exitCode??0);if(a===0&&e&&typeof e!=="function"&&e.error)a=1;this._exit(a,"commander.help","(outputHelp)")}addHelpText(e,a){let c=["beforeAll","before","after","afterAll"];if(!c.includes(e))throw new Error(`Unexpected value for position to addHelpText. Expecting one of '${c.join("', '")}'`);let r=`${e}Help`;return this.on(r,(i)=>{let n;if(typeof a==="function")n=a({error:i.error,command:i.command});else n=a;if(n)i.write(`${n} `)}),this}_outputHelpIfRequested(e){let a=this._getHelpOption();if(a&&e.find((r)=>a.is(r)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function ta(e){return e.map((a)=>{if(!a.startsWith("--inspect"))return a;let c,r="127.0.0.1",i="9229",n;if((n=a.match(/^(--inspect(-brk)?)$/))!==null)c=n[1];else if((n=a.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(c=n[1],/^\d+$/.test(n[3]))i=n[3];else r=n[3];else if((n=a.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)c=n[1],r=n[3],i=n[4];if(c&&i!=="0")return`${c}=${r}:${parseInt(i)+1}`;return a})}function he(){if(h.env.NO_COLOR||h.env.FORCE_COLOR==="0"||h.env.FORCE_COLOR==="false")return!1;if(h.env.FORCE_COLOR||h.env.CLICOLOR_FORCE!==void 0)return!0;return}ye.Command=ge;ye.useColor=he});var oa=b((P)=>{var{Argument:ra}=G(),{Command:pe}=ca(),{CommanderError:Qc,InvalidArgumentError:ia}=k(),{Help:Zc}=oe(),{Option:na}=se();P.program=new pe;P.createCommand=(e)=>new pe(e);P.createOption=(e,a)=>new na(e,a);P.createArgument=(e,a)=>new ra(e,a);P.Command=pe;P.Option=na;P.Argument=ra;P.Help=Zc;P.CommanderError=Qc;P.InvalidArgumentError=ia;P.InvalidOptionArgumentError=ia});var la=b((gi,xa)=>{xa.exports=(e)=>{if(typeof e!=="object"||e===null)throw new TypeError("Expected an object");let a={};for(let[c,r]of Object.entries(e))a[r]=c;for(let c of Object.getOwnPropertySymbols(e)){let r=e[c];a[r]=c}return a}});var ha=b((yi,Xc)=>{Xc.exports={"4":"zh_CHS","1025":"ar_SA","1026":"bg_BG","1027":"ca_ES","1028":"zh_TW","1029":"cs_CZ","1030":"da_DK","1031":"de_DE","1032":"el_GR","1033":"en_US","1034":"es_ES","1035":"fi_FI","1036":"fr_FR","1037":"he_IL","1038":"hu_HU","1039":"is_IS","1040":"it_IT","1041":"ja_JP","1042":"ko_KR","1043":"nl_NL","1044":"nb_NO","1045":"pl_PL","1046":"pt_BR","1047":"rm_CH","1048":"ro_RO","1049":"ru_RU","1050":"hr_HR","1051":"sk_SK","1052":"sq_AL","1053":"sv_SE","1054":"th_TH","1055":"tr_TR","1056":"ur_PK","1057":"id_ID","1058":"uk_UA","1059":"be_BY","1060":"sl_SI","1061":"et_EE","1062":"lv_LV","1063":"lt_LT","1064":"tg_TJ","1065":"fa_IR","1066":"vi_VN","1067":"hy_AM","1069":"eu_ES","1070":"wen_DE","1071":"mk_MK","1074":"tn_ZA","1076":"xh_ZA","1077":"zu_ZA","1078":"af_ZA","1079":"ka_GE","1080":"fo_FO","1081":"hi_IN","1082":"mt_MT","1083":"se_NO","1086":"ms_MY","1087":"kk_KZ","1088":"ky_KG","1089":"sw_KE","1090":"tk_TM","1092":"tt_RU","1093":"bn_IN","1094":"pa_IN","1095":"gu_IN","1096":"or_IN","1097":"ta_IN","1098":"te_IN","1099":"kn_IN","1100":"ml_IN","1101":"as_IN","1102":"mr_IN","1103":"sa_IN","1104":"mn_MN","1105":"bo_CN","1106":"cy_GB","1107":"kh_KH","1108":"lo_LA","1109":"my_MM","1110":"gl_ES","1111":"kok_IN","1114":"syr_SY","1115":"si_LK","1118":"am_ET","1121":"ne_NP","1122":"fy_NL","1123":"ps_AF","1124":"fil_PH","1125":"div_MV","1128":"ha_NG","1130":"yo_NG","1131":"quz_BO","1132":"ns_ZA","1133":"ba_RU","1134":"lb_LU","1135":"kl_GL","1144":"ii_CN","1146":"arn_CL","1148":"moh_CA","1150":"br_FR","1152":"ug_CN","1153":"mi_NZ","1154":"oc_FR","1155":"co_FR","1156":"gsw_FR","1157":"sah_RU","1158":"qut_GT","1159":"rw_RW","1160":"wo_SN","1164":"gbz_AF","2049":"ar_IQ","2052":"zh_CN","2055":"de_CH","2057":"en_GB","2058":"es_MX","2060":"fr_BE","2064":"it_CH","2067":"nl_BE","2068":"nn_NO","2070":"pt_PT","2077":"sv_FI","2080":"ur_IN","2092":"az_AZ","2094":"dsb_DE","2107":"se_SE","2108":"ga_IE","2110":"ms_BN","2115":"uz_UZ","2128":"mn_CN","2129":"bo_BT","2141":"iu_CA","2143":"tmz_DZ","2155":"quz_EC","3073":"ar_EG","3076":"zh_HK","3079":"de_AT","3081":"en_AU","3082":"es_ES","3084":"fr_CA","3098":"sr_SP","3131":"se_FI","3179":"quz_PE","4097":"ar_LY","4100":"zh_SG","4103":"de_LU","4105":"en_CA","4106":"es_GT","4108":"fr_CH","4122":"hr_BA","4155":"smj_NO","5121":"ar_DZ","5124":"zh_MO","5127":"de_LI","5129":"en_NZ","5130":"es_CR","5132":"fr_LU","5179":"smj_SE","6145":"ar_MA","6153":"en_IE","6154":"es_PA","6156":"fr_MC","6203":"sma_NO","7169":"ar_TN","7177":"en_ZA","7178":"es_DO","7194":"sr_BA","7227":"sma_SE","8193":"ar_OM","8201":"en_JA","8202":"es_VE","8218":"bs_BA","8251":"sms_FI","9217":"ar_YE","9225":"en_CB","9226":"es_CO","9275":"smn_FI","10241":"ar_SY","10249":"en_BZ","10250":"es_PE","11265":"ar_JO","11273":"en_TT","11274":"es_AR","12289":"ar_LB","12297":"en_ZW","12298":"es_EC","13313":"ar_KW","13321":"en_PH","13322":"es_CL","14337":"ar_AE","14346":"es_UR","15361":"ar_BH","15370":"es_PY","16385":"ar_QA","16394":"es_BO","17417":"en_MY","17418":"es_SV","18441":"en_IN","18442":"es_HN","19466":"es_NI","20490":"es_PR","21514":"es_US","31748":"zh_CHT"}});var ya=b((K)=>{var Jc=la(),ga=ha(),de=Jc(ga);K.from=(e)=>{if(typeof e!=="number")throw new TypeError("Expected a number");return ga[e]};K.to=(e)=>{if(typeof e!=="string")throw new TypeError("Expected a string");if(de[e])return Number(de[e])};K.all=new Proxy(de,{get(e,a){let c=e[a];if(c)return Number(c)}})});var vt={};Zt(vt,{getWindowsCursorIdeInstallPathMethod2:()=>pr,getWindowsCursorIdeInstallPathMethod1:()=>yr});async function yr(){let e=String.raw`HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\{DADADADA-ADAD-ADAD-ADAD-ADADADADADAD}}_is1`,a=await be([e]);if(!a[e]?.values)throw new Error("Specified registry key not found");let c=a[e].values,r=c.DisplayIcon?.value;if(!r||typeof r!=="string"||!r.toLowerCase().endsWith("cursor\\cursor.exe"))throw new Error("Invalid Cursor IDE DisplayIcon");let i=c.InstallLocation?.value;if(!i)throw new Error("InstallLocation not found");if(!Bt.existsSync(i))throw new Error("Installation path does not exist");return i}async function pr(){try{let e=String.raw`HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall`,a=await be([e]);if(!a[e]?.keys)throw new Error("Registry path not found");for(let c of a[e].keys){let r=`${e}\\${c}`,n=(await be([r]))[r]?.values;if(n?.DisplayIcon?.value){let t=n.DisplayIcon.value;if(t.toLowerCase().endsWith("cursor\\cursor.exe"))return t.replace("\\Cursor.exe","")}}throw new Error("Cursor IDE installation path not found")}catch(e){throw console.error("Error occurred during registry search:",e),e}}var Bt,Lt,be=(e)=>{return new Promise((a,c)=>{Lt.default.list(e,(r,i)=>{if(r)c(r);else a(i)})})};var Ut=Xt(()=>{Bt=require("fs"),Lt=A(require("regedit"))});var C=A(Z()),U=require("node:process");var F=A(require("node:readline")),Le=require("node:stream");function ac({onlyFirst:e=!1}={}){let a=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");return new RegExp(a,e?void 0:"g")}var tc=ac();function ve(e){if(typeof e!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(tc,"")}function Ue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}