UNPKG

ulysse

Version:

A simple CLI tool for blocking your distracting apps and websites

2 lines 397 kB
#!/usr/bin/env node var e=require("node:events"),t=require("node:child_process"),i=require("node:path"),n=require("node:fs"),r=require("node:process"),o=require("assert"),s=require("events"),c=require("readline"),a=require("fs"),d=require("net"),l=require("path"),_=require("crypto"),u=require("child_process"),p=require("dgram"),T=require("buffer"),E=require("os"),A=require("util");function h(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var L,I,R={},m={},f={};function C(){if(L)return f;L=1;class e extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}}return f.CommanderError=e,f.InvalidArgumentError=class extends e{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}},f}function S(){if(I)return m;I=1;const{InvalidArgumentError:e}=C();return m.Argument=class{constructor(e,t){switch(this.description=t||"",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}this._name.length>3&&"..."===this._name.slice(-3)&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}},m.humanReadableArgName=function(e){const t=e.name()+(!0===e.variadic?"...":"");return e.required?"<"+t+">":"["+t+"]"},m}var N,K={},O={};function g(){if(N)return O;N=1;const{humanReadableArgName:e}=S();function t(e){return e.replace(/\x1b\[\d*(;\d*)*m/g,"")}return O.Help=class{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){const t=e.commands.filter((e=>!e._hidden)),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort(((e,t)=>e.name().localeCompare(t.name()))),t}compareOptions(e,t){const i=e=>e.short?e.short.replace(/^-/,""):e.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){const t=e.options.filter((e=>!e.hidden)),i=e._getHelpOption();if(i&&!i.hidden){const n=i.short&&e._findOption(i.short),r=i.long&&e._findOption(i.long);n||r?i.long&&!r?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description)):t.push(i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];const t=[];for(let i=e.parent;i;i=i.parent){const e=i.options.filter((e=>!e.hidden));t.push(...e)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach((t=>{t.description=t.description||e._argsDescription[t.name()]||""})),e.registeredArguments.find((e=>e.description))?e.registeredArguments:[]}subcommandTerm(t){const i=t.registeredArguments.map((t=>e(t))).join(" ");return t._name+(t._aliases[0]?"|"+t._aliases[0]:"")+(t.options.length?" [options]":"")+(i?" "+i:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce(((e,i)=>Math.max(e,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i))))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce(((e,i)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(i))))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce(((e,i)=>Math.max(e,this.displayWidth(t.styleOptionTerm(t.optionTerm(i))))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce(((e,i)=>Math.max(e,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i))))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let t=e.parent;t;t=t.parent)i=t.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue){(e.required||e.optional||e.isBoolean()&&"boolean"==typeof e.defaultValue)&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`)}if(void 0!==e.presetArg&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),void 0!==e.envVar&&t.push(`env: ${e.envVar}`),t.length>0){const i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}argumentDescription(e){const t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map((e=>JSON.stringify(e))).join(", ")}`),void 0!==e.defaultValue&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){const i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatItemList(e,t,i){return 0===t.length?[]:[i.styleTitle(e),...t,""]}groupItems(e,t,i){const n=new Map;return e.forEach((e=>{const t=i(e);n.has(t)||n.set(t,[])})),t.forEach((e=>{const t=i(e);n.has(t)||n.set(t,[]),n.get(t).push(e)})),n}formatHelp(e,t){const i=t.padWidth(e,t),n=t.helpWidth??80;function r(e,n){return t.formatItem(e,i,n,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""];const s=t.commandDescription(e);s.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(s),n),""]));const c=t.visibleArguments(e).map((e=>r(t.styleArgumentTerm(t.argumentTerm(e)),t.styleArgumentDescription(t.argumentDescription(e)))));o=o.concat(this.formatItemList("Arguments:",c,t));const a=this.groupItems(e.options,t.visibleOptions(e),(e=>e.helpGroupHeading??"Options:"));if(a.forEach(((e,i)=>{const n=e.map((e=>r(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e)))));o=o.concat(this.formatItemList(i,n,t))})),t.showGlobalOptions){const i=t.visibleGlobalOptions(e).map((e=>r(t.styleOptionTerm(t.optionTerm(e)),t.styleOptionDescription(t.optionDescription(e)))));o=o.concat(this.formatItemList("Global Options:",i,t))}return this.groupItems(e.commands,t.visibleCommands(e),(e=>e.helpGroup()||"Commands:")).forEach(((e,i)=>{const n=e.map((e=>r(t.styleSubcommandTerm(t.subcommandTerm(e)),t.styleSubcommandDescription(t.subcommandDescription(e)))));o=o.concat(this.formatItemList(i,n,t))})),o.join("\n")}displayWidth(e){return t(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map((e=>"[options]"===e?this.styleOptionText(e):"[command]"===e?this.styleSubcommandText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleCommandText(e))).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((e=>"[options]"===e?this.styleOptionText(e):"["===e[0]||"<"===e[0]?this.styleArgumentText(e):this.styleSubcommandText(e))).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,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,i,n){const r=" ".repeat(2);if(!i)return r+e;const o=e.padEnd(t+e.length-n.displayWidth(e)),s=(this.helpWidth??80)-t-2-2;let c;if(s<this.minWidthToWrap||n.preformatted(i))c=i;else{c=n.boxWrap(i,s).replace(/\n/g,"\n"+" ".repeat(t+2))}return r+o+" ".repeat(2)+c.replace(/\n/g,`\n${r}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;const i=e.split(/\r\n|\n/),n=/[\s]*[^\s]+/g,r=[];return i.forEach((e=>{const i=e.match(n);if(null===i)return void r.push("");let o=[i.shift()],s=this.displayWidth(o[0]);i.forEach((e=>{const i=this.displayWidth(e);if(s+i<=t)return o.push(e),void(s+=i);r.push(o.join(""));const n=e.trimStart();o=[n],s=this.displayWidth(n)})),r.push(o.join(""))})),r.join("\n")}},O.stripColor=t,O}var X,b={};function P(){if(X)return b;X=1;const{InvalidArgumentError:e}=C();function t(e){return e.split("-").reduce(((e,t)=>e+t[0].toUpperCase()+t.slice(1)))}return b.Option=class{constructor(e,t){this.flags=e,this.description=t||"",this.required=e.includes("<"),this.optional=e.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(e),this.mandatory=!1;const i=function(e){let t,i;const n=/^-[^-]$/,r=/^--[^-]/,o=e.split(/[ |,]+/).concat("guard");n.test(o[0])&&(t=o.shift());r.test(o[0])&&(i=o.shift());!t&&n.test(o[0])&&(t=o.shift());!t&&r.test(o[0])&&(t=i,i=o.shift());if(o[0].startsWith("-")){const t=o[0],i=`option creation failed due to '${t}' in option flags '${e}'`;if(/^-[^-][^-]/.test(t))throw new Error(`${i}\n- a short flag is a single dash and a single character\n - either use a single dash and a single character (for a short flag)\n - or use a double dash for a long option (and can have two, like '--ws, --workspace')`);if(n.test(t))throw new Error(`${i}\n- too many short flags`);if(r.test(t))throw new Error(`${i}\n- too many long flags`);throw new Error(`${i}\n- unrecognised flag format`)}if(void 0===t&&void 0===i)throw new Error(`option creation failed due to no flags found in '${e}'.`);return{shortFlag:t,longFlag:i}}(e);this.short=i.shortFlag,this.long=i.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,t){return this.defaultValue=e,this.defaultValueDescription=t,this}preset(e){return this.presetArg=e,this}conflicts(e){return this.conflictsWith=this.conflictsWith.concat(e),this}implies(e){let t=e;return"string"==typeof e&&(t={[e]:!0}),this.implied=Object.assign(this.implied||{},t),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,t){return t!==this.defaultValue&&Array.isArray(t)?t.concat(e):[e]}choices(t){return this.argChoices=t.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new e(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}name(){return this.long?this.long.replace(/^--/,""):this.short.replace(/^-/,"")}attributeName(){return this.negate?t(this.name().replace(/^no-/,"")):t(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}},b.DualOptions=class{constructor(e){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,e.forEach((e=>{e.negate?this.negativeOptions.set(e.attributeName(),e):this.positiveOptions.set(e.attributeName(),e)})),this.negativeOptions.forEach(((e,t)=>{this.positiveOptions.has(t)&&this.dualOptions.add(t)}))}valueFromOption(e,t){const i=t.attributeName();if(!this.dualOptions.has(i))return!0;const n=this.negativeOptions.get(i).presetArg,r=void 0!==n&&n;return t.negate===(r===e)}},b}var y,H,w,D={};function v(){if(y)return D;y=1;return D.suggestSimilar=function(e,t){if(!t||0===t.length)return"";t=Array.from(new Set(t));const i=e.startsWith("--");i&&(e=e.slice(2),t=t.map((e=>e.slice(2))));let n=[],r=3;return t.forEach((t=>{if(t.length<=1)return;const i=function(e,t){if(Math.abs(e.length-t.length)>3)return Math.max(e.length,t.length);const i=[];for(let t=0;t<=e.length;t++)i[t]=[t];for(let e=0;e<=t.length;e++)i[0][e]=e;for(let n=1;n<=t.length;n++)for(let r=1;r<=e.length;r++){let o=1;o=e[r-1]===t[n-1]?0:1,i[r][n]=Math.min(i[r-1][n]+1,i[r][n-1]+1,i[r-1][n-1]+o),r>1&&n>1&&e[r-1]===t[n-2]&&e[r-2]===t[n-1]&&(i[r][n]=Math.min(i[r][n],i[r-2][n-2]+1))}return i[e.length][t.length]}(e,t),o=Math.max(e.length,t.length);(o-i)/o>.4&&(i<r?(r=i,n=[t]):i===r&&n.push(t))})),n.sort(((e,t)=>e.localeCompare(t))),i&&(n=n.map((e=>`--${e}`))),n.length>1?`\n(Did you mean one of ${n.join(", ")}?)`:1===n.length?`\n(Did you mean ${n[0]}?)`:""},D}var M=function(){if(w)return R;w=1;const{Argument:o}=S(),{Command:s}=function(){if(H)return K;H=1;const o=e.EventEmitter,s=t,c=i,a=n,d=r,{Argument:l,humanReadableArgName:_}=S(),{CommanderError:u}=C(),{Help:p,stripColor:T}=g(),{Option:E,DualOptions:A}=P(),{suggestSimilar:h}=v();class L extends o{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:e=>d.stdout.write(e),writeErr:e=>d.stderr.write(e),outputError:(e,t)=>t(e),getOutHelpWidth:()=>d.stdout.isTTY?d.stdout.columns:void 0,getErrHelpWidth:()=>d.stderr.isTTY?d.stderr.columns:void 0,getOutHasColors:()=>R()??(d.stdout.isTTY&&d.stdout.hasColors?.()),getErrHasColors:()=>R()??(d.stderr.isTTY&&d.stderr.hasColors?.()),stripColor:e=>T(e)},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(){const e=[];for(let t=this;t;t=t.parent)e.push(t);return e}command(e,t,i){let n=t,r=i;"object"==typeof n&&null!==n&&(r=n,n=null),r=r||{};const[,o,s]=e.match(/([^ ]+) *(.*)/),c=this.createCommand(o);return n&&(c.description(n),c._executableHandler=!0),r.isDefault&&(this._defaultCommandName=c._name),c._hidden=!(!r.noHelp&&!r.hidden),c._executableFile=r.executableFile||null,s&&c.arguments(s),this._registerCommand(c),c.parent=this,c.copyInheritedSettings(this),n?this:c}createCommand(e){return new L(e)}createHelp(){return Object.assign(new p,this.configureHelp())}configureHelp(e){return void 0===e?this._helpConfiguration:(this._helpConfiguration=e,this)}configureOutput(e){return void 0===e?this._outputConfiguration:(this._outputConfiguration=Object.assign({},this._outputConfiguration,e),this)}showHelpAfterError(e=!0){return"string"!=typeof e&&(e=!!e),this._showHelpAfterError=e,this}showSuggestionAfterError(e=!0){return this._showSuggestionAfterError=!!e,this}addCommand(e,t){if(!e._name)throw new Error("Command passed to .addCommand() must have a name\n- specify the name in Command constructor or using .name()");return(t=t||{}).isDefault&&(this._defaultCommandName=e._name),(t.noHelp||t.hidden)&&(e._hidden=!0),this._registerCommand(e),e.parent=this,e._checkForBrokenPassThrough(),this}createArgument(e,t){return new l(e,t)}argument(e,t,i,n){const r=this.createArgument(e,t);return"function"==typeof i?r.default(n).argParser(i):r.default(i),this.addArgument(r),this}arguments(e){return e.trim().split(/ +/).forEach((e=>{this.argument(e)})),this}addArgument(e){const t=this.registeredArguments.slice(-1)[0];if(t&&t.variadic)throw new Error(`only the last argument can be variadic '${t.name()}'`);if(e.required&&void 0!==e.defaultValue&&void 0===e.parseArg)throw new Error(`a default value for a required argument is never used: '${e.name()}'`);return this.registeredArguments.push(e),this}helpCommand(e,t){if("boolean"==typeof e)return this._addImplicitHelpCommand=e,e&&this._defaultCommandGroup&&this._initCommandGroup(this._getHelpCommand()),this;const i=e??"help [command]",[,n,r]=i.match(/([^ ]+) *(.*)/),o=t??"display help for command",s=this.createCommand(n);return s.helpOption(!1),r&&s.arguments(r),o&&s.description(o),this._addImplicitHelpCommand=!0,this._helpCommand=s,(e||t)&&this._initCommandGroup(s),this}addHelpCommand(e,t){return"object"!=typeof e?(this.helpCommand(e,t),this):(this._addImplicitHelpCommand=!0,this._helpCommand=e,this._initCommandGroup(e),this)}_getHelpCommand(){return this._addImplicitHelpCommand??(this.commands.length&&!this._actionHandler&&!this._findCommand("help"))?(void 0===this._helpCommand&&this.helpCommand(void 0,void 0),this._helpCommand):null}hook(e,t){const i=["preSubcommand","preAction","postAction"];if(!i.includes(e))throw new Error(`Unexpected value for event passed to hook : '${e}'.\nExpecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._lifeCycleHooks[e].push(t):this._lifeCycleHooks[e]=[t],this}exitOverride(e){return this._exitCallback=e||(e=>{if("commander.executeSubCommandAsync"!==e.code)throw e}),this}_exit(e,t,i){this._exitCallback&&this._exitCallback(new u(e,t,i)),d.exit(e)}action(e){return this._actionHandler=t=>{const i=this.registeredArguments.length,n=t.slice(0,i);return this._storeOptionsAsProperties?n[i]=this:n[i]=this.opts(),n.push(this),e.apply(this,n)},this}createOption(e,t){return new E(e,t)}_callParseArg(e,t,i,n){try{return e.parseArg(t,i)}catch(e){if("commander.invalidArgument"===e.code){const t=`${n} ${e.message}`;this.error(t,{exitCode:e.exitCode,code:e.code})}throw e}}_registerOption(e){const t=e.short&&this._findOption(e.short)||e.long&&this._findOption(e.long);if(t){const i=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 '${i}'\n- already used by option '${t.flags}'`)}this._initOptionGroup(e),this.options.push(e)}_registerCommand(e){const t=e=>[e.name()].concat(e.aliases()),i=t(e).find((e=>this._findCommand(e)));if(i){const n=t(this._findCommand(i)).join("|"),r=t(e).join("|");throw new Error(`cannot add command '${r}' as already have command '${n}'`)}this._initCommandGroup(e),this.commands.push(e)}addOption(e){this._registerOption(e);const t=e.name(),i=e.attributeName();if(e.negate){const t=e.long.replace(/^--no-/,"--");this._findOption(t)||this.setOptionValueWithSource(i,void 0===e.defaultValue||e.defaultValue,"default")}else void 0!==e.defaultValue&&this.setOptionValueWithSource(i,e.defaultValue,"default");const n=(t,n,r)=>{null==t&&void 0!==e.presetArg&&(t=e.presetArg);const o=this.getOptionValue(i);null!==t&&e.parseArg?t=this._callParseArg(e,t,o,n):null!==t&&e.variadic&&(t=e._concatValue(t,o)),null==t&&(t=!e.negate&&(!(!e.isBoolean()&&!e.optional)||"")),this.setOptionValueWithSource(i,t,r)};return this.on("option:"+t,(t=>{const i=`error: option '${e.flags}' argument '${t}' is invalid.`;n(t,i,"cli")})),e.envVar&&this.on("optionEnv:"+t,(t=>{const i=`error: option '${e.flags}' value '${t}' from env '${e.envVar}' is invalid.`;n(t,i,"env")})),this}_optionEx(e,t,i,n,r){if("object"==typeof t&&t instanceof E)throw new Error("To add an Option object use addOption() instead of option() or requiredOption()");const o=this.createOption(t,i);if(o.makeOptionMandatory(!!e.mandatory),"function"==typeof n)o.default(r).argParser(n);else if(n instanceof RegExp){const e=n;n=(t,i)=>{const n=e.exec(t);return n?n[0]:i},o.default(r).argParser(n)}else o.default(n);return this.addOption(o)}option(e,t,i,n){return this._optionEx({},e,t,i,n)}requiredOption(e,t,i,n){return this._optionEx({mandatory:!0},e,t,i,n)}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){return this._storeOptionsAsProperties?this[e]:this._optionValues[e]}setOptionValue(e,t){return this.setOptionValueWithSource(e,t,void 0)}setOptionValueWithSource(e,t,i){return this._storeOptionsAsProperties?this[e]=t:this._optionValues[e]=t,this._optionValueSources[e]=i,this}getOptionValueSource(e){return this._optionValueSources[e]}getOptionValueSourceWithGlobals(e){let t;return this._getCommandAndAncestors().forEach((i=>{void 0!==i.getOptionValueSource(e)&&(t=i.getOptionValueSource(e))})),t}_prepareUserArgs(e,t){if(void 0!==e&&!Array.isArray(e))throw new Error("first parameter to parse must be array or undefined");if(t=t||{},void 0===e&&void 0===t.from){d.versions?.electron&&(t.from="electron");const e=d.execArgv??[];(e.includes("-e")||e.includes("--eval")||e.includes("-p")||e.includes("--print"))&&(t.from="eval")}let i;switch(void 0===e&&(e=d.argv),this.rawArgs=e.slice(),t.from){case void 0:case"node":this._scriptPath=e[1],i=e.slice(2);break;case"electron":d.defaultApp?(this._scriptPath=e[1],i=e.slice(2)):i=e.slice(1);break;case"user":i=e.slice(0);break;case"eval":i=e.slice(1);break;default:throw new Error(`unexpected parse option { from: '${t.from}' }`)}return!this._name&&this._scriptPath&&this.nameFromFilename(this._scriptPath),this._name=this._name||"program",i}parse(e,t){this._prepareForParse();const i=this._prepareUserArgs(e,t);return this._parseCommand([],i),this}async parseAsync(e,t){this._prepareForParse();const i=this._prepareUserArgs(e,t);return await this._parseCommand([],i),this}_prepareForParse(){null===this._savedState?this.saveStateBeforeParse():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.\n- 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,t,i){if(!a.existsSync(e))throw new Error(`'${e}' does not exist\n - if '${i}' is not meant to be an executable command, remove description parameter from '.command()' and use '.description()' instead\n - if the default executable name is not suitable, use the executableFile option to supply a custom name or path\n - ${t?`searched for local subcommand relative to directory '${t}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory"}`)}_executeSubCommand(e,t){t=t.slice();let i=!1;const n=[".js",".ts",".tsx",".mjs",".cjs"];function r(e,t){const i=c.resolve(e,t);if(a.existsSync(i))return i;if(n.includes(c.extname(t)))return;const r=n.find((e=>a.existsSync(`${i}${e}`)));return r?`${i}${r}`:void 0}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let o,l=e._executableFile||`${this._name}-${e._name}`,_=this._executableDir||"";if(this._scriptPath){let e;try{e=a.realpathSync(this._scriptPath)}catch{e=this._scriptPath}_=c.resolve(c.dirname(e),_)}if(_){let t=r(_,l);if(!t&&!e._executableFile&&this._scriptPath){const i=c.basename(this._scriptPath,c.extname(this._scriptPath));i!==this._name&&(t=r(_,`${i}-${e._name}`))}l=t||l}i=n.includes(c.extname(l)),"win32"!==d.platform?i?(t.unshift(l),t=I(d.execArgv).concat(t),o=s.spawn(d.argv[0],t,{stdio:"inherit"})):o=s.spawn(l,t,{stdio:"inherit"}):(this._checkForMissingExecutable(l,_,e._name),t.unshift(l),t=I(d.execArgv).concat(t),o=s.spawn(d.execPath,t,{stdio:"inherit"})),o.killed||["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((e=>{d.on(e,(()=>{!1===o.killed&&null===o.exitCode&&o.kill(e)}))}));const p=this._exitCallback;o.on("close",(e=>{e=e??1,p?p(new u(e,"commander.executeSubCommandAsync","(close)")):d.exit(e)})),o.on("error",(t=>{if("ENOENT"===t.code)this._checkForMissingExecutable(l,_,e._name);else if("EACCES"===t.code)throw new Error(`'${l}' not executable`);if(p){const e=new u(1,"commander.executeSubCommandAsync","(error)");e.nestedError=t,p(e)}else d.exit(1)})),this.runningCommand=o}_dispatchSubcommand(e,t,i){const n=this._findCommand(e);let r;return n||this.help({error:!0}),n._prepareForParse(),r=this._chainOrCallSubCommandHook(r,n,"preSubcommand"),r=this._chainOrCall(r,(()=>{if(!n._executableHandler)return n._parseCommand(t,i);this._executeSubCommand(n,t.concat(i))})),r}_dispatchHelpCommand(e){e||this.help();const t=this._findCommand(e);return t&&!t._executableHandler&&t.help(),this._dispatchSubcommand(e,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){this.registeredArguments.forEach(((e,t)=>{e.required&&null==this.args[t]&&this.missingArgument(e.name())})),this.registeredArguments.length>0&&this.registeredArguments[this.registeredArguments.length-1].variadic||this.args.length>this.registeredArguments.length&&this._excessArguments(this.args)}_processArguments(){const e=(e,t,i)=>{let n=t;if(null!==t&&e.parseArg){const r=`error: command-argument value '${t}' is invalid for argument '${e.name()}'.`;n=this._callParseArg(e,t,i,r)}return n};this._checkNumberOfArguments();const t=[];this.registeredArguments.forEach(((i,n)=>{let r=i.defaultValue;i.variadic?n<this.args.length?(r=this.args.slice(n),i.parseArg&&(r=r.reduce(((t,n)=>e(i,n,t)),i.defaultValue))):void 0===r&&(r=[]):n<this.args.length&&(r=this.args[n],i.parseArg&&(r=e(i,r,i.defaultValue))),t[n]=r})),this.processedArgs=t}_chainOrCall(e,t){return e&&e.then&&"function"==typeof e.then?e.then((()=>t())):t()}_chainOrCallHooks(e,t){let i=e;const n=[];return this._getCommandAndAncestors().reverse().filter((e=>void 0!==e._lifeCycleHooks[t])).forEach((e=>{e._lifeCycleHooks[t].forEach((t=>{n.push({hookedCommand:e,callback:t})}))})),"postAction"===t&&n.reverse(),n.forEach((e=>{i=this._chainOrCall(i,(()=>e.callback(e.hookedCommand,this)))})),i}_chainOrCallSubCommandHook(e,t,i){let n=e;return void 0!==this._lifeCycleHooks[i]&&this._lifeCycleHooks[i].forEach((e=>{n=this._chainOrCall(n,(()=>e(this,t)))})),n}_parseCommand(e,t){const i=this.parseOptions(t);if(this._parseOptionsEnv(),this._parseOptionsImplied(),e=e.concat(i.operands),t=i.unknown,this.args=e.concat(t),e&&this._findCommand(e[0]))return this._dispatchSubcommand(e[0],e.slice(1),t);if(this._getHelpCommand()&&e[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(e[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(t),this._dispatchSubcommand(this._defaultCommandName,e,t);!this.commands.length||0!==this.args.length||this._actionHandler||this._defaultCommandName||this.help({error:!0}),this._outputHelpIfRequested(i.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();const n=()=>{i.unknown.length>0&&this.unknownOption(i.unknown[0])},r=`command:${this.name()}`;if(this._actionHandler){let i;return n(),this._processArguments(),i=this._chainOrCallHooks(i,"preAction"),i=this._chainOrCall(i,(()=>this._actionHandler(this.processedArgs))),this.parent&&(i=this._chainOrCall(i,(()=>{this.parent.emit(r,e,t)}))),i=this._chainOrCallHooks(i,"postAction"),i}if(this.parent&&this.parent.listenerCount(r))n(),this._processArguments(),this.parent.emit(r,e,t);else if(e.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",e,t);this.listenerCount("command:*")?this.emit("command:*",e,t):this.commands.length?this.unknownCommand():(n(),this._processArguments())}else this.commands.length?(n(),this.help({error:!0})):(n(),this._processArguments())}_findCommand(e){if(e)return this.commands.find((t=>t._name===e||t._aliases.includes(e)))}_findOption(e){return this.options.find((t=>t.is(e)))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((e=>{e.options.forEach((t=>{t.mandatory&&void 0===e.getOptionValue(t.attributeName())&&e.missingMandatoryOptionValue(t)}))}))}_checkForConflictingLocalOptions(){const e=this.options.filter((e=>{const t=e.attributeName();return void 0!==this.getOptionValue(t)&&"default"!==this.getOptionValueSource(t)})),t=e.filter((e=>e.conflictsWith.length>0));t.forEach((t=>{const i=e.find((e=>t.conflictsWith.includes(e.attributeName())));i&&this._conflictingOption(t,i)}))}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((e=>{e._checkForConflictingLocalOptions()}))}parseOptions(e){const t=[],i=[];let n=t;const r=e.slice();function o(e){return e.length>1&&"-"===e[0]}const s=e=>!!/^-\d*\.?\d+(e[+-]?\d+)?$/.test(e)&&!this._getCommandAndAncestors().some((e=>e.options.map((e=>e.short)).some((e=>/^-\d$/.test(e)))));let c=null;for(;r.length;){const e=r.shift();if("--"===e){n===i&&n.push(e),n.push(...r);break}if(!c||o(e)&&!s(e)){if(c=null,o(e)){const t=this._findOption(e);if(t){if(t.required){const e=r.shift();void 0===e&&this.optionMissingArgument(t),this.emit(`option:${t.name()}`,e)}else if(t.optional){let e=null;r.length>0&&(!o(r[0])||s(r[0]))&&(e=r.shift()),this.emit(`option:${t.name()}`,e)}else this.emit(`option:${t.name()}`);c=t.variadic?t:null;continue}}if(e.length>2&&"-"===e[0]&&"-"!==e[1]){const t=this._findOption(`-${e[1]}`);if(t){t.required||t.optional&&this._combineFlagAndOptionalValue?this.emit(`option:${t.name()}`,e.slice(2)):(this.emit(`option:${t.name()}`),r.unshift(`-${e.slice(2)}`));continue}}if(/^--[^=]+=/.test(e)){const t=e.indexOf("="),i=this._findOption(e.slice(0,t));if(i&&(i.required||i.optional)){this.emit(`option:${i.name()}`,e.slice(t+1));continue}}if(n!==t||!o(e)||0===this.commands.length&&s(e)||(n=i),(this._enablePositionalOptions||this._passThroughOptions)&&0===t.length&&0===i.length){if(this._findCommand(e)){t.push(e),r.length>0&&i.push(...r);break}if(this._getHelpCommand()&&e===this._getHelpCommand().name()){t.push(e),r.length>0&&t.push(...r);break}if(this._defaultCommandName){i.push(e),r.length>0&&i.push(...r);break}}if(this._passThroughOptions){n.push(e),r.length>0&&n.push(...r);break}n.push(e)}else this.emit(`option:${c.name()}`,e)}return{operands:t,unknown:i}}opts(){if(this._storeOptionsAsProperties){const e={},t=this.options.length;for(let i=0;i<t;i++){const t=this.options[i].attributeName();e[t]=t===this._versionOptionName?this._version:this[t]}return e}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce(((e,t)=>Object.assign(e,t.opts())),{})}error(e,t){this._outputConfiguration.outputError(`${e}\n`,this._outputConfiguration.writeErr),"string"==typeof this._showHelpAfterError?this._outputConfiguration.writeErr(`${this._showHelpAfterError}\n`):this._showHelpAfterError&&(this._outputConfiguration.writeErr("\n"),this.outputHelp({error:!0}));const i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach((e=>{if(e.envVar&&e.envVar in d.env){const t=e.attributeName();(void 0===this.getOptionValue(t)||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,d.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}}))}_parseOptionsImplied(){const e=new A(this.options),t=e=>void 0!==this.getOptionValue(e)&&!["default","implied"].includes(this.getOptionValueSource(e));this.options.filter((i=>void 0!==i.implied&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i))).forEach((e=>{Object.keys(e.implied).filter((e=>!t(e))).forEach((t=>{this.setOptionValueWithSource(t,e.implied[t],"implied")}))}))}missingArgument(e){const t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){const t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){const t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){const i=e=>{const t=e.attributeName(),i=this.getOptionValue(t),n=this.options.find((e=>e.negate&&t===e.attributeName())),r=this.options.find((e=>!e.negate&&t===e.attributeName()));return n&&(void 0===n.presetArg&&!1===i||void 0!==n.presetArg&&i===n.presetArg)?n:r||e},n=e=>{const t=i(e),n=t.attributeName();return"env"===this.getOptionValueSource(n)?`environment variable '${t.envVar}'`:`option '${t.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let i=[],n=this;do{const e=n.createHelp().visibleOptions(n).filter((e=>e.long)).map((e=>e.long));i=i.concat(e),n=n.parent}while(n&&!n._enablePositionalOptions);t=h(e,i)}const i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;const t=this.registeredArguments.length,i=1===t?"":"s",n=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(n,{code:"commander.excessArguments"})}unknownCommand(){const e=this.args[0];let t="";if(this._showSuggestionAfterError){const i=[];this.createHelp().visibleCommands(this).forEach((e=>{i.push(e.name()),e.alias()&&i.push(e.alias())})),t=h(e,i)}const i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(void 0===e)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";const n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),(()=>{this._outputConfiguration.writeOut(`${e}\n`),this._exit(0,"commander.version",e)})),this}description(e,t){return void 0===e&&void 0===t?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return void 0===e?this._summary:(this._summary=e,this)}alias(e){if(void 0===e)return this._aliases[0];let t=this;if(0!==this.commands.length&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");const i=this.parent?._findCommand(e);if(i){const t=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${t}'`)}return t._aliases.push(e),this}aliases(e){return void 0===e?this._aliases:(e.forEach((e=>this.alias(e))),this)}usage(e){if(void 0===e){if(this._usage)return this._usage;const e=this.registeredArguments.map((e=>_(e)));return[].concat(this.options.length||null!==this._helpOption?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?e:[]).join(" ")}return this._usage=e,this}name(e){return void 0===e?this._name:(this._name=e,this)}helpGroup(e){return void 0===e?this._helpGroupHeading??"":(this._helpGroupHeading=e,this)}commandsGroup(e){return void 0===e?this._defaultCommandGroup??"":(this._defaultCommandGroup=e,this)}optionsGroup(e){return void 0===e?this._defaultOptionGroup??"":(this._defaultOptionGroup=e,this)}_initOptionGroup(e){this._defaultOptionGroup&&!e.helpGroupHeading&&e.helpGroup(this._defaultOptionGroup)}_initCommandGroup(e){this._defaultCommandGroup&&!e.helpGroup()&&e.helpGroup(this._defaultCommandGroup)}nameFromFilename(e){return this._name=c.basename(e,c.extname(e)),this}executableDir(e){return void 0===e?this._executableDir:(this._executableDir=e,this)}helpInformation(e){const t=this.createHelp(),i=this._getOutputContext(e);t.prepareContext({error:i.error,helpWidth:i.helpWidth,outputHasColors:i.hasColors});const n=t.formatHelp(this,t);return i.hasColors?n:this._outputConfiguration.stripColor(n)}_getOutputContext(e){const t=!!(e=e||{}).error;let i,n,r;return t?(i=e=>this._outputConfiguration.writeErr(e),n=this._outputConfiguration.getErrHasColors(),r=this._outputConfiguration.getErrHelpWidth()):(i=e=>this._outputConfiguration.writeOut(e),n=this._outputConfiguration.getOutHasColors(),r=this._outputConfiguration.getOutHelpWidth()),{error:t,write:e=>(n||(e=this._outputConfiguration.stripColor(e)),i(e)),hasColors:n,helpWidth:r}}outputHelp(e){let t;"function"==typeof e&&(t=e,e=void 0);const i=this._getOutputContext(e),n={error:i.error,write:i.write,command:this};this._getCommandAndAncestors().reverse().forEach((e=>e.emit("beforeAllHelp",n))),this.emit("beforeHelp",n);let r=this.helpInformation({error:i.error});if(t&&(r=t(r),"string"!=typeof r&&!Buffer.isBuffer(r)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(r),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",n),this._getCommandAndAncestors().forEach((e=>e.emit("afterAllHelp",n)))}helpOption(e,t){return"boolean"==typeof e?(e?(null===this._helpOption&&(this._helpOption=void 0),this._defaultOptionGroup&&this._initOptionGroup(this._getHelpOption())):this._helpOption=null,this):(this._helpOption=this.createOption(e??"-h, --help",t??"display help for command"),(e||t)&&this._initOptionGroup(this._helpOption),this)}_getHelpOption(){return void 0===this._helpOption&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this._initOptionGroup(e),this}help(e){this.outputHelp(e);let t=Number(d.exitCode??0);0===t&&e&&"function"!=typeof e&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){const i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.\nExpecting one of '${i.join("', '")}'`);const n=`${e}Help`;return this.on(n,(e=>{let i;i="function"==typeof t?t({error:e.error,command:e.command}):t,i&&e.write(`${i}\n`)})),this}_outputHelpIfRequested(e){const t=this._getHelpOption();t&&e.find((e=>t.is(e)))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}}function I(e){return e.map((e=>{if(!e.startsWith("--inspect"))return e;let t,i,n="127.0.0.1",r="9229";return null!==(i=e.match(/^(--inspect(-brk)?)$/))?t=i[1]:null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))?(t=i[1],/^\d+$/.test(i[3])?r=i[3]:n=i[3]):null!==(i=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))&&(t=i[1],n=i[3],r=i[4]),t&&"0"!==r?`${t}=${n}:${parseInt(r)+1}`:e}))}function R(){return!d.env.NO_COLOR&&"0"!==d.env.FORCE_COLOR&&"false"!==d.env.FORCE_COLOR&&(!(!d.env.FORCE_COLOR&&void 0===d.env.CLICOLOR_FORCE)||void 0)}return K.Command=L,K.useColor=R,K}(),{CommanderError:c,InvalidArgumentError:a}=C(),{Help:d}=g(),{Option:l}=P();return R.program=new s,R.createCommand=e=>new s(e),R.createOption=(e,t)=>new l(e,t),R.createArgument=(e,t)=>new o(e,t),R.Command=s,R.Option=l,R.Argument=o,R.Help=d,R.CommanderError=c,R.InvalidArgumentError=a,R.InvalidOptionArgumentError=a,R}(),k=h(M);const{program:B,createCommand:U,createArgument:x,createOption:G,CommanderError:W,InvalidArgumentError:F,InvalidOptionArgumentError:Y,Command:V,Argument:q,Option:j,Help:$}=k;var Z,J,z,Q,ee,te,ie,ne={},re={exports:{}},oe={exports:{}};function se(){if(J)return re.exports;J=1;const e=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,t=()=>{const t={enabled:"undefined"!=typeof process&&"0"!==process.env.FORCE_COLOR,visible:!0,styles:{},keys:{}},i=(e,t,i)=>"function"==typeof e?e(t):e.wrap(t,i),n=(e,n)=>{if(""===e||null==e)return"";if(!1===t.enabled)return e;if(!1===t.visible)return"";let r=""+e,o=r.includes("\n"),s=n.length;for(s>0&&n.includes("unstyle")&&(n=[...new Set(["unstyle",...n])].reverse());s-- >0;)r=i(t.styles[n[s]],r,o);return r},r=(e,i,r)=>{t.styles[e]=(e=>{let t=e.open=`[${e.codes[0]}m`,i=e.close=`[${e.codes[1]}m`,n=e.regex=new RegExp(`\\u001b\\[${e.codes[1]}m`,"g");return e.wrap=(e,r)=>{e.includes(i)&&(e=e.replace(n,i+t));let o=t+e+i;return r?o.replace(/\r*\n/g,`${i}$&${t}`):o},e})({name:e,codes:i}),(t.keys[r]||(t.keys[r]=[])).push(e),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let i=e=>n(e,i.stack);return Reflect.setPrototypeOf(i,t),i.stack=this.stack?this.stack.concat(e):[e],i}})};return r("reset",[0,0],"modifier"),r("bold",[1,22],"modifier"),r("dim",[2,22],"modifier"),r("italic",[3,23],"modifier"),r("underline",[4,24],"modifier"),r("inverse",[7,27],"modifier"),r("hidden",[8,28],"modifier"),r("strikethrough",[9,29],"modifier"),r("black",[30,39],"color"),r("red",[31,39],"color"),r("green",[32,39],"color"),r("yellow",[33,39],"color"),r("blue",[34,39],"color"),r("magenta",[35,39],"color"),r("cyan",[36,39],"color"),r("white",[37,39],"color"),r("gray",[90,39],"color"),r("grey",[90,39],"color"),r("bgBlack",[40,49],"bg"),r("bgRed",[41,49],"bg"),r("bgGreen",[42,49],"bg"),r("bgYellow",[43,49],"bg"),r("bgBlue",[44,49],"bg"),r("bgMagenta",[45,49],"bg"),r("bgCyan",[46,49],"bg"),r("bgWhite",[47,49],"bg"),r("blackBright",[90,39],"bright"),r("redBright",[91,39],"bright"),r("greenBright",[92,39],"bright"),r("yellowBright",[93,39],"bright"),r("blueBright",[94,39],"bright"),r("magentaBright",[95,39],"bright"),r("cyanBright",[96,39],"bright"),r("whiteBright",[97,39],"bright"),r("bgBlackBright",[100,49],"bgBright"),r("bgRedBright",[101,49],"bgBright"),r("bgGreenBright",[102,49],"bgBright"),r("bgYellowBright",[103,49],"bgBright"),r("bgBlueBright",[104,49],"bgBright"),r("bgMagentaBright",[105,49],"bgBright"),r("bgCyanBright",[106,49],"bgBright"),r("bgWhiteBright",[107,49],"bgBright"),t.ansiRegex=e,t.hasColor=t.hasAnsi=e=>(t.ansiRegex.lastIndex=0,"string"==typeof e&&""!==e&&t.ansiRegex.test(e)),t.alias=(e,i)=>{let r="string"==typeof i?t[i]:i;if("function"!=typeof r)throw new TypeError("Expected alias to be the name of an existing color (string) or a function");r.stack||(Reflect.defineProperty(r,"name",{value:e}),t.styles[e]=r,r.stack=[e]),Reflect.defineProperty(t,e,{configurable:!0,enumerable:!0,set(i){t.alias(e,i)},get(){let e=t=>n(t,e.stack);return Reflect.setPrototypeOf(e,t),e.stack=this.stack?this.stack.concat(r.stack):r.stack,e}})},t.theme=e=>{if(null===(i=e)||"object"!=typeof i||Array.isArray(i))throw new TypeError("Expected theme to be an object");var i;for(let i of Object.keys(e))t.alias(i,e[i]);return t},t.alias("unstyle",(e=>"string"==typeof e&&""!==e?(t.ansiRegex.lastIndex=0,e.replace(t.ansiRegex,"")):"")),t.alias("noop",(e=>e)),t.none=t.clear=t.noop,t.stripColor=t.unstyle,t.symbols=(Z||(Z=1,function(e){const t="undefined"!=typeof process&&"Hyper"===process.env.TERM_PROGRAM,i="undefined"!=typeof process&&"win32"===process.platform,n="undefined"!=typeof process&&"linux"===process.platform,r={ballotDisabled:"☒",ballotOff:"☐",ballotOn:"☑",bullet:"•",bulletWhite:"◦",fullBlock:"█",heart:"❤",identicalTo:"≡",line:"─",mark:"※",middot:"·",minus:"-",multiplication:"×",obelus:"÷",pencilDownRight:"✎",pencilRight:"✏",pencilUpRight:"✐",percent:"%",pilcrow2:"❡",pilcrow:"¶",plusMinus:"±",question:"?",section:"§",starsOff:"☆",starsOn:"★",upDownArrow:"↕"},o=Object.assign({},r,{check:"√",cross:"×",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"»",radioOff:"( )",radioOn:"(*)",warning:"‼"}),s=Object.assign({},r,{ballotCross:"✘",check:"✔",cross:"✖",ellipsisLarge:"⋯",ellipsis:"…",info:"ℹ",questionFull:"?",questionSmall:"﹖",pointer:n?"▸":"❯",pointerSmall:n?"‣":"›",radioOff:"◯",radioOn:"◉",warning:"⚠"});e.exports=i&&!t?o:s,Reflect.defineProperty(e.exports,"common",{enumerable:!1,value:r}),Reflect.defineProperty(e.exports,"windows",{enumerable:!1,value:o}),Reflect.defineProperty(e.exports,"other",{enumerable:!1,value:s})}(oe)),oe.exports),t.define=r,t};return re.exports=t(),re.exports.create=t,re.exports}function ce(){return z||(z=1,function(e){const t=Object.prototype.toString,i=se();let n=!1,r=new Set;const o={yellow:"blue",cyan:"red",green:"magenta",black:"white",blue:"yellow",red:"cyan",magenta:"green",white:"black"};e.longest=(e,t)=>e.reduce(((e,i)=>Math.max(e,t?i[t].length:i.length)),0),e.hasColor=e=>!!e&&i.hasColor(e);const s=e.isObject=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);e.nativeType=e=>t.call(e).slice(8,-1).toLowerCase().replace(/\s/g,""),e.isAsyncFn=t=>"asyncfunction"===e.nativeType(t),e.isPrimitive=e=>null!=e&&"object"!=typeof e&&"function"!=typeof e,e.resolve=(e,t,...i)=>"function"==typeof t?t.call(e,...i):t,e.scrollDown=(e=[])=>[...e.slice(1),e[0]],e.scrollUp=(e=[])=>[e.pop(),...e],e.reorder=(e=[])=>{let t=e.slice();return t.sort(((e,t)=>e.index>t.index?1:e.index<t.index?-1:0)),t},e.swap=(e,t,i)=>{let n=e.length,r=i===n?0:i<0?n-1:i,o=e[t];e[t]=e[r],e[r]=o},e.width=(e,t=80)=>{let i=e&&e.columns?e.columns:t;return e&&"function"==typeof e.getWindowSize&&(i=e.getWindowSize()[0]),"win32"===process.platform?i-1:i},e.height=(e,t=20)=>{let i=e&&e.rows?e.rows:t;return e&&"function"==typeof e.getWindowSize&&(i=e.getWindowSize()[1]),i},e.wordWrap=(e,t={})=>{if(!e)return e;"number"==typeof t&&(t={width:t});let{indent:i="",newline:n="\n"+i,width:r=80}=t,o=(n+i).match(/[^\S\n]/g)||[];r-=o.length;let s=`.{1,${r}}([\\s\\u200B]+|$)|[^\\s\\u200B]+?([\\s\\u200B]+|$)`,c=e.trim(),a=new RegExp(s,"g"),d=c.match(a)||[];return d=d.map((e=>e.replace(/\n$/,""))),t.padEnd&&(d=d.map((e=>e.padEnd(r," ")))),t.padStart&&(d=d.map((e=>e.padStart(r," ")))),i+d.join(n)},e.unmute=e=>{let t=e.stack.find((e=>i.keys.color.includes(e)));return t?i[t]:e.stack.find((e=>"bg"===e.slice(2)))?i[t.slice(2)]:e=>e},e.pascal=e=>e?e[0].toUpperCase()+e.slice(1):"",e.inverse=t=>{if(!t||!t.stack)return t;let n=t.stack.find((e=>i.keys.color.includes(e)));if(n){let r=i["bg"+e.pascal(n)];return r?r.black:t}let r=t.stack.find((e=>"bg"===e.slice(0,2)));return r?i[r.slice(2).toLowerCase()]||t:i.none},e.complement=t=>{if(!t||!t.stack)return t;let n=t.stack.find((e=>i.keys.color.includes(e))),r=t.stack.find((e=>"bg"===e.slice(0,2)));if(n&&!r)return i[o[n]||n];if(r){let n=r.slice(2).toLowerCase(),s=o[n];return s&&i["bg"+e.pascal(s)]||t}return i.none},e.meridiem=e=>{let t=e.getHours(),i=e.getMinutes(),n=t>=12?"pm":"am";return t%=12,(0===t?12:t)+":"+(i<10?"0"+i:i)+" "+n},e.set=(t={},i="",n)=>i.split(".").reduce(((t,i,r,o)=>{let s=o.length-1>r?t[i]||{}:n;return!e.isObject(s)&&r<o.length-1&&(s={}),t[i]=s}),t),e.get=(e={},t="",i)=>{let n=null==e[t]?t.split(".").reduce(((e,t)=>e&&e[t]),e):e[t];return null==n?i:n},e.mixin=(t,i)=>{if(!s(t))return i;if(!s(i))return t;for(let n of Object.keys(i)){let r=Object.getOwnPropertyDescriptor(i,n);if(hasOwnProperty.call(r,"value"))if(hasOwnProperty.call(t,n)&&s(r.value)){let o=Object.getOwnPropertyDescriptor(t,n);s(o.value)&&o.value!==r.value?t[n]=e.merge({},t[n],i[n]):Reflect.defineProperty(t,n,r)}else Reflect.defineProperty(t,n,r);else Reflect.defineProperty(t,n,r)}return t},e.merge=(...t)=>{let i={};for(let n of t)e.mixin(i,n);return i},e.mixinEmitter=(t,i)=>{let n=i.constructor.prototype;for(let r of Object.keys(n)){let o=n[r];"function"==typeof o?e.define(t,r,o.bind(i)):e.define(t,r,o)}};const c=(e,t)=>{n||(n=!0,r.forEach((e=>e())),!0===e&&process.exit(128+t))},a=c.bind(null,!0,15),d=c.bind(null,!0,2);e.onExit=e=>(0===r.size&&(process.once("SIGTERM",a),process.once("SIGINT",d),process.once("exit",c)),r.add(e),()=>{r.delete(e),0===r.size&&(process.off("SIGTERM",a),process.off("SIGINT",d),process.off("exit",c))}),e.define=(e,t,i)=>{Reflect.defineProperty(e,t,{value:i})},e.defineExport=(e,t,i)=>{let n;Reflect.defineProperty(e,t,{enumerable:!0,configurable:!0,set(e){n=e},get:()=>n?n():i()})}}(ne)),ne}function ae(){return ee?Q:(ee=1,Q=({onlyFirst:e=!1}={})=>{const t=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(t,e?void 0:"g")})}function de(){if(ie)return te;ie=1;const e=ae();return te=t=>"string"==typeof t?t.replace(e(),""):t,te}var le,_e,ue,pe,Te,Ee,Ae,he,Le,Ie,Re,me,fe,Ce,Se,Ne={};function Ke(){return le||(le=1,Ne.ctrl={a:"first",b:"backward",c:"cancel",d:"deleteForward",e:"last",f:"forward",g:"reset",i:"tab",k:"cutF