UNPKG

bknd

Version:

Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.

29 lines 419 kB
#!/usr/bin/env node import{createRequire as O4}from"node:module";var X4=Object.create;var{getPrototypeOf:G4,defineProperty:FJ,getOwnPropertyNames:Y4}=Object;var B4=Object.prototype.hasOwnProperty;var yS=(S,T,U)=>{U=S!=null?X4(G4(S)):{};let J=T||!S||!S.__esModule?FJ(U,"default",{value:S,enumerable:!0}):U;for(let I of Y4(S))if(!B4.call(J,I))FJ(J,I,{get:()=>S[I],enumerable:!0});return J};var h0=(S,T)=>()=>(T||S((T={exports:{}}).exports,T),T.exports);var n0=(S,T)=>{for(var U in T)FJ(S,U,{get:T[U],enumerable:!0,configurable:!0,set:(J)=>T[U]=()=>J})};var rz=(S,T)=>()=>(S&&(T=S(S=0)),T);var y0=O4(import.meta.url),E4=Symbol.dispose||Symbol.for("Symbol.dispose"),W4=Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose"),lz=(S,T,U)=>{if(T!=null){if(typeof T!=="object"&&typeof T!=="function")throw TypeError('Object expected to be assigned to "using" declaration');var J;if(U)J=T[W4];if(J===void 0)J=T[E4];if(typeof J!=="function")throw TypeError("Object not disposable");S.push([U,J,T])}else if(U)S.push([U]);return T},nz=(S,T,U)=>{var J=typeof SuppressedError==="function"?SuppressedError:function(z,$,Q,N){return N=Error(Q),N.name="SuppressedError",N.error=z,N.suppressed=$,N},I=(z)=>T=U?new J(z,T,"An error was suppressed during disposal"):(U=!0,z),Z=(z)=>{while(z=S.pop())try{var $=z[1]&&z[1].call(z[2]);if(z[0])return Promise.resolve($).then(Z,(Q)=>(I(Q),Z()))}catch(Q){I(Q)}if(U)throw T};return Z()};var rT=h0((M4)=>{class xJ extends Error{constructor(S,T,U){super(U);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=T,this.exitCode=S,this.nestedError=void 0}}class iz extends xJ{constructor(S){super(1,"commander.invalidArgument",S);Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}}M4.CommanderError=xJ;M4.InvalidArgumentError=iz});var p1=h0((f4)=>{var{InvalidArgumentError:w4}=rT();class az{constructor(S,T){switch(this.description=T||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,S[0]){case"<":this.required=!0,this._name=S.slice(1,-1);break;case"[":this.required=!1,this._name=S.slice(1,-1);break;default:this.required=!0,this._name=S;break}if(this._name.endsWith("..."))this.variadic=!0,this._name=this._name.slice(0,-3)}name(){return this._name}_collectValue(S,T){if(T===this.defaultValue||!Array.isArray(T))return[S];return T.push(S),T}default(S,T){return this.defaultValue=S,this.defaultValueDescription=T,this}argParser(S){return this.parseArg=S,this}choices(S){return this.argChoices=S.slice(),this.parseArg=(T,U)=>{if(!this.argChoices.includes(T))throw new w4(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(T,U);return T},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}}function V4(S){let T=S.name()+(S.variadic===!0?"...":"");return S.required?"<"+T+">":"["+T+"]"}f4.Argument=az;f4.humanReadableArgName=V4});var _J=h0((P4)=>{var{humanReadableArgName:C4}=p1();class tz{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(S){this.helpWidth=this.helpWidth??S.helpWidth??80}visibleCommands(S){let T=S.commands.filter((J)=>!J._hidden),U=S._getHelpCommand();if(U&&!U._hidden)T.push(U);if(this.sortSubcommands)T.sort((J,I)=>{return J.name().localeCompare(I.name())});return T}compareOptions(S,T){let U=(J)=>{return J.short?J.short.replace(/^-/,""):J.long.replace(/^--/,"")};return U(S).localeCompare(U(T))}visibleOptions(S){let T=S.options.filter((J)=>!J.hidden),U=S._getHelpOption();if(U&&!U.hidden){let J=U.short&&S._findOption(U.short),I=U.long&&S._findOption(U.long);if(!J&&!I)T.push(U);else if(U.long&&!I)T.push(S.createOption(U.long,U.description));else if(U.short&&!J)T.push(S.createOption(U.short,U.description))}if(this.sortOptions)T.sort(this.compareOptions);return T}visibleGlobalOptions(S){if(!this.showGlobalOptions)return[];let T=[];for(let U=S.parent;U;U=U.parent){let J=U.options.filter((I)=>!I.hidden);T.push(...J)}if(this.sortOptions)T.sort(this.compareOptions);return T}visibleArguments(S){if(S._argsDescription)S.registeredArguments.forEach((T)=>{T.description=T.description||S._argsDescription[T.name()]||""});if(S.registeredArguments.find((T)=>T.description))return S.registeredArguments;return[]}subcommandTerm(S){let T=S.registeredArguments.map((U)=>C4(U)).join(" ");return S._name+(S._aliases[0]?"|"+S._aliases[0]:"")+(S.options.length?" [options]":"")+(T?" "+T:"")}optionTerm(S){return S.flags}argumentTerm(S){return S.name()}longestSubcommandTermLength(S,T){return T.visibleCommands(S).reduce((U,J)=>{return Math.max(U,this.displayWidth(T.styleSubcommandTerm(T.subcommandTerm(J))))},0)}longestOptionTermLength(S,T){return T.visibleOptions(S).reduce((U,J)=>{return Math.max(U,this.displayWidth(T.styleOptionTerm(T.optionTerm(J))))},0)}longestGlobalOptionTermLength(S,T){return T.visibleGlobalOptions(S).reduce((U,J)=>{return Math.max(U,this.displayWidth(T.styleOptionTerm(T.optionTerm(J))))},0)}longestArgumentTermLength(S,T){return T.visibleArguments(S).reduce((U,J)=>{return Math.max(U,this.displayWidth(T.styleArgumentTerm(T.argumentTerm(J))))},0)}commandUsage(S){let T=S._name;if(S._aliases[0])T=T+"|"+S._aliases[0];let U="";for(let J=S.parent;J;J=J.parent)U=J.name()+" "+U;return U+T+" "+S.usage()}commandDescription(S){return S.description()}subcommandDescription(S){return S.summary()||S.description()}optionDescription(S){let T=[];if(S.argChoices)T.push(`choices: ${S.argChoices.map((U)=>JSON.stringify(U)).join(", ")}`);if(S.defaultValue!==void 0){if(S.required||S.optional||S.isBoolean()&&typeof S.defaultValue==="boolean")T.push(`default: ${S.defaultValueDescription||JSON.stringify(S.defaultValue)}`)}if(S.presetArg!==void 0&&S.optional)T.push(`preset: ${JSON.stringify(S.presetArg)}`);if(S.envVar!==void 0)T.push(`env: ${S.envVar}`);if(T.length>0){let U=`(${T.join(", ")})`;if(S.description)return`${S.description} ${U}`;return U}return S.description}argumentDescription(S){let T=[];if(S.argChoices)T.push(`choices: ${S.argChoices.map((U)=>JSON.stringify(U)).join(", ")}`);if(S.defaultValue!==void 0)T.push(`default: ${S.defaultValueDescription||JSON.stringify(S.defaultValue)}`);if(T.length>0){let U=`(${T.join(", ")})`;if(S.description)return`${S.description} ${U}`;return U}return S.description}formatItemList(S,T,U){if(T.length===0)return[];return[U.styleTitle(S),...T,""]}groupItems(S,T,U){let J=new Map;return S.forEach((I)=>{let Z=U(I);if(!J.has(Z))J.set(Z,[])}),T.forEach((I)=>{let Z=U(I);if(!J.has(Z))J.set(Z,[]);J.get(Z).push(I)}),J}formatHelp(S,T){let U=T.padWidth(S,T),J=T.helpWidth??80;function I(L,H){return T.formatItem(L,U,H,T)}let Z=[`${T.styleTitle("Usage:")} ${T.styleUsage(T.commandUsage(S))}`,""],z=T.commandDescription(S);if(z.length>0)Z=Z.concat([T.boxWrap(T.styleCommandDescription(z),J),""]);let $=T.visibleArguments(S).map((L)=>{return I(T.styleArgumentTerm(T.argumentTerm(L)),T.styleArgumentDescription(T.argumentDescription(L)))});if(Z=Z.concat(this.formatItemList("Arguments:",$,T)),this.groupItems(S.options,T.visibleOptions(S),(L)=>L.helpGroupHeading??"Options:").forEach((L,H)=>{let X=L.map((G)=>{return I(T.styleOptionTerm(T.optionTerm(G)),T.styleOptionDescription(T.optionDescription(G)))});Z=Z.concat(this.formatItemList(H,X,T))}),T.showGlobalOptions){let L=T.visibleGlobalOptions(S).map((H)=>{return I(T.styleOptionTerm(T.optionTerm(H)),T.styleOptionDescription(T.optionDescription(H)))});Z=Z.concat(this.formatItemList("Global Options:",L,T))}return this.groupItems(S.commands,T.visibleCommands(S),(L)=>L.helpGroup()||"Commands:").forEach((L,H)=>{let X=L.map((G)=>{return I(T.styleSubcommandTerm(T.subcommandTerm(G)),T.styleSubcommandDescription(T.subcommandDescription(G)))});Z=Z.concat(this.formatItemList(H,X,T))}),Z.join(` `)}displayWidth(S){return sz(S).length}styleTitle(S){return S}styleUsage(S){return S.split(" ").map((T)=>{if(T==="[options]")return this.styleOptionText(T);if(T==="[command]")return this.styleSubcommandText(T);if(T[0]==="["||T[0]==="<")return this.styleArgumentText(T);return this.styleCommandText(T)}).join(" ")}styleCommandDescription(S){return this.styleDescriptionText(S)}styleOptionDescription(S){return this.styleDescriptionText(S)}styleSubcommandDescription(S){return this.styleDescriptionText(S)}styleArgumentDescription(S){return this.styleDescriptionText(S)}styleDescriptionText(S){return S}styleOptionTerm(S){return this.styleOptionText(S)}styleSubcommandTerm(S){return S.split(" ").map((T)=>{if(T==="[options]")return this.styleOptionText(T);if(T[0]==="["||T[0]==="<")return this.styleArgumentText(T);return this.styleSubcommandText(T)}).join(" ")}styleArgumentTerm(S){return this.styleArgumentText(S)}styleOptionText(S){return S}styleArgumentText(S){return S}styleSubcommandText(S){return S}styleCommandText(S){return S}padWidth(S,T){return Math.max(T.longestOptionTermLength(S,T),T.longestGlobalOptionTermLength(S,T),T.longestSubcommandTermLength(S,T),T.longestArgumentTermLength(S,T))}preformatted(S){return/\n[^\S\r\n]/.test(S)}formatItem(S,T,U,J){let Z=" ".repeat(2);if(!U)return Z+S;let z=S.padEnd(T+S.length-J.displayWidth(S)),$=2,N=(this.helpWidth??80)-T-$-2,L;if(N<this.minWidthToWrap||J.preformatted(U))L=U;else L=J.boxWrap(U,N).replace(/\n/g,` `+" ".repeat(T+$));return Z+z+" ".repeat($)+L.replace(/\n/g,` ${Z}`)}boxWrap(S,T){if(T<this.minWidthToWrap)return S;let U=S.split(/\r\n|\n/),J=/[\s]*[^\s]+/g,I=[];return U.forEach((Z)=>{let z=Z.match(J);if(z===null){I.push("");return}let $=[z.shift()],Q=this.displayWidth($[0]);z.forEach((N)=>{let L=this.displayWidth(N);if(Q+L<=T){$.push(N),Q+=L;return}I.push($.join(""));let H=N.trimStart();$=[H],Q=this.displayWidth(H)}),I.push($.join(""))}),I.join(` `)}}function sz(S){let T=/\x1b\[\d*(;\d*)*m/g;return S.replace(T,"")}P4.Help=tz;P4.stripColor=sz});var jJ=h0((D4)=>{var{InvalidArgumentError:_4}=rT();class ez{constructor(S,T){this.flags=S,this.description=T||"",this.required=S.includes("<"),this.optional=S.includes("["),this.variadic=/\w\.\.\.[>\]]$/.test(S),this.mandatory=!1;let U=j4(S);if(this.short=U.shortFlag,this.long=U.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(S,T){return this.defaultValue=S,this.defaultValueDescription=T,this}preset(S){return this.presetArg=S,this}conflicts(S){return this.conflictsWith=this.conflictsWith.concat(S),this}implies(S){let T=S;if(typeof S==="string")T={[S]:!0};return this.implied=Object.assign(this.implied||{},T),this}env(S){return this.envVar=S,this}argParser(S){return this.parseArg=S,this}makeOptionMandatory(S=!0){return this.mandatory=!!S,this}hideHelp(S=!0){return this.hidden=!!S,this}_collectValue(S,T){if(T===this.defaultValue||!Array.isArray(T))return[S];return T.push(S),T}choices(S){return this.argChoices=S.slice(),this.parseArg=(T,U)=>{if(!this.argChoices.includes(T))throw new _4(`Allowed choices are ${this.argChoices.join(", ")}.`);if(this.variadic)return this._collectValue(T,U);return T},this}name(){if(this.long)return this.long.replace(/^--/,"");return this.short.replace(/^-/,"")}attributeName(){if(this.negate)return oz(this.name().replace(/^no-/,""));return oz(this.name())}helpGroup(S){return this.helpGroupHeading=S,this}is(S){return this.short===S||this.long===S}isBoolean(){return!this.required&&!this.optional&&!this.negate}}class SZ{constructor(S){this.positiveOptions=new Map,this.negativeOptions=new Map,this.dualOptions=new Set,S.forEach((T)=>{if(T.negate)this.negativeOptions.set(T.attributeName(),T);else this.positiveOptions.set(T.attributeName(),T)}),this.negativeOptions.forEach((T,U)=>{if(this.positiveOptions.has(U))this.dualOptions.add(U)})}valueFromOption(S,T){let U=T.attributeName();if(!this.dualOptions.has(U))return!0;let J=this.negativeOptions.get(U).presetArg,I=J!==void 0?J:!1;return T.negate===(I===S)}}function oz(S){return S.split("-").reduce((T,U)=>{return T+U[0].toUpperCase()+U.slice(1)})}function j4(S){let T,U,J=/^-[^-]$/,I=/^--[^-]/,Z=S.split(/[ |,]+/).concat("guard");if(J.test(Z[0]))T=Z.shift();if(I.test(Z[0]))U=Z.shift();if(!T&&J.test(Z[0]))T=Z.shift();if(!T&&I.test(Z[0]))T=U,U=Z.shift();if(Z[0].startsWith("-")){let z=Z[0],$=`option creation failed due to '${z}' in option flags '${S}'`;if(/^-[^-][^-]/.test(z))throw Error(`${$} - 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(J.test(z))throw Error(`${$} - too many short flags`);if(I.test(z))throw Error(`${$} - too many long flags`);throw Error(`${$} - unrecognised flag format`)}if(T===void 0&&U===void 0)throw Error(`option creation failed due to no flags found in '${S}'.`);return{shortFlag:T,longFlag:U}}D4.Option=ez;D4.DualOptions=SZ});var TZ=h0((v4)=>{function b4(S,T){if(Math.abs(S.length-T.length)>3)return Math.max(S.length,T.length);let U=[];for(let J=0;J<=S.length;J++)U[J]=[J];for(let J=0;J<=T.length;J++)U[0][J]=J;for(let J=1;J<=T.length;J++)for(let I=1;I<=S.length;I++){let Z=1;if(S[I-1]===T[J-1])Z=0;else Z=1;if(U[I][J]=Math.min(U[I-1][J]+1,U[I][J-1]+1,U[I-1][J-1]+Z),I>1&&J>1&&S[I-1]===T[J-2]&&S[I-2]===T[J-1])U[I][J]=Math.min(U[I][J],U[I-2][J-2]+1)}return U[S.length][T.length]}function k4(S,T){if(!T||T.length===0)return"";T=Array.from(new Set(T));let U=S.startsWith("--");if(U)S=S.slice(2),T=T.map((z)=>z.slice(2));let J=[],I=3,Z=0.4;if(T.forEach((z)=>{if(z.length<=1)return;let $=b4(S,z),Q=Math.max(S.length,z.length);if((Q-$)/Q>Z){if($<I)I=$,J=[z];else if($===I)J.push(z)}}),J.sort((z,$)=>z.localeCompare($)),U)J=J.map((z)=>`--${z}`);if(J.length>1)return` (Did you mean one of ${J.join(", ")}?)`;if(J.length===1)return` (Did you mean ${J[0]}?)`;return""}v4.suggestSimilar=k4});var zZ=h0((l4)=>{var g4=y0("node:events").EventEmitter,DJ=y0("node:child_process"),JS=y0("node:path"),r1=y0("node:fs"),A=y0("node:process"),{Argument:u4,humanReadableArgName:d4}=p1(),{CommanderError:hJ}=rT(),{Help:c4,stripColor:p4}=_J(),{Option:UZ,DualOptions:r4}=jJ(),{suggestSimilar:JZ}=TZ();class bJ extends g4{constructor(S){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=S||"",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:(T)=>A.stdout.write(T),writeErr:(T)=>A.stderr.write(T),outputError:(T,U)=>U(T),getOutHelpWidth:()=>A.stdout.isTTY?A.stdout.columns:void 0,getErrHelpWidth:()=>A.stderr.isTTY?A.stderr.columns:void 0,getOutHasColors:()=>yJ()??(A.stdout.isTTY&&A.stdout.hasColors?.()),getErrHasColors:()=>yJ()??(A.stderr.isTTY&&A.stderr.hasColors?.()),stripColor:(T)=>p4(T)},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(S){return this._outputConfiguration=S._outputConfiguration,this._helpOption=S._helpOption,this._helpCommand=S._helpCommand,this._helpConfiguration=S._helpConfiguration,this._exitCallback=S._exitCallback,this._storeOptionsAsProperties=S._storeOptionsAsProperties,this._combineFlagAndOptionalValue=S._combineFlagAndOptionalValue,this._allowExcessArguments=S._allowExcessArguments,this._enablePositionalOptions=S._enablePositionalOptions,this._showHelpAfterError=S._showHelpAfterError,this._showSuggestionAfterError=S._showSuggestionAfterError,this}_getCommandAndAncestors(){let S=[];for(let T=this;T;T=T.parent)S.push(T);return S}command(S,T,U){let J=T,I=U;if(typeof J==="object"&&J!==null)I=J,J=null;I=I||{};let[,Z,z]=S.match(/([^ ]+) *(.*)/),$=this.createCommand(Z);if(J)$.description(J),$._executableHandler=!0;if(I.isDefault)this._defaultCommandName=$._name;if($._hidden=!!(I.noHelp||I.hidden),$._executableFile=I.executableFile||null,z)$.arguments(z);if(this._registerCommand($),$.parent=this,$.copyInheritedSettings(this),J)return this;return $}createCommand(S){return new bJ(S)}createHelp(){return Object.assign(new c4,this.configureHelp())}configureHelp(S){if(S===void 0)return this._helpConfiguration;return this._helpConfiguration=S,this}configureOutput(S){if(S===void 0)return this._outputConfiguration;return this._outputConfiguration={...this._outputConfiguration,...S},this}showHelpAfterError(S=!0){if(typeof S!=="string")S=!!S;return this._showHelpAfterError=S,this}showSuggestionAfterError(S=!0){return this._showSuggestionAfterError=!!S,this}addCommand(S,T){if(!S._name)throw Error(`Command passed to .addCommand() must have a name - specify the name in Command constructor or using .name()`);if(T=T||{},T.isDefault)this._defaultCommandName=S._name;if(T.noHelp||T.hidden)S._hidden=!0;return this._registerCommand(S),S.parent=this,S._checkForBrokenPassThrough(),this}createArgument(S,T){return new u4(S,T)}argument(S,T,U,J){let I=this.createArgument(S,T);if(typeof U==="function")I.default(J).argParser(U);else I.default(U);return this.addArgument(I),this}arguments(S){return S.trim().split(/ +/).forEach((T)=>{this.argument(T)}),this}addArgument(S){let T=this.registeredArguments.slice(-1)[0];if(T?.variadic)throw Error(`only the last argument can be variadic '${T.name()}'`);if(S.required&&S.defaultValue!==void 0&&S.parseArg===void 0)throw Error(`a default value for a required argument is never used: '${S.name()}'`);return this.registeredArguments.push(S),this}helpCommand(S,T){if(typeof S==="boolean"){if(this._addImplicitHelpCommand=S,S&&this._defaultCommandGroup)this._initCommandGroup(this._getHelpCommand());return this}let U=S??"help [command]",[,J,I]=U.match(/([^ ]+) *(.*)/),Z=T??"display help for command",z=this.createCommand(J);if(z.helpOption(!1),I)z.arguments(I);if(Z)z.description(Z);if(this._addImplicitHelpCommand=!0,this._helpCommand=z,S||T)this._initCommandGroup(z);return this}addHelpCommand(S,T){if(typeof S!=="object")return this.helpCommand(S,T),this;return this._addImplicitHelpCommand=!0,this._helpCommand=S,this._initCommandGroup(S),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(S,T){let U=["preSubcommand","preAction","postAction"];if(!U.includes(S))throw Error(`Unexpected value for event passed to hook : '${S}'. Expecting one of '${U.join("', '")}'`);if(this._lifeCycleHooks[S])this._lifeCycleHooks[S].push(T);else this._lifeCycleHooks[S]=[T];return this}exitOverride(S){if(S)this._exitCallback=S;else this._exitCallback=(T)=>{if(T.code!=="commander.executeSubCommandAsync")throw T};return this}_exit(S,T,U){if(this._exitCallback)this._exitCallback(new hJ(S,T,U));A.exit(S)}action(S){let T=(U)=>{let J=this.registeredArguments.length,I=U.slice(0,J);if(this._storeOptionsAsProperties)I[J]=this;else I[J]=this.opts();return I.push(this),S.apply(this,I)};return this._actionHandler=T,this}createOption(S,T){return new UZ(S,T)}_callParseArg(S,T,U,J){try{return S.parseArg(T,U)}catch(I){if(I.code==="commander.invalidArgument"){let Z=`${J} ${I.message}`;this.error(Z,{exitCode:I.exitCode,code:I.code})}throw I}}_registerOption(S){let T=S.short&&this._findOption(S.short)||S.long&&this._findOption(S.long);if(T){let U=S.long&&this._findOption(S.long)?S.long:S.short;throw Error(`Cannot add option '${S.flags}'${this._name&&` to command '${this._name}'`} due to conflicting flag '${U}' - already used by option '${T.flags}'`)}this._initOptionGroup(S),this.options.push(S)}_registerCommand(S){let T=(J)=>{return[J.name()].concat(J.aliases())},U=T(S).find((J)=>this._findCommand(J));if(U){let J=T(this._findCommand(U)).join("|"),I=T(S).join("|");throw Error(`cannot add command '${I}' as already have command '${J}'`)}this._initCommandGroup(S),this.commands.push(S)}addOption(S){this._registerOption(S);let T=S.name(),U=S.attributeName();if(S.negate){let I=S.long.replace(/^--no-/,"--");if(!this._findOption(I))this.setOptionValueWithSource(U,S.defaultValue===void 0?!0:S.defaultValue,"default")}else if(S.defaultValue!==void 0)this.setOptionValueWithSource(U,S.defaultValue,"default");let J=(I,Z,z)=>{if(I==null&&S.presetArg!==void 0)I=S.presetArg;let $=this.getOptionValue(U);if(I!==null&&S.parseArg)I=this._callParseArg(S,I,$,Z);else if(I!==null&&S.variadic)I=S._collectValue(I,$);if(I==null)if(S.negate)I=!1;else if(S.isBoolean()||S.optional)I=!0;else I="";this.setOptionValueWithSource(U,I,z)};if(this.on("option:"+T,(I)=>{let Z=`error: option '${S.flags}' argument '${I}' is invalid.`;J(I,Z,"cli")}),S.envVar)this.on("optionEnv:"+T,(I)=>{let Z=`error: option '${S.flags}' value '${I}' from env '${S.envVar}' is invalid.`;J(I,Z,"env")});return this}_optionEx(S,T,U,J,I){if(typeof T==="object"&&T instanceof UZ)throw Error("To add an Option object use addOption() instead of option() or requiredOption()");let Z=this.createOption(T,U);if(Z.makeOptionMandatory(!!S.mandatory),typeof J==="function")Z.default(I).argParser(J);else if(J instanceof RegExp){let z=J;J=($,Q)=>{let N=z.exec($);return N?N[0]:Q},Z.default(I).argParser(J)}else Z.default(J);return this.addOption(Z)}option(S,T,U,J){return this._optionEx({},S,T,U,J)}requiredOption(S,T,U,J){return this._optionEx({mandatory:!0},S,T,U,J)}combineFlagAndOptionalValue(S=!0){return this._combineFlagAndOptionalValue=!!S,this}allowUnknownOption(S=!0){return this._allowUnknownOption=!!S,this}allowExcessArguments(S=!0){return this._allowExcessArguments=!!S,this}enablePositionalOptions(S=!0){return this._enablePositionalOptions=!!S,this}passThroughOptions(S=!0){return this._passThroughOptions=!!S,this._checkForBrokenPassThrough(),this}_checkForBrokenPassThrough(){if(this.parent&&this._passThroughOptions&&!this.parent._enablePositionalOptions)throw Error(`passThroughOptions cannot be used for '${this._name}' without turning on enablePositionalOptions for parent command(s)`)}storeOptionsAsProperties(S=!0){if(this.options.length)throw Error("call .storeOptionsAsProperties() before adding options");if(Object.keys(this._optionValues).length)throw Error("call .storeOptionsAsProperties() before setting option values");return this._storeOptionsAsProperties=!!S,this}getOptionValue(S){if(this._storeOptionsAsProperties)return this[S];return this._optionValues[S]}setOptionValue(S,T){return this.setOptionValueWithSource(S,T,void 0)}setOptionValueWithSource(S,T,U){if(this._storeOptionsAsProperties)this[S]=T;else this._optionValues[S]=T;return this._optionValueSources[S]=U,this}getOptionValueSource(S){return this._optionValueSources[S]}getOptionValueSourceWithGlobals(S){let T;return this._getCommandAndAncestors().forEach((U)=>{if(U.getOptionValueSource(S)!==void 0)T=U.getOptionValueSource(S)}),T}_prepareUserArgs(S,T){if(S!==void 0&&!Array.isArray(S))throw Error("first parameter to parse must be array or undefined");if(T=T||{},S===void 0&&T.from===void 0){if(A.versions?.electron)T.from="electron";let J=A.execArgv??[];if(J.includes("-e")||J.includes("--eval")||J.includes("-p")||J.includes("--print"))T.from="eval"}if(S===void 0)S=A.argv;this.rawArgs=S.slice();let U;switch(T.from){case void 0:case"node":this._scriptPath=S[1],U=S.slice(2);break;case"electron":if(A.defaultApp)this._scriptPath=S[1],U=S.slice(2);else U=S.slice(1);break;case"user":U=S.slice(0);break;case"eval":U=S.slice(1);break;default:throw Error(`unexpected parse option { from: '${T.from}' }`)}if(!this._name&&this._scriptPath)this.nameFromFilename(this._scriptPath);return this._name=this._name||"program",U}parse(S,T){this._prepareForParse();let U=this._prepareUserArgs(S,T);return this._parseCommand([],U),this}async parseAsync(S,T){this._prepareForParse();let U=this._prepareUserArgs(S,T);return await this._parseCommand([],U),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 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(S,T,U){if(r1.existsSync(S))return;let J=T?`searched for local subcommand relative to directory '${T}'`:"no directory for search for local subcommand, use .executableDir() to supply a custom directory",I=`'${S}' does not exist - if '${U}' 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 - ${J}`;throw Error(I)}_executeSubCommand(S,T){T=T.slice();let U=!1,J=[".js",".ts",".tsx",".mjs",".cjs"];function I(N,L){let H=JS.resolve(N,L);if(r1.existsSync(H))return H;if(J.includes(JS.extname(L)))return;let X=J.find((G)=>r1.existsSync(`${H}${G}`));if(X)return`${H}${X}`;return}this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let Z=S._executableFile||`${this._name}-${S._name}`,z=this._executableDir||"";if(this._scriptPath){let N;try{N=r1.realpathSync(this._scriptPath)}catch{N=this._scriptPath}z=JS.resolve(JS.dirname(N),z)}if(z){let N=I(z,Z);if(!N&&!S._executableFile&&this._scriptPath){let L=JS.basename(this._scriptPath,JS.extname(this._scriptPath));if(L!==this._name)N=I(z,`${L}-${S._name}`)}Z=N||Z}U=J.includes(JS.extname(Z));let $;if(A.platform!=="win32")if(U)T.unshift(Z),T=IZ(A.execArgv).concat(T),$=DJ.spawn(A.argv[0],T,{stdio:"inherit"});else $=DJ.spawn(Z,T,{stdio:"inherit"});else this._checkForMissingExecutable(Z,z,S._name),T.unshift(Z),T=IZ(A.execArgv).concat(T),$=DJ.spawn(A.execPath,T,{stdio:"inherit"});if(!$.killed)["SIGUSR1","SIGUSR2","SIGTERM","SIGINT","SIGHUP"].forEach((L)=>{A.on(L,()=>{if($.killed===!1&&$.exitCode===null)$.kill(L)})});let Q=this._exitCallback;$.on("close",(N)=>{if(N=N??1,!Q)A.exit(N);else Q(new hJ(N,"commander.executeSubCommandAsync","(close)"))}),$.on("error",(N)=>{if(N.code==="ENOENT")this._checkForMissingExecutable(Z,z,S._name);else if(N.code==="EACCES")throw Error(`'${Z}' not executable`);if(!Q)A.exit(1);else{let L=new hJ(1,"commander.executeSubCommandAsync","(error)");L.nestedError=N,Q(L)}}),this.runningCommand=$}_dispatchSubcommand(S,T,U){let J=this._findCommand(S);if(!J)this.help({error:!0});J._prepareForParse();let I;return I=this._chainOrCallSubCommandHook(I,J,"preSubcommand"),I=this._chainOrCall(I,()=>{if(J._executableHandler)this._executeSubCommand(J,T.concat(U));else return J._parseCommand(T,U)}),I}_dispatchHelpCommand(S){if(!S)this.help();let T=this._findCommand(S);if(T&&!T._executableHandler)T.help();return this._dispatchSubcommand(S,[],[this._getHelpOption()?.long??this._getHelpOption()?.short??"--help"])}_checkNumberOfArguments(){if(this.registeredArguments.forEach((S,T)=>{if(S.required&&this.args[T]==null)this.missingArgument(S.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 S=(U,J,I)=>{let Z=J;if(J!==null&&U.parseArg){let z=`error: command-argument value '${J}' is invalid for argument '${U.name()}'.`;Z=this._callParseArg(U,J,I,z)}return Z};this._checkNumberOfArguments();let T=[];this.registeredArguments.forEach((U,J)=>{let I=U.defaultValue;if(U.variadic){if(J<this.args.length){if(I=this.args.slice(J),U.parseArg)I=I.reduce((Z,z)=>{return S(U,z,Z)},U.defaultValue)}else if(I===void 0)I=[]}else if(J<this.args.length){if(I=this.args[J],U.parseArg)I=S(U,I,U.defaultValue)}T[J]=I}),this.processedArgs=T}_chainOrCall(S,T){if(S?.then&&typeof S.then==="function")return S.then(()=>T());return T()}_chainOrCallHooks(S,T){let U=S,J=[];if(this._getCommandAndAncestors().reverse().filter((I)=>I._lifeCycleHooks[T]!==void 0).forEach((I)=>{I._lifeCycleHooks[T].forEach((Z)=>{J.push({hookedCommand:I,callback:Z})})}),T==="postAction")J.reverse();return J.forEach((I)=>{U=this._chainOrCall(U,()=>{return I.callback(I.hookedCommand,this)})}),U}_chainOrCallSubCommandHook(S,T,U){let J=S;if(this._lifeCycleHooks[U]!==void 0)this._lifeCycleHooks[U].forEach((I)=>{J=this._chainOrCall(J,()=>{return I(this,T)})});return J}_parseCommand(S,T){let U=this.parseOptions(T);if(this._parseOptionsEnv(),this._parseOptionsImplied(),S=S.concat(U.operands),T=U.unknown,this.args=S.concat(T),S&&this._findCommand(S[0]))return this._dispatchSubcommand(S[0],S.slice(1),T);if(this._getHelpCommand()&&S[0]===this._getHelpCommand().name())return this._dispatchHelpCommand(S[1]);if(this._defaultCommandName)return this._outputHelpIfRequested(T),this._dispatchSubcommand(this._defaultCommandName,S,T);if(this.commands.length&&this.args.length===0&&!this._actionHandler&&!this._defaultCommandName)this.help({error:!0});this._outputHelpIfRequested(U.unknown),this._checkForMissingMandatoryOptions(),this._checkForConflictingOptions();let J=()=>{if(U.unknown.length>0)this.unknownOption(U.unknown[0])},I=`command:${this.name()}`;if(this._actionHandler){J(),this._processArguments();let Z;if(Z=this._chainOrCallHooks(Z,"preAction"),Z=this._chainOrCall(Z,()=>this._actionHandler(this.processedArgs)),this.parent)Z=this._chainOrCall(Z,()=>{this.parent.emit(I,S,T)});return Z=this._chainOrCallHooks(Z,"postAction"),Z}if(this.parent?.listenerCount(I))J(),this._processArguments(),this.parent.emit(I,S,T);else if(S.length){if(this._findCommand("*"))return this._dispatchSubcommand("*",S,T);if(this.listenerCount("command:*"))this.emit("command:*",S,T);else if(this.commands.length)this.unknownCommand();else J(),this._processArguments()}else if(this.commands.length)J(),this.help({error:!0});else J(),this._processArguments()}_findCommand(S){if(!S)return;return this.commands.find((T)=>T._name===S||T._aliases.includes(S))}_findOption(S){return this.options.find((T)=>T.is(S))}_checkForMissingMandatoryOptions(){this._getCommandAndAncestors().forEach((S)=>{S.options.forEach((T)=>{if(T.mandatory&&S.getOptionValue(T.attributeName())===void 0)S.missingMandatoryOptionValue(T)})})}_checkForConflictingLocalOptions(){let S=this.options.filter((U)=>{let J=U.attributeName();if(this.getOptionValue(J)===void 0)return!1;return this.getOptionValueSource(J)!=="default"});S.filter((U)=>U.conflictsWith.length>0).forEach((U)=>{let J=S.find((I)=>U.conflictsWith.includes(I.attributeName()));if(J)this._conflictingOption(U,J)})}_checkForConflictingOptions(){this._getCommandAndAncestors().forEach((S)=>{S._checkForConflictingLocalOptions()})}parseOptions(S){let T=[],U=[],J=T;function I(N){return N.length>1&&N[0]==="-"}let Z=(N)=>{if(!/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/.test(N))return!1;return!this._getCommandAndAncestors().some((L)=>L.options.map((H)=>H.short).some((H)=>/^-\d$/.test(H)))},z=null,$=null,Q=0;while(Q<S.length||$){let N=$??S[Q++];if($=null,N==="--"){if(J===U)J.push(N);J.push(...S.slice(Q));break}if(z&&(!I(N)||Z(N))){this.emit(`option:${z.name()}`,N);continue}if(z=null,I(N)){let L=this._findOption(N);if(L){if(L.required){let H=S[Q++];if(H===void 0)this.optionMissingArgument(L);this.emit(`option:${L.name()}`,H)}else if(L.optional){let H=null;if(Q<S.length&&(!I(S[Q])||Z(S[Q])))H=S[Q++];this.emit(`option:${L.name()}`,H)}else this.emit(`option:${L.name()}`);z=L.variadic?L:null;continue}}if(N.length>2&&N[0]==="-"&&N[1]!=="-"){let L=this._findOption(`-${N[1]}`);if(L){if(L.required||L.optional&&this._combineFlagAndOptionalValue)this.emit(`option:${L.name()}`,N.slice(2));else this.emit(`option:${L.name()}`),$=`-${N.slice(2)}`;continue}}if(/^--[^=]+=/.test(N)){let L=N.indexOf("="),H=this._findOption(N.slice(0,L));if(H&&(H.required||H.optional)){this.emit(`option:${H.name()}`,N.slice(L+1));continue}}if(J===T&&I(N)&&!(this.commands.length===0&&Z(N)))J=U;if((this._enablePositionalOptions||this._passThroughOptions)&&T.length===0&&U.length===0){if(this._findCommand(N)){T.push(N),U.push(...S.slice(Q));break}else if(this._getHelpCommand()&&N===this._getHelpCommand().name()){T.push(N,...S.slice(Q));break}else if(this._defaultCommandName){U.push(N,...S.slice(Q));break}}if(this._passThroughOptions){J.push(N,...S.slice(Q));break}J.push(N)}return{operands:T,unknown:U}}opts(){if(this._storeOptionsAsProperties){let S={},T=this.options.length;for(let U=0;U<T;U++){let J=this.options[U].attributeName();S[J]=J===this._versionOptionName?this._version:this[J]}return S}return this._optionValues}optsWithGlobals(){return this._getCommandAndAncestors().reduce((S,T)=>Object.assign(S,T.opts()),{})}error(S,T){if(this._outputConfiguration.outputError(`${S} `,this._outputConfiguration.writeErr),typeof this._showHelpAfterError==="string")this._outputConfiguration.writeErr(`${this._showHelpAfterError} `);else if(this._showHelpAfterError)this._outputConfiguration.writeErr(` `),this.outputHelp({error:!0});let U=T||{},J=U.exitCode||1,I=U.code||"commander.error";this._exit(J,I,S)}_parseOptionsEnv(){this.options.forEach((S)=>{if(S.envVar&&S.envVar in A.env){let T=S.attributeName();if(this.getOptionValue(T)===void 0||["default","config","env"].includes(this.getOptionValueSource(T)))if(S.required||S.optional)this.emit(`optionEnv:${S.name()}`,A.env[S.envVar]);else this.emit(`optionEnv:${S.name()}`)}})}_parseOptionsImplied(){let S=new r4(this.options),T=(U)=>{return this.getOptionValue(U)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(U))};this.options.filter((U)=>U.implied!==void 0&&T(U.attributeName())&&S.valueFromOption(this.getOptionValue(U.attributeName()),U)).forEach((U)=>{Object.keys(U.implied).filter((J)=>!T(J)).forEach((J)=>{this.setOptionValueWithSource(J,U.implied[J],"implied")})})}missingArgument(S){let T=`error: missing required argument '${S}'`;this.error(T,{code:"commander.missingArgument"})}optionMissingArgument(S){let T=`error: option '${S.flags}' argument missing`;this.error(T,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(S){let T=`error: required option '${S.flags}' not specified`;this.error(T,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(S,T){let U=(Z)=>{let z=Z.attributeName(),$=this.getOptionValue(z),Q=this.options.find((L)=>L.negate&&z===L.attributeName()),N=this.options.find((L)=>!L.negate&&z===L.attributeName());if(Q&&(Q.presetArg===void 0&&$===!1||Q.presetArg!==void 0&&$===Q.presetArg))return Q;return N||Z},J=(Z)=>{let z=U(Z),$=z.attributeName();if(this.getOptionValueSource($)==="env")return`environment variable '${z.envVar}'`;return`option '${z.flags}'`},I=`error: ${J(S)} cannot be used with ${J(T)}`;this.error(I,{code:"commander.conflictingOption"})}unknownOption(S){if(this._allowUnknownOption)return;let T="";if(S.startsWith("--")&&this._showSuggestionAfterError){let J=[],I=this;do{let Z=I.createHelp().visibleOptions(I).filter((z)=>z.long).map((z)=>z.long);J=J.concat(Z),I=I.parent}while(I&&!I._enablePositionalOptions);T=JZ(S,J)}let U=`error: unknown option '${S}'${T}`;this.error(U,{code:"commander.unknownOption"})}_excessArguments(S){if(this._allowExcessArguments)return;let T=this.registeredArguments.length,U=T===1?"":"s",I=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${T} argument${U} but got ${S.length}.`;this.error(I,{code:"commander.excessArguments"})}unknownCommand(){let S=this.args[0],T="";if(this._showSuggestionAfterError){let J=[];this.createHelp().visibleCommands(this).forEach((I)=>{if(J.push(I.name()),I.alias())J.push(I.alias())}),T=JZ(S,J)}let U=`error: unknown command '${S}'${T}`;this.error(U,{code:"commander.unknownCommand"})}version(S,T,U){if(S===void 0)return this._version;this._version=S,T=T||"-V, --version",U=U||"output the version number";let J=this.createOption(T,U);return this._versionOptionName=J.attributeName(),this._registerOption(J),this.on("option:"+J.name(),()=>{this._outputConfiguration.writeOut(`${S} `),this._exit(0,"commander.version",S)}),this}description(S,T){if(S===void 0&&T===void 0)return this._description;if(this._description=S,T)this._argsDescription=T;return this}summary(S){if(S===void 0)return this._summary;return this._summary=S,this}alias(S){if(S===void 0)return this._aliases[0];let T=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler)T=this.commands[this.commands.length-1];if(S===T._name)throw Error("Command alias can't be the same as its name");let U=this.parent?._findCommand(S);if(U){let J=[U.name()].concat(U.aliases()).join("|");throw Error(`cannot add alias '${S}' to command '${this.name()}' as already have command '${J}'`)}return T._aliases.push(S),this}aliases(S){if(S===void 0)return this._aliases;return S.forEach((T)=>this.alias(T)),this}usage(S){if(S===void 0){if(this._usage)return this._usage;let T=this.registeredArguments.map((U)=>{return d4(U)});return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?T:[]).join(" ")}return this._usage=S,this}name(S){if(S===void 0)return this._name;return this._name=S,this}helpGroup(S){if(S===void 0)return this._helpGroupHeading??"";return this._helpGroupHeading=S,this}commandsGroup(S){if(S===void 0)return this._defaultCommandGroup??"";return this._defaultCommandGroup=S,this}optionsGroup(S){if(S===void 0)return this._defaultOptionGroup??"";return this._defaultOptionGroup=S,this}_initOptionGroup(S){if(this._defaultOptionGroup&&!S.helpGroupHeading)S.helpGroup(this._defaultOptionGroup)}_initCommandGroup(S){if(this._defaultCommandGroup&&!S.helpGroup())S.helpGroup(this._defaultCommandGroup)}nameFromFilename(S){return this._name=JS.basename(S,JS.extname(S)),this}executableDir(S){if(S===void 0)return this._executableDir;return this._executableDir=S,this}helpInformation(S){let T=this.createHelp(),U=this._getOutputContext(S);T.prepareContext({error:U.error,helpWidth:U.helpWidth,outputHasColors:U.hasColors});let J=T.formatHelp(this,T);if(U.hasColors)return J;return this._outputConfiguration.stripColor(J)}_getOutputContext(S){S=S||{};let T=!!S.error,U,J,I;if(T)U=(z)=>this._outputConfiguration.writeErr(z),J=this._outputConfiguration.getErrHasColors(),I=this._outputConfiguration.getErrHelpWidth();else U=(z)=>this._outputConfiguration.writeOut(z),J=this._outputConfiguration.getOutHasColors(),I=this._outputConfiguration.getOutHelpWidth();return{error:T,write:(z)=>{if(!J)z=this._outputConfiguration.stripColor(z);return U(z)},hasColors:J,helpWidth:I}}outputHelp(S){let T;if(typeof S==="function")T=S,S=void 0;let U=this._getOutputContext(S),J={error:U.error,write:U.write,command:this};this._getCommandAndAncestors().reverse().forEach((Z)=>Z.emit("beforeAllHelp",J)),this.emit("beforeHelp",J);let I=this.helpInformation({error:U.error});if(T){if(I=T(I),typeof I!=="string"&&!Buffer.isBuffer(I))throw Error("outputHelp callback must return a string or a Buffer")}if(U.write(I),this._getHelpOption()?.long)this.emit(this._getHelpOption().long);this.emit("afterHelp",J),this._getCommandAndAncestors().forEach((Z)=>Z.emit("afterAllHelp",J))}helpOption(S,T){if(typeof S==="boolean"){if(S){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(S??"-h, --help",T??"display help for command"),S||T)this._initOptionGroup(this._helpOption);return this}_getHelpOption(){if(this._helpOption===void 0)this.helpOption(void 0,void 0);return this._helpOption}addHelpOption(S){return this._helpOption=S,this._initOptionGroup(S),this}help(S){this.outputHelp(S);let T=Number(A.exitCode??0);if(T===0&&S&&typeof S!=="function"&&S.error)T=1;this._exit(T,"commander.help","(outputHelp)")}addHelpText(S,T){let U=["beforeAll","before","after","afterAll"];if(!U.includes(S))throw Error(`Unexpected value for position to addHelpText. Expecting one of '${U.join("', '")}'`);let J=`${S}Help`;return this.on(J,(I)=>{let Z;if(typeof T==="function")Z=T({error:I.error,command:I.command});else Z=T;if(Z)I.write(`${Z} `)}),this}_outputHelpIfRequested(S){let T=this._getHelpOption();if(T&&S.find((J)=>T.is(J)))this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)")}}function IZ(S){return S.map((T)=>{if(!T.startsWith("--inspect"))return T;let U,J="127.0.0.1",I="9229",Z;if((Z=T.match(/^(--inspect(-brk)?)$/))!==null)U=Z[1];else if((Z=T.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null)if(U=Z[1],/^\d+$/.test(Z[3]))I=Z[3];else J=Z[3];else if((Z=T.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null)U=Z[1],J=Z[3],I=Z[4];if(U&&I!=="0")return`${U}=${J}:${parseInt(I)+1}`;return T})}function yJ(){if(A.env.NO_COLOR||A.env.FORCE_COLOR==="0"||A.env.FORCE_COLOR==="false")return!1;if(A.env.FORCE_COLOR||A.env.CLICOLOR_FORCE!==void 0)return!0;return}l4.Command=bJ;l4.useColor=yJ});var NZ=h0((s4)=>{var{Argument:ZZ}=p1(),{Command:kJ}=zZ(),{CommanderError:a4,InvalidArgumentError:$Z}=rT(),{Help:t4}=_J(),{Option:QZ}=jJ();s4.program=new kJ;s4.createCommand=(S)=>new kJ(S);s4.createOption=(S,T)=>new QZ(S,T);s4.createArgument=(S,T)=>new ZZ(S,T);s4.Command=kJ;s4.Option=QZ;s4.Argument=ZZ;s4.Help=t4;s4.CommanderError=a4;s4.InvalidArgumentError=$Z;s4.InvalidOptionArgumentError=$Z});var H6=h0(($V,AN)=>{AN.exports={name:"dotenv",version:"17.2.3",description:"Loads environment variables from .env file",main:"lib/main.js",types:"lib/main.d.ts",exports:{".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},scripts:{"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard",pretest:"npm run lint && npm run dts-check",test:"tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000","test:coverage":"tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",prerelease:"npm test",release:"standard-version"},repository:{type:"git",url:"git://github.com/motdotla/dotenv.git"},homepage:"https://github.com/motdotla/dotenv#readme",funding:"https://dotenvx.com",keywords:["dotenv","env",".env","environment","variables","config","settings"],readmeFilename:"README.md",license:"BSD-2-Clause",devDependencies:{"@types/node":"^18.11.3",decache:"^4.6.2",sinon:"^14.0.1",standard:"^17.0.0","standard-version":"^9.5.0",tap:"^19.2.0",typescript:"^4.8.4"},engines:{node:">=12"},browser:{fs:!1}}});var E6=h0((QV,HS)=>{var BI=y0("fs"),dU=y0("path"),qN=y0("os"),CN=y0("crypto"),PN=H6(),OI=PN.version,X6=["\uD83D\uDD10 encrypt with Dotenvx: https://dotenvx.com","\uD83D\uDD10 prevent committing .env to code: https://dotenvx.com/precommit","\uD83D\uDD10 prevent building .env in docker: https://dotenvx.com/prebuild","\uD83D\uDCE1 add observability to secrets: https://dotenvx.com/ops","\uD83D\uDC65 sync secrets across teammates & machines: https://dotenvx.com/ops","\uD83D\uDDC2️ backup and recover secrets: https://dotenvx.com/ops","✅ audit secrets and track compliance: https://dotenvx.com/ops","\uD83D\uDD04 add secrets lifecycle management: https://dotenvx.com/ops","\uD83D\uDD11 add access controls to secrets: https://dotenvx.com/ops","\uD83D\uDEE0️ run anywhere with `dotenvx run -- yourcommand`","⚙️ specify custom .env file path with { path: '/custom/path/.env' }","⚙️ enable debug logging with { debug: true }","⚙️ override existing env vars with { override: true }","⚙️ suppress all logs with { quiet: true }","⚙️ write to custom object with { processEnv: myObject }","⚙️ load multiple .env files with { path: ['.env.local', '.env'] }"];function FN(){return X6[Math.floor(Math.random()*X6.length)]}function FT(S){if(typeof S==="string")return!["false","0","no","off",""].includes(S.toLowerCase());return Boolean(S)}function xN(){return process.stdout.isTTY}function _N(S){return xN()?`\x1B[2m${S}\x1B[0m`:S}var jN=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function DN(S){let T={},U=S.toString();U=U.replace(/\r\n?/mg,` `);let J;while((J=jN.exec(U))!=null){let I=J[1],Z=J[2]||"";Z=Z.trim();let z=Z[0];if(Z=Z.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),z==='"')Z=Z.replace(/\\n/g,` `),Z=Z.replace(/\\r/g,"\r");T[I]=Z}return T}function hN(S){S=S||{};let T=O6(S);S.path=T;let U=a.configDotenv(S);if(!U.parsed){let z=Error(`MISSING_DATA: Cannot parse ${T} for an unknown reason`);throw z.code="MISSING_DATA",z}let J=B6(S).split(","),I=J.length,Z;for(let z=0;z<I;z++)try{let $=J[z].trim(),Q=bN(U,$);Z=a.decrypt(Q.ciphertext,Q.key);break}catch($){if(z+1>=I)throw $}return a.parse(Z)}function yN(S){console.error(`[dotenv@${OI}][WARN] ${S}`)}function q1(S){console.log(`[dotenv@${OI}][DEBUG] ${S}`)}function Y6(S){console.log(`[dotenv@${OI}] ${S}`)}function B6(S){if(S&&S.DOTENV_KEY&&S.DOTENV_KEY.length>0)return S.DOTENV_KEY;if(process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0)return process.env.DOTENV_KEY;return""}function bN(S,T){let U;try{U=new URL(T)}catch($){if($.code==="ERR_INVALID_URL"){let Q=Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw Q.code="INVALID_DOTENV_KEY",Q}throw $}let J=U.password;if(!J){let $=Error("INVALID_DOTENV_KEY: Missing key part");throw $.code="INVALID_DOTENV_KEY",$}let I=U.searchParams.get("environment");if(!I){let $=Error("INVALID_DOTENV_KEY: Missing environment part");throw $.code="INVALID_DOTENV_KEY",$}let Z=`DOTENV_VAULT_${I.toUpperCase()}`,z=S.parsed[Z];if(!z){let $=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${Z} in your .env.vault file.`);throw $.code="NOT_FOUND_DOTENV_ENVIRONMENT",$}return{ciphertext:z,key:J}}function O6(S){let T=null;if(S&&S.path&&S.path.length>0)if(Array.isArray(S.path)){for(let U of S.path)if(BI.existsSync(U))T=U.endsWith(".vault")?U:`${U}.vault`}else T=S.path.endsWith(".vault")?S.path:`${S.path}.vault`;else T=dU.resolve(process.cwd(),".env.vault");if(BI.existsSync(T))return T;return null}function G6(S){return S[0]==="~"?dU.join(qN.homedir(),S.slice(1)):S}function kN(S){let T=FT(process.env.DOTENV_CONFIG_DEBUG||S&&S.debug),U=FT(process.env.DOTENV_CONFIG_QUIET||S&&S.quiet);if(T||!U)Y6("Loading env from encrypted .env.vault");let J=a._parseVault(S),I=process.env;if(S&&S.processEnv!=null)I=S.processEnv;return a.populate(I,J,S),{parsed:J}}function vN(S){let T=dU.resolve(process.cwd(),".env"),U="utf8",J=process.env;if(S&&S.processEnv!=null)J=S.processEnv;let I=FT(J.DOTENV_CONFIG_DEBUG||S&&S.debug),Z=FT(J.DOTENV_CONFIG_QUIET||S&&S.quiet);if(S&&S.encoding)U=S.encoding;else if(I)q1("No encoding is specified. UTF-8 is used by default");let z=[T];if(S&&S.path)if(!Array.isArray(S.path))z=[G6(S.path)];else{z=[];for(let L of S.path)z.push(G6(L))}let $,Q={};for(let L of z)try{let H=a.parse(BI.readFileSync(L,{encoding:U}));a.populate(Q,H,S)}catch(H){if(I)q1(`Failed to load ${L} ${H.message}`);$=H}let N=a.populate(J,Q,S);if(I=FT(J.DOTENV_CONFIG_DEBUG||I),Z=FT(J.DOTENV_CONFIG_QUIET||Z),I||!Z){let L=Object.keys(N).length,H=[];for(let X of z)try{let G=dU.relative(process.cwd(),X);H.push(G)}catch(G){if(I)q1(`Failed to load ${X} ${G.message}`);$=G}Y6(`injecting env (${L}) from ${H.join(",")} ${_N(`-- tip: ${FN()}`)}`)}if($)return{parsed:Q,error:$};else return{parsed:Q}}function mN(S){if(B6(S).length===0)return a.configDotenv(S);let T=O6(S);if(!T)return yN(`You set DOTENV_KEY but you are missing a .env.vault file at ${T}. Did you forget to build it?`),a.configDotenv(S);return a._configVault(S)}function gN(S,T){let U=Buffer.from(T.slice(-64),"hex"),J=Buffer.from(S,"base64"),I=J.subarray(0,12),Z=J.subarray(-16);J=J.subarray(12,-16);try{let z=CN.createDecipheriv("aes-256-gcm",U,I);return z.setAuthTag(Z),`${z.update(J)}${z.final()}`}catch(z){let $=z instanceof RangeError,Q=z.message==="Invalid key length",N=z.message==="Unsupported state or unable to authenticate data";if($||Q){let L=Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw L.code="INVALID_DOTENV_KEY",L}else if(N){let L=Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw L.code="DECRYPTION_FAILED",L}else throw z}}function uN(S,T,U={}){let J=Boolean(U&&U.debug),I=Boolean(U&&U.override),Z={};if(typeof T!=="object"){let z=Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw z.code="OBJECT_REQUIRED",z}for(let z of Object.keys(T))if(Object.prototype.hasOwnProperty.call(S,z)){if(I===!0)S[z]=T[z],Z[z]=T[z];if(J)if(I===!0)q1(`"${z}" is already defined and WAS overwritten`);else q1(`"${z}" is already defined and was NOT overwritten`)}else S[z]=T[z],Z[z]=T[z];return Z}var a={configDotenv:vN,_configVault:kN,_parseVault:hN,config:mN,decrypt:gN,parse:DN,populate:uN};QV.confi